Skip to content

Commit 8f58c38

Browse files
committed
docs(spec): name every shape the residual door refuses, and the residual job name gap it leaves to the binder
The migration entry, the changeset and the residual predicate's docblock now name two residual extensions of one object beside another body's, and the first / last / index strategies once a multi-package input carries packages[]; the jobs row says neither runs when both are enabled. Two pins hold the shapes newly named. Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude <noreply@anthropic.com>
1 parent f4e83b0 commit 8f58c38

4 files changed

Lines changed: 93 additions & 26 deletions

File tree

‎.changeset/35711-residual-extension-and-jobs.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'@objectstack/objectql': minor
55
---
66

7-
fix(objectql)!: a `'preserve'` composition's top-level `objectExtensions` entry that no package body carries is registered and served; composition refuses two such jobs of one name, and a residual extension sharing its package's slot
7+
fix(objectql)!: a composition's top-level `objectExtensions` entry that no package body carries is registered and served; composition refuses two such jobs of one name, and residual extensions that would share one package's slot
88

99
Clause-②: no (narrowing)
1010
Metadata-protocol: narrowed
@@ -14,10 +14,11 @@ Skills-docs: none — no skill teaches placing `objectExtensions` or `jobs` in a
1414

1515
**BREAKING** accept-set narrowing, shipped as `minor`, beside a runtime fix.
1616

17-
- **Fixed (`@objectstack/objectql`, `@objectstack/metadata`).** Under `composeStacks(stacks, { manifest: 'preserve' })`, an input with no `manifest` keeps its collections at the artifact's top level, and the boot registers that residual under the artifact's `manifest.id` (ADR-0130 D4). Its `objectExtensions` entries were registered by no door: the target object was served without their fields (`INVALID_FIELD` on a write naming one) and nothing was logged, through `os serve` and through `os build`'s artifact alike. The residual rule (`unclaimedTopLevel`) now lists such an entry (type `object_extension`) when no package body carries an entry equal to it, and the engine registers it as an `extend` contribution under `manifest.id`, as a body's entry registers. An entry whose field names a picklist no package body declares is not registered and is named at boot, like a residual object.
18-
- **Refused now, at composition (`STACK_CROSS_REFERENCE_INVALID`, 422).** Two manifest-less inputs declaring one job name: the boot's job binder schedules neither (`NOT SCHEDULED` at `error`). A residual `objectExtensions` entry for an object that the last input with a manifest also extends with other fields: under `'preserve'` that input's id is `manifest.id`, one extension of an object registers per package, so only the last one's fields would be served. The finding names that body's entry first, then the residual's: `Object extension of 'crm_line' is declared twice in \`objectExtensions\`: 'com.example.billing' (stack #2) objectExtensions[0] and stack #1 objectExtensions[0]. …`.
19-
- **Wording.** The `jobs` finding at every door now says what the runtime does with the pair: `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 none of them runs.`
20-
- **Unchanged.** A residual extension for an object another package extends composes, and both register. A residual entry equal to a body's entry is that body's copy. Package-claimed extensions and a single residual job compose and boot as before.
21-
- **Installed artifacts keep loading.** A residual extension sharing its package's slot registers, the last one served, with one `error` line per object naming the entries.
17+
- **Fixed (`@objectstack/objectql`, `@objectstack/metadata`).** A composed artifact that carries `packages[]` keeps the entries no package body claims at its top level, and the boot registers that residual under the artifact's `manifest.id` (ADR-0130 D4). Under `composeStacks(stacks, { manifest: 'preserve' })` that is an input with no `manifest`; under `'first'`, `'last'` or an index it is also the own top-level entries of an input that is itself a multi-package artifact. Its `objectExtensions` entries were registered by no door: the target object was served without their fields (`INVALID_FIELD` on a write naming one) and nothing was logged, through `os serve` and through `os build`'s artifact alike. The residual rule (`unclaimedTopLevel`) now lists such an entry (type `object_extension`) when no package body carries an entry equal to it, and the engine registers it as an `extend` contribution under `manifest.id`, as a body's entry registers. An entry whose field names a picklist no package body declares is not registered and is named at boot, like a residual object.
18+
- **Refused now, at composition (`STACK_CROSS_REFERENCE_INVALID`, 422), under every manifest strategy once the result carries `packages[]`.** Two residual jobs of one name: the boot's job binder schedules neither (`NOT SCHEDULED` at `error`). A residual `objectExtensions` entry for an object that the body carrying `manifest.id` also extends with other fields: one extension of an object registers per package, so only the last one's fields would be served; the finding names that body's entry first, then the residual's: `Object extension of 'crm_line' is declared twice in \`objectExtensions\`: 'com.example.billing' (stack #2) objectExtensions[0] and stack #1 objectExtensions[0]. …`. Two residual `objectExtensions` entries for one object, also when another package body extends that object: a residual entry is now told from a body's flattened copy by value, not by target, so the two are one package's pair (they used to count as that body's copies and compose).
19+
- **Not refused (known gap).** A residual job that shares its name with a package body's job, with other content, still composes: it is read as that body's copy, and the boot holds two enabled jobs of the name and schedules neither.
20+
- **Wording.** The `jobs` finding at every door now says what the runtime does with the pair: `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.`
21+
- **Unchanged.** One residual extension for an object another package extends composes, and both register. A residual entry equal to a body's entry is that body's copy. Package-claimed extensions and a single residual job compose and boot as before.
22+
- **Installed artifacts.** A residual extension sharing its package's slot registers, the last one served, with one `error` line per object naming the entries. A residual extension now passes the registry's `extend` door as a package body's entry does, so one that door refuses (reachable only through `strict: false` or a hand-built artifact) now fails a boot that used to load and drop it.
2223

2324
One-line fix: declare each job name once; move a top-level extension into the package that owns it, or merge it into that package's own entry for the object.

‎packages/spec/src/migrations/entries/semantic/18.stack-residual-extension-registered-and-jobs-judged.ts‎

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,47 @@
22

33
import type { SemanticMigration } from '../../types.js';
44

5-
// An accept-set narrowing of composition, beside a runtime fix. A
6-
// composeStacks(…, { manifest: 'preserve' }) artifact's residual (top-level
7-
// entries no package body claims, registered under manifest.id) now has its
8-
// objectExtensions registered by the engine, where no door registered one; the
9-
// composition door judges what that registration makes one package. No D2
10-
// conversion: which of two extensions or two jobs to keep is the author's call.
5+
// An accept-set narrowing of composition, beside a runtime fix. A composed
6+
// artifact that carries packages[] has a residual (top-level entries no package
7+
// body claims, registered under manifest.id); its objectExtensions are now
8+
// registered by the engine, where no door registered one, and the composition
9+
// door judges what that registration makes one package. That holds under every
10+
// manifest strategy: 'preserve' with an input that has no manifest, and
11+
// 'first' / 'last' / an index with an input that is itself a multi-package
12+
// artifact. No D2 conversion: which of two extensions or two jobs to keep is the
13+
// author's call.
14+
//
15+
// Known gap, left to the job binder and not judged at composition: a residual
16+
// job whose name a package body's job also carries (with other content) is read
17+
// as that body's copy and composes, and the boot schedules neither of the two
18+
// enabled jobs. A follow-up card carries the question.
1119
export const entry: SemanticMigration = {
1220
id: 'stack-residual-extension-registered-and-jobs-judged',
1321
surface:
14-
"composeStacks(…, { manifest: 'preserve' }) with inputs that carry no manifest: two of them declaring one job "
15-
+ 'name, or one carrying an objectExtensions entry for an object that the last input with a manifest also '
16-
+ 'extends with other fields.',
22+
'composeStacks(…) whose result carries packages[] beside top-level entries no package body claims (the residual): '
23+
+ "under manifest 'preserve' the entries of inputs that carry no manifest, and under 'first', 'last' or an index "
24+
+ 'also every top-level entry an input that is itself a multi-package artifact carries of its own. Refused there '
25+
+ 'now: two residual jobs of one name; a residual objectExtensions entry for an object that the body carrying '
26+
+ 'manifest.id also extends with other fields; two residual objectExtensions entries for one object, also when a '
27+
+ 'package body extends that object too (before this release they counted as that body\'s copies and composed).',
1728
replacement:
1829
'Declare each job name once in the artifact. Put a top-level extension in the package that owns it, or merge it '
19-
+ "into that package's own objectExtensions entry for the same object: the residual registers under the "
20-
+ "artifact's manifest id, which under manifest preserve is the last input with a manifest, and one extension "
21-
+ 'of an object registers per package.',
30+
+ "into that package's own objectExtensions entry for the same object, and merge two top-level extensions of one "
31+
+ "object into one: the residual registers under the artifact's manifest id (under manifest preserve the last "
32+
+ 'input with a manifest, under first / last / an index the manifest that strategy keeps), and one extension of an '
33+
+ 'object registers per package.',
2234
reason:
2335
'A residual objectExtensions entry was registered by no door, so its fields were missing on the target and '
24-
+ 'nothing was said; it now registers under manifest.id. That id is also a package body under manifest preserve, '
25-
+ 'so a residual entry for an object that body extends too keeps only the last fields, and composition refuses '
26-
+ 'the pair (STACK_CROSS_REFERENCE_INVALID) with the one-package wording, the body entry first. Two residual jobs '
27-
+ 'of one name composed and the boot then scheduled neither (NOT SCHEDULED at error); composition refuses them '
28-
+ 'now, and the jobs wording at every door says that none of them runs. An artifact built before this keeps '
29-
+ 'loading: a residual extension pair is registered (the last one served) with an error line naming both.',
36+
+ 'nothing was said; it now registers under manifest.id. A residual entry is told from a body\'s flattened copy by '
37+
+ 'value, not by target, so two residual entries for one object are one package\'s pair whatever other packages '
38+
+ 'extend, and only the last one\'s fields register. Under manifest preserve that id is also a package body, so a '
39+
+ 'residual entry for an object that body extends too keeps only the last fields. Composition refuses each pair '
40+
+ '(STACK_CROSS_REFERENCE_INVALID) with the one-package wording, a body entry first. Two residual jobs of one name '
41+
+ 'composed and the boot then scheduled neither (NOT SCHEDULED at error); composition refuses them now, and the '
42+
+ 'jobs wording at every door says that when both are enabled neither runs. The same holds under first, last or '
43+
+ 'an index once an input carries packages[]. An artifact built before this keeps loading: a residual extension '
44+
+ 'pair is registered (the last one served) with an error line naming both. One case is NOT refused: a residual '
45+
+ 'job sharing its name with a package body\'s job composes, and the binder schedules neither (a known gap).',
3046
acceptanceCriteria:
3147
'objectstack validate and objectstack build load the composed stack without a STACK_CROSS_REFERENCE_INVALID '
3248
+ 'finding "Job \'NAME\' is declared twice in jobs" or "Object extension of \'OBJECT\' is declared twice in '

‎packages/spec/src/stack-residual-extension-jobs.test.ts‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function expectOneIssue(r: Refusal | null): asserts r is Refusal {
5555

5656
const JOB_CONSEQUENCE_AND_REMEDY =
5757
'The runtime keys jobs by name: the metadata keeps only the last of these entries, and the job scheduler ' +
58-
'refuses a name two enabled jobs share, so none of them runs. Rename one of them, or merge them into a single entry.';
58+
'refuses a name two enabled jobs share, so when both are enabled neither runs. Rename one of them, or merge them into a single entry.';
5959

6060
const EXTENSION_CONSEQUENCE_AND_REMEDY =
6161
"The runtime applies one extension of a target object per package, so only the last of these entries' fields " +
@@ -106,6 +106,27 @@ describe('residual jobs under `preserve` are judged as one package', () => {
106106
});
107107
});
108108

109+
describe('the residual door is not `preserve`-only: a multi-package input carries `packages[]` under every strategy', () => {
110+
const nested = () => composeStacks(
111+
[defineStack({ manifest: sales, objects: [line] }), defineStack({ manifest: billing })],
112+
{ manifest: 'preserve' },
113+
);
114+
115+
it.each(['first', 'last'] as const)('`%s`: two residual jobs of one name beside a nested artifact\'s packages[] are refused', (strategy) => {
116+
const r = refusalOf(() =>
117+
composeStacks([nested(), defineStack({ jobs: [job('First')] }), defineStack({ jobs: [job('Second')] })], { manifest: strategy }),
118+
);
119+
expectOneIssue(r);
120+
expect(r.issues![0]).toMatch(/^Job 'crm_nightly' is declared twice in `jobs`: /);
121+
expect(r.issues![0]).toContain(JOB_CONSEQUENCE_AND_REMEDY);
122+
});
123+
124+
it('CONTROL: `last` with a nested artifact and one residual job composes, packages[] carried', () => {
125+
const composed = composeStacks([nested(), defineStack({ jobs: [job('Only')] })], { manifest: 'last' }) as unknown as { packages?: unknown[] };
126+
expect(composed.packages, 'anti-vacuity: the artifact carries packages[]').toHaveLength(2);
127+
});
128+
});
129+
109130
describe('a residual `objectExtensions` entry shares the slot of the body that carries `manifest.id`', () => {
110131
it('a residual extension of a target that body extends too: refused, the body\'s entry first', () => {
111132
// `'last'` keeps billing's manifest, so the residual registers as billing.
@@ -152,6 +173,25 @@ describe('a residual `objectExtensions` entry shares the slot of the body that c
152173
)).toBeNull();
153174
});
154175

176+
it('two residual extensions of a target another body extends: refused as the residual\'s pair (claimed by value, not by target)', () => {
177+
const r = refusalOf(() =>
178+
composeStacks(
179+
[
180+
defineStack({ manifest: billing, objectExtensions: [extension('cb_billing')] }),
181+
defineStack({ objectExtensions: [extension('cb_first')] }),
182+
defineStack({ objectExtensions: [extension('cb_second')] }),
183+
defineStack({ manifest: sales, objects: [line] }),
184+
],
185+
{ manifest: 'preserve' },
186+
),
187+
);
188+
expectOneIssue(r);
189+
expect(r.issues![0]).toBe(
190+
"Object extension of 'crm_line' is declared twice in `objectExtensions`: stack #1 objectExtensions[0] and " +
191+
`stack #2 objectExtensions[0]. ${EXTENSION_CONSEQUENCE_AND_REMEDY}`,
192+
);
193+
});
194+
155195
it('CONTROL: a package-claimed extension is unchanged — two packages each extending one target compose', () => {
156196
const composed = composeStacks(
157197
[

‎packages/spec/src/stack.zod.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ const SAME_STACK_ENTRY_IDENTITY = Object.freeze({
33863386
subject: (name) => `Job '${name}'`,
33873387
consequence: () =>
33883388
'The runtime keys jobs by name: the metadata keeps only the last of these entries, and the job ' +
3389-
'scheduler refuses a name two enabled jobs share, so none of them runs.',
3389+
'scheduler refuses a name two enabled jobs share, so when both are enabled neither runs.',
33903390
remedy: RENAME_OR_MERGE,
33913391
},
33923392
// An i18n bundle is one `name` across several `locale` tags, so the identity
@@ -3713,6 +3713,16 @@ function composedPackageBodies(composedPackages: unknown): Record<string, unknow
37133713
* is never read as a second entry of the residual, while two entries that no
37143714
* body declares are judged as one package's: the boot's job binder schedules
37153715
* neither of two enabled jobs of one name.
3716+
*
3717+
* ⚠ Known gap, left to the binder and NOT judged here: the claim is by NAME, so
3718+
* a residual job whose name a package body's job also carries is read as that
3719+
* body's copy even when the two differ, and composes. The boot reads jobs off
3720+
* the stack whole, so it holds two enabled jobs of that name and its binder
3721+
* (`jobNameCollisions`, `@objectstack/runtime`) schedules neither — read from
3722+
* code, not driven. Two package bodies each declaring the name meet the same
3723+
* binder outcome and compose too (cross-package reuse, ADR-0048 §3.4). Whether
3724+
* composition should refuse a job name shared across packages is a follow-up
3725+
* card's question, not this door's.
37163726
*/
37173727
function residualEntryPredicate(composedPackages: unknown): (key: string, entry: unknown) => boolean {
37183728
const bodies = composedPackageBodies(composedPackages);

0 commit comments

Comments
 (0)