Skip to content

fix(sqlite): isolate authenticated local commits#195

Open
marcus-pousette wants to merge 1 commit into
fix/sqlite-atomic-local-prooffrom
fix/sqlite-auth-optimistic-commit
Open

fix(sqlite): isolate authenticated local commits#195
marcus-pousette wants to merge 1 commit into
fix/sqlite-atomic-local-prooffrom
fix/sqlite-auth-optimistic-commit

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Problem

SQLite must not hold a savepoint while asynchronous authorization runs, and a committed authenticated operation must never be separated from its exact proof.

What changes

Authenticated local writes:

  1. prepare an exact read-only proposal
  2. call authorizeLocalOps, which returns one complete proof
  3. validate and snapshot the proposal, 64-byte signature, and 16-byte token reference
  4. atomically revalidate and commit operation, materialization, and proof
  5. prepare and reauthorize only after an explicit optimistic conflict, up to four attempts

Policy, codec, proof, database, and listener failures are terminal. Events are emitted only after commit.

Clean-slate choice

There is no optional proof hook, missing-reference branch, proofless authenticated commit, or old savepoint-across-auth path.

Fast paths

  • Writes without authSession retain the single immediate SQL call.
  • No SQLite transaction or lock is held during authorization.
  • Reconcile reuses the exact retained proof and cannot mint one later.

Verification

  • sqlite-node: 38/38 under Node 20
  • native extension release build
  • interface, benchmark, conformance, and sqlite-node TypeScript builds
  • Rustfmt, Prettier, and diff checks

Stack

Stacked on #194 and completes the SQLite authenticated local-write path.

@marcus-pousette marcus-pousette added bug Something isn't working area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy labels Jul 12, 2026
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from ba21c50 to 6cc3ac6 Compare July 12, 2026 12:44
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch from cac68d8 to 0f717c6 Compare July 12, 2026 12:44
@marcus-pousette marcus-pousette changed the title fix(sqlite): isolate local authorization from database writes fix(sqlite): isolate authenticated local commits Jul 12, 2026
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from 6cc3ac6 to b148b40 Compare July 13, 2026 14:07
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch from 0f717c6 to 00a95a6 Compare July 13, 2026 14:07
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from b148b40 to 260817c Compare July 13, 2026 14:12
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch 2 times, most recently from 5e1addb to 21c9a88 Compare July 13, 2026 15:14
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from 260817c to 0b5e4a2 Compare July 13, 2026 15:14
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch from 21c9a88 to e054eaa Compare July 13, 2026 15:22
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch 2 times, most recently from 5158707 to 44948a1 Compare July 13, 2026 15:30
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch from e054eaa to 8069ef0 Compare July 13, 2026 15:30
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from 44948a1 to 6643f10 Compare July 13, 2026 15:51
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-auth-optimistic-commit branch from 8069ef0 to 871d990 Compare July 13, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant