Repository navigation
Commit 7f72b49
fix(cli): os migrate meta --from 18 names the own field rows beside Modify All that protocol 19 narrows (#39160)
Fixes #38924
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:从 18 升级的开发者做迁移预演时,每个"修改全部记录"且自己把某字段设为隐藏或只读的权限集都会被逐条点名,写明 18
与 19 的结果和两种做法;库里保存的权限集复核清单也同样点名;19 上的实际权限行为不变。
- 为什么做:属于 19 正式版升级收口(18 到 19 升级线);此前工具声称"字段读取会保留",这类权限集升级后却会悄悄失去该字段的读和改。
- 出错会怎样:只影响迁移工具的提示文字和清单,不改任何权限;出错最多是多报或漏报一行提示,可直接撤回。
- 要你做什么:无。
## What changes
- **Wording (Expected 1).** Measured on `origin/main` `ffda6dab9e`
through `os migrate meta --from 18` over the card's fixture: the claim
prints in the `why:` of the protocol-19 semantic notice, from the
entry's `reason` ("adds `viewAllFields: true` beside every such bit
(...), so their field reads are kept"). The conversion's `summary`
carries a twin ("the bit keeps every field read they cast"). Both now
say the bit keeps the field reads the bits cast **except** a field the
set's own `readable: false` row hides beside Modify All, and that it
keeps **no** edit Modify All cast. The `reason` also says the dry run
and the `--stored` list name each such row. The rest of the text is
unchanged. No committed output mirrors it: the migrations `registry.ts`
is gitignored and regenerated by the build, and the docs page
`content/docs/permissions/field-level-security.mdx` does not repeat the
claim.
- **Naming (Expected 2).** `os migrate meta --from 18` prints a group
after the edits (②c) naming each own field row beside Modify All that
protocol 19 narrows: set, `at`, `objects` entry, field row, the
protocol-18 answer (read and edit), the protocol-19 answer (`hidden` /
`read-only` / `read-only-where-when-matches` /
`edit-only-where-when-matches`), each with a choice that leads to a row
the list never names, and the choice (change the row to keep the 18
answer, or accept the narrowing). `--json` carries the same list under
ONE new key, `ownFieldRowNarrowing`, present only when non-empty. No key
is renamed or removed. The list covers the entries the run itself writes
`viewAllFields: true` beside; a source that already carries the bit
lists nothing, and the step-19 text says so.
- **Stored (Expected 3).** Each `viewAllFieldsReview` entry of `os
migrate meta --stored` carries `ownFieldRows` (present only when there
is a row), and the human list prints one line per row under its entry.
- **One predicate.** `ownFieldRowsBesideModifyAll` lives in
`packages/spec/src/conversions/` and is exported from the
`@objectstack/spec` root. It runs the conversion
`permission-view-all-fields-beside-record-bypass` itself to pick the
entries, so its population is exactly the entries the chain rewrites and
the `--stored` list names, narrowed to Modify All. A row `OBJECT.FIELD`
belongs to the set's own entry for `OBJECT`, otherwise to its `'*'`
entry, as in the field merge. View All alone is never listed: on 18 a
set's own row already beat its own View All, and View All never voted an
edit.
- **Widened:** `@objectstack/spec` root exports
`ownFieldRowsBesideModifyAll` and three types; the `--json` key
`ownFieldRowNarrowing`; the optional member `ownFieldRows` on
`StoredViewAllFieldsReview`, whose element type `StoredOwnFieldRow` is
exported from `@objectstack/metadata-protocol`.
- The CLI side is a new module,
`packages/cli/src/utils/own-field-row-narrowing.ts`; `meta.ts` gets hook
lines only. The stored side is a new module,
`packages/metadata-protocol/src/stored-own-field-rows.ts`;
`stored-migration.ts` gets five hook lines: the import, the optional
interface member, the return type, the return spread and the formatter
line.
## Tests
- `packages/cli/test/migrate-meta-own-field-row-38924.test.ts` runs in
process through `MigrateMeta.run` (unit tier):
- The fixture set (View All + Modify All on `contact`, own
`'contact.salary': { readable: false }`) is named with its row,
`protocol 19: hidden` and the choice, and "so their field reads are
kept" is absent.
- Control: a set with View All only and no field row keeps its plain
edit line and is not named.
- `--json` key-set equality: the control's keys equal the pre-change
replay keys exactly; the fixture's are those plus `ownFieldRowNarrowing`
in one place.
- An assembled stack's package body is named under its own prefix
(`packages[0].manifest.permissions[0]`), and a run that does not cross
into 19 names nothing.
-
`packages/spec/src/conversions/own-field-rows-beside-modify-all.test.ts`
covers:
- each 19 answer (hidden, read-only, conditional edit);
- a row-conditioned lock (`read-only-where-when-matches`); each choice
converges (the followed rows list nothing); a `*.FIELD` row is not
listed;
- `editable: true` and no `when` not listed;
- the `'*'` lookup, where an explicit entry beats the wildcard;
- View All alone not listed;
- an author-written `viewAllFields` either way not listed;
- non-set bodies.
- `packages/metadata-protocol/src/stored-own-field-rows.test.ts`:
`collectViewAllFieldsReview` carries `ownFieldRows` on the Modify All
entry only, and the formatter prints each row under its entry.
## Acceptance notes
- **Ablations**, done once on the committed implementation; each restore
was proved with a blob hash equal to `HEAD` and a clean `git status`.
- Naming: the `ownFieldRowNarrowingSites(...)` call in `meta.ts` was
replaced by an empty list → 2 failed / 1 passed. The naming and `--json`
cases went red; the control stayed green.
- Wording: the old "so their field reads are kept" was put back into the
semantic entry, spec rebuilt, and `ablation-dist-preflight` showed the
marker in `packages/spec/dist` → 1 failed / 2 passed (the wording case).
The restore leg rebuilt spec; the marker is absent from all 610 built
files and the 3 cases pass.
- **File surface, past the claim, each forced by a measurement:**
- (1) The predicate sits in `packages/spec/src/conversions/` (plus one
export block in `conversions/index.ts`), not in
`packages/spec/src/migrations/`. Importing
`@objectstack/spec/migrations` from `metadata-protocol` (runtime code)
pulled the whole migrations registry into its import closure:
`check-temporal-live-filter` went red on that, and the spec root note
says that entry is kept off runtime paths for this reason.
- (2) Two thin adapter modules beside the one predicate: CLI walk/print,
and stored select/format. Each is needed because only hook lines may
land in `meta.ts` and `stored-migration.ts`.
- (3) `packages/spec/api-surface/root.json` and
`packages/spec/export-origins/root.json` were regenerated by
`check:generated --fix` for the new root export.
- (5) One export line in `packages/metadata-protocol/src/index.ts`
(review nit N1): it exports the type `StoredOwnFieldRow`, declared under
**Widened** above.
- (4) One row in `packages/cli/test/normalized-call-sites.test.ts`. That
pin requires every new `(normalized` call site in a command to be
classified, and CI's `Test Core (2/12)` went red until it was. The row
is `reads: 'packages'`, measured by the assembled-stack case above.
- **Two CI reds on the first head (`126d7649`), both fixed in
`60ea167c`.**
- The `spec` `test:repo` house-sentence pin judges every plain-quoted
literal that spells `os migrate meta --from N`. My new sentence spelled
it and was not the house sentence. It now says "The same command, with
or without `--write`, names each own field row…", after the sentence
that already names the command.
- The call-site row in (4).
- **Scope choice:** an entry whose author already wrote `viewAllFields`
(either value) is not named, matching the conversion and the `--stored`
list predicate. That entry still narrows beside Modify All on 19. Raised
as an open question in the report, not widened here.
- `#39136` (stored `runStored`) and `#39131` merged while this branch
was open. `origin/main` was merged before this PR opened; the only
conflicts were two adjacent additions in `meta.ts`, and both sides were
kept.
- `packages/core/src/security/effective-object-permissions.ts` has a
code comment with the same "keeps every read" phrasing. It is outside
this card's file surface and is not printed anywhere; noted, not
changed.
## Verification
Two-minute check: in a folder with an `objectstack.config.ts` holding
the card's fixture set, run `os migrate meta --from 18`. Expected: a
group `1 own field row(s) beside Modify All that protocol 19 narrows`,
naming `permission set 'hr_manager' (permissions[0]), objects entry
'contact', field row 'contact.salary'` with `protocol 19: hidden, no
read and no edit`. The `why:` of the protocol-19 permission notice no
longer says "so their field reads are kept". With `--json`, the payload
has `ownFieldRowNarrowing`.
Read first, by risk:
1. `packages/spec/src/conversions/own-field-rows-beside-modify-all.ts`:
`narrowedOutcome` and the covering-entry lookup. This is the 18 vs 19
model the whole list rests on.
2. `packages/metadata-protocol/src/stored-migration.ts`: the five hook
lines in a file `#39136` just changed.
3. The semantic entry's `reason` hunk: the corrected promise.
<details><summary>Local gates and CI, head 60ea167</summary>
- `node scripts/pm/dispatch-gates.mjs --ran`: 101 derived, 100 run with
exit 0, 1 NOT MEASURED. The one is `node
scripts/check-plugin-teardown-shape.mjs --self-test`, exit 3,
PREREQUISITE NOT MET: its fixture is pinned to a commit this shallow
clone cannot reach. CI runs it.
- Tests:
- `pnpm --filter @objectstack/spec test`: 923 files, 29157 passed.
- `pnpm --filter @objectstack/spec test:repo`: 95 files, 1633 passed.
- `test/normalized-call-sites.test.ts` and the per-card test: 2 files,
17 passed.
- `pnpm --filter @objectstack/metadata-protocol test`: 383 passed, 9
skipped.
- CLI: the 24 `migrate meta` test files: 23 files, 175 passed, 1
skipped.
- Typecheck exit 0 for `spec`, `metadata-protocol` and `cli`.
- `eslint --no-inline-config` over the 11 changed source and test files:
exit 0. The repo-wide `pnpm lint` run is CI's.
- `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts up
to date.
- NOT MEASURED locally: the full CLI unit tier (`--project unit`) did
not finish inside the 10-minute foreground window. CI's `Test Core` runs
it.
- Fix round 1 (head `e659f7cf`), targeted runs only: spec own-row test
and the house-sentence pin, 2 files / 24 passed; metadata-protocol
stored-own-field-rows and protocol.stored-migration, 2 files / 57
passed; cli per-card test, normalized-call-sites and
meta.stored-view-all-fields, 3 files / 20 passed; typecheck exit 0 for
spec, metadata-protocol and cli. The counts above are from `60ea167c`.
- CI on `e659f7cf`: 60 success, 13 skipped, 0 failed.
- CI on `60ea167c`: 60 success, 13 skipped, 0 failed. Success includes
`Lint & Repo Gates`, `TypeScript Type Check`, `Test Core` (12/12
shards), `Build Core`, `Governed Surface Queue Guard`, `Type Check UI`,
`Test UI` (16/16), `Build & E2E UI`, `Live E2E UI`, `Dogfood Regression
Gate` and `Check Changeset`. `Temporal Conformance (live PG + MySQL)` is
skipped on PRs; it first runs in the merge queue.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYko9cFNzePK9vaCkYe)_
<!-- signed: repo:objectstack@os-justin · os-justin ·
session_01QSeKYnrQ7UMtHofKQVjcH2 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3dc3983 commit 7f72b49
16 files changed
Lines changed: 800 additions & 13 deletions
File tree
- .changeset
- packages
- cli
- src
- commands/migrate
- utils
- test
- metadata-protocol/src
- spec
- api-surface
- export-origins
- src
- conversions
- entries/19
- migrations/entries/semantic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
1057 | 1058 | | |
1058 | 1059 | | |
1059 | 1060 | | |
| 1061 | + | |
| 1062 | + | |
1060 | 1063 | | |
1061 | 1064 | | |
1062 | 1065 | | |
| |||
1309 | 1312 | | |
1310 | 1313 | | |
1311 | 1314 | | |
| 1315 | + | |
| 1316 | + | |
1312 | 1317 | | |
1313 | 1318 | | |
1314 | 1319 | | |
| |||
1563 | 1568 | | |
1564 | 1569 | | |
1565 | 1570 | | |
| 1571 | + | |
| 1572 | + | |
1566 | 1573 | | |
1567 | 1574 | | |
1568 | 1575 | | |
| |||
1630 | 1637 | | |
1631 | 1638 | | |
1632 | 1639 | | |
| 1640 | + | |
| 1641 | + | |
1633 | 1642 | | |
1634 | 1643 | | |
1635 | 1644 | | |
| |||
1688 | 1697 | | |
1689 | 1698 | | |
1690 | 1699 | | |
| 1700 | + | |
1691 | 1701 | | |
1692 | 1702 | | |
1693 | 1703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
0 commit comments