Repository navigation
fix(plugin-approvals): a locked record's lines read as locked, and deleting the locked record still lands - #36135
Conversation
…ocked record's lines Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
…ed record's lines Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
…lines; a line stays locked against any other delete Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
… the record while pending Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
|
security#2 · sunhaolin · session_017xRBcRtGQS7L4qLKpL8stv {
"issue": null,
"status": "needs_decision",
"branch": "claude/sec2-vv32",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36135",
"session": "session_017xRBcRtGQS7L4qLKpL8stv",
"premise_still_valid": false,
"summary": "Delivered the parts of the order that hold whichever way the pending decision goes. The record-lock read (getRecordLock) now answers locked for a master_detail line of a locked record. Deleting a locked record while pending lands again with its lines and cancels the request, because the cascade leg of the held master's own delete is let through; a cascade from any other record is still refused. The docs page states both. The node-level switch is NOT implemented: main already locks lines whenever the node locks the record, and changing that default is a decision for the seat (open_questions).",
"tests": "plugin-approvals at 96774702: 126 files / 1815 tests passed; typecheck incl. check:test-typecheck OK. Red-then-green: record-lock-read base 2 failed / 6 passed, fix 8/8; detail-row-lock base (pre-fix lifecycle-hooks) 1 failed / 13 passed, fix 14/14. Ablation via scripts/ablation-replace.mjs (src-resolved suite, no dist): getRecordLock guard -> 2 failed; cascade yield -> 1 failed; sole-edge narrowing -> 1 failed; existing hook registrations beforeInsert/beforeUpdate/beforeDelete -> 3/4/2 failed. Every restore was blob == HEAD with git diff HEAD empty.",
"gates": "Local: dispatch-gates --commands at 96774702 derived 103 families; reconciliation with exit codes: 103 derived, 99 run, 4 NOT-MEASURED (exit 3 prerequisite: check-plugin-teardown-shape --self-test [shallow clone], spec check:skill-examples, check:dual-build-cjs-loads [unbuilt dists], check:i18n [CLI not built]), 0 UNRUN. Every other family exited 0. CI check-runs: in_progress at report time.",
"dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
"line_budget": "6 files, +298 / -9 against merged main dc10b3b4 (code +110 / -9, tests +166, docs +19, changeset +12)",
"files_changed": [
".changeset/sec2-vv32.md",
"content/docs/automation/approvals.mdx",
"packages/plugins/plugin-approvals/src/approval-service.ts",
"packages/plugins/plugin-approvals/src/lifecycle-hooks.ts",
"packages/plugins/plugin-approvals/src/detail-row-lock.integration.test.ts",
"packages/plugins/plugin-approvals/src/record-lock-read.integration.test.ts"
],
"deviations": [
"Order scope not fully implemented: the node-level switch was not added, because main already enforces the line lock under a later maintainer ruling; reported as needs_decision, not guessed.",
"Clause-②: no declared. getRecordLock now answers true for held lines where it answered false. The master-delete yield accepts a delete main refused, but main's refusal is unreleased, so nothing released is narrowed. No packages/spec change.",
"Branch worked from a worktree on the order-named branch claude/sec2-vv32, not claude/issue-N; main merged once (dc10b3b4) before the PR.",
"In this public copy, open_questions and summary are written at rule level (security-findings §2); the full fork is in the seat's final report.",
"Contract-tier L2 review of this PR is owed to the security seat; no mailbox knocked."
],
"mcp_calls": "1 — mcp__github__issue_read (read). No GitHub MCP write tool.",
"api_writes": "relay: advisory_read (1 read action), pr_create (POST /pulls + POST /issues/36135/assignees), and this comment via post-stamped.mjs (POST /issues/36135/comments)",
"open_questions": [
{
"question": "Line lock default and switch: keep the default-on line lock main ships (card #35599 ruling A), or move it behind a node-level switch?",
"options": [
"A keep main's default-on lock; no switch",
"B node-level switch, default off",
"C node-level switch, default on (opt-out)"
],
"recommendation": "withheld here; with the seat"
}
],
"security_findings": "withheld",
"out_of_scope_findings": [
"carrier: none · noted in the PR's Acceptance notes: a locked record whose line object has a second cascading relation stays undeletable while pending (fail-closed by design)"
]
} |
📓 Docs Drift CheckThis PR changes 1 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 62fa4130a2b5124d7f81550bbe33a4e984231acf && git checkout 62fa4130a2b5124d7f81550bbe33a4e984231acf
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e4f5e56c017ca2b2b028c7700b88c5ae9e677eed 6755be39c332e0fa374f28d8d063fa1324442e0a && git checkout -B drift-repro e4f5e56c017ca2b2b028c7700b88c5ae9e677eed && git merge --no-ff 6755be39c332e0fa374f28d8d063fa1324442e0a
node scripts/docs-audit/affected-docs.mjs --json e4f5e56c017ca2b2b028c7700b88c5ae9e677eed
|
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov Contract reviewHead-sha: REWORK. Reviewer: an isolated What holds
Owed, then a delta read
Nit
|
…y inside a transaction; pin the refused shapes Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
…ions Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
|
security#2 · sunhaolin · session_017xRBcRtGQS7L4qLKpL8stv {
"issue": null,
"status": "done",
"branch": "claude/sec2-vv32",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36135",
"session": "session_017xRBcRtGQS7L4qLKpL8stv",
"round": "rework 1 (delta on comment 7065210600)",
"premise_still_valid": false,
"summary": "Rework closed. (1) A held record's delete removes its lines only inside an open transaction (ctx.transaction on the cascade leg). On a datasource that declares supports.transactionsUnsupported, or a cascade across datasources, the whole delete is refused 409 RECORD_LOCKED, and the record, its lines and its pending request stay. (2) Docs and changeset now qualify 'deleting a different record never removes a locked line': when the locked record is itself a master_detail child, deleting its parent removes it and its lines and cancels its request (pinned). (3) The two documented fail-closed shapes are pinned: a junction under two cascading masters, and master_detail plus a cascading lookup. Nit: the docs now say the whole delete is refused 409 RECORD_LOCKED. Main merged first (e987cc90). No node switch, per the seat's relay of the maintainer's 2026-11-22 ruling.",
"tests": "plugin-approvals at 3ffe6c3d: 126 files / 1821 tests passed; typecheck incl. check:test-typecheck OK. detail-row-lock.integration.test.ts at 62481a13: 20/20. Red before the transaction guard: the two no-transaction pins failed (DELETE_RESTRICTED where RECORD_LOCKED was expected; the delete landed). The two fail-closed shape pins already refused on the base; a first draft of them also asserted 'no cancel call at all', which the rolled-back line legs' afterDelete contradicts, so they now assert that the held record's request is not cancelled. Ablation of ' && ctx?.transaction != null' through scripts/ablation-replace.mjs: 2 failed / 18 passed, restored (blob == HEAD, git diff HEAD empty). The first ablation attempt used an empty replacement, which the tool refuses as uncountable; it ran no test, and the re-run used a non-empty replacement.",
"gates": "dispatch-gates at 3ffe6c3d: 103 derived. One red, check:query-options-erasure (test surface 236 -> 237 from an as-any on new pins), fixed in 62481a13 by typing the options; re-run exit 0, at 236. Reconciliation at 62481a13: 103 derived, 101 run, 2 NOT-MEASURED (exit 3 prerequisite: check-plugin-teardown-shape --self-test [shallow clone], spec check:skill-examples), 0 UNRUN. CI: in_progress at report time.",
"dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
"line_budget": "this round: 4 files changed (lifecycle-hooks.ts +20, detail-row-lock.integration.test.ts +219, approvals.mdx +16/-6, changeset 1 line)",
"files_changed": [
".changeset/sec2-vv32.md",
"content/docs/automation/approvals.mdx",
"packages/plugins/plugin-approvals/src/lifecycle-hooks.ts",
"packages/plugins/plugin-approvals/src/detail-row-lock.integration.test.ts"
],
"deviations": [
"The review record the seat named (the newest security#2 comment on #36135) was not on the PR when read (2 comments, 0 reviews). The rework was taken from the seat's session message.",
"Added one pin beyond the ask, the held-record-as-detail-row case, because the docs now state it.",
"PR body not edited (dev writes the body only at pr_create); this comment carries the delta."
],
"mcp_calls": "4 total, all reads: issue_read x1, pull_request_read x3 (check_runs, comments, reviews). No write tool.",
"api_writes": "4 relay writes total: advisory_read, pr_create, report comment 7065210600, and this comment (POST /issues/36135/comments)",
"open_questions": [],
"security_findings": "withheld",
"out_of_scope_findings": []
} |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov Delta read at Closed
Owed
|
…y inside an open unit of work Claude-Session: https://claude.ai/code/session_017xRBcRtGQS7L4qLKpL8stv Co-authored-by: Claude <noreply@anthropic.com>
|
security#2 · sunhaolin · session_017xRBcRtGQS7L4qLKpL8stv {
"issue": null,
"status": "done",
"branch": "claude/sec2-vv32",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36135",
"session": "session_017xRBcRtGQS7L4qLKpL8stv",
"round": "rework 2 (delta on comment 7074252234)",
"premise_still_valid": false,
"summary": "Rework 2 closed at d2056107. (1) The cascade yield now needs an OPEN unit of work: a ctx.transaction handle the engine does not report closed (new inOpenUnit, reading the engine's isClosedUnitHandle structurally and failing closed when the engine cannot answer). A delete carrying a closed unit's handle is refused 409 RECORD_LOCKED whole. (2) approvals.mdx states the accepted rule: server code that owns the transaction must not catch the refused delete and commit over it. (3) Docs and changeset add the case of a record and its lines together on a non-default datasource, and widen the one exception to a held record that is a lookup child with deleteBehavior 'cascade'. (4) PR body patched through the relay with a signed trailer: different-record exception, no-transaction refusal, 29-test count and current gates.",
"tests": "plugin-approvals at d2056107: 126 files / 1822 tests passed; typecheck incl. check:test-typecheck OK. Two pin files: 29/29. New pin: cascade split across two sqlite datasources, delete carrying a finished transaction's handle. Base (handle-present check only): DELETE_RESTRICTED. Fix: RECORD_LOCKED 409, record and 2 lines intact, request pending. Ablation of the open-unit test ('return true' for any handle) via scripts/ablation-replace.mjs: 1 failed (DELETE_RESTRICTED), 20 passed. Restored with blob == HEAD and git diff HEAD empty. The legitimate atomic-path delete pin stays green, so the real engine reports the atomic cascade's handle as open.",
"gates": "dispatch-gates at d2056107: 103 derived, 102 run, 1 NOT-MEASURED (exit 3, check-plugin-teardown-shape --self-test, shallow clone), 0 UNRUN. Every other family exited 0, check:query-options-erasure included. CI on d2056107: in_progress at report time.",
"dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
"line_budget": "this round: 4 files (lifecycle-hooks.ts open-unit predicate, MinimalEngine member and docblock; detail-row-lock.integration.test.ts +1 describe; approvals.mdx; changeset)",
"files_changed": [
".changeset/sec2-vv32.md",
"content/docs/automation/approvals.mdx",
"packages/plugins/plugin-approvals/src/lifecycle-hooks.ts",
"packages/plugins/plugin-approvals/src/detail-row-lock.integration.test.ts"
],
"deviations": [
"Open-unit test uses the engine's isClosedUnitHandle structurally on the hook's MinimalEngine, not @objectstack/objectql's exported openTransactionKind: objectql is only a devDependency of plugin-approvals, and importing it would add a runtime dependency to a published package. If the engine member were renamed, the yield is withheld (safe) and the atomic-path delete pin goes red (loud).",
"Not pinned (source reading plus the seat's measurement): record and lines on one non-default datasource (the cascade plan is 'split' when any participant is off the default driver, so no unit opens), and a held lookup(cascade) child going with its parent (no master_detail edge on the held record, so the detail-row lock does not guard its own delete).",
"Correction to rework 1's report: the Contract review record (comment 7073815672) did exist; my read raced its posting."
],
"mcp_calls": "8 total, all reads: issue_read x1, pull_request_read x6 (check_runs x3, comments, reviews, get, status counted once), get_job_logs x1. No write tool.",
"api_writes": "6 relay writes total: advisory_read, pr_create, report comments 7065210600 / 7074252234, issue_patch of the #36135 body, and this comment",
"open_questions": [],
"security_findings": "withheld",
"out_of_scope_findings": []
} |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov Contract reviewServed-tier: ① Derived judgmentsA locked record's
Review trail:
② Semver level
③ Boundary flagsThe second-cascade refusal, the transaction rule and the catch-and-commit rule are accepted by the seat and documented. SQL push-down: none added. ④ Design judgmentThis holds against the maintainer's ruling of 2026-11-22: the default-on line lock stands, and no switch is added. No must-fix or should-fix is open at this head; only nits remain. Implemented-by: VERDICT: PASS |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov 席位记录 · ACCEPT · head 维护者速读
席位意见:ACCEPT。经过三轮审核和返工,应修项已全部关闭。 席位核对
|
…bjectstack-ai#36306) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP3RHGWUG7UH3fNa4tBa9UC)_ repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1 Fixes objectstack-ai#36035 Clause-②: no Metadata-protocol: none ## 维护者速读 - 审批动态里「无人可审」那条系统说明不再显示岗位内部名:中文读者看到岗位的中文名(如「销售经理」),没有翻译时用岗位自己的显示名,都没有才退回内部名;英文审计原文不变。 - 接着上一轮「转交给管理员说明用岗位显示名」的修复,补上它留下的「无人可审」说明,属于控制台核心业务操作体验专题。 - 只改读取时的显示,库里存的审计原文和旧请求的说明都原样保留,转交规则不动;出问题可直接撤回。 - 无。 ## What changes 1. **The note stores its literals as a reference.** `no-approver-note.ts`: a new note stores `slots` (the slate's `type:value` literals, `noApproverSlots`) in the `__noApproverNote` snapshot entry instead of the pre-composed `who` string. `noApproverWho(slate, positionLabel?)` composes `type 'value'`, naming a position by the label `positionLabel` answers, else by its name. `noApproverSentence` / `noApproverNoteText` take an optional `positionLabel` and compose from `slots`; a note that stored `who` (written before this change) is rendered from that string exactly as before. `noApproverNoteOf` reads either shape. 2. **The read names the position the way objectstack-ai#36030 does.** `ApprovalService.localizeRoutingNotes` builds the label map for the note's positions through the existing `notePositionLabels` (reader's pack `positions.NAME.label`, else the declared `label` from `positionLabelSource`, else nothing) and passes it to `noApproverNoteText`. No second resolver: the position-name extraction is `slatePositions`, factored out of `adminRescuePositions` in `admin-rescue-note.ts`, which now delegates to it. 3. **The stored English is unchanged.** The write site (`approval-service.ts`, one hunk) stores `slots`; the row's `comment` is still `noApproverNoteText(note)` with no render, which composes the same `position 'NAME'` English as before. The refusal remedy and the submitter's notice still compose from the slate with no labels (see Acceptance notes). 4. **Docs.** `content/docs/automation/approvals.mdx`, the no-approver paragraph: the note names the position by its label for a reader and by its name in the stored text. `approval-service.ts` carries three small hunks (import, the write line, the read line); the note module could not carry the write and the read alone. `overlap-check` is clean against objectstack-ai#36295, objectstack-ai#36247, objectstack-ai#36144 and objectstack-ai#36135, which share that file. ## Tests <details><summary>Pins: admin-rescue-named-slate.integration.test.ts, new describe "[objectstack-ai#36035] the no-approver note names its position by its label"</summary> The suite's real `ApprovalService` on `ObjectQL` over in-memory SQLite, an organization with no administrator (so the request opens on the slate that names no one), the plugin catalog plus an app pack in a real in-memory `i18n` service, and a `positionLabelSource` declaring `sales_manager` as "Sales Manager". - the snapshot stores `{ action_id, slots: ['position:sales_manager'] }`; the row stores the English with `position 'sales_manager'`; a no-locale read is served that English; - zh-CN (pack label 销售经理) reads `...担任 position '销售经理' 的成员...` and no `sales_manager`; - en and ja-JP (no pack key) read `position 'Sales Manager'`; - a position no pack and no declaration knows (`treasury`) keeps its name; - CONTROL: a note rewritten to the old stored shape (`who: "position 'sales_manager'"`) renders exactly as before in zh-CN, en and with no locale. The pin went into the existing harness file as a sibling of the objectstack-ai#35418 describe rather than a new file: it reuses that file's engine, organizations and `open` helper (AGENTS.md: a new pin for a component with a shared harness goes into that file). </details> <details><summary>Ablations at 8a83eed (scripts/ablation-replace.mjs, each restored to the HEAD blob with an empty git diff HEAD)</summary> - A1 read site passes no `positionLabel`: 2 failed (zh-CN pack label, declared label) / 3 passed. - A2 write site stores the composed `who` again: 3 failed (snapshot shape, zh-CN, declared) / 2 passed. - A3 an unknown position's name dropped: 3 failed (snapshot English, unlabelled name, legacy row) / 2 passed. - A4 a stored `who` no longer read: 1 failed (legacy CONTROL) / 4 passed. </details> <details><summary>Runs at 8a83eed</summary> - `pnpm --filter @objectstack/plugin-approvals test`: Test Files 126 passed (126), Tests 1813 passed (1813). - `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0 (test layer held at its ledgered debt). - eslint over the four changed source files: exit 0. </details> ## Acceptance notes - The `__noApproverNote` snapshot entry is internal to `@objectstack/plugin-approvals` (nothing in `packages/spec`, `ui/` or the package index reads it); new notes carry `slots`, older ones keep `who`, and the read accepts both. - Same family, not in this PR, carried by objectstack-ai#36308 (class a, user-visible): the decision door's refusal remedy and the submitter's `approval.comment` notice compose the no-approver sentence from the slate with no labels, so they still name the machine name (`...holds position 'legal'...`, pinned in `exclude-submitter.integration.test.ts`). The notice is rendered per recipient at delivery, so labelling it needs the recipient's locale, not the reader's. - Observation, carried by objectstack-ai#36308 (class a, user-visible): the `{{who}}` hole carries the approver type's English machine token in every pack, so a zh-CN reader now reads `担任 position '销售经理' 的成员`, where the administrators' note translates the type (`岗位「销售经理」`). Translating the type needs a per-type clause in all eleven catalogs; out of this card's scope. ## Verification Read first: `no-approver-note.ts` (`noApproverWho`, `noApproverSentence`, `noApproverNoteOf` — the old/new shape split), the `localizeRoutingNotes` hunk in `approval-service.ts`, the write hunk at `slateSource = 'no_one'`. Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec vitest run src/admin-rescue-named-slate.integration.test.ts -t 36035` — expect 5 passed. <details><summary>Local gates at 8a83eed</summary> `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran`: 103 derived families accounted for, 103 run, 0 NOT-MEASURED (a derived zero: every family recorded an exit code, all 0). Four first answered exit 3 (prerequisite) and were rerun after it was met: `check-plugin-teardown-shape --self-test` (pinned fixture commit fetched), `check:skill-examples`, `check:i18n` and `check:dual-build-cjs-loads` (after the build closure finished). `overlap-check`: clean against origin/main and 4 open PRs. CI families: not yet reported at open. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…k before it edits, and a page's locks are read in one request (objectstack-ai#35795) (objectstack-ai#36295) <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu3ktGWQBYiYJq1ThpuDKTbF)_ repo:objectstack#1 · os-sales · session_01L6bhgXSK9qt8je9QbZvhKb Fixes objectstack-ai#35795 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 列表里直接改格子时:如果这条记录「是否被审批锁住」或「我能不能改这条」还没查回来,双击、回车、F2 或直接打字都不会立刻弹出编辑框,格子上先显示「正在确认这条记录能否编辑…」;答案一回来,没锁就自动打开编辑框(打的那个字也保留),锁了就显示「此记录正在审批中,已锁定。」。不会再出现「能进编辑、保存才被拒」。 - 查询中点了别的格子,就放弃这次等待,不会突然在别处弹出编辑框。查询中点开关、粘贴、清空:同样先提示正在确认,答案回来没锁才写入,锁了就不写并说明原因。 - 一页数据只发一个锁查询:第一次点格子时把整页的锁一起问;之后用方向键走动不再发请求。新增服务端批量接口 `POST /api/v1/approvals/records/:object/locks`(一次最多 200 条,读不到的记录和不存在的一样答 null),SDK 有对应方法。 - 风险:查询很慢时,用户第一次操作要等一下才出编辑框;没装审批服务的部署照旧(501 后不再问)。可直接撤回本 PR 回到原样。 - 需要你决定的:无。 ## What changes **Server (new route, contract, SDK).** - `IApprovalService.getRecordLocks?(object, recordIds, context)` (`packages/spec/src/contracts/approval-service.ts`, optional like `getRecordLock`): entry `i` answers `recordIds[i]` exactly as `getRecordLock` answers it (`{ locked }`, or `null` for an unreadable or missing record, never told apart). New export `APPROVAL_RECORD_LOCKS_MAX_RECORD_IDS = 200` (the explain batch's cap, so a page splits the same way for both reads). `api-surface/contracts.json` and `export-origins/contracts.json` regenerated. - `ApprovalService.getRecordLocks` (plugin-approvals): two engine reads whatever the page size: the caller's `id $in` read of the ids (the same anchor `getRecordLock` reads as the caller), then one pending-request lookup judged by the record-lock hook's own judgement through the new `recordsHeldByLockingApproval` (`lifecycle-hooks.ts`, the many-record form of `recordHeldByLockingApproval` over the same `lockingRequestsForRecords`). - `POST /api/v1/approvals/records/:object/locks` (`approvals-routes.ts`): body `{ "recordIds": [...] }` answers `{ success: true, data: { records: [{ recordId, locked }] } }` in order, `locked: null` where the single read answers 404. Closed query set EMPTY (`APPROVAL_RECORD_LOCKS_PARAMS`); the body is closed too (`readRecordLocksBody`): any other key, a non-list, a non-string or blank id, an empty list or more than the cap is refused whole with `400 VALIDATION_ERROR`, the service never asked. A service without `getRecordLocks` answers 501, never one `getRecordLock` per id. Route ledger row `sdk` → `client.approvals.getRecordLocks(object, recordIds)`. **List grid.** - `useRowApprovalLocks` asks the locks of the page in one request per `APPROVAL_RECORD_LOCKS_MAX_RECORD_IDS` ids when a cell is first selected (`ObjectGrid`'s `onCellSelect` passes the selected row plus the page's ids); rows already asked are not asked again, rows a later page brings are asked on the next select. It exposes `settling(recordId)`: the read the row waits on while it is on the wire. - `useRecordCrudVerdicts` exposes `settling()`: the explain questions on the wire as one promise (read from a ref, so it sees a question sent since the last render). - `ObjectGrid.describeCell`: when the cell has no read-only reason yet but the row's lock read, or its `update` verdict (when still unknown), is on the wire, the facts carry `checking: { text, settled }`. - `@object-ui/components` `GridCellFacts.checking` (optional, new): `data-table`'s `attemptEdit` shows `text` on the cell, remembers the edit (with its typed seed) and asks it again when `settled` settles, unless another cell was selected, a newer edit was asked or an editor is open by then. A toggle, paste or clear asked meanwhile shows `text` and writes nothing (an intrinsic refusal such as "required" is still said first). - i18n: `grid.readOnlyReason.checking` in all 11 locales plus the plugin's English fallback. Docs: `content/docs/automation/approvals.mdx` ("Reading the locks of a page of records"). Changeset `.changeset/35795-batched-record-lock-read.md` (patch on the seven packages the diff moves; `Metadata-protocol: none` ⇒ patch). ## Why PR objectstack-ai#35747 read a row's lock with one `GET …/:recordId/lock` per selected row, sent on a double-click's first press and needed on its second. A slower answer let the editor open on a locked record and only the save was refused; the record verdict had the same window, and arrow keys sent one read per row (the L2 record 7034067196, S3 and N2). objectstack-ai#35684 rules out 「能进编辑、保存被拒」. **Batch route over projection** (premise, accepted by the seat with the claim 7072869185): the lock is the approvals plugin's own judgement; projecting it into `GET /data/:object` would teach the data layer about approvals or add a virtual-field protocol and charge every list read, while a batch route is the same shape as the explain batch the list already sends, asked only when the reader first acts on a cell. ## Small calls made in this thread (Sales 22:19:27Z: listed here) - **Wait, then open** (the card's first arm) rather than "open nothing, say checking": the premise proposed the latter; building it showed that a real double-click on a fresh page (and every Playwright `dblclick`) would then always need a second double-click. The waiting edit is dropped by selecting another cell, so nothing opens elsewhere. - The lock and verdict of a page are asked on the first cell select (lazy, the objectstack-ai#34208 posture), not on first paint. - The same cap as explain (200); a body with any other key is refused, like an unknown query name. - A row the caller cannot read (`locked: null`) and a failed read fall back to the `approval_status` column (fail open, as before; the server still refuses a locked write). - No principal key on the lock answers (unchanged from objectstack-ai#35747): they are dropped on any data change of the object and on unmount. ## Verification Each new pin was run against the fix, then with the fix ablated. - `ObjectGrid.cellSelection-35684.test.tsx`, new top-level `describe` "an edit waits for the row's lock and verdict (objectstack#35795)", 7 cases with fake timers for the slow reads: a slow lock read on a locked row says checking for 1999 ms and then locked, never an editor; on an unlocked row the editor opens by itself when it answers; a key typed while checking is the editor's value; a slow verdict holds it the same way; selecting another cell drops the wait; a page sends one lock read and the arrow keys send none (lock or explain); a 501 deployment is asked once and edits. The existing lock case now reads the page in one request. Ablating the `checking` branch of `attemptEdit`: 5 of the 7 red, restored. - `rest-approvals-record-lock-route.test.ts`, new top-level `describe` for the route: preservation (service asked once with the ids in order and the caller; one entry per id; a full page at the cap), nine refusal shapes (400 + nested `VALIDATION_ERROR` + service never called), the empty closed query set, 501 when only `getRecordLock` exists (and it is not called), a read refusal relayed at its own status. - `record-lock-read.integration.test.ts` (real ObjectQL + better-sqlite3 + `ApprovalsServicePlugin.start()`), new top-level `describe`: for each of submitter, approver and a non-participant reader, the page answer equals `getRecordLock` per id (repeated ids, unreadable, missing); two engine reads for a page of three; an outsider is refused 403 as for one record; a blank id answers null; deciding unlocks the page as the hook does. - `client.test.ts`: one POST, object segment encoded, body `{ recordIds }`. - Local runs on the merged tree: see the next section. **Local runs** (merged tree, main `a5a5312f` + this branch, after `pnpm install --frozen-lockfile && pnpm build`): - `@objectstack/plugin-approvals` test: 126 files / 1,812 passed. `@objectstack/client`: 59 / 820 passed. `@objectstack/spec`: 869 files / 27,877 passed. `@objectstack/rest`: first run 2 red (the two write-route ledgers had no row for the new POST route); rows added (`no-record-echo` in the objectstack-ai#8497 tripwire, a driven `approvals.getRecordLocks` row in the hook-refusal ledger), both files now 737 / 737. - Typecheck clean: rest, plugin-approvals, client, spec, ui plugin-grid, components, i18n. - UI (`packages/plugin-grid/ components/ plugin-list/ plugin-detail/ i18n/`): first run 18 red in 4 files: a paste / toggle / digit was dropped while checking (fixed: those writes now wait too, as the edit does), and `zh-Hant.ts` was not regenerated (fixed with `gen:zh-hant`). The six affected files then 102 / 102. A second full run of these packages is in progress; its result goes on this PR. - `spec check:generated`: `api-surface` and `export-origins` regenerated (one line each). `overlap-check.mjs`: clean against main and every open PR sharing a file (objectstack-ai#36135, objectstack-ai#36144, objectstack-ai#36208). - Added after the seat's ask: `ObjectGrid.autosave-35685.test.tsx`, new top-level `describe` (2 cases, fake timers): a paste is not written for 1999 ms of a slow lock read and is written when it answers unlocked; on a locked answer it is never written and the cell says why. Ablating the wait in `writeCell`: both red, restored. ## Acceptance notes - **objectstack-ai#36135** (draft) makes `getRecordLock` also answer `true` for a `master_detail` line of a locked record. This PR's batch answers the record half only. Whichever lands second carries the other half into `getRecordLocks` (the line half batched: one FK read of the page, one lookup per master object). `overlap-check.mjs` reads this branch clean against objectstack-ai#36135 (it was moved off the lines objectstack-ai#36135 edits). - The notice text stays on the cell until the answer arrives or the reader moves; it is not a toast. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (a contract interface member and a constant) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is the maintainer's summary, in the maintainer's language). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgXSK9qt8je9QbZvhKb)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgXSK9qt8je9QbZvhKb <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgXSK9qt8je9QbZvhKb --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The rule: a locked record's lines are locked with it, and deleting the locked record itself still lands. No node switch is added and no default moves: lines lock whenever the record's approval node locks the record, as
mainalready enforces.ApprovalService.getRecordLock(the record-lock read behindGET /api/v1/approvals/records/:object/:recordId/lockandclient.approvals.getRecordLock) now answers{ locked: true }for amaster_detailchild row while its master is held by a locking pending approval. It used the record-lock judgement only, so it answered{ locked: false }for exactly the rows the detail-row lock refuses with409 RECORD_LOCKED. The newdetailRowHeldByLockingApproval(inlifecycle-hooks.ts) asks the hook's own question: the row's master edges, read off its FK columns as SYSTEM, each judged by the one shared lookup (lockingRequestsForRecords). The caller-scoped readability anchor is unchanged, so a row the caller cannot read still answersnull, like a missing id.master_detailcascade legs of that delete, so a locked record with lines could not be deleted (409 RECORD_LOCKED). The detail-row lock'sbeforeDeletenow lets a cascade leg through on one edge only. That leg carries the engine's declared markerctx.referentialCascadeDelete, and the detail object's single cascade-capable relation must be themaster_detailedge to the held master, which makes the record being deleted that master. The leg must also run inside an open unit of work: actx.transactionhandle the engine does not report closed. A delete with no open transaction is refused whole with409 RECORD_LOCKED, and the record, its lines and its pending request stay. That covers a datasource that declaressupports.transactionsUnsupported, a cascade across datasources, a record and its lines together on a non-default datasource, and a handle whose unit has already finished. Every other shape is refused too: a junction under two cascading masters, or a line that also has alookupdeclaringdeleteBehavior: 'cascade'. So deleting a different record never removes a held record's line, with one exception. When the held record is itself the child of a record whose delete cascades to it (amaster_detailchild, or alookupchild withdeleteBehavior: 'cascade'), deleting that parent removes the held record with its lines and cancels its request.content/docs/automation/approvals.mdxnow states that lines are locked with the record (insert / update / delete / reparent, the carried exemptions,lookupchildren untouched). It also states what deleting the record while pending does and when that delete is refused, that server code owning the transaction must not catch the refusal and commit over it, and that the lock read answers for a line.Why
A page reads the lock to decide whether to offer an edit, so the read must answer the same way the server refuses. And a pending record must stay deletable, because the delete-cancel linkage is the only route left once the record is locked.
Tests
Each new pin was run against the base first (red), then with the fix (green), and each guard was ablated (red) and restored (
git diff HEADempty, blob equal to HEAD).record-lock-read.integration.test.ts: new top-leveldescribe("a locked record's lines are locked with it — the record-lock read answers for a detail row too"), 4 cases on the realApprovalsServicePlugin.start()rig, with two line objects added to it. Base: 2 failed / 6 passed (expected { locked: false } to deeply equal { locked: true }). Fix: 8 / 8. Ablating the new|| detailRowHeldByLockingApproval(...): 2 failed, restored.detail-row-lock.integration.test.ts, four new top-leveldescribes:master_detailplus a cascading lookup, are refused with nothing removed. Base: the delete case failed (refusedRECORD_LOCKED). Ablating the cascade yield: 1 failed. Ablating the sole-edge narrowing: 1 failed.supports.transactionsUnsupported: a held record with a laterrestrictrow, a held record with lines only, and a control in which an unheld record deletes. Base: 2 failed (DELETE_RESTRICTED; the delete landed).DELETE_RESTRICTED.DELETE_RESTRICTED). Every ablation was restored.beforeInsert3 failed,beforeUpdate4 failed,beforeDelete2 failed, each restored.d2056107:pnpm --filter @objectstack/plugin-approvals test: 126 files / 1822 tests passed.typecheck(incl.check:test-typecheck) OK.Acceptance notes
["held_sheet_a"]for the master object and[]for its line object. An approver reads lines through the line object's own access: acontrolled_by_parentdetail follows the master's readability (source reading, not run on a kernel), and aprivatedetail owned by the submitter is not readable to them.Verification
Two-minute check:
pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/record-lock-read.integration.test.ts src/detail-row-lock.integration.test.tsshould report 2 files and 29 tests passed.Files to read first, by risk:
packages/plugins/plugin-approvals/src/lifecycle-hooks.ts(thecascadeSourcehunk inbindDetailRowLockHookandsoleCascadeEdgeOf), theninOpenUnitanddetailRowHeldByLockingApprovalbeside it, thenapproval-service.tsgetRecordLock.Local gates at d205610 — 103 derived, 102 exit 0, 1 NOT MEASURED
Derived with
node scripts/pm/dispatch-gates.mjs --commandsatd2056107and reconciled with--ran(exit codes recorded): "103 derived, 102 run, 1 NOT-MEASURED, 0 UNRUN". The one NOT MEASURED ischeck-plugin-teardown-shape --self-test, refused on a local prerequisite (exit 3, shallow clone) and left to CI. Every other derived family exited 0, among themcheck:query-options-erasure,check:nul-bytes,check:doc-authoring,check:engine-double-contract,check:test-source-alias,check:system-context-census,check:i18nandcheck-empty-changeset. CI's own check-runs are the verdict for everything else.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses. (CI owns the repo-wide run)main, one pull request.packages/spectouched: not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code