Skip to content

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

Merged
jeefy merged 1 commit into
mainfrom
quality/test-platform-resolution-guards
Oct 29, 2026
Merged

jeefy merged 1 commit into
mainfrom
quality/test-platform-resolution-guards

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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 refactor: per-event RunState on the platform; scope platform() per run #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

#607 landed platform() with two arms no suite reaches: the throw when
nothing installed a platform (src/platform/index.ts:51, 0 hits in both the
unit and the bundle coverage runs at 8878c9d) and the fall-back from an
installed scope that has no platform for the current work to the
process-wide one. Each case imports src/platform fresh so the empty slot
and the installed scope never leak into the platform setup.ts gives every
other test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2026
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 29, 2026 02:40
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the tree, not just the diff. This looks correct to me (comment only — approval is a human's call).

Verified against src/platform/index.ts at pr head b5bc038:

  • The throw case is real and previously untested: platform() is scope.get() ?? current (src/platform/index.ts:49) then throw new Error('no platform installed: …') (src/platform/index.ts:51), and grep -r "no platform installed" __tests__/ finds no other test reaching it — runState.test.ts only exercises the installed-scope concurrency path.
  • The fall-back test exercises the right arm: the flag-based scope returns undefined outside run(), so ?? current resolves to the setPlatform() value (src/platform/index.ts:49), and inside run() the scoped value wins. The three expects pin both sides plus restoration.
  • vi.resetModules() before each case means both src/platform and the adapter's copy of it come from the same fresh registry, so installPlatformScope/setPlatform act on the instance under test and nothing leaks into the platform setup.ts installs for other files. actionsPlatform() (src/adapters/actions.ts:12) builds only closures, so constructing it without a GitHub context is safe here.

Test-only, one new file, disjoint from every other held PR as the body claims. PR body matches the diff.

— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pins platform()'s two uncovered arms from #607 with fresh module imports; correctly avoids touching the shared setup platform.

@jeefy jeefy removed the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2026
@jeefy

jeefy commented Oct 29, 2026

Copy link
Copy Markdown
Member

/kind cleanup

@jeefy
jeefy merged commit 1284cb0 into main Oct 29, 2026
18 checks passed
@jeefy
jeefy deleted the quality/test-platform-resolution-guards branch October 29, 2026 15:36
@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant