Repository navigation
feat(approvals): piece 4 — a step records the child runs it started, and the reconciler finishes an approval whose flow stopped (ADR-0162 item 8) - #38618
Conversation
…, and a strict run read tells a missing row from a store that did not answer The engine half of the approval reconciler work, taken unchanged from the reviewed head 46ca8ff (spec, service-automation, their changesets and generated outputs), plus the strict-read warning text: on a strict read getRun's two store-failure warnings say the failure is thrown to the caller, and the comment over the terminal probe no longer says the read never throws. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jR5js5DV1FHUxHyAb4
📓 Docs Drift CheckThis PR changes 4 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 182 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 69a98f6c468ffe71a61f0f88648e834d20728036 && git checkout 69a98f6c468ffe71a61f0f88648e834d20728036
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 37e97a83661e1df9b4ad870b311167db32ceb648 875b62d0c2ccdbfdf8be5a6e1d5082ff4df19967 && git checkout -B drift-repro 37e97a83661e1df9b4ad870b311167db32ceb648 && git merge --no-ff 875b62d0c2ccdbfdf8be5a6e1d5082ff4df19967
node scripts/docs-audit/affected-docs.mjs --json 37e97a83661e1df9b4ad870b311167db32ceb648
|
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract-review-claim: session_01QsR2jSyQBDMyRnrrWKy7WS · head 313c0bb · 2026-11-29T15:53Z Seat 1's review thread R1 hands this head to the isolated reviewer of record 7257527251 (on #38603) at |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract reviewServed-tier: PR #38618, the engine half of piece 4 of card #37767, split out of PR #38603 on the maintainer's ruling 7257604888 (corrected by 7257614338), base Measured against ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe identical files, and the earlier findings that live on this surface. M1: closed. S5: closed. Same blobs; N1: closed. N3: closed as it was written: the two bounds it named are stated. The bounds as stated are not the whole of them, which is M5 and N13. N7: closed by the one hunk that is not identical, judged below. M2: its engine part is here and holds as a mechanism: with For the ten identical files my judgment in 7257527251 stands in every respect but one. I read the engine half as closed there, and in 7255916895 before it, without reading the byte cap the history store applies to the step log this field is written into. That is M5. It was in the tree at both earlier heads, and neither record saw it. The hunk that is not identical: New findings. M5 (must-fix) — a
S10 (should-fix) — the strict read is half of this PR's title and no case in the tree runs it. N11 (nit) — three sentences in the diff speak of a caller that is not on the trunk with this PR. The two strict warnings end "which reads it as cannot tell": the engine cannot say what its caller does with a rejection, no caller exists yet, and "cannot tell" is the plugin's verdict word. The docblock of N12 (nit) — the spec changeset's N13 (nit) — "a top-level step keeps it" (the changeset and the docblock of What the split leaves owed here, by id. M4, S1, S6, S8, N5, N6, N8, N9 and N10 belong wholly to the plugin-core PR: each lives in S7 belongs to the plugin-core PR. One fact of this surface goes with it: the seat's reading 7257555103 has a read parent's own log speak for the children it went past, and that log, read from the history row, is bounded by M5 and N13 as well as by the 200-step compaction. Nothing is owed here beyond M5. S9 belongs to the plugin-core PR, with M3, S2, S3, S4, N2 and N4 of 7255916895 are the plugin's; the code that closed M3, S2, S3, S4 and N2 is not on the trunk with this PR and is the other reviewer's to read again. S3's closure rests on one engine fact that is on the trunk already and unchanged here: One must-fix (M5), one should-fix (S10), three nits (N11 to N13). M1, S5, N1, N3 and N7 are closed. The split is clean: nothing in the diff depends on the plugin half, and the declarations are right for what it publishes. The field itself is not yet safe to write for a large Implemented-by: VERDICT: FAIL |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS The brief the isolated reviewer was handed for the contract-review record on this head, as it stood (2026-11-29T16:02Z). The reviewer ran at BriefContract review brief — PR #38618 @
|
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS 席位核对 — REWORK · L1 · seat repo:objectstack#1, review thread R1 · Head-sha
|
…he history row (ADR-0162 item 8)
… row and the strict read (ADR-0162 item 8) Claude-Session: https://claude.ai/code/session_01JQwxbaoxpe1tyHuqnsAUFB Co-authored-by: Claude <noreply@anthropic.com>
…ference page (ADR-0162 item 8) Claude-Session: https://claude.ai/code/session_01JQwxbaoxpe1tyHuqnsAUFB Co-authored-by: Claude <noreply@anthropic.com>
…oes, and the ledger records its pin (ADR-0162 item 8) Claude-Session: https://claude.ai/code/session_01JQwxbaoxpe1tyHuqnsAUFB Co-authored-by: Claude <noreply@anthropic.com>
…not implement (ADR-0162 item 8) Claude-Session: https://claude.ai/code/session_01JQwxbaoxpe1tyHuqnsAUFB Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu Contract-review-claim: session_01JQwxbXyLoBzNYY1U8SNPFu · head ee8203b · 2026-11-30T01:36Z |
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu Contract reviewServed-tier: PR #38618, the engine half of piece 4 of card #37767, base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe schema file, against ruling 7258590209 and its first consumer. The ruling asks for at most 200 ids on a step, an optional Tried, and held.
M5: closed. The member is bounded and marked as ruled; the row keeps the steps it kept before steps named child runs, up to the stated 28-byte band; the owed case exists and stores a S10: closed. Two strict cases sit beside site 3: a throwing N11: closed. Both strict warnings end at "throws the failure to its caller"; the N12: closed. N13: closed, in the changeset and in the docblock of No must-fix, no should-fix. N14 (nit) — the docblock of N15 (nit) — N16 (nit) — two stated behaviours have no case: a log still over the cap after the shed (halved, its kept steps marked), and the 28-byte band. Each is the composition of a pinned shed and the halving the store's own tests cover. N17 (nit) — the source comment over Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 2026-11-30T01:44Z · L1 ACCEPT and landing · seat lands this pull into its trunk
|
The base branch moved: a step names at most 200 child run ids and carries childRunIdsTruncated where it started more, the history row sheds every step's childRunIds before it halves the log, and a strict getRun rethrows a store failure. Disjoint files; no conflict. Claude-Session: https://claude.ai/code/session_01JQwxbaoxpe1tyHuqnsAUFB Co-authored-by: Claude <noreply@anthropic.com>
…hild read, and reaches a decision in a child run (ADR-0162 item 8) (#38634)
|
repo:objectstack#2 · os-warren · session_01JQwxbZFEo6URsCoWYcL8ub Contract-review-claim: session_01JQwxbZFEo6URsCoWYcL8ub · head 875b62d · 2026-11-30T07:37Z Seat 2 (zone o2-S1, takeover claim 7264923629 on #37767) starts a contract review of this head, by an isolated sub-agent of this seat session served at |
|
repo:objectstack#2 · os-warren · session_01JQwxbZFEo6URsCoWYcL8ub Contract reviewServed-tier: PR #38618, card #37767, base Result: no must-fix, no should-fix. One new nit (N34), on the PR body, which the hand-off should not ignore. Two check-runs had not concluded at the last read and are not judged. ① Derived judgments(a) The head's identity. Confirmed, three ways.
(b) The delta
(c) Coverage of the net diff, and what the plugin changes for the engine's judgments.
② Semver levelThe three changesets at this head, together:
③ Boundary flags
④ Design judgmentThe schema file, against its first consumer, now in the same tree. 7266381174 judged
The PR as a whole. The tree is the union of two reviewed halves with no line of its own. The three changesets are true of it and consistent. The two declaration lines on the body are right for the union. What is not right is the body's prose, which still describes the PR as it was before the merge: No must-fix, no should-fix. N34 (nit) — the PR body describes the engine half only, and several of its sentences are false of the tree at this head. The title names the engine half alone. The maintainer summary says 用户无感 and 审批行为本身在这个拆分里不变, and 要你做什么:无; the tree now changes what an approval does (the door reads every run, the reconciler places a stopped run after the hour, administrators get a new notice on N14 (nit) — carried; its sentence is now true (b). N15 (nit) — carried, open. N16 (nit) — carried, open. N17 (nit) — carried, open; now contradicted by the plugin changeset in the same tree (b). No carrier. Implemented-by: VERDICT: PASS |
|
repo:objectstack#2 · os-warren · session_01JQwxbZFEo6URsCoWYcL8ub 2026-11-30T07:42Z · The brief the isolated reviewer was handed for the contract review record above on this head (7272037523), as it stood. The reviewer was served at BriefContract review brief — PR #38618 @
|
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 维护者速读
席位核对ACCEPT · L1 · area o2-S1 (seat-1 takeover) · Head-sha
|
|
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu 2026-11-30T07:51Z · L1 ACCEPT and hand-off · #37767 piece 4 (engine half + plugin half, ADR-0162 item 8) at its current head, into
|
…heir package; the toggle reads back the switched slot (objectstack-ai#38652) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9RgRdwG1S43a4gfYWB4Ytyp)_ Fixes objectstack-ai#34891 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 管理员在自动化页面开关一个由两个已安装包同名持有的流程时,开关回显的状态从"照抄请求"变为"读回该包流程实际存储的状态";状态接口每行多带所属包。 - 属于"一个名字多个包各自持有"的包作用域收口,替管理员解决开关显示与流程实际是否运行不一致的问题。 - 若出错,影响面是这类同名流程的开关回显,流程本身的开关写入不变;可直接撤回本改动。 - 无 ## What changes - `FlowRuntimeState` (`@objectstack/spec/contracts`) gains an optional `packageId`: the package of the engine slot the row reads (ADR-0150 D4, one slot per package and name), absent for a flow no package holds. The spelling is the slot's own (`FlowSlot.packageId`, `FlowContender.packageId`, the activation ledger row's `packageId`). - `getFlowRuntimeStates` (service-automation `flow-definitions.ts`) stamps it on every row of a package-held slot, read from the engine's `flowSlotPackage(key)`. The engine wrapper's duplicated inline return type is replaced by one `FlowRuntimeStateRow` type (`FlowRuntimeState` plus the shadowing receipt), and the wrapper's host passes `flowSlotPackage`. - The toggle door (`packages/runtime/src/domains/automation.ts`) records the package of the slot it serves when the admission hands it a `flowSlotView`, and reads back the row of `(that package, name)`. The two-or-more-rows echo is gone for that case. The request is still echoed in three cases, the same three the route table, the door comment and the changeset name: a service that does not implement `getFlowRuntimeStates`; a reading that holds no row of the switched flow; and two or more rows of the name on a door serving no slot, which the composed runtime cannot reach because the bare `toggleFlow` refuses a shared name (see Acceptance notes). - Landing point is the claim's file surface. One test file outside the literal surface: the producer pins went into `packages/services/service-automation/src/flow-slots-per-package.test.ts` as a new top-level `describe`, because that file is the engine's per-slot harness and a pin for a component with a shared harness goes there. Test-only. Read first, by risk: 1. `packages/runtime/src/domains/automation.ts`, the toggle arm's read-back filter (the `flowSlotPackage` capture at the admission block and the `rows` filter). 2. `packages/services/service-automation/src/flow-definitions.ts`, `getFlowRuntimeStates` (the `packageOf` spread). 3. `packages/spec/src/contracts/automation-service.ts`, the new `packageId` member. ## Tests - Door (`automation-addressed-route.test.ts`, the co-held toggle suite): the double now reads rows the engine's way, each carrying its slot's `packageId`, and composes a status that keeps a slot off apart from the switch. New red line: the switched slot is republished `obsolete` while the switch awaits its durable write; the door answers `200 { enabled: false }`. The three existing co-held cases now pass by read-back, not by echo. - Engine (`flow-slots-per-package.test.ts`, new `describe` "the status rows carry their slot's package"): a co-held name's two rows each carry their own package and own state; a one-holder name's row carries its package and a package-less flow's row has no `packageId` key; and the race measured on the real engine: with the activation store's write held open, P2's flow republished `obsolete` mid-switch, `toggleFlowSlot` resolves, two rows of the name exist, P2's own row reads `enabled: false, status: 'obsolete'`, and `executeSlot` refuses `FLOW_DISABLED`. The race the card describes can be reached as written. - Spec type pin: `FlowRuntimeState['packageId']` is `string | undefined`. - `automation-toggle-caller.test.ts` is unchanged: the no-read echo stays pinned there. <details><summary>Ablations (each restored: blob equals HEAD, git diff HEAD empty)</summary> - Producer: deleted the `...packageOf(this.flowSlotPackage(name)),` line (`scripts/ablation-replace.mjs`, mutation landed: anchor 1 to 0). `flow-slots-per-package.test.ts -t 'status rows carry'`: `Tests 3 failed | 92 skipped (95)`, all three new engine cases red. - Door: replaced the package filter with `true` (mutation landed: anchor 1 to 0). Runtime toggle files: `Tests 1 failed | 65 passed (66)`. The red is the obsolete-republish case, answering `{"name":"convert","enabled":true}`, which is the card's defect. A first attempt used replacement text that already occurred in the file; the tool refused it and restored before running anything, so that attempt measured nothing. </details> <details><summary>Suites (head 72f56b4)</summary> - `pnpm --filter @objectstack/service-automation test`: Test Files 299 passed (299), Tests 4442 passed (4442), exit 0. - `pnpm --filter @objectstack/runtime test`: Test Files 656 passed (656), Tests 12522 passed, 25 skipped (12547), exit 0. - `pnpm --filter @objectstack/spec test`: Test Files 913 passed (913), Tests 28893 passed, 1 todo (28894), exit 0. - `turbo run typecheck` for spec, service-automation and runtime: 44 tasks successful. The runtime test layer first failed TS2307 on `@objectstack/driver-turso` in three files this diff does not touch, because that devDependency was not built in this worktree. After building it: `check:test-typecheck: OK` for both packages. </details> ## Acceptance notes - The echo that remains: a service whose reading holds NO row of the switched flow. For the engine on the co-held path that happens only if the slot is withdrawn while the switch is in flight, which is another race than this card's. That arm was already the behaviour before this change and is pinned by other suites in the same file, whose doubles read no rows. Left as it is. - A bare toggle (no slot view) still reads the name's one row. Two rows on a bare door would need an engine with a name resolver but a door with no registry. Bare `toggleFlow` refuses a shared name otherwise, so that case is not reachable in the composed runtime. - `flowRuntimeStateOf` (`packages/types/src/flow-runtime-state.ts`, the MCP definition reader's switch) still answers `undefined` on two rows of one name. It could pick by `packageId` once its callers pass the item's package. Not changed here: it is outside this card's surface, and it fails closed ("unknown is answered as absent, never as enabled"). - Other row readers are untouched, because the field is optional: `packages/client` (`getRuntimeStatus` docblock lists the optional members and does not yet name `packageId`), `packages/cli` `serve.ts`, and the Console under `ui/`. A Console status badge for a co-held name could pick its row by `(packageId, name)`. No `ui/` change is in this PR. ## Verification Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/automation-addressed-route.test.ts -t 'republished'`. Expected: 1 passed. The obsolete-republish case answers `{ enabled: false }`. <details><summary>Local gates (derived from dispatch-gates --commands at 72f56b4)</summary> - 100 derived families run. `dispatch-gates --ran` with exit codes recorded: `100 derived famil(ies) accounted for — 98 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)`. - NOT MEASURED: `check:dual-build-cjs-loads`, reason: PREREQUISITE NOT MET, it reads every package's built output and 38 packages have no `dist/` in this worktree. `check:published-readme-exports`, reason: PREREQUISITE NOT MET, 32 packages' built type entries are missing. Both are left to CI. - Every other derived family exited 0, among them `check:api-surface`, `check:authorable-surface`, `check:docs`, `check:export-origins`, `check:engine-double-contract`, `check:nul-bytes`, `check:cross-package-test-inputs` and `check:test-source-alias`. - `overlap-check.mjs` before each push: `VERDICT clean exit 0` against origin/main and objectstack-ai#38618, which shares `engine.ts` and merges cleanly. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW)_ <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmQJUGAAa5rz9Yi2DvW --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…s own flows (objectstack-ai#38642) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_ Fixes objectstack-ai#38595 Clause-②: no Metadata-protocol: none ## 维护者速读 - 管理员把一个应用包以新的命名空间安装或复制之后,复制出来的流程调用的是复制包自己的子流程,按钮触发的也是复制包自己的流程;以前调用的是原包的流程,或者因为找不到流程而每次运行都失败。复制时如果调用方流程排在被调用流程前面,现在两个流程都会复制成功,不再被保存检查拒掉调用方;如果被调用的流程本身复制失败,调用它的流程也一并列为失败并撤回,不会留下指向不存在流程的调用。 - 属于"软件包安装与复制"这块能力,替用新命名空间安装应用包、或复制一份应用包来改的管理员解决"复制后流程跑不起来或串到原包"的问题。 - 只影响带新命名空间的安装和复制;如果改名规则出错,复制包里的某个流程调用会指向错误的名字,原包不受影响,可以直接撤回这次合并恢复原来的行为。 - 无 ## What changes `planNamespaceRename` (`packages/metadata-protocol/src/package-namespace-rename.ts`), the one rename engine behind the unmanaged install's `targetNamespace` and `duplicatePackage`, renamed a package flow under the prefix swap (`crm_child` to `crm2_child`) but rewrote no name that calls it. It now builds a flow rename map from the package's own `flow` items and rewrites a value that EQUALS a renamed flow name, whole, at: - the derived index's `flow` sites, `REFERENCE_SITES.byTarget.get('flow')`, read the same way the object sites are (by property, wherever it occurs). Dumped at runtime on this tree it holds `{fromType:'flow', property:'flowName'}` and `{fromType:'translation', property:'flows'}`, so a `subflow` step's `config.flowName` and a translation's `flows` keys follow; - the one hand-written site, commented as such in the code: a `target` whose sibling executor is `'flow'`. That is `type: 'flow'` on an action (`ActionSchema`, an object's `actions[]`, an inline action, an `action:group` member, an API endpoint) and `actionType: 'flow'` on an `action:button` / `action:icon` page block, where `type` is the component. The index cannot carry `target`, because on every other executor it names a URL, script, page, endpoint or form, and a property-wide site would rewrite those too and list them in the "Used by" answer. A flow the package does not hold keeps its name, a flow the prefix swap keeps keeps its name, and nothing is substring-rewritten. A value that is not a renamed flow name falls through to the rules every string already took, so nothing that read the same before reads differently now. Collisions work as they do for objects: a renamed flow name that meets a name the item already holds at that site (a translation keyed by both `crm_child` and `crm2_child`) refuses the item, and the refusal names the flow. The internal `atReference: boolean` of the walk became the site's rename map (object or flow), so both kinds share one walk and one collision rule. **This round (delta after PR objectstack-ai#38594 merged as d33183a).** `origin/main` was merged into this branch with a merge commit (3a7134a, no conflicts). With both changes on one tree, a parent-first `duplicatePackage` was refused by the publish gate (measurement below). So the `duplicatePackage` leg's `host.saveMetaItem` call in `protocol-package-commits.ts` now passes `copyPlanFlowNames` on a flow write, the unmanaged-install leg's way: the copy names (`rename.copyName`) of every flow row the same duplicate writes. On a non-flow write nothing is passed. The gate's rule itself is not touched; the names are additive (`pending.flows`), so they can let a call to a flow of the same copy through and refuse nothing. **Third round (L1 REWORK 7267334209, route per claim amendment 7267347516).** `duplicatePackage` is best-effort, so a planned flow can still land in `failed[]` after the gate passed its caller on the plan's word. The duplicate leg now closes its flow plan after the copy loop. Each copied flow whose `subflow` / `map` step calls a planned flow (its copy name) that was not written is taken back out of the copy, through the same `undoBatchRowWrite` the object settle uses. It is reported in `failed[]` with an error that names that callee. This repeats until nothing changes, so a caller's caller goes too. The loop reads a caller's address before and after its write for that undo, only when the caller calls a planned flow. The plan is now one list built before the loop (`planFlowSources`). The callee walk uses the spec's `FLOW_REGION_SLOTS_BY_TYPE`, the region table the publish gate walks. The install leg is not touched. ## Tests <details><summary>Engine pins, package-namespace-rename.test.ts (7 new cases)</summary> `flowName` follows; `other_flow`, an unprefixed `bare_child` and a superstring `crm_child_v2` keep their names; a flow action's `target` follows while `modal` / `script` / `api` targets equal to the same string do not; the object `actions[]`, API endpoint and page `actionType` spellings; translation `flows` keys; the collision refusal; and a copy that keeps the source namespace renames nothing. </details> <details><summary>Door pins, new package-namespace-rename-flow-refs-38595.test.ts (6 cases)</summary> The harness (`makeEngine`, `crmBody`) is copied from `package-unmanaged-install.test.ts`, which is not edited. Its automation service answers `listFlows`, so a gate that judges a step's called flow has a non-empty universe. - an unmanaged install with `targetNamespace: 'crm2'` installs, and the stored `crm2_parent` calls `crm2_child`; - the copied flow action reads `target: 'crm2_child'`, and the `modal` control keeps `target: 'crm_child'`; - with the source package installed under its own names beside the copy, the copy's `crm2_parent` calls `crm2_child`; - a call to `other_flow` keeps its name; - `duplicatePackage` into `crm2` gives the same result with the source installed, and the source still calls `crm_child`; - parity: the duplicate and the import into `crm2` store identical flow and action items. </details> <details><summary>Stacking measurement (this round), new describe in package-namespace-rename-flow-refs-38595.test.ts (2 cases)</summary> The source package is installed with its stored flow rows in the order `crm_parent` (a `subflow` step calling `crm_child`), then `crm_child`; the test asserts that order. It is then duplicated into `crm2`. The automation service holds `other_flow`, `crm_child`, `crm_parent`, never `crm2_child`. Measured at 2af21e1 (merge of `main` plus the test, before the fix), the gate refuses. `duplicated.failed` was, verbatim: ``` [{ type: 'flow', name: 'crm_parent', error: 'flow/crm2_parent failed author-time validation: 1 issue — flows[0].nodes[1].config.flowName [flow-subflow-unknown]' }] ``` and only `crm2_child` was copied (`Tests 2 failed | 6 passed (8)`). With the fix (300cf74) the case passes: `failed` is empty, both flows are stored and `crm2_parent` calls `crm2_child`. CONTROL, the gate is live in this harness: a third flow `crm_caller` calls `crm_ghost`, which the engine holds at the source install and no longer at the copy, and the package holds no such flow. The copy keeps the name `crm_ghost`, and with the fix the duplicate still refuses exactly `flow/crm_caller` with `flow-subflow-unknown` while both other flows are copied. So the plan names let through only the copy's own flows. </details> <details><summary>Withdrawal pins (third round), same describe (2 cases)</summary> - (a) L1's parent-first case. `crm_parent` calls `crm_child`, and `crm_child` calls `crm_ghost`, which the engine holds at the source install and drops before the duplicate. `failed` holds `flow/crm_child` and `flow/crm_parent`, and the parent's error names `'crm2_child'`. No flow of the copy is stored, no stored copied flow calls a flow the deployment does not hold, and the copy's object is still copied. - (b) A two-level chain, `crm_a` to `crm_b` to `crm_c`, with `crm_c` calling the dropped `crm_ghost`. All three end in `failed[]` (the errors of `a` and `b` name `'crm2_b'` and `'crm2_c'`). `crm2_solo`, outside the chain, is the only copied flow, and nothing copied calls a missing flow. - The success pins and the `crm_ghost` CONTROL pass unchanged: `Tests 10 passed (10)` for the card file at 712fda7. Ablations, each run after the fix commit 28e4856 with `scripts/ablation-replace.mjs`: - Cascade off: `if (withdrawn.length === 0) break;` became `if (withdrawn.length >= 0) break;` (blob `4ca8e112244c` to `6eec66471fb7`). Result: `Tests 2 failed | 8 passed (10)`. (a) fails with `expected [ 'flow/crm_child' ] to deeply equal [ 'flow/crm_child', 'flow/crm_parent' ]`, which is L1's measured state, and (b) fails with `expected [ 'flow/crm_c' ] …`. - Transitive step off: the line that marks a withdrawn caller as not written was deleted (blob `4ca8e112244c` to `378006812f35`). Result: `Tests 1 failed | 9 passed (10)`. Only (b) fails, with `expected [ 'flow/crm_b', 'flow/crm_c' ] …`. - Both times the tool restored the file: blob equal to HEAD, and `git diff HEAD` empty. </details> <details><summary>Ablation of the second round's line</summary> The fix was committed first (300cf74). `node scripts/ablation-replace.mjs` replaced the guard `...(singular === 'flow'` of the new spread with `...(false` (anchor 1 to 0, blob `d064b03b149a` to `f110fae517f4`). The card test file then failed both new cases (`Tests 2 failed | 6 passed (8)`): the parent-first case with the refusal above, the CONTROL because `crm2_parent` was refused beside `crm_caller`. The tool restored the file: blob equal to HEAD, `git diff HEAD` empty. </details> <details><summary>Package run at 712fda7 (third round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2` under the verify lock: `VERDICT command-exit 0`, `Test Files 374 passed | 9 skipped (383)`, `Tests 23690 passed | 45 skipped (23735)`. The 69 families `dispatch-gates --commands` derives for this round's four paths: 67 exit 0. `check:dual-build-cjs-loads` and `check:lean-entry-closure` exit 3 (PREREQUISITE NOT MET: they read every package's `dist`), so they are NOT MEASURED here and left to CI. `overlap-check`: clean. </details> <details><summary>Package run at 964a326 (second round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2` under the verify lock, after building the closure (`pnpm --filter '@objectstack/metadata-protocol^...' build`): `VERDICT command-exit 0`, `Test Files 374 passed | 9 skipped (383)`, `Tests 23688 passed | 45 skipped (23733)`. The card pins after the merge (`package-namespace-rename-flow-refs-38595.test.ts`, `package-namespace-rename.test.ts`, `package-unmanaged-install.test.ts`): `Test Files 3 passed (3)`, `Tests 152 passed (152)`. </details> <details><summary>Package run at 5ec669b (first round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && … exec vitest run --maxWorkers=2` under the verify lock: `VERDICT command-exit 0`, `Test Files 373 passed | 9 skipped (382)`, `Tests 23670 passed | 45 skipped (23715)`. The typecheck program lists the test files. </details> <details><summary>Ablation</summary> The fix commit came first. Then `scripts/ablation-replace.mjs` swapped the one line that fills the flow rename map for a no-op (anchor 1 to 0, blob `e90813508b99` to `114356add0b3`). With that in place, 9 of the 13 new cases failed (`Tests 9 failed | 26 passed (35)`): every rewrite pin on both test files. The four that stayed green were the three controls and the parity case, which stays equal when both doors are equally wrong. The tool then restored the file: the blob matched HEAD again and `git diff HEAD` was empty. </details> <details><summary>Under PR objectstack-ai#38594's gate (head 93f3643)</summary> In a throwaway tree at that head, with this branch's two commits cherry-picked, the closure was built and both test files passed (`Tests 42 passed`). With the same ablation there, the install pins fail with the gate's own 422: `INVALID_METADATA`, `flow-subflow-unknown` at `flows[0].nodes[1].config.flowName`, "calls flow 'crm_child' … Did you mean crm2_child". So the gate is live in this harness and the pins pass under it, without depending on its code. The tree was removed afterwards. </details> ## Acceptance notes - **The parent-first duplicate is fixed in this PR now.** The first round reported that with this branch and PR objectstack-ai#38594 both applied, a parent-first `duplicatePackage` fails `flow-subflow-unknown` and writes only the child. PR objectstack-ai#38594 merged without a copy-plan on its duplicate leg, so the seat routed the fix here (claim amendment 7266007014). It was re-measured on the merged tree (see Tests) and fixed on the duplicate leg's `saveMetaItem` call alone. - The `copyPlanFlowNames` doc comment in `protocol-door-requests.ts` said "`duplicatePackage` copies stored rows, which the gate's own read of the stored flows already holds". That stopped being true once the copy's calls name the copy's flows. Per claim amendment 7266793287, 48420e0 rewords that comment only: both copy doors state the field, the names the same copy writes under their written names. In the third round (712fda7), the comment and the changeset sentence say the gate is told the flows the copy PLANS to write. They also say that on the duplicate, a caller whose planned callee was not written is withdrawn with it. No logic changes; metadata-protocol typecheck exits 0, and the 48 families `dispatch-gates --commands` derives for that path ran with 46 at exit 0 and `check:dual-build-cjs-loads` / `check:lean-entry-closure` at exit 3 (PREREQUISITE NOT MET, left to CI). - Measured with the same engine probe, outside this card: the names of other non-object items (dashboard, page, report) are renamed by the prefix swap, but their references are not. That covers app navigation's `dashboardName` / `pageName` / `reportName` and a translation's `dashboards` / `pages` / `reports` keys. A dashboard header action with `actionType: 'flow'` keeps its `actionUrl`. These are reported to the seat as one family. They are not fixed here. - Outside the dispatched file surface, added by the PM's amendment: `scripts/engine-double-contract.pinned.json` gains 3 rows (15 lines) for the new test file's copied stub engine, produced by `node scripts/check-engine-double-contract.mjs --write`. No existing row changed, and `pnpm check:engine-double-contract` exits 0 at fb44b0f and again at 964a326. - Local gates at 964a326: the 77 families `dispatch-gates --commands` derives for this diff were run; 75 exit 0, and `check:dual-build-cjs-loads` and `check:lean-entry-closure` exit 3 (`PREREQUISITE NOT MET`: they read every package's built `dist`, which this worktree built only for the closure), so those two are NOT MEASURED here and are left to CI. `overlap-check`: clean against `origin/main`, objectstack-ai#38618 and objectstack-ai#38497. - Read, not changed (for the seat): whether `importUnmanagedPackage` has the same gap on partial failure. It does not, as read at 712fda7. Its prepare pass refuses the whole install before the base exists if any item fails to convert or rename (422 or the rename refusal). Its `copyPlanFlowNames` is built from `prepared`, which is exactly the items the write loop writes. Any `saveMetaItem` throw in that loop, and any object the batch settle refuses, goes through `rollBackUnmanagedImport`, which deletes the whole new base. So on success every planned flow is written, and on failure nothing remains. The one residue is a rollback that itself fails. It is not silent: `console.error`, plus an answer saying the base could NOT be fully removed and must be uninstalled. ## Verification Read first, by risk: 1. `protocol-package-commits.ts`, the `duplicatePackage` leg's close: the withdrawal block after the copy loop (the fixpoint, the undo and the error text), and `plannedCalleesOf` with `planFlowSources` above the loop. Check that a withdrawn caller is removed from `copied` and pushed to `failed[]` exactly once. 2. `package-namespace-rename.ts`, the `deepRewrite` object branch: the child-site expression `referenceSiteOf(k) ?? (site && k === 'name' ? site : flowTargetSite(v, k))` replaced the old boolean. Object sites must behave exactly as before. 3. `package-namespace-rename-flow-refs-38595.test.ts`: the parent-first duplicate and its CONTROL, the source-still-installed case and the duplicate parity. (`flowTargetSite` and `FLOW_EXECUTOR_KEYS` in `package-namespace-rename.ts`, the one hand-written site, were read in the first round's review.) Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/package-namespace-rename-flow-refs-38595.test.ts src/package-namespace-rename.test.ts` should report 2 files and 39 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmQJUGAAa5rz9Yi2DvW --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…d to change and held for its whole approval (closedStates, ADR-0162) (objectstack-ai#38810) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9HqHpbnZfMBnSP27W5MzeEY)_ Part of objectstack-ai#37768 Part of objectstack-ai#37766 Part of objectstack-ai#37767 Clause-②: yes (narrowing) Metadata-protocol: semantic Skills-docs: follow-up objectstack-ai#38425 **This PR supersedes objectstack-ai#38497** (the approvals trunk `claude/o5-data-approvals-trunk` → `main`). The trunk took its two `main` refreshes as squashes, which left its history without `main` and objectstack-ai#38497 in conflict with `main` again. This branch is the trunk with its history joined to `main`: it carries every commit on the trunk, and `main` up to `2fba83493b`. The Part-of lines and the two declarations above are objectstack-ai#38497's; Clause-② carries the narrowing arm of piece 5 (objectstack-ai#38746, `feat(approvals)!`), which landed on the trunk after objectstack-ai#38497's body was written. objectstack-ai#38497's description follows unchanged below, under "The trunk (from objectstack-ai#38497)". ## 维护者速读 - 改了什么:objectstack-ai#38497 的全部内容(单据关闭态锁定 ADR-0162 的 A/B/C 各片、objectstack-ai#37766 各片、审批 objectstack-ai#37767 各块,含第 5 块「审批全程锁单」),改由这个 PR 落到 main;objectstack-ai#38497 由席位关闭。 - 为什么换 PR:主干两次刷新都被 squash 合入,主干和 main 的历史断开,objectstack-ai#38497 又与 main 冲突;这条分支内容等于主干加最新 main,历史里带着 main,所以对 main 是干净的。 - 谁受影响:同 objectstack-ai#38497 下文说明;声明了 `closedStates` 的对象受影响,没声明的照旧。 - 要你做什么:待 battery、L1 与非实现方契约复审之后,由席位交棒。 ## How this branch is built - Trunk head `a5f33621e3` (objectstack-ai#38797, squashed; its tree is `85aea4d1c2`). - `77e94868d0` merges `8ff2442358`, the gated head objectstack-ai#38797 squashed: same tree `85aea4d1c2`, no content change; it puts `main` up to `fc198b2847` into the history. - `2f344f7b1d` merges `origin/main` at `2fba83493b` (7 commits after `fc198b2847`) through `scripts/pm/os-regen-merge.sh`: no conflict, and none of the 7 commits touches a file the trunk's own changes touch. ## Trunk refreshes with `main`, and their records - objectstack-ai#38791 (`main` at `59faf74c6f`): L1-b ACCEPT 7284982294, contract review PASS 7285519382, seat record 7285551596; DELIBERATE CORRECTION declaration 7284894883. - objectstack-ai#38797 (`main` at `fc198b2847`): L1-b ACCEPT 7289462740, contract review PASS 7289911344, seat record 7289942965; DELIBERATE CORRECTION declaration 7289249692. ## Measured on this head - `scripts/pm/dispatch-gates.mjs` against `main`: 147 derived, 147 run, 0 NOT-MEASURED, all exit 0. - Regeneration from this tree (`gen:schema`, `gen:docs`, `gen:liveness-counts`, then `check:generated` and `check-system-context-census.mjs`): exit 0, and the tree was unchanged after it. - Tests and typecheck green: objectql, metadata-protocol, platform-objects, plugin-approvals, core, service-automation, spec, runtime; cli tests green; dogfood 500 files / 4295 tests passed. - A trial merge of this head with `main` at `0fc9eab900` has no conflict. ## The trunk (from objectstack-ai#38497) > **Trunk moved (seat repo:objectstack#5, area o5-data).** This PR replaces objectstack-ai#38421, the same closed-state trunk handed back by seat 2 (clock-out brief 7250342397 on objectstack-ai#34478). The trunk branch is now `claude/o5-data-approvals-trunk`, cut from `claude/project-thread-yxheps` at `bfe2df88b` and written only by area `o5-data`. Since the hand-back it carries objectstack-ai#37766 slice C (PR objectstack-ai#38485, merged into this trunk as `07f0923c5c` with `--no-ff`). Still to land on this trunk before it leaves draft: objectstack-ai#37766 slices B and D, objectstack-ai#37767 pieces 3–5, objectstack-ai#37768 slice C (Release-order lines on those cards). The sections below are objectstack-ai#38421's, for slices A and B of objectstack-ai#37768 and piece 2 of objectstack-ai#37767; the slices added since are described in their own PRs. > **Since landed on this trunk** (all in this PR's diff): objectstack-ai#37766 slices B and D: objectstack-ai#38499, objectstack-ai#38546, objectstack-ai#38562, objectstack-ai#38563; objectstack-ai#37767 pieces 3–5: objectstack-ai#38540 (piece 3), objectstack-ai#38618 (piece 4), objectstack-ai#38746 (piece 5), with the ADR-0162 revision objectstack-ai#38601; objectstack-ai#37768 slice C: objectstack-ai#38516. Two refreshes with `main`: objectstack-ai#38791, objectstack-ai#38797. > (objectstack-ai#38497 as written) Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.closedStates`, and the engine's enforcement of it) > (objectstack-ai#38497 as written) Metadata-protocol: added > (objectstack-ai#38497 as written) Skills-docs: follow-up objectstack-ai#38425 ### 维护者速读 - 用户能看到什么变化:对象上写了「哪些状态算已关闭」后,单据一旦进入这些状态(比如发票已付款、已作废),它和它的明细行就不能再被普通用户改、删、挪动明细或加明细,系统返回 409「记录已锁定」;批量操作只要碰到一条已关闭的单据就整批不执行。系统自身的写(汇总重算、审批回写状态)照常落地。没写这个键的对象完全不变。 - 为什么做:单据关闭态锁定(ADR-0162)的第一、二部分:A 定下这个键和编写规则,B(本次新增)让平台真正按它锁单据,应用不用再手写锁定代码,也第一次能挡住「删一条明细」这种以前挡不住的改动。 - 出错会怎样:只影响写了这个新键的对象。最坏情况是该锁的没锁(回到今天的样子),或者某个平台内部写被误锁(已逐条列出并测试)。分支在拒绝文案(C 部分)和审批两张卡落地前不合并,所以不会单独发布。 - 要你做什么:无。有一条覆盖层的发现交座位判断是否要上决策卡(见 Acceptance notes「Overlay」)。 ### What changes #### Slice A — the key (ADR-0162 D1) Slice A of objectstack-ai#37768 (ADR-0162 D1, the key), on the card's trunk branch. Slices B (the engine's judgement, D2–D7, D10) and C (the refusal, D8) land on this same branch; it does not merge before the card's `Release-order` line is met, so the key is never published without its enforcement (ADR-0078, ADR-0162 D10). **Spec (`packages/spec`)** - `ObjectSchema.closedStates`: optional map from a field of the object to the list of that field's values that close a record, e.g. `{ status: ['paid', 'void'], approval_status: ['approved'] }`. The record is guarded against a `__proto__` key like `fields`. No default, so no parsed object grows a key. TSDoc and `.describe()` state the contract D1–D5 give. - `refuseDishonestClosedStates` (`src/data/closed-states.ts`, outside the barrel, the `stage-field-kinds.ts` precedent), called from the object's `superRefine`. One located `custom` issue each, at `['closedStates', FIELD]` or `['closedStates', FIELD, i]`: a key naming no field of the object; a field that is not a single-value `select` (another type, `radio` included, or `multiple: true`); a select with no inline `options` (a `picklist`-backed one); an empty list; a value that is not one of the field's options; a repeated value. Because the object document is judged whole, the same refusals cover removing or retyping a named field and removing a listed option: the next version leaves a declaration that names what the edit took away. - Studio object form row (Advanced section, JSON row beside `uiReadonlyWhen`). - Liveness row `object.closedStates`: **`planned`**, evidence `closed-states.ts#refuseDishonestClosedStates` (the refusals, live at parse) — the `enable.aiReadable` precedent. It turns `live`, with its runtime proof, in slice B: nothing on this branch reads the key at runtime yet. See Acceptance notes. - Regenerated: reference docs (`content/docs/references/data/object.mdx`, `packages/spec/docs/references/**`), the authorable-surface record (`data/Object:closedStates`), liveness state counts (object: planned 1 → 2). **Other packages** - `metadata-core` FLS scrub: `closedStates` classified as a map keyed by this object's fields (`recordOf(keep, true)`): an entry whose field is denied to the caller is left out of the served definition, an emptied map is deleted, and the values (option codes) are literals, never read as references. - `platform-objects`: the form row's label and help text authored in all ten translated metadata-forms locales (ar, de, es-ES, fr, ja-JP, ko, pt-BR, ru, zh-CN, zh-Hant), `en` regenerated by `check-i18n-bundles --write`; two derived leaf-count pins moved (+2 leaves in `advanced`, +1 translated label). - Three changesets: `@objectstack/spec` minor, `@objectstack/metadata-core` patch, `@objectstack/platform-objects` patch (the `uiReadonlyWhen` precedent). #### Slice B — the engine's judgement (ADR-0162 D2–D7, D10) **Engine (`packages/objectql`)** - `closed-state-lock.ts` (new): the one judgement every write door calls. A record is closed when its STORED row holds a listed value (D2); its unit is the record plus its direct `master_detail` lines, and a junction row is a line of both masters (D3). Every write a system context does not make is bound, and a write with no context is bound (D5). The refusal is `409 RECORD_LOCKED` with `reason` (`record_closed` · `master_closed` · `cascade_reaches_closed` · `cannot_judge`), `object`, `blockingObject`, `lockReason: 'closed_state'`; the message names no id and no state value. D8's sentences are slice C. - Wired doors: by-id update and delete (`engine-update.ts`, `engine-delete-and-aggregate.ts`, judged against the prior row the write already reads); predicate update and delete (refused whole before any row is written: one existence probe on the record, and for lines one semi-join probe where the store compiles the composed `ReadableIds` leaf, else the write's one read of its matched rows under `MAX_BULK_PER_ROW_HOOK_ROWS`); insert and insertMany (a line under a closed master; partial-mode insertMany is refused whole); the cascade set where it is planned (`engine-cascade-planning.ts`, D6); restore (`recycle-bin/restore.ts`, D7). - Placement (D10): after the middleware gates, before the before-hooks. A master the write NAMES goes through the caller's own read door first (`masterDetailHeadersCallerReads`), so an unreadable master answers as before and the lock never confirms that a record the caller cannot read exists; a STORED master is read by the engine. - `closed-state-values.ts` (new): `closedValuesOf`, split out so the registry does not import the write path. **Registry fold (seat review S1, `registry-closed-state-fold.ts`, new)** - An extension that redeclares a field the served `closedStates` names, and removes it, retypes it, makes it multi-value or narrows its options past a listed value (or leaves it with no inline options), has THAT redeclaration refused: the field stands as the fold had it, the fold logs it once naming the package, and the rest of the extension lands. One test per case. The four guarantee sentences of slice A stand as written. - A tenant overlay (the fold's base) may ADD closed values; the served declaration is the package's list with the overlay's added, and a field the package's list names keeps the package's definition where the overlay broke it. **Other** - Liveness `object.closedStates` → **`live`**, evidence the engine's reads and the dogfood suite; state counts regenerated. - Error-code ledger: `RECORD_LOCKED` registered under `@objectstack/objectql` (third emitter beside plugin-approvals and rest). This is a D8 ledger line pulled forward because B already throws the code; C keeps the sentences. - Changeset `@objectstack/objectql` minor; the spec changeset gains the ledger line. **After the seat's delta review (7249320091, PASS), head 8e95b36** - S2: every master check is asked of the store: one existence probe per chunk of ids with the closed predicate in its `where` and `fields: ['id']` (`anyClosedAmong`), never a read of state columns tested in process. The cascade set is judged the same way: one probe per chunk for its own state, and for its lines the predicate door's semi-join where `lineProbeServes` says the store runs it; only a store that cannot keeps the read of the lines' keys, then one probe of their masters (D4's stated fallback). Pinned per shape by `a cascade that reaches a line of a closed record is refused …` (probe store: no read of the master; no-probe store: one probe carrying the predicate, `fields: ['id']`). - N2: where the fold restores the package's field over an overlay that broke it, the overlay's added closed values for that field are served only where the package's field declares them. - CI on a0d9493: the system-context census row for `boundByClosedStates` (row 29g on `content/docs/permissions/system-context.mdx`, register regenerated). The local census had passed before the commit because it walks tracked files only. - Carried to slice C by the seat: tests for the assignment-rule and approval-mirror system writes, a plugin-security-level D10 test, and the API names in the developer `message`. #### Engine-derived writes (Done-when list) | Write | Context it runs in | What the lock does | Test | |---|---|---|---| | Referential clear of a deleted record's references (`set_null`) | system (reference-cleanup elevates; the clear also carries the referential-clear marker) | lands: exactly the cleared field | `a referential clear lands on a closed record` | | Recycle-bin relink on restore | caller, carrying `REFERENTIAL_CLEAR_OPTION` | lands (a bare reference restore, the clear's inverse) | `the recycle-bin relink puts a cleared reference back on a closed record, for the caller` | | Roll-up summary recompute | `{ ...caller, isSystem: true }` | lands | `the summary recompute writes the closed invoice in a system context, and lands` | | Cascade legs of a planned delete | caller | judged ONCE, at the planned set (D6); legs are not judged again | `a delete whose cascade reaches a closed record removes no row`, with and without transactions | | Change Owner (`changeRecordsOwner`) | **caller** | bound: each closed record (and line) is a `RECORD_LOCKED` failure, the open ones move | Change Owner block (4 tests) | | Banned-user hand-over (`transferUserAssignedWork`) | **caller** | bound: closed records stay with the user, counted as failures | `the hand-over of a user's work leaves the closed records …` | | Assignment rules | system | lands | not added here (system, unbound by D5) | | Approval status mirror | system, attributed | lands | measured below | The two writes that run in the CALLER's context (Change Owner and the hand-over) are bound, not exempted, and are reported to the seat as the card asks. #### Measured: the approval mirror and the request's finalisation They do **not** share one unit of work. `ApprovalService` finalises the request (`engine.update('sys_approval_request', …, { context: SYSTEM_CTX })`, `approval-service.ts` ~6305) and then calls `mirrorStatusField` (~6312), which issues its own `engine.update` with no transaction handle and swallows a failure into a warning (`approval-service.ts` ~4989–5015). The same order holds at recall, reject, return and the dead-run abandon (~7110, ~7726, ~7768, ~9810). A mirror that fails leaves a finalised request and an unmirrored record. The lock does not change this: the mirror is a system write and lands on a closed record. #### Hook-supplied master (N14) A master a `beforeInsert` / `beforeUpdate` hook supplies is **not** judged: the lock runs before the before-hooks (D10), so it judges the master the caller named. Pinned by `a master a beforeInsert hook supplies is not judged by the lock`. ### Why ADR-0162 (merged as `972114df`), Execution item 1, on the maintainer's rulings recorded on objectstack-ai#32004 (7073676422) and objectstack-ai#36253 (7200732942, 7201405662, 7205949718). Apps that must freeze a decided document hand-code it today and cannot guard the removal of a line at all. ### Tests **Slice B** - `packages/qa/dogfood/test/closed-state-lock.test.ts` (new, 69): on SQLite in two store shapes, each pinned, a store that runs the line probe and one that declares `readableIdsLeaf: false` (the MongoDB / OData shape). Every row of D4's table, for a record and for a line, single-row and many-row, on both shapes; the read shape of each (probe: one statement on the line table; no probe: the matched rows plus one read of their masters); the three cannot-judge cases (a master named by something that is not one id, a state read that fails, a many-row line write past the per-row ceiling with 10,001 seeded lines, with the probe-store control that lands); the closing write lands whole and the next is refused; no context refused; system writes, deletes and restores; the cascade removes no row with and without transactions; restore; engine-derived writes; a refused write runs no before-hook; an object that declares nothing reads nothing extra; Change Owner and the hand-over. - `packages/objectql/src/registry-closed-state-fold.test.ts` (new, 13): the four extension breaches each refused with the rest of the extension applied, two controls; overlay may add, may add to an object with none, may not shorten (key left out, fewer values), may not break a named field, relabel control, and an overlay's added value for a field the package's version of which is restored is not served (N2). Measured: with the two guards disabled, 7 of the first 12 fail. **Slice A** - `packages/spec/src/data/closed-states.test.ts` (new, 22 cases): the ADR example parses and keeps its value; absent stays absent; no tie to a `state_machine` rule either way; `create()` keeps it; each refusal above, one located issue each, with its message's subject; one issue per offending entry with a sound entry untouched; removing the field, retyping it, making it multi-value and removing a listed option each refused, with the control that removing an unlisted option lands; the save and publish door (`getMetadataTypeSchema('object')`) and the stack door refuse at the same path; a line object needs no declaration and may declare its own. - `metadata-core` `object-schema-fls-references.test.ts`: a denied field's entry dropped and the readable one kept; a map left empty deleted; CONTROL: a value spelled like the denied field is served as written. - Moved pins, each with a history line: `compose-stacks-merge-collection-refusal.test.ts` and `compose-stacks-collection-pipe-arm.test.ts` — `closedStates` is an object-level collection, so `composeStacks` `objectConflict: 'merge'` refuses two stacks that declare it differently (new `it.each` row), and it is the first collection key on the real shape behind a preprocess stage, which the landed reading carries and the in-only reading does not (the invariance case now pins exactly that); `protocol.meta-types-degenerate-derivation.test.ts` object 53 → 54 top-level properties; the two `platform-objects` echo-decision counts. <details><summary>Slice A local runs (head 5d8b45b)</summary> - `pnpm --filter @objectstack/spec test`: 913/915 files on the first run; the two red files were the composeStacks pins above, re-run green after the move (92/92). - `pnpm --filter @objectstack/metadata-core --filter @objectstack/platform-objects test`: 29/29 files, 1121 tests; 130/130 files, 2218 tests. - `pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.meta-types-degenerate-derivation.test.ts`: 18/18. - `typecheck` of spec, metadata-core, platform-objects: exit 0. - `pnpm --filter @objectstack/spec check:generated`: all artifacts up to date (after `--fix` rebuilt the dist; it wrote nothing). - `pnpm check:i18n`: OK, all bundles in sync. - `node scripts/pm/dispatch-gates.mjs --ran`: 122 derived, 120 run, every one exit 0; 2 NOT MEASURED (exit 3, prerequisite: other packages' builds) — `check:skill-examples` (client SDK dist) and `check:dual-build-cjs-loads` (a full build); CI runs both. - `node scripts/pm/overlap-check.mjs`: clean against `origin/main`, no open PR shares a file. - No full dogfood battery: no `!` in the title and no `(narrowing)` arm. </details> <details><summary>Slice B local runs</summary> On 8e95b36: objectql full suite 644/644 files, 14559/14559 tests; dogfood `closed-state-lock.test.ts` 69/69 on a rebuilt dist; fold 13/13; typecheck objectql and dogfood, `check:facade-delegation-only`, `check:system-context-census` green. Head 1f399d9. - `pnpm --filter @objectstack/objectql exec vitest run`: 643/644 files, 14557/14558 tests on the first run; the red file was `federated-injected-column-readers.test.ts`, which asks every engine use of `isFederatedObject()` for a disposition: the line probe's federated-master decline got its row (`exempt`, reads no row) and the file re-ran green (5/5). - `pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.ts` against a rebuilt objectql dist: 67/67. - `pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts`: 12/12; with the two fold guards disabled, 7 of 12 fail. - `typecheck` of objectql (with `check:test-typecheck`) and dogfood: exit 0. - `node scripts/pm/dispatch-gates.mjs --ran`: 101 derived, 101 run, every one recorded `exit 0`. First run: 94 green, 7 red, each re-run after its fix: five spec dist-reading gates and `check:generated` answered exit 3 / 1 on a spec dist older than the ledger edit (green after `pnpm --filter @objectstack/spec build`); `check:facade-delegation-only` was red because `engine.ts` grew 7 lines past its ceiling (the new host members now share existing lines, 6856 ≤ 6857). - `pnpm check:system-context-census`: OK (the lock reads `isSystem` through `boundByClosedStates`, inside the census). - `node scripts/pm/overlap-check.mjs`: clean against `origin/main`, no open PR shares a file. - No full dogfood battery: no `!` in the title and no `(narrowing)` arm. </details> Slice A CI on 5d8b45b: 65 checks passed, 11 skipped, none failed. ### Acceptance notes - **Overlay (card Done-when, for the seat).** Verified and pinned: an overlay may ADD `closedStates`, and before this branch it already could (an overlay body is a full object document, and the fold serves it as the base), so a subscriber's admin can freeze records of a packaged object in states the package did not close. Before the guard an overlay could also SHORTEN the package's list (leave the key out or list fewer values), which unlocked what the package locks; it no longer can. Whether "may add" stays is a product question: if it changes what a subscriber may do to a packaged document, it goes back to the seat as a decision card, as the card says. The pin is `may ADD: an overlay that declares closed values of its own is served with them`. - **The fold "refuses" by keeping the field, not by failing registration.** An extension is a separate package that may load in any order; failing its whole registration over one field would take its other objects and fields down with it. The redeclaration of the named field is dropped, the fold logs it once with the package id, and the rest applies. - **D10 gate placement** is proven in the engine by order (the lock runs inside the write after the middleware chain and before the before-hooks, pinned by `a refused write runs no before-phase hook`); no plugin-security-level test was added for "a caller denied the object gets the same answer on a closed record". - **Liveness (slice A: `planned`; slice B: `live`)** (confirmed by the seat, claim revision 7248339226). The claim's file surface names "the liveness ledger row with its runtime proof (ADR-0054)". On this slice there is no runtime reader to prove: the engine's judgement is slice B. A `live` row now would cite a consumer that does not exist. Slice A set the row `planned`; slice B flips it to `live` with the engine reads and the dogfood suite as evidence. - **Narrow readings of D1, decided here (small, listed for the seat):** `radio` is refused (D1 says `select`); a `picklist`-backed select is refused because its options are not on the object and this is the one door every save passes (the `stageField` precedent); an empty map `closedStates: {}` is accepted and closes nothing (D1 refuses an empty list, not an empty map). "Stored" needs no check of its own: a computed value is a `formula` field, never a `select`. - **Publish door.** The removal and retype refusals ride the object's whole-document parse, which the save and publish door runs (pinned at `getMetadataTypeSchema('object')`). A field removed through a tool that rewrites the object document reaches the same parse. - **Not in this slice (the card's other Done-when lines):** the overlay question moved to slice B (claim revision 7248339226) and is answered above. The `skills/**` follow-up is objectstack-ai#38425; the docs card (item 5) and an eval that exercises a declaration are owed by the card, named here as the card asks. - The Metadata-protocol line was `added` on objectstack-ai#38497, the card's own value for the key (the seat's claim revision 7248339226). This PR declares `semantic`: it also carries objectstack-ai#38746, whose changeset `.changeset/37767-hold.md` declares `Metadata-protocol: semantic` (a record that declares `closedStates` is now held for its whole approval, with no change to what an author writes), and AGENTS.md takes the strongest of several kinds, `narrowed` over `semantic` over `added`. - Branch is the trunk `claude/o5-data-approvals-trunk` (cut from seat 2's `claude/project-thread-yxheps`), not `claude/issue-37768-*`. ### Verification Two-minute check: `pnpm --filter @objectstack/spec exec vitest run src/data/closed-states.test.ts` — expect 22 passed; `pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts` — expect 13 passed; after `pnpm --filter @objectstack/objectql build`, `pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.ts` — expect 69 passed. ### 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. - [x] 3. No formatter ran; `pnpm lint` passes (CI). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request (the card's trunk branch). - [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. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmPpwJymVUdp5AnRPBq <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Requested by Jianguo · project thread
Part of #37767
Supersedes #38603: both of its halves are now in this PR. The engine half was built here; the plugin core was rebuilt in #38634, reviewed there in four rounds, and squash-merged into this branch (
875b62d0c2). The card stays open: piece 5 and the ADR reword (#38601) follow.维护者速读
approval.flow_not_continued,管理员可以在通知偏好里关掉。引擎这边用户无感:流程运行记录里每一步会记下它启动了哪些子流程(最多 200 个,超出会标明"没记全"),运行历史超过 64 KB 时先丢这些清单、不再丢步骤;读运行记录时可以分清"记录不存在"和"存储暂时读不到"。claude/o5-data-approvals-trunk,不进main,可以整体撤回。Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none —
skills/names none ofExecutionStepLog,childRunIds,childRunIdsTruncated,runStartedFor,reconcileMarkedApprovals,approvalFlowNotContinued,flow_not_continuedorunjudged_since(git grep at875b62d0c2: 0 hits each); the step log is a runtime record, and the reconciler and its notice are platform behaviour no skill teaches an author to writeWhat changes
Piece 4 of #37767 (ADR-0162 item 8), in two halves. The maintainer's ruling 7257604888 (correction 7257614338) split it: the engine half was built and reviewed here first, and the plugin core was rebuilt in #38634, stacked on this branch, and merged into it once reviewed. The tree at this head is the union of the two reviewed halves and nothing else: its tree equals #38634's reviewed head
b048058186, andee8203b011..875b62d0c2is #38634's net diff byte for byte (record 7272037523).Engine half (14 files; reviewed at
ee8203b011)ExecutionStepLogSchema.childRunIds(packages/spec), optionalstring[]: the child runs a step started, at most 200, the first ones started.ExecutionStepLogSchema.childRunIdsTruncated, optionaltrue(ruling 7258590209): the step started more child runs thanchildRunIdsnames, either more than 200 or because the history row shed its links. The reference page and theauthorable-surfaceshard are regenerated with both keys.NodeExecutionResult.childRunIdsis copied onto the step's log entry, bounded there for every executor (dag-traversal.ts#stepChildRunsOf,MAX_STEP_CHILD_RUN_IDSinengine.ts);StepLogEntrydeclares both keys. Asubflowstep names the one run it started on every exit; amapstep names the item runs that execution of the step started.suspended-run-store.ts#serializeStepsBounded). A terminal step log over the row's 64 KB is stored without every step'schildRunIds, each step that named child runs markedchildRunIdsTruncated: true; only a log still over the cap without them is halved from its head, as before. The marks' own bytes (28 per marked step) are stated in the changeset.AutomationEngine.runStartedFor(context): the run the lastexecutecall started for that context object, named only once the run is past the start-condition gate and the re-entry guard, or where it fails before its first node and is recorded as failed.getRun(runId, { strict: true }): a store failure is rethrown after the warning instead of read asnull. Without the option the read degrades tonullas before. The plugin half's reconciler is its first caller (two call sites inapproval-service.ts).Plugin half (8 files; reviewed at
b048058186in #38634)Only for an approval the check stamped when it opened (one with a step that can act on an object that declares
closedStates).ApprovalServicereads the approval's run tree (subflowandmapchildren at any depth, throughgetRunwith the strict read) and keeps what it read on the request's snapshot (__runsRead:ended,open,between,stood). A run is kept as ended only once it and every child its steps name were read to an end.reconcileMarkedApprovals, run fromapprovals-plugin.tson the sweep clock,escalationScanIntervalMs, default five minutes) finishes what a door could not tell. Within one hour of the mark (RECONCILER_AGE_BOUND_MS) it writes nothing. Past it, a run is placed only where two judgements in a row read the same stopped state for it (S14 of fix(approvals): the reconciler keeps a run as ended only with every child read, and reaches a decision in a child run (ADR-0162 item 8) #38634): abandoned with the submitter told where a later step can follow, the outcome written with the administrators' notice at the last step. A store that does not answer is cannot tell at any age.subflowormapon a child that ended or has no row (including an item run of amapover records); the latest request's own run at its own step; a cut step log (a step markedchildRunIdsTruncated, or a halved ornullrow told from the run's summary); a run with no row that no read run speaks for; a tree of more runs than the judgements can read (at most 200 kept, at most 200 judgements read on).approval.flow_not_continuedjoinsPLATFORM_NOTIFICATION_TOPICS(service-messaging);approvalFlowNotContinuedTitleandapprovalFlowNotContinuedBodyin all 11 locale packs. It goes out only where the outcome's write landed.stepLogCutdocblock state it.content/docs/automation/approvals.mdxand.changeset/37767-reconciler.mddescribe all of the above; the tenant-audit shard moves by one elevated update ofsys_approval_request(14 to 15,keepRunsRead).Reviews
ee8203b011b048058186875b62d0c2The per-round review-item tables are in #38634's body (plugin) and in this PR's history of this body (engine: M5, S10, N11 to N13 of 7258563513).
Follow-ups, not in this PR
childRunIdsinexecution.zod.tsthat says a reader "can reach every run of its tree from the step log alone", which the plugin changeset now contradicts. The published description under it is right. Also N23 and thestopOfnote.Tests
step-child-runs.test.ts(10 cases, among them amapof 1,600 items stored and read back after a restart) and two strict-read cases inengine-residual-log-cause.test.ts; the full@objectstack/service-automationsuite at57d21b78b7passed 4,451 tests.approval-reconciler-37767.integration.test.ts, the cases named in fix(approvals): the reconciler keeps a run as ended only with every child read, and reaches a decision in a child run (ADR-0162 item 8) #38634's body, on the real engine where a shape allows and over run-store doubles otherwise;@objectstack/plugin-approvalspassed 2,216 tests atc885ffce70.b048058186, whose check-runs concluded 43 success, 15 skipped, 0 failed.Acceptance notes
scripts/engine-double-contract.pinned.jsongains one row (the history-row double instep-child-runs.test.tsupdates by id), written bynode scripts/check-engine-double-contract.mjs --write; admitted in seat record 7266411280.json.lengthinserializeStepsBoundedcounts UTF-16 units, not bytes, as before this PR.MAX_STEP_CHILD_RUN_IDS,MAX_RUNS_READ_PER_APPROVAL,HISTORY_STEPS_KEPTandRECONCILER_AGE_BOUND_MSare exported from their modules, not from any package barrel.Human Minimum
packages/specholds no runtime logic (two optional fields on the step log's schema).pnpm lintis CI's.claude/o5-data-approvals-trunk, per the trunk rule; the plugin PR was stacked on this branch by the maintainer's split).packages/spec: the generated reference page andauthorable-surfaceshard are regenerated outputs.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Body rewritten for the merged tree by
repo:objectstack#2 · os-warren · session_01JQwxbZFEo6URsCoWYcL8ub(N34 of record 7272037523).🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbZFEo6URsCoWYcL8ub