Skip to content

fix(plugin-approvals): the batch lock read answers a line of a held master as locked - #37145

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-37041-batch-lock-detail-lines
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-37041-batch-lock-detail-lines

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php

Fixes #37041
Clause-②: no
Metadata-protocol: none

维护者速读

What changes

  • getRecordLocks (the batch door POST /api/v1/approvals/records/:object/locks) now asks the detail-row lock as well as the record lock, so a master-detail line whose master is held by a locking approval answers locked: true, exactly as getRecordLock already does and as the route doc promises ("Each entry is exactly the single-record door's answer for that id").
  • New batch helper detailRowsHeldByLockingApproval in lifecycle-hooks.ts: one SYSTEM read of the rows' master_detail FK columns for the whole page, then one locking-request lookup per master_detail edge for every master those rows name. That is 1 + edges reads whatever the page size, never one per row; an object with no master_detail edge reads nothing extra. The one-row detailRowHeldByLockingApproval now delegates to it, so the single and batch reads share one judgement. With one id, the FK read keeps the by-id shape the one-row read always sent.
  • The answer's shape is unchanged ({ locked } or null); unreadable-vs-missing stays indistinguishable (the caller's anchor read is untouched and runs first).
  • packages/spec/src/contracts/approval-service.ts: one clause in each of the getRecordLock and getRecordLocks docblocks saying that a master-detail line also answers true while the record it belongs to is held (the detail-row lock's judgement). The text "locked only", the rest of the console: a non-participant reader is offered inline edit on a record whose pending approval locks it (lockRecord: true), and the save answers 409 RECORD_LOCKED #25934 ruling A text and the answer shape are untouched; check:generated reports all 14 spec artefacts up to date at 88b76bf.

Seat 4's consumer constraint (comment 7145422785): answered by #37151

Seat ruling (repo:objectstack#3, 2026-11-24 22:53Z): this PR lands the parity fix alone with Fixes #37041; the lock-kind question moved to #37151, which carries route A, route B and keep to the maintainer. The measurements below are kept as that card's evidence.

The constraint asks this PR to say which of (A) the batch entry and the single door say which kind of lock holds the row, or (B) the grid hides Delete on master-held lines. Measured at 517e415:

Route A: the ruled text it would change. The getRecordLock docblock in packages/spec/src/contracts/approval-service.ts carries the #25934 ruling A: "What is answered: locked only. ... ⛔ No request id, node, participants or pending flag". A kind field (for example heldBy: 'record' | 'master', master winning when both hold, since a held master refuses the line's delete either way) rewrites "locked only" there, the same sentence in the plugin's getRecordLock docblock ("{ locked } only"), the REST door comment ("the payload is { locked } alone") and the return type of both optional contract members (a published shape, so Clause-② would become yes (widening)). Because that is ruled text, this PR stops here and the shape question goes to the seat.

Route A: what the field would tell a caller who can read the line but not the master. With parity alone, locked: true on a line already says "this line or its master is held", and the single door has said that since it shipped. The kind field adds one bit: which of the two. A caller who may update the line can already learn that bit without a destructive act: an edit is refused RECORD_LOCKED with the record lock's sentence (record_locked: the line's own object label and title) when the line is held itself, and with the detail-row lock's sentence (record_locked_untitled: the MASTER object's label, no title) when its master is held (lifecycle-hooks.ts, recordLockRefusal called from the two hooks). Delete is offered only to callers who can write, and for them A discloses nothing new. A read-only line reader with no request visibility learns the bit only through A. Nothing about the request (id, node, participants, pending) is disclosed in either case.

Route B: what the grid can tell without a server field. The grid has the object schema (it already branches on master_detail field types in ObjectGrid.tsx). So it can know the object is a detail object, but not why a given row is locked. The only server-free rule is to hide Delete on every locked row of an object that has a master_detail field. That over-hides Delete on a line held by a request of its own whose master is not held, which the server would accept (the detail-row hook judges only the master; the record lock is update-only, and the delete-cancel linkage cancels the request). It also copies the server's "which hook refuses delete" rule into the client. Asking the batch door a second time for the masters' ids would need the FK column on the page and a readable master (an unreadable master answers null), so it does not close the gap. Collision: PR #37128 (#36911, seat 4, open draft at d4f56f4) edits ui/packages/plugin-grid/src/objectGridActionsColumn.tsx and ObjectGrid.tsx, so route B can only start after it merges.

No regression from landing parity alone. Today the batch door answers master-held lines locked: false, so the grid offers both Edit and Delete, and the server refuses both. After this PR (and #37128) it offers Delete only, which the server still refuses. That is one refused offer instead of two. The Delete gap exists already and is not created here.

Tests

plugin-approvals: targeted file, full suite, typecheck (head 9b5bdcd)
  • pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/record-lock-read.integration.test.ts: Test Files 1 passed (1), Tests 14 passed (14) (12 existing + 2 new).
  • pnpm --filter @objectstack/plugin-approvals test: Test Files 128 passed (128), Tests 1922 passed (1922).
  • pnpm --filter @objectstack/plugin-approvals typecheck: exit 0; check:test-typecheck: OK.
  • New pins in record-lock-read.integration.test.ts:
    • single/batch parity for every caller (submitter, approver, reader) over a record held itself (held_sheet_a), a line of a held master (held_sheet_line_a), unheld records and lines (_b), a missing id and a repeated id. It also covers a line held by its own request, and the unlock once the master's request is decided.
    • a page of 8 lines reads exactly [line, sys_approval_request, line, sys_approval_request], never one read per row.
Ablation (one, on the tested behaviour)

The test imports ./approval-service.js from src (no dist hop). node scripts/ablation-replace.mjs replaced { locked: held.has(id) || heldByMaster.has(id) } with { locked: held.has(id) }: anchor x1 -> x0, blob 50e23203 -> da6d398c. Result: Tests 2 failed | 12 passed (14), and the two failures are exactly the two new pins. Restored: blob == HEAD (50e23203), git diff HEAD empty.

Acceptance notes

Verification

Read first, by risk:

  1. packages/plugins/plugin-approvals/src/lifecycle-hooks.ts, detailRowsHeldByLockingApproval: the batch FK read (SYSTEM) and the per-edge master lookup.
  2. packages/plugins/plugin-approvals/src/approval-service.ts, getRecordLocks: the second half runs only on readable ids the record lock left unlocked.
  3. packages/plugins/plugin-approvals/src/record-lock-read.integration.test.ts: the two new pins.

Two-minute check: pnpm --filter @objectstack/plugin-approvals exec vitest run src/record-lock-read.integration.test.ts should report 14 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php


Generated by Claude Code

…aster as the single read does

getRecordLocks asked only whether each row was held by a request of its
own; getRecordLock also asks the detail-row lock. Add the batch form
detailRowsHeldByLockingApproval (one FK read plus one lookup per
master_detail edge, never one per row), make the one-row form delegate to
it, and pin single/batch parity for a record held itself, a line of a held
master and an unheld record.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/plugin-approvals, @objectstack/spec, touching 9 documentable anchor(s).

4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/actions-as-tools.mdx (via IApprovalService (symbol, a top-level interface))
  • content/docs/automation/approvals.mdx (via ApprovalService (symbol, a top-level class), IApprovalService (symbol, a top-level interface), approvals.getRecordLocks (sdk, the route ledger binds it to POST /api/v1/approvals/records/:object/locks, selected by route anchor /approvals/records/:object/locks), getRecordLocks (sdk, the bare tail of client method approvals.getRecordLocks, bound to POST /api/v1/approvals/records/:object/locks), /approvals/records/:object/locks (route, bridged from symbol getRecordLocks — its route source's handler names it))
  • content/docs/automation/flows.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/concepts/architecture.mdx (via getSchema (literal, a string literal in detailRowsHeldByLockingApproval))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-6.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via ApprovalService (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 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 — 175 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 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4b7b18b4f8409867bb356901a474d9c1c01df1a3 — the merge of head 584c26a0f89855639167544f105793bb35245fe1 into base 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2, 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 4b7b18b4f8409867bb356901a474d9c1c01df1a3 && git checkout 4b7b18b4f8409867bb356901a474d9c1c01df1a3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2 584c26a0f89855639167544f105793bb35245fe1 && git checkout -B drift-repro 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2 && git merge --no-ff 584c26a0f89855639167544f105793bb35245fe1

node scripts/docs-audit/affected-docs.mjs --json 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2

⚠️ 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 49c8e0f069ac5e21b11ba40d8bbbbfd8cd2eced2 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

席位核对 — REWORK · repo:objectstack#3 · head 9b5bdcd · 2026-11-24T23:07Z

L1: REWORK (L1-w, zone wf-B)
Head-sha: 9b5bdcd81cdcab04bf7854606891135121ff7bb3

The code is right. Two paper findings stand between it and ACCEPT, one of which moves a published docblock and so brings an L2.

Must-fix

M1. The published getRecordLocks docblock is made false by this PR. packages/spec/src/contracts/approval-service.ts (shipped in dist/*.d.ts), getRecordLocks: "The same judgement, off the same snapshot, the record-lock beforeUpdate hook enforces." Before this PR that sentence described the batch read exactly: it asked recordsHeldByLockingApproval only. After it, the batch answers locked: true for a line whose master is held. No pending request sits on that line, and the record-lock hook does not refuse it; the detail-row lock hook does. So for that case the sentence is now false. The same omission already sits in the getRecordLock docblock above it ("true when a pending request on the record comes from a node whose lockRecord is not false — the same judgement … the record-lock beforeUpdate hook enforces"). It is pre-existing there, but getRecordLocks defers to it ("exactly what getRecordLock answers"), so fixing one sentence without the other leaves the two contradicting each other.

  • Fix: one clause in each of the two docblocks saying that a master-detail line also answers true while its master is so held (the detail-row lock's judgement), as the plugin docblock and content/docs/automation/approvals.mdx ("Asked of a line, it answers true while the record the line belongs to is locked") already say. locked only stays: nothing in the console: a non-participant reader is offered inline edit on a record whose pending approval locks it (lockRecord: true), and the save answers 409 RECORD_LOCKED #25934 ruling A's "what is answered" changes, only the condition for true is completed. Clause-②: no stays (no shape moves).
  • This puts a non-test packages/spec/src/** path in the diff, so the new head owes an L2 at CONTRACT_REVIEW_TIER. I run it on that head. The claim's file surface names the spec docblock "only under route A", so the seat amends the claim first. Adjacent getRecordLock fix, four conditions: same defect class, mechanical, nobody else holds it, same gate family. All hold.

Should-fix

S1. The PR body's 维护者速读 still asks the maintainer to rule here. Its last bullet, "要你做的:裁定行菜单"删除"按钮的取舍…", predates the seat's routing call. That question now lives on #37151, and this PR lands the parity fix alone. As written, the maintainer reads this PR as waiting on them. Fix: point the bullet at #37151 (or say nothing is asked of the maintainer here). It is a body patch by the card thread through relay issue_patch and does not move the head.

Read and found right (head 9b5bdcd)

  • l1-face.mjs --pr 37145: CLEAN, 13 items. Draft, base main, Fixes #37041 binds only this card, Clause-②: no / Metadata-protocol: none match the edited claim 7145985823. The changeset names @objectstack/plugin-approvals. Floors are green, and so are all checks: 39 success, 18 expected skips, 0 failed, 0 pending. mergeable_state clean.
  • Fixes is right. Both acceptance lines are met: batch parity without a read per row, plus a parity pin over held-itself, line-of-held-master and unheld. Seat 4's shape question (7145422785) is a separate card, approvals: the record lock reads cannot say whether a row is held by its own approval or by its master's, so a list cannot tell which locked rows may still be deleted #37151, carrying route A, route B and keep for the maintainer. It is not an unmet half of Approvals batch lock read answers "not locked" for a master-detail line of a locked master, unlike the single-record read it claims to equal #37041.
  • Parity. getRecordLocks runs the detail half only on readable ids the record lock left unheld. That matches getRecordLock's recordHeld || detailRowHeld short-circuit. Unreadable and missing ids still answer null from the untouched caller anchor, so the two cases stay indistinguishable. Repeated ids are deduped before every read and answered at each position.
  • detailRowsHeldByLockingApproval. The bookkeeping guard comes first, and an object with no edge reads nothing. A single id keeps the one-row { id } / limit 1 shape. Many ids use $in with limit = n, under SYSTEM as before. Master ids are deduped per edge. Ids are compared as strings on both sides (String(row.id), String(record_id), scalarFk). One master goes through pendingRequestFor and several go through the $in path, and both fail open on a read error, so the batch and the single read agree there too. The master count never exceeds the readable rows, which already passed PENDING_LOCK_LIMIT (1,000) at the record half, and the door caps a call at 200 ids, so the batch adds no new refusal path. The one-row form's only caller is getRecordLock; the write hooks are untouched.
  • Tests. Real commands with output (file 14/14, plugin suite 1922/1922, typecheck exit 0). One ablation on the tested line: the two new pins fail, everything else passes, and the restored blob equals HEAD. The read-count pin fixes the order [line, sys_approval_request, line, sys_approval_request] for an 8-row page. The parity pin covers three callers, a missing id, a repeated id, a self-held line and the unlock after a decision.
  • Changeset, sentence by sentence. The batch read answered false while the single read answered true and the write was refused: matches the card's measurement. "One read of the rows' master-detail columns plus one lookup per master-detail edge … never one read per row": matches the code and the read-count pin. "The answer's shape is unchanged": yes. "A list page that reads the batch door now stops offering an editor on such a line": ui/packages/plugin-grid/src/hooks/useRowApprovalLocks.ts reads the door for the select-first cells (ObjectGrid.tsx hostCellSelection). True.
  • content/docs/automation/approvals.mdx needs no edit. It already describes the batch read as the single read per id, and the single read as true for a line of a locked record. This PR makes that page true.

Note (not a finding)

  • With one row, detailRowHeldByLockingApproval now looks up every edge's master instead of returning at the first held one. The answer is the same and the read count is bounded by the edge count (usually 1).

Path to ACCEPT

  1. Seat: amend the claim's file surface to include the two packages/spec/src/contracts/approval-service.ts docblocks (M1).
  2. Card thread: push the two-clause docblock fix (plus any regenerated spec artefact a gate asks for) and patch the body's 维护者速读 bullet (S1).
  3. L1-w: delta read on the new head, and the L2 CONTRACT_REVIEW_TIER record (claim line first) on the same head.

…master

The getRecordLock and getRecordLocks docblocks named only the record-lock
hook's judgement; both reads also answer a master-detail line true while
its master is held (the detail-row lock). One clause in each; the answer
shape and the rest of the What-is-answered text are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php

Test UI (10/16) red at 88b76bf: judged a flake this PR did not cause; one re-run of the failed jobs follows.

  • Failing file: ui/packages/app-shell/src/views/ReportNewPage-36692.test.tsx. handleSave awaits loadHanRomanizer() (a cold import('pinyin-pro')) before saveAndPublishRuntimeMetadata; the test waits two setTimeout(0) flushes only. On the loaded shard test 1's save arrived after its assertion (0 calls) and landed in test 2 after beforeEach's mockClear (1 call), so test 2 failed too (log read by the card's dev).
  • This PR's diff has no ui/** path; the only change since the green head 9b5bdcd is a spec TSDoc comment (88b76bf). At 88b76bf the file passes locally 3/3 runs (6/6 tests each).
  • One re-run through scripts/pm/rerun-failed.mjs; a second failure is read as real. The timing race in that test is not this PR's to fix and is noted for its owner.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 88b76bf · 2026-11-25T00:06Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 88b76bf8994f21d5c295326b5ba46adcf18532b0
Local-runs: none
Scope: packages/spec/src/contracts/approval-service.ts + packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/lifecycle-hooks.ts
Security-touching: yes

① Derived judgments

Read from the net diff 517e4153..88b76bf8 (5 files), not from the PR body.

  • getRecordLocks accept set: a readable master-detail line whose master carries a locking pending request moves from { locked: false } to { locked: true }. Right. It is what getRecordLock answers for the same id on main, what the detail-row lock hook (bindDetailRowLockHook) refuses on write, and what the batch docblock already promised ("exactly what getRecordLock answers for that id"). No other entry moves: an unreadable or missing id still answers null from the untouched caller anchor, a row held by its own request is answered by the first half and never reaches the second, and an object with no master_detail edge takes no extra read.
  • getRecordLock (single) accept set: meant to be unchanged; it is not quite. detailRowHeldByLockingApproval now delegates to the batch form and answers .has(recordId). Main answered from "the engine returned a row"; the head answers from "the returned row's id, as a string, equals the asked id". For every id spelled as stored the answer is identical. Where the datasource matches an id more loosely than string equality, the answer flips to false. Wrong in that corner: S1.
  • detailRowHeldByLockingApproval read count: the early return at the first held master is gone; every edge is now looked up. Right. Same answer, bounded by the edge count, and the function's only caller is getRecordLock.
  • New export detailRowsHeldByLockingApproval in lifecycle-hooks.ts. Module-internal: packages/plugins/plugin-approvals/src/index.ts does not re-export lifecycle-hooks. No public surface is added. Right.
  • Spec docblocks: one clause in each of getRecordLock and getRecordLocks. The condition for true is completed; the return types, the optionality, the null rule, the cap and the sentence "What is answered: locked only" do not move. Right. No type, schema, constant, route or wire payload changes anywhere in the diff.
  • Write path: unchanged. bindApprovalLockHook and bindDetailRowLockHook are not in the diff; the hook still looks masters up one at a time through lockingRequestsForRecords.

② Semver level

  • .changeset/37041-batch-lock-detail-lines.md: @objectstack/plugin-approvals patch, Clause-②: no, Metadata-protocol: none. The level is right: a bug fix in a released package, nothing a metadata author can write changes, and no published shape widens or narrows.
  • Clause-②: no is right. The answer stays { locked } | null per entry; the docblock edit states a condition the implementation's single door already met.
  • Package list: the diff also moves @objectstack/spec (the two docblocks ship in its dist declaration files) and the changeset does not name it. .changeset/config.json puts @objectstack/spec and @objectstack/plugin-approvals in the one fixed group, so spec is versioned and published with this changeset either way; what is lost is a line in spec's own CHANGELOG. Graded N2, not a level error.
  • Changeset body, sentence by sentence against the tree: the before/after answers, "one read of the rows' master-detail columns plus one lookup per master-detail edge ... never one read per row", and "the answer's shape is unchanged" all match the code. The gate verdict agrees: both Check Changeset runs on this head concluded success.

Check-runs on 88b76bf8: 73 runs, every one success or skipped; none failed, none pending. Among them: Build Core, Test Core (all 10 shards and the roll-up), Test UI (all 16 shards and the roll-up), Type Check (workspace, source gates, consumer gates, debt ledger), every Lint lane, Spec property liveness, Governed Surface Queue Guard, Dogfood Regression Gate, PR-body guards, Check Changeset.

③ Boundary flags

  • Dev report 7146721964, open_questions[0] (seat 4's constraint 7145422785: should the answer say which kind of lock holds the row, route A, or should the grid hide Delete on master-held lines, route B). Answered for this head, escalated for the rest. This head takes neither route: it lands parity alone, and the shape stays { locked }. That is the only option of the three that leaves the console: a non-participant reader is offered inline edit on a record whose pending approval locks it (lockRecord: true), and the save answers 409 RECORD_LOCKED #25934 ruling A text ("What is answered: locked only") untouched, so it is the only one a seat may land without a ruling. Route A rewrites ruled text and widens a published return type; it is the maintainer's to rule. The PR body and the claim's seat edit say the question was moved to card approvals: the record lock reads cannot say whether a row is held by its own approval or by its master's, so a list cannot tell which locked rows may still be deleted #37151; I did not read that card (outside this brief's inputs) and take no position between A and B. On the contract's side, nothing in the spec text promises anything about delete: the promise is "never offers an edit the server will refuse", and the head makes that true for lines. The remaining gap (a refused Delete offer on a master-held line) exists on main and is not created here.
  • security_findings: none. Agreed with one qualification, recorded under ④ (disclosure): no new class of disclosure, a wider door for an existing one.
  • out_of_scope_findings: []. One to add, not this PR's: getRecordLocks anchors on String(row.id) equal to the asked id while getRecordLock anchors on "a row came back", so the two doors can already differ on main for a loosely matched id (null against { locked }). Pre-existing and untouched by this diff; the seat may file it with S1.
  • SQL push-down (Prime Directive 5). detailRowsHeldByLockingApproval reads the page's FK columns into the application, dedupes the master ids there and sends them back as an $in on sys_approval_request: an in-app semi-join, new at page scale (main did it for one row). No reason is written in the docblock, the changeset or the PR body for not asking the database to join. A reason does exist in the tree: the judgement (nodeConfigLocksRecord over the parsed node_config_json snapshot) is in-app by design and must be the one copy the write hook uses (lockingRequestsForRecords), the id set is bounded by the door's cap of 200, and the record half on main has the same shape. It is not stated where the next reader will look. Graded S2.

④ Design judgment

Spec docblocks against the code and against ruling A.

  • getRecordLock, new sentence: "Asked of a master-detail line, it also answers true while the record the line belongs to is so held — the detail-row lock's judgement, which refuses the line's writes." True of the head: getRecordLock ORs detailRowHeldByLockingApproval, which judges each master through the same lockingRequestsForRecords the hook calls, and the hook refuses insert, update and delete. "So held" correctly limits it to a locking pending request on the master itself; a master that is only a line of a held grand-master is not held, in the read and in the hook alike (neither is transitive).
  • The sentence sits inside the bullet "What is answered: locked only" and leaves that bullet's claim intact: the payload is still one boolean, and the line that follows ("No request id, node, participants or pending flag") is still true. Ruling A's text is completed, not changed.
  • getRecordLocks, new clause: "and, for a master-detail line, the detail-row lock's: a line answers true while the record it belongs to is so held." True of the head, and it removes the falsehood the L1 named (the batch no longer answers from the record-lock hook's judgement alone).
  • N1: both clauses say "the record the line belongs to" in the singular. masterEdgesOf counts every master_detail field, so a junction row answers true while any one of its masters is held.

getRecordLocks against the contract, sentence by sentence.

  • "Entry i answers recordIds[i]", "a repeated id is answered at each of its positions": the final ids.map is positional over the undeduped list; every read uses the deduped asked. Holds.
  • "null when it cannot or when it does not exist, never an entry that tells the two apart": the caller's $in read still runs first and alone decides null. Both later halves take only ids that read returned, and heldByMaster is consulted only behind readableIds.has(id). An unreadable id and a missing id cause the same reads (none), so neither the answer nor the read pattern separates them. Holds.
  • "The same judgement ... the record-lock hook enforces — and ... the detail-row lock's": first half recordsHeldByLockingApproval, second half detailRowsHeldByLockingApproval, both through lockingRequestsForRecords and nodeConfigLocksRecord. Holds.
  • "A caller refused the object's read outright is refused the same way for every id": the anchor read throws before any other read. Holds.

detailRowsHeldByLockingApproval, attempts to break it.

  • Several master_detail edges: one lookup per edge, results unioned; a row held through the second edge only is found. Two edges naming the same master object each get their own lookup. Holds.
  • A master that is a bookkeeping object: masterEdgesOf drops the edge; lockingRequestsForRecords would also answer empty. A bookkeeping object asked as the detail: returns before any read. Holds.
  • Duplicate ids: the service dedupes; a direct caller passing duplicates gets limit at or above the distinct count and a Set back. Holds.
  • A page at the 200-id cap: at most 200 master ids per edge, under PENDING_LOCK_LIMIT (1,000), so the lockedError refusal in pendingRequestsForRecords cannot fire on the second half; a service caller past 1,000 ids is already refused by the first half, as on main. The lookup's row limit (1,001) cannot truncate, since DUPLICATE_REQUEST keeps one pending request per record. Holds.
  • A read error on the masters' requests: one master goes through pendingRequestFor, several through the $in branch; both catch and answer empty, so the single read, the batch read and the hook all fail open together. A read error on the FK read throws out of both doors alike, as the single door did on main. Holds.
  • A line held by its own request and by its master: answered true by the first half and filtered out of unheld. Holds.
  • Numeric ids: the master side is normalised on both ends (scalarFk to string, String(record_id)), so a numeric FK matches a string record_id. The row side is where S1 lives.
  • Batch against write hook: the hook exempts system sessions and the opening run's own writes; the read answers for the row, not for a writer. The docblocks on detailRowHeldByLockingApproval say so. Not a disagreement.

Disclosure (the reason for Security-touching: yes). The spec hunks teach what a caller who can read a line is told about another record: locked: true on a line says its master carries a locking pending approval, and the master's readability to that caller is not checked (the FK read and the request lookup are SYSTEM). This is not new at this head. The single door has answered it per id on main, and a writer learns it from the RECORD_LOCKED refusal. The batch door now answers it for up to 200 lines per request. What is disclosed is one bit per line; the master's id, the request, its node and its participants are not. The caller-anchor order is intact, so an unreadable row and a missing row stay indistinguishable. I find no new disclosure class and no must-fix here. The contract's "Who is answered" bullet does not say in words that reading the line is enough and the master need not be readable; with route A open on #37151, the ruling there should carry that sentence either way.

Findings.

S1 (should-fix) — packages/plugins/plugin-approvals/src/lifecycle-hooks.ts, detailRowHeldByLockingApproval: (await detailRowsHeldByLockingApproval(engine, objectName, [recordId])).has(recordId) makes the single door's detail half depend on String(row.id) === recordId. Main took the row the engine returned for where: { id } and never compared ids. On a datasource that matches ids more loosely than string equality (a case-insensitive id collation, a numeric id column asked as "07"), the caller's anchor finds the row, the write hook refuses the line RECORD_LOCKED, and getRecordLock now answers { locked: false } where main answered true. That is the defect class this card exists to remove, reintroduced in a corner of the door the diff meant to leave alone. Fix: the one-row form answers from the set's size (it asked one id, so a non-empty set is its answer), keeping the batch form as it is. Not measured on a live driver; read from the code, and it does not arise for an id spelled as stored, which is why it is not a must-fix.

S2 (should-fix) — packages/plugins/plugin-approvals/src/lifecycle-hooks.ts, detailRowsHeldByLockingApproval docblock: the helper materialises master ids in the application and semi-joins by $in without saying why the join is not pushed down (AGENTS.md, Prime Directive 5). State the reason there in one sentence: the judgement is in-app over the node_config_json snapshot and must be the write hook's own lockingRequestsForRecords, and the id set is bounded by the door's 200-id cap. No code change is asked.

N1 (nit) — packages/spec/src/contracts/approval-service.ts, both new clauses: "the record the line belongs to" reads as one master; a row with several master_detail edges answers true while any of them is held. "A record the line belongs to" would say it.

N2 (nit) — .changeset/37041-batch-lock-detail-lines.md: the frontmatter names @objectstack/plugin-approvals only, while the diff also moves text shipped in @objectstack/spec's declaration files. The fixed group publishes spec at the same version regardless; adding '@objectstack/spec': patch would put the docblock completion in spec's CHANGELOG.

No must-fix.

Implemented-by: claude/issue-37041-batch-lock-detail-lines
Reviewed-by: session_01WGufzgv2LZN1W2qSYTZvYs

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

席位核对 — REWORK · repo:objectstack#3 · head 88b76bf · 2026-11-25T00:11Z

L1: REWORK (L1-w, delta read, zone wf-B)
Head-sha: 88b76bf8994f21d5c295326b5ba46adcf18532b0

Round 1 (7147044772): M1 closed. Both spec docblocks now say a master-detail line answers true while its master is held. The wording matches the plugin docblock and approvals.mdx, and "locked only" and the rest of the #25934 ruling A text are untouched. S1 closed. The PR body's 维护者速读 now says nothing is asked of the maintainer here and points at #37151.

The L2 at CONTRACT_REVIEW_TIER on this head is PASS with two should-fix findings open (comment 7148242072, claim 7148157373). Under the merge standard, should-fix findings are fixed and re-reviewed before landing, so this head is REWORK.

Must-fix

M2. The changeset does not name @objectstack/spec. The new docblock clauses ship in spec's dist/*.d.ts, but .changeset/37041-batch-lock-detail-lines.md names only @objectstack/plugin-approvals (l1-face: "published package(s) touched with no changeset entry: @objectstack/spec"). The L2 rates it a nit because both packages sit in one fixed version group. The L1 checklist requires an entry for every published package touched. The card thread is already pushing '@objectstack/spec': patch.

Should-fix (from the L2, adopted)

  • L2 S1. detailRowHeldByLockingApproval now answers .has(recordId) against String(row.id). Before, it judged whatever row the by-id read returned. On a datasource that matches ids loosely, getRecordLock would answer false while the write is still refused: for example a case-insensitive collation, or a numeric id asked as "07". Read off the diff, and confirmed: the old form used rows[0] with no id comparison. Fix: in the one-row form, answer held.size > 0. That restores main's behaviour exactly.
  • L2 S2. The detailRowsHeldByLockingApproval docblock gives no reason for collecting master ids in the app and semi-joining them with $in (AGENTS.md Prime Directive 5). The reason exists: the judgement runs in the app over the node_config_json snapshot, it is shared with the write hook, and the 200-id cap bounds the ids. Write that reason in the docblock. No code change.

Nit (fold into the same round, since S1 moves the head anyway)

  • L2 N1. Both new spec clauses say "the record the line belongs to" in the singular. A row with several master_detail edges answers true while any of its masters is held, so "a record the line belongs to" or "any of its masters" is exact. If left, it needs its own follow-up card under the nit rule.

Path to ACCEPT

One push covering M2, S1, S2 (and N1). Then the L2 reviewer reads the delta on that head under a new claim, and I read the L1 delta on the same head.

…row it found

The one-row form asked exactly one id, so a non-empty answer is that row's;
it no longer depends on the engine spelling the id back as asked. The batch
form's docblock says why the join stays in-app, and the spec contract
docblocks say "a record the line belongs to".

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 584c26a · 2026-11-25T01:13Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 584c26a0f89855639167544f105793bb35245fe1
Local-runs: none
Scope: packages/spec/src/contracts/approval-service.ts + packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/lifecycle-hooks.ts
Security-touching: yes

Delta review. The previous record is on head 88b76bf8 (PR comment 7148242072: PASS with S1, S2, N1, N2 open). Read here: the delta 88b76bf8..584c26a0 (two commits, cf433db6 and 584c26a0, 4 files, 38 additions and 5 deletions) and the full net diff 517e4153..584c26a0 (5 files). Judged from the tree, not from the commit messages.

① Derived judgments

  • getRecordLocks accept set: a readable master-detail line whose master carries a locking pending request answers { locked: true } where main answers { locked: false }. Right, and unchanged by the delta: packages/plugins/plugin-approvals/src/approval-service.ts is identical at both heads. Unreadable and missing ids still answer null from the caller's anchor read alone.
  • getRecordLock (single) accept set: now unchanged from main. The delta turns the one-row form's answer from .has(recordId) into a test that the set is non-empty (its size). The helper is asked exactly one id with limit: 1, so the set holds at most that one row, and a non-empty set is the row's answer however the engine spells its id back. That is main's behaviour (take the row the by-id read returned, compare no ids). Right. S1: closed.
  • detailRowsHeldByLockingApproval (batch form): code unchanged by the delta; only its docblock gained a paragraph. It still answers with ids as the engine spells them, which is what getRecordLocks needs, since that door anchors on the same spelling (readableIds is built from String(row.id)).
  • Spec docblocks: the two clauses now read "a record the line belongs to" / "a record it belongs to". Three lines of comment text moved; no type, schema, constant, route or wire payload changes anywhere in the net diff. "What is answered: locked only" is untouched. Right.
  • Changeset frontmatter: '@objectstack/spec': patch added. A release-list change, not a surface change. Right.
  • New export detailRowsHeldByLockingApproval: still module-internal (the package index does not re-export lifecycle-hooks); the delta's test imports it by relative path. No public surface is added.
  • Write path: unchanged. Neither lock hook is in the net diff.

② Semver level

  • .changeset/37041-batch-lock-detail-lines.md at this head: @objectstack/plugin-approvals patch and @objectstack/spec patch, Clause-②: no, Metadata-protocol: none. Every published package the net diff moves is named, each at the level its kind takes: a bug fix in plugin-approvals, a docblock completion in spec, nothing a metadata author can write. N2: closed.
  • Clause-②: no is right: the answer stays { locked } | null per entry and no published shape widens or narrows.
  • The added body sentence, "The getRecordLock / getRecordLocks contract docblocks in @objectstack/spec now say a line of a held master answers true", matches the spec file at this head. The rest of the body is unchanged and still matches the code.

Check-runs on 584c26a0: 69 runs, every one success or skipped; none failed, none pending. Among them: Build Core, Test Core (all 10 shards and the roll-up), Test UI (all 16 shards and the roll-up), Type Check (workspace, source gates, consumer gates, debt ledger), every Lint lane, Spec property liveness, Governed Surface Queue Guard, Dogfood Regression Gate, PR-body guards, Check Changeset.

③ Boundary flags

  • Dev report 7146721964, open_questions[0] (route A, a lock-kind field, or route B, the grid hides Delete on master-held lines). Unchanged by the delta. This head still lands parity alone with the shape { locked }, the only option that leaves the console: a non-participant reader is offered inline edit on a record whose pending approval locks it (lockRecord: true), and the save answers 409 RECORD_LOCKED #25934 ruling A text untouched; route A edits ruled text and is the maintainer's to rule. The PR body and the claim's seat edit place the question on card approvals: the record lock reads cannot say whether a row is held by its own approval or by its master's, so a list cannot tell which locked rows may still be deleted #37151, which is outside this brief's inputs and was not read; no position is taken between A and B. No new dev report has been posted on the card since the previous record, so there is no new flag or open question to answer.
  • security_findings: none. Agreed, with the qualification under ④ (disclosure), unchanged from the previous record.
  • out_of_scope_findings: []. The one this review added stands and is still not this PR's: getRecordLocks anchors on String(row.id) equal to the asked id, while getRecordLock anchors on "a row came back", so on a datasource that matches ids loosely the two doors differ (null against { locked }). It is on main, in the record half as well, and the delta does not touch it. With S1 closed the single door is back to main's behaviour, which makes this difference visible again in the detail half exactly as it is in the record half. It belongs on its own card.
  • SQL push-down (Prime Directive 5). The reason is now written where the materialisation happens, in the detailRowsHeldByLockingApproval docblock: the judgement is made in-app over each request's node_config_json snapshot and must be the write hook's own (lockingRequestsForRecords), and the id list is bounded by the door's cap. Checked against the tree: nodeConfigLocksRecord parses the snapshot in the application, both hooks and both reads go through lockingRequestsForRecords, and APPROVAL_RECORD_LOCKS_MAX_RECORD_IDS is 200. The reason is true and sufficient. S2: closed.

④ Design judgment

The delta, hunk by hunk.

  • lifecycle-hooks.ts, detailRowHeldByLockingApproval: the non-empty test on the set's size, with a three-line comment saying why membership is not compared. Correct for the only shape it can be asked in (one id, limit: 1). Tried against it: an engine that returned a different row than the one asked would now answer for that row, but the by-id read with limit: 1 is the same read main trusted, and the write hook trusts it too. No disagreement between read and hook.
  • lifecycle-hooks.ts, batch docblock: the new paragraph is accurate sentence by sentence, as checked under ③. "1 + edges bounded reads is the whole cost" matches the code and the read-count pin.
  • approval-service.ts (spec), both clauses: "a record the line belongs to" is exact for masterEdgesOf, which counts every master_detail field. N1: closed.
  • .changeset: covered under ②.
  • record-lock-read.integration.test.ts (the lane seat's ACCEPT, read here only as evidence for S1): a stand-in engine hands back LINE-1 for an asked line-1; the one-row form answers true, the batch form answers with the engine's spelling. It pins the behaviour S1 asked for.

Does the delta introduce anything new. No. No code path other than the one-row return expression changed. The spec text change narrows nothing and discloses nothing new. The reads, their order and their contexts are as they were at 88b76bf8.

Standing judgments from the previous record, re-read on this head and unchanged.

  • Spec docblocks against the code and ruling A: both clauses are true of the head; they complete the condition for true inside the bullet "What is answered: locked only" and leave "No request id, node, participants or pending flag" true.
  • getRecordLocks against the contract: positional answers and repeated ids, the null rule, the shared judgement and the outright-refusal rule all hold.
  • Break attempts on detailRowsHeldByLockingApproval, all holding: several master_detail edges, a bookkeeping master, duplicate ids, a page at the 200-id cap against PENDING_LOCK_LIMIT, a read error on the masters' requests (single read, batch read and hook fail open together), a line held by both its own request and its master, numeric ids on the master side.

Disclosure (the reason for Security-touching: yes). Unchanged by the delta. The spec hunks teach what a caller who can read a line is told about another record: locked: true on a line says a master of it carries a locking pending approval, and the master's readability to that caller is not checked. The single door already answers this per id on main and a writer learns it from the RECORD_LOCKED refusal; the batch door now answers it for up to 200 lines per request. One bit per line; no request id, node or participant. The caller's anchor read still runs first and alone decides null, so an unreadable row and a missing row stay indistinguishable. No new disclosure class.

Findings.

S1: closed
S2: closed
N1: closed
N2: closed

No must-fix, no should-fix.

Implemented-by: claude/issue-37041-batch-lock-detail-lines
Reviewed-by: session_01WGufzgv2LZN1W2qSYTZvYs

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

席位核对 — ACCEPT · repo:objectstack#3 · head 584c26a · 2026-11-25T01:15Z

L1: ACCEPT (L1-w, delta read, zone wf-B)
Head-sha: 584c26a0f89855639167544f105793bb35245fe1

No must-fix, no should-fix. The L2 at CONTRACT_REVIEW_TIER on this head is PASS with no must-fix and no should-fix open (comment 7149359590, claim 7149332250). This is Tier S: no governed path, 184 changed lines on this card's only PR. needs:contract-review is not owed, because a same-head PASS is on record.

Delta 88b76bf8..584c26a0 (two commits)

  • M2 closed (cf433db). The changeset names '@objectstack/spec': patch beside plugin-approvals. l1-face now reports every published package touched as covered. The added body sentence ("The getRecordLock / getRecordLocks contract docblocks in @objectstack/spec now say a line of a held master answers true") matches the spec hunks.
  • L2 S1 closed (584c26a). With one id, detailRowHeldByLockingApproval answers size > 0: one id, limit: 1, so the set holds that row or nothing. That is main's "judge the row the by-id read returned". The new pin uses a stand-in engine that spells line-1 back as LINE-1 and answers true. The card thread reports an ablation that turns it red.
  • L2 S2 closed. The docblock now states the reason for not pushing the join down (in-app judgement over node_config_json, shared with the write hook through lockingRequestsForRecords, ids bounded by the 200 cap). The L2 checked each part against the tree.
  • L2 N1 closed. Both spec clauses now say "a record the line belongs to".
  • approval-service.ts (plugin) is byte-identical across the two heads, and nothing else moved.
  • l1-face --pr 37145: 13 items clean. 58 success, 11 expected skips, 0 failed, 0 pending. Floors are green and mergeable_state is clean.

Everything round 1 found right on 9b5bdcd still stands (parity, read count, Fixes #37041, changeset sentences, the consumer). Round-1 findings M1 and S1 were closed on 88b76bf (7148256170).

Landing to-do

Fixes #37041 closes the card on merge. The pre-existing difference L2 noted is out of this PR and is with the seat to file: the batch anchor matches ids by exact string, while the single anchor takes any returned row.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php

Landing · 2026-11-25T01:17Z · head 584c26a

Probe Reading at head 584c26a0f89855639167544f105793bb35245fe1
check-governed-merges.mjs --pr 37145 NOT governed — 0 of 5 paths hit the register; 184 changed lines (+166 / -18) ≤ 3000
landing-k.mjs --pr 37145 OK — K = 11 < 15, no new locale pack, no shared book moved

Verdicts on this head: L1 ACCEPT 7149373728, L2 (CONTRACT_REVIEW_TIER) PASS 7149359590. 69 check-runs, every one success or an expected skip; mergeable_state clean.

State change: ready for review + auto-merge (merge queue). On merge, Fixes #37041 closes the card and wf-B removes pm:dispatched with the close-out. Follow-up: #37151 (maintainer ruled route A) is unblocked by this merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 25, 2026 01:17
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit f92d271 Nov 25, 2026
70 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37041-batch-lock-detail-lines branch November 25, 2026 01:49
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…s approval went next (objectstack-ai#37148)

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

Fixes objectstack-ai#35863

repo:objectstack#3 · os-support-ai · session_01WGufzg3ayWUHg9nLoybejn

Clause-②: yes
Metadata-protocol: none

## 维护者速读

- 审批人打开自己已经审过的审批单时,「审批进度」里在已决步骤下多出一行:审批已流转到哪一步并在等谁决定,或者整条审批已经结束、结果是什么。
- 属于审批流程体验:解决审过的人看不到「后来怎么样了」的问题。
- 出错时这一行不显示或说法不准,不影响审批本身,撤回这个改动即可恢复原样。
- 无。

## What changes

**Served shape (`@objectstack/spec/contracts`,
`ApprovalRequestRow.flow_route`).** One optional member, `outcome`,
served only beside `ahead: 'decided'`:

- `step?: { id, label }`: the run's latest request when it is a later
one than this request (same `flow_run_id`, opened after it, on any node,
a later round of the same node included; a pending one wins over a
decided one). Absent when no later request was opened.
- `status: ApprovalStatus`: that latest request's status, or this
request's own when `step` is absent. `pending` with a `step` = the
approval went on to that step and waits on its decision.
- `ended: boolean`: the record's approval is known to have stopped: a
root run, whose own flow body starts no child run (`subflow` / `map`),
that has stopped for good. `false` = not known (rounds 1 to 3 below).

`outcome` is absent when nothing past the request is known (no later
request in the run and the approval not known to have ended, or several
later requests are pending at once), so nothing is guessed. A pending
request's route never carries it.

**Server (`@objectstack/plugin-approvals`).** `routeOutcome` in
`approval-route.ts` is the rule, a pure function over the run's own
request rows (the same rows `passedSteps` already reads) and whether the
run has ended. `flowRoute` calls it for decided rows only.
`ApprovalService.attachFlowRoute` reads "ended" off the run itself
through `automation.getRun`, judged by the dead-run sweep's own
`TERMINAL_RUN_STATUSES` (derived from the total `RUN_STATUS_LIVENESS`
map), in the new `runHasEnded`. An unreadable run reads as "not known to
have ended", never as a failed read: the field is display-only like the
rest of the route.

**Docs.** `content/docs/automation/approvals.mdx` gains the decided
route's `outcome`, beside the existing `flow_route` example (the docs
drift check named that page).

**UI (`@object-ui/app-shell`, `@object-ui/i18n`,
`@object-ui/console`).** `ApprovalStepLine` takes an `outcome` prop and,
with `decided`, draws one line under the decided step, outside the
ordered list so assistive tech never counts it as a step: "Went on to
STEP, waiting for a decision", "Went on to STEP: DECISION", "Went on to
STEP, then ended: DECISION", or "The approval ended here". The approval
request page's decision panel hands it the served outcome on a decided
route only. Four new `approvalsInbox` rows in all eleven built-in
locales. The console's `ApprovalRequest` type and app-shell's
`ApprovalRequestLite` mirror the member.

### Why this shape (card option 2, one outcome) and not option 1 (the
steps after)

- Option 1 needs a `rejected` step state: a widening of the `state` enum
every step-line consumer switches on, and it still needs a separate
marker for "ended".
- The card asks the UI for one line under the decided step; one outcome
is exactly that line's data.
- Reading the run's latest request (rather than walking the graph) keeps
the route's existing rule: history, never the graph, and nothing
guessed.

### Read first (by risk)

1. `routeOutcome` in
`packages/plugins/plugin-approvals/src/approval-route.ts`: which later
row is "the latest", the parallel-pending refusal, and the
ended-at-this-request arm.
2. The `outcome` doc on `flow_route` in
`packages/spec/src/contracts/approval-service.ts`: the contract text the
L2 read judges.
3. `outcomeText` in
`ui/packages/app-shell/src/views/approval-progress/ApprovalStepLine.tsx`:
which status draws which sentence, and when it draws nothing.

### Two-minute verification

`pnpm --filter @objectstack/plugin-approvals exec vitest run
--maxWorkers=2 src/flow-route.integration.test.ts`: expect 14 passed,
including "a request decided at step 1 of a two-step route: the outcome
says step 2 is pending, then that the approval ended there".

## Tests

- `approval-route.test.ts`: a new `routeOutcome` describe (9 cases):
later pending, ended at a later step (approved and rejected), ended at
this request (approved, rejected, recalled, cancelled), not ended and
nothing later (no outcome), a later round of the same node, pending wins
over decided, parallel pending (no outcome), rows that are not later
requests, and `flowRoute` carrying it on decided rows only.
- `flow-route.integration.test.ts` (real ObjectQL over SQLite, real
AutomationEngine and approval node): the existing decided pin now
asserts `outcome: { status: 'approved', ended: true }` at the last step;
new pins for the card's two cases (decided at step 1 of a two-step route
shows step 2 `pending`, then `rejected, ended` once step 2 is rejected),
a first-step rejection ending the approval, and a pending request
carrying no outcome.
- `ApprovalDecisionPanel.stepLine-12491.test.tsx` (the existing harness,
a new top-level describe, 7 cases): each sentence, no line without an
outcome or with nothing to say, no line on a pending route, and every
locale pack carrying the four rows.

## Acceptance notes

- Size: 850 added / 18 removed lines over 24 files at 6080e34, under
the 3,000-line human-merge threshold.
- The line does not say who holds the later step. The card mentions it
in passing; the approver names of a later step are information this
request's reader was never served, so naming them is a read-access
question, not a display one. Not filed: no defect, and the card's own
ask (step N / ended approved / rejected / recalled) is met.
- `ended: true` with `status: 'approved'` reports the last decision; a
root run that failed after that approval also reads "ended". The run's
own status is not served here; that would be a second widening for a
rare case.
- Claim file surface: the diff also touches
`ui/packages/i18n/src/locales/*.ts` (the four rows the line needs),
`ui/apps/console/src/services/approvalsApi.ts` (the console's type
mirror of `flow_route`) and `content/docs/automation/approvals.mdx` (the
page that documents `flow_route`).
- The shape reported to the zone named `{ status, step? }`; the landed
shape adds `ended`, because "the approval ended" is a fact about the
run, not about any one request's status.

## Round 1 (L2 FAIL 7147867236, L1 REWORK 7147881964), head 99ab892

- **M1, a child run's end.** The approval node now records on each new
request whether its run is a root run or a child (`subflow` body, `map`
item: the engine links those upward by `$parentRunId`), as `__runRoot`
on the config snapshot (precedent `__round`; no schema change).
`attachFlowRoute` asks the run for "ended" only when the snapshot says
root; a child run's request, a request opened before the stamp, or an
unreadable run is never served `ended: true`. New pin in
`flow-route.integration.test.ts`: an approval inside a `subflow` whose
child run completed while the root run went on to the general manager
serves no outcome, and the root run's last request then served `{
status: 'approved', ended: true }` (round 2 withdraws that: its flow
hosts a `subflow`); a second pin removes the stamp from a decided
last-step request and the outcome disappears. Ablations: root-run read
forced `true` gives 2 failed / 9 passed; executor stamp forced `true`
gives 1 failed / 10 passed; both restored.
- **S1, audience.** The `outcome` contract doc and the `attachFlowRoute`
docblock state the disclosure: every reader of the request gets the
later step's node id and label and that request's status, never its id,
approvers, comments or field values, within the request-visibility bound
of ruling record 5299823744 as the seat ruled for this card.
- **S2, an unreadable run (option a).** `ended` is now defined as "known
to have stopped" (`false` = not known, including an unreadable run), and
the contract, the changeset and `approvals.mdx` say an outcome with a
later request is served even when the run cannot be read. **N1**: the
contract says `status` is the last decision only when it is not
`pending`.
- Checks: `@objectstack/plugin-approvals` full suite Test Files 128
passed (128), Tests 1934 passed (1934); plugin-approvals and spec
typecheck exit 0; spec rebuilt and `check:generated` all 14 up to date;
overlap-check clean against main and the open PR heads, objectstack-ai#37145 included.
CI at 99ab892: 70 check-runs, 61 success, 9 skipped, 0 failed, every
required context green; mergeable clean. The local re-run of the derived
gate list at this head stopped at 9 of 121 (all exit 0) when the
container restarted; CI ran the families.

## Round 2 (L2 FAIL 7150840780, L1 REWORK 7150863825), head e264c10

- **M2, a later step in a child run.** Chosen: the second of the two
named ways. "Ended" is never claimed for a run whose flow can start a
child run; child runs' rows are not read. `flowHostsChildRuns`
(`approval-route.ts`) says whether the flow holds a `subflow` or `map`
node anywhere, regions included (`loop` body, `parallel` branch,
`try_catch`, every graph `collectFlowGraphs` walks), and
`attachFlowRoute` asks the run for "ended" only when it does not. Two
choices inside it, stated so they can be judged:
- It is read off the flow definition (the same body the route's steps
are read off), not off the run's step log: the persisted step log is
compacted to a bounded number of steps, so "the run never ran a
child-run node" cannot be proven from it, while "the flow has none" can.
The cost is that a flow with a `subflow` on a branch the run never took
also never says "ended"; the line is then left out, never wrong.
- It covers the case with a `step` too, not only "ended with no later
step": with manager → general manager → subflow legal → end, the
manager's outcome would otherwise read `{ step: gm, status: 'approved',
ended: true }` and name the general manager's decision as the last one
while legal came after. With this rule it reads `{ step: gm, status:
'approved', ended: false }`, which is true.
- Not chosen, reading child runs' rows: a request does not record its
root run id (only `__runRoot`, a yes/no), the engine serves no "children
of a run" read, and walking `$parentRunId` chains from the read side
would need a new engine member, outside the claimed surface.
- Served shape for the review's setup (manager in the root run, then a
subflow holding legal, then the end; legal rejects, the root run
completes): the manager's request is served `flow_route: { steps:
[manager done], ahead: 'decided' }` with no `outcome`. Pinned exactly in
`flow-route.integration.test.ts` ("a later step in a child run: the root
run's end is not served as \"ended here\" for the request before it").
The round-1 hosted pin now asserts that the root run's own last request
also gets no outcome, its flow hosting a `subflow`.
- Contract, changeset and `approvals.mdx`: "known to have stopped" now
names "runs a flow that can start a child run" among the `false` cases,
and `step` says a request a child run opened is not among the run's
requests.
- **N4**: the `attachFlowRoute` docblock reads "as the seat ruled on PR
objectstack-ai#37148".
- Unit: a `flowHostsChildRuns` describe (3 cases): `subflow` and `map`
at the top level; inside a `loop` body, a `parallel` branch, a
`try_catch` catch, and nested two deep; none anywhere (approvals,
gateways, a `loop` of approvals, an empty flow).
- Ablations (through `scripts/ablation-replace.mjs`, restored to blob ==
HEAD each time): the gate in `attachFlowRoute` forced off gives Tests 2
failed / 10 passed (the new pin and the hosted pin); `map` removed from
the child-run node types gives 2 failed / 26 passed; the region walk
replaced by the top-level nodes gives 1 failed / 27 passed.
- Checks: targeted `approval-route.test.ts` +
`flow-route.integration.test.ts` Test Files 2 passed (2), Tests 40
passed (40); `@objectstack/plugin-approvals` full suite Test Files 128
passed (128), Tests 1938 passed (1938); plugin-approvals and spec
typecheck exit 0; spec rebuilt and `check:generated` all 14 up to date;
overlap-check clean against origin/main and PR heads objectstack-ai#37185, objectstack-ai#37173,
objectstack-ai#37166. CI at e264c10: 70 check-runs, 61 success, 9 skipped, 0 failed,
every required context green; mergeable clean.

## Round 3 (L2 PASS with S3 7151818256, L1 REWORK 7151830517), head
6080e34

- **S3, which flow body is judged.** Chosen: refuse "ended" unless the
run provably ran the body armed now; no new engine member.
`ranArmedBody` (`approval-service.ts`) holds when the armed body is the
flow's newest registration in the engine's version history
(`getFlowVersionHistory`, compared as the very object) and was
registered strictly before the run started (the run log's `startedAt`,
which a resume carries over unchanged). A run starts on the body armed
at its start and resumes pinned to it, so with nothing registered since,
that body is the one it ran. `runHasEnded` now requires it beside the
terminal status.
- Not the run's `flowVersion`: it is the author's number and an edit
need not change it (the edit pin re-registers under the same version).
- Not judging the run's own version out of the history: the history is
the engine's in-memory list since boot and a version number can repeat,
so it can name the wrong body; the run log carries no body checksum to
match.
- `getFlowVersionHistory` and `startedAt` are declared on the plugin's
automation surface as members `AutomationEngine` already implements and
returns publicly, the existing precedent for that interface.
- Cost, stated: a flow registered again after a run started (an edit, a
rollback, the re-registration every restart makes) leaves that run's
requests without "ended", so after a restart older decided requests drop
the line until a new run. Omitted, never wrong.
- **Pins** (`flow-route.integration.test.ts`): a run that started a
`subflow` (legal rejects, the root completes), then its flow
re-registered under the same version without the subflow: the manager's
request still serves no `outcome`; a run started on the edited body then
ends at the manager, `{ status: 'approved', ended: true }`. A rollback:
version 2 (with the subflow) runs, `rollbackFlow` re-arms version 1
(without): no `outcome`.
- **Wording**: the contract, the changeset and `approvals.mdx` now say
"the flow body the run ran" and when that body is known, and list "ran a
body that is not known (its flow was registered again since it started)"
among the `false` cases.
- **N5**: the `CHILD_RUN_NODE_TYPES` docblock names the only two
executors that set `$parentRunId` (`builtin/subflow-node.ts`,
`builtin/map-node.ts`), says `loop`, `parallel` and `try_catch` stay
in-run, and that a new child-run starter joins the set in the same
change. A pin would have to read `service-automation` sources from this
package's tests, which the cross-package test-input gate refuses, so it
is a comment.
- **Left, with reasons.** N2 (later is measured against `created_at`,
not the decision): a run opens its requests one after another, so the
order they were opened in is the order the approval moved in; the only
same-run overlap is parallel branches, which `routeOutcome` already
refuses to pick from. No reachable wrong case, so no change and no card
needed in my view. **N3, fixed after all**: both UI mirrors now type
`outcome.status` as the row's own `status`
(`ApprovalRequestRow['status']` in the console,
`ApprovalRequestLite['status']` in app-shell), the open union each
already uses, rather than a bare `string`.
- Ablations (through `scripts/ablation-replace.mjs`, restored to blob ==
HEAD each time): `ranArmedBody` dropped from `runHasEnded` gives Tests 1
failed / 12 passed (the edit pin); the time test forced true gives 1
failed / 12 passed (the edit pin); the identity test dropped gives 1
failed / 13 passed (the rollback pin).
- Checks: targeted `approval-route.test.ts` +
`flow-route.integration.test.ts` Tests 42 passed;
`@objectstack/plugin-approvals` full suite Test Files 128 passed (128),
Tests 1940 passed (1940) at bfff5d1 (6080e34 adds only the two UI type
lines); `ApprovalDecisionPanel.stepLine-12491.test.tsx` Tests 20 passed
(20) at 6080e34; plugin-approvals and spec typecheck exit 0; spec
rebuilt and `check:generated` all 14 up to date; overlap-check clean
against origin/main and the open PR heads before each push. Three pushes
this round, not one: 30ec243 (S3), bfff5d1 (the rollback pin, once the
identity ablation showed that branch unpinned), 6080e34 (N3); CI on the
first two was cancelled by the next push. CI at 6080e34: 70 check-runs,
61 success, 9 skipped, 0 failed, every required context green; merges
cleanly with main.

## Verification

<details><summary>Targeted tests (code at 19f57ef; later commits touch
only the changeset, the docs page and one test import)</summary>

- `pnpm --filter @objectstack/plugin-approvals exec vitest run
--maxWorkers=2 src/approval-route.test.ts
src/flow-route.integration.test.ts`: VERDICT command-exit 0, Test Files
2 passed (2), Tests 34 passed (34).
- `pnpm --dir ui exec vitest run
packages/app-shell/src/views/approval-decision/ApprovalDecisionPanel.stepLine-12491.test.tsx
packages/app-shell/src/views/RecordApprovalsPanel.stepProgressVertical.test.tsx
packages/app-shell/src/views/RecordApprovalsPanel.servedRoute-26668.test.tsx`:
VERDICT command-exit 0, Test Files 3 passed (3), Tests 29 passed (29).
- `pnpm --filter @objectstack/plugin-approvals typecheck && pnpm
--filter @objectstack/spec typecheck`: VERDICT command-exit 0.
- `pnpm --filter @objectstack/spec check:generated`: all 14 generated
artifacts up to date (spec dist built after the contract edit).

</details>

<details><summary>Ablations (each through scripts/ablation-replace.mjs,
mutation proven on disk, restored, tree clean after)</summary>

- `flowRoute` outcome replaced by `undefined`: Tests 4 failed / 30
passed (the `flowRoute` unit case and the three integration outcome
pins).
- `runHasEnded` forced `false`: Tests 3 failed / 6 passed in the
integration file (every `ended: true` pin).
- The decision panel's `outcome` hand-off deleted: Tests 4 failed / 16
passed (every drawn-line case).

All three suites import source, not `dist/`, so no rebuild leg applies.

</details>

<details><summary>Local gates (dispatch-gates, derived at 19f57ef and
again at 1f6480a)</summary>

Derived by `node scripts/pm/dispatch-gates.mjs --commands` (120 families
once the docs page joined the diff); `--ran` reconciliation: 120 of 120
accounted for. 117 exit 0. Exit 3 (prerequisite not met in this
container, nothing measured; CI ran them green):

- `node scripts/check-plugin-teardown-shape.mjs --self-test`: exit 3
(shallow clone cannot reach the pinned positive control)
- `pnpm check:dual-build-cjs-loads`: exit 3 (reads built output of the
whole workspace)
- `pnpm check:i18n`: exit 3 (needs its package build closure; nothing
compared)

Exit 0:

- `node scripts/check-adr-0087-registration.mjs --base origin/main`
- `node scripts/check-adr-0087-registration.mjs --self-test`
- `node scripts/check-changeset-no-major.mjs --base origin/main`
- `node scripts/check-closing-keyword-parity.mjs`
- `node scripts/check-closing-keyword-parity.mjs --self-test`
- `node scripts/check-comment-mask-adoption.mjs`
- `node scripts/check-comment-mask-adoption.mjs --self-test`
- `node scripts/check-comment-mask-corpus.mjs`
- `node scripts/check-dev-prereqs.mjs --self-test`
- `node scripts/check-dts-emitted.mjs --self-test`
- `node scripts/check-empty-changeset.mjs --base origin/main`
- `node scripts/check-empty-changeset.mjs --self-test`
- `node scripts/check-issue-citations.mjs`
- `node scripts/check-plugin-teardown-shape.mjs`
- `node scripts/check-sdui-manifest.mjs`
- `node scripts/check-sdui-manifest.mjs --self-test`
- `node scripts/check-tenant-audit-census.mjs`
- `node scripts/check-tenant-audit-census.mjs --self-test`
- `node scripts/ci/assert-turbo-remote-cache.mjs --self-test`
- `node scripts/ci/plan-test-core-shards.mjs --self-test`
- `node scripts/ci/prune-turbo-cache.mjs --self-test`
- `node scripts/ci/snapshot-next.mjs --self-test`
- `node scripts/docs-audit/check-affected-docs.mjs`
- `node scripts/docs-audit/check-drift-comment.mjs`
- `node scripts/pm/check-governed-queue-guard.mjs --self-test`
- `node scripts/pm/release-rehearsal-clone.mjs --self-test`
- `node scripts/release-pending-publish.mjs --self-test`
- `pnpm --dir ui exec vitest run scripts/`
- `pnpm --filter @objectstack/lint run check:doc-formula-expressions`
- `pnpm --filter @objectstack/spec run check:api-surface`
- `pnpm --filter @objectstack/spec run check:authorable-surface`
- `pnpm --filter @objectstack/spec run check:browser-reachable-entries`
- `pnpm --filter @objectstack/spec run check:docs`
- `pnpm --filter @objectstack/spec run check:dual-source-exports`
- `pnpm --filter @objectstack/spec run check:duration-unit-keys`
- `pnpm --filter @objectstack/spec run check:empty-state`
- `pnpm --filter @objectstack/spec run check:entry-nameability`
- `pnpm --filter @objectstack/spec run check:error-code-provenance`
- `pnpm --filter @objectstack/spec run check:export-origins`
- `pnpm --filter @objectstack/spec run check:exported-any`
- `pnpm --filter @objectstack/spec run check:liveness`
- `pnpm --filter @objectstack/spec run check:llms-txt`
- `pnpm --filter @objectstack/spec run check:skill-refs`
- `pnpm --filter @objectstack/spec run check:strictness-ledger`
- `pnpm --filter @objectstack/spec run check:variant-docs`
- `pnpm --filter @objectstack/spec run check:yaml-examples`
- `pnpm check:adr-anchors`
- `pnpm check:adr-symbol-anchors`
- `pnpm check:changeset-gate-self-tests`
- `pnpm check:ci-filter-parity`
- `pnpm check:cli-command-ids`
- `pnpm check:closed-ceremony-text`
- `pnpm check:cross-package-test-inputs`
- `pnpm check:dispatcher-error-vocabulary`
- `pnpm check:doc-authoring`
- `pnpm check:driver-memory-census`
- `pnpm check:dts-closure`
- `pnpm check:engine-double-contract`
- `pnpm check:error-status-conformance`
- `pnpm check:gitlink-declared`
- `pnpm check:i18n-stale-fill`
- `pnpm check:issue-citations`
- `pnpm check:keyed-text-bounds`
- `pnpm check:lean-entry-closure`
- `pnpm check:logger-receiver-detach`
- `pnpm check:merge-driver`
- `pnpm check:nul-bytes`
- `pnpm check:object-def-param-keys`
- `pnpm check:objectql-double-limit`
- `pnpm check:optional-error-sink`
- `pnpm check:org-identifier`
- `pnpm check:page-declaration-shape`
- `pnpm check:platform-object-tenancy-census`
- `pnpm check:pm-expected-skips`
- `pnpm check:pm-prior-rulings`
- `pnpm check:published-files`
- `pnpm check:query-options-erasure`
- `pnpm check:refd-timer-probe`
- `pnpm check:registry-log-declared`
- `pnpm check:rest-log-spy-declared`
- `pnpm check:role-word`
- `pnpm check:settings-bind-window`
- `pnpm check:skill-identifier-liveness`
- `pnpm check:slot-lookup`
- `pnpm check:sourcemap-no-sources-content`
- `pnpm check:spec-docblock-symbol-anchors`
- `pnpm check:spec-parsed-alias`
- `pnpm check:system-context-census`
- `pnpm check:test-source-alias`
- `pnpm check:tier-file-adoption`
- `pnpm check:type-check-coverage`
- `pnpm check:type-check-debt`
- `pnpm check:undeclared-dep-imports`
- `pnpm check:vouch-for-reference-callers`
- `pnpm check:watch-hint-literal`
- `pnpm check:where-matcher`
- `node scripts/check-adr-links.mjs`
- `node scripts/check-adr-links.mjs --self-test`
- `node scripts/check-doc-route-spelling.mjs --advisory`
- `node scripts/check-doc-route-spelling.mjs --self-test`
- `node scripts/check-docs-section-name.mjs`
- `node scripts/check-docs-section-name.mjs --self-test`
- `node scripts/check-section-landing-index.mjs`
- `node scripts/check-section-landing-index.mjs --self-test`
- `pnpm --filter @objectstack/lint run check:doc-security-posture`
- `pnpm --filter @objectstack/spec run check:skill-examples`
- `pnpm check:corpus-claim-drift`
- `pnpm check:doc-anchors`
- `pnpm check:doc-frontmatter`
- `pnpm check:docs-audit-scope`
- `pnpm check:docs-redirects`
- `pnpm check:docs-single-h1`
- `pnpm check:docs-spec-enumerations`
- `pnpm check:docs-transcript-drift`
- `pnpm check:published-readme-links`
- `pnpm check:react-page-adapter-contract`
- `pnpm check:vendor-version-stamps`

</details>

- After the docs page and the test import landed: `pnpm
check:test-source-alias` exit 0 at 1f6480a (CI had flagged the decision
panel harness reaching the lazy `@object-ui/plugin-detail` load without
a module-top import; the harness now imports it at collection); the
edited harness file re-run, Test Files 1 passed (1), Tests 20 passed
(20).

CI at head 1f6480a: 61 success, 9 skipped, 0 failed of 70 check-runs;
every required context green (Lint & Repo Gates, TypeScript Type Check,
Test Core, Build Core, Governed Surface Queue Guard, Lint UI, Type Check
UI, Test UI, Build & E2E UI, Live E2E UI, Dogfood Regression Gate) and
Check Changeset green. Mergeable: clean.

NOT MEASURED locally: `Type Check UI` (`@object-ui/app-shell type-check`
needs the UI package closure built; the local run stopped on
missing-module errors only, none in a touched line). CI's `Type Check
UI` is the reading.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn)_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn

<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzg3ayWUHg9nLoybejn -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…am as approval feed items (objectstack-ai#37188)

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

Fixes objectstack-ai#35723

repo:objectstack#3 · os-support-ai · session_01WGufzg3KqwSpt61Y8ovKK7

Clause-②: no
Metadata-protocol: none

## 维护者速读

-
用户能看到什么变化:在走审批的记录详情页「动态」里,每个审批步骤(提交、通过、驳回、退回修改、重新提交、撤回、取消)都显示为一行,按读者的语言显示(中文读者看到「已批准
· 经理审批」),点「看审批」直接打开该记录的「审批」页签;以前这里看不到任何审批。
- 为什么做:记录详情页专题里「动态流审批一行」那一半——上一张卡只画了这一行的样子,但没有任何地方产出审批条目,这张卡补上产出方。
- 出错会怎样:最坏情况是动态里少了或多了审批行,或某行显示成英文;审批本身、审批页签和锁定都不受影响。撤回本 PR
后,已写入的审批行仍在动态表里保留最多 14 天,且失去本 PR 的可见性限制,会以普通系统行的样子展示给所有能看该记录的人。
- 要你做什么:无

## What changes

- **Producer (plugin-approvals, new module
`approval-activity-feed.ts`).** An `afterInsert` hook on the decision
log `sys_approval_action` appends one `sys_activity` row per step of
kind `submit`, `approve`, `reject`, `revise` (sent back for revision),
`resubmit`, `recall` and `cancel`, about the record the request governs.
Other kinds (reminder, reassign, thread comment, ...) write none, and no
decision comment rides on the row. An object with `enable.activities:
false` gets no entry, as the CRUD mirror writes none for it. Shape
follows ADR-0052 section 5, so no published vocabulary moves: `type:
'system'` (platform-only; the app activity door refuses it),
`metadata.kind: 'approval'` plus the step's action, its stored label and
the two machine names its label is translated by (`flow_name`,
`step_name`), `source_object: 'sys_approval_request'` / `source_id`
naming the request.
- **In the reader's language (route b, round 2).** `summary` stores the
English sentence from plugin-approvals' own catalog (`approvalActivity*`
in `translations/messages.ts`, ten ids added to all eleven shipped
packs); a new `sys_activity` middleware (`bindApprovalActivityLocale`)
re-composes it on `find` / `findOne` for a non-system read that carries
a locale, with the approvals door's own lookup (`readerLabelsFor`): the
sentence is `messages.approvalActivity*` in the reader's locale, and the
step label is `flows.FLOW.approvals.NODE.label` read the way the
approvals tab reads it, else the stored label. A list that projects
`summary` alone borrows the recognition columns and hands back only what
it asked for. A system read, a read with no locale or no `i18n` service,
or a key the pack misses serves the stored line. No `sys_activity` on
the deployment (no plugin-audit) means no write; a failed append never
fails the step and is logged once at `error` with consequence and fix.
`approval-service.ts` is untouched (overlap with PR objectstack-ai#37145 and branch
`claude/project-thread-x90m5y` avoided).
- **Read gate (same module).** A `sys_activity` middleware narrows
`find` / `findOne` / `count` / `aggregate` so an approval row is served
only when the approvals service would serve the caller its request
(`RequestVisibilitySource`, the same source the request-table gates
read). A read pinning `object_name` + `record_id` asks with that record,
so an object that opts into `enable.approvalsVisibleToReaders` serves
its readers too. Every non-approval row passes untouched; plugin-audit's
parent-record gate still applies on top; failure to resolve fails closed
for approval rows only. Count and rows agree.
- **Console (plugin-detail).** `activityRowToFeedItem` reads the triple
`type: 'system'` + `metadata.kind: 'approval'` + `source_object:
'sys_approval_request'` as the `approval` feed kind
(`APPROVAL_ACTIVITY_FEED_TYPE`), so `PRODUCED_FEED_TYPES` now contains
`approval` and the unproduced-kind diagnostic no longer names it. New
`RecordViewApprovalsContext` carries the stream's 「看审批」 callback into
`RecordActivityRenderer` and `RecordChatterPanel`.
- **Host (app-shell `RecordDetailView`).** The approval tag's opener is
extracted as `openRecordApprovals` (approvals panel if drawn, else the
审批 tab) and supplied through `RecordViewApprovalsContext` only when the
reader is served approvals; otherwise the line has no link.
- **Docs.** `content/docs/frontend/plugins/plugin-detail.mdx`:
`approval` joins the produced-kinds table (six produced, seven not); the
unproduced example becomes `call`.
- **Ledgers.** `approver-address-readers.test.ts` classifies the two new
`actor_id` reads as `display`; the tenant-audit write census for
plugin-approvals is regenerated (one new elevated `sys_activity`
insert); `content/docs/permissions/system-context.mdx` row 17 owns the
new middleware's `isSystem` read (its register regenerated with
`--write`).

## Round 2 (L1 REWORK on dc76347)

- **S1, route (b): the server re-composes on read.** It is the objectstack-ai#26167
precedent's own shape: plugin-audit's `activity-summary-message.ts`
stores the sentence plus its code and re-composes it per reader in a
`sys_activity` middleware, and this row's code is already on it
(`metadata.action`, now with `flow_name` / `step_name`). The step label
must be translated through the app's flows pack, which lives in the
server's `i18n` service and is read by the approvals door's
`reader-locale-labels` lookup; the console holds no such pack.
Server-side, every reader of the column (the record page, the API, an
export) gets the same line, and no console locale pack moves. Pinned for
a zh-CN reader: `已批准 · 经理审批` and `已提交审批`, with the step label from an
app flows pack.
- **S2:** handled by the zone (claim amended).
- **N1:** done in the same code path: `revise`, `resubmit` and `cancel`
write entries (`Sent back for revision · STEP`, `Resubmitted for
approval`, `Approval request cancelled`, the last attributed to no one),
each pinned.
- **N2:** the flag is honored, as the CRUD mirror honors it
(`audit-writers.ts` writes no activity row for an object with
`enable.activities: false`); pinned.
- **N3:** the step half is pinned exactly (`Approved · Manager review`,
`Rejected · Manager review`), plus the stored metadata.
- **N4:** the 维护者速读 revert sentence now says rows already written stay
up to 14 days and, without the read gate, are served to every record
reader as generic system lines.

## Tests

<details><summary>Readings, round 2 (head 06a3c76)</summary>

All local runs went through `scripts/pm/os-verify-lock.sh`; verdict
lines quoted. Round-2 head `06a3c7640b` (after merging `origin/main` at
`93bd45957b`).

- `pnpm --filter @objectstack/plugin-approvals exec vitest run` +
`typecheck` (head `06a3c764` minus the cancel pin): `Test Files 129
passed (129)`, `Tests 1929 passed (1929)`, `check:test-typecheck: OK`,
`VERDICT command-exit 0`.
- `src/approval-activity-feed-35723.integration.test.ts` at
`06a3c7640b`: `Tests 7 passed (7)` (approve/reject/recall, send back +
resubmit, cancel on record delete, muted timeline, zh-CN reader, reader
without approval access, record-reader opt-in).
- Ablation (S1): `node scripts/ablation-replace.mjs` replaced the
`bindApprovalActivityLocale(...)` call in `approvals-plugin.ts` with a
no-op (anchor 1 to 0, blob changed); the zh-CN pin went red (`Tests 1
failed | 6 passed (7)`, the six others green), restore verified (`blob
== HEAD`, `git diff HEAD` empty).
- Local gate subset: `dispatch-gates --ran` reconciles `106 derived, 104
run, 2 UNRUN`; 101 exit 0. `check:i18n` first exit 3 (PREREQUISITE NOT
MET), then its own one-command prerequisite build and re-run:
`check-i18n-bundles: OK (10 package(s) — all bundles in sync, no
undeclared authoring keys)`, `VERDICT command-exit 0`.
`check:system-context-census` (red in CI on `05d82f29`) fixed in
`f0b51c92`: `OK — 202 elevation read sites ... the generated register
(178 symbol(s)) matches the tree`, self-test all cases passed. NOT
MEASURED locally, CI runs them: `check:dual-build-cjs-loads`, `spec
check:skill-examples` (exit 3, unbuilt dist outside the closure); `pnpm
--dir ui exec vitest run scripts/` and `check:type-check-debt` (declared
narrowing: the first was OOM-killed in round 1, the second needs a
whole-workspace build; no `ui/` file and no package's type-check set
changed this round).
- `overlap-check --branch=claude/issue-35723-approval-feed-items`:
`VERDICT clean exit 0`.
- Round 1 readings (UI suites, record-page ablation) stand for the
unchanged `ui/` files: `RecordDetailView.*` 100 files / 858 tests,
plugin-detail 417 files, both `type-check` exit 0.
- Full dogfood: not owed (no `!` in the title, no `(narrowing)` arm).

</details>

## Acceptance notes

- `sys_activity` keeps its own lifecycle (rows reaped after 14 days);
the 审批 tab keeps the full history. Steps taken before this lands write
no backfilled rows.
- The console restates the three writer values (`recordActivityFeed.ts`)
because plugin-detail cannot depend on the server plugin; both sides are
pinned by tests.
- The producer reads the decision log rather than calling in from each
decision method, so a step the service learns to record elsewhere
reaches the stream with no second call site.
- New UI pin for the mapper and stream lives in a card-named file
`recordActivityFeed.approvalStep-35723.test.tsx` (it renders React; the
shared `recordActivityFeed.test.ts` is a non-JSX file). The record-page
pin joined the shared `RecordDetailView.harness.test.tsx` as its own
top-level block.

## Verification

First read (by risk):
1. `packages/plugins/plugin-approvals/src/approval-activity-feed.ts` —
`bindApprovalActivityReadGate` (who sees an approval row),
`bindApprovalActivityLocale` (the system-read pass-through and the
borrowed columns), and the producer hook's transaction and tenant
context.
2. `ui/packages/plugin-detail/src/renderers/recordActivityFeed.ts` —
`isApprovalStepRow`, the mapping branch.
3. `ui/packages/app-shell/src/views/RecordDetailView.tsx` —
`openRecordApprovals` / `viewApprovals`, a plain function below the
page's early returns (a hook there breaks hook order).

Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec
vitest run --maxWorkers=2
src/approval-activity-feed-35723.integration.test.ts` — expect 7 passed:
one entry per step (approve / reject / recall, send back and resubmit,
cancel on record delete), none on a muted timeline, a zh-CN reader
served `已批准 · 经理审批`, none served to a reader without approval access
while other entries stay, and served under the record-reader opt-in.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzg3KqwSpt61Y8ovKK7)_

https://claude.ai/code/session_01WGufzg3KqwSpt61Y8ovKK7

<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzg3KqwSpt61Y8ovKK7 -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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 tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Approvals batch lock read answers "not locked" for a master-detail line of a locked master, unlike the single-record read it claims to equal

2 participants