Skip to content

test(store): a Linux multi-process harness in CI, and per-process throttle/cache docs (#927) - #946

Merged
jimhoyd merged 3 commits into
mainfrom
claude/multiprocess-harness-927
Sep 29, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/multiprocess-harness-927

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #927

This is the last of the #927 plan. #934 (auth pragmas and the shared sign-in limit) and #936 (the declaration fence, the network-filesystem refusal, the host lease and the single audit drainer) landed earlier.

Harness

test/multiprocess.integration.ts (npm run test:multiprocess) starts three real urlcode serve processes from the built CLI, on distinct loopback ports. They serve one site whose host.mjs composes audit, auth and store from this checkout, and share one data/ directory: store.sqlite, auth.sqlite and audit.sqlite. Every collection is audit: true behind auth: true. All data is synthetic, and the secret is generated per run.

It asserts:

  • Race suites across processes, released at once over HTTP:
    • 240 interleaved transfers: the sum stays 0 and no account goes below its floor.
    • One Idempotency-Key sent 12 times: exactly one create runs and the others replay it.
    • 12 claims of one ticket: exactly one transition wins.
    • 24 overlapping bookings: no committed pair overlaps.
    • Every answer is the documented refusal or a 503 storage_unavailable that wrote nothing.
  • One drainer, exactly once, in order:
    • Throughout the run, one process holds the drain lease.
    • audit.sqlite holds one event per committed change: created records, 2 per transfer (counted by retained idempotency claims) and claimed tickets.
    • No event id appears twice, and at never goes backwards in stored order.
  • Sign-in burst: 24 correct sign-ins across the processes, alongside 60 signed-in reads.
    • Sign-ins answer only 200, 429 or 503; reads only 200 or 503. There is never a 401.
    • At most 9 more sign-ins succeed, because the shared limit had already counted one.
  • SIGKILL mid-load: the drain-lease holder is killed while all three write.
    • A survivor takes the lease over and empties the outbox.
    • A replacement process starts beside the dead one's lease row.
    • After a clean stop, PRAGMA integrity_check returns ok on all three databases, and the sum, non-overlap and exactly-once/order checks all hold.

The declaration fence across real processes ("a stale declaration gets 503") stays proved in packages/store/test/multiprocess.test.ts.

CI

  • A new multiprocess job runs on ubuntu-latest with Node 24, in every full-lane run, including extension-only ones.
  • verify-complete requires it except in the docs lane (scripts/ci-plan.ts gate). test/ci-plan.test.ts and test/ci-workflow.test.ts cover it.
  • npm run verify:workspaces also runs the harness.
  • docs/CI.md documents the job.

Docs

  • The per-process caveat for multi-process serving, with links to the harness:
    • CAPACITY.md has a new "Several serving processes on one host" section: throttle quotas are per process, so up to N× across N processes; each process keeps its own origin cache and metrics; Better Auth's sign-in limit is the one shared counter; and more processes add no store write throughput.
    • policies/throttle.md and policies/cache.md
    • OBSERVABILITY.md: scrape each process's port, not the proxy.
  • STORE.md:
    • A new "What the multi-process harness proves" section, including what it does not prove.
    • The stale "race suites do not yet run across processes" and "multi-process serving is not built" lines are fixed.
  • The audit-only multi-host gap:
  • RUNTIME-IMPLEMENTATION.md: the RIM-STORE-PERSIST-001 evidence column lists the harness.

Package budgets

  • Core: no budget change after merging main, which raised them in fix(docs,store): installed docs link only what the package ships (#931) #937 to 994 / 3920 KiB. With the test:multiprocess script, core measures 1014165 packed / 4011284 unpacked bytes on Node 26, leaving about 2.8 KiB of headroom on each after Node 24's roughly 800 extra packed bytes. The comment in scripts/package-audit.ts records this.
  • Auth: 18 → 21 KiB packed, 56 → 57 KiB unpacked, for its README. It was 732 packed bytes under budget before CI's Node 24 variance. Measured: 17700 / 54758 bytes.

Evidence and limits

  • Locally, on macOS with Node 26.10, npm run verify and npm run test:package pass.
  • The harness passed on every run after the last edit: about 13–15 s each, 0 busy 503s, 8 unanswered requests at the kill, and 690–726 audit events each stored once. The Linux run is this PR's CI.
  • It is not a soak test and measures no throughput. Its load lasts seconds.
  • It does not cover a full disk, a power loss or OS crash (SIGKILL is only a process crash), long-run WAL growth, or several hosts.
  • It runs on CI's disk, not a production one.
  • CI passing is not an independent security review or deployment proof.

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 29, 2026 13:21
…ottle/cache docs (#927)

test/multiprocess.integration.ts starts three `urlcode serve` processes from the
built CLI on one site whose host.mjs composes audit, auth and store over one
data directory. Across the processes it races Idempotency-Key, a transition,
240 transfers and overlapping intervals over HTTP. It then checks that one
drainer delivered every audit event exactly once, and that a sign-in burst
beside signed-in reads never answers a false 401 and stays inside the shared
limit. Finally it SIGKILLs the audit drain holder mid-load: a survivor takes
the lease over, a replacement starts, and afterwards PRAGMA integrity_check
and every invariant hold. It runs in about 15 seconds locally.

CI runs it in a new Linux/Node 24 `multiprocess` job in every full-lane run.
verify-complete requires the job except in the docs lane, and the ci-plan and
ci-workflow tests cover it.

Docs:
- CAPACITY, the throttle and cache policy pages and OBSERVABILITY: throttle
  budgets, origin caches and metrics are per process under multi-process
  serving.
- STORE: what the harness proves and what it does not.
- STORE and the auth and audit READMEs: only the store's lease detects a second
  host; auth also skips the network-filesystem check (#941).

Package budgets: core unpacked +3 KiB and packed +1 KiB (the package.json
script); auth +3 KiB packed and +1 KiB unpacked (its README).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd merged commit e9ce1c1 into main Sep 29, 2026
28 checks passed
@jimhoyd
jimhoyd deleted the claude/multiprocess-harness-927 branch September 29, 2026 18:33
jimhoyd added a commit that referenced this pull request Sep 29, 2026
jimhoyd added a commit that referenced this pull request Sep 29, 2026
jimhoyd added a commit that referenced this pull request Sep 29, 2026
--local-review and hermetic runs compose: the store-credits recipe seeds its issuer from tests/seed.json instead of
adding it to the live database, and the recipe tests assert nothing reaches the configured database.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant