Skip to content

fix(cli): os migrate meta --write writes a moved form as a form item, or leaves it in its view - #39453

Draft
objectstack-fleet[bot] wants to merge 3 commits into
mainfrom
claude/issue-39392-wip
Draft

objectstack-fleet[bot] wants to merge 3 commits into
mainfrom
claude/issue-39392-wip

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #39392

Clause-②: no
Metadata-protocol: none

维护者速读

  • 开发者把带表单视图的 18.x 应用一键升级到 19 时,表单以前被从视图里删掉却没写到任何地方,现在要么写成独立表单项,要么原样留在视图里并列为待手工处理。
  • 属于 19 版升级路径(正式发布前的重点),替所有带表单视图(含公开收集线索表单)的老应用解决升级后表单丢失、公开表单打不开的问题。
  • 出错时最坏是某个表单被留在原处、命令以失败退出并点名要手工搬的那一项,不会再静默丢内容;改动只在升级命令里,可直接撤回。
  • 无

What changes

os migrate meta --from 18 --write plans its source edits by diffing the normalized stack against the migrated one and attributing each change to the conversion entry that explains it, by path. A conversion that MOVES content to another collection (the protocol-19 form move views[i].formViews.KEY → forms[name=OBJECT.KEY], and its translation-tail move _views.KEY.title / submitBehavior → the bundle's forms['OBJECT.KEY']) reports the site it took the content from and names the destination only in to. No path rule tied the destination's change to that entry, and a change no entry explains is never written, so the source's removal was written alone: the form was deleted from the view file and written nowhere, the run said "no mechanical change remains", and os validate passed.

  • packages/cli/src/utils/authored-source-codemod.ts: new moveDestination() reads an absolute destination path out of an entry's to (keys, [0], ['a.b'], [name=X]; resolved against the migrated stack, or packages[i].manifest when the entry's path starts there) and returns it only when it reaches a value the chain changed. explainingEntries() joins every entry whose destination a change sits at, inside or around, unconditionally. Source and destination are therefore one component: written together, or both left as not written with the reason (for example a stack whose forms is built by a call such as exportsOf(forms)), and the view block keeps its bytes. No conversion is known by name; a to that is a display value, a single key, relative, or unresolvable names no destination.
  • WrittenSite gains optional movedTo { file, line }; the human report prints forms[name=OBJECT.KEY] ← views[i].formViews.KEY under the destination's file, and --json adds movedTo to the written site.
  • An internal record form (record-form slot, no public link, no action opening it) is still deleted, as the conversion already decided.
  • Changeset: @objectstack/cli patch.

Tests

New packages/cli/src/commands/migrate/meta.write-form-move-39392.test.ts (unit tier, in-process MigrateMeta.run over temp projects linking the real @objectstack/spec), 5 cases:

  1. Blank scaffold wiring (exportsOf(…), no forms: key): formViews.intake lands in a new forms: list with the converted body, the view block goes only then, re-run is clean; the internal record form is deleted.
  2. Human report lists the destination beside the site; nothing reported unexplained.
  3. A public form plus its zh-CN submitBehavior tail: both moves write both halves.
  4. Refuse-and-keep: forms: built by a call ⇒ view file keeps its bytes, move listed not written, exit 1.
  5. The human report names that move as not written.

Fails on main, passes here (both the write path and the refuse path), measured by swapping origin/main's meta.ts and authored-source-codemod.ts into this tree:

main source:  Tests  5 failed (5)   e.g. "expected [ 'forms' ] to deeply equal []" (the destination was the unexplained change),
              "expected [ 'translations[0].zh-CN.forms', …(1) ] to deeply equal []", "expected undefined to be 1" (no exit 1 on the refuse path)
this branch:  Test Files  1 passed (1)   Tests  5 passed (5)

Local, at 2e00cd3 (all under os-verify-lock):

turbo build --filter=@objectstack/cli^... --filter=@objectstack/cli   70/70 successful   VERDICT command-exit 0
vitest --project unit, the 22 unit files importing meta.ts or authored-source-codemod.ts   22 files / 173 tests passed   VERDICT command-exit 0
pnpm --filter @objectstack/cli run typecheck   tsc + check:test-typecheck OK   VERDICT command-exit 0

The full cli unit project did not fit the container's foreground cap and was stopped, so it is narrowed to the 22 files above and declared to CI; the integration tier is CI's.

Acceptance notes

  • Narrowing declared: full cli unit project and integration tier, CI. Derived gates: 72 derived, 67 run green, 5 not measured locally (two refused on prerequisites outside the cli closure: check:dual-build-cjs-loads, check:i18n-coverage; one checker-health self-test needing a deeper clone: check-plugin-teardown-shape --self-test; two killed on the shared box: check:query-options-erasure, check:type-check-debt), all CI's.
  • Resumed from claude/issue-39392-wip@90b28ccb after a container restart; this run verified the commit, merged origin/main, and ran the tests and gates.
  • No spec, conversion entry or stored-form file is touched; the stored-metadata half of the same switch is a separate card.

Verification

Read first, by risk:

  1. packages/cli/src/utils/authored-source-codemod.ts: moveDestination and the explainingEntries join (the only change to what gets written).
  2. packages/cli/src/utils/authored-source-codemod.ts: the written.push hunk computing movedTo.
  3. packages/cli/src/commands/migrate/meta.ts: the report lines.

Two-minute check: pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 src/commands/migrate/meta.write-form-move-39392.test.ts ⇒ Tests 5 passed (5).


Generated by Claude Code

…ith its source, or neither

A conversion that moves content to another collection (the protocol-19 form
move, its translation tails) reports the site it took the content from and
names the destination only in `to`. The planner tied the destination's change
to no entry, so it was never written while the source's removal was: the form
was deleted from the view and written nowhere. The planner now reads an
absolute destination path from `to` and joins its change to the entry, so the
two are written together or left together.

Claude-Session: https://claude.ai/code/session_016WV4cxRh6Sbfo2Xm49JPx6
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

8 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
  • 1 anchor(s) matched too much of the corpus to be a work list: os migrate meta (command, 44 pages)
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 41 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7f43ae6c75b1044de72c4af3da0b194da7a0dd60 — the merge of head 2e00cd31774246647856b88894e1c606fffb56b5 into base c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7f43ae6c75b1044de72c4af3da0b194da7a0dd60 && git checkout 7f43ae6c75b1044de72c4af3da0b194da7a0dd60
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c 2e00cd31774246647856b88894e1c606fffb56b5 && git checkout -B drift-repro c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c && git merge --no-ff 2e00cd31774246647856b88894e1c606fffb56b5

node scripts/docs-audit/affected-docs.mjs --json c9ea363d71087bd9d16e0a8ee6de0c5f76331e0c

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czfEjskBjZM6jhKWFR

2026-12-04T01:04Z · L1-a verdict: ACCEPT at head 2e00cd3177 (zone em-upgrade, card #39392, p1) — CI not yet green at read time

席位核对

Checklist verdict. Shape: open, draft, base main, Fixes #39392 first line, no keyword on another card. Fixes is right: the card's expected state is "the forms are written as form items, or left in place and listed as not written", and the PR does exactly those two, plus the zh-CN submitBehavior / title tail from Repro B. Clause-②: no · Metadata-protocol: none hold: the CLI's write planner changes, no spec or conversion entry. Four files under packages/cli; no contract-review face is touched, so no L2 is owed. The changeset sentences match the diff: written with the view block removed only then, the refuse-and-keep path with exit 1, movedTo in --json, the internal record form still deleted, and the restore-from-VCS line for anyone who already ran --write on next.4.

Code read.

  • moveDestination reads a destination only when the whole to parses as an absolute path of two or more steps (keys, [0], quoted keys, [name=X]), resolved in the migrated body the entry belongs to (packages[i].manifest or the stack), and only when that value changed. A display value, a single key, a relative path or an unresolved one yields null. So the join can only bind a source to a destination it really wrote.
  • explainingEntries adds every entry whose destination is at, inside or around the change, unconditionally. Joined entries become one component in the existing union-find, so source and destination are written together or both land in manual with the refusal. The failure mode is wider all-or-nothing components (a site left by hand), never a deleted block with no destination. That is the safe direction for a p1 data-loss bug.
  • movedTo is taken from the resolved change in the same component; meta.ts prints it under the destination file and counts that file among the chain's files.

The size call the zone asked to judge. Accepted. authored-source-codemod.ts is 2,246 lines on main; this PR adds net +98 (with #39449's +~30, still well under the 300-line threshold the split rule names). moveDestination and valueAtPath are a fix to the attribution step this file owns, not a new responsibility, so a new module is not owed here. If the file grows again, the split card goes to the seat.

Evidence. New test, 5 cases: all 5 fail with main's meta.ts and codemod swapped in (the destination is the unexplained change; no exit 1 on the refuse path), all 5 pass on the branch. The 22 unit files that import either module: 173 passed. CLI typecheck and check:test-typecheck OK. git merge-tree --write-tree of this head with #39449's head (2f035937cc): clean (read here). Gates at this head: 25 success, 18 expected skip, 0 failed, 12 pending at read time (Test Core shards and the floor checks among them). Landing needs every check green or expected skip on the head that lands. The full CLI unit project and the integration tier are CI's, as declared.

End-to-end, recorded. The tests stop at the written source and a clean re-run. The card's user-visible loss (GET /api/v1/forms/contact-us 404 after the 18.6.0 showcase upgrade) is re-checked by the QA re-run of #39391 S2 after merge. The zone tells the QA seat the merge sha.

Pointer for #39392: ACCEPT → PR #39453 (this comment). Not governed: the zone lands it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants