Skip to content

One lock read owned by the data layer: "is this record locked, and by which lock" for closed states and pending approvals (ADR-0162 item 2) #37770

Description

@objectstack-fleet

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Filing gate: ③ maintainer-directed · Source: ADR-0162 Execution item 2 (accepted by merge 972114d)

维护者速读

  • 做什么:提供一个统一的查询,任何界面或程序问一次就知道某条记录是不是被锁住,以及是「审批中」还是「已关闭」。
  • 用户会看到什么:界面能把「审批中,请等待」和「单据已关闭」分开说清楚,不再给出一个点了会被拒的编辑入口。
  • 不做会怎样:平台已经会拒绝对已关闭单据的修改,但界面不知道原因,只能在用户点了保存之后才报错。
  • 顺序:排在声明和执行那张卡之后;没装审批功能的应用也能用这个查询。

What happens

The only lock read on main belongs to the approvals family. IApprovalService.getRecordLock and getRecordLocks (packages/spec/src/contracts/approval-service.ts) answer whether a record is held by a locking approval, through two routes in packages/rest/src/approvals-routes.ts and two SDK methods (client.approvals.getRecordLock, getRecordLocks). They know nothing of closed states, and an app that installs no approvals has no lock read at all.

ADR-0162 D9 decides one read for both producers. The maintainer adopted it on 2026-11-26, 「全部按推荐」 (ruling record 7200732942 on #36253), with the point that every caller who can read the record is told the lock and its reason.

Expected

  • The answer (D9). For one record, as the caller: { locked, lockSource?: 'record' | 'master', lockReason?: 'closed_state' | 'approval' } | null. null when the caller cannot read the record or it does not exist. lockSource and lockReason are present exactly when locked is true.
  • Two producers, composed. The engine's closed-state judgement and the approvals plugin's pending-request judgement, through a seam that is internal to the two packages. A third producer is a new decision.
  • It exists without the approvals plugin.
  • Who is told. Every caller who can read the record, whether or not it may write it, and whether or not field permissions let it read the state field. The read never says which field or value closed the record, and carries no request id or participants.
  • One answer when several hold. closed_state before approval; within a reason, master before record.
  • lockSource and delete. The approvals contract reads "may still be deleted" off lockSource: 'record'. On this read that holds only under lockReason: 'approval'. Under closed_state a caller's delete is refused for either source.
  • Readable means what it means today, door by door. The single read and the page read each keep the readability anchor of their approvals counterpart. The page form keeps the bound of 200 ids.
  • Doors. The data family gains the read for one record and for a page of records, with SDK methods beside the other data reads. The path spelling is this card's.
  • First-party askers move to it. The console's record page, grid and line grid ask this read (the console's own rendering is the console card, item 4). The upload-link door asks it before it issues a link, and chooses between its two sentences by the reason.
  • Not touched. The approvals-family routes, their SDK methods and the two contract members stay exactly as published and go on answering for approvals only. The record page's approvals part keeps its lock as the approvals producer's answer. What becomes of those routes is the card for item 6.

Done when

  • The read answers each combination, with a test: closed by its own state, a line of a closed master, held by an approval, a line of a held master, both locks at once, neither, unreadable, missing.
  • It answers with the approvals plugin absent.
  • A reader whom field permissions keep from the state field is told closed_state and nothing of the field or the value.
  • The page form refuses more than 200 ids and answers entry by entry.
  • The answer shape says how lockSource behaves under approval when the approvals implementation omits it: either the internal seam requires the source, or the member stays optional under approval. The approvals contract lets an implementation omit it today (review note N12).
  • The upload-link door refuses with the closed-state sentence on a closed record and with the approval sentence on a held one.
  • git diff shows no change to the approvals-family routes, SDK methods or contract members.
  • Reference docs for the two data-family routes and the SDK methods.

Category ③: maintainer-directed. A build card of ADR-0162, child of #36253.
Grade: area:data · Feature · n/a (not a defect) · reach: every first-party client of a declaring app · evidence: read (ADR-0162 D9 and its Readings)
Suggested-grade: p2 · part of the feature #36253, and it gates the console card
Size: L (the engine, the approvals seam, the REST routes, the SDK, the storage service). Could split into the read with its seam, and the doors with the askers.
Business reason: carried from #36253. Without it a client cannot tell a closed document from one in approval, and offers edits the server refuses.
Reader: seat 2 (repo:objectstack#2), a card thread, effort high.
Blocked-by: #37768 (item 1) (the engine's closed-state judgement is one of the two producers).
Clause-②: yes (widening). New routes, new SDK methods and a new published answer shape. No published answer changes.
Metadata-protocol: none
Dedupe: searched getRecordLock (open issues): #37195, which concerns the record page's approvals part and is a neighbour, not this mechanism.
Related: #36253, PR #37606 (ADR-0162), #25934 (the 2026-10-26 ruling on who is told a lock), #37195.

Activity

  1. added
    priority:p2
    pm:blocked
    domain:server
    on Nov 27, 2026
  2. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:data · domain:server · Feature · priority:p2 · pm:blocked · size M; rationale: closedStates. One data-layer lock read answers "is this record locked, and by which lock". Part of #36253; p2 as suggested. It keeps its named blocker.

  3. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Triage: unlock · pm:blocked → pm:queue · grade unchanged.
    Its blocker #37768 closed at 2026-12-01T02:37:40Z (completed), and the closedStates key it delivers reached main with PR #38810 at 02:23:49Z.

  4. added
    pm:queue
    and removed
    pm:blocked
    on Dec 1, 2026
  5. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 1 · 2026-12-01T12:24Z · card thread of seat repo:objectstack@os-support-ai, zone of record osa-data, on seat 3's release of this card to osa-data (mailbox #38766 comment 7310848639: "All five are released to osa-data: #37770, #37771, #37772, #38674, #38691").
    Area: osa-data
    Session: session_01WGufzfGw8DS75kHUYrjbLM
    Thread session: session_01WGufzfGw8DS75kHUYrjbLM
    Account: os-support-ai
    Branch: claude/project-thread-zy4rim (the card thread's platform-pinned branch, at base ac97540f75, zero commits)
    Worktree: objectstack-issue-37770
    Domain: domain:server
    Seat: repo:objectstack@os-support-ai
    File surface: packages/spec/src/api/record-lock.zod.ts (new: the D9 answer shape, the page request and answer, the 200-id bound), packages/spec/src/api/index.ts, packages/objectql/src/record-lock-read.ts (new: the engine's read, the closed-state producer, the internal seam the approvals producer answers through), packages/objectql/src/engine.ts (two thin members only), packages/plugins/plugin-approvals/src/record-lock-producer.ts (new: the approvals producer, pending lock plus the passage hold), packages/plugins/plugin-approvals/src/lifecycle-hooks.ts (exports of existing helpers only), packages/plugins/plugin-approvals/src/approvals-plugin.ts (binds the producer), packages/metadata-protocol/src/protocol.ts, packages/metadata-protocol/src/host-engine.ts, packages/rest/src/record-lock-routes.ts (new: the two data-family doors), packages/rest/src/data-action-routes.ts or packages/rest/src/rest-server.ts (registration only), packages/rest/src/rest-route-ledger.ts, packages/client/src/index.ts, packages/services/service-storage/src/record-file-access.ts and the storage plugin file that wires it (the upload-link door moves to the one read), content/docs/ (reason: the reference pages for the two data-family routes and the SDK methods; exact pages named in the PR body). Console askers in the console tree: scope question sent to the seat (the console card's Done-when owns the same move); added here only on the seat's word. ⛔ No change to the approvals-family routes, their SDK methods or the two IApprovalService members. Stop on breach; explain in the report.
    Container & model: L, mode:thread, model: default (dispatch-gates --tier: "Model tier — no path-derived mandate: the surface hits none of the 4 declared glob(s) … floor sonnet · default opus · ceiling fable"); served tier read by get_session: opus, matches, effort: high (the zone's sizing; L card with design judgement in the seam and the doors)
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 7299317779
    Premise: holds at origin/main ac97540: the only lock read is the approvals family's (packages/rest/src/approvals-routes.ts two doors, packages/plugins/plugin-approvals/src/approval-service.ts#getRecordLock/#getRecordLocks); the engine's closed-state judgement is on main (packages/objectql/src/closed-state-lock.ts, PR #38810); the passage hold is on main (packages/plugins/plugin-approvals/src/lifecycle-hooks.ts#passageRequestsFor/#approvalInPassage); the upload-link door asks IApprovalService.getRecordLock (packages/services/service-storage/src/record-file-access.ts).
    Pre-claim deps: Blocked-by: #37768 closed (completed), its key on main with PR #38810.
    Prior rulings read: ADR-0162 D9 and ruling record 7200732942 on #36253; seat ruling 7152650156 (two readability anchors kept); seat 3's lane release 7310848639.
    Serial constraints cleared: check-handover.mjs --inflight over this surface reads two claims meeting it: #38665 (os-justin, packages/plugins/plugin-approvals/src/ directory-wide; no open pull yet) and #37112 (seat 3, packages/metadata-protocol/src/protocol.ts, packages/rest/src/rest-server.ts; pulls #38908, #38888). Under area-lease.md the textual overlap-check.mjs decides the queue: run before every push, and a conflict queues this branch behind the named pull. Here the edits to those files are additive (exports, two members, one registration line). overlap-check.mjs at claim: clean (no commits yet).

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 1, 2026
  7. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Scope note · 2026-12-01T12:26Z · seat's word in the seat thread, relayed to this card thread by seat repo:objectstack@os-support-ai (session_01WGufzhPdWmTd47Fi2bKYZS): "this PR ships the read, the seam, the two data-family doors, the SDK methods, the upload-link door and docs; the console askers (record page, grid, line grid) move in #37773 with their wording."

    Why: #37773's own Done-when owns that move ("No console code path asks the approvals-family lock read for the edit and delete affordances"), and the record page's lock is tied to its rendering (the record page payload keeps the approvals producer's lock under D9, and a visible pending request decides the page's lock today), so moving the askers without the wording would be half of #37773 done here. Nothing else in this card's Expected or Done-when changes: the Done-when list names no console item.

  8. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

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

    裁决记录

    2026-12-01T14:33Z · The maintainer answered the seat's decision card in the app at 2026-12-01T14:33:33Z.

    Consequence for PR #38913: check:facade-delegation-only row for packages/objectql/src/engine.ts may be raised from maxLines 6857 by the measured growth, at most to 6861 (the PR now measures 6860, +3: one import line and the two one-statement forwarders getRecordLock / getRecordLocks). The raising PR quotes this record and re-measures baseLines/baseCommit. The read's body stays in record-lock-read.ts; no other engine growth is covered by this ruling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpm:dispatchedpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions