Repository navigation
Commit e75a528
feat(spec)!: refuse two entries under one identity in one package at the composition and package-body doors (#35699)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu6hTn2MxPVXtxBXndQYNLXw)_
Fixes #35228
Part of #35608
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no skill teaches splitting one package's entries for
one identity across sub-stacks or package bodies;
`skills/objectstack-data/SKILL.md` teaches one `objectExtensions` entry
per extension, and the refusal names both entries and prescribes the
merge
## 维护者速读
-
用户能看到什么变化:应用作者把同一个包拆成几个模块再拼起来时,如果两个模块给同一个对象加字段(或者两个模块起了同名的页面、流程等),校验和构建现在会直接报错并点出两处位置;以前会悄悄只留后一处。
-
为什么做:有应用在同一个包里分两处给同一个对象加字段,前一处的字段无声消失,上线后读写才报字段不存在;这次按维护者裁决把"一个包里同一对象只能有一段扩展"在拼包和包内容处也管住,并把同类的其他元数据一起收口。
-
出错会怎样:已经构建、已经安装的包照常启动,只在启动日志里多一条错误提示;如果误拦了正常写法,作者会在校验时看到报错,撤回这个合并即可恢复原状,不涉及数据迁移。
- 要你做什么:无
Harness branch: this PR's head is `claude/project-thread-nbjebo`
(harness-assigned, not `claude/issue-35228-…`), noted for the Duplicate
Fix Guard workflow.
The folded card #35608 rides this PR; the seat finishes that card by
hand after the merge.
## What changes
The ruling on #35228 (maintainer, letter A, runtime arm A1: 「推荐
A,已安装的包只记错误日志、照常启动。」) applied, with #35608 folded in:
- **`packages/spec/src/stack.zod.ts`.** The same-package identity table
behind `defineStack`'s duplicate-entry refusal (all 29 keys: the 27 of
the original refusal plus `queues` and `assignmentRules`) is now read by
one helper, `duplicateEntryFindings`, at four doors, with one wording
and per-door origins:
- a stack's top level: `stack.KEY[i]` — byte-identical to before;
- each `packages[i]` body of a `defineStack` call:
`stack.packages[i].manifest.KEY[j]`;
- the ONE package a flat `composeStacks` makes (every manifest strategy
but `'preserve'`): the inputs' entries together, each labelled with its
input (`'com.example.sales' (stack #0) objectExtensions[0]`). `objects`
is skipped there, since two inputs declaring one object name is the
`objectConflict` strategy's to refuse or fold;
- the RESIDUAL package of any composition, under every manifest strategy
including `'preserve'`: the top-level entries no body of the composed
artifact claims, read by the boot's own residual reading
(`isResidualTopLevelItem`, plus a claimed-by-identity rule for
`datasources` and `objectExtensions`), judged as one package. A flat
composition with no `packages[]` carries all its entries as residual. A
nested multi-package input's flattened copies of its bodies are never
read as a second entry;
- every package body a composition carries or, under `'preserve'`,
assembles, each judged on its own.
One entry object reached through two inputs (one built sub-stack passed
twice) counts once at the door, in every collection but `hooks`. In
`hooks` a hook reached twice is refused: a built artifact serialises the
two references into two equal hook entries and binds both handlers,
while a source boot folds them, so accepting it would let one accepted
composition behave differently between a source boot and a built boot
(one bind against two). Counting hooks by position also makes the
composition door agree with the single-stack door for hooks.
The composition doors join `composeStacks`' artifact cross-reference
pass, so the refusal is `STACK_CROSS_REFERENCE_INVALID` / 422 and
carries the inputs' conversion record like the other composition
refusals. Cross-package reuse (ADR-0048 §3.4) is untouched; two bodies
under one package id stay the boot's `DUPLICATE_ARTIFACT_PACKAGE`.
- **`packages/objectql/src/engine-registration.ts` (A1).** The
`objectExtensions` loop first logs, at `error`, once per (package,
target) in a body carrying two or more entries for one target: the
target, the package, every entry index, that only the last entry's
fields register, and "merge them and rebuild". The line stays quiet when
every entry for that target is equal by value (one sub-stack composed
twice, as composed or as built JSON); equal entries beside one that
differs still log, naming every entry. The outcome is unchanged: nothing
refused, nothing merged. `registry-object-registration.ts` (the
replace-on-reload splice) is not touched.
- **Migration entry**
`stack-package-duplicate-entry-refused-at-every-door` (semantic,
protocol 18) and one changeset (`@objectstack/spec` +
`@objectstack/objectql`, `minor`, BREAKING banner, `adr-0087:
registered`).
## Tests
- `packages/spec/src/stack-object-extension-duplicate-target.test.ts`
(#35228): composed stack with two `objectExtensions` entries for one
target refused with the exact message naming both; every flat manifest
pick (`first`, `last`, an index) refused; a hand-built `packages[1]`
body refused at `stack.packages[1].manifest.objectExtensions[0] and
…[1]`; a nested artifact's body refused under `last` and `preserve`; a
loose input under `preserve` refused as its body; the single-stack
message pinned byte for byte; controls: `preserve` with two packages
each extending one target, two hand-built bodies, one package extending
two targets, the same sub-stack passed twice. Added on review:
`preserve` with two manifest-less inputs declaring page `home`, and two
extensions for one target, both refused naming both, plus the body-slot
control (S2); a `preserve` artifact with two packages each extending one
target, nested in a flat and in a `preserve` composition, accepted, and
the nested artifact's own residual pair refused (S1); a hook reached
twice refused (S3).
- `packages/spec/src/stack-compose-duplicate-entry-census.test.ts`
(#35608): the census as a table-driven test over the 29 keys — each
input accepted alone; flat composition refused per key (28 by this
check, `objects` by its object-conflict refusal); a `packages[0]` body
refused per key; cross-package control under `preserve` accepted per key
with one entry in each body.
-
`packages/objectql/src/engine-same-target-object-extensions-log.test.ts`
(A1): one error line naming both entries, the earlier field absent and
the later served (today's outcome); once per (package, target); controls
(one entry; two packages); reload pin — re-registering with a renamed
field serves the new name and not the old. Added on review (S3): the
accepted twice-passed sub-stack composition, registered as composed and
as built JSON, logs no error; equal entries beside a differing one log.
- `packages/spec/src/stack-conversions-record.test.ts`: the composition
duplicate refusal carries its inputs' conversion records.
- `packages/spec/src/stack-datasource-connector.test.ts`: fixture
triage. Two flat-composition fixtures declare one connector name in two
inputs; that is now also the one composed package's duplicate, so they
assert the second finding, and the reversed-order control now asserts
the refusal. A `preserve` fixture now also meets the residual duplicate
finding (second issue of the same envelope).
## Acceptance notes
- Census on base `e91d9671` (before the fix), `composeStacks([A, B])`
default strategy, A with the manifest and the first entry, B the second:
26 keys ACCEPTED with 2 entries; `objects` REFUSED
`STACK_COMPOSE_OBJECT_CONFLICT`; `apps` REFUSED
`STACK_SINGLE_APP_VIOLATION`. After: all 29 refused (28
`STACK_CROSS_REFERENCE_INVALID`, which runs before the single-app count
as in `defineStack`; `objects` unchanged). A boot census (which entry is
served) was not repeated: the original duplicate-entry card measured it
for the same collections and registrars.
- Under `'preserve'`, a manifest-less input contributes no body; its
entries are the residual package, which the residual door now judges
(review S2).
- Accepted deviation (review N2): the refusal's remedy does not mention
manifest `'preserve'`, because the #22934 sentence stays byte-identical
at every door.
- Out of scope, filed as #35711 (with review N5, a residual job judged
by no door): a residual (top-level, unclaimed) `objectExtensions` entry
of a packages-carrying artifact is registered by no door at boot
(scratch probe on `c5b827e5`: the extended field absent on the resolved
target). So at that door the refusal's sentence ("only the last entry's
fields register") overstates what registers: none do. The refusal itself
stands.
- The connector-lend rule's flattened-artifact branch now always arrives
beside the duplicate finding for a flat composition; it is kept as it
was.
- The A1 line is once per registration of a body; a reload of the same
unfixed body logs it again.
- `stack.zod.ts`'s docblock above the table now says 29 collections
(review N1); objects stay with `objectConflict`, and the app pair
answers `STACK_CROSS_REFERENCE_INVALID` (review N3).
## Verification
Two-minute check: `pnpm --filter @objectstack/spec exec vitest run
--project local src/stack-object-extension-duplicate-target.test.ts`
passes; then delete the line
`...collectComposedResidualDuplicateEntryErrors(stacks,
composed.packages),` in `stack.zod.ts` and rerun: the flat-composition
and residual cases go red.
Read first, by risk: `packages/spec/src/stack.zod.ts` (the
`duplicateEntryFindings` family and the two lines added to
`composeBuiltStacks` step 3b),
`packages/spec/src/stack-datasource-connector.test.ts` (the re-judged
fixtures), `packages/objectql/src/engine-registration.ts`
(`logSameTargetObjectExtensions`).
Readings below on head `58464e71` unless noted; the review round's
readings on head `c5b827e5` come first.
<details><summary>Review round on c5b827e (S1-S3)</summary>
```text
closure build --filter='@objectstack/dogfood^...' :: VERDICT command-exit 0
pins (spec: duplicate-target, compose census, conversions-record, datasource-connector) :: Test Files 4 passed · Tests 203 passed
pins (objectql: engine-same-target-object-extensions-log) :: 1 file · 7 passed
pnpm --filter @objectstack/spec test :: exit 0 Test Files 863 passed · Tests 27626 passed | 1 todo
pnpm --filter @objectstack/objectql test :: exit 0 Test Files 617 passed · Tests 13930 passed
spec typecheck / objectql typecheck :: exit 0 / exit 0
dogfood battery :: VERDICT command-exit 0 · Test Files 482 passed | 3 skipped (485) · Tests 4093 passed | 68 skipped (4161)
ablation (scripts/ablation-replace.mjs, each leg red, restored by blob hash):
A residual filter deleted -> 37 failed of 203
B old preserve skip restored -> 4 failed (both S2 pins, two connector residual refusals)
C hooks exception deleted -> 1 failed (hook reached twice)
D equal-by-value quiet deleted -> 1 failed of 7 (twice-passed composition)
dispatch-gates --commands :: 97 derived, 97 run, 0 NOT-MEASURED (dual-build-cjs-loads and plugin-teardown self-test now measured, exit 0)
check-platform-checklist --changed-from origin/main :: OK, 6 anchors, 0 lost · overlap-check :: clean
CI on c5b827e :: 58 success, 11 skipped (opt-in and queue-only)
```
The two reds on `58464e71` (TypeScript Type Check, Test UI) were
cancel-in-progress aggregators after the `c5b827e5` push, not test
failures.
</details>
<details><summary>Package suites and typecheck</summary>
```text
pnpm --filter @objectstack/spec test :: exit 0 Test Files 863 passed (863) · Tests 27620 passed | 1 todo
pnpm --filter @objectstack/objectql test :: exit 0 Test Files 617 passed (617) · Tests 13928 passed
pnpm --filter @objectstack/spec typecheck :: exit 0 (on 85531416, pre-rebase; same blobs)
pnpm --filter @objectstack/objectql typecheck:: exit 0 (on 85531416)
pnpm --filter @objectstack/cli exec vitest run --project unit :: exit 0 431 files · 6159 tests (on 85531416)
```
`test:repo` (the spec `repo` vitest project) is declared to CI: the diff
touches none of its tests.
</details>
<details><summary>Dogfood battery (title carries the bang)</summary>
```text
pnpm --workspace-concurrency=2 --filter='@objectstack/dogfood^...' build :: exit 0
pnpm --filter @objectstack/dogfood test :: VERDICT command-exit 0
Test Files 482 passed | 3 skipped (485) · Tests 4093 passed | 68 skipped (4161)
```
</details>
<details><summary>Ablation and base control (blobs of both edited source
files identical on 85531416 and 58464e7)</summary>
Each leg through `scripts/ablation-replace.mjs` (anchor 1 -> 0, blob
moved, restored, `git diff HEAD` empty after):
```text
delete the flat composition door -> 30 failed | 95 passed (census flat rows 28 + two #35228 cases)
delete the defineStack package-body door -> 29 failed | 96 passed (census body rows 28 + the hand-built body)
delete the composed package-body door -> 2 failed | 8 passed (nested body; preserve loose input)
delete the registrar error log call -> 2 failed | 3 passed (both log pins; reload and controls green)
```
Base control, `stack.zod.ts` restored from `e91d9671`: the five new-door
pins fail, the single-stack byte-identical pin and the original
duplicate-entry suite pass (5 failed | 143 passed).
</details>
<details><summary>Gate families (dispatch-gates --commands, 97
derived)</summary>
```text
95 :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 3 NOT MEASURED: needs the unshallowed history
pnpm check:dual-build-cjs-loads :: exit 3 NOT MEASURED: needs every workspace dist
--ran reconciliation: 97 derived accounted for — 95 run, 2 NOT-MEASURED
node scripts/check-platform-checklist.mjs --changed-from origin/main :: OK, 6 anchors judged, 0 lost
node scripts/pm/overlap-check.mjs :: VERDICT clean exit 0
check:dev-prereqs (local only) :: NOT MEASURED — workspace only partly built (closure build)
```
</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.
- [ ] 3. No formatter ran; `pnpm lint` was not run locally (a CI-owned
repo scan).
- [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 (none stale: `check:api-surface`,
`check:authorable-surface`, `check:docs`, `check:spec-changes`,
`check:upgrade-guide` exit 0).
- [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.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgVLY5efsfaT3UG2zwH
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgVLY5efsfaT3UG2zwH -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ed906d5 commit e75a528
9 files changed
Lines changed: 1149 additions & 24 deletions
File tree
- .changeset
- packages
- objectql/src
- spec/src
- 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 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 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
83 | 144 | | |
84 | 145 | | |
85 | 146 | | |
| |||
319 | 380 | | |
320 | 381 | | |
321 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
322 | 397 | | |
323 | 398 | | |
324 | 399 | | |
| |||
| 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 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
0 commit comments