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.

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