Repository navigation
Commit cedc094
fix(objectql)!: register a preserve composition’s residual objectExtensions entry; judge residual jobs at composition (#36338)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_
Fixes #35711
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no skill teaches placing `objectExtensions` or
`jobs` in a manifest-less input of a `'preserve'` composition; the
refusal names both entries and prescribes the fix
## 维护者速读
-
用户能看到什么变化:应用作者把几个包拼成一个产物时,若某个没有包标识的部分给别人的对象加了字段,这些字段现在能正常使用;以前字段直接消失,写入时报字段不存在,启动日志也一句不提。
-
为什么做:拼包产物里不属于任何包的"剩余部分"的对象扩展没有任何环节去登记,属于同一组拼包问题的最后一个漏洞;同时两个没有包标识的部分声明同名定时任务时,拼包不拦、启动时两个都不运行。
-
出错会怎样:拼包时新拦下三种写法(剩余部分里的同名定时任务;剩余部分和持有产物标识的那个包给同一对象各加一段扩展;剩余部分给同一对象加两段扩展,即使别的包也扩展了这个对象),不论选哪种拼包方式,只要产物里带有多个包就会拦;作者会在校验时看到点名两处的报错;已构建的产物照常启动,只多一条错误日志;撤回本次合并即可恢复原状,不涉及数据迁移。
- 要你做什么:无。本次虽然收紧拼包规则,但不在受管范围,座位会在完整回归测试对准最终版本之后自行合入。
## What changes
Measured first, on main `c30ce97cd7`, through the real `os serve`
(`packages/cli/bin/run-dev.js serve`, SQLite in memory), on
`composeStacks([owner, other, noManifest], { manifest: 'preserve' })`:
- **Residual extension.** The input without a manifest extends
`probe_account` with `residual_note`. `GET
/api/v1/meta/object/probe_account` listed no `residual_note`; `POST
/api/v1/data/probe_account` with it answered `400 INVALID_FIELD`; the
boot logged nothing about it. `os build` of the same config exits 0 and
carries the entry at the artifact's top level (`1 Extensions`), so a
built artifact reaches the same drop. Producers: a composition yields
`packages[]` beside a residual under `'preserve'` with an input that has
no manifest, and under any strategy (`'preserve'`, `'first'`, `'last'`,
an index) once an input is itself a multi-package artifact, whose own
top-level collections are then residual; a flat composition of inputs
that carry no `packages[]` is one package with no residual.
- **Residual jobs.** Two inputs without a manifest declaring job
`probe_nightly`: `composeStacks` accepted them; the boot (with scheduled
work on) logged `NOT SCHEDULED` at `error` and armed neither.
The fix, REGISTER rather than refuse, because the residual already has
an owner: ADR-0130 D4 registers every residual item under `manifest.id`,
and the engine already registers the residual's objects and items there;
an extension was the one residual entry no door registered.
- **`packages/metadata/src/plugin.ts`.** The residual rule
`unclaimedTopLevel` (the one copy every door reads) now lists a
top-level `objectExtensions` entry (type `object_extension`) when it
names a target and no package body carries an entry EQUAL to it by
value. Not by target: the flattened top level repeats each body's entry
and a built artifact loses the references, but each copy still holds
what its body's entry holds; an equal entry is also the case where
nothing is lost. The metadata door still registers no extension (it
never registered a body's either).
- **`packages/objectql/src/plugin.ts`.** The `manifest` service
registers those entries after every body, under the residual's id,
through the registry's `extend` verb with the same contribution a body's
entry builds: `objectExtensionContribution` (`engine-registration.ts`)
is the one reading of an `objectExtensions` entry, and `registerApp`
step 2b now builds a body's contribution through it too, so the two
cannot drift (it carries `place`, which #36236 added to step 2b on
main). Two follow-ons of registering:
- Under `'preserve'` the residual's id is the last
input-with-a-manifest's body too, and the registry keeps one extension
of a target per package. A residual entry for a target that body also
extends (or two residual entries for one target) keeps only the last
one's fields; the boot says so once per target at `error`, like the
#35228 arm A1 line for one body.
- An entry whose field names a picklist no package body declares is not
registered and is named at boot (`warn`), the residual objects' own rule
(the boot's picklist audit would refuse the field).
- **`packages/spec/src/stack.zod.ts`, the composition door.** The
residual door now mirrors that reading: an `objectExtensions` entry is
claimed by a body only when a body carries an equal entry; the owner
body's entries for a target the residual also extends are judged with
the residual's, body first (the boot's registration order), so the
#22934 sentence ("only the last of these entries' fields register") is
now true at that door. `jobs` is judged there by name (a body's job name
claims the slot), where `TOP_LEVEL_COLLECTIONS_NEVER_RESIDUAL` used to
drop it (that set is the owner-stamp mirror and is unchanged).
- **The `jobs` row's wording, at every door.** It said only the last
entry is kept; the binder schedules none. Now: `The runtime keys jobs by
name: the metadata keeps only the last of these entries, and the job
scheduler refuses a name two enabled jobs share, so when both are
enabled neither runs.` (exact only for two enabled jobs; a disabled one
counts no collision). One row, so it stays byte-identical across doors.
- ADR-0087 semantic entry
`stack-residual-extension-registered-and-jobs-judged`, changeset `minor`
for spec, metadata and objectql.
Newly refused at composition (`STACK_CROSS_REFERENCE_INVALID`, 422),
under every manifest strategy once the result carries `packages[]`
(`'preserve'`, and `'first'`/`'last'`/an index with a multi-package
input):
1. two residual jobs of one name;
2. a residual extension for an object the body carrying `manifest.id`
extends with other fields;
3. two residual extensions of one object, also when another package body
extends that object (the claim is by value now; it was by target, so
both counted as that body's copies and composed).
Unchanged: one residual extension for an object ANOTHER package extends
(both register), a residual entry equal to a body's, every
package-claimed extension, one residual job.
Not refused, a known gap left to the binder (stated in
`residualEntryPredicate`'s docblock and the migration entry): a residual
job that shares its name with a package body's job, with other content,
composes as that body's copy, and the boot schedules neither of the two
enabled jobs. Read from code, not driven.
## Tests
New pins, named after the card:
- `packages/spec/src/stack-residual-extension-jobs.test.ts` — residual
job pair refused (code `STACK_CROSS_REFERENCE_INVALID`, status 422,
exact sentence); the single-stack door says the same row; residual
extension sharing the owner body's slot refused, body entry first;
residual extension of a target another body extends composes; two
residual extensions of a target another body extends refused (shape 3);
`'first'` and `'last'` with a nested multi-package input refuse a
residual job pair (with a CONTROL that the artifact carries
`packages[]`); an equal entry is a copy; CONTROLS: one residual job
composes, each body's own job name, two packages each extending one
target, the owner body's own pair reported once.
- `packages/metadata/src/unclaimed-top-level-residual-extension.test.ts`
— `unclaimedTopLevel` lists the residual entry, composed and as built
JSON, never the body's flattened copy; CONTROLS: nothing listed when
every extension is a body's, no residual without `packages[]`.
-
`packages/objectql/src/manifest-service-residual-object-extension.test.ts`
— on a kernel through the `manifest` service: the residual field is
served (composed and built JSON); it serves exactly what the same entry
serves from a body (parity), and a `place`d entry too (anti-vacuity: the
placement changes what is served); CONTROL a package-claimed extension
unchanged, nothing logged; the owner-slot pair serves the last fields
with one `error` line; a dangling-picklist entry is not registered and
is named at `warn`.
<details><summary>Package suites and typecheck</summary>
Head `058d5c2815`. Since f4e83b0 the change is docblocks, the
migration entry, the changeset, the `jobs` row's last clause (now "so
when both are enabled neither runs") and two spec pins (contract review
S1, S2, N3, N4); the spec pin file re-ran here: 13 passed. The objectql
and metadata readings below are from f4e83b0 (`origin/main`
d8599c2 merged in, then the one-reading unification); neither package
changed since. The spec suite's last full run is seat 4's at 5a41a05
(870/870 files, 27886 tests); since then `packages/spec` changed only by
the main merge and a type cast, and its pin was re-run here.
- `pnpm --filter @objectstack/objectql exec vitest run --project local
--maxWorkers=2` — Test Files 628 passed (628), Tests 14272 passed
- `pnpm --filter @objectstack/metadata exec vitest run --maxWorkers=2` —
Test Files 82 passed (82), Tests 2638 passed
- `src/stack-residual-extension-jobs.test.ts` (spec) — 13 passed at
058d5c2 (9 at f4e83b0);
`src/unclaimed-top-level-residual-extension.test.ts` (metadata) — 3
passed; `src/manifest-service-residual-object-extension.test.ts`
(objectql) — 6 passed
- typecheck: `pnpm --filter @objectstack/spec typecheck` exit 0 (tsc,
`check:scripts-typecheck`, `check:test-typecheck` OK), re-run at
8f58c38 (058d5c2 adds comments only); `@objectstack/metadata` exit
0; `@objectstack/objectql` exit 0 (`check:test-typecheck` OK). The first
objectql run after the unification found TS2345 at step 2b (the shared
definition is typed `unknown` per key); fixed in f4e83b0 by handing
it to the registry as the residual caller does.
- These ran outside the verify lock (declared narrowing): the lock was
held by two sibling dogfood batteries for about 100 minutes; the battery
below ran under it.
</details>
<details><summary>Ablation (each fix reverted after commit, through
scripts/ablation-replace.mjs; every restore proven blob == HEAD, `git
diff HEAD` empty)</summary>
- A, metadata listing removed: the metadata pin turns red (1 failed of
3).
- B, objectql registration call deleted: the objectql pin turns red (3
failed of 4 at that time).
- C, spec `jobs` judged by slot again: the spec jobs pin turns red (1
failed of 9).
- D, spec owner-body pairing removed: the owner-slot pin turns red (1
failed of 9).
- E (seat 7, at f4e83b0), `place: ext.place` replaced by `place:
undefined` in `objectExtensionContribution`: the objectql pin turns red
(1 failed of 6, the placement anti-vacuity); restore proven blob == HEAD
(cbc7b4d), `git diff HEAD` empty.
</details>
<details><summary>Real boot (os serve) after the fix</summary>
Same probe as the measure-first reading, at 5957d21: `GET
/api/v1/meta/object/probe_account` lists `residual_note`; `POST
/api/v1/data/probe_account` with it answers a created record.
</details>
## Acceptance notes
- Measure-first, step 2 (producers): `packages[]` beside a residual
comes from `'preserve'` with an input that has no manifest, and from any
strategy once an input is itself a multi-package artifact (its own
top-level collections are residual); `'first'`/`'last'`/an index over
inputs that carry no `packages[]` compose one flat package with no
residual. `os build` carries the composed top level as is (`1
Extensions`, exit 0). This corrects the first version of this note,
which said `'preserve'` only; the composition door's docblock always
said every strategy.
- #36236 landed on main with `place` in `registerApp` step 2b's
extension literal. Merging main here, the residual builder would have
registered a residual entry without its placement; the two are now one
call (`objectExtensionContribution`), `place` included, and the parity
pin covers a placed entry.
- The residual extension's dangling-picklist judgement reads the stack's
own bodies, like the residual objects' rule; a field naming a picklist
an already-installed package declares is treated as dangling (not
registered, named at boot): conservative, not silent.
- The `jobs` row's sentence changed at every door (it said the last
entry is kept; the binder schedules none). The #22934 rows stay one
table, byte-identical across doors.
- `defineStack` on a hand-built `packages[]` stack judges its whole top
level as one package (`stack.KEY[i]`), unchanged here.
## Open items (follow-up cards)
- #36431: a residual job sharing its name with a package body's job
(other content) composes and the boot schedules neither (contract review
S2, L1). Whether composition should refuse a job name shared across
packages is for the maintainer to rule.
- #36432: a residual picklist named only by a residual extension is
still refused as unreferenced at validate, build and boot (L1);
`packages/metadata/src/picklist-references.ts` still tells authors a
composed stack's top-level `objectExtensions` entry is not registered,
which after this PR holds only for an entry naming a picklist no body
declares (review N1); `sameAuthoredValue` (metadata) hand-copies the
spec's `deepEqualAuthored` and no test holds them equal (review N5).
- Not carried by either card: `logResidualSameTargetExtensions` also
reports an owner-body pair for a target the residual does not extend, a
second line beside `registerApp`'s (review N2).
## Verification
First files to read (by risk): `packages/spec/src/stack.zod.ts`
(`residualEntryPredicate`, `ownerBodyExtensionEntries`, the `jobs` row),
`packages/objectql/src/plugin.ts`
(`registerUnclaimedTopLevelExtensions`),
`packages/metadata/src/unclaimed-top-level-residual-extension.test.ts`.
Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
--project local --maxWorkers=2
src/manifest-service-residual-object-extension.test.ts` (after building
the objectql closure) — 6 passed.
Local gates at 058d5c2: 100 derived families (`dispatch-gates
--commands`), reconciled with `--ran` (exit codes recorded): 100 run, 0
NOT MEASURED. Seven first exited on a prerequisite (five spec `dist/`
gates: `dist` predated the last comment commit;
`check:dual-build-cjs-loads`: not every package built; the cli test:
`MODULE_NOT_FOUND`) and were re-run after the full closure build: exit 0
each. `check:type-check-debt` exit 0 (its full re-measure, 0 raw tsc
errors). `check:nul-bytes` exit 0. `overlap-check` clean before each
push.
PR check-runs at 058d5c2: Lint & Repo Gates, TypeScript Type Check,
Test Core, Build Core, Governed Surface Queue Guard, Type Check UI, Test
UI, Build & E2E UI, Live E2E UI, Dogfood Regression Gate and Check
Changeset success; Lint UI skipped (no `ui/` path).
Dogfood battery at 058d5c2: `os-verify-lock: VERDICT command-exit 0`
(closure build exit 0, then `pnpm --filter @objectstack/dogfood test`):
Test Files 484 passed, 3 skipped (487); Tests 4107 passed, 68 skipped
(4175). The same counts at f4e83b0.
Clause-② reading (seat 7): the diff refuses at composition three shapes
that compose today (listed under What changes), under every manifest
strategy once the result carries `packages[]`, so it is a narrowing,
declared `no (narrowing)` as the claim's conditional names. The contract
review at f4e83b0 named the third shape and the reach beyond
`'preserve'`, which the first version of this body left out. No governed
path is in the diff: the seat lands it with `--land` once the dogfood
battery is pinned to the head. Registering the residual extension is the
REGISTER judgement stated under What changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jTeURPvEm465RcoYEC -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 36873ee commit cedc094
9 files changed
Lines changed: 929 additions & 43 deletions
File tree
- .changeset
- packages
- metadata/src
- 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 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
383 | 429 | | |
384 | 430 | | |
385 | 431 | | |
| |||
419 | 465 | | |
420 | 466 | | |
421 | 467 | | |
422 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
423 | 474 | | |
424 | 475 | | |
425 | 476 | | |
| |||
428 | 479 | | |
429 | 480 | | |
430 | 481 | | |
| 482 | + | |
431 | 483 | | |
432 | 484 | | |
433 | 485 | | |
434 | 486 | | |
435 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
436 | 492 | | |
437 | 493 | | |
438 | 494 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 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 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
128 | 170 | | |
129 | | - | |
| 171 | + | |
130 | 172 | | |
131 | 173 | | |
132 | 174 | | |
| |||
395 | 437 | | |
396 | 438 | | |
397 | 439 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
419 | 444 | | |
420 | | - | |
421 | | - | |
| 445 | + | |
| 446 | + | |
422 | 447 | | |
423 | 448 | | |
424 | 449 | | |
| |||
0 commit comments