Skip to content

Commit 030cd91

Browse files
committed
docs(approvals): state how the single lock door judges a loosely spelled id; cite the anchor ruling
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php
1 parent e99cf2c commit 030cd91

7 files changed

Lines changed: 28 additions & 15 deletions

File tree

‎.changeset/37151-record-lock-source.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Both approval lock reads (`IApprovalService.getRecordLock` and `getRecordLocks`,
1717

1818
When both hold (a line with a pending request of its own, under a held master), the answer is `'master'`, because that is the delete the server refuses. An unlocked record still answers `{ locked: false }`, with no `lockSource`, and `null` (`404 RECORD_NOT_FOUND` at the single door, `locked: null` in the batch door) still means unreadable or missing, never told apart. No request id, node, approvers or `pending` flag is served. A list can now hide Delete on a line whose master is under approval instead of offering a delete the server refuses.
1919

20-
The `IApprovalService` return types gain the optional `lockSource?: 'record' | 'master'`, so an existing implementation that answers `{ locked }` alone still satisfies the contract; the REST doors then serve `{ locked: true }` without a kind.
20+
The `IApprovalService` return types gain the optional `lockSource?: 'record' | 'master'`, so an implementation may omit it on a locked answer and still satisfies the contract; the REST doors then serve `{ locked: true }` without a kind.
2121

22-
Which rows count as readable is unchanged at both doors. The two doors keep different readability anchors on purpose: the single door counts any returned row, the batch door only the row whose id is the asked id; aligning them would narrow a published answer (seat ruling on PR #37191). So an id the database matches only under another spelling (a different letter case, `07` for a numeric `7`) answers its lock at the single-record door and `null` in the batch door; a client asking with the ids the server gave it gets the same answer from both.
22+
Which rows count as readable is unchanged at both doors. The two doors keep different readability anchors on purpose: the single door counts any returned row, the batch door only the row whose id is the asked id; aligning them would narrow a published answer (seat ruling 7152650156 on #37151). So an id the database matches only under another spelling (a different letter case, `07` for a numeric `7`) answers `null` in the batch door. The single-record door counts the row it finds as readable and judges it, as before: a line of a held master answers `'master'`, because that check reads the row found, but a record's own request is looked up by the id as asked, so a record held by its own request may answer `{ locked: false }` under another spelling. A client asking with the ids the server gave it gets the same answer from both doors.
2323

2424
`@objectstack/client`: `client.approvals.getRecordLock` and `getRecordLocks` type the answer with the optional `lockSource?: 'record' | 'master'`.

‎content/docs/automation/approvals.mdx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,12 @@ Each entry is what the single-record read answers for that id, in the order the
492492
ids were sent; `null` stands where that read answers `404`, so a record the
493493
caller cannot read and one that does not exist look the same. Send the ids as
494494
the server spelled them: an id the database matches only under another spelling
495-
(a different letter case, `07` for `7`) answers `null` here, where the
496-
single-record read answers its lock. One request
495+
(a different letter case, `07` for `7`) answers `null` here. The single-record
496+
read does find such a record and answers for it, but it looks up the record's
497+
own request by the id as sent, so it may answer `{ "locked": false }` for a
498+
record its own request holds; a line of a locked record still answers
499+
`"master"`. The two reads keep these different rules on purpose (seat ruling
500+
7152650156 on #37151). One request
497501
carries at most 200 ids (`APPROVAL_RECORD_LOCKS_MAX_RECORD_IDS`); a longer list,
498502
an empty one or any other body key is refused with `400 VALIDATION_ERROR`. The
499503
SDK call is `client.approvals.getRecordLocks(object, recordIds)`, the service

‎packages/client/src/index.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,8 +7152,7 @@ export class ObjectStackClient {
71527152
* locked record which approval holds it, `lockSource`: `'record'` (its own;
71537153
* deleting it cancels the request) or `'master'` (the record a
71547154
* master-detail line belongs to; the server refuses the line's delete too) —
7155-
* and
7156-
* nothing else, answered to every caller who can read the record, whether
7155+
* and nothing else, answered to every caller who can read the record, whether
71577156
* or not they take part in the approval (`IApprovalService.getRecordLock`).
71587157
* A record the caller cannot read answers 404, exactly as a record id that
71597158
* does not exist; a deployment without the read answers 501.

‎packages/plugins/plugin-approvals/src/approval-service.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11342,7 +11342,7 @@ export class ApprovalService implements IApprovalService, ObjectSchemaReadDelega
1134211342
* here. {@link getRecordLock} counts any row its read hands back, so for
1134311343
* such an id the two doors differ, deliberately: the two doors keep
1134411344
* different readability anchors on purpose, and aligning them would narrow
11345-
* a published answer (seat ruling on PR #37191). For an id spelled as the
11345+
* a published answer (seat ruling 7152650156 on #37151). For an id spelled as the
1134611346
* engine spells it — what a list holds — entry `i` is exactly the single
1134711347
* door's answer.
1134811348
*
@@ -11473,7 +11473,11 @@ export class ApprovalService implements IApprovalService, ObjectSchemaReadDelega
1147311473
* engine hands back (a case-insensitive collation, a numeric id asked as
1147411474
* `'07'`); {@link getRecordLocks} counts only the row whose id IS the asked
1147511475
* id. The two doors keep different readability anchors on purpose:
11476-
* aligning them would narrow a published answer (seat ruling on PR #37191).
11476+
* aligning them would narrow a published answer (seat ruling 7152650156 on #37151).
11477+
* For such an id the master half below reads the row the engine found, but
11478+
* the row's own request is looked up by the id as asked
11479+
* ({@link recordHeldByLockingApproval}), so a record held by its own request
11480+
* may answer `{ locked: false }` under another spelling.
1147711481
*
1147811482
* ## What is answered — the lock and its kind, nothing about the request
1147911483
*

‎packages/plugins/plugin-approvals/src/record-lock-read.integration.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* (`'record'`) or its master's (`'master'`, winning when both hold) — and
2424
* so which delete the server refuses; the page read gives each row the
2525
* single read's kind (ruling 7148480184);
26-
* - the two doors keep their own readability anchors (seat ruling on PR
27-
* #37191): the single read counts any row its read hands back, the page
26+
* - the two doors keep their own readability anchors (seat ruling
27+
* 7152650156 on #37151): the single read counts any row its read hands back, the page
2828
* read only the row whose id IS the asked id.
2929
*
3030
* The REST door's half (one 404 for both `null`s, the closed query set, the
@@ -523,7 +523,7 @@ describe('lockSource — which approval holds a locked row, the same at the sing
523523
});
524524

525525
/**
526-
* The readability anchors, kept apart on purpose (seat ruling on PR #37191):
526+
* The readability anchors, kept apart on purpose (seat ruling 7152650156 on #37151):
527527
* `getRecordLock` counts any row its read hands back, whatever spelling of the
528528
* id the engine hands back; `getRecordLocks` counts only the row whose id IS
529529
* the asked id. Aligning them would narrow a published answer, so each door's

‎packages/rest/src/approvals-routes.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export function registerApprovalsEndpoints(this: ApprovalsRouteHost, basePath: s
552552
// Each entry is exactly the single-record door's answer for that id, as
553553
// the engine spells it (an id matched only under another spelling answers
554554
// `locked: null` here: the two doors keep different readability anchors
555-
// on purpose, seat ruling on PR #37191) —
555+
// on purpose, seat ruling 7152650156 on #37151) —
556556
// `locked`, and `lockSource` on a locked row — the 404 folded to
557557
// `locked: null` (unreadable or missing, told apart by nothing); a service
558558
// without `getRecordLocks` answers 501, never one `getRecordLock` per id.

‎packages/spec/src/contracts/approval-service.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,8 @@ export interface IApprovalService {
11231123
* A record held by its own request may still be deleted, which cancels
11241124
* the request; a line of a held master refuses insert, update and delete.
11251125
* An unlocked record answers `{ locked: false }`, with no `lockSource`.
1126+
* An implementation may omit `lockSource` on a locked answer; the REST
1127+
* doors then serve `{ locked: true }` alone, never a guessed kind.
11261128
* ⛔ No request id, node, participants or `pending` flag: whether
11271129
* the caller may see the request is still `approvalsVisibleToReaders`'
11281130
* question, and this member does not answer it. `lockSource` is one kind
@@ -1160,9 +1162,13 @@ export interface IApprovalService {
11601162
* when the line is held by a request of its own too). A row counts as
11611163
* readable only when the read hands back the row whose id IS the asked id;
11621164
* {@link getRecordLock} counts any row its read hands back, so an id the
1163-
* engine matches under another spelling answers `null` here and the lock
1164-
* there. The two doors keep different readability anchors on purpose:
1165-
* aligning them would narrow a published answer (seat ruling on PR #37191).
1165+
* engine matches under another spelling answers `null` here and is judged
1166+
* there — but not wholly on the row found: the line-of-a-held-master half
1167+
* reads the row the engine found, so such a line answers `'master'`, while
1168+
* the row's own request is looked up by the id as asked, so a record held by
1169+
* its own request may answer `{ locked: false }` there. The two doors keep
1170+
* different readability anchors on purpose: aligning them would narrow a
1171+
* published answer (seat ruling 7152650156 on #37151).
11661172
* A repeated id
11671173
* is answered at each of its positions. A caller refused the object's read
11681174
* outright is refused the same way for every id.

0 commit comments

Comments
 (0)