Skip to content

fix(sqlite): commit local proofs with their operations#194

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

fix(sqlite): commit local proofs with their operations#194
marcus-pousette wants to merge 1 commit into
fix/sqlite-optimistic-local-commitfrom
fix/sqlite-atomic-local-proof

Conversation

@marcus-pousette

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

Copy link
Copy Markdown
Collaborator

Problem

If a local operation commits and its authorization proof is stored afterward, a crash between those writes leaves an operation that cannot be safely forwarded or audited.

What changes

Every optimistic SQLite commit requires a 64-byte signature and 16-byte proof reference. The native extension writes that complete proof into treecrdt_sync_op_auth inside the same savepoint as the operation, materialized tree changes, and materialization metadata.

Both schema initialization orders enforce NOT NULL, length(sig) = 64, and length(proof_ref) = 16. The operation reference comes from the operation actually committed and the database clock supplies the timestamp.

Clean-slate choice

There is no proofless commit arity, optional reference, unconstrained old schema, migration, or durable mirror. Authenticated optimistic commits are proof-bearing by contract. Unauthenticated writes use #193's separate immediate path.

Fast paths

  • The immediate unauthenticated UDF performs no sidecar write.
  • The proof store reads the native row directly.
  • The authenticated commit adds one co-transactional row, with no second transaction or lookup.

Failure behavior

Any bind, constraint, insert, trigger, finalization, materialization, or savepoint-release failure rolls back operation, proof, tree state, and metadata together.

Verification

  • SQLite extension: 26/26
  • malformed/missing/wrong-width proof rejection
  • both schema initialization orders
  • op-ref derivation, database timestamps, and atomic rollback

Stack

Stacked on #193 and consumes #187's exact-proof shape.

@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-optimistic-local-commit branch from 416b21e to 644b31d Compare July 12, 2026 12:44
@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-atomic-local-proof branch from b148b40 to 260817c Compare July 13, 2026 14:12
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-optimistic-local-commit branch 2 times, most recently from fd77168 to 729a743 Compare July 13, 2026 15:14
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch 2 times, most recently from 0b5e4a2 to 5158707 Compare July 13, 2026 15:22
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-optimistic-local-commit branch 2 times, most recently from 0e2e6e4 to f50f698 Compare July 13, 2026 15:30
@marcus-pousette marcus-pousette force-pushed the fix/sqlite-atomic-local-proof branch from 5158707 to 44948a1 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-optimistic-local-commit branch from f50f698 to afa49f6 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