Repository navigation
fix(gate): fail the unit gate closed, and cache only what it can prove (#150) - #179
Merged
Merged
Conversation
#150) Vitest's exit status was returned by runSuite and never read, so a non-zero exit that the report did not explain was green. The rule is now the CI twin's (check-unit-shard-verdict): a non-zero exit fails the gate only when neither the report nor the log explains it. The declared-vs-read unhandled count drops '>' for '!==' for the same reason, and a step that could not be spawned names the step instead of reading as failed. A cached verdict now records the gate inputs it was computed against — GATE_INPUT_PATHS plus the installed node and bun — and both readers compare them, because the machine-bound sqlite-binding and host-toolchain classes move with a bun upgrade that HEAD never sees. What may be reused or recorded is a decision with a reason: --no-cache forces a re-run and still records it, --allow-dirty neither reuses nor records, forwarded selectors record nothing, and HEAD and the tree are re-read before writing so a mid-run commit cannot become the previous revision's verdict. A forwarded selector's summary line now says it is not a gate-1 verdict, because it printed the same shape as one. The flake waiver asked only whether the test file was in the diff, so a branch that changed src/x.ts and broke x.test.ts one run in ten waived it as 'not ours'. local/gate-flake-coupling.mjs couples a test to itself, its sibling module, its one level of imports and the harness sharedHarnessPaths derives from the config and the runner; a per-test row that passes in isolation but is still refused says why.
#150) LOCAL-PATCHES keeps the evidence for the release-tooling patch series and the known-red sets, so the gate repairs need an entry there: which of the issue's five items had already landed (#160's linked-worktree cache directory, #177's dirty-verdict refusal and shared cache module, #178's judgement module and its tests), what the new fail-closed and cache rules are, why the verdict records its gate inputs, and the coupling rule's limits. BRANCHES gets the branch entry: why it exists, its shape, its target, and its verification state.
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gate 1 of this fork's PR process is
node local/gate-unit.mjs: one full unit run, each unallowlistedfailure re-run in isolation, exit 0 only when nothing outside
local/unit-known-red.jsonfails.local/open-pr.mjsrefuses a PR without a cached PASS from it. Issue #150 listed five ways thatverdict could be wrong; three of them had already landed by the time this branch was cut (#160 fixed
the linked-worktree cache directory, #177 the dirty-verdict refusal and the shared cache module, #178
the judgment module, its tests and the missing
closeSyncimport). This branch closes the rest, and itis rebased onto
204984546dso it builds on that shape instead of against it.Vitest's exit status is read.
runSuitereturned it andevaluateonly ever consumedelapsedMs,so a non-zero exit that the report did not explain was green. The rule is now the CI twin's
(
check-unit-shard-verdict.mjs): a non-zero exit fails the gate only when neither the report nor thelog explains it. With it, the declared-vs-read unhandled count is
!==rather than>(a log yieldingmore headlines than Vitest declared is a moved log shape too), and a step that could not be spawned
names the step instead of reading as
failed.What is recorded, and what is reused, is a decision with a reason. The cached verdict records
gateInputs— a fingerprint overGATE_INPUT_PATHS(this gate, its coupling module, the shared cachemodule, the shard-verdict parser,
config/.bun-version) plus the installed node and bun — and bothreaders compare it, because the machine-bound
sqlite-bindingandhost-toolchainclasses move with abun upgrade that HEAD never sees.
--no-cacheforces a re-run and still records it (the only way astale environmental FAIL can be replaced) without parsing the cache, so it stays the way out of a
damaged file;
--allow-dirtyneither reads the cache nor records, because both would answer about thetree rather than HEAD; forwarded selectors record nothing. Before writing, HEAD and the tree are
re-read — the suite takes twenty minutes, and a commit made in that window would otherwise be recorded
as a verdict on the revision it replaced.
A forwarded selector cannot be quoted as gate 1.
-- <vitest args>still runs, but the sharedsummary line carries
partial: -- <args>andNOT a gate-1 verdict: forwarded selectors ran a subset of the suite.A flaky pass is waived only when nothing coupled to the test changed. #178 made the isolated re-run
per test, but the waiver still asked only whether the test file was in the diff, so a branch that
changed
src/x.tsand brokex.test.tsone run in ten waived it as "not ours". The newlocal/gate-flake-coupling.mjscouples a test to itself, its sibling module, its imports (one level,relative or
@renderer//@), and the whole harness:SHARED_TEST_INPUTSplus whateverconfig/vitest.config.tsandconfig/scripts/run-vitest.mjsimport, including the two inputs a parsercannot see (
config/dark-build-switches.cjs, loaded throughcreateRequire(…), andsrc/packages/process-host/, the runner's bare workspace import). A per-test row that passes inisolation and is still refused says why in the summary instead of reading as a plain UNEXPECTED
failure.
local/gate-flake-coupling.mjsis new (the coupling rule moved out ofgate-unit.mjsto stay underoxlint's 600-line budget, and two helpers each moved to
gate-verdict-cache.mjsandunit-gate-judgement.mjsfor the same reason).tests/tools/gate-unit.test.mjsis new;tests/tools/open-pr.test.mjsgains the gate-inputs refusal and a cross-reader fingerprint check.Fixes #150
Verification
node config/scripts/run-vitest.mjs run --config config/vitest.config.ts tests/tools/gate-unit.test.mjs tests/tools/open-pr.test.mjs tests/tools/unit-gate.test.mjsgate-unit.test.mjs, 2 new inopen-pr.test.mjs; #178'sunit-gate.test.mjsstill green)pnpm run check:code-quality:changedsince204984546dORCA_QUEUE_LOCKED=1 orca-queue -- /opt/homebrew/bin/pnpm tc3c0ad4e858— no type errors in 18,074 + 3,231 + 34 + 16,084 files. Not re-run on the final revision: the queued re-run sat behind other worktrees' fullgate-unitruns for 70+ minutes and never started (see below). Every file this diff touches is.mjsunderlocal/ortests/tools/, outside every tsconfiginclude, so the typechecked surface of the branch is exactly the base's; the re-run is confirmation, not a different verdict.Why gate 1 is waived here. The full suite has a known runtime trap on this machine, and the shared
orca-queuelock was held by other worktrees' fullgate-unitruns for essentially the wholeverification window (a 34-minute run was still going when this PR opened, with three jobs ahead of
mine). Recorded as not-run rather than claimed. Every changed file is
local/tooling or its tests;nothing touches product code, the allowlist or the red set. Run
orca-queue node local/gate-unit.mjson
4b7c756dcfbefore merging if you want gate 1's own PASS on record.Two environment problems found while verifying, worth fixing separately. One orphaned
post-sync.mjsheld the queue lock for 32 minutes at 0.85 s of CPU. Andorca-queuedoes not exportORCA_QUEUE_LOCKEDto the command it runs, so thepnpmshim re-queues inside a run that alreadyholds the lock and deadlocks against its own parent — reproduced four times, by me and by other
worktrees. Passing
ORCA_QUEUE_LOCKED=1makes the shim exec realpnpmwhile the outer queue stillserialises, which is how
pnpm tcran. The focused suites were run directly throughconfig/scripts/run-vitest.mjs— the same runnerpnpm testuses — because a queuedpnpm testwaited 25 minutes for the lock and hit the tool deadline.
Review
Reviewed by Opus 5.5, high (claude/opus, tool-enabled), R1–R4 over the branch's own diff: every round's blocking findings fixed, round 4's SHOULD-FIX fixed and pinned by a test, no fifth round (AGENTS.md caps the review at three rounds without your approval).
What each round changed:
timeout or a setup file and still waive its own load-only flake.
sharedHarnessPaths()now derivesthe harness from
config/vitest.config.tsandrun-vitest.mjs, plus the two inputs a parser cannotsee.
to what was actually unread (the exit status), with the residual limit stated: a partial report with
failures still explains a non-zero exit.
--no-cachecould not replace it. Now anincomplete run is never recorded and
--no-cacherecords its result.--allow-dirtycould reuse a clean cached verdict, answering about a tree the cache neversaw. The cache is not read in that mode at all.
revision's verdict. HEAD and the tree are re-checked before writing.
matchedfieldwas dead on the rows that kept it. The refusal now travels with the failure and prints as
FLAKY in isolation, but <file> is in this branch diff.blocked:line verbatim, and nothing tested thatopen-prandgate-unitfingerprint the same bytes — now a test that reads the inputs from thecommit, the same shape as the allowlist-symmetry test fix(fork): make the process surface report what it reads #177 recorded the bug for.
read from
nodeandbunon PATH, the descriptor test cleans up its temp dir, and the cache-dirprobe became an assertion instead of writing into the real gitdir.
Note for review
local/gate-verdict-cache.mjs,local/unit-gate-judgement.mjsandlocal/open-pr.mjscame fromfix(fork): make the process surface report what it reads #177/test(unit-gate): name every known red and run what upstream's unit lane runs #178 and are extended, not rewritten. The cache file name stays
(revision, allowlist)so bothreaders keep finding the same file, and the gate inputs live inside the record.
@orca/…specifiersother than process-host are skipped rather than guessed. Each can only waive a flake the branch
caused, never refuse one it did not.