You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e765768
Browse filesBrowse the repository at this point in the historyBrowse files
docs(adr): ADR-0142 — apply the delta review's round-5 findings
Merge question 16 names the data API's existing If-Match / expectedVersion
check as compare-then-write and states the real fork; a lost claim answers
the ledgered CONCURRENT_UPDATE 409; question 17 quotes the degradation rule.
Claude-Session: https://claude.ai/code/session_017BFhbTnbbHcXkSnMss2btn
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/adr/0142-ownership-queue-membership-claim-and-assignment-rules.md
+23-12Lines changed: 23 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,7 +199,11 @@ ADR-0131 D3 states the split this record reuses: *"Assignments are organization
199
199
method (`packages/spec/src/contracts/data-driver.ts`) with a declaration site in `driver-memory`, `driver-mongodb`,
200
200
`driver-sql` and `driver-turso`; `driver-sqlite-wasm` declares none of its own and its tests call the one it is built on.
201
201
Every shipped driver therefore answers it, and the contract still allows a driver that does not. A conditional update —
202
-
"set the cursor to N+1 where it still reads N" — is expressible with it; no atomic increment exists.
202
+
"set the cursor to N+1 where it still reads N" — is expressible with it; no atomic increment exists. The data path has one
203
+
conditional-update contract already: `PATCH` and `DELETE` take an opt-in `If-Match` header or `expectedVersion` token
204
+
(`packages/spec/src/api/protocol.zod.ts`, `packages/rest/src/crud-routes.ts`) and answer **409 `CONCURRENT_UPDATE`** when
205
+
it differs from the row's `updated_at` (`packages/metadata-protocol/src/protocol.ts#ConcurrentUpdateError`) — compared in
206
+
`updateData` over the existence probe, before `engine.update`, so it is compare-then-write, not atomic.
203
207
204
208
### 2. The pull — HotCRM at `8f52859`
205
209
@@ -391,8 +395,10 @@ claim (`{ owner_id: null }`, set by
391
395
the gate on the operation context as it sets the depth today) and D5's cursor (`{ version }`). The engine lowers the
392
396
write to the driver's conditional `updateMany(object, { where: { id, ...expect } }, data)` where the driver has it; one
393
397
affected row is re-read by id and the by-id branch continues unchanged — hooks, formulas, the per-record event, the
394
-
roll-up, the response — at the cost of one read; zero rows answer **409 `RESOURCE_CONFLICT`** ("the record was taken"),
395
-
the distinction the engine already draws between a by-id miss and a predicate update that matched nothing. Where the
398
+
roll-up, the response — at the cost of one read; zero rows answer **409 `CONCURRENT_UPDATE`** — the data path's existing
399
+
code for "another writer got there first", with "the record was taken" as its message — the distinction the engine
400
+
already draws between a by-id miss and a predicate update that matched nothing. The existing `expectedVersion` check is
401
+
untouched by the PR (merge question 16). Where the
396
402
driver has no `updateMany`, the precondition degrades to the pre-image check and the write goes through unconditionally,
397
403
logged once per process at `warn`; every shipped driver has it (Context §1).
398
404
@@ -566,7 +572,8 @@ at merge (the card's own words; HotCRM `AGENTS.md` rule 2: *merged is not availa
566
572
`sys_job_queue` are a different noun — a work queue of jobs, not of people — and nothing here touches them; the two
567
573
words co-exist as `sys_team` and `team` do.
568
574
-**Codes** (ADR-0112 D1, D3 — registered in the ledger by the PR): `PERMISSION_DENIED` 403 for a refused claim, release,
569
-
move or supplied queue; `RESOURCE_CONFLICT` 409 for a lost claim race; one new code, `QUEUE_NOT_FOUND` 422, only for a
575
+
move or supplied queue; `CONCURRENT_UPDATE` 409 for a lost claim race — the ledger's existing code for a write another
576
+
writer beat, so the verb carries one 409, not two (ADR-0112 D1); one new code, `QUEUE_NOT_FOUND` 422, only for a
570
577
caller-supplied `queue` that resolves nowhere in the row's organization. A rule's unresolved target is never a refusal
571
578
(D5). D3's registration refusal is thrown at `registerObject`, a door Studio and the metadata API reach at request
572
579
time, so it carries the ADR-0112 envelope the registry's other field refusals carry — `INVALID_METADATA`, 422, as
@@ -724,15 +731,19 @@ objection names the number.
724
731
absent and every admission inapplicable (ADR-0078); a suffixed name (`owner_queue`) avoids the collision at the price
725
732
of a less legible column whose name differs from the type's. The recommendation is loud and names the fix; its cost
726
733
is an upgrade-time refusal for an app that already has the field.
727
-
16.**The by-id write precondition (`expect`) is engine-internal: set by the gate for a claim and by the assignment seam
728
-
for the cursor, reachable from no data door.** Exposing it on the data API (a conditional update, `If-Match`-like,
729
-
through REST and the SDK) would give every app optimistic concurrency — a real want — at the price of a new request
730
-
vocabulary through every door, a 409 every client must learn to handle, a spec key and ledger entry of its own, and
731
-
a platform-wide contract decided on a queue card. The recommendation keeps the primitive private to D4's two users;
732
-
exposing it later is additive and needs no undo.
734
+
16.**The by-id write precondition (`expect`) is engine-internal — set by the gate for a claim and by the assignment seam
735
+
for the cursor, reachable from no data door — and the data API's existing optimistic concurrency stays where it is.**
736
+
`PATCH` and `DELETE` already take `If-Match` / `expectedVersion` and answer 409 `CONCURRENT_UPDATE`, compared in
737
+
`updateData` before `engine.update` (Context §1): compare-then-write. The alternative lowers that check onto the same
738
+
precondition (`expect: { updated_at: <token> }`), making today's optimistic concurrency atomic for every client
739
+
already sending the token; its cost is moving the comparison into the write while preserving what the protocol
740
+
layer settles around it — the probe-first ordering (404 before 409), the token normalisation, and the conflict's
741
+
re-read of the row under the caller's context for `currentVersion` / `currentRecord` — on a queue card. The
742
+
recommendation leaves the data path's shape alone; its cost is that the existing check stays non-atomic. Lowering
743
+
it later is additive.
733
744
17.**A stack that declares `queues` or `assignmentRules` with no queue service registered is refused at boot, not
734
-
warned about.** AGENTS.md puts a functional degradation at `warn`, and a loud warning would keep a lean composition
735
-
booting; but this degraded state is not cosmetic — every insert the rules cover parks nowhere and every claim fails
745
+
warned about.** AGENTS.md says *"An `if (!service)` composition branch is usually functional and belongs at
746
+
`warn`"*, and a loud warning would keep a lean composition booting; but this degraded state is not cosmetic — every insert the rules cover parks nowhere and every claim fails
736
747
closed, with the declaring package none the wiser — and ADR-0093 D5 is the precedent for failing fast on a degraded
737
748
middle state. Cost of the recommendation: a composition that ships such a package and deliberately omits
738
749
`plugin-sharing` cannot boot until it drops the keys or adds the plugin. Cost of the warning: ADR-0078's inert
0 commit comments