Skip to content

feat(core): reclaim deleted event aggregates - #537

Merged
LeXwDeX merged 7 commits into
devfrom
feat/524-event-retention-reclamation
Sep 4, 2026
Merged

feat(core): reclaim deleted event aggregates#537
LeXwDeX merged 7 commits into
devfrom
feat/524-event-retention-reclamation

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Closes #524

Why

Explicit session deletion removed the session aggregate but could strand related DAG event aggregates, and replaying those zombies fails the workflow/session foreign key. SQLite also kept deleted pages allocated because new databases did not enable full auto-vacuum before WAL and legacy conversion had no safe explicit path.

What changed

  • Capture and scrub all session-owned DAG aggregates, including terminal workflows, while preserving interruptions and soft-degrading ordinary cleanup failures.
  • Add an atomic, guarded startup residue sweep that deletes only aggregates with neither a session nor workflow read model.
  • Initialize genuinely new databases with auto_vacuum=FULL before WAL in both drivers; detect legacy NONE databases without converting at startup.
  • Add explicit opencode db vacuum --db <existing-file> conversion with target validation and FULL readback verification.
  • Wire the sweep through AppLayer and HttpApiApp LayerNode composition.
  • Record the approved decision and non-goals in ADR-0001; archived retention, active-history truncation, incremental vacuum, and chore(ops): reclaim pre-guard session data from the local database #531 live cleanup remain excluded.

Evidence

  • Focused core tests: 11 passed.
  • Focused opencode tests: 11 passed.
  • DAG core gate: 60 passed with coverage floors.
  • Package and root typechecks passed.
  • Root lint passed within the 4850 warning ratchet.
  • Full DAG verification and final review: ACCEPT, 0 blocking findings.
  • Core full suite after hermetic npm-audit fixture repair: 1228 passed; repair review ACCEPT.
  • All database tests use :memory: or disposable temporary files; no live OpenCode database was opened by the delivery tests.

Checklist

  • Decision Checkpoint approved and committed as ADR
  • Atomic TOCTOU regression pinned
  • Startup failure paths soft-degrade while interrupts propagate
  • Legacy conversion is explicit and refuses missing/non-file targets
  • No migration, HTTP schema, SDK, sync, or event manifest change

@LeXwDeX
LeXwDeX changed the base branch from main to dev September 4, 2026 01:12
@LeXwDeX LeXwDeX changed the title Delivery event-retention-reclamation chore(core): bound event cleanup and SQLite reclamation Sep 4, 2026
@LeXwDeX LeXwDeX changed the title chore(core): bound event cleanup and SQLite reclamation feat(core): reclaim deleted event aggregates Sep 4, 2026
@LeXwDeX
LeXwDeX marked this pull request as ready for review September 4, 2026 05:52
@LeXwDeX
LeXwDeX merged commit da0f73f into dev Sep 4, 2026
8 checks passed
@LeXwDeX
LeXwDeX deleted the feat/524-event-retention-reclamation branch September 4, 2026 09:35
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.

chore(core): design bounded event retention and SQLite reclamation

1 participant