Repository navigation
feat(agent,cli): reclaim oversized run journals; wait for the remote verdict - #1367
Merged
Merged
Conversation
… them A settled run's raw journal was retired only if its folded snapshot fit 4 MiB *and* the run held at most 65,536 rows. Over either limit the compactor returned `Ok(0)` and never looked again, so `run_events` only grew. Measured on a 1 GiB `agent.db`: 1.6M raw rows / 375 MiB, of which 1,213,282 rows sat in 15 runs whose only disqualifier was the row count, plus one run whose folded projection was 4.5 MiB. The automatic trigger is also in-process only, so a run that settled under an older build is never retried at all. - Retire raw rows in bounded 32,768-row transactions after publishing the snapshot; the first slice stays in the publishing transaction, so a crash still leaves either the whole journal or (snapshot + inert leftover rows). - Publish a snapshot above the 4 MiB target instead of abandoning the run. It is counted in `journal.oversize_publishes` and logged once per run, and it is still 6–17x smaller than the journal it replaces; the delivered projection is the same fold a client already receives from the raw path. - Record why a journal was kept (`journal.skipped.<reason>`) and the durable reclaim counters in `storage_meta`, so "nothing happened" is diagnosable. - Add sessionless `get_journal_stats` / `reclaim_run_journals` and `future session journal [--reclaim [--yes]]`: a report, a plan, and an explicit resumable sweep. Off unless asked for, bounded per call, prints rows and bytes before/after, and gates on `quick_check`. - The sweep reports `hasMore` only for work it can still do, retires inert leftovers of an interrupted retirement, always attempts at least one run per call, and skips (rather than aborts on) a journal it cannot represent. Replay equivalence is unchanged: the snapshot is the same folded projection of the same journal, covered by a test that compares what a client renders (text in order, tool arguments, tool results) before and after reclamation.
`a_broker_that_refuses_the_credential_is_reported` failed on Windows CI (run 40267289153 attempt 1) because its 30 s window also contained the child's own startup: the embedded agent's prologue took 26.2 s and no `Remote:` line had appeared when the window closed, so the refused connection had not even been attempted. Attempt 2 of the same run on the same commit passed, which is why the rerun hid it. The claim is *that* the refusal is reported, not *when*, so the wait now ends on an outcome: the line appears, the child ends, or a 300 s backstop against a hang expires. `Verdict` names which, so a timeout is reported as a timeout instead of a bare `false`, and a child that never reports is killed rather than blocking `wait()` forever. Every assertion is unchanged. Three more waits in the same file had the same shape (a line that cannot exist before the child's first start attempt, budgeted from `spawn` at 30-40 s) and are converted with it; the recorded survey lists the 27 waits left alone and why. The accompanying record has the runner's log, the prologue measurements and two falsification experiments: a 45 s prologue is red before (49.25 s) and green after (49.84 s), and a child that never reports fails at 300.27 s naming the timeout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frozen snapshot of
dev-huichenate7ea4222(rebased onto currentorigin/main; 0 behind).b30ac356):journal_compaction.rsretired a run's raw journal only when it fit underSNAPSHOT_BYTE_BUDGET(4 MiB) and otherwise returnedOk(0)— permanently. Since streamedtool_deltaevents land one row each, every long run exceeded it and was never reclaimed: measured 1,668,496run_eventsrows / 392.5 MB on one machine, growing ~25 MB/hour, which filled a disk and took a remote desktop down for 30 minutes. Now an oversized journal is reclaimed in bounded slices (journal_reclaim.rs), with replay equality asserted per run; verified on a real DB copy: 21/21 reclaimed runs replay identically (e.g. 136,298 events → 1,375-event snapshot, 250 tool calls, EQUAL).hasMorefix: it used to mean "some run still has a raw journal", so an unreclaimable run made the CLI repeat itself — 1,042 duplicate refusals measured on a real DB copy. It now means "this scan still has work", with at least one run handled per call and a 256-slice cap.e7ea4222): the CLI waits for the remote's verdict instead of a fixed 30 s window; acceptance recorded indocs/testing/remote-start-refusal-wait-2026-10-26.md.Verification reported by the implementing session: agent 2498 + cli 1313 tests pass, fmt/clippy/check-docs clean; the 3 agent test failures and 2 Windows clippy errors reproduce on the untouched baseline and are unrelated. Its one honest gap: a
>4 MiBlive run was not exercised end-to-end (no model configured in its isolated instance) — covered by unit tests at the same call site plus the real 17 MiB→4.6 MiB reclaim.No RPC contract change beyond additive fields; no compaction threshold touched; no destructive schema migration.