Ray's Knowledge Base
Unlock

Pending-Start prune gate must exclude the current call's own Start

PitfallVerified 18 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

After gating prune_objects on 'any Start has no matching Post', pruning never runs. Every call looks like it has a pending Start.

Cause#

record_after loads starts and posts before it appends this call's Post. The current call's own Start therefore has no matching Post in the loaded posts, and it counts as pending.

Fix#

Skip the prune only when another call's Start is pending. Match a Start as 'this call' on (session, tool_use_id, agent_id). Then check for a matching Post on (session, tool_use_id). Code: pending_other = starts.iter().any(|s| !(s.session == session && s.tool_use_id == tool_use_id && s.agent_id.as_deref() == agent_id) && !posts.iter().any(|p| p.session == s.session && p.tool_use_id == s.tool_use_id)). Run prune_objects only when pending_other is false. Be careful with the negation: a first draft used this || !posts.any(...), which is true for the current call.

Evidence#

Seen in the rvow blob provenance work (crates/rvow-core/src/provenance.rs). After the fix, the 8 provenance unit tests, clippy and the full cargo test passed. In a normal sequential flow every older Start has a Post, so pruning still runs.