Repository navigation
feat(lint): an approval's closed-state gap is refused at every authoring door, through the first request's one judge (ADR-0162 item 7, slice N45) - #38562
Conversation
…door, through the first request's one judge The judge of ADR-0162 D5's opening conditions moves from the approvals plugin to @objectstack/metadata-core (approval-opening.ts), with an awaiting driver for the first request and a synchronous one over a stack in hand. The plugin re-exports it; its verdict is unchanged. A new reference-integrity member, validateApprovalClosedStates (approval-closed-state-gap, error), asks the same judge on each flow of a stack, so os validate, build and lint refuse the gap, and the runtime publish door refuses it (INVALID_METADATA) on a flow write and, with the written package's live flows as subjects, on an object write. A flow the stack does not hold, a node type the spec does not ship, the host's job service and an object without closedStates are not refused there; the first request still judges them. Sentences in 11 locales. ADR-0162 gains one dated note under D5 for the maintainer's hand. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
…into claude/project-thread-fkdrk9
📓 Docs Drift CheckThis PR changes 3 package(s): 22 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 13 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 ff63329bef3f172553255c62d2c69cd386d41ba1 && git checkout ff63329bef3f172553255c62d2c69cd386d41ba1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 97f9f1f236d67647b8521f0bdd500d430afbe063 f6110c77780cd4cb3de7ea977e23340010a0a942 && git checkout -B drift-repro 97f9f1f236d67647b8521f0bdd500d430afbe063 && git merge --no-ff f6110c77780cd4cb3de7ea977e23340010a0a942
node scripts/docs-audit/affected-docs.mjs --json 97f9f1f236d67647b8521f0bdd500d430afbe063
|
…d the two gap catalogs equal The note now splits what the maintainer ruled from what the analysis carried and what the seat proposes, quotes the option's line in full and reads each of the four passages it touches. The rule's header, its changeset and the door test's batch case now say what the door does in a package publish: a redrafted flow leaves the object write's subjects and is judged at its own write. A gap that shows only across two flows is refused by the CLI and at the first request, not at a single flow write. A plugin-approvals test holds the authoring rule's sentences equal to the first request's, gap kind by gap kind, in all 11 locales. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
…into claude/project-thread-fkdrk9
…-state gap is refused at authoring A subsection after the refused opening: os validate, build and lint fail with approval-closed-state-gap, and Studio, REST /meta and MCP refuse the save or publish with INVALID_METADATA, in the same words as the opening. It names what is left to the first request: a flow not in view, a node type a plugin adds, and the host's job service. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5nzgcVrZ8Neqqd1AFi Contract-review-claim: session_01FEkQ5nzgcVrZ8Neqqd1AFi · head 2a8d0a7 · 2026-11-29T11:02Z The card thread starts an isolated contract-review sub-agent at |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5kjJ6Qm1z2mRox4ZbB 席位核对 — ACCEPT · L1-b · area o5-data · Head-sha
|
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5nzgcVrZ8Neqqd1AFi Contract reviewServed-tier: ① Derived judgmentsGate verdicts, read off the check-runs on this head: 73 runs, 62 success, 10 skipped, 1 cancelled, 0 failure. The cancelled run is PR-body guards; a later run of the same name succeeded, so its verdict is success. The successes include Lint & Repo Gates, TypeScript Type Check, Test Core (the aggregate and its 12 shards), Build Core, Check Changeset, Governed Surface Queue Guard, Spec property liveness, Build Docs and Dogfood Regression Gate. What the diff changes in what is accepted and what is published:
② Semver levelThree patch changesets, one per package whose source moved: lint ( One condition holds ③ Boundary flagsNo
The ruling record's carried lines, which bind the build unless the review or the maintainer's approval changes them:
The three findings of the review of closed PR #38527 that the ruling record disposes: the protocol member is not added (confirmed, no protocol file in the diff); the batch reading is confirmed by the two package-publish integration tests; the refusal leaves under a code the door already gives (confirmed). Open questions on the card belong to other PRs and are not answered here: two in 7251445681 (PR #38485) and one in 7253794078 (PR #38546). SQL push-down: the diff adds no query, no id materialisation and no in-app join. The rule reads a stack in memory, and the runtime door reads the snapshots it already gathers. Security: no changed hunk teaches permission, sharing, credential, token or authentication behaviour. The hunks add an authoring-time configuration check and its sentences. For the seat, none of it a finding on a scope file:
④ Design judgmentThe ADR note and the status-line sentence (the hit).
S1 (should-fix) — the rule reads a record input's object as the object of the run's record, and the first request does not.
A run's object is a fact of how it was started, not of its variables:
No door reads a variable's Two consequences, traced by reading:
Grade: should-fix, not must-fix. No shipped flow declares a record start input, no shipped object declares The fix is the seat's choice, and either form moves the head:
In both, the note lists the flow that declares no object among what a door does not judge. The implementing files.
Nits. None affects correctness or the contract. Nit A can ride the S1 fix head; the others are follow-ups or accepted deviations.
No must-fix. One should-fix, S1, is open on this head. Its fix earns a delta review, and the delta record closes it by id. This record was rendered by an isolated sub-agent that the card thread (session_01FEkQ5nzgcVrZ8Neqqd1AFi) started for this review. It drafted neither this diff nor the ADR note, and it was fed only the brief's inputs: card #37766 with every comment, this PR's body, file list and net diff against Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5nzgcVrZ8Neqqd1AFi The brief the isolated contract-review sub-agent was handed for record 7255121575, verbatim, for the seat to read before it adopts the record: BriefContract review brief — PR #38562 @
|
…equest reads the run's The first request judges on the object its root run was started on, and no door sets that from a variable. The rule now reads the start node's object where a flow declares one, and a record input's object only where it declares none; a record input beside a start object is no longer read as a root. A flow that declares neither is left to the first request, and the ADR-0162 note, the rule's header and hint, and the approvals guide say so. allNodes is no longer exported from metadata-core. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract-review-claim: session_01QsR2jSyQBDMyRnrrWKy7WS · head f6110c7 · 2026-11-29T12:15Z Delta review at |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Contract reviewServed-tier: Delta review, 2026-11-29T12:17Z. Record 7255121575 reviewed ① Derived judgmentsGate verdicts, read off the check-runs on this head: 73 runs, 63 success, 10 skipped, 0 failure, 0 pending. Every skipped name is in the base branch's roster ( What the delta changes in what is accepted and what is published, against
② Semver levelThe three changesets keep their level (patch) and their declaration lines, and the PR body's two lines agree with them. The metadata-core changeset no longer lists ③ Boundary flags
④ Design judgmentS1: closed. The fix is the first of the two forms 7255121575 offered, with the disclosure of the second for the fallback.
Nit A: closed ( What the delta leaves, none of it graded above a nit:
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS 维护者速读
席位意见:建议合并。注记后半不是您的原话,是席位的提议,请随合并一并接受或划掉;其中两处和您当时看到的分析不同:插件自带的节点类型在线上发布入口也不算「会暂停」,只留给首次发起时拒绝;流程没有声明起始对象时,按它的记录型输入来判断,结论可能和首次发起时不一致。 席位核对 — ACCEPT · L1 · seat repo:objectstack#1, review thread R1 · Head-sha
|
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS Tier H approval request · 2026-11-29T12:21Z This pull request carries one dated note on ADR-0162 ( |
…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 Leehom · project thread
Part of #37766
Clause-②: yes (widening)
Metadata-protocol: none
Ruling-ref: 7253749311 (option D, 「D 统一校验,各入口都拒绝」)
维护者速读
os validate/os build/os lint时报错;设计器、REST/meta和 MCP 在正式保存、草稿转发布、恢复和整包发布时(草稿保存不拦)以INVALID_METADATA(422,入口已有的错误码)拒绝,并逐条说明缺什么(11 种语言)。validateApprovalClosedStates,放在共享的编写期规则表里),只有一份判定(移到@objectstack/metadata-core),开审批时的检查调用的是同一份代码,所以作者看到的和开审批时看到的是同一个结论;两份句子目录由测试逐条保持一致。What changes
One judge, moved.
packages/metadata-core/src/approval-opening.ts(new) holds the judge slice B put in the approvals plugin, unchanged in verdict, with two drivers over one walk (approvalFlowWalk):judgeApprovalOpeningawaits each flow it reads (the first request), andjudgeApprovalOpeningSyncjudges a stack in hand (the rule; a read that answers a promise counts as unreadable). The plugin'sapproval-opening-check.tsre-exports it under the names it exported before. metadata-core depends on spec only, asflow-cycle.ts("the ONE judge") does; plugin-approvals and lint already depend on metadata-core, so no dependency edge is added.One rule.
packages/lint/src/validate-approval-closed-states.ts(new), findingapproval-closed-state-gapat error, a member of the reference-integrity suite withruntimeTypes: ['flow', 'object']andsubjects: ['flows'], the shapevalidateReadonlyFlowWriteshas. Each flow of the stack is judged as an approval's root on the object its run can be started on, read off the definition as the first request reads it off the run: thestartnode'sobjectNamewhere the flow declares one, and only where it declares none, each record start input's object ([Decision] flows and records: may a flow start input declare a record reference (A), and does a non-system create stop choosing the new record's id (C)? #29425); its callees are read from the same stack; a gap reached from several roots is reported once. Its developer sentence is the first request'sensentence for the gap, and its user sentence (validate-approval-closed-states.user-text.ts) is the first request's catalog sentence in all 11 platform locales.ADR-0162: one dated note under D5 and an Amended pointer on the status line, prepared for the maintainer's hand and worded by an at-tier pen (
CONTRACT_REVIEW_TIER). It quotes the ruling and the option's line verbatim, reads line 242 ("reported … early notice"), Execution item 7, the Points bullet at 432 ("is not made at publish") and the Alternatives entry on publish with the ruling, leaves each as written, and marks apart what the ruling record carried from the analysis and what the seat proposes.The approvals guide (
content/docs/automation/approvals.mdx, on o5-data's ask after the guide landed on the trunk at97f9f1f23): a subsection after the refused opening, "Refused where the approval is authored", naming the three commands, the publish door, what is left to the first request.Proposals for the points the ruling left open
validateApprovalClosedStates, findingapproval-closed-state-gap, refused at the door asINVALID_METADATA(422), the code every reference-integrity refusal already leaves under.@objectstack/metadata-core, besideflow-cycle.ts. Not in lint (plugin-approvals has lint as a devDependency only) and no new edge.unreadable_flowdropped; lint: a second batch of publish-time checks for metadata that saves and does not work — the ones only the hosted build check makes today #35143's gate owns a call to a flow the deployment does not hold); a node type the spec does not ship, which counts as one that does not pause (onlyFLOW_PAUSE_CAPABLE_NODE_TYPESare judged; the first request reads the engine's descriptors); the host'sjobservice (no_job_serviceis never raised).subjects: ['flows'], the runtime gate's subject pass), and the differential charges the write only with what it adds, so a gap the stored universe already holds is not charged to an unrelated object write.e5760397c).Dispositions from the ruling record
addAuthoringGateis not added).publishPackageDraftswith the closing object and the repaired flow as drafts of one package passes; the closing object alone is refused. The door's pending declarations already carry the batch; no protocol change.INVALID_METADATA(422), which the door already lists. The ledger row built for the old shape is not pushed.Readings
flows[0]). A gap that shows only across the written flow and a flow it calls, or one that calls it, is refused by the CLI over the whole stack and at the first request, not at that write.objectWriteFlowSubjects) and is judged as its draft at its own write. So declaringclosedStatesand repairing the flow in one publish passes, and declaring it without the repair is refused.startobject, no record input), started by an action or by name, is judged with no object for the run's record at authoring and on the run's record at the first request. A record input beside a declared start object is not read as the run's object (contract review S1, fixed atf6110c777).closedStatesreads nothing, at authoring and at the first request alike. No shipped object declares it, so the rule finds nothing over the shipped corpus.Metadata-protocol: none: the rule reads onlyclosedStates, which the trunk adds and no released version accepts, so nothing publishable today is refused. The ruling record's release rule: the release that first publishes the key carries this refusal.Face and tier
node scripts/pm/dispatch-gates.mjs --tierover the diff:docs/adr/**⇒ contract tier (CONTRACT_REVIEW_TIER), no one-line exit; the ADR note is Tier H and lands by the maintainer's hand.Clause-②: yes (widening): metadata-core and lint gain exports.packages/lint/**sits inside #35143's claim (seat 6);node scripts/pm/overlap-check.mjs --base=origin/claude/o5-data-approvals-trunkatc0021e910: clean against the trunk and the three open PRs that share a file (#38550, #38497, #38241).Verification
packages/metadata-core/src/approval-opening.test.ts(3): the two drivers agree; a promise in the sync driver is unreadable; the walk asks each callee once, with its caller.packages/lint/src/validate-approval-closed-states.test.ts(14): each field condition, the pause, another field, a subflow judged through its caller, a record start input, one report for many roots, a clean approval; what is not refused (an unheld callee, a plugin node type, the host, no declaration, an object not in the stack, another closing field); the user sentence inenandzh-Hans.packages/lint/src/runtime-gate.approval-closed-states.test.ts(8): throughrunRuntimeAuthoringRules, flow writes refused and let through, object writes refused and not charged for a stored gap, and a package publish's two halves (the object write without the redrafted flow, the flow at its own write).packages/plugins/plugin-approvals/src/approval-closed-states-sentences.test.ts(11): the rule's sentence equals the first request's for each of the 9 gap kinds, in each locale. Reverse-verified: one changed word in the lint catalog turns its locale red.packages/plugins/plugin-approvals/src/approval-closed-states-37766.integration.test.ts(6, real kernel): an active flow save refused (INVALID_METADATA, 422), a clean one saved, a draft saved and its promotion refused, a closing object save refused, the package publish passing with the repaired flow and refused without it.97f9f1f23(the guide and Approval status mirror: a write that does not land, a run that ends between two steps, and a decision whose run cannot resume must not leave a document closed on an unfinished approval (ADR-0162 item 8) #37767 piece 3) merged in at2a8d0a7d6; the approvals opening, closed-state and outcome-when-over files re-run green (105 tests).check:doc-anchors,check:doc-authoring,check:docs-transcript-drift: OK.tsc --noEmiton the three packages, eslint on the changed files,check:doc-anchors,check:test-source-alias,check:error-status-conformance,check-changeset-no-major,check-adr-0087-registration: OK.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi