Skip to content

fix(spec, objectql, driver-sql): a predicate delete with a cascade locks the rows it walks - #34517

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-3w505l
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-3w505l

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34373

Clause-②: yes (widening: DriverOptions.lockRows and DriverCapabilities.lockRows)
Metadata-protocol: added
Skills-docs: none — a driver capability and an engine→driver option; no skill teaches DriverOptions or DriverCapabilities

维护者速读

  • 改了什么:带级联的谓词删除(delete(obj, { where, multi: true }))在删除事务里先给命中的行加锁再删;SQL 驱动声明新能力位 lockRows,find() 在事务内发 FOR UPDATE。
  • 为什么改:原先先读命中 id、走级联、再按 id 删,调用方的条件(如「只删仍是 pending 的」)不在最终 DELETE 上;并发提交把行改出条件后,这行照样被删、还被计数。
  • 风险与回滚:只有声明 lockRows 的驱动在事务内才加锁,其它驱动和 split 计划行为不变;回滚即回退本 PR,spec 只多两个可选键。
  • 先看:packages/objectql/src/engine-delete-and-aggregate.ts 的级联分支(约 750–775 行)和 packages/drivers/driver-sql/src/sql-driver-crud.ts 的 lockRowsIfAsked。
  • 两分钟验证:设好 OS_TEST_POSTGRES_URL 后跑 pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-34373-lock-rows.test.ts,看两种并发次序都不会删掉被改出条件的行。
  • 需要你做的:无,等审核席复审后由席位转 ready。

What changes

A predicate delete on an object that delete-family lookups reference reads the matched ids, walks the cascade, then deletes those rows by id $in, so the caller's predicate is not on the final DELETE. A concurrent commit between the read and the delete that moved a row out of the predicate ({ id, source: 'idp_pending' } → active) was deleted anyway, and counted.

  • spec (packages/spec/src/data/driver.zod.ts):
    • DriverOptions.lockRows (hunk @@ -113,0 +114,23 @@, after bypassTenantAudit): on a find() inside a transaction, lock the returned rows until the transaction ends.
    • DriverCapabilities.lockRows (hunk @@ -340,0 +367,35 @@, after aggregationFilter) and its header bullet (hunk @@ -162,0 +186,3 @@): the driver's find() honours that option; absence = false.
    • Precedent: the bit follows aggregationFilter — packages/spec/src/data/driver.zod.ts:339 on main, read by the engine at packages/objectql/src/engine-delete-and-aggregate.ts:1443 (drv?.supports?.aggregationFilter === true), changeset .changeset/33698-measure-filter-pushdown.md: one optional capability bit, landed together with its engine reader, absence = the engine keeps its own path.
    • Collision note: objectql: refuse a cross-object where up front with INVALID_FILTER / 400 on a driver that compiles no semi-join (MongoDB, OData) — ADR-0139 capability-bit amendment #33876 also adds a DriverCapabilities bit next to aggregationFilter. The hunk at +367 is the one that meets it; the DriverOptions hunk and the header bullet are independent.
  • objectql (engine-delete-and-aggregate.ts, the cascade arm of runPredicateDelete): when the unit has a transaction handle and the driver declares supports.lockRows, the matched-row read carries lockRows: true. Rows deleted are still exactly the rows walked.
  • objectql refusal (engine-driver-options.ts buildDriverOptions, new lock-rows-refusal-error.ts, engine.ts host gets getDriver): lockRows arriving at the engine→driver hop from any option bag is refused before a driver runs — NOT_IMPLEMENTED / 501 when the object's driver does not declare the bit, PRECONDITION_REQUIRED / 428 when no transaction reaches that driver. A lock request is never dropped silently. The read and delete verbs already refuse lockRows from a caller as an unknown option (rejectUnknownEngineOptions), unchanged.
  • driver-sql (sql-driver-crud.ts lockRowsIfAsked, sql-driver.ts supports.lockRows: true): find()/findOne() add forUpdate() (PG/MySQL/Oracle FOR UPDATE, MSSQL UPDLOCK, SQLite nothing — the database lock keeps the promise, see Verification). lockRows without a transaction → PRECONDITION_REQUIRED / 428.

What keeps the window: a driver without the bit (memory, MongoDB, OData), and a cascade that cannot run in one transaction (split plan, no transactions).

Tests

  • New packages/drivers/driver-sql/src/sql-driver-34373-lock-rows.test.ts: the 428 refusal; live PG/MySQL row-lock cells (writer after the locked read waits; locked read behind a writer waits and does not return the moved row); SQLite two-connection pins for WAL (SQLITE_BUSY_SNAPSHOT on the transaction's delete, row kept as moved) and rollback journal (writer SQLITE_BUSY, delete stands).
  • New describe('[#34373] …') in packages/objectql/src/engine-cascade-delete-atomic.test.ts: locked read with the bit; none without the bit or without transactions; the verbs' existing refusal of lockRows; 501 and 428 with code + status; the in-transaction pass.
  • Tests changed:
    • packages/objectql/src/engine-cascade-delete-atomic.test.ts — the shared harness makeDriver takes { transactional, lockRows } and records a reads ledger; existing cases unchanged.
    • packages/spec/src/data/driver.test.ts — LIVE_BITS gains lockRows; the shape pin renamed to 6 live bits + 31 tombstones; accept/refuse cases for both keys.

Acceptance notes

The card's scenario (guarded predicate delete vs a concurrent move) is read end to end below against live PostgreSQL 16, at head and with the lock stripped.

Review follow-ups (contract review 6933706748 nits N1–N3 and the PostgreSQL UPDATE-privilege note): filed #34549.

Verification

All readings on a shared cloud box; heavy runs under scripts/pm/os-verify-lock.sh. Live PostgreSQL 16 local (OS_TEST_POSTGRES_URL), server zone Asia/Shanghai, process TZ=America/New_York for the full driver-sql suite (its timezone fixtures require both skews). MySQL, SQL Server and Oracle were not measured here; Temporal Conformance (live PG + MySQL) runs the live cells on main's full battery; it is skipped on this pull request by its own if:, so no check-run on this PR executes the live PostgreSQL or MySQL lock cells — the PostgreSQL reading here is local.

Suites
  • @objectstack/spec vitest: 937 files, 28629 passed, 1 todo.
  • @objectstack/objectql vitest: 605 files, 13516 passed.
  • @objectstack/driver-sql vitest (live PG + SQLite): 267 files passed, 4 skipped; 5459 passed, 128 skipped (MySQL / MSSQL cells NOT RUN).
  • sql-driver-34373-lock-rows.test.ts: 7 passed, 1 skipped (MySQL cell).
  • tsc --noEmit for spec, objectql, driver-sql: clean. pnpm --filter @objectstack/spec check:generated: 14/14 current after the docs regeneration.
End to end: ObjectQL engine + SqlDriver on live PostgreSQL

A temporary test (not committed) booted ObjectQL with a real SqlDriver, a ticket object and a master_detail note child (so the delete takes the cascade arm), inserted one pending ticket with one note, and wrapped find so that right after the delete's matched-row read a second driver (its own pool) runs update(ticket, { status: 'active' }) and is given 400 ms. Then engine.delete('ticket', { where: { status: 'pending' }, multi: true }).

run lock requested writer committed before the delete removed row after
head yes no (waited on the row lock) 1 gone (deleted while still pending; the move then found nothing)
lock stripped before the driver — yes (active committed) 1 gone: the active row was deleted — the card's defect
Ablation readings (each restored, tree clean after)
  • A1 sql-driver-crud.ts return builder.forUpdate(); → return builder;: both live-PG row-lock pins red.
  • A2 engine-delete-and-aggregate.ts { ...writeOptions, lockRows: true } → writeOptions: "reads the matched rows with lockRows …" red (1 of 27).
  • A3 the engine-driver-options.ts refusal guard disabled: the 501 and 428 pins red (2 of 27).
  • A4 sql-driver-crud.ts if (!options.transaction) → if (false): "answers PRECONDITION_REQUIRED / 428" red.
SQLite, two connections on one file (measured)
  • WAL (the file default connect() applies): the other connection's update commits; the transaction's own deleteMany fails SQLITE_BUSY_SNAPSHOT; after rollback the row is active (not deleted).
  • Rollback journal: the other connection's update fails SQLITE_BUSY after the busy timeout; the transaction's delete removes the row as matched.
Overlap with in-flight work

git merge-tree --write-tree of this head against #34439 (7c80b9db, shares packages/objectql/src/engine.ts) and against branch claude/issue-34412-before-hook-side-write-unit (320f1f86, shares engine-delete-and-aggregate.ts): both clean, exit 0.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 section excepted by the dispatch order).
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmRukLEFGv24PSBTaHb

…ws inside the unit of work

The cascade arm reads the matched ids, walks the cascade, then deletes by id,
so the caller's predicate never reaches the DELETE. Inside the unit of work,
a driver declaring the new DriverCapabilities.lockRows now takes that read
with the new DriverOptions.lockRows (SELECT ... FOR UPDATE in driver-sql), so
no concurrent commit can move a matched row out of the predicate before the
delete.

Claude-Session: https://claude.ai/code/session_01ADHkmRukLEFGv24PSBTaHb
Co-authored-by: Claude <noreply@anthropic.com>
…scade arm's locked read

Claude-Session: https://claude.ai/code/session_01ADHkmRukLEFGv24PSBTaHb
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/driver-sql, @objectstack/objectql, @objectstack/spec, touching 18 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/data.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

20 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6.

⛔ 5 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/data.json) — pages documenting those are invisible to this run
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 176 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 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b41c5a46ba3de65f602412554577e66c7a7720e1 — the merge of head e689bd7db84b327b38a84f80d1c913899b1a0ff2 into base 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6, 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 b41c5a46ba3de65f602412554577e66c7a7720e1 && git checkout b41c5a46ba3de65f602412554577e66c7a7720e1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 e689bd7db84b327b38a84f80d1c913899b1a0ff2 && git checkout -B drift-repro 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 && git merge --no-ff e689bd7db84b327b38a84f80d1c913899b1a0ff2

node scripts/docs-audit/affected-docs.mjs --json 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6

⚠️ 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 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 7148349 · 2026-11-17T00:17Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7148349e5a6927e129b1b8adb485e5d6480ea309
Local-runs: none
Scope: packages/spec/src/data/driver.zod.ts + packages/objectql/src/engine-delete-and-aggregate.ts, packages/objectql/src/engine-driver-options.ts, packages/objectql/src/engine.ts, packages/objectql/src/lock-rows-refusal-error.ts, packages/drivers/driver-sql/src/sql-driver-crud.ts, packages/drivers/driver-sql/src/sql-driver.ts

① Derived judgments

Inputs read: card #34373 body and all 8 comments (triage, ruling 6919195250, four claims, the needs_seat report with routes A/B/C, the done report), PR #34517 body, file list and the net diff against the merge base with main, and the check-runs on the head. Nothing was built or run.

Check-runs on the head: 67 runs. Every completed run concluded success or skipped; none failed. Pending at the time of reading: Test UI (10/16) (in progress, no verdict; the diff holds no UI file). Test Core (the aggregate) and all eight Test Core shards, the three Type Check runs, Spec property liveness, Check Changeset, Governed Surface Queue Guard, Lint · PM dispatch-gates and the PR-body guards are success. ⚠️ Temporal Conformance (live PG + MySQL) is skipped on a pull request by its own if: (full battery only), so no check-run on this head executed the live PostgreSQL or MySQL row-lock cells of sql-driver-34373-lock-rows.test.ts: on this head they are ordinary skips. The live PostgreSQL reading is the dev's own local one (PR body, ablation A1); the MySQL cell has been run by nobody yet and first runs on main's full battery. The PR body sentence "CI's Temporal Conformance runs the MySQL cell" is true of main, not of this head.

Accept-set and public-surface changes the diff implies:

  • DriverOptionsSchema gains optional boolean lockRows. A widening: every bag that parsed still parses. Right.
  • DriverCapabilitiesSchema gains optional boolean lockRows, absence meaning false. A widening, on the aggregationFilter precedent (one optional bit landed with its engine reader). Right. The audited shape pin moves to 6 live bits + 31 tombstones and authorable-surface/data.json gains both keys, matching.
  • Because declaredDriverOptionKeys() reads the schema shape, lockRows now crosses the engine to driver hop from every bag buildDriverOptions is given. The diff answers that in the same function: 501 NOT_IMPLEMENTED when the object's driver lacks the bit, 428 PRECONDITION_REQUIRED when no transaction reaches it. Right, and necessary: without the guard the new key would be a silently ignored option on every non-declaring driver reached through the engine.
  • One input that used to succeed now refuses: a bag with no closed option set (an insert's options) carrying lockRows: true. Before this diff the key was undeclared and dropped at the hop without a sound; now it answers 501 or 428. This is a refusal of a key that had no meaning and no caller before this PR (no sender in the tree; read by grep at head), not the narrowing of a published accept set. Judged right, and not a (narrowing) arm.
  • The find, findOne, delete, update, count and aggregate verbs keep refusing lockRows at their closed option sets (unchanged, pinned for find and delete). Right: the engine's one sender stays its own.
  • SqlDriver.supports.lockRows: true on every dialect, and find() / findOne() gain a 428 refusal for lockRows with no transaction. New behaviour on a new key only. Right. SqliteWasmDriver inherits both with no override (knex compiles nothing for SQLite; one connection).
  • Engine behaviour: the cascade arm's matched-row read is a locking read when the unit has a handle and the driver declares the bit. No outcome changes without a concurrent writer; rows deleted are still exactly the rows walked (the objectql: a predicate delete (multi: true with a filter) skips the referential walk, so a flow's bulk delete_record bypasses restrict, master_detail cascade and set_null #26871 / objectql: since #26930 a predicate delete walks every matched row one by one; 1,001 rows cost ~1.7 s (18×), and rest's nested-object-door cap test now nears its 5 s budget in the merge queue #27004 invariant kept). Right.

② Semver level

Changeset .changeset/34373-predicate-delete-lock-rows.md: @objectstack/spec minor, @objectstack/objectql patch, @objectstack/driver-sql patch. This is the level the precedent changeset for aggregationFilter (#33698) took for the same shape of change, and minor is right for two optional additive keys on published schemas. All three packages sit in the one fixed version group, so the release bump is the group's minor either way. Check Changeset is success.

Clause-②: yes (widening: DriverOptions.lockRows and DriverCapabilities.lockRows) is present and identical on the PR body and in the changeset, and it is true of the diff: both spec edits widen, nothing published is narrowed. Metadata-protocol: added matches the two new authorable-surface entries. No ! is owed and none is claimed.

③ Boundary flags

Dev deviations, each answered:

  • packages/objectql/src/engine-driver-options.ts edited though the last claim's file surface names only the engine.ts host line and the new error file. Accepted: buildDriverOptions lives there, the claim describes exactly this refusal seam, and the hunk is the guard and nothing else.
  • Ablations A1 to A4 run with vitest directly, outside os-verify-lock. A process deviation with no effect on the contract; accepted.
  • First gate pass before the last commit, re-run in full at this head. Accepted; the recorded pass is the head's.
  • Local heap flag for check:test-typecheck. Environmental; the CI type-check runs are success without it.

Open questions, each answered:

  • Q1, route to contract review or land without: answered by this record.
  • Q2, should the memory, MongoDB and OData drivers refuse 501 when called DIRECTLY with lockRows: no, not in this card (option A). Judged against declared ⇒ enforced: the option's TSDoc says "A driver honours it only when it declares DriverCapabilities.lockRows", and every refusal it promises is scoped to the engine ("its read and delete verbs do not take the key", "refused there", at the engine to driver hop). The capability's TSDoc says the same from the other side ("an option a driver silently ignores is a lock the engine believes it holds and does not. The bit is the driver's promise"). So the contract text as written does NOT promise more than the code enforces: the enforcement point it names is the capability bit plus the engine's guard, and both exist and are pinned (501 and 428 with code and status). What the text leaves unsaid, rather than over-promised, is the plain consequence for a direct caller: a non-declaring driver ignores the key, so a direct caller must read supports.lockRows first. That is nit N1 below. Option B (a 501 in each driver) is a sound follow-up if a direct driver caller that sends the key ever exists; none does in the tree at this head.
  • Q3, Turso remote inherits the bit, and MySQL, SQL Server and Oracle are not measured live: accept for this card (option A), with two follow-ups named in ④ (N2, N3). Through the engine both are safe: the engine sends the key only with an open handle that covers the object's driver, and a caller's own lockRows on a transport with no transaction answers 428 at the hop. See ① for what CI did and did not measure on this head.

SQL push-down: no new id materialisation and no new in-app join. The id read followed by id $in batches is the arm's existing shape, with its reason on the tree (#26871, #27004: the walk's own writes can move a row into or out of the predicate, so the rows deleted must be the rows walked). This diff adds a lock to that existing read and pushes it down as the dialect's own locking read. No finding.

Open PR #34530 (card #33697) also edits packages/spec/src/data/driver.zod.ts: it adds the capability bit zonedDateBucketing, read by engine.aggregate. The two edits do not collide in meaning: different bits, different verbs (aggregate() against find()), different engine readers, and neither changes what the other's bit promises. They do collide in text and in one counted fact: both append after aggregationFilter in the schema, the header bullet list, the SqlDriver.supports literal, LIVE_BITS and the three generated driver*.mdx tables, and BOTH rename the audited-shape pin to "6 live bits + 31 tombstones" and call their bit "the sixth". Whichever lands second must merge main, make that 7 live bits (title and comments; the identical title line can merge textually clean and stay wrong), and regenerate. The claim already records that the area serialises the landing.

Not in the diff, recorded for the seat: on PostgreSQL a locking read needs UPDATE privilege on the table in addition to SELECT (PostgreSQL's documented rule; not measured here). A platform-owned table is unaffected. A federated object whose remote role holds DELETE without UPDATE, and which delete-family lookups reference, would have its predicate delete refused by the database where it ran before. Rare and loud; worth one line in a follow-up card, not a finding on this head.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/data/driver.zod.ts, against ruling route B on the card (lock the matched rows inside the unit of work, then keep the delete by id; a driver option or capability; drivers without row locks keep the window and say so) and against its first consumer, the cascade arm of runPredicateDelete:

  • The schema implements route B as ruled, with the names the seat ruled (claim 6931526435). Option and bit are both optional booleans; absence of the bit is false. Holds.
  • The option's TSDoc, sentence by sentence: "only with transaction set" is enforced twice (428 at the hop, 428 in lockRowsIfAsked); "honours it only when it declares the bit" is enforced by the 501 at the hop; "read and delete verbs do not take the key" is the closed option sets, pinned; "the engine's one sender" is true of the tree (one lockRows: true literal in packages/objectql/src). Holds.
  • The bit's TSDoc: the promise ("the writer waits ... or one of the two fails loudly; a writer's commit is never followed by a successful write of the transaction over the changed row") is the right strength. It is what every dialect can keep, it covers a deadlock abort, and it is exactly what the card's guard needs. FOR UPDATE is the right lock strength for rows about to be deleted. The SQLite paragraph matches the two committed two-connection pins (WAL: the transaction's delete fails SQLITE_BUSY_SNAPSHOT; rollback journal: the writer fails SQLITE_BUSY). "The memory, MongoDB and OData drivers keep that window" states the residue the ruling required be stated. Holds.
  • Tried to break it: (1) a predicate that compiles to a join, where PostgreSQL refuses a lock on the nullable side: findRows builds no join, and composed scope leaves compile to subqueries, which lock only the outer rows. (2) DISTINCT or GROUP BY under the lock: not on the find path. (3) The retry ladder dropping the lock: every rung is rebuilt by buildBase, which re-applies it. (4) The 428 being swallowed into a statement fault: it is thrown while building, outside the try. (5) The engine's own send escaping its guard: it checks the handle and the bit itself, and the handle in writeOptions is only ever one transactionCoversDriverFor admitted. (6) A row moved INTO the predicate after the read: not walked, not deleted, as before. None broke.
  • Considered and accepted as inside the stated promise: locking the root first can deadlock against a writer that holds a child row and then writes the parent (a roll-up recompute). The database aborts one side loudly; "or one of the two fails" covers it.

Implementing files:

  • engine-delete-and-aggregate.ts: agrees with the contract. The lock rides the matched-row read only; the walk and the by-id deletes keep writeOptions. The comment's "no open transaction (the 'split' plan ...)" is slightly narrower than the code, which also locks under a 'split' plan when an ambient handle covers the root's driver; the code is the safer of the two.
  • engine-driver-options.ts, engine.ts, lock-rows-refusal-error.ts: agree. Both codes exist in StandardErrorCode with those statuses; the error carries code, status and httpStatus; refusal happens before any driver call (pinned: nothing written).
  • sql-driver-crud.ts, sql-driver.ts: agree. find() and findOne() both pass through findRows, so both honour the key, as the option's TSDoc says.

N1 (nit) — the option's TSDoc never says outright that a driver WITHOUT the bit ignores the key on a direct call, so a direct caller must read supports.lockRows first. The text does not claim otherwise; one sentence would close the question the dev raised. Left as an accepted deviation on this head (a fix moves the head); fold it into the follow-up below.

N2 (nit) — the bit's TSDoc states the MySQL and SQL Server behaviour as fact and the driver declares the bit on every dialect, Oracle included, while only PostgreSQL and SQLite are measured (the aggregationFilter precedent names its measured dialects). On SQL Server and Oracle the lock is knex's compile, unread against a server; on Oracle a findOne() with lockRows (a row limit under a locking read) is likely refused by the database. Both failures would be loud, and the engine's one sender uses neither a limit nor findOne. Follow-up card: measure the MySQL, SQL Server and Oracle cells and name the measured dialects in the TSDoc.

N3 (nit) — TursoDriver (outside this repository) inherits lockRows: true while its remote transport carries no transaction. The engine never sends it the key, and a caller's own request answers 428 at the hop, so nothing is wrong through the engine. By the precedent the same literal's comments set for transactionsUnsupported and aggregationFilter (a subclass whose transport cannot do it spreads the baseline and turns the bit off), the remote mode should declare lockRows: false. Follow-up card in the driver's own repository.

Implemented-by: claude/project-thread-3w505l
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRukLEFGv24PSBTaHb

Test UI red at 7148349 is a runner timeout, not this diff. Test UI (10/16) (job 133704173413) was cancelled by its 30-minute timeout-minutes, which turned the Test UI aggregate red. No test failed.

  • Step times from the jobs API: Checkout repository 19.5 min (the same shard on queue run 43980731814 took 0.5 min); the test step itself ran 9.2 min before the cancel (10.3 min on that green run).
  • Per-file test times in the shard match that green run: 109 shared files, sum 79.2 s vs 77.2 s (ratio 1.03).
  • The diff touches no ui/ path; the other 15 Test UI shards and all 8 Test Core shards are green.

The run concluded cancelled, so the relay's one failed-jobs re-run (run_rerun_failed, which requires failure) does not apply. A re-run of the shard, or the queue run, is what clears it.

Stamped 2026-11-17T00:26Z.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSLi1reMd27fT62jJ3

CI note · PR #34517 · 2026-11-17T00:26Z

Test UI (10/16) on head 7148349 was killed at its job timeout (log ends mid-run with "The operation was canceled" after green files; ci.yml reads a timed-out shard as cancelled), and the Test UI aggregate went red on it. This PR touches no ui/** file. The relay refuses to re-run a cancelled run (rerun-failed.mjs: fence failed), so the area syncs the branch with main through the relay's pr_update_branch (platform-readings ②), which starts a fresh CI run. No code change; the L2 record 6933706748 was taken on 7148349 and a clean base merge is its head-move exception.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSLi1reMd27fT62jJ3

Final head · PR #34517 · 2026-11-17T01:04Z

Final head for L1: e689bd7db84b327b38a84f80d1c913899b1a0ff2. It is 7148349e plus the platform's own base sync (pr_update_branch, comment above), no code change. Check-runs on this head: 72, of which 60 success and 12 skipped, none pending, none red. The L2 record 6933706748 (PASS) was taken on 7148349e; a clean merge of main is its head-move exception.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head e689bd7 · 2026-11-17T01:06Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 first review · ACCEPT · head e689bd7db84b327b38a84f80d1c913899b1a0ff2 · card #34373 · read 2026-11-17T01:07Z

Checklist (read on GitHub at this head, not from the report)

  • Shape: draft, base main, Fixes #34373. Closing-keyword scan of the whole body: one hit, #34373; #33876, #34439, #34549, #34412 carry no keyword.
  • Head provenance: e689bd7d = 7148349e + a merge of main. Every one of the 15 PR files has the same blob at both heads (git rev-parse per path), so the merge moved nothing this PR owns.
  • File surface: 15 files from get_files. All inside claim 6931526435 except packages/objectql/src/engine-driver-options.ts, which the dev reports as a breach: it is where buildDriverOptions lives, and the claim already names "one getDriver line in the buildDriverOptions host literal" and the loud refusal, so the file is the card's own fix, not a neighbouring defect. It still needs a File surface amended comment on the card before landing (no head move).
  • Declarations: Clause-②: yes (widening), Metadata-protocol: added (the shard authorable-surface/data.json gains the two lockRows keys), Skills-docs: none — a driver capability and an engine→driver option; no skill teaches DriverOptions or DriverCapabilities. The changeset grades @objectstack/spec minor, objectql and driver-sql patch; Check Changeset is success.
  • Mechanism, read in the source: the cascade arm of the predicate delete reads matched rows with { ...writeOptions, lockRows: true } only when writeOptions.transaction != null and driver.supports?.lockRows === true; otherwise the read is unchanged. driver-sql's lockRowsIfAsked adds forUpdate() on both read paths and refuses lockRows without a transaction (PRECONDITION_REQUIRED / 428). buildDriverOptions refuses a lockRows arriving from any other bag before a driver runs: NOT_IMPLEMENTED / 501 when the object's driver lacks the bit, 428 with no transaction. The engine's own locked read goes straight to driver.find, so it never meets that refusal.
  • Changeset sentences, checked: "the matched-row read now takes a lock on a driver that can lock" (the gate above); "The rows deleted are still exactly the rows walked" (only the read options change); "the engine sends no lock request to such a driver" (pinned); "The engine's read and delete verbs do not take lockRows from a caller" (rejectUnknownEngineOptions, pinned); the 501 / 428 sentence (pinned with code and status). "SQL Server an update lock (UPDLOCK)" and Oracle are what knex's forUpdate() compiles there; neither was run (body says so; follow-up review follow-ups of PR #34517 #34549).
  • Rejection assertions: the 501 and 428 engine pins assert code, status and object and that nothing was written; the driver 428 pin is ablated (A4).
  • Tests and controls: ablations A1–A4 each with what went red. The live PostgreSQL lock cells and the end-to-end table (head: writer waits, row deleted while pending; lock stripped: the active row is deleted, the card's defect) are local readings; the body states plainly that no check-run on this PR runs the live cells. Accepted as reported, with the dev's deviation that the ablations ran outside the verify lock.
  • Gates at this head: check-runs on e689bd7d…: 72 runs, 60 success, 12 skipped, 0 failed; Lint & Repo Gates, TypeScript Type Check, Dogfood Regression Gate, Check Changeset success.
  • L2: CONTRACT_REVIEW_TIER owed (packages/spec/src/data/driver.zod.ts). Record 6933706748, l2-review#4, Served-tier: CONTRACT_REVIEW_TIER, VERDICT PASS, Head-sha: 7148349e…. Since every PR file is byte-identical at e689bd7d, it reads for this head under the clean-merge exception; the seat confirms that reading when it lands. Its nits N1–N3 and the UPDATE-privilege note are filed as review follow-ups of PR #34517 #34549.

Before landing (no push needed unless noted)

  1. Serial with feat(objectql,driver-sql): PostgreSQL buckets a non-UTC reference timezone in the database (ADR-0053 D2 as amended) #34530 (area o2-F, card aggregate: PostgreSQL buckets a non-UTC timezone in the database (amend ADR-0053 D2; SQLite keeps DST zones in memory) — epic #33631 R6 #33697), which adds a DriverCapabilities bit too. git merge-tree --write-tree of this head against feat(objectql,driver-sql): PostgreSQL buckets a non-UTC reference timezone in the database (ADR-0053 D2 as amended) #34530's head 2b76c7f4 exits 1: conflicts in packages/spec/src/data/driver.zod.ts, packages/spec/src/data/driver.test.ts (both rename the shape pin to "6 live bits"), packages/drivers/driver-sql/src/sql-driver.ts, and the three generated content/docs/references/data/driver*.mdx. The body's collision note names objectql: refuse a cross-object where up front with INVALID_FILTER / 400 on a driver that compiles no semi-join (MongoDB, OData) — ADR-0139 capability-bit amendment #33876 only. Whichever lands second merges main, regenerates the spec artefacts, moves the pin to 7 live bits and re-runs CI. That head is no longer a clean merge, so its L2 record must be re-read on it (the seat routes it).
  2. Card: the File surface amended comment for engine-driver-options.ts.
  3. Body: the attribution comment and the "Requested by" line sit at the bottom; they open the body.

Owed after this

  • Landing tier: node scripts/pm/check-governed-merges.mjs --pr 34517: 0 of 15 paths governed, 600 changed lines (+590 / −10) ≤ 3000 ⇒ ordinary queue landing by the area, in the order item 1 sets.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: e689bd7db84b327b38a84f80d1c913899b1a0ff2
Local-runs: none
Scope: packages/spec/src/data/driver.zod.ts + packages/objectql/src/engine-delete-and-aggregate.ts, packages/objectql/src/engine-driver-options.ts, packages/objectql/src/engine.ts, packages/objectql/src/lock-rows-refusal-error.ts, packages/drivers/driver-sql/src/sql-driver-crud.ts, packages/drivers/driver-sql/src/sql-driver.ts

① Derived judgments

Delta review. The previous at-tier record is comment 6933706748 (VERDICT PASS on head 7148349e5a6927e129b1b8adb485e5d6480ea309, no must-fix, no should-fix, nits N1 to N3). This record re-reads that one on the new head and judges only what moved.

Inputs read: the previous record and every comment on PR #34517, the PR body, the git objects of both heads and both merge bases, the 72 check-runs on the new head, and the state of PR #34530. Nothing was built, checked out or run.

What the new head is, read from the tree:

  • e689bd7d is a two-parent merge commit: first parent 7148349e (the head the previous record judged), second parent 631d77f3 (main). It is the only new commit.
  • The merge base with main moved from 495a79c7 to 631d77f3; nine main commits lie between them.
  • git diff 7148349e e689bd7d over the PR's 15 files is empty: every one is byte-identical at both heads.
  • The PR's file list against the new merge base is the same 15 paths with the same statuses (3 added, 12 modified) as against the old one, and the full net diff against the new base is byte-identical to the net diff against the old base.
  • The merge is clean in the strict sense: the 67 paths that differ between the two heads are exactly the 67 paths main changed between the two merge bases, and each of them carries main's blob at the new head. The merge added nothing of its own.

What the merge brought in from main (nine commits, 495a79c7..631d77f3), against the Scope and what it imports or what consumes the new option and bit:

So every judgment in ① of the previous record holds unchanged on the merged tree: the two widenings (DriverOptions.lockRows, DriverCapabilities.lockRows), the 501 and 428 refusals at the engine to driver hop, the one formerly silent input that now refuses, the closed option sets on the verbs, SqlDriver.supports.lockRows: true, and the cascade arm's locking read.

PR #34530 and the live-bits count: main at the new merge base does NOT contain #34530. It is still open and draft (head 2b76c7f4), zonedDateBucketing appears nowhere in driver.zod.ts on main or on this head, and main's pin still reads "5 live bits + 31 tombstones". On this head the count is internally consistent at 6: LIVE_BITS holds six names ending in lockRows, the pin title reads "6 live bits + 31 tombstones", the SqlDriver.supports literal carries the bit, the three generated pages and authorable-surface/data.json carry the key. Six is the right number for this tree. The collision note of the previous record stands as written for whichever of the two lands second: merge main, make it 7 live bits (title and comments; the identical title line can merge textually clean and stay wrong), regenerate the spec artefacts and the three driver*.mdx pages.

Check-runs on the new head: 72 runs, all completed; 60 success, 12 skipped, none failed, none pending.

  • Test UI (10/16), the shard that was cancelled at its job timeout on the previous head, is success here, and the Test UI aggregate is success.
  • Test Core (the aggregate) and all eight Test Core shards, TypeScript Type Check with its four lanes, Lint & Repo Gates with its lanes, Spec property liveness, both Check Changeset runs, Governed Surface Queue Guard, Build Core, Build Docs, Dogfood Regression Gate and both PR-body guard runs are success.
  • ⚠️ Temporal Conformance (live PG + MySQL) was SKIPPED on this head, as on the previous one. Its if: in ci.yml excludes pull_request and merge_group events (full battery only). No check-run on this head executed the live PostgreSQL or MySQL row-lock cells of sql-driver-34373-lock-rows.test.ts; they are ordinary skips here. The live PostgreSQL reading remains the dev's own local one, and the MySQL cell has been run by nobody; both first run in CI on main's full battery after landing. The PR body now states this correctly (the sentence the previous record corrected has been rewritten).
  • The other eleven skips are opt-in or event-gated jobs (Lint UI, Dogfood Verify CLI, UI Published Artifacts, the dogfood shard matrix, Packed-tarball smoke, 18.x upgrade harness, the two queue verdicts, the schedule gate, and the second Auto Label and Check PR Size runs).

② Semver level

Unchanged. The changeset .changeset/34373-predicate-delete-lock-rows.md is byte-identical at both heads: @objectstack/spec minor, @objectstack/objectql patch, @objectstack/driver-sql patch. Minor is right for two optional additive keys on published schemas. Clause-②: yes (widening: DriverOptions.lockRows and DriverCapabilities.lockRows) and Metadata-protocol: added are still present on the PR body and still true of the diff, which did not move. Nothing main brought in changes the level: no merged commit touches the three packages' published surface in data. Check Changeset is success on this head.

③ Boundary flags

No new boundary crossing: the merge moved no file this PR owns, and no file in the Scope.

The dev deviations and open questions Q1 to Q3 answered in the previous record stand as answered. Nothing new was raised on this head. The PR body records that nits N1 to N3 and the PostgreSQL UPDATE-privilege note are filed as #34549; that is a statement about a card, not about this tree, and it changes no judgment here.

Collision with open PR #34530 (card #33697), restated for the landing order because it is the one live risk on this head:

Main beyond the new merge base (13 further commits on the fetched origin/main, tip 7b3e9558): none touches a Scope file, the audit pin or the driver pages. Two touch neighbouring files in the same directories (field.zod.ts with field.mdx in #34489, seed.zod.ts with its two pages in #34429); neither is imported by the Scope's changed lines. A trial three-way merge of this head with that tip reports no conflict.

SQL push-down: unchanged from the previous record; no new id materialisation and no in-app join in this delta.

④ Design judgment

No must-fix, no should-fix.

This section is short because nothing in the Scope moved: all seven Scope files are byte-identical to the head the previous record judged, and main brought no change to any file they import or to any reader of the new option or bit. The design judgment of record 6933706748 therefore applies to this head word for word:

Nits N1 to N3 of the previous record carry over unchanged in substance and in grade (nit): N1, the option's TSDoc does not say outright that a driver without the bit ignores the key on a direct call; N2, the bit is declared on every SQL dialect while only PostgreSQL and SQLite are measured; N3, the Turso remote transport inherits the bit. None is new, none blocks this head.

No new finding on this head.

Limit of this record: it holds for e689bd7d only. A later head that merges #34530's change is not a clean base merge and needs its own at-tier reading.

Implemented-by: claude/project-thread-3w505l
Reviewed-by: session_01ADHkmP44onN8RMzsPMqjRq

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmSLi1reMd27fT62jJ3

Landing · PR #34517 · 2026-11-17T01:10Z

ACCEPT → PR #34517 comment 6934544391 (L1-b, head e689bd7). L2 → comment 6933706748 (PASS at 7148349, CONTRACT_REVIEW_TIER; the 15 PR files are blob-identical on both heads, so it carries under the clean main-merge exception, confirmed by the seat).
Head-sha: e689bd7

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 01:10
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 371e5f1 Nov 17, 2026
77 checks passed
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 protocol:data size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants