This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(gates): resolve a bare export { X } against the file's own imports - #7961
Merged
Merged
Conversation
…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>
baozhoutao
marked this pull request as ready for review
September 6, 2026 04:52
This was referenced Sep 6, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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, soexport { X }overimport { X } from './x'is skipped exactly asexport { X } from './x'already was.scanFile's skip read the export's module specifier (if (fromModule && (fromModule.startsWith(".") || fromModule.startsWith("@object-ui/"))) continue;). A bareexport { X }has none,fromModulewasnull, the skip never fired, and the name was recorded as are-exportfinding 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
specBindingsnow also records every binding's source module (importedFrom); nothing else about that loop changed. Alias form resolves by the local name (propertyName ?? name), soexport { X as Y }is judged onX. 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:export { X }whereXis bound by@object-ui/*import@objectstack/specimportspecBindingsarmMeasured: before / after
Same corpus both runs, on this branch's base
d39ede24eagainst@objectstack/spec17.2.0 — 1348 files scanned against 4959 spec export names in both.The whole delta is one line:
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:ListViewwas kept alive by that barrel line alone — the component atListView.tsxis skipped structurally byrendersJsx. With the barrel attributed correctly the name matches nothing, and ratchet 3 said so on the run in between: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.tsxstill fails if the spec'sListViewstops being authored metadata or if the export stops being a component that consumes it).⛔
@object-ui/auth:AuthProviderand@object-ui/plugin-list:UserFiltersare 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 --teston both changed paths —NOT GOVERNED.Planted probe (predicted, then observed), on the live barrel itself:
const NavigationConfig = { mode: 'page' }; export { NavigationConfig };appended topackages/plugin-list/src/index.tsx. The gate reported both halves —const NavigationConfig … :16andre-export NavigationConfig … :17— in the same file whose sibling re-exports are now silent. Restored; blob hash back to the HEAD blob andgit diff HEADempty.Ablation on the committed tree — the two new lines removed, mutation proven on disk (anchor count 1 → 0, blob
ba20382b→f01c6018):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.@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.git diff HEADempty, 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.Draft PR #7685 (#7122, head
7be4b2456) carries one hunk on this same file,@@ -670,46 +670,18 @@in the ALLOW map, retiring the two #7580BreakpointName/BreakpointColumnMapentries. My hunks are non-adjacent by construction — the re-export arm (:1614–:1690), the:585–:616) and the rule-2 header clause — so a three-way merge is clean. Whichever lands second should mergeListViewentry / tombstone (mainfirst, because both PRs move thedeclared dialectscount 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.spec-symbol-batch6.test.tsx, which does not depend on the entry existing. Keeping it would serve no reader.ListViewunder 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.Generated by Claude Code