Skip to content

docs(data-modeling): closed states, the closedStates key and every authoring note (ADR-0162) - #38993

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-37772-closed-states-docs
Dec 1, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-37772-closed-states-docs

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

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:

Runtime parse of the page's examples (spec dist at this head)
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.

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 feat(objectql)!: a record in a closed state, and its lines, are closed to change and held for its whole approval (closedStates, ADR-0162) #38810's body reads Skills-docs: follow-up #38425. It names the skills follow-up card, not Docs: document closedStates in the data-modelling guide with every authoring note, and point the approvals guide at it (ADR-0162 item 5) #37772. The skills follow-up (skills: the data skill teaches the closedStates key (after #37768) #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 feat(objectql)!: a record in a closed state, and its lines, are closed to change and held for its whole approval (closedStates, ADR-0162) #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.
Local gates at 1db9570 (dispatch-gates derivation for this diff, reconciled with --ran)
dispatch-gates --ran: 55 derived famil(ies) accounted for — 55 run, 0 NOT-MEASURED
(all 55 :: exit 0 at 1db9570f, 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)

Generated by Claude Code

…uthoring note (ADR-0162)

A new data-modelling page documents the 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. It
carries every authoring note of ADR-0162, the three the ruling names under
their own headings, and names the registered handler beside the script
body where it says what runs elevated. The showcase's paid invoice is the
worked example. The approvals guide's two "the record unlocks" passages
point at closed states.

Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
Co-authored-by: Claude <noreply@anthropic.com>
check:docs-audit-scope refuses a hand-written page the list does not name;
regenerated with check-audit-scope.mjs --write (+1, -0).

Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Dec 1, 2026
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 5704d13210f85fff6a32559690f750288d4536d6 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

Final green head · 2026-12-01T18:46Z · zone osa-data
Head-sha: 1db9570

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 review · PR #38993 (#37772) · head 1db9570 · 2026-12-01T18:50Z

VERDICT: ACCEPT. No must-fix and no should-fix.

  • Face. l1-face is CLEAN at 1db9570, with 13 items read and none flagged. Checks are 32 success, 22 expected skip and 0 failed, and mergeable_state is clean. The PR is docs only. skip-changeset is right, and Clause-②: no and Metadata-protocol: none are right. It is not governed, so no L2 is owed.
  • Read sentence by sentence. I read closed-states.mdx, both approvals.mdx hunks, index.mdx and meta.json, which together make up the owed docs read.
    • The page's code facts match packages/objectql/src/closed-state-lock.ts and ADR-0162:
      • the refusal is 409 RECORD_LOCKED, the same code the approval lock uses;
      • the refusal's own body does not say which lock refused (D8);
      • the lock read answers lockReason closed_state/approval and lockSource record/master (D9);
      • its disclosure is one bit of the state field to every reader;
      • a cascade is refused whole;
      • a system context is not bound.
    • Every in-repo link target exists:
      • approvals.mdx anchors #closed-states, #hold, #what-the-mirror-field-owes, #what-the-flow-owes, #when-the-outcome-lands-on-the-record, #refused-where-the-approval-is-authored, #an-approval-that-does-not-mirror-onto-the-closing-field and #what-an-abandoned-approval-leaves;
      • data-api § Record locks;
      • hooks § Elevation;
      • the administrator guide § Handing over a banned user's work;
      • system-context.
    • The two os:check examples pass the doc gates.
  • Card Done-when. Each box:
    • The page exists and is linked from index.mdx and meta.json.
    • Every ADR-0162 authoring note has its own section: publishing closes at once, automation that acts as the caller including the steps after a decision, code that passes no context, action buttons, the way out, the owner is kept, line order, the lock-read disclosure, and cascade.
    • The ruling's three named notes have their own headings: #action-buttons, #lock-read and #new-approval.
    • The handler registered for a script action is named beside the script body (review note N15).
    • Both "the record unlocks" passages now point at closed states: the finalization paragraph and the send-back paragraph.
    • The showcase's declaration is the worked example, and feat(showcase): a paid invoice declares closedStates; the three paid-invoice line hooks are removed (ADR-0162 item 3) #38917 merged it at 17:46Z.
  • Zone question (1): Fixes, despite the literal Skills-docs box. Accepted. The box's purpose is a skills/** follow-up filed apart from the key's own PR. skills: the data skill teaches the closedStates key (after #37768) #38425 ("skills: the data skill teaches the closedStates key") is that card, and it is open. PR feat(objectql)!: a record in a closed state, and its lines, are closed to change and held for its whole approval (closedStates, ADR-0162) #38810's Skills-docs: follow-up #38425 names it rather than this card. That first half was settled when feat(objectql)!: a record in a closed state, and its lines, are closed to change and held for its whole approval (closedStates, ADR-0162) #38810 merged, and no PR can rewrite it now. The body says so explicitly, so Fixes closes nothing that is still owed here.
  • Zone question (2): leaving out console behaviour that has not shipped (Console: read the one lock read, word "closed" apart from "in approval", and save a closing header last (ADR-0162 item 4) #37773). Right. The card says the docs describe shipped behaviour only. The page describes the master-detail save order as it ships today: header first, so a closing save that also changes lines is refused whole. It promises nothing from Console: read the one lock read, word "closed" apart from "in approval", and save a closing header last (ADR-0162 item 4) #37773.
  • Nit, accepted. § The refusal says "The refusal carries nothing that says which lock refused". That is true of the HTTP body, per ADR D8. In process, the engine's thrown error does carry reason and lockReason: 'closed_state' (closedStateLockError). Server code could read those, but the page tells authors to use the lock read, which is the published route.

Next: zone landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

2026-12-01T18:51Z · Landing: L1 ACCEPT on head 1db9570 (7321664623; both zone questions accepted, one accepted nit). Not governed (0 of 5 paths), docs only, no L2 owed, CI 32 success / 0 failure, mergeable clean. Ready for review and auto-merge (squash). Fixes #37772. Note for #37773: when the console's closing-header-last save ships, the page's master-detail save sentence (header first today) is that PR's to update.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 1, 2026 18:52
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 20f47c9 Dec 1, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37772-closed-states-docs branch December 1, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: document closedStates in the data-modelling guide with every authoring note, and point the approvals guide at it (ADR-0162 item 5)

2 participants