Skip to content

feat(auth): version the API key hash and switch CSRF enforcement; record the #38 review decisions - #78

Merged
aRustyDev merged 3 commits into
mainfrom
feat/auth-followups
Oct 24, 2026
Merged

aRustyDev merged 3 commits into
mainfrom
feat/auth-followups

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What this does

Implements the owner's decisions of 2026-10-24 on the auth slice that merged as #76 (453226c). Bead plane-byd.11.6. There is no GitHub issue, so no "Closes".

  1. API keys stay plain SHA-256, no pepper, with an escape hatch (Q-0052.3). A key is 256 random bits, so a leaked digest cannot be reversed with or without a pepper, and a pepper would add a secret and a rotation story to every target. The hatch lets a pepper be introduced later without invalidating any key: migration 0007 adds api_keys.hash_version (default 1), core has a versioned api_key_hash(version, token) (1 = plain SHA-256, the only scheme that ships), a key is looked up under every supported version, and one found under another version than the current is moved lazily after a successful use, through Background, by a compare-and-set port method rehash_api_key. No field on Ports, no env var, default behaviour unchanged.
  2. CSRF: option A is built and not enforced while the stock frontend exists (Q-0050.8). CoreConfig::csrf_enforce (core's default is on; the composition roots read THRUST_CSRF_ENFORCE and default it off; the contract targets and Stage 2 run it on). Off changes one thing: the token is not consulted for a cookie mutation. /_info reports csrf_enforce, and scripts/contract.sh refuses a pass whose server says otherwise. A new csrfoff pass tests the off mode.
  3. Q-0050.9 recorded, no code: for M6, a Workers VPC service over a tunnel to id.auth.woven, the CNPG pattern (ADR-0094).
  4. Docs: dated notes in ADR-0052 (the hatch with the steps to turn a pepper on, the monitoring query, idle keys, dropping v1, the rollback caveat; the CSRF switch, the interim posture stated plainly, the flip criterion), ADR-0141 (line 38 amended, original kept), ADR-0050; QUESTIONS.md; PLAN.md (the flip is an item of M4, the VPC service an item of M6); research/0012 (issue chore(ci): enforce the clippy deny list, cargo fmt --check and cargo-deny; forbid sqlx, sea-orm, diesel in check-deps.sh #40 now carries the RUSTSEC-2023-0071 ignore); the docs/src pages that carry CSRF, API-key, count or list text; defect X22 widened, X29 and G-14 added (X25 to X28 and G-13 are left to feat(db): engine pass, search routes and the FR-22 order; spike 0002 decides Postgres #77).

Commits (one per bead, Refs: footer):

Commit Bead
16fcf64 feat(ports): version the API key hash so a pepper can be added later plane-byd.11.6.1
3de443e feat(api): a switch for CSRF enforcement, off while the stock frontend exists plane-byd.11.6.2
1ff9f4d docs: record the #38 review decisions plane-byd.11.6.3

Evidence

Run on the branch (origin/main had not moved: 453226c, no rebase needed).

Check Result
scripts/rs cargo nextest run --workspace 1019 passed, 4 skipped
scripts/rs cargo test --doc --workspace ok
scripts/check-deps.sh ok
thrust-worker for wasm32, default features and --no-default-features both build
pg_adapter (Docker, DOCKER_HOST set) 13 passed
scripts/contract-all.sh 18 of 18 PASS (was 16): main 37 on all four targets, sweeper 2, panic 1, cron 1, worker 1, bindings 6, and two new cells native-memory csrfoff and worker-memory csrfoff, 6 each
scripts/mutants.sh 9 KILLED (the 7 before, plus the two new CSRF-switch mutants) and 2 guard refusals, 0 SocketNotFoundError
one-off, not in the matrix: scripts/contract.sh worker-cf csrfoff 6 of 6 (exercises wrangler.toml's var)

EXPECT_MAIN stays 37 (the new csrf_off_ tests are skipped in the main pass and selected by csrfoff, EXPECT_CSRFOFF=6); Stage 2's main stays 31.

Controls shown failing (counts are failed tests)

Check Broken variant Failed
Key hash, core (key_hash_tests, 242 cases) red before the multi-version lookup and the move existed 30
a build that skips the re-hash 13
a build that looks up only the current version 38
a build that accepts a row whose stored version is not the scheme that made its digest 16
rehash_api_key, memory adapter no compare-and-set / no positive check / no unique check / api_key reporting version 1 / insert without the positive check 32 / 4 / 6 / 51 / 3
rehash_api_key, Postgres vs the generated model (3 runs each, default 32 cases) no version in the WHERE / a move that keeps the version / api_key reporting version 1 3 of 3 runs each
Migration 0007 the first version, with an inline CHECK the test failed: 3 checks after 3 runs (Postgres adds an inline CHECK again on every ADD COLUMN IF NOT EXISTS); fixed with a named constraint, 1 after 3 runs
CSRF switch, core (752 tests) the pre-switch behaviour (mutant_csrf_always) / the switch ignored when on / mutant_skip_csrf 6 / 6 / 29
CSRF switch, HTTP main pass mutant_csrf_never (reports csrf_enforce: true, never enforces) 5 of 37
CSRF switch, HTTP csrfoff pass mutant_csrf_always 3 of 6 (the other three do not depend on enforcement)
The /_info guard a main pass against a server started with enforcement off, and a csrfoff pass against one started with it on both refused, exit 5 (also rows of mutants.sh)
Worker default wrangler.memory.toml's var flipped to "on", csrfoff pass guard refused (exit 5): the toml var is what makes that Worker's default off; --var ...:on overrides it in the other passes

Not verified

  • scripts/stage2-contract.sh: the new csrfoff pass and the csrf_enforce guard are written and not run (no deployed Worker). wrangler.stage2.toml now sets THRUST_CSRF_ENFORCE = "on", which has not been deployed.
  • A real second hash scheme. The hatch is proved with a stand-in (HMAC-SHA256 under a fixed test pepper, cfg(test) only, RFC 4231 vectors checked). No contract test can observe a re-hash over HTTP, and nothing deployed has run the migration or a move (G-14).
  • The SQLite port of 0007 (feat(db): engine pass, search routes and the FR-22 order; spike 0002 decides Postgres #77's: it needs its own spelling of "add the column once", and number 0006 is left free for it).
  • The stock React app. That it sends the token only on its auth form posts is read from research/0012 §5, not run.
  • That openidconnect uses rsa only to verify with the issuer's public key: the note in the docs repeats issue chore(ci): enforce the clippy deny list, cargo fmt --check and cargo-deny; forbid sqlx, sea-orm, diesel in check-deps.sh #40's reading, which asks for it to be confirmed against the crate's source when the ignore is written. No deny.toml exists yet.

Deviations from the brief, and why

  • contract-all.sh is 18 cells, not 16: the new pass needs cells (native-memory and worker-memory, so the Worker's reading of the var and of the toml default is exercised).
  • Migration 0007 is three statements (ADD COLUMN IF NOT EXISTS, then DROP CONSTRAINT IF EXISTS and ADD CONSTRAINT for the CHECK), not the single statement with an inline CHECK: the single statement is not idempotent (see the control above). It is still plain SQL with no DO block.
  • CoreConfig::default().csrf_enforce is true (the rule as ADR-0052 wrote it, so every existing test keeps its meaning); the roots default it off, as decided.
  • The csrfoff pass starts the target with no setting at all (a default value in worker-dev.sh passes no --var), so it also shows the roots' own default.
  • scripts/mutants.sh gained a third field (the pass) and two rows that start a server with the other setting (a knob, THRUST_SERVER_CSRF_ENFORCE, that only that script sets).
  • The unit tests of the key hash include tests/common through #[path] and extern crate self as thrust_core under cfg(test), so they reuse the integration tests' world instead of building a second one.

🤖 Generated with Claude Code

aRustyDev and others added 3 commits October 23, 2026 23:28
Q-0052.3, owner decision 2026-10-24. API keys stay the plain SHA-256 of a token of at least 256 random bits, with no
pepper (a leaked digest cannot be reversed with or without one, a pepper would add a secret and a rotation story to every
target for no gain, and sessions took the same decision on 2026-10-22). What this adds is the escape hatch: a pepper, or
any second scheme, can be introduced later WITHOUT invalidating a single key.

- Migration 0007 adds api_keys.hash_version smallint NOT NULL DEFAULT 1 with a positive CHECK (0006 is left to the SQLite
  adapter). Every existing key is version 1. The CHECK is its own named statement: ADD COLUMN IF NOT EXISTS skips the
  column but NOT an inline CHECK, which Postgres adds again on every run (the first version of the migration test failed
  with 3 checks after 3 runs, which is how this was found).
- thrust-ports: hash_version on NewApiKey and LiveApiKey, and Database::rehash_api_key(id, from_version, new_hash,
  new_version), a compare-and-set that is a no-op for a row that is not at from_version. Memory and Postgres adapters.
- thrust-core: api_key_hash(version, token) (1 = plain SHA-256, the only scheme that ships), API_KEY_HASH_CURRENT and
  API_KEY_HASH_SUPPORTED, and the two CoreConfig fields they default. authenticate_api_key looks the key up under every
  version the process reads (current first) and accepts a row only when it is stored under the version whose digest
  found it; a key found under another version than the current one is moved by the same Background task that stamps
  last_used_at, a failed move ignored. create_api_key stores the current version. No Ports field, no env var, default
  behaviour unchanged.

Tests (generative first). The mechanism is proved with a stand-in scheme, version 2 = HMAC-SHA256 under a fixed test
pepper, that exists only under cfg(test) in thrust-core (its HMAC checked against RFC 4231 vectors): stored version x five
configurations x four key states x four usage patterns (242 cases in the module), a model_ sequence test against a
reference model with its generator coverage control, and the adapter contract of rehash_api_key exhaustively in the memory
adapter and as generated sequences against real Postgres. The no-plaintext column test lists hash_version, and a new test
pins the upgrade path of a database that has keys before 0007.

Controls shown failing (counts are failed tests):
- core, red before the lookup and the move existed: 30 of 242
- a build that skips the re-hash: 13; one that looks up only the current version: 38; one that accepts a row whose stored
  version is not the scheme that made its digest: 16
- memory adapter: rehash without the compare-and-set 32, without the positive check on rehash 4, without the unique
  check 6, api_key reporting version 1 for every key 51, insert without the positive check 3
- Postgres against the generated model, 3 runs each at the default 32 cases, every run failed: rehash without the
  version in its WHERE, a rehash that keeps the version, api_key reporting version 1
- migration: 3 checks after 3 runs with the inline CHECK, 1 after the fix

Refs: plane-byd.11.6.1
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d exists

Q-0050.8, owner decision 2026-10-24. ADR-0052's double submit (option A) is built and stays built, but it is NOT enforced
while the stock Plane frontend is what talks to this server: that app sends the token only on its auth form posts, so
enforcing it on JSON mutations would break it. Long term the frontend is custom and enforcement is the target.

- thrust-core: CoreConfig::csrf_enforce. `authenticate_request` asks a cookie-authenticated mutation for the token only
  when it is on. Core's default is ON (the rule as ADR-0052 wrote it, so every test that builds a CoreConfig keeps its
  meaning); off changes one thing, the token is not consulted for a cookie mutation. The cookie, GET auth/csrf, csrf_ok
  and a bearer token or an API key are untouched.
- The composition roots read it and default it OFF: THRUST_CSRF_ENFORCE in thrust-server, the same var in thrust-worker,
  declared in wrangler.toml and wrangler.memory.toml (off) and wrangler.stage2.toml (on). /_info (test routes) reports
  csrf_enforce.
- The contract targets keep the meaning of their CSRF tests: contract.sh, worker-dev.sh and stage2-contract.sh run with it
  on, and a vacuity guard reads /_info and refuses a pass whose server says otherwise (exit 5). A new pass, csrfoff, starts
  the target with NO setting so that it also shows the roots' own default (the native server's, and the Worker's [vars]):
  6 tests (EXPECT_CSRFOFF=6) on native-memory and worker-memory, two new contract-all cells. The main pass is still 37 of 37
  (`--skip csrf_off_`), stage 2 main still 31. stage2-contract.sh has the pass and the guard too (not run: no deployed
  Worker).
- scripts/mutants.sh: mutant_csrf_never (switch ignored when on, killed by the main pass) and mutant_csrf_always (ignored
  when off, killed by csrfoff), and two rows that start a server with the other setting and require the guard to refuse it.

Tests. Core: the credential matrix gains an enforce dimension (192 cases, was 96) plus one test that off changes nothing
but the cookie mutation. HTTP: the 126-request credential table is parameterised by enforcement and runs in both passes,
and the csrf_off_ tests mirror the enforcing ones request for request (a cookie mutation with no token, a wrong one, an
empty one, no CSRF cookie, all accepted; sign-out, sign-out-everywhere and the key routes with the cookie alone; the
credential still checked: dead cookie 401, guest 403).

Controls shown failing (counts are failed tests):
- core, the pre-switch behaviour (mutant_csrf_always): 6 of 752; the switch ignored when on: 6; mutant_skip_csrf: 29
- contract main pass against mutant_csrf_never: 5 of 37 (the guard passes, the server reports csrf_enforce true)
- contract csrfoff pass against mutant_csrf_always: 3 of 6 (the three that do not depend on enforcement still pass)
- the guard: a main pass against a server started with enforcement off, and a csrfoff pass against one started with it on,
  both exit 5 with "VACUITY GUARD: csrf_enforce"
- worker-memory csrfoff with wrangler.memory.toml's var flipped to "on": exit 5 from the guard, so the toml var is what
  makes that Worker's default off; worker-memory main with `--var ...:on` overriding the toml "off": 37 of 37, guard true

Refs: plane-byd.11.6.2
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The owner's decisions of 2026-10-24 on the questions PR #76 left open, as dated notes (the text they amend is kept):

- ADR-0052: Q-0052.3 answered. API keys stay plain SHA-256 with no pepper, and the hash_version hatch is described: what
  is built, the steps to introduce a pepper, the query that shows progress, what happens to idle keys, that dropping v1
  invalidates the keys still at v1 on purpose, and the rollback caveat. Q-0050.8: option A is built and not enforced
  while the stock frontend exists, with the switch, the interim posture stated plainly (only SameSite=Lax, HttpOnly,
  Secure and the __Host- prefix protect the cookie, as in Plane) and the flip criterion.
- ADR-0141: the baseline line "API keys stored as peppered hashes with prefix lookup" is amended in place with a pointer,
  and a dated note says SHA-256 of 256 random bits, no pepper (a pepper is for low-entropy secrets), lookup by digest.
- ADR-0050: Q-0050.8 outcome, and Q-0050.9's direction (a Workers VPC service over a tunnel to id.auth.woven, the CNPG
  pattern of ADR-0094; recorded for M6, not built), and that issue #40 now carries an explicit cargo-deny ignore for
  RUSTSEC-2023-0071 (the rsa crate) with a re-check note.
- QUESTIONS.md: Q-0052.3 and Q-0050.8 answered, Q-0050.9 direction recorded and still for M6.
- PLAN.md: the CSRF flip is an explicit item of M4 (the Dioxus frontend replacing the stock one), the Workers VPC service
  to the issuer an explicit item of M6.
- research/0012 points at the outcomes and at issue #40 for the rsa note; spikes/README.md likewise.
- docs/src: flows/app.md (the enforcement switch, the key hash version, /_info, csrf_failed only while enforcement is on),
  architecture/app.md (migration 0007, rehash_api_key, the two CoreConfig fields), the testing pages (the csrfoff pass and
  its guard, 18 cells, the two new mutants, defect X22 widened and X29 added, gap G-14, G-12 updated) and cicd.md.

Defect and gap ids are the next free ones on origin/main after #38's X21 to X24 and G-12 (PR #77 plans X25 to X28 and G-13).

Refs: plane-byd.11.6.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 1de2dac into main Oct 24, 2026
28 checks passed
@aRustyDev
aRustyDev deleted the feat/auth-followups branch October 24, 2026 03:57
aRustyDev added a commit that referenced this pull request Oct 24, 2026
Reconciles the engine cells with the identity tables, sign-in, API keys and the OIDC login that
landed on main while the deployed runs were going. A merge, not a rebase: the branch is pushed and
there is to be no history rewrite and no force-push.

Conflicts were adjacency and are resolved by keeping both sides (manifests, the Postgres adapter's
migrations 0005 to 0007 in order, the model test's 82 step classes, the API's routes, the contract
scripts' passes and guards, the testing docs' defect and gap ids, PLAN.md, the spikes README).

The SQLite twin takes on what the port now asks of a Database: migrations 0005 (identity) and 0007
(API key hash version) in its own dialect, the fourteen identity methods, `session` that requires an
existing active user, `seed` that creates the fixture's users. AppDo builds the new Ports fields
(rng, argon2id hasher, OIDC provider) and reads the same CoreConfig as the Worker's other sets. The
cell configs carry THRUST_CSRF_ENFORCE.

tests/identity.rs is the memory adapter's identity matrix (183 cases) run against SqliteDatabase. It
passed on the first run; control: with the is_active joins of `session` and `api_key` removed, 4 of
the 183 fail.

Run on the merged tree, all local: native-sqlite main 37 of 37, worker-do main (wrangler dev) 37 of
37 with the auth and OIDC tests, native-pg main 37 of 37, contract-all 18 of 18, worker-do csrfoff,
do and engine, native-sqlite csrfoff and engine, nextest 1256 passed, pg_adapter 13 of 13,
mutants.sh 17 killed and 2 guard checks refused, check-deps, wasm32 builds. Nothing was deployed: the
deployed numbers in research/0011 predate this merge (section 14), and the identity code has not run
on a deployed Worker. Argon2id at the real cost blocks the one object for the length of each hash
(26 ms locally); research/0011 section 10, item 6.

Refs: plane-byd.11.4
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Oct 24, 2026
…o cell is archived on a tag

The owner decided spike 0002 on 2026-10-24:
- criterion 3 is read on the realistic paged list (a 1,000-item project in a ~100k-item database):
  both cells pass; the unpaged 10,000-item list is a slice artifact both engines fail and becomes a
  pagination requirement of the list endpoint (issue #58);
- a projected cost satisfies criterion 5: both cells pass as projected;
- Q-0040.6: Postgres is the default.

ADR-0040 moves to `accepted` as Postgres through Hyperdrive, with a "Decision — spike 0002" section:
the readings, the evidence, worker-do as a viable fallback and why it was not chosen (it serialises
the instance, argon2id sign-in included; the object's location is fixed at creation; backup and
restore of a Durable Object was not exercised; it would reopen ADR-0042, 0044 and 0045), and what
Postgres staying the default means: the TLS item (FR-09, #41), the cluster coupling (FR-10) and the
CNPG infrastructure are not moot. The Postgres follow-ups that stand are recorded, not changed: the
8-connection per-PR role cannot host two Hyperdrive configs, the adapter's "db error" drops the
SQLSTATE and message, Hyperdrive caching stays off (4 of 21 tests fail on read-after-write), and
worker-pg placement must be us-east-1 (665-738 ms create from a distant client without it).

ADR-0041 (isolation under Postgres), ADR-0043 (FR-22 confirmed on the platform: it is the order of
record), ADR-0045 and ADR-0083 (the pg_trgm path decided) get notes. QUESTIONS.md answers Q-0040,
Q-0040.1, Q-0040.6, Q-0006.6 and Q-0083.1 (Q-0040.6 as the owner's decision) and adds evidence to
Q-0040.5. PLAN.md, SPEC.md, ARCHITECTURE.md, the spikes README and the spike 0002 record carry the
decision. research/0011 records the decision, the tag `spike/0002-worker-do`, what was archived and
what stays, and says plainly that its worker-do figures were taken before #76 and #78 were merged and
that the SQLite identity code never ran on a deployed Worker.

Refs: plane-byd.11.4.9
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Oct 24, 2026
…decides Postgres (#77)

* feat(sqlite): SQLite adapter and the native-sqlite target

Spike 0002, cell B (issue #37), first half: the `Database` port on SQLite, and
its native twin as a contract target. The Durable Object cell (`worker-do`)
reuses this crate unchanged.

thrust-adapters-sqlite is written once against a small synchronous `Sql` trait
(query, execute, atomically). `NativeSql` implements it on rusqlite (bundled,
feature `native`, never compiled for wasm32). The Durable Object's SqlStorage
is the second implementation, in the next commit.

How ADR-0045's explicit `Tx` maps onto SQLite (risk R1, answered here for the
twin; the object's transactionSync is next): the `Tx` buffers its writes and
answers the use-case's mid-transaction questions (duplicate external key, is
this row live) from the committed rows plus its buffer; `allocate` reads the
counter; `commit` applies the counter advance and every write in ONE
`Sql::atomically` and checks the counter is still where `allocate` read it;
rollback and drop discard the buffer. A gate lets one `Tx` be open at a time,
so nothing moves the counter between `allocate` and `commit` on either twin,
and the counter check makes a hole in the gate an error, never a duplicate.

Migrations: `0001_init.sql` is the end state of the Postgres files 0001-0004
(a SQLite database starts empty, so there is nothing to patch). The runner
applies each file once, as one transaction with its ledger row, one statement
per exec (the object's `exec` is per statement), and refuses a database that a
newer build migrated.

Evidence, red first:
- model test (copy of the Postgres adapter's planner, hermetic, rusqlite in
  memory): with every `Database` method `todo!()` it failed
  ("not yet implemented", minimal input a single create); implemented, 256
  generated sequences pass, and the generator-coverage control reaches every
  step class.
- must-fail controls, each shown failing against a deliberately broken build:
  `mutant_non_atomic_commit` (statements applied one by one) fails 15 of the 36
  cases of `prop_a_commit_that_fails_anywhere_leaves_nothing` ("a failed commit
  left a work item behind"); `mutant_dup_sequence` and `mutant_gate_leak` fail
  the model test; a splitter that ignores BEGIN, and a runner that does not use
  a transaction, each fail their property in migrate.rs.
- `scripts/contract.sh native-sqlite main`: 21 of 21, `/_info` reports
  adapters=sqlite. Control: the same pass with `mutant_dup_sequence` fails 8
  tests (a first version of that mutant, which only duplicated within one
  transaction, left all 21 green and was rewritten: the slice allocates once
  per transaction).
- nextest --workspace 252 passed; doctests pass; check-deps exits 0 and now
  asserts rusqlite and libsqlite3-sys are absent from the Worker graph.

native-sqlite is opt-in: it is not in contract-all.sh, so it is not a required
CI check until ADR-0040 decides.

Refs: plane-byd.11.4.1
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* feat(worker): worker-do, the instance-level Durable Object cell

Spike 0002, cell B (issue #37), second half: the SQLite adapter inside ONE
Durable Object for the whole instance, driven by the same contract suite.

AppDo (thrust-worker/src/app_do.rs) builds the `App` once in `new`, with
`Background` on `State::wait_until`, runs migrations in `new` inside
`blockConcurrencyWhile` (a failing migration resets the object), and serves the
shared axum router over `DoSql`. The front Worker forwards every API request to
`get_by_name_with_location_hint("instance", "enam")`; the queue consumer and the
cron handler forward through the object too (`/_do/consume`, `/_do/sweep`),
because they need the database. `/_do/*` is the Worker-to-object protocol and a
client path that starts with it is a 404. The old per-request body is now
`serve()`, shared by both roots. New adapter set `durable`, `wrangler.do.toml`
(v2 migration adds AppDo), `worker-dev.sh` and `contract.sh` target `worker-do`
(its `/_info` reports adapters=durable, target=worker). app_do.rs is added to
the SystemScope::mint allowlist in check-deps.sh.

R1, answered: how ADR-0045's explicit `Tx` maps onto the object. workers-rs 0.8.7
binds no `transactionSync`, so `DoSql::atomically` calls it through
`Storage::as_raw()` and `js_sys::Reflect`, with a borrowed wasm-bindgen closure
whose `Err` is thrown (that is how transactionSync is told to roll back). The
`Tx` buffers its writes and commits them in one `transactionSync` (see
thrust-adapters-sqlite); nothing yields between `allocate` and `commit`, and a
gate makes that the adapter's own property rather than the use-case's.

Evidence, red first, on the REAL runtime (wrangler dev, local workerd):
- `/_test/do/tx-control` runs the commit-atomicity scenario (every statement a
  commit issues failed in turn, 1 to 3 creates plus a soft delete, 36 cases, 18
  of which fire) inside the object. With `DoSql::atomically` temporarily a plain
  call (no transaction) `worker_do_tx_commit_is_atomic_on_the_objects_sqlite`
  FAILED: "a failed commit changed the database" (an item without its outbox
  row, a counter advanced for nothing). With transactionSync: 0 violations, all
  18 faults fired, and each retried transaction committed.
- `worker_do_tx_naive_mapping_is_caught` runs the same scenario over `Unatomic`
  (atomically = no transaction) on the real SqlStorage and requires violations:
  the control for the control. The probe answers 404 without the admin token.
- `scripts/contract.sh worker-do main`: 21 of 21; `sweeper` 2 of 2, `cron` 1 of 1
  (so queue and cron forwarding work), `tx` 2 of 2. `worker-memory main` still
  21 of 21 after the serve() refactor.
- check-deps exits 0 and the Worker graph now contains thrust-adapters-sqlite
  with rusqlite and libsqlite3-sys absent (no longer a vacuous check). Control:
  without the app_do.rs allowlist entry it exits 1 and names both mint sites.
- The scenario is a library function (`thrust_adapters_sqlite::control`), so
  tests/commit.rs runs it on rusqlite too: 50 hermetic tests in the crate pass,
  and `mutant_non_atomic_commit` fails 15 of the commit cases.

worker-do is opt-in: not in contract-all.sh, so not a required CI check until
ADR-0040 decides.

Refs: plane-byd.11.4.2
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* test(contract): the 50-writer create test and its controls

Spike 0002 exit criterion 1 (R-F2, ADR-0040 S1, ADR-0043 B1): 10,000 creates
from 50 parallel writers in one project give no duplicate `sequence_id`, then
deletes and further creates show no number is reused.

`scripts/contract.sh <target> engine` is a new pass over its own test binary
(`tests/engine.rs`, tests named `engine_`), so the main pass and EXPECT_MAIN are
untouched; EXPECT_ENGINE (1 for now) is mirrored in stage2-contract.sh, which
also gains `tx` and a THRUST_EXPECT_ADAPTERS=durable guard for a deployed
worker-do. The pass starts the target with RATE_LIMIT=1000000: the main pass's
30 per user per window would refuse 200 creates.

The test (10k in total, as the issue and the spike say, not 50 x 10k): 50
bounded tasks, 200 creates each, asserts every number once and contiguous from
1, `sort_order` unique and increasing with it; soft-deletes every 7th number
from 50 tasks at once; 500 more creates must continue at 10,001 and never hand
out a deleted number; an admin's with_deleted listing shows 10,500 rows in
sequence order whose tombstones are exactly the deleted numbers. Writers stop
at the first non-201, so a broken engine fails in milliseconds and says why.

Passes (local, one laptop, debug server builds, loopback): native-memory 1.4 s,
native-sqlite 3.2 s, native-pg 18.9 s (Docker Postgres 16), worker-do 20.4 s
(wrangler dev). 10,000 + 500 creates and 1,428 deletes in each.

Controls, each shown failing for the right reason:
- native-memory + mutant_dup_sequence: "9999 duplicate sequence ids in 10000
  creates, the first: 1".
- native-sqlite + mutant_dup_sequence: 50 of 50 writers get HTTP 409, "UNIQUE
  constraint failed: work_items.project_id, work_items.sequence_id" (the
  engine's own index refuses the duplicate).
- native-sqlite + mutant_no_gate (transactions not serialised): 39 of 50 writers
  get HTTP 500 and the server logs "the sequence counter ... moved between
  allocate and commit" 39 times. So the gate is what makes allocation safe, and
  the counter check turns a hole in it into an error, never a duplicate.
mutants.sh runs all three, and the SQLite adapter's own mutants (non-atomic
commit, gate leak, duplicate number) hermetically. Its kill_check could not see
a failure printed under --nocapture (`FAILED` lands on a line of its own), so
the three engine rows first reported SURVIVED; it now counts cargo's own
`test result: FAILED. N passed; M failed`, and a passing engine log is checked
not to count as killed.

Refs: plane-byd.11.4.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* feat(api): search and bulk-seed routes for the engine cells

Spike 0002 exit criterion 2 (FTS plus trigram, ADR-0083) and the 100k-item
measurements both need routes the slice did not have.

`GET /api/_slice/workspaces/{slug}/projects/{id}/work-items/search?q=` returns
the visible work items whose name or description contains `q`, any case
(Plane's `icontains`), in sequence order, at most 100, under the same permission
as a listing; a blank or over-long `q` is a 400 and `q` is not trimmed. It joins
the retired-prefix table. `POST /internal/seed-work-items` (test routes + admin
token, like /internal/seed) bulk-inserts live work items into one project,
numbered from that project's own counter in one transaction (ADR-0043: a bulk
path takes the same allocator). Both are new `Database` methods
(`search_work_items`, `seed_work_items`).

Engines (migration 0006 on both sides, as agreed with #38 which owns 0005):
- Postgres: `pg_trgm` GIN indexes on name and description, `ILIKE ... ESCAPE`
  with the query's `\`, `%`, `_` escaped. The seed is one `unnest` insert per
  batch, so 5,000 rows are one round trip. pg_trgm is a trusted extension, but
  a schema-only role cannot install it: on the shared dev database an admin
  must (noted in the migration, for the deployed run).
- SQLite (native and Durable Object): an external-content FTS5 table with the
  `trigram` tokenizer, kept in step by insert/delete/update triggers, with a
  `rebuild` that makes the file the expand migration of a seeded database. A
  query of 3+ characters is an FTS5 phrase; 1-2 characters scan with LIKE when
  ASCII and, when not, in Rust a page at a time (SQLite's LIKE folds ASCII
  case only: a differential test found `é` missing `ÉCOLE`, pinned in
  tests/search.proptest-regressions, then fixed).
- Memory: the reference, a scan with `to_lowercase().contains`.

R3, answered by asking the real runtime (`/_test/do/fts-probe`, local workerd
from wrangler 4.123.0): the Durable Object's SQLite HAS FTS5 and the `trigram`
tokenizer. A MATCH finds substrings inside a word, across spaces and across
non-ASCII case ("ÉCOLE" by "école"); a 2-character MATCH finds nothing
(a trigram needs three), LIKE finds it; json_each works. `sqlite_version()` and
`PRAGMA compile_options` are refused in a Durable Object (SQLITE_AUTH), so the
version is not known. The deployed run asks the same probe again.

Evidence, red first:
- the three new `engine_` tests failed against a target without the routes
  (405 on search, 404 on seed); then pass on all five engines: native-memory,
  native-sqlite, native-pg (Docker Postgres 16), worker-do and worker-cf (local
  wrangler, Docker Postgres), 4 of 4 (EXPECT_ENGINE 1 -> 4, mirrored in
  stage2-contract.sh; EXPECT_MAIN untouched at 21, still 21 on native-memory
  and native-sqlite).
- parity: 300 generated items, 20 soft-deleted, 400 generated queries (1-8
  characters, case flipped, `%` `_` `\` quotes in the alphabet; 14,196 hits, 98
  empty, 57 at the cap) answer exactly what `icontains` answers, on every
  engine. Controls: the corpus must tell a case-sensitive matcher and a
  prefix-only matcher from `icontains` on more than 20 queries each; the memory
  adapter with `mutant_search_case_sensitive` fails 2 of the 4 engine tests;
  hermetic `prop_search_matches_the_reference_adapter` fails with LIKE
  unescaped and with unquoted FTS phrases, and an FTS insert trigger dropped
  makes a 6-character query miss a row a 2-character query finds.
- freshness: a created item is found by the next search, a deleted one is not
  (the bound is 60 s; nothing waited); cross-tenant 404, outsider 403, no
  token 401.
- also: worker-cf's 50-writer run failed once at Postgres's default
  max_connections=100 (one writer, "postgres handshake: db error"; the local
  Hyperdrive emulation does not pool). The engine pass starts the container
  with max_connections=400; 2 of 2 runs then pass (112 s and 117 s).
- the `tx` pass of contract.sh worker-do became `do` (3 tests: the two Tx
  controls and the FTS5 probe).

Refs: plane-byd.11.4.4
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* perf(postgres): allocate the sequence outside the create transaction

FR-22 (ADR-0043 round 29, spike 0002 step 2): the counter upsert was the first
statement of the create transaction, so a project's counter row stayed locked
through the work item insert, the outbox insert and the COMMIT, and creates in
one project queued behind one another for that whole span (stage 2 measured
create p95 296 ms at c=1 and 559 ms at c=8).

A `PgTx` now checks its connection out at `begin` but opens no transaction until
its first write (`ensure_tx`). `allocate` runs before that, one statement in
autocommit, so the row is locked for one round trip. A second `allocate` in a
transaction that is already open takes its number on another connection (on
this one the upsert would join the transaction and keep the lock); the normal
create never does. A transaction that wrote nothing needs no COMMIT and its
connection goes back clean; one dropped mid-transaction is still discarded.
Statements per create are unchanged (BEGIN just moved after the upsert).

The price, accepted by ADR-0043: a number taken by a create that then fails or is
abandoned is not given back. That makes three tests of the Postgres adapter
restate a property they used to assert, which AGENTS.md rule 3 allows only with
the reason here: the property ("a rollback leaves no gap", the counter row was
transactional) was given up on purpose by FR-22, as the ADR said it would be.
- `rollback_is_atomic_and_unique_violation_is_a_conflict`: after the conflict
  the next number is 3, not 2.
- `an_abandoned_transaction_does_not_poison_the_pool`: the abandoned
  transactions now WRITE an item (an allocation alone no longer opens a
  transaction), and the test checks that none of it is visible and that the next
  number is 41. It still kills `mutant_discard_noop` (2 tests fail on it).
- `model_postgres_adapter_matches_the_reference_model`: counters advance on
  every end of a transaction, rows only on commit; a new step class
  (NumbersKeptAfterAbort) is required by the generator-coverage control; the
  shrunk counterexample [create+rollback, create+commit] is pinned in
  mod.proptest-regressions.
`concurrent_allocation_is_unique_contiguous_and_serialised`, the contract suite
(21 of 21 on native-pg and worker-cf) and the engine pass (4 of 4, 50 writers,
on both) pass unchanged. The SQLite twin writes its counter at commit and keeps
the no-gap property; memory has always had gaps.

Measured before and after, native-pg, release bench, n=200, 3 runs per arm:
- Loopback (RTT ~0.1 ms): create p95 at c=1 6.1 / 2.4 / 4.9 ms before, 5.4 / 2.9
  / 4.1 after; at c=8 21.0 / 36.9 / 21.6 before, 20.0 / 10.7 / 19.2 after. The
  spread inside an arm is larger than the difference between arms: the lock is
  held for microseconds, so the reorder is not visible here.
- With a 5 ms one-way delay between server and Postgres (new
  scripts/pg-delay-proxy.py, `THRUST_PG_LATENCY_MS=5 scripts/contract.sh
  native-pg bench`; RTT 10 ms, like Hyperdrive's `select 1` p50 of 9-10 ms):
  create p95 at c=1 106 / 92 / 93 ms before, 93 / 93 / 96 after; at c=8 344 / 360
  / 358 ms before, 100 / 97 / 105 after (p50 at c=8: 225 / 215 / 230 before, 90 /
  88 / 91 after). Before, c=8 was 3.7 times c=1, the shape of stage 2's 296 and
  559 ms; after, c=8 is within 10 percent of c=1. List and the rest did not
  move. This is a stand-in for the platform, not the platform: the deployed
  numbers are research/0011's (bead plane-byd.11.4.7, blocked).

Refs: plane-byd.11.4.5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* chore(worker): measurement tooling for the deployed worker-do cell

The plan gives bead plane-byd.11.4.6 (the deployed worker-do run) no commit, because
its numbers go to the research note. The tooling those numbers need does not exist
yet and has to be reproducible, so it lands here, before the run.

- scripts/spike-0002-do.sh and wrangler.do.stage.toml: create the R2 bucket and the
  two queues, deploy the Worker as `thrust-spike-do`, put the admin secret from a
  0600 file; `down` removes the queue consumer, the Worker, the queues and the
  emptied bucket in the order research/0004 section 10.7 found; every step is
  appended to a UTC ledger. No ids and no credentials are in the config.
- `contract.sh <target> scale` (new bench_scale binary): seeds 100,000 work items
  in 100 projects through the bulk route, then times a listing of a 1,000-item
  project and of a 10,000-item one (the slice's list is unpaged, so 100k items in
  one project would be a 45 MB answer), search (common word at the cap, a phrase,
  a miss, a 2-character scan) and create, from the client's side.
- AppDo probes, admin-gated like the others: `/_do/usage` (rows read, rows written
  and database bytes: the numbers Durable Object SQLite is billed by, counted by
  DoSql from the cursors), `/_do/cost-probe` (rows per create, per relay mark, per
  consumer insert, per soft delete, per bulk-seeded item, per list and per search,
  and bytes per item with every index and the FTS5 table), `/_do/migration-story`
  (expand, FTS5 build, contract on a copy of the live data, one phase per call so
  the client can time it, and the real runner given a migration that fails halfway).
- the `do` pass of contract.sh worker-do grows to 5 tests: the cost probe must count
  writes for creates and the FTS5 index, count none for reads, and see a 2-character
  query scan; the migration story must run its phases and a failed migration must
  leave no table and no ledger row while the object keeps serving. First run of the
  cost probe, local workerd, per create: 9.0 rows written and 7.0 read; per
  bulk-seeded item: 5.0 written; ~950 bytes stored per item with its indexes and FTS5.
  It also showed that a 3-character indexed search reads about the project's size in
  rows (SQLite scans the project through work_items_list and uses the FTS5 matches as
  a filter): reported, not asserted, and the test says so.
- feature `mutant_broken_migration` (sqlite adapter, thrust-worker) adds a migration
  whose third statement fails, for the demonstration of an object that cannot start.
  Never in a real build.

Refs: plane-byd.11.4.6
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(postgres): qualify the trigram operator class

Migration 0006 created its trigram indexes with an unqualified `gin_trgm_ops`.
The per-PR roles of the shared dev database (pr-schema.sh) have a ROLE-LEVEL
`search_path = pr_<n>` and nothing else, so when pg_trgm lives in `public` the
operator class is not found and the migration cannot run as that role, which is
the role the deployed `worker-pg` run migrates as.

Reproduced first, on a throwaway postgres:16-alpine: a NOSUPERUSER role with
`ALTER ROLE ... IN DATABASE thrust SET search_path = pr_1001` and its own schema
(exactly what pr-schema.sh makes), pg_trgm installed in `public` by the
superuser, migrations 0001 to 0004 applied as that role (all exit 0), then the
shipped 0006:

  NOTICE:  extension "pg_trgm" already exists, skipping
  ERROR:  operator class "gin_trgm_ops" does not exist for access method "gin"

The fix is `public.gin_trgm_ops` in both indexes, and `CREATE EXTENSION IF NOT
EXISTS pg_trgm WITH SCHEMA public` so that a superuser's CREATE EXTENSION puts the
extension where the qualified name looks whatever its session's search_path is.
After it:
- as pr_1001 (search_path pr_1001, extension in public): 0006 exits 0, again
  exits 0 (idempotent), both indexes are created in pr_1001, and with
  enable_seqscan off `ILIKE '%fix%'` on name or description is a BitmapOr of the
  two trigram indexes.
- as the superuser with a non-public session search_path (s2) and no extension
  yet: 0001-0004 and 0006 exit 0, pg_trgm is installed in `public`, the indexes
  are in s2.
- the path the native-pg target uses (superuser, default search_path, fresh
  container): `contract.sh native-pg main` 21 of 21, `engine` 4 of 4 (search
  parity included), pg_adapter 10 of 10.
Not shown: the same run on the shared dev database itself (cluster access is not
part of this change), and a Hyperdrive connection.

Refs: plane-byd.11.4.4
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* fix(worker): take the Cloudflare account id from the environment

scripts/spike-0002-do.sh (fe36240) exported the Woven Cloudflare account id as a
literal. The package is public and redacts that id (spikes/README.md,
"Redactions"; research/0004 writes `<cloudflare-account-id>`), and the plan said
it was not to be committed anywhere. The script now requires CLOUDFLARE_ACCOUNT_ID
in the environment and says why. The id is an identifier, not a credential, and
nothing else in the tree carries it; it remains in the history of fe36240 on this
branch, which only a rewrite of that commit would remove (the owner's call).

Verified: without the variable the script stops with the message; with it,
`status` runs and shows the torn-down cell (no queue, no bucket, no worker).

Refs: plane-byd.11.4.6
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs: engine cells results (research 0011) and the spike 0002 record

The parts of W9 (bead plane-byd.11.4.9) that do not depend on the `worker-pg` cell.
ADR-0040 stays `proposed`: it gets an update note with the evidence so far and the
statement that the decision waits for `worker-pg`. Nothing here decides the engine.

- research/0011-database-engine-cells.md: every measured number with its conditions
  and caveats (one US laptop as the only client vantage, not the origin region; the
  FR-22 delay-proxy result is a stand-in; the list p95 result depends on list shape,
  a 1,000-item project against an unpaged 10,000-item one), the R1 and R3 answers,
  R2 measured, billed rows per operation and the cost PROJECTION (not reconciled:
  the owner skipped the 24-hour run because there is no real traffic), the migration
  story and its failure case, the outbox fast-path gap after eviction, `/healthz`
  through the object, the ASCII-only LIKE finding, the pg_trgm role finding, the
  teardown ledger, and a list of what was not measured (worker-pg on the platform,
  caching on versus off, the placement re-run, the 24-hour reconciliation, the
  distant-region bench, the real Email send).
- spikes/0002: main pass 15 -> 21 tests, the `Tx` and `contract.sh` anchors replaced
  by names, criterion 5 and step 9 say "projected, not reconciled" and why, step 10
  says the send has not been run, R1 marked answered, and a results table.
  spikes/README.md: the 0002 row and bead.
- ADR-0040, 0043, 0045, 0083: dated update notes (ADR-0043 says FR-22 is implemented
  and its mechanism confirmed, not confirmed on the platform). QUESTIONS.md: evidence
  appended to Q-0040, Q-0040.1, Q-0083.1 and Q-0006.6; Q-0040.6 is untouched.
  PLAN.md: the #37 row.
- docs/src/testing: defect-matrix X25 to X28 (PR #76 took X21 to X24) and the
  engine pass added to X4; gap G-13 (PR #76 took G-12); running, contract-suite and
  mutation pages list the new targets, passes and mutants; contributing/crates and
  features list the new crate and its features.
- scripts/spike-0002-do.sh: `status` now shows a Worker that no longer exists.

Not written, because they wait for `worker-pg`: the ADR-0040 decision, Q-0040.6, the
FR-22 confirmation on the platform, ADR-0041, and the comparison of the cells.

Refs: plane-byd.11.4.9
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* test(worker): tooling for the deployed worker-pg cell

scripts/spike-0002-pg.sh creates, inspects and tears down what the worker-pg run needs,
in research/0004 section 10.7's order: a per-PR role and schema on thrust-pg-dev
(pr-schema.sh), the migrations applied AS that role over a password login, two Hyperdrive
configs (caching disabled and enabled), the R2 bucket and the two queues, the Worker
(placement on or off, optional vars) and the teardown. The account id, the API token and
the database password come from the environment or 0600 files, never from the repo; the
deploy ledger line records variable names, not values.

wrangler.pg.stage.toml is the template the deploy fills in (Hyperdrive config id and the
placement block) into a throwaway copy.

Refs: plane-byd.11.4.7
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* test(worker): the one real email send, and a bench that can skip the delivery phase

Spike 0002 step 10. `stage2_email_real_send_once` sends once through the EMAIL binding of a
deployed Worker, from a sender domain the account owns to a verified destination (both come
from Worker variables set at deploy time, never committed). It runs a control first, an
unowned sender domain that the binding must refuse and that sends nothing, so a pass says
something about domain ownership. `scripts/stage2-contract.sh email` runs it and prints the
message id; it sends a mail each time it is run, so run it once.

`bench` takes THRUST_BENCH_SKIP_DELIVERY: against a Hyperdrive config with caching enabled
the create-to-activity poll sees a cached empty list and times out, and the panic took the
create, list and activity numbers with it.

Refs: plane-byd.11.4.8
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs: worker-pg on the platform, the distant region, caching, placement, FR-22 and the rule's outcome

Updates research 0011 (sections 1, 4.1, 6.2b, 6.3b, 6.5b, 6.7 to 6.10, 7.4, 9.1, 10, 11, 12, 13),
the spike 0002 record, and the ADR-0040, ADR-0041 and ADR-0043 notes with what the deployed
worker-pg run and the distant run measured. ADR-0040 stays proposed and Q-0040.6 is not answered.

The decision rule is applied to all five criteria for both cells. Criterion 3 passes on both for a
1,000-item project and fails on both for the unpaged 10,000-item list, and criterion 5 is a
projection on both, so the rule gives two answers depending on how the owner reads criterion 3
and whether a projection satisfies criterion 5; the note says which and what the owner decides.

Measured on the platform: the engine and main passes on worker-pg (4 of 4, 21 of 21), the list,
search and create numbers at about 132k items, the bench next to worker-do the same day and
stage 2's 296 and 559 ms, Hyperdrive caching on versus off (it breaks read-after-write: 4 of 21
contract tests fail, so it stays off), placement with and without (nothing from the origin's
region; 3.3 to 3.8 times faster creates from us-west-2), the distant bench for both cells (a
mid-distance vantage, not antipodal), FR-22 before and after in the same hour (about 15 percent
at the c=8 p50, nothing at c=1: the delay proxy overstated it), the cold start (nothing
measurable), the Postgres migration story and the one real email send (accepted; delivery not
verified). Findings: a per-PR role limited to 8 connections cannot host two Hyperdrive configs,
and a server error reads "db error" through the adapter. The teardown ledger, the verification
(only art-filestore and workflows-starter-template Workers, the mergify-foo queue, the
workflows-starter-template Durable Object namespace remain; no pr_ role or schema on
thrust-pg-dev; pg_trgm kept) and the not-measured list are in section 11 and 12.

Refs: plane-byd.11.4.7
Refs: plane-byd.11.4.8
Refs: plane-byd.11.4.9
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* test(worker): the worker-pg teardown empties its R2 bucket first

R2 deletes only an empty bucket and wrangler cannot bulk delete, so `down` calls the Worker's
r2purge probe (THRUST_SPIKE_PG_URL) before it removes anything; the run it came from purged 172
objects the contract tests had left.

Refs: plane-byd.11.4.7
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* chore(db): archive the worker-do cell and the SQLite adapter on a tag

The owner decided on 2026-10-24 that Postgres is the system of record, so the instance-level
Durable Object cell and the SQLite adapter built for spike 0002 are not merged. They are archived,
complete and with their docs, on the annotated tag `spike/0002-worker-do` (commit 021dc65 of this
branch), which research/0011 cites. This commit removes what only they needed:

- crates/thrust-adapters-sqlite (the adapter, its migrations 0001, 0005, 0006, 0007, its tests and
  mutants) and its Cargo.lock and workspace entries
- AppDo and the `durable` adapter set of thrust-worker, DoSql in thrust-adapters-cloudflare,
  wrangler.do.toml, wrangler.do.stage.toml, the worker_do_* tests, scripts/spike-0002-do.sh
- the sqlite arm of thrust-server and its mutant features
- the native-sqlite and worker-do targets, the `do` pass and their handling in contract.sh,
  stage2-contract.sh and worker-dev.sh; the SQLite rows of mutants.sh; the rusqlite and app_do.rs
  entries of check-deps.sh
- the SQLite rows of the testing and contributing docs; the defect rows pinned to the archived code
  (X25, X27, X28, X30) now say so and point at the tag

Kept, because it is engine-agnostic or Postgres: the engine pass and the 50-writer test (with the
memory adapter's mutants), the search route and the bulk-seed route with Postgres migration 0006
(pg_trgm, the qualified operator class) and the memory implementation, the FR-22 allocation order,
bench_scale, pg-delay-proxy.py, scripts/spike-0002-pg.sh, the Email probes and the one-send test.
Comments in the Postgres migrations and the model test that talked about the SQLite twin now point at
the tag (comments only: no statement changed).

The history of this branch still has the SQLite and worker-do commits, which a squash merge lists in
its body; they are the archived work.

Refs: plane-byd.11.4
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs: ADR-0040 accepted as Postgres; spike 0002 decided; the worker-do cell is archived on a tag

The owner decided spike 0002 on 2026-10-24:
- criterion 3 is read on the realistic paged list (a 1,000-item project in a ~100k-item database):
  both cells pass; the unpaged 10,000-item list is a slice artifact both engines fail and becomes a
  pagination requirement of the list endpoint (issue #58);
- a projected cost satisfies criterion 5: both cells pass as projected;
- Q-0040.6: Postgres is the default.

ADR-0040 moves to `accepted` as Postgres through Hyperdrive, with a "Decision — spike 0002" section:
the readings, the evidence, worker-do as a viable fallback and why it was not chosen (it serialises
the instance, argon2id sign-in included; the object's location is fixed at creation; backup and
restore of a Durable Object was not exercised; it would reopen ADR-0042, 0044 and 0045), and what
Postgres staying the default means: the TLS item (FR-09, #41), the cluster coupling (FR-10) and the
CNPG infrastructure are not moot. The Postgres follow-ups that stand are recorded, not changed: the
8-connection per-PR role cannot host two Hyperdrive configs, the adapter's "db error" drops the
SQLSTATE and message, Hyperdrive caching stays off (4 of 21 tests fail on read-after-write), and
worker-pg placement must be us-east-1 (665-738 ms create from a distant client without it).

ADR-0041 (isolation under Postgres), ADR-0043 (FR-22 confirmed on the platform: it is the order of
record), ADR-0045 and ADR-0083 (the pg_trgm path decided) get notes. QUESTIONS.md answers Q-0040,
Q-0040.1, Q-0040.6, Q-0006.6 and Q-0083.1 (Q-0040.6 as the owner's decision) and adds evidence to
Q-0040.5. PLAN.md, SPEC.md, ARCHITECTURE.md, the spikes README and the spike 0002 record carry the
decision. research/0011 records the decision, the tag `spike/0002-worker-do`, what was archived and
what stays, and says plainly that its worker-do figures were taken before #76 and #78 were merged and
that the SQLite identity code never ran on a deployed Worker.

Refs: plane-byd.11.4.9
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs: record the verification of the merged tree in research/0011

The tree without the archived worker-do cell: nextest 1,019 passed, doctests, check-deps, the wasm32
builds, contract-all 18 of 18, the engine pass 4 of 4 on the four remaining targets, pg_adapter 13
of 13, and mutants.sh with 11 mutants killed and 2 guard checks refused (0 SocketNotFoundError).

Refs: plane-byd.11.4.9
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
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