You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 681fec2
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cli): migrate --write helper refusal names the blocking input and the site's items (#38631)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JeHmqv6CKCkW8ewrPBLekk)_Fixes#38319
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:做 18 升 19
升级、用命令自动改写元数据的作者,在组合多个包的项目里看到的"没写入"提示,改为点名真正挡路的那个输入和被挡住的包,并给出权限集、对象等条目的名字,而不再只给下标。
- 为什么做:替 HotCRM 的升级解决误导问题,他们 131 条提示都指向服务包,而要改的权限集其实在销售应用包里。
- 出错会怎样:只影响命令打印的提示文字,不改写任何文件、不改变哪些地方会被写入;提示措辞不好时作者仍能照路径手改,可直接撤回。
- 要你做什么:无
## What changes
`os migrate meta --write` on a `composeStacks([…])` project maps a site
in `packages[N]` to input N only while every input before it is a stack
literal (an earlier input could contribute any number of packages). That
refusal stays exactly as it is: same sites refused, same `kind`. Only
its text changes:
- **The blocked package's reason names the blocker as the blocker.**
When input `j` (before `N`) cannot be read, the loop in the
`composedPackages` step used to let input `j`'s own refusal escape
unchanged, so a site in `packages[6]` read "the value is built by
`createHotCrmServiceStack(…)`, not written as a literal", which is input
0's builder and not the site's. It now reads, for the test fixture:
> which input of `composeStacks(…)` built package 1 is unknown: input 0
(`ServiceStack`), before it, is not read as a stack literal (the value
is built by `build(…)`, not written as a literal), so the packages it
contributes cannot be counted
The refusal `kind` is the one the blocking input raised, so `--json`
`kind` values do not move. A site whose own input (j equal to N) is
helper-built keeps naming that input's builder, as before.
- **Each manual line names the items its path indexes into.**
`ManualSite` gains an optional `items` (the indexed elements on the
path, outermost first, each by its `name`, else `id`, else a package
entry's `manifest.id` / `manifest.name`, read from the normalised
stack), and the text report prints it between the site line and the `not
written [kind]` line, as: where packages[1] is `com.probe.app`,
objects[0] is `probe_room`.
Files to read first, by risk:
1. `packages/cli/src/utils/authored-source-codemod.ts`, the `case
'composedPackages'` loop: the try now wraps `composedInput` and, for j
below N only, the `manifest` lookup; j equal to N rethrows untouched, so
the target's own refusal is byte-identical to before.
2. `packages/cli/src/utils/authored-source-codemod.ts`, `pathItems` /
`itemName`: what counts as an item's name.
3. `packages/cli/src/commands/migrate/meta.ts`, `printWriteOutcome`: the
one added line.
## Tests
New case in `packages/cli/test/migrate-meta-composed.test.ts`: a
two-input composition whose input 0 is built by a helper and whose input
1 carries a site. It asserts the refusal kind and the named subjects,
not the prose: package 1's reason names the blocked package (package 1),
the blocking input (input 0, quoted as ServiceStack) and the blocker's
builder (build), and does not open with the old "the value is built by";
package 0's own reason still names its builder and no input index; the
text report's line under the package-1 site names the package id
com.probe.app and the object probe_room; no file is written.
<details><summary>Unit layer of @objectstack/cli, build and typecheck
(head 56e4c0e; the last commit after it only adds module-top imports
to the test file, re-run below)</summary>
```
pnpm --filter @objectstack/cli build && pnpm --filter @objectstack/cli typecheck && pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2
Test Files 449 passed (449)
Tests 6428 passed (6428)
os-verify-lock: VERDICT command-exit 0
```
The integration layer is declared to CI (no spawn entry or
integration-tier file is touched).
</details>
<details><summary>Ablation: the wrap removed, the new case goes red with
the old misdirecting text</summary>
`node scripts/ablation-replace.mjs` replaced the rethrow guard `if (j
=== seg || !(error instanceof Refusal)) throw error;` with an
unconditional `throw error;` plus a marker (anchor 1 to 0, marker 0 to
1, blob changed), then ran the case:
```
AssertionError: expected 'the value is built by `build(…)`, not…' to contain 'package 1'
Tests 1 failed | 8 skipped (9)
ablation-replace: ok restored: blob == HEAD (120c05c) and `git diff HEAD` is empty
```
The test imports the command from `src/`, so no rebuild sits between the
mutation and the run. A first attempt used a bare `throw error;` as the
replacement; the tool refused it before running anything (that text
already occurred 7 times, so the replacement count could not rise), and
it did not count as a run.
</details>
## Acceptance notes
- The resolution strategy is unchanged, per the card's triage: an opaque
earlier input still leaves a later package unmapped. On the reporting
project the target input is itself helper-built
(`createHotCrmAppStack(…)`), so even a mapped position would be refused,
now naming that builder.
- `items` is printed in the text report only; the `--json` `manual` rows
keep their shape (`conversionId`, `path`, `kind`, `reason`).
- A composition whose input list is assembled with a spread names the
blocking input by index only: there is no source element to quote.
## Verification
Two-minute check: `pnpm --filter @objectstack/cli exec vitest run
--maxWorkers=2 test/migrate-meta-composed.test.ts`, which should show
`Tests 9 passed (9)`.
<details><summary>Local gate subset on head 547c0d0</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 73 commands for this diff; all 73
were run on head 547c0d0, exit codes captured before any pipe and
reconciled with `--ran`:
```
Run reconciliation — 73 derived, 72 run, 1 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 73 derived famil(ies) accounted for — 72 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3).
```
72 exited 0. NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test`, reason: exit 3, its positive control is pinned to a commit
this shallow checkout cannot reach (checker-health self-test only; CI
runs it). An earlier pass on a previous head was red on `pnpm
check:test-source-alias` (the edited composed suite reached 13 dynamic
imports from inside clocked cases); the last commit adds the module-top
imports the gate names, as the sibling suite
`migrate-meta-stored-failed.test.ts` does, and the gate is green on this
head. Every other family, and the full farm, is CI's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B)_
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmSwS4mQyXWrddL4r6B -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(cli): `os migrate meta --write` names the input that blocks a composed package, and the items a site sits in
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
In a `composeStacks([…])` project, a site in package N is written only while every input before it is a stack literal, because only then can the command count which input built package N. When an earlier input is built by a helper, the site is still refused (`not written [helper]`), but the reason used to be that earlier input's own one ("the value is built by `createServiceStack(…)`, not written as a literal"), which read as if that input had built the site. It now says which input of `composeStacks(…)` built package N is unknown, names the earlier input that blocks the count and why, and keeps the refusal kind. A site in a package whose own input is helper-built still names that input's builder, as before.
11
+
12
+
Each mechanical change left for the author is also printed with the items its path indexes into, by name, in a line such as: where packages[6] is `com.acme.sales`, permissions[3] is `sales_rep`. The path itself, the `--json` output and which sites are written do not change.
0 commit comments