Repository navigation
fix(cli): migrate meta --write reads export default X as an export, not a second use - #39449
Conversation
… not a second use
The stock generator writes `export const X = …; export default X;`. The
codemod's reference count read the `export default X;` identifier as another
use of X and refused every edit in such a module as [shared]. That line
hands X out like `export { X }` does, so it is no longer counted; instead a
default import of the module now counts against X itself, so a module that
imports the default and reads it still makes the edit [shared].
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cxRh6Sbfo2Xm49JPx6
📓 Docs Drift Check4 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 41 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c87eccfbaa72849908442c562810370b0ae2fa25 && git checkout c87eccfbaa72849908442c562810370b0ae2fa25
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c 2f035937cca1574477d8139328a9ecaa33aba24d && git checkout -B drift-repro c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c && git merge --no-ff 2f035937cca1574477d8139328a9ecaa33aba24d
node scripts/docs-audit/affected-docs.mjs --json c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czfEjskBjZM6jhKWFR 2026-12-04T00:46Z · L1-a verdict: ACCEPT at head 席位核对Checklist verdict. Shape: open, draft, base Code read.
The point the zone asked to judge. Accepted. Treating Evidence. New test 5/5 on the branch, 1 failed / 4 passed on Pointer for #39396: |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6 2026-12-04T01:23Z · Landing (zone em-upgrade). L1 ACCEPT 7397220605 at head |
Requested by Elon · project thread
Fixes #39396
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
os migrate meta --writerefuses to edit a literal whose binding is read somewhere the walk did not go ([shared]). The generator's module shape,export const X = …;thenexport default X;, was refused: the reference count inauthored-source-codemod.tsread the identifier inexport default X;as a second use ofX.isReference: the identifier inexport default X;is no longer a read whenXis a module-level variable of that module. It is treated like theexport { X }specifier, which was already skipped.bindingOfExport: for the same statement, the module'sdefaultexport now resolves to the bindingXand not to a separatedefaultbinding. So a default import of the module (import person from './contact.object') counts as a use ofX. Without this half, skipping the export line would hide a real second use that comes through the default import. The ablation below pins it.export default (X),export default someImport, a call or a literal.Tests
New
packages/cli/src/utils/authored-source-codemod-39396.test.ts, which runs the planner in-process over temp projects:export { contact } from …: the edit is written. Red onmain(expected [ 'shared' ] to deeply equal []), green after the fix.export { default as contact } from …: the edit is written. This was already green; it pins that thebindingOfExportchange did not break it.[shared].contactby name and reads it: still[shared].contactagain itself: still[shared].Ablation: with the
bindingOfExporthalf reverted (on disk, same run), case 3 goes red (expected [] to deeply equal [ 'shared' ]). Without theisReferencehalf, case 1 stays red as onmain.Acceptance notes
export default X;whereXis a module-levelconst. Ifexport default X;re-exports an imported binding, it is still counted as a use, as before. That keeps the refusal on the safe side, and the generator never writes that shape.export { X } from …) is still not a use. Only modules that import and readXare counted, as before this change.Verification
Read first:
packages/cli/src/utils/authored-source-codemod.ts, thebindingOfExporthunk. This is the riskiest change: it moves default-import uses ontoX.packages/cli/src/utils/authored-source-codemod.ts, theisReferenceanddefaultExportedLocalhunk.packages/cli/src/utils/authored-source-codemod-39396.test.ts.Two-minute check:
pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 src/utils/authored-source-codemod-39396.test.tsshould report 5 passed.Local gate readings at 2f03593
maincode: 1 failed, 4 passed (case 1,expected [ 'shared' ] to deeply equal []).migrate-meta-write,-composed,-protocol-range,-own-field-row-38924,-default-range,-default-range-window,-strict-factories, plus the new file): 8 files, 77 passed, 1 skipped.pnpm --filter @objectstack/cli typecheck: exit 0.dispatch-gates.mjs --commands: 68 derived. 63 exited 0 on the first run.check:i18n,check:i18n-coverageandcheck:i18n-walk-parityexited 3 (CLI not built) and exited 0 after building the CLI. 2 NOT MEASURED:check-plugin-teardown-shape.mjs --self-test(shallow clone, pinned fixture commit unreachable) andcheck:dual-build-cjs-loads(needs every package's dist).--ranreports 68 derived, 66 run, 2 NOT-MEASURED, 0 UNRUN.overlap-check.mjsis clean.git merge-tree --write-treeagainstclaude/issue-39392-wip(2e00cd3), which edits the same file in the form-move path, merges cleanly.@objectstack/cliunit layer andtest:repo. Both are left to CI, as declared.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cxRh6Sbfo2Xm49JPx6