← Back to Pull requests

test: pin rollout token parsing and publish safety guards #31

Closed
unknown closed this pull request without merging on Nov 25, 2026 09:44 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 09:16 UTC
Author

Two modules with no tests, where a one-line refactor would quietly corrupt stats or delete the wrong directory:

  • lib/rollout-tokens.js feeds every report's token totals.

  • - token_count events are cumulative, so only the last valid snapshot may win.
    - token_count-shaped payloads on non-event_msg records are ignored, and a later token_count with no usage doesn't clobber the total.
    - Malformed JSONL lines are skipped, a missing file gives zero usage, and negative or NaN counts become 0.
  • lib/publish.js is the only code that runs fs.rm recursively and pushes to the user's repo.

  • - Repo-slug, branch-name (--exec=, @{, .lock) and site-dir (including backslash traversal) validation.
    - Refusing to delete a work dir without the publish-clone marker.
    - The generatedAt-only no-op.
    - The add/commit/push sequence, run offline through the existing injectable git runner and tmp dirs.

    These are tests only: 9 new tests, all passing locally. (Locally, 4 suites need @inquirer/prompts installed; that's the same on main, and CI installs it.)
    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/mangeshraut712/codex-insights/pull/31" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    No production code changes; only new tests that document expected behavior for publish and token parsing.

    > Overview

    Adds test-only coverage for two previously untested modules whose behavior is safety- and stats-sensitive.

    > New test/rollout-tokens.test.js locks in how rollout JSONL is parsed: extractTokenSnapshot null/edge sanitization, last-wins cumulative totals, skipping malformed lines and non-event_msg token_count records, and zero usage when the file is missing.

    > New test/publish.test.js covers input validation for --repo, --branch, and --site-dir, refusal to recursively delete a work directory without the publish marker, skipping git commit when only generatedAt differs, and the full copy/add/commit/push flow via an injectable git recorder.

    > <sup>Reviewed by Cursor Bugbot for commit 52f672736136b2dfd901f52cac75c8577e7dbaa2. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 326 lines (+244 / -82) across 4 files Reviewer: mangeshraut712 Review duration: 28m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.65) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 326 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #31"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.2% (HIGH) · Higher = larger blast radius
    65.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.8% · Safe to merge
    25.8%