Skip to content

Release 2.4.0 — format 4 tier B: leader batching + verdicts#22

Merged
pango07 merged 2 commits into
mainfrom
feat/format-4-tier-b
Jul 11, 2026
Merged

Release 2.4.0 — format 4 tier B: leader batching + verdicts#22
pango07 merged 2 commits into
mainfrom
feat/format-4-tier-b

Conversation

@pango07

@pango07 pango07 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

What

The second half of format 4 — tier B: ordered intents, lease-elected leader batching, verdicts in log entries — completing the committed track from the design (PR #19). Client-side behavior on the same on-store format; no new format bump.

How it works

  • Fast path untouched: uncontended ordered writes race slots exactly as in format 3.
  • Escalation: two slot losses inside one commit (or a ConflictError rescue after an exhausted budget) flips the instance into queue mode for 10s — statements ship as ordered intents (SQL + params, shippable as data; transactions never travel this path).
  • Self-electing leader: any waiting writer that finds the lease free arbitrates the whole queue — every pending intent planned sequentially against a virtual manifest (the existing in-process group-commit machinery, promoted across processes) and landed as one log slot, with per-intent verdicts (RETURNING rows, or a precise machine-readable error) embedded in the entry. Writers read their fate from the log tail they already scan.
  • Crashed-leader window closed by construction: a verdict on record makes a leftover intent blob cleanup, never work — tested by re-planting an arbitrated intent (no double-apply).

The bug the harness caught (worth reading)

First run: hot counter at 188 instead of 24. Concurrent request handlers inside one instance share the proto's writer identity, so tryLease's "holder is me → renew" path let every concurrent waiter elect itself — eight simultaneous leaders each executing the full batch. Fix: all lease-holding work (folds + leader passes) now serializes through one per-instance chain. The design doc records the subtlety.

Verification — 240 checks green (10 new)

  • Deterministic tier B: 3 instances × 8 forced-queued updates → counter exactly 24, verdicts embedded, all 24 intents batched into a single log slot, queue drained; error verdict (PRIMARY_KEY_CONFLICT) propagates to the right writer; planted crashed-leader intent executes exactly once, re-planted one is swept without re-executing.
  • Organic escalation: 4 instances contending with the heuristic free — exact counter, escalation confirmed tripped.
  • All prior sections still green, including format-3 chaos + property harnesses (which now exercise escalation under chaos organically).
  • Live: sql-smoke 101, api-smoke 30, cli-smoke 19, stress --log (zero lost updates), property --log (model holds) — real Blob store.
  • Docs synced: design §6 both-tiers-shipped status (+ the lease-identity subtlety), commit-protocol deep-dive gains the format-4 section, format table, READMEs, counts.

Merging publishes 2.4.0 to npm as latest — the committed implementation track (auto IDs → intent queues → cross-process group commit) is then complete.

🤖 Generated with Claude Code

Completes two-tier writes (Design §6). Constraint-bearing statements
normally race slots exactly as in format 3; when the contention heuristic
trips (two slot losses in one commit, or rescue after an exhausted retry
budget), writers queue their statement as an ordered intent instead. Any
waiting writer that finds the lease free elects itself leader, plans every
pending intent sequentially against a virtual manifest (the in-process
group-commit machinery promoted across process boundaries), and lands the
batch as ONE log slot with per-intent verdicts — RETURNING rows or a
precise error — embedded in the entry. Waiting writers learn their fate
from the log-tail reads they already do.

Safety: the lease stays a performance mechanism (slots arbitrate); a
verdict on record makes a leftover intent cleanup, never work, closing the
crashed-leader window by construction. The one real bug the harness caught:
concurrent request handlers share the proto's writer identity, so lease
acquisition alone let N waiters elect N simultaneous leaders (8x
over-applied counter) — all lease work now serializes through one
per-instance chain.

Harness datapoint: 24 concurrent ordered updates from 3 instances landed
as a single log slot.

240 checks green (10 new), live suites + stress/property over real Blob.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
larva-db Ready Ready Preview, Comment Jul 11, 2026 12:11am

Request Review

CI caught the tickets check reading 400ms after two instances' appends —
too early when their folds serialize behind one lease (150ms poll cycles).
Not a correctness bug: the qlog showed every intent durable and the second
fold still lease-waiting; the design says appends are durable at ack and
visible at fold. The suite now polls for the condition (waitFor, 5s cap)
at every fold boundary, and the fake S3 keeps an env-gated queue/log
traffic journal (LARVA_DBG) for the next flake hunt. 6/6 local runs green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pango07 pango07 merged commit dc60b64 into main Jul 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant