Skip to content

feat(spec)!: a view holds lists only; view-held forms are tombstoned - #38908

Closed
objectstack-fleet[bot] wants to merge 29 commits into
mainfrom
claude/project-thread-d63y4z
Closed

objectstack-fleet[bot] wants to merge 29 commits into
mainfrom
claude/project-thread-d63y4z

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #37112

Supersedes #38888 (same commits, continued by the holding seat). This branch is cut from #38888's head 240a1f54f2 and merged with main; work continues here in pushed commits and the body is filled in as they land.

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: pending (filled in when the skills and docs commits land)

维护者速读

  • 用户能看到什么变化:升级到 19 版后,视图只放列表,表单只认独立的表单类型;旧写法会被拒绝并给出改法;没跑升级命令的项目会拒绝启动并提示该跑哪条命令。
  • 为什么做:表单拆成独立类型这个专题的收尾一步,19 大版本按裁定一次切换。
  • 出错会怎样:碰到的是升级到 19 版的部署和作者;已下线的表单保持下线,合并前可撤回,发版后撤回要再出一个版本。
  • 要你做什么:暂无,等席位契约复审后再请你批。

What changes

PR 2 of 2 for #37112 (PR 1, #38844, shipped the conversions, os migrate protocol --to 19 and the switch marker).

  • Tombstones in @objectstack/spec: view.form, view.formViews, the form view kind, the flattened form overlay, and the _views.KEY.title / .submitBehavior translation tails (ADR-0159 D7, D8). The served container expansion drops form members; the raw expansion stays for the projection and the conversions.
  • Tombstone tail: liveness ledgers, form inputs, variant docs, retired-key entries, the tree-scoped absence pin.
  • Boot guard (ruling 7303149461): a 19 runtime without the switch marker refuses to start and names the command; no skip switch. Birth marker (ruling 7308112533): a store created from empty records the marker itself.
  • View reads serve lists only (metadata-protocol, intake, rest, loaders); the save door refuses the old shapes with the prescription.
  • Lint stops reading the old shapes; form-view-internal-not-loaded is retired (its successor on form items stays).
  • Kept-reader pins on a 19 build, with ablations; the tests that asserted a projected form is served are rewritten to the major's answer (none deleted).
  • Console (ui/).
  • Docs, skills, BREAKING changeset.

Why

ADR-0159 card ⑤b: forms are their own metadata type, and major 19 stops reading the three view-held form shapes (ruling record 7142585849 on #36868: convert first, then switch, in the next major).

Verification

To be filled in: the before-tombstoning readings, the pins and their ablations, dispatch-gates --commands reconciliation, and the dogfood battery on the final head.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT

A view holds lists only (ADR-0159 D7): `view.form`, `view.formViews` and
the `form` view kind are retiredKey / enumWithRetiredValues tombstones
naming `forms:`, the flattened form overlay is gone, and the served
container expansion drops form members while the raw expansion stays
for the projection and the conversions. The translation tails
`_views.KEY.title` and `.submitBehavior` are tombstoned and the
translator no longer reads them (D8).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
A view item keeps its discriminated-union shape with the list arm alone,
and its unmatched discriminator answers the `viewKind: 'form'`
prescription. The view ledger grades `form` and `formViews` dead with
REMOVED notes; the undrilled-container, key-mention and
dropped-refinement baselines shrink by the sites the tombstones closed;
generated references follow.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
Every test that asserted a view-held form (the container's form and
formViews, the viewKind 'form' item, the flattened form overlay, and the
_views form translation tails) now asserts the protocol-19 answer: the
door refuses the whole form at its own key with the D7 prescription, and
the same body is judged where a form lives now, the form item. No test
is deleted; each rewritten case carries an [ADR-0159 D7] or D8 note.

A shared testkit holds the four retired view-held doors so the
form-key retirement tests judge their old rows in one place. The
dropped-refinements header count follows the 22 site lines already
removed.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
…ewContainer

The served view read uses expandServedViewContainer (lists only). Every
other reader keeps the raw expansion of a stored container.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
…oors and in the census

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
… serves no projected item

The served view list leaves out stored old-shape form items. The form
doors' withdrawal layer reads them through getViewItemsWithStoredForms.
The stored-form census keeps the before-the-switch reading.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
GetUiViewResponse is a view for `list` or `{ object, form }` for `form`.
The answer is unchanged, and a test pins it byte-equal.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAmjLdCQkCPb8p8sKJs
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:system protocol:ui tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 6 package(s): @objectstack/cli, @objectstack/metadata-protocol, @objectstack/plugin-auth, @objectstack/rest, @objectstack/runtime, @objectstack/spec, touching 150 documentable anchor(s). ⚠️ 31 changed file(s) yielded no anchor (packages/runtime/src/index.ts, packages/spec/api-surface/api.json, packages/spec/api-surface/root.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

83 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 50fa10c768c4f0c7099c412a8675694ab0e31822.

⛔ 20 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 31 changed file(s) yielded no anchor (packages/runtime/src/index.ts, packages/spec/api-surface/api.json, packages/spec/api-surface/root.json, …) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: os serve (command, 53 pages)
  • 17 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 197 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 50fa10c768c4f0c7099c412a8675694ab0e31822 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b2211be5882206058d5ba206aaf87d43f19410d9 — the merge of head 573b29bb88d49d0ecea922750802ecd995bd73dd into base 50fa10c768c4f0c7099c412a8675694ab0e31822, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b2211be5882206058d5ba206aaf87d43f19410d9 && git checkout b2211be5882206058d5ba206aaf87d43f19410d9
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 50fa10c768c4f0c7099c412a8675694ab0e31822 573b29bb88d49d0ecea922750802ecd995bd73dd && git checkout -B drift-repro 50fa10c768c4f0c7099c412a8675694ab0e31822 && git merge --no-ff 573b29bb88d49d0ecea922750802ecd995bd73dd

node scripts/docs-audit/affected-docs.mjs --json 50fa10c768c4f0c7099c412a8675694ab0e31822

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 50fa10c768c4f0c7099c412a8675694ab0e31822 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

The switch marker's docblock said no boot reads the row in this release and
that only the command writes it. The served boot now reads it, and a store
created from empty records it as a birth marker (details.birth). The docblock
also says what the command records on a datastore with no sys_metadata table.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
The `form` member left `ViewKindSchema` in protocol 19 (ADR-0159 D7), so the
discriminated union's key is `viewKind:list`. check:variant-docs reported the
old `viewKind:form|list` row as orphaned and the one-arm union as undeclared.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…tch is not recorded

A served boot now reads the switch marker (sys_migration
'adr-0159-form-type-switch') in the guard's own start(), after the
organization-ownership guard, and refuses to start when it is absent, not
verified or unreadable, naming `os migrate protocol --to 19` as the boot was
started. Nothing skips the check: os serve always composes its own instance
and refuses a stack plugin that carries the guard's name.

A store the boot observes being created from empty records the marker itself
as a birth marker (details.birth), from the served guard, from the birth half
createStandaloneStack composes, and from the deferred flush of a CLI boot. The
refusing half stays out of createStandaloneStack.

The switch command records `applied_at` only when the ceremony ran: on a
database with no sys_metadata table the row is the census's verdict alone.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…ow the 19 tombstones

The view container's `form` / `formViews` and the `viewKind: 'form'` item are
tombstones in protocol 19 (ADR-0159 D7), and the `_views` form tails with them
(D8). What still described them as live is brought level:

- liveness/form.json: the body rows no longer say they are inherited from
  view.json `form.*` rows that left with the container's tombstone. The two
  rows view.json had re-cited after the seed (`columns`, `sections`) carry
  that later verdict, and `sharing`'s evidence no longer says an old shape is
  answered as the form it projects.
- liveness/translation.json: `forms` is the one address of a form's strings;
  the fallback read of the `_views` tails is gone, and the note says where the
  tails are registered.
- liveness/README.md: the `view`, `form` and `translation` rows record the
  tombstones.
- view.zod.ts: the refusal of a body that is no view and the prose around the
  wire schema name the list slots only; content/docs/references/ui/view.mdx is
  the regenerated mirror.
- i18n-resolver.ts: the dispatch comment no longer describes the removed
  fallback read.

No schema shape, read path or refusal changes.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
… the ownership guard

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
`view` is lists only since protocol 19 (ADR-0159 D7). The refusals and the
conversion are pinned beside the schema; this adds the playbook's tree-scoped
absence leg, in the `repo` project, inside the radius the package already
declares.

It judges the authoring shape, three arms: `formViews` in key position, the
`viewKind: 'form'` item, and a `defineView` container whose own braces hold a
`form` member. Inline code is prose, so a page may still say what was removed.

The population is what an author copies from: `skills/`, `content/` and
`scripts/` whole, the examples' non-code files and each app's `src/`, and under
`packages/` what a package teaches (Markdown and YAML). A package's code and
JSON are the stated bound: typed authoring there is refused by `tsc` at the
tombstone, and the code that names the shapes untyped is the reader of rows
stored before 19 with its fixtures, whose job is to spell them.

`scripts/cross-package-test-inputs.mjs` names the pin as a further witness on
the rows it reads; no glob is added, so `turbo.json` is unchanged.

The walk is red at this commit on two files, both outside what this change may
edit: `content/docs/concepts/architecture.mdx` (a fenced comment still says a
view is authored with a `form` member) and `scripts/codemod/view-to-viewitem.mjs`
(its header still prescribes the `form` view item).

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
The depth test beside `keyPosition` was redundant: `keyPosition` is only ever
true at the container's own depth. Drop it, say the rule in the doc comment,
and add the neighbour that holds it (a `form` key after a comma one level down).

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
An ablation of the line-comment skip left the specimens green: the comment
specimen put no `form` where a key can stand. Give the line comment, the block
comment and a string at the container's own depth a specimen each that turns
red when its skip is removed.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
… bears it on an empty database

protocol.integration.test.ts: the fixture's package ships its public form
as a `form` item (a protocol-19 stack is refused at boot with
`view.formViews` in it, which left this suite red in beforeAll). New pins:
the served boot's guard refuses the database before the switch and after a
held --apply, admits it once the command recorded the switch; a database
with no sys_metadata table gets a verified record with applied_at unset.

apply.organization-ownership-birth.integration.test.ts: os migrate apply
records the protocol-19 birth marker on a database it created from empty,
and none on one it did not create.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…its caller, naming the command

schema-migrate.birth-after-flush.test.ts pins formTypeSwitchBirthFailure:
the row it names, the cause, and `os migrate protocol --to 19 --apply --yes`
(never the organization-ownership ceremony's steps).

Both edited cli test files pay the first load of the dist-resolved
dependencies their source reaches at module top (check:test-source-alias).

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…red on the showcase

A showcase database an earlier boot left with no switch record is refused
naming `os migrate protocol --to 19`; the real CLI binary previews without
writing and records the switch with --apply --yes; the next boot is
served. A database the boot creates from empty records the switch itself
(details.birth) and the boot after it reads that record.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…9 switch record

serve-form-type-switch-refusal.integration.test.ts pins the wiring only
serve.ts owns, on the shipped entrypoint in production posture: a database
the boot creates is served and carries details.birth; the same database
with the record gone exits non-zero before the banner and names the
command, printing no credential; a stack plugin under the guard's name does
not take its place; the named command records the switch and the next boot
is served.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…y; a form reads no object off a list

[ADR-0159 D7] Lane C, step 1 of the major-19 form type switch.

- `getMetaItem({ type: 'view', name })` answers no `item` for a stored row
  that is not a list (`servedViewItemAnswer`), in every state it serves. The
  stored row is neither rewritten nor refused; the raw reads are unchanged.
- `anonymousFormObjectName` no longer reads the container's
  `list.data.object`: a `form` item names its object itself (card item 5).
- New pins, `packages/rest/src/stored-forms-major19-kept-reader.test.ts`:
  what both public form doors answer on a 19 build at a package's open `form`
  item while a stored old-shape row stands (status, `code`, no record), the
  served `view` reads, and the save door's refusal of the three old shapes
  (`INVALID_METADATA`, 422, located path).
- `stored-forms-switch-37112.test.ts`: every base that shipped the open form
  as an old-shape container now ships it as a `form` item (two pins read 200
  from a shape 19 no longer serves).
- `protocol.ui-view-response-conformance.test.ts` pays its `@objectstack/lint`
  load at module top (`check:test-source-alias`).

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…9 build

An open stored `form` row beside a stored old-shape row of the name that is switched off, in the package's declared override and in no package: the `form` row is the served row, and both doors answer 404.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
The guest-grants-channel, guest-owner-stamp, read-back-masking,
submit-answer and withdrawal-walled suites authored their public form as
`view.formViews.intake`, which the protocol-19 schema refuses, so the
package no longer type-checked. Each fixture now keeps its list in the
`defineView` container and declares the form with `defineForm` under
`forms:` (`OBJECT.intake`, bound by `object`, same sections and sharing).

The walled suite reads and writes the form at `/meta/form/NAME` and edits
`sharing` at the item's root, where a form item carries it. No assertion
is removed or changed: every status, code and landed-row expectation is
as it was.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
…FORM_TYPE_SWITCH_REQUIRED; the auth family starts after the guard

The refusal is stamped with a registered machine code (error-code ledger,
under @objectstack/runtime, door: none, on the precedent of the v18
organization-ownership refusal), and isFormTypeSwitchBootRefusal
discriminates on it. The three generated reference pages follow the ledger.

AuthPlugin and IdentityObjectsPlugin name the guard in
optionalDependencies beside the v18 guard, so nothing they write at start
is written before its verdict; form-type-switch-guard-ordering.pin.test.ts
proves the declaration is what moves the order.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
… at module top

check:test-source-alias asks it of an added test file whose source reach
loads @objectstack/core/egress through a dynamic import.

Claude-Session: https://claude.ai/code/session_01ADHkmPVdwjc3wMNdnuWeFT
Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
objectstack-ai#38913)

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB8bGG76Ba3qpTAkGh8yPgHA)_

Fixes objectstack-ai#37770

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up objectstack-ai#38961

## 维护者速读

- 新增一个由数据层回答的锁读取(单条和一页最多 200 条),告诉任何能读记录的人它是否被锁、是因关闭态还是因审批锁住。
- 不装审批插件也能用,此时只有关闭态会锁;审批原有的读取、SDK 方法和服务成员一字未改。
- 上传链接在发放前改问这个读取,关闭的记录用新句子拒绝,审批中的记录仍用原句子。
- 控制台记录页、表格和明细表格改问这个读取的工作归 objectstack-ai#37773,不在本 PR。

## What changes

ADR-0162 D9: one answer to "is this record locked, and by which lock",
for both locks a record can be under.

- **Answer shape** (`packages/spec/src/api/record-lock.zod.ts`):
`RecordLockSchema`, `GetRecordLocksRequestSchema`,
`RecordLockEntrySchema`, `GetRecordLocksResponseSchema`,
`RECORD_LOCKS_MAX_RECORD_IDS = 200`. Spelled as two strict arms
(`locked: true` with both kinds, `locked: false` with none) so the
published JSON Schema carries the "both kinds exactly when locked" rule
too. Done-when item 5 (N12): **the internal seam requires the source**,
so `lockSource` is never optional under `approval`.
- **The read** (`packages/objectql/src/record-lock-read.ts`,
`ObjectQL#getRecordLock` / `#getRecordLocks`). Readability is read as
the caller, with each form's approvals-counterpart anchor (seat ruling
7152650156): the single read counts any row its by-id read returns and
judges the engine-spelled id; the page counts a row only when its id is
the asked id. The closed-state producer reads straight from the driver,
above the caller's grants (so field permissions on the state field do
not hide the answer, per D9) and inside the caller's org scope
(`buildDriverOptions`). A store read that fails is thrown, never read as
open. Order: `closed_state` before `approval`; within a reason `master`
before `record`.
- **The approvals producer**
(`packages/plugins/plugin-approvals/src/record-lock-producer.ts`):
pending under a locking node, or a passage on a `closedStates` object,
for the record itself and for `master_detail` lines of such a master. It
reuses the lock hooks' own helpers (four of them gain `export` in
`lifecycle-hooks.ts`, which the package entry does not re-export). It is
bound beside the lock hooks inside the `disableAutoHooks` block and
cleared in `destroy()`, so a composition that binds no approval lock
answers no approval lock.
- **Data protocol**
(`packages/metadata-protocol/src/protocol-record-lock.ts`):
`getRecordLock` / `getRecordLocks`, the object-existence gate first,
then the engine. An engine without the read answers `undefined`, which
the REST doors turn into 501.
- **REST** (`packages/rest/src/record-lock-routes.ts`, registered from
`data-action-routes.ts`, so `rest-server.ts` does not move): closed
empty query sets, `sendOk` envelope, the by-id read's localized `404
RECORD_NOT_FOUND` with `Vary`, 400 for a bad page body, 501 when the
read is missing. Two ledger rows (`data.getRecordLock`,
`data.getRecordLocks`) with their response schemas.
- **SDK** (`packages/client`): `data.getRecordLock(object, id)` and
`data.getRecordLocks(object, recordIds)`, with the types re-exported.
- **Upload-link door**
(`packages/services/service-storage/src/record-file-access.ts`): asks
`engine.getRecordLock` as the caller before it issues a field link and
refuses `409 RECORD_LOCKED` with "the record is closed, so no file can
be added to it" on `closed_state`, or the existing approval sentence on
`approval`. An engine without the read falls back to the approvals
service, as before.
- **Docs**: `content/docs/api/data-api.mdx` § Record locks,
`content/docs/api/client-sdk.mdx`, and a pointer from the approvals lock
reads in `content/docs/automation/approvals.mdx`.
- **Engine line ceiling**: `engine.ts` gains one import line and two
one-statement forwarders (+3, 6857 → 6860). The
`check:facade-delegation-only` row is raised by that measured growth,
per the maintainer's ruling record
[7314474264](objectstack-ai#37770 (comment))
on objectstack-ai#37770 (「提到 6861」): `baseLines` 6860 at `dd7675de60`, `maxLines`
6860. No other engine growth is covered by that ruling.
- **Level**: the two new request and response shapes enter the `api`
authorable-surface shard, which the changeset level axis reads as
`Metadata-protocol: added`, so `@objectstack/spec` is a `minor`; the
other packages are `patch`.

Out of scope here: moving the console askers (record page, grid, line
grid) onto this read belongs to objectstack-ai#37773, together with its wording.

Follow-ups: objectstack-ai#38961 (the skills page § Reading the lock points at this
read) and objectstack-ai#38962 (the contract review's nits: pin the passage arm and
the read's jsdoc on a failed store read; the closed-state lines'
semi-join and the repeated foreign-key read).

## Why

A client could only ask the approvals read, which knows nothing of
closed states, so a closed invoice looked editable until the save was
refused. ADR-0162 D9 (adopted, ruling record 7200732942) puts one read
in the data layer for both.

## Tests

- `plugin-approvals/src/record-lock-one-read-37770.integration.test.ts`
(11): real ObjectQL over better-sqlite3 with the real
`ApprovalsServicePlugin`. Every Done-when combination: closed own, line
of a closed master, held by an approval, line of a held master, both at
once, neither, unreadable, missing; agreement with the write path; the
reader whose field permissions hide the state field is told
`closed_state`; no read on the object refuses the same for every id;
`lockRecord: false` and a decided request let go; the approvals-family
read still calls a closed record unlocked; without the plugin only
closed states lock; `destroy()` empties the slot, and the cross-package
key is the one the engine reads; the page answers entry by entry,
refuses 201 ids and takes 200.
- `rest/src/record-lock-routes.test.ts` (10): both doors, parsed against
the ledgered schemas; only the three members are served; 404/Vary;
relayed refusals; 501; 400 for each bad body; closed query sets.
- `rest/src/rest-write-route-hook-refusal-sentence.ledger.test.ts`: the
page door's write-verb row is driven.
- `service-storage/src/record-file-access.integration.test.ts`: the
fixture's approvals stand-in now also fills the engine slot; a new case
pins the closed-state sentence and that closed wins over held.

## Acceptance notes

- `git diff origin/main -- packages/rest/src/approvals-routes.ts
packages/spec/src/contracts` and the client's `approvals.*` methods: no
change (Done-when item 7).
- The read answers for a caller. A system context is bound by neither
lock and is not described.
- No permission or sharing boundary moves: readability is the caller's
existing read, and the answer carries no field, value, request id or
participants.

## Verification

- Package typechecks: objectql, metadata-protocol, rest, client,
plugin-approvals, service-storage — clean.
- Spec build with generated baselines regenerated and committed
(authorable surface, json-schema manifest, api surface, export origins,
strictness ledger counts, reference pages, llms.txt inventory).
- `dispatch-gates --commands`: every derived gate was run locally. The
ones that failed were fixed (route envelope, query-options erasure,
ADR-0122 alias pins, api surface, docs, export origins, llms.txt, facade
ceiling under ruling 7314474264). Four could not run here, for
environment reasons only: `check-plugin-teardown-shape --self-test`
needs an unshallow clone, and `check:skill-examples`,
`check:dual-build-cjs-loads` and `check:i18n` need built dists. CI runs
all four.
- Package suites: objectql 14662, rest census and route tests,
plugin-approvals, service-storage 94, metadata-protocol canonical-fold
census — green.
- `overlap-check`: clean against origin/main, objectstack-ai#38908, objectstack-ai#38888.

## 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.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [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_01WGufzfGw8DS75kHUYrjbLM

<!-- signed: repo:objectstack@os-support-ai · os-support-ai ·
session_01WGufzfGw8DS75kHUYrjbLM -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

2026-12-02T03:29Z · Closed as superseded. PR #38957 merged (f42afe7f64) and closed #37112. It started from #38908's head and carries every commit of #38908 and #38888, as its body states, so nothing on this branch is lost. Its body asked for this pull to be closed on landing. Reopen it if anything here is found missing from main.

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 protocol:system protocol:ui size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants