Skip to content

Agent Supervisor 0.3.5: keep the coordinator snapshot under the journal bound - #11

Open
rooagidev wants to merge 2 commits into
mainfrom
release/0.3.5
Open

rooagidev wants to merge 2 commits into
mainfrom
release/0.3.5

Conversation

@rooagidev

Copy link
Copy Markdown
Contributor

Problem

The coordinator persists its whole snapshot on every change, and the journal refuses a snapshot over 4 MiB (MAX_SNAPSHOT_BYTES). Nothing finished was ever dropped from the snapshot. A Desktop Supervisor service that had run for about a day held 3,073 exited processes and 585 runs, a 4.19 MB snapshot. The next commit was refused, persistence_failed was set, and the loop stopped for good: every later call returned coordinator loop is closed. Restarting would not have helped for long, because the snapshot only grew.

Fix

  • Bounded retention (prune_retained, run on every change): keep at most 128 finished runs, each with its activities and attempts, and 256 exited processes; the oldest are dropped first. Records still in use are always kept: live processes, records an open FlowRun's tasks refer to, attempts with a pending approval or tool request, and the records of the change being persisted. A run restored as Unknown with no live process counts as finished.
  • Retry once at the bound: a commit refused as too large drops every finished record and is retried once.
  • Visible failure: when a change truly cannot be persisted, the service writes the reason to stderr. Later calls now get coordinator persistence failed; reopen the service to recover instead of coordinator loop is closed.
  • Version 0.3.5, with release notes in docs/releases/0.3.5.md. Lockfiles change only this repo's own packages.

Validation

  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings: clean.
  • cargo test --all-targets -- --test-threads=1: 135 library tests pass, plus the integration tests.
  • New tests: the finished-run cap, the exited-process cap (live processes kept), and a persistent commit over the bound that prunes, persists and restores. All three fail with pruning disabled.
  • The existing freeze test now expects the persistence error for later calls instead of Closed.
  • Every Cargo.lock passes cargo metadata --locked.
  • I ran the release binary on a copy of the real 6.4 MB journal. It started, committed the 8 FlowRun fence restores, and the snapshot dropped from 4.2 MB to 1.2 MB with all 8 FlowRuns intact.

Every change persists the whole coordinator snapshot, and the store refuses
a snapshot over 4 MiB. Nothing finished was ever dropped from it, so a
long-lived service reached the bound (3,073 exited processes and 585 runs
after about a day), the next commit failed, and the loop stopped for good:
every later call returned "coordinator loop is closed".

- Keep at most 128 finished runs (with their activities and attempts) and
  256 exited processes, oldest dropped first. Records still in use are
  always kept: live processes, records an open FlowRun's tasks refer to,
  attempts with a pending approval or tool request, and the change's own.
- A commit still over the bound drops every finished record and retries
  once.
- When a change truly cannot be persisted, log why, and answer later calls
  with the persistence error instead of "coordinator loop is closed".
The coordinator keeps its snapshot under the journal bound, so a
long-running service no longer stops with "coordinator loop is closed".
Release notes in docs/releases/0.3.5.md.

This branch has not been deployed

No deployments
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.

2 participants