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

fix(gates): resolve a bare export { X } against the file's own imports - #7961

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-7275-bare-reexport-barrel-skip
Sep 6, 2026
Merged

baozhoutao merged 1 commit into
mainfrom
claude/issue-7275-bare-reexport-barrel-skip

Conversation

@claude

@claude claude Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #7275

The rule

A bare export { X } is a barrel line too: the re-export arm now resolves the exported local name against the file's own imports and applies the existing barrel skip to it, so export { X } over import { X } from './x' is skipped exactly as export { X } from './x' already was.

scanFile's skip read the export's module specifier (if (fromModule && (fromModule.startsWith(".") || fromModule.startsWith("@object-ui/"))) continue;). A bare export { X } has none, fromModule was null, the skip never fired, and the name was recorded as a re-export finding located at the barrel — pointing a reader at the wrong file and putting the ALLOW / DEBT ratchets within reach of an edit to a barrel rather than to the shape, which is the failure mode the skip exists to prevent.

The import loop that builds specBindings now also records every binding's source module (importedFrom); nothing else about that loop changed. Alias form resolves by the local name (propertyName ?? name), so export { X as Y } is judged on X. Forms with a specifier are untouched.

⛔ What is deliberately NOT skipped

A blanket "skip every bare export { X }" would pass the first two cases below and silently delete the rest of rule 1. All four are pinned as fixtures:

bare export { X } where X is bound by result
a relative / @object-ui/* import skipped — judged at its declaration site
an @objectstack/spec import derivation, via the unchanged specBindings arm
nothing (declared in this file) still a visible finding
a third-party import still a finding — this scan does not cover that module, so nothing else judges the name

Measured: before / after

Same corpus both runs, on this branch's base d39ede24e against @objectstack/spec 17.2.0 — 1348 files scanned against 4959 spec export names in both.

rule 1 findings declared dialects (ALLOW) untriaged collisions (DEBT)
before 36 20 14 in 7 packages
after 35 19 14 in 7 packages

The whole delta is one line:

- re-export ListView  packages/plugin-list/src/index.tsx:15

Every other finding in the tree is byte-identical (full dump diffed before and after; the removed row is the only one). Rule 2 and rule 4 are unmoved: 2 declared deliberate copies, 19 unbacked claims in 5 packages, and no member citation.

Ledger disposition

@object-ui/plugin-list:ListView was kept alive by that barrel line alone — the component at ListView.tsx is skipped structurally by rendersJsx. With the barrel attributed correctly the name matches nothing, and ratchet 3 said so on the run in between:

@object-ui/plugin-list:ListView is in ALLOW but no longer collides with a spec export name

So the entry is deleted, with a tombstone in the same shape as the two beside it recording what it carried beyond the waiver (spec-symbol-batch6.test.tsx still fails if the spec's ListView stops being authored metadata or if the export stops being a component that consumes it).

⛔ @object-ui/auth:AuthProvider and @object-ui/plugin-list:UserFilters are not re-added. #6291 deleted them because they matched nothing, and the corrected scan does not report them either — re-adding either would be a stale entry on the run that added it. Three entries written on one judgement; all three are now made structurally, and none of them is reachable by editing a barrel.

Verification

  • node scripts/check-spec-symbol-derivation.mjs — before: exit 0, 20 declared dialects; with the scanner fix but the entry still in ALLOW: exit 1, ratchet 3 (quoted above); final: exit 0, 19 declared dialects.
  • pnpm exec vitest run --maxWorkers=2 scripts/__tests__/check-spec-symbol-derivation.test.ts — 60 passed (55 before, 5 new). It is the only file in the repo that imports the edited module; every other reference to it is prose.
  • pnpm type-check:scripts, pnpm lint:root (0 errors), pnpm check:control-bytes, check:entry-guard, check:unreferenced-sources, check:vi-mock-specifiers, check:vi-mock-inherit, check:shell-escape-residue, lint:coverage, type-check:coverage — all exit 0.
  • node scripts/check-changeset-presence.mjs — No source or published contract of a released package changed in this range, so no changeset is owed.
  • node scripts/check-governed-queue-guard.mjs --test on both changed paths — NOT GOVERNED.

Planted probe (predicted, then observed), on the live barrel itself: const NavigationConfig = { mode: 'page' }; export { NavigationConfig }; appended to packages/plugin-list/src/index.tsx. The gate reported both halves — const NavigationConfig … :16 and re-export NavigationConfig … :17 — in the same file whose sibling re-exports are now silent. Restored; blob hash back to the HEAD blob and git diff HEAD empty.

Ablation on the committed tree — the two new lines removed, mutation proven on disk (anchor count 1 → 0, blob ba20382b → f01c6018):

  • fixtures: 2 failed | 58 passed — cases (a) and (e), the two that depend on the branch; (b), (c), (d) stayed green, which is what says the ablation removed the resolution and not the arm.
  • the gate: exit 1 — but in the reverse direction from the run before the ledger edit, and that is the honest reading. With the ALLOW entry now deleted, the reappearing barrel finding is not re-excused, it is fresh: @object-ui/plugin-list declares 1 spec-named symbol the spec already owns: re-export 'ListView' packages/plugin-list/src/index.tsx:15. The fix and the ledger edit hold each other up in both directions.
  • restored: blob equal to the HEAD blob, git diff HEAD empty, anchor count back to 1.

All runs measured at ab22b86d6. Heavy runs went through the shared verify lock (VERDICT command-exit 0); wall-clock figures under it are shared-box readings.

⚠️ Overlap with an in-flight PR

Draft PR #7685 (#7122, head 7be4b2456) carries one hunk on this same file, @@ -670,46 +670,18 @@ in the ALLOW map, retiring the two #7580 BreakpointName / BreakpointColumnMap entries. My hunks are non-adjacent by construction — the re-export arm (:1614–:1690), the ListView entry / tombstone (:585–:616) and the rule-2 header clause — so a three-way merge is clean. Whichever lands second should merge main first, because both PRs move the declared dialects count the gate prints.

Judgement, on the four axes

The only real choice here was the disposition of the three renderer entries, and specifically whether to keep ListView's.

  • 实际业务需求 — measured, not assumed: the entry excuses nothing after the fix (ratchet 3 quoted above), and its behavioural content is held by spec-symbol-batch6.test.tsx, which does not depend on the entry existing. Keeping it would serve no reader.
  • 项目长远合理性 — deleting it is the contract-first move. The alternative (leaving it, or rewriting the barrel so it keeps matching) fixes the ledger at the barrel, which is exactly what this card says the scanner must stop being able to do.
  • 防 AI 写代码犯错 — a stale ALLOW entry reserves the name: the next hand-written ListView under it would land silently. That is the tightening this repo prefers over a tolerant carry-over, and it is why the fix reports a local declaration twice (at its declaration and at its bare export) rather than teaching the scanner that a bare export is always someone else's problem.
  • 创业阶段不扩散需求 — no new surface, no new flag, no transitional double spelling: one predicate shared by the two spellings of the same barrel line, and one entry fewer in the map.

Generated by Claude Code

…rts (objectui#7275)

`scanFile`'s re-export arm skips a barrel that re-exports a module this scan
already covers — a relative path or an `@object-ui/*` sibling — because whatever
it points at is judged at its own declaration site. The skip read the export's
MODULE SPECIFIER:

    const fromModule = stmt.moduleSpecifier && ts.isStringLiteral(...) ? ... : null;
    if (fromModule && (fromModule.startsWith(".") || fromModule.startsWith("@object-ui/"))) continue;

A bare `export { X }` written over a local `import` has no specifier, so
`fromModule` was `null`, the skip never fired, and the name was recorded as a
`re-export` finding located AT THE BARREL. That points a reader at the wrong
file, and it puts the ALLOW / DEBT ratchets within reach of an edit to a barrel
rather than to the shape — precisely the failure mode the skip exists to prevent.

The fix keeps the import loop that builds `specBindings` and has it also record
every binding's source module (`importedFrom`). A bare re-export now resolves its
LOCAL name (`propertyName ?? name`, so `export { X as Y }` resolves by `X`)
against that map and is skipped only when the binding comes from a module this
scan already covers. The two forms a blanket skip would have lost are pinned:
`import { X } from '@objectstack/spec'; export { X }` stays derivation via the
unchanged `specBindings` arm, and `const X = ...; export { X }` stays a visible
finding. An import from a third-party module is not skipped either, for the same
reason `export { X } from 'some-lib'` is not: this scan does not cover it.

Measured on d39ede2 against @objectstack/spec 17.2.0, same corpus both runs
(1348 files, 4959 spec export names): rule 1 reported 36 findings before and 35
after. The single removed finding is `re-export ListView` at
packages/plugin-list/src/index.tsx:15 — the tree's only instance. Every other
finding is byte-identical.

Ledger disposition. `@object-ui/plugin-list:ListView` was kept alive by that
barrel line alone; with it gone the name matches nothing and ratchet 3 failed the
entry ("is in ALLOW but no longer collides with a spec export name"). The entry is
deleted with a tombstone in the shape of the two beside it, and the map goes from
20 declared dialects to 19. `@object-ui/auth:AuthProvider` and
`@object-ui/plugin-list:UserFilters` are NOT re-added: the corrected scan does not
report them either, which is why objectui#6291 deleted them. Three entries written
on one judgement, all three now made structurally.

Claude-Session: https://claude.ai/code/session_013uAaxiwgYDybsTNV9xwa1M

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

2 participants