Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): bound the bug lane fan-out and scope the host-contract checker (#3942)

Andrew Mikofalvye42bcae73383
diff --git a/.github/scripts/bug-lane-failure-extraction.test.mjs b/.github/scripts/bug-lane-failure-extraction.test.mjs
index 4ce28f25f..f66b83395 100644
--- a/.github/scripts/bug-lane-failure-extraction.test.mjs
+++ b/.github/scripts/bug-lane-failure-extraction.test.mjs
@@ -28,6 +28,41 @@ const workflow = readFileSync(join(REPO_ROOT, '.github', 'workflows', 'bug-lane-
const scratch = mkdtempSync(join(tmpdir(), 'bug-lane-extraction-'));
afterAll(() => rmSync(scratch, { recursive: true, force: true }));
+/**
+ * The verify step's own shell options, lifted rather than pasted.
+ *
+ * `pipefail` is load-bearing for the chain below, not housekeeping: without it
+ * `timeout … | tee "$RETRY_LOG"` reports tee's status, which is 0 whenever the
+ * log is writable, so a genuinely red retry takes the `then` arm, clears
+ * RETRY_STATUS, and mints a PASS that dispatches a release. Pasting a copy here
+ * would supply the option the shipped step is supposed to prove it sets.
+ */
+function shellOptions() {
+ const lines = workflow.split('\n');
+ // Scoped to the verify step, not the file: other steps set their own options,
+ // and finding one of those would let this step lose pipefail unnoticed --
+ // which is the whole failure being guarded against.
+ const step = lines.findIndex((line) => line.includes('- name: Verify the synthetic tree'));
+ const next = lines.findIndex((line, i) => i > step && /^ {6}- name:/.test(line));
+ const line = lines
+ .slice(step, next === -1 ? undefined : next)
+ .find((candidate) => candidate.trim().startsWith('set -'));
+ // Separate messages because these are separate failures: a renamed step and a
+ // dropped option need different fixes, and one diagnostic naming both would
+ // report the wrong cause for whichever it was not.
+ if (step === -1) {
+ throw new Error(
+ 'bug-lane-verify.yml no longer has a step named "Verify the synthetic tree", so this test cannot find the shell options it runs under. Re-anchor on the current step name.',
+ );
+ }
+ if (!line?.includes('pipefail')) {
+ throw new Error(
+ "bug-lane-verify.yml's verify step no longer sets pipefail — the retry status read depends on it, and without it a red retry mints a pass. Re-anchor this test rather than pasting the option back.",
+ );
+ }
+ return line.trim();
+}
+
/**
* The extraction block, lifted verbatim from the workflow and dedented.
*
@@ -49,13 +84,102 @@ function extractionSnippet() {
return block.map((line) => line.slice(indent)).join('\n');
}
+/**
+ * Lifts the WHOLE chain from an exit code to a verdict, starting at the
+ * RETRY_STATUS seed rather than at the mapping, because the mapping is not
+ * where a first-attempt blow is decided. That path never reaches the retry, so
+ * its status has to be propagated across the case arm first; lifting only the
+ * mapping and injecting RETRY_STATUS steps over that line entirely.
+ *
+ * Deleting it is the one mutation in this region that manufactures an
+ * APPROVAL rather than a wrong page: RETRY_STATUS stays 0, the mapping does
+ * not fire, and the `elif` mints verdict=pass with a warning claiming the
+ * tiers passed on retry when no retry ran. The dispatch step gates on that
+ * verdict, so the lane ships a point release off a tick that never finished.
+ */
+function verdictSnippet() {
+ const lines = workflow.split('\n');
+ const start = lines.findIndex((line) => line.trim() === 'RETRY_STATUS=0');
+ const end = lines.findIndex((line) => line.includes('TIER_VERDICT=could-not-verify ;; esac'));
+ if (start === -1 || end === -1 || end < start) {
+ throw new Error(
+ 'bug-lane-verify.yml no longer contains the exit-code-to-verdict chain this test lifts (the RETRY_STATUS seed through the mapping arm). Re-anchor rather than deleting.',
+ );
+ }
+ const block = lines.slice(start, end + 1);
+ const indent = block[0].length - block[0].trimStart().length;
+ return block.map((line) => line.slice(indent)).join('\n');
+}
+
+/**
+ * Run the shipped chain for one FIRST_STATUS and return both the propagated
+ * retry status and the verdict.
+ *
+ * Only the retry's INVOCATION is substituted, not the arm around it and not the
+ * `| tee` it feeds -- so PIPESTATUS still has two elements, and the two
+ * assignments that read its outcome are the shipped ones and actually execute.
+ * Replacing the whole arm would excise `RETRY_STATUS="${PIPESTATUS[0]}"`, and
+ * that line has the same failure mode this harness exists to catch: index it
+ * `[1]` and it reads `tee`'s status, which is 0 whenever the log is writable,
+ * so a genuinely red retry mints a PASS and the lane dispatches a release.
+ * Nothing else in the repo executes it — the sibling shape assertions are all
+ * textual.
+ *
+ * Anchored on `if timeout` rather than the bare word so the match cannot start
+ * anywhere but the invocation, and so a future line above it cannot capture the
+ * anchor away from the retry.
+ *
+ * The throw on a miss is what keeps the harness honest. `String.replace` returns
+ * its input unchanged, so a drifted anchor would leave the real invocation in
+ * the chain -- and the two budget-code cases never enter the retry arm at all,
+ * so they would keep passing while testing a chain nobody had substituted.
+ * Silently green is the failure mode worth refusing.
+ */
+function verdictFor(firstStatus, retryOutcome = 1) {
+ const snippet = verdictSnippet();
+ const chain = snippet.replace(
+ /if timeout[\s\S]*?--output-logs=errors-only 2>&1/,
+ `if (exit ${retryOutcome})`,
+ );
+ if (chain === snippet) {
+ throw new Error(
+ 'verdictFor no longer matches the retry invocation in bug-lane-verify.yml — re-anchor rather than deleting.',
+ );
+ }
+ const script = [
+ shellOptions(),
+ `FIRST_STATUS=${firstStatus}`,
+ 'RETRY_LOG=/dev/null',
+ chain,
+ 'printf "%s %s" "$RETRY_STATUS" "$TIER_VERDICT"',
+ ].join('\n');
+ const result = spawnSync('bash', ['-c', script], { encoding: 'utf8' });
+ expect(result.status, `chain exited ${result.status}: ${result.stderr}`).toBe(0);
+ const [retryStatus, verdict] = result.stdout.split(' ');
+ return { retryStatus, verdict };
+}
+
/** Run the shipped snippet over a log file and return the JSON it emits. */
-function extract(logContents) {
+function extract(logContents, tierVerdict) {
const logPath = join(scratch, `log-${Math.abs(hash(logContents))}.txt`);
writeFileSync(logPath, logContents);
const script = [
+ // Pasted rather than lifted, unlike verdictFor above, because the option
+ // cannot change what this returns: every pipe in the extraction block ends
+ // in `|| true` or `|| echo`, so pipefail has nothing to propagate. Routing
+ // it through shellOptions() would redden these six cases for a regression
+ // they say nothing about.
'set -euo pipefail',
'RETRY_LOG="$1"',
+ // Omitting these exercises the ordinary red-tier path: the snippet defaults
+ // TIER_VERDICT, and the budget-blow branch it guards is simply not taken, so
+ // the two variables that branch would read are never dereferenced.
+ // 999 is deliberately not the shipped budget: this pins that the value
+ // interpolates, not what it currently is, so re-sizing the real one cannot
+ // leave a green test asserting a retired number.
+ ...(tierVerdict === undefined
+ ? []
+ : [`TIER_VERDICT=${tierVerdict}`, 'RETRY_STATUS=124', 'TIER_BUDGET_SECONDS=999']),
extractionSnippet(),
'printf %s "$FAILURES_JSON"',
].join('\n');
@@ -76,6 +200,57 @@ const ESC = '\u001b';
const failLine = (file, name) =>
`${ESC}[41m${ESC}[1m FAIL ${ESC}[22m${ESC}[49m ${file}${ESC}[2m > ${ESC}[22m${name}`;
+describe('exit code to verdict', () => {
+ // 124 is timeout's own signal. 137 is the SIGKILL --kill-after escalates to,
+ // which fires precisely when a tier ignores SIGTERM -- so dropping it is the
+ // realistic mutation, and it would reclassify a hard-killed run as a red tier
+ // and page "failed TWICE, not flake-class" over a truncated failure list.
+ test('both budget codes mint could-not-verify', () => {
+ expect(verdictFor(124).verdict).toBe('could-not-verify');
+ expect(verdictFor(137).verdict).toBe('could-not-verify');
+ });
+
+ // Asserted alongside the verdict because this is what the verdict is derived
+ // FROM on a first-attempt blow, and it is the step the mapping cannot see.
+ // Left at 0, the mapping never fires and the `elif` below mints a PASS.
+ test('a first-attempt blow propagates its status past the retry arm', () => {
+ expect(verdictFor(124).retryStatus).toBe('124');
+ expect(verdictFor(137).retryStatus).toBe('137');
+ });
+
+ test('an ordinary failure still mints fail', () => {
+ expect(verdictFor(1).verdict).toBe('fail');
+ expect(verdictFor(2).verdict).toBe('fail');
+ });
+
+ // The success branch of the retry's if/else: a retry that succeeds must leave
+ // the status clear, or an ordinary red tier that recovered would be refused.
+ test('a recovered retry leaves nothing for the mapping to fire on', () => {
+ expect(verdictFor(1, 0).retryStatus).toBe('0');
+ });
+
+ // Reading the wrong element of PIPESTATUS gives `tee`'s status, which is 0
+ // whenever the log is writable -- so a doubly-red tick would mint a pass and
+ // dispatch. This asserts the failing command's own status survives.
+ test('a red retry reports its own status, not the tee it pipes into', () => {
+ // The recovered-retry case above is the same FIRST_STATUS with the opposite
+ // retryOutcome: there the retry succeeds and must clear the status, here it
+ // fails and must report its own rather than the tee's.
+ //
+ // The verdict is deliberately not asserted. TIER_VERDICT starts at `fail`
+ // and is only overridden on 124/137, so it reads `fail` under the shipped
+ // line and under the mutant alike.
+ expect(verdictFor(1, 1).retryStatus).toBe('1');
+ });
+
+ // The second route into could-not-verify, exercised nowhere before: the
+ // first attempt fails ordinarily and the RETRY runs out of budget.
+ test('a retry that blows its own budget still mints could-not-verify', () => {
+ expect(verdictFor(1, 124).verdict).toBe('could-not-verify');
+ expect(verdictFor(1, 137).verdict).toBe('could-not-verify');
+ });
+});
+
describe('bug-lane failure extraction', () => {
test('names each failing vitest test, with the escape codes stripped', () => {
const failures = extract(
@@ -95,6 +270,37 @@ describe('bug-lane failure extraction', () => {
expect(failures.join('\n')).not.toContain(ESC);
});
+ // A budget blow is the one red verdict that is NOT evidence about the batch.
+ // The lane's whole reason to exist is paging correctly, and the incident that
+ // prompted this wrapper was a refusal that read as a bad fix. So the page must
+ // say "could not verify" even though the log underneath is full of real FAIL
+ // lines from tiers that did finish before the clock ran out.
+ test('replaces the named failures when the attempt ran out of budget', () => {
+ const log = [
+ failLine('src/acp/thread-socket.test.ts', 'rename round-trips'),
+ ' Test Files 1 failed | 474 passed (492)',
+ ].join('\n');
+
+ const failures = extract(log, 'could-not-verify');
+ expect(failures).toHaveLength(1);
+ expect(failures[0]).toContain('did not finish within 999s');
+ // The exit code separates a clean timeout from a SIGKILL escalation, which
+ // is the difference between a slow tier and one that ignored the signal.
+ expect(failures[0]).toContain('exit 124');
+ // The point of the override: no test name survives to be blamed.
+ expect(failures[0]).not.toContain('thread-socket');
+ });
+
+ // The override must fire ONLY on the budget codes. An ordinary red tier is
+ // still the common case and must keep naming what went red.
+ test('leaves an ordinary red tier naming its failures', () => {
+ const failures = extract(
+ failLine('src/acp/thread-socket.test.ts', 'rename round-trips'),
+ 'fail',
+ );
+ expect(failures).toEqual(['src/acp/thread-socket.test.ts > rename round-trips']);
+ });
+
// A typecheck failure prints no FAIL line at all, so the fallback is the only
// thing standing between that verdict and an empty page.
test('falls back to the one turbo line that names the failing task', () => {
diff --git a/.github/scripts/bug-lane-refusal-payload.mjs b/.github/scripts/bug-lane-refusal-payload.mjs
index 625d170c5..4745065fd 100644
--- a/.github/scripts/bug-lane-refusal-payload.mjs
+++ b/.github/scripts/bug-lane-refusal-payload.mjs
@@ -179,6 +179,17 @@ export function classifyRefs(refs, gitShow) {
const classifiedWithNoPaths = (r) => Array.isArray(r.files) && r.files.length === 0;
export function describeRefusal({ verdict, refs }) {
+ if (verdict === 'could-not-verify') {
+ return {
+ // Deliberately not "failed": the tiers ran out of budget, so there is no
+ // result to report about the batch either way. Every clause of the `fail`
+ // wording below would be false here, and the one an operator acts on
+ // ("not a retry candidate") would be the exact inverse of the truth.
+ headline: 'Bug lane: could not verify the synthetic tree',
+ meaning:
+ 'The fast tiers ran out of their time budget rather than finishing. Nothing was verified, so this says nothing about the queued fixes.',
+ };
+ }
if (verdict === 'fail') {
return {
headline: 'Bug lane: verification failed on the synthetic tree',
@@ -228,6 +239,13 @@ export function describeRefusal({ verdict, refs }) {
* to a door that is locked is worse than saying it is locked.
*/
export function optionsFor({ verdict, refs }) {
+ if (verdict === 'could-not-verify') {
+ return [
+ 'Nothing here is evidence about the fixes — the tiers did not finish, so no test passed or failed on their account.',
+ 'The batch stays pending and the next tick retries it. Unlike a red verification, this IS a retry candidate.',
+ 'If this keeps happening the runner or the budget is the thing to look at — but identical refusals stay silent, so check the lane\u2019s recent runs rather than waiting to be paged again.',
+ ];
+ }
if (verdict === 'fail') {
return [
'Check the failures above against the fixes first — a failure in code no fix touches means the STABLE is red, which no amount of re-running or re-picking will clear.',
@@ -261,7 +279,9 @@ function refLines(refs) {
const lines = [];
for (const entry of refs.slice(0, MAX_REFS_SHOWN)) {
const tickets = (entry.tickets ?? []).join(', ');
- const label = [`\`${entry.ref.slice(0, 9)}\``, tickets && `(${tickets})`].filter(Boolean).join(' ');
+ const label = [`\`${entry.ref.slice(0, 9)}\``, tickets && `(${tickets})`]
+ .filter(Boolean)
+ .join(' ');
const shown = entry.files.slice(0, MAX_FILES_SHOWN);
// "conflicted in 0 files:" followed by nothing is the shape that made a
// page unreadable — it states a conflict and then lists no evidence for
@@ -315,7 +335,21 @@ const MAX_FAILURES_SHOWN = 8;
* without opening anything: a failing test in a package the fixes never touched
* is the stable being red on its own, not a fix that depends on later work.
*/
-function failureLines(failures) {
+function failureLines(failures, verdict) {
+ if (verdict === 'could-not-verify') {
+ // No lead line: the bullet already carries the budget and the exit code,
+ // and a heading restating it was the redundancy the previous commit set out
+ // to remove. The `fail` arm's lead earns its place by adding the attempt
+ // count; there is nothing equivalent to add here.
+ //
+ // Which attempt ran out is deliberately not claimed. A first-attempt blow
+ // is never retried, but the RETRY can blow its own budget too, so "there
+ // was no second attempt" holds on one path and not the other.
+ if (failures.length === 0) {
+ return ['The tiers ran out of their time budget. Read the run log for where the time went.'];
+ }
+ return failures.map((f) => ` • ${f}`);
+ }
if (failures.length === 0) {
// Hedged, because `verdict=fail` has two sites in the workflow: the
// retry-exhausted tier path, and the `pnpm install --frozen-lockfile`
@@ -353,7 +387,9 @@ export function buildSlackPayload({
`*Over \`${stable}\` on \`${repo}\`.* ${meaning}`,
'',
'*Why it refused*',
- ...(verdict === 'fail' ? failureLines(failures) : refLines(refs)),
+ ...(verdict === 'fail' || verdict === 'could-not-verify'
+ ? failureLines(failures, verdict)
+ : refLines(refs)),
// A red tier does not imply an empty `refs`. The pick loop writes its
// `conflicts` output for every DROPPED ref and then lets the survivors run
// the tiers, so a partial drop followed by a red tier arrives here with
@@ -361,7 +397,7 @@ export function buildSlackPayload({
// partial-drop page cannot cover the gap because its own step is gated on
// `verdict == 'pass'`. Losing the labelling problem must not also lose the
// information, so the drops keep their own heading.
- ...(verdict === 'fail' && refs.length > 0
+ ...((verdict === 'fail' || verdict === 'could-not-verify') && refs.length > 0
? ['', '*Also dropped from this batch, before the tiers ran*', ...refLines(refs)]
: []),
'',
diff --git a/.github/scripts/bug-lane-refusal-payload.test.mjs b/.github/scripts/bug-lane-refusal-payload.test.mjs
index d0340dd9f..8dbe764f0 100644
--- a/.github/scripts/bug-lane-refusal-payload.test.mjs
+++ b/.github/scripts/bug-lane-refusal-payload.test.mjs
@@ -468,13 +468,92 @@ describe('workflow wiring', () => {
// The guarantee the whole change rests on: an all-already tick is silent
// BY CONSTRUCTION, because the paging chain only ever fires on the two
// verdicts that represent a real question for a human.
- test('only conflict and fail can reach the pager', () => {
+ test('only conflict, fail and could-not-verify can reach the pager', () => {
const gate = step('Refusal signature');
const verdicts = [...gate.matchAll(/verdict == '([a-z-]+)'/g)].map((m) => m[1]);
- expect(new Set(verdicts)).toEqual(new Set(['conflict', 'fail']));
+ // `could-not-verify` is a refusal an operator must see: the tiers never
+ // finished, so the batch stays pending with nothing said about it.
+ expect(new Set(verdicts)).toEqual(new Set(['conflict', 'fail', 'could-not-verify']));
expect(verdicts).not.toContain('already-in-stable');
});
+ // The page is the only channel this workflow has — its own header notes that
+ // `workflow_dispatch` runs are excluded from the status rollup and can never
+ // colour a commit. So the distinction has to exist HERE, not just in the run
+ // log, or it does not exist for the person it is for.
+ describe('a budget blow does not read as a red tier', () => {
+ const payload = (verdict) =>
+ buildSlackPayload({
+ verdict,
+ stable: 'v0.63.6',
+ refs: [],
+ runUrl: 'https://example.test/run',
+ failures: ['the tiers did not finish within 1500s'],
+ });
+ const page = (verdict) => payload(verdict).blocks[1].text.text;
+
+ test('says nothing was verified, rather than naming a cause', () => {
+ // The headline is its own surface: it is what Slack shows in a list, so
+ // "failed" there is the first thing an operator reads and acts on.
+ expect(JSON.stringify(payload('could-not-verify'))).toContain('could not verify');
+ const body = page('could-not-verify');
+ expect(body).toContain('Nothing was verified');
+
+ // ROUTING, not just the branch. Every assertion below this comment used
+ // to be satisfiable by rendering NOTHING: revert the verdict test on the
+ // `failureLines` call and this page becomes a `*Why it refused*` heading
+ // over a blank line, which is the exact shape `refLines` warns about --
+ // stating a refusal and listing no evidence for it.
+ expect(body).toContain('did not finish within 1500s');
+ expect(body).not.toMatch(/\*Why it refused\*\n\n/);
+ // The one thing this whole verdict exists to tell an operator. Nothing
+ // else in this file asserts any `optionsFor` string for it, so emptying
+ // that branch rendered a bare header and stayed green.
+ expect(body).toContain('IS a retry candidate');
+ // Every one of these is false on a blow, and the last is the inverse of
+ // the truth — the batch is precisely a retry candidate.
+ expect(body).not.toContain('not flake-class');
+ expect(body).not.toContain('depends on later work');
+ expect(body).not.toContain('not a retry candidate');
+ expect(body).not.toContain('the stable is red on its own');
+ });
+
+ // Mirrors the `fail` parity case: a partial drop followed by a budget blow
+ // arrives here with real drop evidence, and the partial-drop page cannot
+ // cover it because its own step gates on `verdict == 'pass'`.
+ test('still accounts for refs dropped before the tiers ran', () => {
+ const body = buildSlackPayload({
+ verdict: 'could-not-verify',
+ stable: 'v0.63.6',
+ refs: [
+ {
+ ref: 'abc1234',
+ inert: false,
+ files: [
+ { path: 'packages/core/src/index.ts', inert: false, detail: 'carries behavior' },
+ ],
+ },
+ ],
+ runUrl: 'https://example.test/run',
+ failures: ['the tiers did not finish within 1500s (exit 124)'],
+ }).blocks[1].text.text;
+ expect(body).toContain('Also dropped from this batch');
+ expect(body).toContain('abc1234');
+ // Rendering the page showed `undefined - CARRIES BEHAVIOR (undefined)`
+ // from a fixture that passed bare strings where refLines reads objects.
+ // Asserting the ref alone did not see it, so assert the file line too.
+ expect(body).toContain('packages/core/src/index.ts');
+ expect(body).not.toContain('undefined');
+ });
+
+ test('still says all of that for a genuine red tier', () => {
+ const body = page('fail');
+ expect(body).toContain('not flake-class');
+ expect(body).toContain('not a retry candidate');
+ expect(body).not.toContain('ran out of');
+ });
+ });
+
// `${V:-{\}}` expands to a LITERAL `{\}` — a brace in a parameter-expansion
// default is not escapable there. jq --argjson then refuses, and the enriched
// page degrades to the plain fallback on every single run, with nothing in
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index b0bc59486..38a8d2b8b 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -580,23 +580,27 @@ describe('the bug lane verifies the synthetic tree at the same bar as main', ()
// Single-shot here holds a candidate to a STRICTER bar than the tier that
// gates main, which retries each package once and treats a retry-pass as
// green. These tiers spawn real processes (an orphaned CLI reaped on host
- // death), so one flake under runner contention refused a sound fix on
- // 2026-08-04 and the page blamed the fix for it.
+ // death), so one flake under runner contention has refused a sound fix and left
+ // the page blaming the fix for it.
const runs = [...verify.matchAll(/turbo run typecheck test/g)];
expect(
runs.length,
'verify must invoke the tiers twice: once, then one flake retry',
).toBe(2);
- expect(verify).toContain('elif pnpm exec turbo run typecheck test');
+ // The retry now sits in the ordinary-failure arm of a case, because a
+ // budget blow is deliberately routed past it.
+ expect(verify).toContain('case "$FIRST_STATUS" in');
+ const ordinaryArm = verify.indexOf('*)', verify.indexOf('case "$FIRST_STATUS" in'));
+ expect(ordinaryArm, 'the ordinary-failure arm must exist').toBeGreaterThan(-1);
+ expect(verify.indexOf('| tee "$RETRY_LOG"')).toBeGreaterThan(ordinaryArm);
});
test('the first attempt runs to completion so the retry stays incremental', () => {
- // Load-bearing against this job's cancel window, not a style choice.
- // turbo defaults to `--continue=never`, which cancels every in-flight and
- // unstarted task on the first failure — none of those cache, so the retry
- // re-runs them and a late failure costs close to two full passes. With
- // `cancel-in-progress: true` a tick that outruns the next one is killed
- // before it can page, losing the refusal entirely.
+ // A cost guard, not a style choice. turbo defaults to `--continue=never`,
+ // which cancels every in-flight and unstarted task on the first failure —
+ // none of those cache, so the retry re-runs them and a late failure costs
+ // close to two full passes. That matters because each attempt now runs
+ // under its own budget, and two near-full passes is how a tick reaches it.
// Scoped to the invocation LINES, not the step text: the comment above
// them names both flags to explain the choice, and a ratchet that bans
// naming what it rules out just gets worked around.
@@ -612,14 +616,85 @@ describe('the bug lane verifies the synthetic tree at the same bar as main', ()
expect(retry).not.toContain('--force');
});
- test('only a second consecutive failure mints verdict=fail', () => {
- const failAt = verify.indexOf('verdict=fail');
- const elifAt = verify.indexOf('elif pnpm exec turbo run typecheck test');
- expect(elifAt).toBeGreaterThan(-1);
- // The install-failure guard mints its own verdict=fail earlier; the one
- // that matters here is the tier verdict, which must sit after the retry.
- expect(verify.lastIndexOf('verdict=fail')).toBeGreaterThan(elifAt);
- expect(failAt).toBeGreaterThan(-1);
+ test('only a second consecutive failure mints a refusing verdict', () => {
+ const installGuardAt = verify.indexOf('verdict=fail');
+ const retryAt = verify.indexOf('| tee "$RETRY_LOG"');
+ expect(retryAt).toBeGreaterThan(-1);
+ // The install-failure guard mints its own verdict=fail before the tiers
+ // run. The tier verdict is the one that matters here, and it is emitted
+ // from a variable now, because a blown budget is a different verdict from
+ // a red tier. Either way it must sit after the retry.
+ expect(installGuardAt).toBeGreaterThan(-1);
+ expect(installGuardAt).toBeLessThan(retryAt);
+ expect(verify.indexOf('verdict=${TIER_VERDICT}')).toBeGreaterThan(retryAt);
+ });
+
+ test('each tier attempt runs under its own budget, and a blown one still pages', () => {
+ // The job's `timeout-minutes` is a hard kill that sets no verdict, and every
+ // paging step gates on one — so a job that hits it refuses NOTHING and, since
+ // this group queues rather than cancels, stacks the next verify behind it. A
+ // silent tick is strictly worse than a wrong one here, and bounding turbo's
+ // concurrency made overrun likelier by design. Both attempts are wrapped so a
+ // budget blow arrives as exit 124 and is reported as "could not verify"
+ // rather than as a verdict on the batch.
+ const wrappers = [...verify.matchAll(/timeout --foreground --kill-after=\d+s/g)];
+ expect(wrappers.length, 'both attempts must carry their own budget').toBe(2);
+
+ // Substrings alone would not pin this: 124 and 137 also appear in prose a
+ // few lines up, so deleting the functional branch and keeping the comments
+ // would stay green, and so would transposing the two messages. Anchor on
+ // the gate and require each message on the correct side of it.
+ const gateAt = verify.indexOf('"${TIER_VERDICT:-fail}" == "could-not-verify" ]]; then\n echo');
+ expect(gateAt, 'the warning must branch on the computed budget flag').toBeGreaterThan(-1);
+ const couldNotVerifyAt = verify.indexOf('COULD NOT VERIFY', gateAt);
+ const notFlakeAt = verify.indexOf('not flake-class', gateAt);
+ expect(couldNotVerifyAt).toBeGreaterThan(gateAt);
+ expect(notFlakeAt).toBeGreaterThan(couldNotVerifyAt);
+
+ // A blown budget must NOT be retried: a second attempt burns another full
+ // budget and buries the signal, which is the PR tier's stated rule. Scoped
+ // INSIDE the FIRST_STATUS case and required to precede the ordinary arm --
+ // `124|137)` also spells the flag computation below, so a bare substring
+ // would survive deleting this arm entirely.
+ const caseAt = verify.indexOf('case "$FIRST_STATUS" in');
+ expect(caseAt).toBeGreaterThan(-1);
+ const blowArm = verify.indexOf('124|137)', caseAt);
+ const ordinaryRetryArm = verify.indexOf('*)', caseAt);
+ expect(blowArm, 'the budget arm must sit inside the FIRST_STATUS case').toBeGreaterThan(caseAt);
+ expect(blowArm, 'the budget arm must precede the retry arm').toBeLessThan(ordinaryRetryArm);
+ });
+
+ test('a tick that mints no verdict still refuses out loud', () => {
+ // Every paging step gates on a verdict and steps default to `if: success()`,
+ // so anything that dies before the tiers -- a bad stable ref, a failed
+ // install, the job ceiling reached during checkout -- skips all of them. The
+ // tier budget closes the commonest door; this is what closes the rest.
+ const guard = bugLaneVerify.indexOf("steps.verify.outputs.verdict == ''");
+ expect(guard, 'a no-verdict tick must still page').toBeGreaterThan(-1);
+ const always = bugLaneVerify.lastIndexOf('always()', guard);
+ expect(always, 'the guard is useless without always()').toBeGreaterThan(-1);
+ expect(guard - always).toBeLessThan(40);
+ // A guard that runs and says nothing is the same silence it exists to end,
+ // so require the step to actually emit -- and to say which class it is.
+ const emits = bugLaneVerify.indexOf('::warning::', guard);
+ expect(emits, 'the guarded step must emit something').toBeGreaterThan(guard);
+ expect(bugLaneVerify.slice(guard, emits + 200)).toContain('COULD NOT VERIFY');
+ });
+
+ test('a budget blow and a real refusal do not share a page signature', () => {
+ // They differ by VERDICT, which the signature already hashes. That is the
+ // whole reason a blow mints its own verdict instead of riding `fail` with a
+ // flag: a flag has to be threaded to the page, the signature and the gates
+ // separately, and a missed wiring is silent because each reader defaults it.
+ const sigFrom = bugLaneVerify.indexOf('- name: Refusal signature');
+ const sigTo = bugLaneVerify.indexOf('- name: Has this refusal already been paged?');
+ expect(sigFrom).toBeGreaterThan(-1);
+ expect(sigTo).toBeGreaterThan(sigFrom);
+ const sig = bugLaneVerify.slice(sigFrom, sigTo);
+ expect(sig).toContain('"$VERDICT"');
+ expect(verify).toContain('TIER_VERDICT=could-not-verify');
+ // The flag is gone; if it comes back, the threading hazard comes with it.
+ expect(bugLaneVerify).not.toContain('budget_blown');
});
test('an unchanged refusal is paged once, not once per tick', () => {
diff --git a/.github/workflows/bug-lane-verify.yml b/.github/workflows/bug-lane-verify.yml
index 7b38adebf..00bb649a8 100644
--- a/.github/workflows/bug-lane-verify.yml
+++ b/.github/workflows/bug-lane-verify.yml
@@ -91,7 +91,13 @@ jobs:
bug-lane-verify:
name: Verify the synthetic tree and (when armed) dispatch
runs-on: ubuntu-latest
- timeout-minutes: 45
+ # 60 not 45: bounding turbo's concurrency below trades wall clock for the
+ # contention that was refusing good fixes, and the 25m06s this used to run
+ # in was measured in the UNBOUNDED shape. This is the outer backstop only.
+ # It does not protect a verdict -- reaching it is a hard kill that mints
+ # none -- which is why the tiers carry their own budget and why the step
+ # below refuses out loud when no verdict was produced.
+ timeout-minutes: 60
steps:
- name: Refuse an empty batch
# Only reachable via a hand-typed dispatch: the evaluator never asks
@@ -260,14 +266,14 @@ jobs:
# under runner contention. Unretried, one such flake refuses a fix
# that is fine, and the refusal reads as a real incompatibility.
#
- # `--continue` on the FIRST attempt is what keeps the retry cheap,
- # and it is load-bearing against this job's own cancel window. turbo
+ # `--continue` on the FIRST attempt is what keeps the retry cheap. turbo
# defaults to `--continue=never`: the first failure cancels every
# in-flight and unstarted task, so none of those cache and the retry
# re-runs them too — a failure late in the tiers would cost close to
- # two full passes, and with `cancel-in-progress` a tick that outruns
- # the next one is killed before it can page, which is the one outcome
- # the install guard above exists to prevent. Running the first
+ # two full passes, which this job's wall-clock budget has no room
+ # for. (The cancel window that once made this urgent belongs to
+ # bug-lane.yml; since the split this half queues rather than
+ # cancels, per the group above.) Running the first
# attempt to completion caches every task that genuinely passed, so
# the retry re-executes only what actually failed. `--force` is
# omitted for the same reason: it would discard those cached passes.
@@ -278,14 +284,96 @@ jobs:
# how it reached the tiers at all. So the most severe verdict was the
# one paging with an empty reason, sending a reader to the run log to
# discover what this step already knew.
+ #
+ # `--concurrency=2` caps how many turbo task-graph nodes are
+ # SCHEDULED at once. It does not reach inside a node: each of the two
+ # still runs its Vitest fork pool at the default width, so the shape
+ # is two supervisors sharing four cores, not the one-tier-per-box the
+ # PR tier gets. A fivefold cut from turbo's default of ten, which is
+ # not the same thing as isolation.
+ #
+ # The workspace does own a cap that WOULD reach the pools --
+ # `boundedMaxForks` in test-support/vitest.base.ts -- and it cannot
+ # help here: it applies only when `!CI && cpuCount >= 8`, and this
+ # runner fails BOTH halves. Widening the `CI` guard alone would change
+ # nothing on a four-core box, which is why the bound has to come from
+ # this side instead.
+ #
+ # Contention is not a hypothesis about this step: it is the mechanism
+ # the retry note above already names, and a tier that blows a
+ # per-test timeout under it refuses a fix that is fine.
RETRY_LOG="${RUNNER_TEMP}/bug-lane-tiers-retry.log"
- if pnpm exec turbo run typecheck test --continue --output-logs=errors-only; then
+ # Created up front because a first-attempt blow skips the retry
+ # entirely, and the extraction below reads this file either way.
+ : > "$RETRY_LOG"
+ # The tiers carry their own ceiling because the job's is a hard kill:
+ # it sets no verdict, and every paging step below gates on one, so a
+ # tick that hits it refuses NOTHING. And nothing queues behind it:
+ # bug-lane.yml declines to dispatch while a verify is in flight, so
+ # the ~20-minute ticks in that window evaluate and skip, and the lane
+ # simply stops verifying for as long as the wedge lasts. Wrapping
+ # turns that into exit 124, which this step can report and the page
+ # can render.
+ #
+ # Sized from the one measurement taken on THIS runner: the last
+ # unbounded tick spent 1460s in this step, covering cherry-pick,
+ # install and BOTH attempts, which bounds a single attempt well under
+ # 1500s without measuring it directly.
+ #
+ # The bounded single-attempt cost is still unmeasured -- it needs a
+ # dispatch of this workflow -- and it is the number to re-check if a
+ # tick ever runs out of budget. Both attempts carry this ceiling, so the bound
+ # is 2x1500s, about 50 minutes against the job's 60 -- the remaining
+ # ten cover checkout, setup, the cherry-pick loop and the install,
+ # none of which are bounded themselves.
+ TIER_BUDGET_SECONDS=1500
+ FIRST_STATUS=0
+ timeout --foreground --kill-after=10s "${TIER_BUDGET_SECONDS}s" \
+ pnpm exec turbo run typecheck test --concurrency=2 --continue --output-logs=errors-only \
+ || FIRST_STATUS=$?
+ RETRY_STATUS=0
+ if [[ "$FIRST_STATUS" -ne 0 ]]; then
+ case "$FIRST_STATUS" in
+ 124|137)
+ # NOT retried, which is where this parts company with the PR
+ # tier's idiom it otherwise copies: that tier refuses to retry a
+ # budget blow because a second attempt burns another full budget
+ # and buries the signal. Here it would also race attempt 1's
+ # orphans, since `--foreground` signals the command and not its
+ # children, on the four cores whose contention is the whole
+ # reason for the bound.
+ RETRY_STATUS="$FIRST_STATUS"
+ ;;
+ *)
+ if timeout --foreground --kill-after=10s "${TIER_BUDGET_SECONDS}s" \
+ pnpm exec turbo run typecheck test --concurrency=2 --output-logs=errors-only 2>&1 | tee "$RETRY_LOG"; then
+ RETRY_STATUS=0
+ else
+ # Read BEFORE any other command: the next one clobbers it.
+ RETRY_STATUS="${PIPESTATUS[0]}"
+ fi
+ ;;
+ esac
+ fi
+ # 124 is timeout's own signal, 137 the SIGKILL that --kill-after
+ # escalates to. Reading it here is sufficient because a blow is never
+ # retried: reaching the retry at all implies attempt 1 failed the
+ # ordinary way, so this is whichever attempt produced the verdict.
+ #
+ # It becomes its OWN verdict rather than riding `fail` with a flag
+ # beside it. The page, the refusal signature and the step gates all
+ # key on the verdict, so a flag has to be threaded to each of them
+ # separately -- and one wiring mistake is silent, because every reader
+ # defaults it. A verdict cannot be half-delivered that way.
+ TIER_VERDICT=fail
+ case "$RETRY_STATUS" in 124|137) TIER_VERDICT=could-not-verify ;; esac
+ if [[ "$FIRST_STATUS" -eq 0 ]]; then
echo "verdict=pass" >> "$GITHUB_OUTPUT"
- elif pnpm exec turbo run typecheck test --output-logs=errors-only 2>&1 | tee "$RETRY_LOG"; then
+ elif [[ "$RETRY_STATUS" -eq 0 ]]; then
echo "verdict=pass" >> "$GITHUB_OUTPUT"
echo "::warning::bug-lane: fast tiers passed on retry for ${STABLE} + ${SURVIVING_REFS} — the first attempt failed (flake-class); see its log before trusting this tick."
else
- echo "verdict=fail" >> "$GITHUB_OUTPUT"
+ echo "verdict=${TIER_VERDICT}" >> "$GITHUB_OUTPUT"
# Vitest names the failing test on a `FAIL` line. A typecheck-only
# failure produces none, so fall back to turbo's own failed-task
# lines rather than paging empty again. Sorted-unique and capped:
@@ -316,6 +404,17 @@ jobs:
# failure, two of them redundant and one naming nothing at all.
FAILURES="$(strip_ansi | grep -E '#[^ ]+:.*exited \([0-9]+\)' | sort -u | head -200 || true)"
fi
+ # A budget blow names no test, so the extraction above has nothing
+ # to find. Saying that outright is the point of separating it: the
+ # incident this lane exists to avoid is a refusal that blames a fix
+ # for something the runner did. Defaulted so the block above stays
+ # liftable and runnable on its own.
+ if [[ "${TIER_VERDICT:-fail}" == "could-not-verify" ]]; then
+ # Just the fact. The page's own framing carries what it means,
+ # in the meaning line and again in the options, and rendering all
+ # three showed the same sentence three times over.
+ FAILURES="the tiers did not finish within ${TIER_BUDGET_SECONDS}s (exit ${RETRY_STATUS})"
+ fi
# Encoded into a variable BEFORE the heredoc block, with a fallback.
# Under `set -e` a jq that exits non-zero mid-block (invalid UTF-8
# surviving in the captured log, say) would abort between the
@@ -336,7 +435,11 @@ jobs:
# the causes: a tier can equally be red because the stable's own
# tree is red, and reading a base failure as an incompatible fix is
# how a lane-wide outage looks like a series of bad fixes.
- echo "::warning::bug-lane: fast tiers failed TWICE on ${STABLE} + ${SURVIVING_REFS} — not flake-class. Either the fix assumes something the stable does not have, or the stable is red on its own; the named failures below decide which. It stays on its cycle's path."
+ if [[ "${TIER_VERDICT:-fail}" == "could-not-verify" ]]; then
+ echo "::warning::bug-lane: fast tiers ran out of budget on ${STABLE} + ${SURVIVING_REFS} — COULD NOT VERIFY, which is not a verdict on the batch. What ran out is the clock; whether that is the runner or the tree, this tick cannot say. It stays on its cycle's path."
+ else
+ echo "::warning::bug-lane: fast tiers failed TWICE on ${STABLE} + ${SURVIVING_REFS} — not flake-class. Either the fix assumes something the stable does not have, or the stable is red on its own; the named failures below decide which. It stays on its cycle's path."
+ fi
fi
- name: Dispatch the point release (or log what would ship)
@@ -480,6 +583,32 @@ jobs:
path: ${{ steps.drop.outputs.marker }}
key: bug-lane-drop-${{ steps.drop.outputs.sig }}
+ # Everything above gates on a verdict, and a step that dies before minting
+ # one skips all of it: a bad stable ref, a checkout or setup step dying,
+ # or the job's own ceiling reached while the cherry-pick loop or install
+ # runs, none of which are inside the tiers' budget. (A failed install is
+ # NOT one of these -- the guard above mints `fail` for it explicitly.)
+ # The tier wrapper closes the commonest door. This leaves a trace for the
+ # rest of the class -- but only in the run log, and this workflow's whole
+ # argument for a `could-not-verify` VERDICT is that the run log is not a
+ # channel anyone reads. So the honest claim is narrow: no tick ends
+ # without a record, and a tick that dies before minting a verdict still
+ # does not reach Slack. Closing that properly means paging from here, in
+ # the bare jq+curl shape the drop notifier already uses, which needs no
+ # file from a workspace that may be detached or half-built.
+ - name: A tick that produced no verdict is still a refusal
+ if: always() && steps.verify.outputs.verdict == ''
+ env:
+ STABLE: ${{ inputs.stable }}
+ run: |
+ echo "::warning::bug-lane: verify produced no verdict for ${STABLE} — COULD NOT VERIFY. Nothing here is evidence about the queued fixes; read the run log for where it stopped."
+
+ # `could-not-verify` is enrolled here too, and it is the one verdict that
+ # is NOT a standing answer: it is a fact about one runner's clock. The
+ # trade is deliberate and bounded -- the batch churns as new fixes
+ # qualify, so the signature moves and the lane re-pages -- and the page
+ # itself tells the reader to check recent runs rather than wait.
+ #
# A refusal is a STANDING ANSWER, not an event. The refused ref stays in
# the pending pile and re-qualifies and re-conflicts on every tick, so a
# page-per-tick turns one durable fact into a message every 20 minutes
@@ -513,7 +642,7 @@ jobs:
# ever stops being true, put "$STABLE" back in the printf below.
- name: Refusal signature
id: refusal
- if: env.BUG_LANE_ARMED == 'true' && (steps.verify.outputs.verdict == 'conflict' || steps.verify.outputs.verdict == 'fail')
+ if: env.BUG_LANE_ARMED == 'true' && (steps.verify.outputs.verdict == 'conflict' || steps.verify.outputs.verdict == 'fail' || steps.verify.outputs.verdict == 'could-not-verify')
env:
VERDICT: ${{ steps.verify.outputs.verdict }}
FIX_REFS: ${{ inputs.fix_refs }}
@@ -530,6 +659,10 @@ jobs:
# cause is paged. That is the right trade — the first page already
# tells an operator the lane is refusing and hands them the run log,
# which carries every subsequent cause.
+ #
+ # `could-not-verify` is its own verdict, so it distinguishes itself
+ # here for free: a tick that could not verify can no longer suppress
+ # the genuinely red tick behind it for the same ref set.
sig="$(printf '%s|%s|%s' "$VERDICT" "$FIX_REFS" "$SURVIVING_REFS" | sha256sum | cut -c1-32)"
echo "sig=${sig}" >> "$GITHUB_OUTPUT"
echo "marker=${RUNNER_TEMP}/bug-lane-refusal-marker" >> "$GITHUB_OUTPUT"
diff --git a/packages/desktop/tests/unit/desktop-host-contract-single-source.test.ts b/packages/desktop/tests/unit/desktop-host-contract-single-source.test.ts
index 7c698d686..b859c704b 100644
--- a/packages/desktop/tests/unit/desktop-host-contract-single-source.test.ts
+++ b/packages/desktop/tests/unit/desktop-host-contract-single-source.test.ts
@@ -19,23 +19,61 @@ const ipcTypeAliases = [
] as const;
const ipcTypeReexports = ['OkSharingStatusResult', 'OkSharingSetModeResult'] as const;
-const project = new Project({
+const projectOptions = {
skipFileDependencyResolution: true,
skipLoadingLibFiles: true,
skipAddingFilesFromTsConfig: true,
compilerOptions: { noLib: true },
-});
+} as const;
-const contractSources = project.addSourceFilesAtPaths([
+/**
+ * The barrel check below is the only assertion here that pays for a type
+ * checker over the real corpus: `getExportedDeclarations()` follows `export *`
+ * chains, which the syntactic APIs cannot. (The discrimination test further
+ * down builds one too, over a four-file in-memory tree, so its cost does not
+ * scale with anything.) Building that checker is by far the most expensive
+ * thing this file does, and its cost scales with how many files the project
+ * holds rather than with the two this check actually reads.
+ *
+ * So it gets its own project scoped to `core/src`. That changes how many files
+ * the checker takes as program roots, not what it can reach: the compiler host
+ * still loads dependencies from disk on demand, so a chain leaving `core/src`
+ * resolves either way and this scoped check is no blinder than the shared one.
+ * Measured on this tree, each shape in its own process so neither warms the
+ * other: 0.64s scoped against 2.74s shared, and 0.23s against 1.18s for the
+ * checker alone, with an identical result on both sides.
+ *
+ * `skipFileDependencyResolution` is not what bounds any of that — it only stops
+ * ts-morph eagerly adding a file's imports to the project. That is the whole
+ * story in the syntactic-only ts-morph tests elsewhere in the tree, which never
+ * build a program at all; it stops being the story here, in the one test that
+ * asks for a checker.
+ */
+const coreProject = new Project(projectOptions);
+const coreSources = coreProject.addSourceFilesAtPaths(
join(packagesRoot, 'core', 'src', '**', '*.{ts,tsx}'),
- join(packagesRoot, 'app', 'src', '**', '*.{ts,tsx}'),
- join(packagesRoot, 'desktop', 'src', '**', '*.{ts,tsx}'),
-]);
-const coreBridgeSource = project.getSourceFileOrThrow(coreBridge);
+);
+const coreBridgeSource = coreProject.getSourceFileOrThrow(coreBridge);
+const coreIndexSource = coreProject.getSourceFileOrThrow(
+ join(packagesRoot, 'core', 'src', 'index.ts'),
+);
+
+const project = new Project(projectOptions);
+
+// The first test needs core in the syntactic set as well, to prove
+// `OkDesktopBridge` is declared nowhere else across the three packages. It only
+// ever reads file paths off what it finds, so composing the two projects'
+// sources is transparent to it and keeps `core/src` from being parsed twice.
+const contractSources = [
+ ...coreSources,
+ ...project.addSourceFilesAtPaths([
+ join(packagesRoot, 'app', 'src', '**', '*.{ts,tsx}'),
+ join(packagesRoot, 'desktop', 'src', '**', '*.{ts,tsx}'),
+ ]),
+];
const appShimSource = project.addSourceFileAtPath(appShim);
const desktopShimSource = project.addSourceFileAtPath(desktopShim);
const ipcChannelsSource = project.addSourceFileAtPath(ipcChannels);
-const coreIndexSource = project.addSourceFileAtPath(join(packagesRoot, 'core', 'src', 'index.ts'));
const buildConfigSource = project.addSourceFileAtPath(
join(packagesRoot, 'core', 'tsdown.config.ts'),
);
@@ -51,6 +89,14 @@ function expectTypeOnlyExportStar(sourceFile: SourceFile): void {
expect(exportDeclaration?.hasNamedExports()).toBe(false);
}
+function leafDeclarationNames(bridge: SourceFile): string[] {
+ return [...bridge.getExportedDeclarations()]
+ .filter(([, declarations]) =>
+ declarations.some((declaration) => declaration.getSourceFile() === bridge),
+ )
+ .map(([typeName]) => typeName);
+}
+
function isWindowGlobalAugmentation(declaration: import('ts-morph').InterfaceDeclaration): boolean {
return (
declaration.getName() === 'Window' &&
@@ -102,17 +148,70 @@ describe('desktop host contract single source', () => {
});
test('keeps desktop bridge types off the core barrel', () => {
- const bridgeLeafDeclarations = [...coreBridgeSource.getExportedDeclarations()]
- .filter(([, declarations]) =>
- declarations.some((declaration) => declaration.getSourceFile() === coreBridgeSource),
- )
- .map(([typeName]) => typeName);
+ const bridgeLeafDeclarations = leafDeclarationNames(coreBridgeSource);
const coreBarrelExports = coreIndexSource.getExportedDeclarations();
+
+ // An empty side would satisfy the intersection below while checking
+ // nothing, so a resolution regression could retire this test silently.
+ // These floors sit far enough under both counts to catch a collapse
+ // without tracking ordinary growth -- deliberately not near them, since
+ // both drift with the tree in either direction, and a floor that tracks a
+ // moving count becomes maintenance rather than a guard.
+ expect(bridgeLeafDeclarations.length).toBeGreaterThan(50);
+ expect(coreBarrelExports.size).toBeGreaterThan(500);
+
expect(bridgeLeafDeclarations.filter((typeName) => coreBarrelExports.has(typeName))).toEqual(
[],
);
});
+ /**
+ * The check above reads the real corpus, so it goes green either because
+ * nothing leaks or because it stopped being able to see a leak. Only the
+ * second is a regression, and the counts it asserts cannot tell them apart.
+ *
+ * This pins the discrimination directly, on an in-memory tree small enough
+ * to state: a mutant that MUST be caught, and a control that MUST stay
+ * clean. The mutant routes the leak through an intermediate `export *`,
+ * which is reachable only by following the chain, so this fails if
+ * `getExportedDeclarations()` ever stops resolving transitively -- the one
+ * property that justifies paying for a checker here at all.
+ */
+ test('the barrel check can still see a leak only a checker would follow', () => {
+ const fixture = new Project({ ...projectOptions, useInMemoryFileSystem: true });
+ const bridge = fixture.createSourceFile('/bridge.ts', 'export type Leaked = 1;\n');
+ fixture.createSourceFile('/relay.ts', "export * from './relay-target.ts';\n");
+ fixture.createSourceFile('/relay-target.ts', "export * from './bridge.ts';\n");
+ const barrel = fixture.createSourceFile('/index.ts', "export * from './relay.ts';\n");
+
+ const leaked = leafDeclarationNames(bridge).filter((typeName) =>
+ barrel.getExportedDeclarations().has(typeName),
+ );
+ expect(leaked).toEqual(['Leaked']);
+
+ // The control is a NEAR miss rather than a non-miss. Two files sharing no
+ // names would pass even if `getExportedDeclarations()` returned nothing at
+ // all, which the mutant above already covers. This instead puts a name on
+ // BOTH sides that the check must still not flag, because the bridge only
+ // passes `Shared` through and does not declare it -- so it exercises the
+ // one filter standing between the real check and a false positive.
+ const control = new Project({ ...projectOptions, useInMemoryFileSystem: true });
+ control.createSourceFile('/origin.ts', 'export type Shared = 1;\n');
+ const cleanBridge = control.createSourceFile(
+ '/bridge.ts',
+ "export type Held = 2;\nexport type { Shared } from './origin.ts';\n",
+ );
+ const cleanBarrel = control.createSourceFile(
+ '/index.ts',
+ "export type { Shared } from './origin.ts';\n",
+ );
+ expect(
+ leafDeclarationNames(cleanBridge).filter((typeName) =>
+ cleanBarrel.getExportedDeclarations().has(typeName),
+ ),
+ ).toEqual([]);
+ });
+
test('keeps IPC payloads as aliases of the core contract', () => {
const coreImport = ipcChannelsSource
.getImportDeclarations()