Skip to content

Disk-full evidence for store, auth and audit; the auth mount answers 503 when Better Auth fails on storage - #968

Merged
jimhoyd merged 10 commits into
mainfrom
claude/disk-full-902
Sep 29, 2026
Merged

jimhoyd merged 10 commits into
mainfrom
claude/disk-full-902

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Part of #902: this is the disk-full evidence for item 4.

What changed

  • test/disk-full.test.ts is deterministic and part of npm test, so it runs on every OS. It serves one site that composes audit, auth and store, then fills each database in turn. To fill one, it caps every connection to the file at its current page count with PRAGMA max_page_count. That setting is per connection, so the test captures each extension's own connection. A filler table then takes the remaining free pages. The test covers:
    • store: creates, transfers and a keyed host transaction, until the first refusal of each.
    • audit: record(), and audited store writes.
    • auth: sign-ins.
    • recovery: it lifts the cap and drops the filler.
  • test/disk-full.integration.ts (npm run test:disk-full) starts a real urlcode serve with its data directory on a filesystem of at most 64 MiB. It fills that filesystem to ENOSPC with a filler file, then removes it.
  • CI: the multiprocess job now mounts a 16 MiB tmpfs with sudo and runs the integration test. test/ci-workflow.test.ts asserts the new steps.
  • Fix (auth): a sign-in whose session could not be stored used to answer Better Auth's bare 500 on a full disk, or core's 500 when a lock timeout made the handler throw. The mount now answers 503 {"error":"auth_unavailable"} with Retry-After: 1 and no Set-Cookie. packages/auth/test/auth.test.ts adds a regression test using a held lock.
  • Docs: STORE.md has a new section, "What the disk-full tests prove", and the remaining-Store: declarative interval constraint, declarative transfer, retries for host transactions, multi-process serving #902 list is updated. Also updated: OPERATIONS.md (a full-disk incident note), CAPACITY.md (a disk-space row), the evidence and contract of RIM-STORE-PERSIST-001, CI.md, EXTENSIONS.md, and the auth README, SECURITY and CHANGELOG.
  • Budgets: the auth unpacked budget goes from 63 to 64 KiB (measured 61759). Core measured 1033622 packed and 4089239 unpacked, which is within its current budgets with about 3 KiB of headroom once Node 24's ~800 bytes are counted.

Evidence

Each test checks that every write answers a documented refusal or commits whole:

  • store: 503 storage_unavailable. The rows, the Idempotency-Key claims, the host transaction results and the balance sum match the committed answers exactly.
  • audit: record() answers 503 audit_unavailable, and a refused batch stores none of its events. Store events wait in the outbox.
  • auth: a sign-in answers 503 auth_unavailable and stores no session. A signed-in route answers 200, never a false 401.

After recovery:

  • Refused keys run for the first time; they are not replays.
  • The drain delivers every waiting event once.
  • PRAGMA integrity_check is ok on all three files.

Local runs on macOS, Node 26:

  • npm run verify: green.
  • npm run test:package: green.
  • disk-full.test.ts: three runs, all identical and passing.
  • disk-full.integration.ts on a 16 MiB HFS+ disk image (hdiutil, no root): passed twice.

The Linux tmpfs run is this PR's CI.

Limits

These tests do not prove:

  • several processes on a full disk;
  • a restart or migration while the disk is full;
  • ext4/XFS reserved blocks or quotas;
  • power loss;
  • a checkpoint that fills the disk under sustained load;
  • audit_backlog on a full disk.

max_page_count caps the database file but not its -wal or -shm; only the filesystem run fills those. Neither test is a soak test.

🤖 Generated with Claude Code

jimhoyd and others added 3 commits September 29, 2026 15:03
# Conflicts:
#	docs/RUNTIME-IMPLEMENTATION.md
#	packages/auth/CHANGELOG.md
…3 on a storage failure (#902)

A deterministic every-OS test caps store.sqlite, audit.sqlite and auth.sqlite in
turn with PRAGMA max_page_count plus a filler table, and a Linux CI step fills a
16 MiB tmpfs under a real urlcode serve. Both check documented refusals, no
partial writes, recovery once space frees, and integrity_check.

Found: a sign-in whose session could not be stored answered Better Auth's bare
500 (full disk) or core's 500 (a throw on a lock timeout). The auth mount now
answers 503 auth_unavailable with Retry-After: 1 and no Set-Cookie.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 20:13
jimhoyd and others added 6 commits September 29, 2026 15:16
# Conflicts:
#	docs/RUNTIME-IMPLEMENTATION.md
#	packages/auth/CHANGELOG.md
…-full test (#902)

The static job type-checks before any add-on is built; test/disk-full.test.ts
imports the store's source, whose audit type imports resolved to an unbuilt dist.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/STORE.md
#	scripts/package-audit.ts
# Conflicts:
#	docs/RUNTIME-IMPLEMENTATION.md
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