Skip to content

Add dormant reversible overlay storage primitives [OPL-4474] - #31

Open
rohenaz wants to merge 2 commits into
masterfrom
codex/opl-4474-atomic-overlay-rollback
Open

rohenaz wants to merge 2 commits into
masterfrom
codex/opl-4474-atomic-overlay-rollback

Conversation

@rohenaz

@rohenaz rohenaz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review corrections verified

Fixed rollback of committed siblings sharing retained ancestry. Durable snapshot dependencies require later overlapping mutations to finish rollback before an earlier snapshot can restore; pruning preserves that order too. SQLite and real PostgreSQL storage suites pass, including shared-ancestor rollback, refused out-of-order operations, finalization and replay cleanup. The API remains dormant until runtime coordination is implemented.

Problem

Overlay rollback needs durable, transactionally correct storage primitives before any runtime coordinator can safely enable rejection or reorg recovery. The earlier combined approach mixed storage, callbacks, retry, and reorg assumptions and was stopped by review.

Change

  • add a separate ReversibleTopicStorage contract without changing or activating existing engine adapters
  • persist explicit active, applied, and rollback-pending mutation phases with ordered restart enumeration
  • atomically snapshot recursive input ancestry, events, reservations, and direct spend effects under the active mutation transaction
  • restore or remove exact effects through idempotent rollback and explicit finalization
  • reject active and committed descendant rollback in the wrong order
  • add policy-free, order-safe journal pruning without inventing a finality source
  • serialize SQLite operations and PostgreSQL operations with serializable transactions plus per-topic advisory locks
  • leave all production constructors, runtime wiring, status handling, and current behavior unchanged

Verification

  • go test ./pkg/overlay/storage -count=1
  • focused reversible storage race tests pass
  • go vet ./pkg/overlay/storage
  • git diff --check
  • shared contracts cover phases, restart enumeration, recursive restoration, reservations, concurrent begins, descendants, rollback/finalize/prune idempotency, and empty dormant tables
  • independent GPT-5.6 Sol high-reasoning review: clean after three redesign gates and a late row-iteration error fix

Activation boundary

This PR has no adapter or runtime call site. OPL-4475 must add durable coordination, and OPL-4476 must add the authoritative reorg/finality source and pruning policy before any production activation. PostgreSQL contract tests compile but require Docker/CI for runtime execution.

Linear: OPL-4474


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@linear

linear Bot commented Sep 4, 2026

Copy link
Copy Markdown

OPL-4474

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