Repository navigation
feat(spec)!: strict defineStack judges a packages[] stack per body and counts only the top-level apps no body declares against its manifest - #33074
Conversation
…d counts only undeclared top-level apps against its manifest Strict defineStack now reads a stack that carries packages[] through the judge composeStacks uses for its result (residualSingleAppFinding, one implementation for both doors): each body by its own type, id and apps, and the manifest id with the apps of its own body plus every top-level app no body declares, mirroring the load path's residual rule (unclaimedTopLevel). A hand-built stack whose undeclared top-level app the boot would register beside the manifest-id body's app is refused; an additive artifact whose top level repeats body-declared apps is accepted. A stack without packages[] is judged as before. Claude-Session: https://claude.ai/code/session_01L9qibyebbesu5rXZGhyF6z Co-Authored-By: Claude <noreply@anthropic.com>
…defineStack's single-app rule Claude-Session: https://claude.ai/code/session_01L9qibyebbesu5rXZGhyF6z Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift Check5 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 171 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4eebbc4b479118203ab05a0ad5fd88336559abe4 && git checkout 4eebbc4b479118203ab05a0ad5fd88336559abe4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5430b4a40cf298d0784ea3a9f8aabdf36068d761 35660b555d394212e25efb94f270a27825a5d8e2 && git checkout -B drift-repro 5430b4a40cf298d0784ea3a9f8aabdf36068d761 && git merge --no-ff 35660b555d394212e25efb94f270a27825a5d8e2
node scripts/docs-audit/affected-docs.mjs --json 5430b4a40cf298d0784ea3a9f8aabdf36068d761 |
|
domain:spec#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9 Contract reviewServed-tier:
Check-runs at review time (2026-11-13T08:39Z): 47 success, 11 skipped, 6 in progress (Test Core 7/8 and 8/8, Test UI 1/16 and 16/16, Type Check UI, Type Check · workspace), no failure; ① Derived judgments
② Semver level
Prose faces against the code at head:
③ Boundary flags
④ Design judgmentHolds. Strict No must-fix, no should-fix. Nits:
Implemented-by: VERDICT: PASS |
|
domain:spec#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9 维护者速读
席位意见:可以落地;按冻结裁定 6848983225 暂不入队,解冻后由席位落地。 席位核对ACCEPT · seat
|
|
domain:spec#2 · os-tesla · session_01L9qibvfX5bawZKtfa6u7j9 维护者速读
席位意见:可以落地。 席位核对ACCEPT · seat
|
…] body are judged since 2026-11-13 (objectstack-ai#33502) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X4e82tcKptpRRoyvCJDwBeL)_ Fixes objectstack-ai#33135 domain:skills#1 · os-project-manager · session_01FEkQ5obDWQ7NdtH2f9iZXC Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:ADR-0019 在 2026-11-12 的执行记录里写着「两种形状不受检查:扁平的 `composeStacks`,和手工拼的 `packages[]` 包体」。这句改成当日的读数(过去时),并在其后新增一段「自 2026-11-13 起,组合与 `packages[]` 包体都受检查」,逐条写明 objectstack-ai#32898、objectstack-ai#33074、objectstack-ai#33122 三次合并各自检查了什么;状态行的「已落地」也补上这三次合并及其提交号。 - 为什么改:这句话两半在 `main` 上都已不成立:扁平组合把两个以上应用放到同一个 app/module 包名下会被拒(`STACK_SINGLE_APP_VIOLATION`,422),手工拼的包体也按包分别检查单应用和命名空间前缀。照着旧文字读的作者或 AI 会以为这些形状不受检查。 - 风险与回滚:只改决策记录文字,不动代码、协议和技能包;回滚即还原本 PR。 - 先看:`docs/adr/0019-app-as-consumer-unit.md` D3 修订说明下的「Enforced for compositions and `packages[]` bodies since 2026-11-13」一段;再看第 3 行状态行新增的那半句。 - 两分钟验证:`pnpm check:adr-symbol-anchors`,预期 exit 0、「anchors across 156 records resolve」。 - 需要你做的:受管面 Tier H(`docs/adr/**`):请批准或合并。 ## What changes - **`docs/adr/0019-app-as-consumer-unit.md`, D3, the 2026-11-12 note "Enforced for modules since 2026-11-12".** Its sentence "The check reads one `defineStack` call. Two shapes are not judged (objectstack-ai#32810): a flat `composeStacks` … and a hand-built `packages[]` body." is rewritten as the reading at that merge, in the past tense, and points to the next paragraph: "At this merge the check read one `defineStack` call, and two shapes were not judged (objectstack-ai#32810): … Both are judged since 2026-11-13; see the next paragraph." The rest of that paragraph is unchanged. - **New dated paragraph "Enforced for compositions and `packages[]` bodies since 2026-11-13."**, following the file's own convention (the 2026-11-12 note keeps the paragraph before it "as written" and adds a dated note). One bullet per merge: - objectstack-ai#32898 (`0b23b2a0c4`): `composeStacks` refuses a flat composition (`'last'`, `'first'` or an index) whose kept manifest is an `app` or `module` package and that brings two or more apps, `STACK_SINGLE_APP_VIOLATION` (422), naming each app and its input; the remedy is `manifest: 'preserve'`; every `packages[]` body of a composition is held to one app; a one-input composition is handed back unjudged. - objectstack-ai#33074 (`2c98485db5`): changes only how strict `defineStack` counts the top level of a `packages[]` stack. Before, every top-level app counted against `manifest.id`; since, the residual rule objectstack-ai#32898 gave `composeStacks` (top-level apps no body declares count against `manifest.id` beside that id's own body). Bodies are judged as before, per body since objectstack-ai#32898. - objectstack-ai#33122 (`5b2ec820c8`): strict `defineStack` judges namespace prefixes per body against the body's own namespace, residual top-level objects against `manifest.namespace`, `STACK_NAMESPACE_PREFIX_INVALID`; a body with no namespace is not judged. - What stays unjudged at `defineStack` (other package types, no manifest, `strict: false`, the last now judged at `composeStacks`), and the placement sentence, which stands (measured, below). - **Status line, "Landed in spec".** After the objectstack-ai#32586 clause: "and the same rule on a flat `composeStacks` and on every `packages[]` body (objectstack-ai#32898, merged 2026-11-13 as `0b23b2a0c4`; objectstack-ai#33074, merged 2026-11-13 as `2c98485db5`), and the namespace-prefix rule judged per `packages[]` body (objectstack-ai#33122, merged 2026-11-13 as `5b2ec820c8`)." - Not touched: the D3 reasons, the 2026-11-12 "Enforced today, and not yet." paragraph, ADR-0130 (the order's surface is this file only), and `skills/**` (PR objectstack-ai#33475 teaches the flat-compose fact there). ## Why Read on `origin/main` `b392ff7b`, not from the card: - `packages/spec/src/stack.zod.ts`: `collectComposedSingleAppErrors` and `flatSingleAppFinding` (flat result: every app counts against the one kept manifest), `SINGLE_APP_PACKAGE_TYPES` = `app`, `module`, `SINGLE_APP_COMPOSE_REMEDY` (names `manifest: 'preserve'`), `collectPackageBodySingleAppErrors` (each body by its own `type`, `id`, `apps`), `validateSingleApp` and `residualSingleAppFinding` (one judge for both doors), `namespacePrefixErrors` (per body, residual top level), `composeStacks`' `stacks.length === 1` early return. - `examples/app-multi-package/objectstack.config.ts` composes with `manifest: 'preserve'`. - Attribution per PR, read from each merge commit's tree: `residualSingleAppFinding`, `flatSingleAppFinding` and `collectPackageBodySingleAppErrors` exist at `0b23b2a0c4` (objectstack-ai#32898), where `validateSingleApp` does not call the residual judge; it does at `2c98485db5` (objectstack-ai#33074); `namespacePrefixErrors` first exists at `5b2ec820c8` (objectstack-ai#33122). - Each merge commit is an ancestor of `origin/main` (`git merge-base --is-ancestor`, exit 0 for all three, after deepening the shallow clone). - One probe against `packages/spec/dist` built from `b392ff7b`, not kept as a test: | Shape | Answer | |:--|:--| | flat `composeStacks` (default `'last'`) of two module stacks with one app each | refused, `STACK_SINGLE_APP_VIOLATION` 422 | | the same under `manifest: 'preserve'` | accepted | | hand-built `packages[]` body (module) with two apps, `defineStack` | refused, `STACK_SINGLE_APP_VIOLATION` 422 | | hand-built body, namespace `svc`, object `crm_case` | refused, `STACK_NAMESPACE_PREFIX_INVALID` 422 | | control: same body with `svc_case` | accepted | | placement: module with no objects, app names `crm_case` | accepted | | placement: object-less body's app names a sibling body's object, `defineStack` and `'preserve'` compose | accepted | The placement sentence therefore stands, as the order asked to measure. Ruling: Leehom 2026-11-14T21:21:06Z 「开放 p3卡认领」 (p3 cards open for claiming); scope widened to both halves by the skills seat's note 6884985712 on the card. ## Acceptance notes - **The 2026-11-12 paragraph is edited, not kept verbatim.** The order asks for both "rewrite the whole sentence" and "keep the dated paragraph as the reading at that date". Rewriting the one sentence into the past tense, with a pointer to the new note, does both: the paragraph still reads as at objectstack-ai#32586's merge, and no present-tense sentence on the page is false. - No out-of-scope findings. ## Verification Head `691fe886` (round 1, after contract review 6885553305; round 0 was `c72ef404`), base `origin/main` `b392ff7b`. <details><summary>Derived gates: 21 derived, 21 run, all exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 21 families for the one path. Each ran on head `c72ef404` (round 0) and again on `691fe886`, 21 of 21 exit 0 (`33135-gates-ran-r1.txt`) with its exit code captured before any pipe, after building `@objectstack/lint...` under the verify lock (VERDICT command-exit 0, 86s): - exit 0: `check-adr-links` (scan and `--self-test`), `check-closing-keyword-parity` (scan and `--self-test`), `check-comment-mask-corpus`, `plan-test-core-shards --self-test`, `@objectstack/lint check:doc-formula-expressions`, `check:adr-anchors`, `check:adr-index`, `check:adr-symbol-anchors` ("3594 anchors across 156 records resolve"), `check:ci-filter-parity`, `check:closed-ceremony-text`, `check:cross-package-test-inputs`, `check:doc-authoring`, `check:driver-memory-census`, `check:gitlink-declared`, `check:nul-bytes`, `check:pm-governed-merges`, `check:pm-prior-rulings`, `check:refd-timer-probe`, `check:watch-hint-literal`. - `--ran` reconciliation: "21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED". - The path-less symbol continuations (`#flatSingleAppFinding`, `#SINGLE_APP_COMPOSE_REMEDY`, `#collectPackageBodySingleAppErrors`, `#validateSingleApp`, `#residualSingleAppFinding`, `#namespacePrefixErrors`) are not judged by `check:adr-symbol-anchors` (that spelling is off in this corpus); each was found by `grep` as a declaration in `packages/spec/src/stack.zod.ts` on `b392ff7b`. - CI families are read from this PR's check-runs, not re-run here. </details> <details><summary>Tier and governed readings</summary> - `dispatch-gates --tier`: MANDATORY contract-review tier for `docs/adr/**`; no one-line exit for this surface. This thread ran at the claim's default model; the seat's in-seat contract review is the owed record. - `node scripts/pm/check-governed-merges.mjs --branch claude/project-thread-bd7546`: GOVERNED, landing tier H (人合), `docs/adr/**` x1. Size +50 / -4, under the 3000 threshold. - `node scripts/pm/check-skill-line-ratchet.mjs`: exit 0 (no skill file touched). No changeset: `docs/adr/**` ships in no package (`skip-changeset`). </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5obDWQ7NdtH2f9iZXC <!-- signed: domain:skills#1 · os-project-manager · session_01FEkQ5pjSPT7ui2EUcunaVb --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Tesla · project thread
Fixes #32978
Clause-②: yes (narrowing) — one face narrows and one widens. Narrowed: a stack carrying
packages[]whose top level holds an app that no package body declares, beside an app of the package body with the manifest's id (or two such apps), is refused by strictdefineStack, where it was accepted. Widened: a stack carryingpackages[]whose top level repeats apps that different package bodies declare (an additive artifact, such asresolveArtifactCollectionsoutput) is accepted, where it was refused.Metadata-protocol: narrowed
Skills-docs: none — the taught rule (at most one app per package; compose a suite with
composeStacks(stacks, { manifest: 'preserve' })) is unchanged, and no skill or docs page teaches handing apackages[]stack todefineStack; what moves is which top-level apps strictdefineStackcounts on such a stack. The single-app teaching follow-up of #32898 is #32977.维护者速读
defineStack判带packages[]的栈时,改用composeStacks已有的同一个判法(同一份实现,两道门共用):每个包体按自己的类型和应用判;只有「没有包体声明的顶层应用」才和 manifest id 那个包体自己的应用一起算到栈的 manifest 下,与加载路径的残余规则一致。composeStacks按加载路径的读法判,defineStack还是把全部顶层应用都算到栈自己的 manifest 下,两道门对同一形状判法不同:把resolveArtifactCollections的输出交回defineStack会被误拒;手搭一个多出一个未声明顶层应用的栈却会通过,启动时变成一个包两个应用。Clause-②: yes (narrowing))。实测本仓与 HotCRM 没有任何产品代码把带packages[]的栈交给严格defineStack(HotCRM 是每包defineStack后composeStackspreserve)。不带packages[]的栈判法不变。回滚即 revert。packages/spec/src/stack.zod.ts的validateSingleApp(新分支)与residualSingleAppFinding(抽成两门共用、按门传入残余应用的来源与改法);packages/spec/src/stack.test.ts新 describe;packages/runtime/src/artifact-collections.public-reader.test.ts新 describe。pnpm --filter @objectstack/spec exec vitest run src/stack.test.ts -t "judged per body",预期 4 条全绿,其中一条是「手搭栈的未声明顶层应用与 manifest id 包体的应用一起被拒(422STACK_SINGLE_APP_VIOLATION)」。What changes
One judge for both doors.
residualSingleAppFinding(packages/spec/src/stack.zod.ts), added by #32898 forcomposeStacks, is now shared. It reads apackages[]stack the way the load path registers it: the apps of the body whose id is the manifest's, plus every top-level app no body declares (the residual rule,unclaimedTopLevelin@objectstack/metadata, mirrored by the existingisResidualTopLevelItem;packages/metadatais read, not changed). Two or more of them, at least one residual, are refused. AResidualSingleAppDoorargument carries only what differs per door: the finding's subject, where each residual app came from, and the remedy. ThecomposeStacksfinding is byte-identical to before (its pins are unchanged and green).validateSingleApp(the strictdefineStackpass):packages[]: unchanged. Every app counts against the stack's own package.packages[]with anappormodulemanifest: the top level goes through the shared judge, the residual apps named as'NAME' at its top level (apps[i]), which no package body declares; every body is still judged bycollectPackageBodySingleAppErrorsas before.Example finding: "A 'module' package must define at most one app, but the stack gives package 'com.example.crm.service' 2 ('crm_service' from its package body (packages[1]), 'crm_field_service' at its top level (apps[0]), which no package body declares): an app that no package body declares is registered under the artifact's manifest id, beside the apps of that package's own body. Keep one app per package: declare each such app inside the package body it belongs to, or give it a 'module' package of its own and compose with composeStacks(stacks, { manifest: 'preserve' }), which registers each package body under its own id — ADR-0019 (app-as-consumer-unit) D3 as amended (a suite may surface several apps, one per package)."
Docblocks.
validateSingleApp's docblock no longer sayscomposeStacksjudges by "the same rule" loosely: it states the two readings (nopackages[]/packages[]) and thatcomposeStacksshares the residual judge.StackSingleAppViolationError'sdefineStackraise-site line andcollectComposedSingleAppErrors's docblock say the same.ADR-0087. New semantic entry
define-stack-packages-residual-second-app-refused(packages/spec/src/migrations/entries/semantic/18.define-stack-packages-residual-second-app-refused.ts), no D2 conversion (which package an app belongs to is the author's call). The changeset registers it.Changeset.
.changeset/32978-define-stack-packages-single-app.md,@objectstack/specminor, both declaration lines, BREAKING banner with Before / Now / Unchanged / Fix.No error code added: the refusal is the existing
STACK_SINGLE_APP_VIOLATION(422).Tests
New top-level describe in
packages/spec/src/stack.test.ts("defineStack — a packages[] stack is judged per body, and its top level by the residual rule composeStacks reads"):modulemanifest;codeSTACK_SINGLE_APP_VIOLATION,status422, thedefineStackheader, the package, both apps with where each sits;packages[]is judged unchanged (two apps refused naming the package, one accepted).New top-level describe in
packages/runtime/src/artifact-collections.public-reader.test.ts(file surface amended by the seat, comment 6846967975):defineStack(resolveArtifactCollections(composeStacks([app, module], { manifest: 'preserve' })))passes, with anti-vacuity (two top-level apps under amodulemanifest). The packages share one namespace so the namespace-prefix rule is not what answers (see #33069).Both arms were reproduced on
origin/main157051cebefore the fix with a built probe: the reader round trip was refusedSTACK_SINGLE_APP_VIOLATION422, and the hand-built stack was accepted.Ablations (each committed first, mutated through `scripts/ablation-replace.mjs`, restored to the HEAD blob)
Taken at
f649a494(pre-merge head; the merge oforigin/maintouched no line these mutate). Each mutation landed (anchor 1 → 0, blob changed) and each restore readblob == HEAD (6d75946920d3) and git diff HEAD is empty.stack.zod.tsvalidateSingleAppback to the old reading (const own = true || !Array.isArray(config.packages))defineStackdoor (every top-level app residual)packages[]branch judges nothingartifact-collections.public-reader.test.ts)The runtime suite resolves
@objectstack/spectosrc/(packages/runtime/vitest.config.tsalias), and so doesstack.test.ts(./stack.zod), so no dist rebuild was owed per leg.Acceptance notes
packages[]stack to strictdefineStack. In-repodefineStack(call sites on a stack value are tests (allstrict: falseor per-package inputs) and authored configs withoutpackages[]; HotCRM (0009f58, read-only) builds each package withdefineStackand composes withcomposeStacks(packageStacks, { manifest: 'preserve' }), never re-judging the artifact. The consumer suites below are the empirical half.STACK_NAMESPACE_PREFIX_INVALID, becausevalidateNamespacePrefixjudges the merged top-level copies of body objects against the stack manifest's namespace. Not touched here.ruling|Ruling-ref|maintainer|⛔) overstack.zod.ts: 68 hits file-wide, one inside the edited regions (thevalidateUnmanagedInstallModedocblock, untouched). No ruling sits on the edited lines.surface's "or two or more such apps" name no newly refused shape: two undeclared top-level apps were already refused before this change, with the same code and status. Over-inclusive, in the safe direction.packages[]stack that was already refused (two undeclared top-level apps, orpackages: []with two apps) now reads the residual sentence instead of "package 'X' defines N …", and on that path anappmanifest loses the "fold them into one app" remedy. Code, status and header are unchanged; the changeset does not mention the rewording.resolveArtifactCollectionsoutput as accepted without the spec: strict defineStack refuses an additive packages[] artifact of differently-namespaced packages with STACK_NAMESPACE_PREFIX_INVALID, judging body objects against the stack manifest's namespace #33069 limit (differently-namespaced packages are still refused earlier, by the namespace-prefix rule). This body states the limit.residualSingleAppFinding's docblock saysdoor"only names" the residual apps, butdoor.residualalso enumerates them, so the count comes from the door. The two doors agree today; a third could differ.renamedFrom) edits another region ofstack.zod.ts; this PR touchesvalidateSingleApp(:2690–2760), the:3825) andStackSingleAppViolationErrordocblock (collectComposedSingleAppErrors/residualSingleAppFinding(~:8836–8990).Verification
Readings at head
0d2b8278(after mergingorigin/main12b14462, which brought #33008), afterpnpm install --frozen-lockfileandpnpm turbo run build --concurrency=2 --filter='./packages/**' --filter='@objectstack/dogfood^...'(81/81 tasks), every heavy command underscripts/pm/os-verify-lock.sh(VERDICT command-exit 0 on each), exit codes captured before any pipe:pnpm --filter @objectstack/spec check:generated: all 14 generated artefacts up to date; tree clean.pnpm --filter @objectstack/spec test: Test Files 840 passed (840), Tests 26827 passed, 1 todo.typecheck: exit 0.dispatch-gatesdoes not derive them):@objectstack/runtimetest: Test Files 596 passed (596), Tests 10562 passed, 19 skipped;typecheckexit 0.@objectstack/metadatatest (theunclaimedTopLevelload path): Test Files 76 passed (76), Tests 2178 passed.@objectstack/metadata-protocoltest: Test Files 337 passed, 7 skipped (344); Tests 22799 passed, 36 skipped.@objectstack/coretest: Test Files 146 passed (146), Tests 3368 passed.@objectstack/linttest: Test Files 202 passed (202), Tests 8610 passed.@objectstack/cliunit (vitest run --project unit): Test Files 416 passed (416), Tests 5933 passed. The integration layer is CI's (no spawn entry or integration file in the diff).Clause-②carries a(narrowing)arm):pnpm --filter @objectstack/dogfood testat0d2b8278, lock VERDICT command-exit 0, Test Files 458 passed, 3 skipped (461); Tests 3844 passed, 42 skipped; no failure.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack→ 91 families, each run with</dev/null. 90 exited 0 on the first pass;node scripts/check-plugin-teardown-shape.mjs --self-testexited 3 (PREREQUISITE: its pinned fixture commit621a4876was outside the shallow clone), and aftergit fetch origin 621a487607881c66b2899b7e3477115229a156b4 --depth=1it exited 0 (48 cases). Reconciliation--ran:91 derived famil(ies) accounted for — 91 run, 0 NOT-MEASURED.0d2b8278: 67 check-runs, allsuccessorskipped, none failed or pending (the eleven required contexts that ran on the PR: Lint & Repo Gates, TypeScript Type Check, Test Core, Build Core, Governed Surface Queue Guard, Test UI, Build & E2E UI, Type Check UI, Live E2E UI, Dogfood Regression Gate success; Lint UI skipped by its path filter). Check Changeset success.CONTRACT_REVIEW_TIER, head0d2b8278, PASS, no must-fix or should-fix.Generated by Claude Code