Skip to content

Commit 20f47c9

Browse files
docs(data-modeling): closed states, the closedStates key and every authoring note (ADR-0162) (#38993)
Fixes #37772 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:应用作者在文档站的「数据建模」里多了一页「已关闭状态」,审批文档里两处「审批结束后记录解锁」的地方加上了指向它的说明;运行时行为不变。 - 为什么做:这是「单据关闭后不可再改」这项新能力的文档部分,替声明这个能力的应用作者把规则和最容易踩的坑写清楚。 - 出错会怎样:只影响文档读者,若某句写错,作者可能按错误说法配置;本改动只是文字,可直接撤回。 - 要你做什么:无。 ## What changes - **New page `content/docs/data-modeling/closed-states.mdx`**, listed in the section's navigation (`meta.json`, after Validation Rules) and on the section landing page. It documents the `closedStates` key: its shape, what a field must be, the unit (the record and its direct `master_detail` lines), what is refused and for whom, the `409 RECORD_LOCKED` refusal, and the way out. The showcase's paid invoice (`examples/app-showcase/src/data/objects/invoice.object.ts`, `closedStates: { status: ['paid'] }`) is the worked example. - **Every authoring note of ADR-0162 "What an author has to know"**, each under its own heading or paragraph. The three the maintainer's ruling names have their own headings: "What an action button does on a closed document", "What the lock read tells a reader who may not see the state field", and "A new approval of a closed document, and what an abandoned approval leaves". - **Registered handler named beside the script body (review note N15).** Where the page says what runs elevated, it names the inline `body` and the handler registered with `registerAction` together, both running through the same elevated context. `content/docs/ui/actions.mdx` (section "Authorization inside an action") already names both. No other closed-state passage under `content/docs/**` says that a script body runs elevated, so no other file changes for N15. - **`content/docs/automation/approvals.mdx`: both "the record unlocks" passages now point at closed states.** The finalization passage says that on a declaring object the record is held until the approval is over and is closed where the outcome is a closed value. The send-back passage says that a record closed through another field stays closed in the revise window. The item-7 section (`#closed-states`) is linked and not restated. - `scripts/docs-audit/handwritten-docs.json`: +1 row, regenerated with `check-audit-scope.mjs --write`, because `check:docs-audit-scope` refuses a hand-written page that the list does not name. Every statement is about behaviour that has shipped. Each note was checked against code or a test on `main` (see Acceptance notes). ## Tests Docs-only. The page's two TypeScript examples carry the `os:check` marker, and `check:skill-examples` type-checks them against the built spec. I also parsed them at runtime against the built `@objectstack/spec`: <details><summary>Runtime parse of the page's examples (spec dist at this head)</summary> ``` invoice closedStates: {"status":["paid"]} stack ok, objects: 2 actions: 1 reverse refused: (ZodError, closedStates value 'closed' is not an option) ``` The invoice, its `master_detail` line and the reopen action go through `defineStack`. As a reverse check, the same invoice declaring the non-option value `closed` is refused. </details> ## Acceptance notes - **Evidence per note** (code or test on `main` at b53e70f): - publishing closes existing records at once: `packages/objectql/src/closed-state-lock.ts`, header D2 (closed is read off the stored row; nothing is stored); - automation that acts as the caller is refused, the steps after an approval decision included: `closed-state-lock.ts#boundByClosedStates`, and the approvals guide's `#hold` and "When the outcome lands on the record" (item 7/8, already on main); - no context is bound: dogfood `closed-state-lock.test.ts`, "a write with no principal (no context at all) is refused"; - action button works, its body and its registered handler: `packages/runtime/src/action-execution.ts#buildActionExecutionContext` ("serves every handler an action door dispatches, a host code handler included"); a declarative `operation: 'update'` writes as the caller (spec liveness `action.json` `operation`, live); - the way out is an action or a system flow: the same, and `closed-state-lock.test.ts` "a system context writes and deletes a closed record and its lines"; - keeps its owner: `closed-state-lock.test.ts`, the D7 Change Owner and hand-over cases; - line order and create: `closed-state-lock.test.ts`, "a write that closes an open record lands whole...; the next write is refused" and "a line create under a closed master is refused". The console's header-first save is `ui/packages/plugin-form/src/masterDetailTx.ts#buildMasterDetailEditBatch` (the header is op 0). The console's closing-header-last ordering (ADR-0162 item 4) has not shipped, so the page describes today's header-first order; - the lock read tells every reader: `packages/objectql/src/record-lock-read.ts` header, `content/docs/api/data-api.mdx#record-locks`; - parent delete refused: `closed-state-lock.test.ts` "a delete whose cascade reaches a closed record removes no row", and the `record_closed_delete_blocked` sentences in `packages/spec/src/system/operation-message.ts`; - the refusal carries no `lockReason` on the wire: `closed-state-refusal-wire.dogfood.test.ts`, "relays neither the developer sentence nor the lock's own members". The page therefore sends readers to the lock read for the reason and does not promise a `lockReason` on the 409. - **Not documented, because it has not shipped:** the console reading the one lock read to grey edit and hide delete, and its closing-header-last save (ADR-0162 item 4). The page names only what the showcase declares itself (`userActions` predicates). - **Done-when box "The key's own PR names this card on its `Skills-docs:` line":** PR #38810's body reads `Skills-docs: follow-up #38425`. It names the skills follow-up card, not #37772. The skills follow-up (#38425, "skills: the data skill teaches the closedStates key") is filed separately and is open, so the box's intent holds. Its literal first half cannot be met by any PR now that #38810 has merged. - `content/docs/references/data/object.mdx` is generated (`build-docs.ts`). It is linked and not edited. ## Verification - **Read first (by risk):** `content/docs/data-modeling/closed-states.mdx`, sections "Automation that acts as the caller" (the approval-hold paragraph is the subtlest claim) and "Line edits go before the closing write" (it states today's console order); then `content/docs/automation/approvals.mdx` around the two "the record unlocks" passages. - **Two-minute check:** `node scripts/check-doc-anchors.mjs` reports every internal fragment link resolving, including the new ones into the approvals, actions, hooks, data API and administrator guides. <details><summary>Local gates at 1db9570 (dispatch-gates derivation for this diff, reconciled with --ran)</summary> ``` dispatch-gates --ran: 55 derived famil(ies) accounted for — 55 run, 0 NOT-MEASURED (all 55 :: exit 0 at 1db9570, among them check:doc-authoring, check:doc-anchors, check:doc-frontmatter, check:docs-audit-scope, check:section-landing-index, check:role-word, check:nul-bytes, spec check:docs, spec check:skill-examples, spec check:yaml-examples, check:docs-transcript-drift) ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 828b6ec commit 20f47c9

5 files changed

Lines changed: 413 additions & 1 deletion

File tree

‎content/docs/automation/approvals.mdx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ On finalization the request row gets `status: 'approved'` (or `'rejected'`),
938938
mirrored to the same value, and the record unlocks. The parked run resumes down
939939
the `approve` or `reject` branch.
940940

941+
On an object that declares [`closedStates`](/docs/data-modeling/closed-states),
942+
the record does not unlock there: it is held until the approval is over, and
943+
where the outcome is one of the object's closed values it is then closed to every
944+
caller's change instead of unlocked
945+
([Approvals on an object that declares `closedStates`](#closed-states)).
946+
941947
Statuses in full: `pending`, `approved`, `rejected`, `recalled`, `returned`,
942948
`cancelled` (the platform voided the request, for example because its record was
943949
deleted; `cancel_reason` on the row says why) — the `APPROVAL_STATUSES` constant in `@objectstack/spec/contracts`, which is also
@@ -997,7 +1003,10 @@ flow's `revise` edge. The submitter reworks the record and `resubmit`s (a fresh
9971003
round opens for all approvers) or `recall`s (abandons it). Past the node's
9981004
`maxRevisions` budget (default 3) a send-back **auto-rejects** instead. The
9991005
flow's approval node must declare a `revise` edge, and that edge must target an
1000-
`approval_revise` node, for send-back to be available. A recall from the revise
1006+
`approval_revise` node, for send-back to be available. A record that is in one
1007+
of its object's [closed states](/docs/data-modeling/closed-states) through
1008+
another field stays closed in the revise window, and the submitter cannot rework
1009+
it ([An approval that does not mirror onto the closing field](#an-approval-that-does-not-mirror-onto-the-closing-field)). A recall from the revise
10011010
window cancels the run; when that run is an item of a batch sign-off (a `map`
10021011
over approval items), the recall also wakes the batch, which records the item's
10031012
slot as the cancelled marker `{ $status: 'cancelled', $itemRunId }` and moves on

0 commit comments

Comments
 (0)