Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(test-infra): require the spread operand to BE the obtained module - #8406

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-8183-holds-obtained-module-operand
Sep 7, 2026
Merged

baozhoutao merged 1 commit into
mainfrom
claude/issue-8183-holds-obtained-module-operand

Conversation

@baozhoutao

@baozhoutao baozhoutao commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8183

Note on notation: generic argument lists and other angle-bracket shapes are written out in words below, because GitHub's body sanitizer eats tag-shaped fragments even inside backticks (objectui#6970).

The defect

holdsObtainedModule() in scripts/check-vi-mock-inherit.mjs asked whether the obtained token appeared ANYWHERE inside the spread's text, not whether the module IS the thing being spread:

if (!referencesName(text, token)) return false;
if (tokenIsValue || token === OBTAIN_TOKEN) return true;
const at = text.search(/* the token, whole-word */);
return text.indexOf('(', at + token.length) !== -1;

So a spread of an object literal that merely NESTS the obtained module satisfied it, and the gate quoted the evasion back in its own reason line:

inherits reason: ...({ _: await importOriginal() })

That object carries exactly ONE inherited key — _, holding the module object — so the next export any module in the file's import graph reads at module scope still resolves to undefined. The file dies during COLLECTION, the suite goes red with zero failed assertions and reads like flake. That is the failure objectui#6849 built this gate to stop, wearing the accepted spelling's clothes.

Re-derivation FIRST — the table, on today's tree

Re-derived through the gate's own exported findCallSites() on 47053c9f6 (the post-merge tree, after objectui#8141 landed as PR #8391), not from the card's table:

row shape before after
A spread the obtained module directly — ...(await importOriginal()) inherits inherits
B obtain, bind, never spread frozen (never spreads it) frozen (never spreads it)
C spread an object literal holding the obtained module — ...({ _: await importOriginal() }) inherits ← false negative frozen
D same as C with the obtained value bound to a const first — ...({ _: actual }) inherits ← false negative frozen

C and D are still false negatives on today's tree, so the brief's premise holds. The card's 576 judged / 0 using the C–D shape is stale as the brief warned; today's baseline is stated below and measured, not inherited.

The repair

operandDenotes() reads the spread's operand as ONE whole expression through a deliberately small grammar. The invariant every production preserves is the one that makes a spread inherit: the operand's KEY SET is the real module's, so it still GROWS when the real module grows.

  • await, parentheses, as/satisfies and the non-null assertion are transparent;
  • calling the obtainer produces the module (a bare call, a call with a generic argument list, (orig as any)()); the bare name does not — it is a FUNCTION;
  • a property read keeps a key set the module owns ((await importOriginal()).default, the interop shape);
  • OBTAIN_TOKEN already stands for a completed vi.importActual call;
  • an object literal or an array does not qualify — that is the evasion.

The same function decides binding propagation, so const wrapper = { _: await importOriginal() } no longer enters the inherited set either; without that, C walks back in one level up.

⛔ Untouched, as the dispatch required: isCovered, coveredPrefixes, COVERED_SPECIFIERS and the verdict line — all of them objectui#8141's surface.

Census — before and after, proved per site rather than by inspection

A false refusal reds correct code, which is how a gate gets deleted rather than fixed, so this is measured, not argued.

$ node scripts/check-vi-mock-inherit.mjs        # BEFORE (at 47053c9f6)
✅  check-vi-mock-inherit: OK (4457 tracked source file(s), 2723 test-named; 616 carry
    a mock; 625 call site(s) on ... and their subpaths judged (625 inherit, 0
    auto-mocked); 35 other workspace, 243 external, 879 local, 0 non-static, 3 embedded
    in a string literal -- all out of scope).
exit 0

$ node scripts/check-vi-mock-inherit.mjs        # AFTER
(the same line, byte-identical — `diff` of the two runs is empty)
exit 0

Per-site diff over all 625 judged sites, verdict AND reason string, base gate vs. patched gate driven from the same scan():

625 /tmp/.../persite-before.tsv
625 /tmp/.../persite-after.tsv
$ diff persite-before.tsv persite-after.tsv
PER-SITE DIFF: EMPTY (625 sites byte-identical)

The nine distinct operand shapes the tree actually writes, each now pinned as its own case: a parenthesised awaited call with a generic argument list (367), a bare binding actual (169), the same with a typeof import generic (55), mod (22), the importActual parameter spelling (6), real (2), the plain (await importOriginal()) (2), (await importActual with an any generic ()) (1), and one nested-parenthesis-plus-assertion form in ObjectTree.rowCeiling-7210.test.tsx (1). Population unmoved: 625 judged / 625 inherit / 0 frozen, before and after. A ratchet — no sweep owed.

Pins, and their non-vacuity control

scripts/__tests__/check-vi-mock-inherit.test.ts gains 10 cases: 6 in the POSITIVE control block (the file's own name for its "this must read frozen" block, which is where C and D belong by its own vocabulary — the brief called it the negative-control block) and 4 accept-side counterweights in the negative control block (the eleven). The suite goes 74 tests to 84.

Non-vacuity: each new refusal is paired with the SAME fixture minus the object-literal wrapper, and that twin must read inherits. The two differ by the wrapper alone, so a frozen verdict cannot come from the gate bailing out early (indirect, unreadable, "never obtains the real module") — it can only come from the gate having READ the operand. The reason string is pinned to the one the gate emits AFTER collecting spreads, for the same purpose.

Ablation — the mutation is proved on disk before any result is read

The fix was committed first, then reverted in place (holdsObtainedModule restored byte-for-byte to its pre-fix body), with an EXIT INT TERM trap holding an absolute-path git checkout HEAD -- restore:

== HEAD blob            : 0b79902cabf552a0a70d3a52ca4e9f576376de3a
== on disk before mutate: 0b79902cabf552a0a70d3a52ca4e9f576376de3a
python: replacement written
== on disk after mutate : a83202dbe23dea6cf48a7393146ce8751057571f
== removed-text count   : 0 (must be 0)
== injected-text count  : 1 (must be 1)
== MUTATION CONFIRMED ON DISK
== ABLATED PIN SUITE EXIT: 1
     × C — spreading an object literal that merely HOLDS the obtained module is frozen
     × D — the same evasion with the obtained value bound to a const first
     × the nesting is refused one level up too — a BINDING that merely holds it
     × an ARRAY around the obtained module is refused for the same reason
     × an object literal is refused even when its OWN contents would inherit
 Test Files  1 failed (1)
      Tests  5 failed | 79 passed (84)
== ABLATED GATE EXIT: 0
== on disk after restore: 0b79902cabf552a0a70d3a52ca4e9f576376de3a
== git diff HEAD (must be empty):
== RESTORE CONFIRMED (blob == HEAD blob, diff empty)

Two readings recorded as they came out rather than as a template predicts:

  • 5 of the 6 new refusals are ablation-sensitive. The sixth — spreading the parenthesised callback, ...(importOriginal) — was already frozen before this change, because the old mention test also required a ( after the token and there is none. It is a regression guard against the new grammar losing that, not new-behaviour evidence, and is reported as such rather than counted in the ablation.
  • The gate itself still exits 0 under the ablation. No call site in this tree writes the C or D shape, so the repo scan cannot see this defect at all; the pins are the only thing that can. That is the "green at rest" argument the file's own header makes, observed from the inside.

Checks run

$ node scripts/check-vi-mock-inherit.mjs                 exit 0   (census above)
$ pnpm check:control-bytes                               exit 0   ✅ scanned 6655 tracked text file(s); skipped 85 binary
$ pnpm check:vi-mock-specifiers                          exit 0   ✅ 879 relative specifier(s) resolved, 903 bare
$ pnpm check:comment-mask-corpus                         exit 0   ✓ 4457 files, 1 disagree (the residue objectui#7882 holds open)
$ node scripts/check-changeset-presence.mjs              exit 0   ✅ no changeset owed (0 published source files changed)
$ node scripts/check-governed-queue-guard.mjs --test ... exit 0   ✅ NOT GOVERNED — 2 path(s), none matched
$ pnpm type-check:scripts                                exit 0
$ pnpm lint:root                                         exit 0   ✖ 32 problems (0 errors, 32 warnings) — all pre-existing, none in the two changed files
$ pnpm exec vitest run [the 5 files that read this gate] exit 0   Test Files 5 passed (5) / Tests 236 passed (236)

The five test files are every reader of check-vi-mock-inherit in the tree (git grep -l): its own pin suite, check-readme-exports.test.ts, js-comment-mask-jsx-6891.test.ts, check-vi-mock-specifiers.test.ts and ConversationsSidebar.test.tsx. Exit codes were captured before any pipe.

No changeset: the diff is scripts/** only, which publishes from no package — check-changeset-presence.mjs agrees and is the authority.

Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr

`holdsObtainedModule()` asked whether the obtained token appeared ANYWHERE
inside the spread's text, not whether the module IS the thing being spread.
So a spread of an object literal that merely NESTS the obtained module read
as `inherits`, and the gate quoted the evasion back in its own reason line:

    ...({ _: await importOriginal() })

That object carries exactly ONE inherited key, so the next export any module
in the file's import graph reads at module scope still resolves to
`undefined` -- the objectui#6849 failure the gate exists to stop, wearing the
accepted spelling's clothes.

Replace the mention test with `operandDenotes()`, which reads the operand as
ONE whole expression through a small grammar whose every production preserves
the invariant that makes a spread inherit: the operand's KEY SET is the real
module's, so it grows when the real module grows. `await`, parentheses,
`as`/`satisfies` and `!` are transparent; calling the obtainer produces the
module; a property read keeps a key set the module owns; an object literal or
an array does not.

Measured on 47053c9 by running the gate's own `scan()` before and after and
diffing PER SITE: 625 judged / 625 inherit / 0 frozen both ways, all 625 rows
byte-identical in verdict AND reason. A ratchet, so no sweep is owed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
@github-actions github-actions Bot added the tests label Sep 7, 2026
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

ACCEPT — domain:devx @ objectui execution seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr, R46, reviewed 2026-09-07T17:00Z against GitHub and the tree, ⛔ never against the report's narrative.

The fences held, checked mechanically rather than read

The diff is 2 files, +306/-16, draft, head 679242dba, based on 47053c9f6 — the post-#8391 tip, so this builds on the resolver rather than racing it. Scanning the gate's patch for every fenced identifier returns zero touched lines for isCovered, coveredPrefixes, COVERED_SPECIFIERS and and their subpaths judged. #8117 is not folded in.

The repair is the right shape, and the reason is in what it refuses without being told to

operandDenotes() replaces a mention test with a small whole-expression grammar whose stated invariant is that the operand's key set is the real module's, so it grows when the real module grows. That is the property the gate actually needs, and the evidence it is the property rather than a list of known evasions is that the array form is refused without ever having been designed for — one rule closing a class, not two instances. ⭐ The object-literal exclusion is taken deliberately even where the contents would inherit (...{ ...actual }), argued in the header, and pinned; the one nesting that would be correct spells the same thing as ...actual and no site writes it.

The load-bearing measurement is the one this dispatch demanded, and it is honest about its own scope

625 judged / 625 inherit / 0 frozen before and after, with all 625 rows diffed PER SITE on verdict and reason string against the base gate — byte-identical. That is the "prove no false refusal by census, ⛔ not by inspection" requirement met exactly. The nine distinct operand shapes the tree actually writes are enumerated and each pinned as its own case, so the accept side is defended by construction and not by the aggregate count.

⭐ And the dev caught two of its own implementation bugs with that census before delivering — the first operandDenotes omitted </> from the bracket-pairing table, so generic argument lists would not strip and the census fell from 625 inherit to 41: 584 false refusals. That is precisely the failure this brief was most worried about, it was found by the instrument rather than by eye, and it is reported rather than quietly fixed. This is why the census requirement was not ceremony.

⭐ The report's most valuable line is the one that limits its own claim

The GATE itself still exits 0 under the ablation. No call site in this tree writes the C or D shape, so the repo scan cannot see this defect at all — the pins are the only thing that can.

⇒ The acceptance criterion "reverting your change turns your new pins red" is satisfied by the pins, ⛔ not by the gate's exit code, and the dev says so instead of letting the green stand in for proof. Same shape as #8383's non-vacuity leg this afternoon: an assertion is only worth what its ability to say no is worth. The ablation proves the mutation landed on disk (blob 0b79902ca → a83202dbe, removed-text count 0, injected-text count 1) before any result was read, and the harness exits 90/91/92 rather than reporting a pass if any of those preconditions fail.

⚠️ The dev also declines to count a sixth refusal that was already frozen on the base (...(importOriginal) — the old mention test also required a ( after the token). Reported as a regression guard rather than as new-behaviour evidence. ⛔ Not padding the result is worth as much as the result.

⚠️ One observation from this review, filed as a note rather than a change request

closingIndex / openingIndex treat < and > as an unconditional bracket pair. TypeScript's grammar is genuinely ambiguous there — a => or a comparison inside an operand would skew the depth counter, and beforeTypeAssertion walks that same counter. On today's measured population this is zero-risk: none of the nine operand shapes in the tree contains either, and the per-site diff is empty. It is recorded because the failure direction matters — it would surface as a false refusal, which reds CI loudly on correct code rather than passing silently, so it is self-announcing rather than latent. ⛔ No change requested and no card filed: a hypothetical with no occurrence is not a finding.

Two corrections to this seat's own dispatch, both the dev's and both right

  1. The brief said C and D belong in the pin's negative-control block. By that file's own vocabulary a negative control is correct code that must never be flagged, and a positive control is a failure shape — so C and D went into the positive-control block and the four new accept-side counterexamples into the negative-control block. The dev used the file's definitions over the brief's wording and said so.
  2. The brief referred to "the member-access forms the file already documents". Measured: the header documents no member-access form at all (its only documented non-trivial shape is the (orig as any)() cast-then-call), and no site in the tree uses one. The dev accepted member access because the brief explicitly required it, then wrote the missing justification into the header — a property read keeps a key set the module owns — and pinned it. Documenting rather than transcribing was the right call.

No changeset owed (scripts/** only; check-changeset-presence agrees). Not governed surface (--test on both paths ⇒ NOT GOVERNED). One NOT-MEASURED result is recorded rather than reported as a pass: a first byte-hygiene call hit MODULE_NOT_FOUND on a wrong script name before the correct check:control-bytes was run green.

Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe (operandDenotes present on re-fetched origin/main with </> in both bracket-pair tables; control: the census still reads 625 judged / 625 inherit / 0 frozen, i.e. the ratchet did not move and nothing was newly refused) → LANDED here and on #8183, which closes via Fixes.

⇒ #6892 becomes dispatchable once this lands — it is the last card queued on this file.


Generated by Claude Code

@baozhoutao
baozhoutao marked this pull request as ready for review September 7, 2026 17:11
@baozhoutao
baozhoutao added this pull request to the merge queue Sep 7, 2026
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Armed: PR #8406 flipped ready at 2026-09-07T17:11:18Z on head 679242dba after CI converged all green (28 checks, Live E2E excluded, read 17:11:11Z); post-flip Governed Surface Queue Guard completed/success at 17:11:38Z; auto-merge SQUASH enabled; queued (added_to_merge_queue at 17:11:47Z, read 17:11:52Z).

Landing probe on merge, on re-fetched origin/main: operandDenotes present, with </> in both bracket-pair tables (closingIndex and openingIndex) — their omission was the bug that produced 584 false refusals during development, so their presence is the thing worth re-reading on the merged tree rather than trusting. Control: the census still reads 625 judged, 625 inherit, 0 frozen — the ratchet must not have moved and nothing may be newly refused; a census that dropped would mean a false refusal landed. Then LANDED here and on #8183, which closes via Fixes.

⇒ #6892 becomes dispatchable when this lands — it is the last card queued on scripts/check-vi-mock-inherit.mjs. — domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr.


Generated by Claude Code

Merged via the queue into main with commit fff250f Sep 7, 2026
31 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-8183-holds-obtained-module-operand branch September 7, 2026 17:27
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

LANDED — merged into main at 2026-09-07T17:27:40Z as fff250ff1 (squash), read 17:27:43Z. #8183 closed completed via Fixes.

Content probe on re-fetched origin/main (tip fff250ff1, read 2026-09-07T17:30Z) — the Armed note's two claims:

  1. operandDenotes present at scripts/check-vi-mock-inherit.mjs:1180, and holdsObtainedModule() is retained as the named entry point now delegating to it (:1235-1238) — return operandDenotes(text, token, tokenIsValue) === 'module'; — so both call sites (:1408 binding propagation, :1434 the spread decision) go through the new grammar with no third path left behind.
  2. The bug that produced 584 false refusals is fixed on the merged tree, which is why this and not the headline was chosen as the probe: </> appear in both bracket-pair tables — closingIndex at :1098 and openingIndex at :1111.

Control — taken from the gate RUNNING on merged main, not from a source grep. The post-merge push run of Inert vi.mock Specifiers (34147701330, head fff250ff1, step completed 17:27:57Z) prints:

✅  check-vi-mock-inherit: OK (4458 tracked source file(s), 2724 test-named; 616 carry a mock;
    625 call site(s) on … and their subpaths judged (625 inherit, 0 auto-mocked);
    35 other workspace, 243 external, 879 local, 0 non-static, …)

⇒ 625 judged / 625 inherit / 0 frozen on main after the change — byte-for-byte the census the dev measured before it. Zero false refusals landed. ⭐ That is the reading that matters here: the whole risk of this PR was tightening a recogniser too far, the dev's own first attempt did exactly that (625 → 41 inherit), and the merged tree is measured — by the gate itself, in CI, on main — to have moved nothing. A source grep could not have told us that.

Incidentally the same line re-confirms #8391 an hour on: the verdict reads … and their subpaths judged, with 35 other workspace.


Generated by Claude Code

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

finding(test-infra): check-vi-mock-inherit counts a spread that merely MENTIONS the obtained module as inheriting it

2 participants