← Back to Pull requests

test(platform): pin platform()'s no-platform throw and installed-scope fall-back (src/platform/index.ts:49,51) #609

Closed
unknown closed this pull request without merging on Oct 29, 2026 15:36 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 02:40 UTC
Author

Test Improvement

Adds __tests__/platform/platformGuards.test.ts, three cases for the two arms of platform() (src/platform/index.ts, added by #607) that no suite reaches:

  • the throw new Error('no platform installed: …') on line 51 when nothing has installed a platform;

  • the ?? current fall-back on line 49, from an installed PlatformScope whose get() has no platform for the current work (an adapter's AsyncLocalStorage outside any run) to the process-wide value — and the throw when that fall-back is empty too.
  • Each case imports src/platform fresh (vi.resetModules() before and after) so the empty slot and the installed scope never touch the platform setup.ts gives every other test; the scope used is a tiny flag-based one rather than AsyncLocalStorage because the arm under test is "scope has nothing", not concurrency, which runState.test.ts already pins.

    Why. Both coverage runs at main@8878c9d report the same miss — unit (local, and CI artifact coverage-8878c9d… of run 40801080844): DA:51,0, BRDA:49,0,1,0; bundle (artifact coverage-e2e-8878c9d…, same run): DA:51,0, BRDA:49,2,1,0. The run was still green at 99.95 % lines (2470/2471) because the floor in vitest.config.mjs is 99, so a guard written today landed with no test able to notice it being removed. Whether that floor should now be 100 lines is a maintainer call recorded as a folded finding on the coverage tracker; this PR only closes the gap.

    Files / cluster claimed — one new file, __tests__/platform/platformGuards.test.ts. Disjoint from every held PR: #591/#593/#597 (plugin, dispatcher, label tests), #595 (setup.ts, config type guards), #596 (bundle scenario), #598 (testUtils.ts, ordering), #599 (tsconfig.test.json), #601 (coverageIgnoreHints.test.ts), #603 (runtime.test.ts), #605 (setupQuietActionsCore.ts). No src/, dist/, config or docs file is touched.

    Testing

  • npx vitest run __tests__/platform — 4 files, 20 passed

  • npx vitest run --coverage --exclude '__tests__/bundle/' — 106 files, 1954 passed / 75 skipped; Lines 100 % (2471/2471)*, branches 99.76 % (the four remaining arm misses — close.ts:37, reopen.ts:34, approve.ts:502, auth.ts:224 — predate #607 and are not touched here)

  • npx eslint __tests__/platform/platformGuards.test.ts — clean

  • removing the ?? current fall-back from platform() fails "falls back to the process-wide platform…"; replacing the throw with return found as Platform fails both throw cases
  • ---
    Filed by quality agent (hold-gated mode). Human review required.*

    — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

    Diff: 342 lines (+256 / -86) across 4 files Reviewer: jeefy Review duration: 776m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 342 lines diff across 4 files
    0.42
    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%
    56%
    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.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #609"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    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: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 18.3% · Safe to merge
    18.3%