Skip to content

fix(cli): migrate meta --write keeps the edits that stand on their own, and leaves a pair whole - #39123

Merged
objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/issue-38922-migrate-write-partial
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/issue-38922-migrate-write-partial

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #38922

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:从 18 升级到 19 的用户运行源码自动改写时,能改的改动(动作位置改名、协议版本范围)会留在文件里,不再因为一处改不了就全部撤回;改不了的那组会被整组点名列出。
  • 为什么做:这是 19 正式版的升级主路径,此前在示例应用上一个改动都留不下来,用户要手改一百多处。
  • 出错会怎样:若判断有误,最坏是某组改动被留给用户手改并点名,不会写出半套改动;回退本合并即可撤回。
  • 要你做什么:无

What changes

os migrate meta --from 18 --write on a showcase-shaped stack wrote, re-checked, disagreed with itself and restored every file: one view whose bulkActions named a helper-built action took the action-location renames and the engines.protocol move down with it.

  • Pairs are asked of the chain, before anything is written. A conversion can report one move at unrelated sites (a view's bulkActions removal, and selection added to the actions it names). The planner now re-runs the chain in memory over the stack the written sources would load (the stack the chain started from plus the written units' changes), per unit, and joins the units that cannot be written without each other. A pair one of whose sites is refused is left whole, as entangled, naming the site that holds it. Nothing names a conversion: the pairing is read from the chain's answers (packages/cli/src/utils/authored-source-write-units.ts, a new sibling module; the codemod is over 1,000 lines). One in-memory re-run when the plan is consistent; one per unit of the conversions in the disagreement otherwise.
  • The re-check over the written sources stays, at unit granularity. When it disagrees, only the units it names are put back (listed as not written [unverified]) and the rest is written again; a disagreement no written unit can be tied to still restores every file, as before.
  • Partial write, said first. The write group's first line: Wrote N of M mechanical change(s) into F file(s); K left because of CAUSES, listed below: (each cause with its count), followed by a pair group naming each pair's sites (path, item names, file:line or why it cannot be written) and its files.
  • Exit code. A --write that leaves any mechanical change (or the declared range) by hand exits 1; what it wrote stays written. A write that left nothing exits 0 as before.
  • --json. write gains pairs (sites with conversionId/path/file/line or kind/reason, and files) when a pair was left. No field renamed or removed; manual[] entries keep exactly their four keys.
  • CodemodRefusalKind gains unverified (the put-back units); entangled now also covers a held pair.
  • docs/qa/platform-checklist/areas/cli.json: the WRITE MODE verify text's exit-0 and "every file restored" claims rewritten to the per-unit behaviour (only that line; the "Applied" wording elsewhere in the file is the companion PR's).

#38879's wording is kept: "Would apply N" on a dry run, "N … to apply" with --write, never "Applied".

Tests

New packages/cli/src/commands/migrate/meta.write-partial.test.ts (4 cases, in-process over the real command):

  1. the showcase shape (literal config over a views and an actions module; one view naming a literal and a helper-built action, one naming a literal action; two location renames; range ^18): the renames, the second view's whole pair and the range are written, the first view's pair is left whole and named, exit 1, a second run finds only that pair;
  2. the human first line and the pair group, verbatim;
  3. control: the helper-built action written as a literal, everything written, no pairs, exit 0;
  4. the disk re-check puts back only the units whose bytes did not land, and writes the rest again.

Pins whose asserted behaviour this card changes, updated: test/migrate-meta-write.test.ts (partial write exits 1; first-line prefix), src/commands/migrate/meta.write-exportsof.test.ts (0-of-N write exits 1), test/migrate-meta-protocol-range.test.ts (a range that does not land is put back alone, the chain's edit stays).

Targeted run and ablations

All readings on head 18764e5eb7 unless named.

  • vitest run --project unit over src/commands/migrate/meta.*, test/migrate-meta* (unit tier), doctor-deprecation-hint-commands, invocation.test.ts, vitest-tiers-partition: Test Files 20 passed (20), Tests 217 passed (217). All eight --write suites are in the unit tier (vitest list).
  • pnpm --filter @objectstack/cli typecheck: exit 0.
  • Premise on the start point ec0a60d42e (before any edit), the same fixture shape in one file: --write wrote 1 file(s), but re-running the chain over them did not match this report, so every one was restored to its previous bytes: no longer converted: actions[1].locations, engines.protocol left at '^18'.
  • Ablations via scripts/ablation-replace.mjs, each restored (blob == HEAD, git diff HEAD empty), over the four write suites (62 cases):
    • A, the in-memory pair hold off (heldPairs answer replaced by an empty list): 3 failed / 59 passed (both showcase-shape cases and the put-back case; the control stays green).
    • B, the disk put-back off (disagreeingUnits answer empty, so every disagreement restores all): 2 failed / 60 passed (the put-back case and the range put-back pin).
    • C, the exit predicate off (leftByHand always false): 5 failed / 54 passed / 3 skipped (every exit-1 pin). A first C attempt was refused by the tool as a no-op (anchor inside the replacement) and re-run with a disjoint anchor.
  • Derived gate families (dispatch-gates.mjs --commands, 77): --ran reports 75 run, 2 NOT-MEASURED (check:dual-build-cjs-loads, check:i18n-coverage: PREREQUISITE NOT MET, they need a full workspace build; left to CI). check:test-source-alias was red on 74f3c5d2da (the two edited suites reached the command's dynamic imports without module-top loads); fixed in 0666c92821 with the same imports the sibling suites carry, re-run exit 0. After merging origin/main (#39112 among it): check:platform-checklist exit 0 and the targeted subset above re-run.

Acceptance notes

  • Exit 1 for any write that leaves a change by hand is the card's Expected 3 read literally; it also flips two earlier exit-0 pins for partial writes (refused sites, factory-built stacks).
  • Cost probe (20 views x 3 named actions, 5 with a helper-built action, 100 renames, 200 entries): --write 467 ms end to end, 175 written, 5 pairs held, re-check ok (shared box; ratio-wise negligible against the 7 s first load).

Verification

Two-minute check: in a v18 project whose list view names an action built by a helper, run npx os migrate meta --from 18 --write. Expect the first line of the write group to read Wrote N of M …; K left because of 1 pair(s) …, a 1 pair(s) left whole group naming the view, the actions and the files, engines.protocol now '^19', and exit code 1.

Files to read first: packages/cli/src/utils/authored-source-write-units.ts (heldPairs: the isolation run and the union), authored-source-codemod.ts Phase 5 in planAuthoredSourceWrite, meta.ts writeSources (the put-back loop and disagreeingUnits).


Generated by Claude Code

claude added 11 commits December 2, 2026 06:39
…nly what its re-check disagrees with

Claude-Session: https://claude.ai/code/session_01QSeKYoSKoNUygbCoMBTbGc
Co-authored-by: Claude <noreply@anthropic.com>
…grate-write-partial

# Conflicts:
#	packages/cli/src/commands/migrate/meta.write-exportsof.test.ts
#	packages/cli/src/utils/authored-source-codemod.ts
…klist verify text

Claude-Session: https://claude.ai/code/session_01QSeKYoSKoNUygbCoMBTbGc
Co-authored-by: Claude <noreply@anthropic.com>
… edited write suites

Claude-Session: https://claude.ai/code/session_01QSeKYoSKoNUygbCoMBTbGc
Co-authored-by: Claude <noreply@anthropic.com>
…grate-write-partial

# Conflicts:
#	docs/qa/platform-checklist/areas/cli.json
@github-actions github-actions Bot added size/xl 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 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

36 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)
  • 29 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 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 cef9a803ae9d3e01a8f77a338a37426a5f7dd1b6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 16dff1740e79b0bd2022cdbc30faa8ddf381855e — the merge of head 18764e5eb7057605b1ed5280e87a45f9fd96ed25 into base cef9a803ae9d3e01a8f77a338a37426a5f7dd1b6, 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 16dff1740e79b0bd2022cdbc30faa8ddf381855e && git checkout 16dff1740e79b0bd2022cdbc30faa8ddf381855e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin cef9a803ae9d3e01a8f77a338a37426a5f7dd1b6 18764e5eb7057605b1ed5280e87a45f9fd96ed25 && git checkout -B drift-repro cef9a803ae9d3e01a8f77a338a37426a5f7dd1b6 && git merge --no-ff 18764e5eb7057605b1ed5280e87a45f9fd96ed25

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

⚠️ 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-justin · os-justin · session_01QSeKYoSKoNUygbCoMBTbGc

Final green head for review · 2026-12-02T11:01Z
Head-sha: 18764e5eb7
Check-runs at this head: 40 success · 18 skipped · 0 failure · 0 pending.
Owed: L1 (seat session). Landing: zone build, after ACCEPT, if not governed.
Card #38922 · claim 7340158020 · amendments on the card · dev report 7342772453.
Points for the reader:

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

L1 ACCEPT · PR #39123 (#38922) · head 18764e5eb7057605b1ed5280e87a45f9fd96ed25 · read 2026-12-02T11:03Z

席位核对 · ACCEPT

ACCEPT · repo:objectstack@os-justin · head 18764e5eb7057605b1ed5280e87a45f9fd96ed25

  1. Shape. Draft, base main, Fixes #38922. 9 files, +1130 / −73, CLI only. Final green head per the zone's comment 7343328613.
  2. Card delivered.
    • --write keeps the units that stand alone: action-location renames, writable pairs, and the engines.protocol range.
    • A pair one of whose sites is refused is left whole and named.
    • The disk re-check puts back only the units it disagrees with; an untied disagreement still restores every file.
    • The premise is measured on ec0a60d42e: every file was restored.
  3. Design read (authored-source-write-units.ts heldPairs; meta.ts writeSources, disagreeingUnits, leftByHand).
    • Pairing is asked of the chain in memory: one re-run over the predicted stack, then one per candidate unit against a baseline without the candidates, joined by union-find. No conversion is named.
    • A throw over a predicted stack answers no pairs, and the disk re-check still judges the write. That is the right fail-safe direction: never a half pair on disk that the re-check would not catch.
    • The pairing lives in a new sibling module.
  4. The zone's points.
  5. Tests assert the substance. Four new in-process cases over the real command: the showcase shape with exit 1 and a second run finding only the pair; the verbatim first line and pair group; a control at exit 0; and a per-unit put-back. Three ablations go red on the expected pins: pair hold 3/62, put-back 2/62, exit predicate 5/62.
  6. Gates. Check-runs at this head: 58, 40 success / 18 skipped / 0 failed / 0 pending.
  7. Noted for the seat. meta.ts is now 2,027 lines, and cli: os migrate meta --stored calls a stored view's bulk actions "not declared as an action of that object" when the package declares them, and ends green (exit 0) while the runtime serves that row as invalid #38923 / cli: os migrate meta --from 18 says adding viewAllFields: true keeps a permission set's field reads, but a set with Modify All and its own row hiding a field still loses that field (read and edit) on 19 — the tool should name such entries #38924 queue on it.
    • The maintainer's split ruling (7311900364: splits rank after p1/p2 unless fleet efficiency is badly hit) governs. So the seat files no pure-move split now; the queued cards go first.
    • If a queued card's diff would grow meta.ts materially, the zone puts the new code in a sibling module, as this PR did.
  8. Landing. Not governed and Clause-②: no: the zone lands it per landing-operations.md.

Clause-②: no · Metadata-protocol: none

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYoSKoNUygbCoMBTbGc

Landing · 2026-12-02T11:04Z · head 18764e5eb7

  • L1 ACCEPT 7343376759 at this head (seat session); no L2 owed (--json additions: type not exported, vocabulary undocumented — per the ACCEPT).
  • check-governed-merges.mjs --pr 39123: NOT governed; +1130/−73 ≤ 3000.
  • Check-runs at this head: 40 success · 18 skipped · 0 failure (comment 7343328613).
  • landing-k.mjs --pr 39123: K = 4 < 15, OK.
  • Action: pr_ready + automerge_enable.
  • Carried nit (next zone text PR): the changeset gains a clause that manual[].kind gains unverified.

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/xl 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