GeezerVison is showing github.com — id(outbox): finished entries are kept forever — the in-memory map, the append-only journal and the deliveries view all grow with the server's entire delivery history · Issue #1726 · developing-today/code
id(outbox): finished entries are kept forever — the in-memory map, the append-only journal and the deliveries view all grow with the server's entire delivery history #1726DescriptionProblem
The envelope outbox (pkgs/id/src/envelope_outbox.rs) never forgets a finished delivery:
Outbox.entries (envelope_outbox.rs:121) is a BTreeMap<String, Entry> holding every payload ever queued. The only removal anywhere in the module is the Withdrawn arm of apply (envelope_outbox.rs:322), and withdraw itself refuses any entry that has been attempted or finished — so a Delivered / Refused / GaveUp entry can never leave the map for the life of the process.
- The on-disk journal has the same shape:
commit (envelope_outbox.rs:278) only appends one JSON line per queue/attempt/finish, and open (envelope_outbox.rs:130) only ever truncates a torn final line (set_len, :160). No compaction or pruning exists anywhere in the crate (verified by searching src/ for the outbox file's writers: commit/open are the only ones).
- The cost is paid on every restart and every directory view:
open replays and re-parses every line ever written, and deliveries() (pkgs/id/src/directory_view.rs:432) iterates all entries and clones a DeliveryView for each one the viewer may see. The view's own doc promises only envelopes "still in, or recently left, the outbox" (directory_view.rs:86) — the implementation has no recency bound at all, so a long-lived server's directory view grows linearly with its entire delivery history, forever.
This is a queue, not a journal of record: the directory log is where history lives. Nothing else in the crate reads finished outbox entries except deliveries() and entry() status lookups.
Evidence (verified this run, main 8c6bdc09)
- Line trace of
envelope_outbox.rs (whole file): apply arms are Queued, QueuedArtifact, Attempted, Finished, Withdrawn; only Withdrawn removes, and withdraw() (same file) errors unless attempts == 0 && finish.is_none().
grep over pkgs/id/src for compaction/pruning of the outbox (set_len, remove, rewrite): the only hits are the torn-tail truncation in open and the Withdrawn removal above.
deliveries() at directory_view.rs:432-448 filters by viewer only — no age, count, or finish-time bound — while its field doc at :86 says "recently left".
Distinct from #1620 (torn-tail acceptance in the same file) and from #1713 (SaveRateLimiter map growth in web/) — this is the outbox store itself, its journal file, and its directory view.
Why it matters
A world server runs for months and flushes its outbox on a timer (world_hub.rs spawn_outbox_flush). Every friend envelope and artifact push adds permanent in-memory entries (including full payload clones), permanent journal lines, restart replay time, and directory-view response size. Growth is slow but strictly unbounded and invisible until the file and the view are large.
Acceptance criteria
- A retention rule is pinned and documented at
Outbox (e.g. finished entries kept for a bounded age or bounded count, still long enough for deliveries() to honestly show "recently left" ones).
- Finished entries past the bound are dropped from the in-memory map, and the journal is compacted (rewritten without the dropped history) at a safe point, e.g. on
open after replay.
-
deliveries() output is bounded by the same rule; a test with an old finished entry and a recent finished entry shows only the recent one.
- Existing outbox tests keep passing (
envelope_outbox + envelope_net flush tests), including torn-tail handling (id(outbox): a parseable torn tail is accepted, then merged into the next record — Outbox::open only drops unterminated final lines that fail to parse #1620's area must not regress: compaction must keep the crash-torn-tail rule working).
- A restart test: after compaction, reopening the file yields the same due/pending set as before.
Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026
Filed this run by new-issue-creator-code-a (lane A). Found via: full line trace of pkgs/id/src/envelope_outbox.rs plus a crate-wide search for any outbox compaction/pruning (none exists outside the torn-tail truncation), and the deliveries() view in pkgs/id/src/directory_view.rs:432 vs its 'recently left' doc at :86. Verified on main 8c6bdc0. Enqueued as a repo-task/v1 triage packet in repo-health-code-pilot. dezren39 commented on Nov 4, 2026 agent-note:v1
state: escalated
queue: repo-health-code-pilot
task: 8101 (triage, worker repo-worker-code, lane 262eb403-3347-4a7c-ba6b-e7bc263ca853)
by: openchamber-scheduled-lane
at: 2026-11-04T04:14Z
Triage verdict: the original outbox-retention problem remains actionable, and the canonical fix is already in open PR #4710 (queue/6512-1726-outbox-retention); it has one passing check. I will not open a competing PR or modify this PR because it is authored/owned by the repo owner. Fresh review state has one unresolved high Copilot finding: compaction uses fs::rename(src, dst) while the destination exists, which typically fails on Windows and may make Outbox::open() fail. The owner needs to choose/approve the replacement strategy (platform-specific atomic replace versus a documented non-atomic fallback) on the existing PR. No duplicate fix packet was enqueued. This task is blocked/escalated to the owner pending that decision; after the PR finding is addressed, resume the canonical PR and re-check its CI/review state. dezren39 commented on Nov 10, 2026 🤖 Agent note · picked up — escalation reviewed, proceeding
On the standing user/escalated label: the 2026-11-04 escalation (task 8101) rested on one Copilot high finding — journal compaction's fs::rename(src, dst) fails on Windows when dst exists, which could make Outbox::open() fail there. Reviewing it first-hand per the current runbook (user/escalated is for decisions genuinely Drew's): the remedy is a standard engineering disposition, not a product decision — Copilot itself named the fallback (platform-specific replace; on Windows remove-then-rename with the atomicity loss documented). I am applying that fix to PR #4710 in this task and replying on the review thread, so the escalation is discharged here rather than re-asked.
Plan: merge current main into the PR branch in a laptop worktree, apply the Windows-replace fix, run the targeted envelope_outbox / directory_view tests on the laptop, push, then merge under the standing criteria (Codex review on the PR already completed with no findings) and reconcile issue #1726's acceptance boxes.
dezren39 commented on Nov 11, 2026 🤖 Agent note · done — PR #4710 merged
What landed: MAX_FINISHED_ENTRIES = 100 retention documented at Outbox (newest finished entries by finish order, plus every unfinished entry); finished entries past the bound are dropped from the in-memory map during replay and the journal is compacted on open (compact_journal); deliveries() is bounded by the same retention. Shepherd merge-up to current main (merge commit 097adce7fd) resolved 4 conflicts in envelope_outbox.rs and adapted the compaction snapshot to current replay validation: attempt counts now replay incrementally (push_attempt_increments), because a Finished/Attempted record must increment the count by exactly one. The Copilot high finding is fixed via a platform replace_journal helper (atomic rename on non-Windows; documented remove-then-rename fallback on Windows).
Acceptance check:
- Retention rule pinned + documented at
Outbox — ✅ module/struct docs + MAX_FINISHED_ENTRIES.
- Finished past bound dropped + journal compacted on open — ✅
replay_compacts_finished_history_and_preserves_state_and_finish_order.
deliveries() bounded; old-vs-recent test — ✅ deliveries_keeps_the_newest_finished_entries_and_all_pending_entries (newest 100 finished + all pending).
- Existing outbox tests pass incl. torn-tail (id(outbox): a parseable torn tail is accepted, then merged into the next record — Outbox::open only drops unterminated final lines that fail to parse #1620) — ✅
cargo test envelope_outbox 21 passed; envelope_net flush tests 7 passed.
- Restart test: reopening after compaction yields the same due/pending set — ✅ same replay test (entries + due sets asserted equal across two reopens).
Tests (laptop, worktree ~/git/fleet/queue-14748-4710-outbox-retention): cargo test envelope_outbox — 21 passed, 0 failed; cargo test envelope_net — 7 passed; cargo test deliveries_keeps_the_newest — 1 passed. Codex review on the PR: completed, no findings. Copilot: 1 high finding, fixed + thread resolved.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|