brainy/src/transaction
David Snelling 508a8e363e fix: transaction timeout rolls back applied operations (no torn state)
Transaction.execute() checked its time budget at the top of the operation
loop and threw TransactionTimeoutError from OUTSIDE the per-operation
try/catch, so a mid-flight timeout bypassed rollback entirely — only
per-operation failures rolled back. A bulk transact that crossed its 30s
budget mid-flight left the operations already applied to canonical storage
in place while the generation was never stamped: torn, generation-less
state. The generation-store commit path's abort cleanup explicitly assumes a
throw from execute() already restored the applied operations byte-identically
(it only discards the uncommitted staging directory), so the missing
rollback broke that invariant.

Give execute() a single rollback point: the operation loop is the sole
rollback-guarded region, and any error escaping it — an operation failure OR
a mid-flight timeout — rolls back every applied operation in reverse order,
then surfaces the original error (a rollback failure still supersedes it via
TransactionRollbackError). The per-exit-path rollback that let the timeout
throw slip past is gone; atomicity now holds by construction for every error
type. An aborted transaction leaves generation() unchanged and storage
byte-identical to its pre-transaction state.

Regression (tests/unit/transaction/timeout-rollback.test.ts): a mid-flight
timeout leaves an in-memory canonical store byte-identical with the tx in the
rolled_back terminal state; the operation-failure and rollback-failure paths
through the same single rollback point; and a clean transaction still commits.
2026-07-11 13:44:15 -07:00
..
operations fix: transact forward references resolve graph endpoint ints at execute time 2026-07-10 18:06:37 -07:00
errors.ts chore(8.0): modernize toolchain + position Bun as a runtime 2026-07-01 09:16:46 -07:00
RevisionConflictError.ts feat: per-entity _rev + update({ ifRev }) CAS + add({ ifAbsent }) 2026-06-09 10:04:24 -07:00
Transaction.ts fix: transaction timeout rolls back applied operations (no torn state) 2026-07-11 13:44:15 -07:00
TransactionManager.ts feat: add v5.8.0 features - transactions, pagination, and comprehensive docs 2025-11-14 10:26:23 -08:00
types.ts feat: add v5.8.0 features - transactions, pagination, and comprehensive docs 2025-11-14 10:26:23 -08:00