Repository navigation
Commit 75ab117
fix(spec,lint): os lint reports an omitted cbp master required on the default defineStack door (#34020)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9CZHtkC74Ydb9at95QTnivt)_
Fixes #33940
Clause-②: yes
Metadata-protocol: none
## 维护者速读
- 改了什么:默认(strict)`defineStack` 解析时,如果作者在 `controlled_by_parent` 对象的
`master_detail` 上没写 `required`,spec 会在解析后的字段上悄悄记一笔“作者省略了”;`os lint` 的
`relationship/master-detail-required` 读这笔记录,在默认写法下也报 error。
- 为什么改:裁决 A(#30905,记录 6687830530)放行可选主字段,同时承诺 `os lint` 对省略写法报错;但默认
strict 解析先把省略填成 false,lint 永远看不到,迁移说明那句话在最常见的写法下是假的。
- 风险与回滚:解析结果不变(仍是 `required: false`,可选主字段),栈照常加载,`os validate` / `os
build` 不变;只是 `os lint` 在这一种写法上多报一条 error。回滚即 revert 本 PR。
-
先看:`packages/spec/src/data/master-detail-required-omission.ts`(记录与读取),`packages/spec/src/stack.zod.ts`
中 `recordMasterDetailRequiredOmissions`
的调用,`packages/lint/src/data-model-rules.ts` 中 `optionalMaster` 那一行。
- 两分钟验证:在示例应用副本的默认 `defineStack({ … })` 里加一个 cbp 对象,唯一的 master_detail 不写
required,跑 `os lint --json`:应 exit 1,报
relationship/master-detail-required 在 `.required`;改成 `required: false`
后应 exit 0。
- 需要你做的:无,席位落地。
## What changes
- **`@objectstack/spec`** — new module
`src/data/master-detail-required-omission.ts`. After a strict
`defineStack` parse succeeds,
`recordMasterDetailRequiredOmissions(normalized.objects, data.objects)`
stamps a non-enumerable, non-writable
`Symbol.for('objectstack.field.masterDetailRequiredOmitted')` on each
parsed `master_detail` field of a `controlled_by_parent` object whose
authored definition writes no `required`. The one published reader is
`masterDetailRequiredOmitted(field)` (`@objectstack/spec/data`); the
stamp is internal (not re-exported), mirroring `stack-provenance.ts`.
The parsed value is untouched (`required: false`), so the ruled reading
(option A: the omission is admitted as the optional master) holds at
every runtime reader, and nothing refuses the stack.
- **`@objectstack/lint`** — `cbpMasterReferenceFinding` (R2) treats a
sole `master_detail` as the optional master only when `required ===
false` AND the field does not carry the record. On the default door the
omitted spelling now gets the same finding, path and fix it already got
on `{ strict: false }` and on a raw config.
- **Why on the field, not the stack:** `loadConfig`
(`packages/cli/src/utils/config.ts`) spreads the default export into a
new object, which drops a stack-level symbol (that is why it reads
`stackConversionsOf` before the spread). The `objects` array and each
field reach `lintDataModel` by reference, so a field-level record needs
no `packages/cli` change and no second load of the user's module.
Measured: `composeStacks` (error / override / merge) keeps the record on
the composed field too.
- Regenerated: `packages/spec/api-surface/data.json`,
`packages/spec/export-origins/data.json` (one added export each).
- **Fix of text this change made false:**
`docs/qa/platform-checklist/areas/cli.json`, item
`cli.validate-v18-authoring-verdicts`. Revision 4 (PR #33929, merged
into main while this card was in flight) moved the item's `os lint` arm
to `{ strict: false }` and said the default strict door gives `os lint`
exit 0 with no finding. That is no longer true, so revision 6 (stacked
on main's revision 5, PR #34068, which only adds `--reporter=tree` to
acceptance[0].verify) moves steps[2] and acceptance[3] back to the
default door, states that the default door reports only
`relationship/master-detail-required` (not
`security-controlled-by-parent-no-relation`, because the parsed field is
the optional master the runtime derives access from) and keeps `{
strict: false }` as the second door. No other clause changed.
- Docblocks touched: `data-model-rules.ts` (R2 header),
`controlled-by-parent-master.ts` (module header). The semantic entry
`cbp-optional-master-admitted` is unchanged: its sentence "`os lint`
reports the omission at `error`" is now true on the default door, which
was the seat's call (fix the reach, not the prose).
## Why
The maintainer ruling on #30905 (record 6687830530), option 「A
放行为可选主字段(推荐)」, keeps the omitted `required` readable as the optional
master at the parse and pairs it with the lint: "`os lint` errors on the
omitted spelling". The published entry repeats that promise. On the
ordinary authoring door it did not hold (measured on #33842 / PR
#33929).
## Tests
New, no existing assertion edited (no forced test edits):
- `packages/spec/src/data/master-detail-required-omission.test.ts` (7
cases): strict `defineStack` records an omitted `required` on the sole
master and on a second `master_detail` beside a required one; nothing
for explicit `false` / `true`, for another sharing model, for a lookup,
for `{ strict: false }`, or for a bare `ObjectSchema.safeParse`; the
record is invisible to `Object.keys`, `JSON.stringify` and
`FieldSchema`, and a copy drops it.
- `packages/lint/src/data-model-rules.master-detail-required.test.ts`,
new top-level `describe` (4 cases) over stacks a real `defineStack`
built: omitted → one error at `.required` with both spellings; CONTROLS
explicit `false` and `true` → clean; `{ strict: false }` → the same
finding as before; a copied field → clean (the pre-record reading).
Ablations (each committed first, mutated through
`scripts/ablation-replace.mjs`, rebuilt, `ablation-dist-preflight` hit,
then restored with blob == HEAD and rebuilt with the marker absent from
dist):
- A1, lint stops reading the record: lint unit `the sole master_detail
without required` turns red (1 failed / 33 passed); the CLI on the
default door reads `os lint` exit 0, passed true, 0 R2 findings (the
defect).
- A2, `defineStack` stops stamping: spec unit 3 failed / 4 passed (src),
lint unit 1 failed / 33 passed (spec dist), CLI default door `os lint`
exit 0 with 0 R2 findings.
## Acceptance notes
- `Clause-②: yes` differs from the claim's expected `no`: the diff adds
one public export, `masterDetailRequiredOmitted` on
`@objectstack/spec/data`, and the spec lane charter counts any widening
of the public surface as Clause ②. No parse accept set moves, so
`Metadata-protocol: none` and patch changesets.
- On the default door only R2 fires;
`security-controlled-by-parent-no-relation` does not, because the stack
the runtime loads really does derive the optional master from the parsed
`false`. On `{ strict: false }` both fire, as before.
- Not reached by design: the save door and a bare
`ObjectSchema.safeParse` record nothing (neither runs `os lint`);
`ObjectSchema.create()` still forces an omitted `required` to `true`.
- The record lives in `packages/spec` as a declared producer record
beside the provenance mark, not as business logic: it states what the
author wrote and nothing reads it at runtime.
- `pnpm --filter @objectstack/spec check:generated` exits 1 at Node's
default heap in this container: its `check:test-typecheck` leg's `tsc`
dies without diagnostics. At `NODE_OPTIONS=--max-old-space-size=6144`
(the heap `lint.yml` sets for the ledger re-measure) it exits 0 with all
14 artifacts current, and `check:test-typecheck` alone reads OK (52
files / 240 errors / 131 pinned signatures held).
## Verification
Verification head: `7e6f3db1` (main `ea6de745` merged in via
`scripts/pm/os-regen-merge.sh`). That merge had one conflict,
`docs/qa/platform-checklist/areas/cli.json` item
`cli.validate-v18-authoring-verdicts`: PR #34068 had meanwhile taken
revision 5 on the same item. Resolution: main's revision 5 row and its
acceptance[0] edit are kept as written; this PR's row is renumbered to
revision 6 and the item's `revision` set to 6. Apart from those two
numbers the PR's diff is byte-identical to the one verified at
`6e1439cc` (per-file hunks of `git diff e71ecc1 d468bb8` and `git diff
ea6de74 7e6f3db` match in 10 of 11 files; cli.json differs only in
`"revision": 5` → `6` on the item and the row). Re-read at `7e6f3db1`
after `pnpm install --frozen-lockfile`, `rm -rf
packages/runtime/.objectstack` and a full `./packages/**` rebuild under
the verify lock: `check:generated` exit 0 at heap 6144 (all 14 artifacts
current), spec test 844 files / 26973 tests passed, lint test 212 files
/ 9030 tests passed, `check:platform-checklist` exit 0 (16 areas, 433
items). The readings below were verified at `6e1439cc` (main `b4ce310b`
merged in via `scripts/pm/os-regen-merge.sh`; no conflict, the regen
chain found nothing to rewrite). Re-read at `6e1439cc` after `pnpm
install --frozen-lockfile`, `rm -rf packages/runtime/.objectstack` and a
full `./packages/**` rebuild under the verify lock: `check:generated`
exit 0 (all 14 artifacts current), spec test 843 files / 26968 tests
passed, lint test 212 files / 9030 tests passed, the four end-to-end
readings below unchanged, and the 96 derived gates all exit 0 at heap
6144 (`--ran`: 96 run, 0 NOT-MEASURED). CI on `6e1439cc`: every
check-run completed, all required contexts success. The readings below
were first taken at `eb7616fe` (main `0ac112fc` merged in), with the
same results.
<details>
<summary>End to end: the #33929 reproduction and its controls (scratch
copy of examples/app-todo, CLI from the tree)</summary>
```
=== sole master_detail, required omitted, default strict defineStack
os lint --json exit 1 passed false
error relationship/master-detail-required at objects[2].fields.hdr.required
os validate --json exit 0
os build exit 0
=== required: false, default door
os lint --json exit 0 passed true
os validate --json exit 0
os build exit 0
=== required: true, default door
os lint --json exit 0 passed true
os validate --json exit 0
os build exit 0
=== required omitted, defineStack(..., { strict: false })
os lint --json exit 1 passed false
error relationship/master-detail-required at objects[2].fields.hdr.required
error security-controlled-by-parent-no-relation at objects[2].sharingModel
os validate --json exit 0
os build exit 0
```
Base reading (#33929, at 895783a): the first case gave `os lint --json`
exit 0 with no finding. The shipped examples app-crm and app-todo lint
with no R2 finding (their cbp masters are built by
`ObjectSchema.create()`, which writes `required: true`); app-showcase's
config could not load here (its connector-slack dist is not in the CLI
closure), and its two cbp masters are `ObjectSchema.create()` with
`required: true` in source.
</details>
<details>
<summary>Package tests and typecheck (under the verify lock)</summary>
```
pnpm --filter @objectstack/spec test Test Files 843 passed (843) Tests 26968 passed | 1 todo
pnpm --filter @objectstack/lint test Test Files 212 passed (212) Tests 9030 passed
pnpm --filter @objectstack/spec typecheck VERDICT command-exit 0
pnpm --filter @objectstack/lint typecheck VERDICT command-exit 0
pnpm --filter @objectstack/cli exec vitest run --project unit Test Files 422 passed (422) Tests 6002 passed
```
The cli integration layer is declared to CI (no spawn entry or
integration file touched).
</details>
<details>
<summary>Derived gates (dispatch-gates --commands at eb7616f, re-run at
6e1439c)</summary>
96 derived families, 96 run, reconciled with `--ran`: "96 run, 0
NOT-MEASURED (a DERIVED zero)". 95 exited 0 at the default heap;
`check:generated` exited 1 there (the out-of-memory `tsc` above) and 0
at the CI heap of 6144, which is the line reconciled.
`check:platform-checklist` exit 0 (16 areas, 429 items).
`check:dev-prereqs` (local-only family): NOT MEASURED, 34 `ui/` packages
unbuilt in this container.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic
(the record is a producer stamp beside the provenance mark; nothing
reads it at runtime).
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` is CI's.
- [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.
<!-- signed: domain:spec#2 · os-steve · session_01ADHkmSUpRcnYp68V8zPYaB
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 121017b commit 75ab117
11 files changed
Lines changed: 356 additions & 7 deletions
File tree
- .changeset
- docs/qa/platform-checklist/areas
- packages
- lint/src
- spec
- api-surface
- export-origins
- src
- data
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2424 | 2424 | | |
2425 | 2425 | | |
2426 | 2426 | | |
2427 | | - | |
| 2427 | + | |
2428 | 2428 | | |
2429 | 2429 | | |
2430 | 2430 | | |
| |||
2440 | 2440 | | |
2441 | 2441 | | |
2442 | 2442 | | |
2443 | | - | |
| 2443 | + | |
2444 | 2444 | | |
2445 | 2445 | | |
2446 | 2446 | | |
| |||
2462 | 2462 | | |
2463 | 2463 | | |
2464 | 2464 | | |
2465 | | - | |
| 2465 | + | |
2466 | 2466 | | |
2467 | | - | |
| 2467 | + | |
2468 | 2468 | | |
2469 | 2469 | | |
2470 | 2470 | | |
| |||
2509 | 2509 | | |
2510 | 2510 | | |
2511 | 2511 | | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
2512 | 2518 | | |
2513 | 2519 | | |
2514 | 2520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
232 | 294 | | |
233 | 295 | | |
234 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
| |||
413 | 420 | | |
414 | 421 | | |
415 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
416 | 427 | | |
417 | | - | |
| 428 | + | |
418 | 429 | | |
419 | 430 | | |
420 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
| 1042 | + | |
1042 | 1043 | | |
1043 | 1044 | | |
1044 | 1045 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
| 1028 | + | |
1028 | 1029 | | |
1029 | 1030 | | |
1030 | 1031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
426 | 432 | | |
427 | 433 | | |
428 | 434 | | |
| |||
0 commit comments