Skip to content

fix(durable): spawn DurableRetentionService background prune sweep in production - #6285

Merged
bug-ops merged 1 commit into
mainfrom
fix/6264-durable-retention-sweep
Jul 14, 2026
Merged

fix(durable): spawn DurableRetentionService background prune sweep in production#6285
bug-ops merged 1 commit into
mainfrom
fix/6264-durable-retention-sweep

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • zeph_durable::retention::DurableRetentionService::run() implemented the periodic prune sweep documented in specs/064-durable-execution/spec.md ("Retention & Compaction"), but was never instantiated anywhere in production — only the crate's own doctest and the manual one-shot zeph durable prune CLI subcommand ever called into the durable-execution prune path.
  • Every production call site that opens a durable backend now also spawns the retention sweep via TaskSupervisor::spawn (task name durable.retention_sweep, RestartPolicy::Restart { max: 5, base_delay: 5s }), alongside the existing JournalWriter actor spawn:
    • The shared open_durable_backend() helper (crates/zeph-core/src/agent/durable_bootstrap.rs), covering both the P1 agent-turn and P2 orchestration adapters.
    • The P3 scheduler daemon's build_durable_adapter() (src/commands/scheduler_daemon.rs), a separate process.
  • Gated by the same per-adapter conditions that already guard backend construction — no new config surface added.
  • P1/P2 deliberately share one fixed task name so a second adapter's spawn collapses into a supervised restart of the same sweep (TaskSupervisor's documented same-name-aborts-prior-instance behavior) rather than running duplicate sweeps against the same durable.db.

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins — 13611 passed, 34 skipped
  • RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"
  • gitleaks protect --staged --no-banner --redact — no leaks found
  • New unit test spawns_retention_sweep_reachable_via_task_supervisor_snapshot (P1/P2 path)
  • New unit tests spawns_retention_sweep_alongside_journal_writer + does_not_spawn_when_scheduler_adapter_disabled (P3 scheduler-daemon path)
  • CHANGELOG.md updated under [Unreleased]
  • .local/testing/playbooks/durable.md updated with a full #6264 (fixed) section

Closes #6264

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Jul 14, 2026
@bug-ops
bug-ops enabled auto-merge (squash) July 14, 2026 17:37
@bug-ops
bug-ops force-pushed the fix/6264-durable-retention-sweep branch from c356969 to 048d8a5 Compare July 14, 2026 17:39
… production

RetentionService::run() implemented the periodic sweep documented in
spec-064 ("Retention & Compaction") but was only ever driven from its own
doctest. Every production path that opens a durable backend now spawns it
via TaskSupervisor alongside the JournalWriter: the shared P1/P2
open_durable_backend helper and the P3 scheduler daemon's
build_durable_adapter, gated by the same per-adapter conditions that
already guard backend construction. Without this, terminal executions
past their TTL were never automatically reclaimed and durable.db grew
unbounded regardless of retention config.

Closes #6264
@bug-ops
bug-ops force-pushed the fix/6264-durable-retention-sweep branch from 048d8a5 to 0a79bff Compare July 14, 2026 17:47
@bug-ops
bug-ops merged commit 4276d81 into main Jul 14, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6264-durable-retention-sweep branch July 14, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

durable execution: DurableRetentionService background prune sweep is never spawned in production

1 participant