fix(buzz-acp): treat settled turns as activity for the idle-pool clock - #6519
Open
sanjay3290 wants to merge 2 commits into
Open
fix(buzz-acp): treat settled turns as activity for the idle-pool clock#6519sanjay3290 wants to merge 2 commits into
sanjay3290 wants to merge 2 commits into
Conversation
Add a note_turn_settled seam called unconditionally from the PoolEvent::Result and PoolEvent::Panic arms, and pin the contract in tests: a turn that settles after 2x the idle bound must re-anchor the clock so the pool is not immediately sleep-due, while an idle pool with no settled turn is still torn down on schedule. The reanchor test fails at this commit; the next commit supplies the bump. Signed-off-by: Sanjay Ramadugu <sramadugu1@gmail.com>
note_turn_settled now advances last_activity, so the idle-pool reaper anchors on turn completion and panic recovery instead of dispatch time only. A long-running turn that finishes inside the idle bound is no longer torn down on the first reaper tick after it completes. Signed-off-by: Sanjay Ramadugu <sramadugu1@gmail.com>
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.
Problem
buzz-acp's idle-pool reaper anchors onlast_activity, which is only advanced when a prompt is dispatched. It is never advanced when a turn settles.So a turn that runs longer than the idle bound is torn down on the first reaper tick after it completes — the pool did useful work for the entire window, and the clock still reads as if it had been idle the whole time. The longer a turn runs, the more certain the teardown.
Fixes #6378.
Change
Adds a
note_turn_settledseam and calls it unconditionally from both settle paths in the event loop —PoolEvent::Result(lib.rs:3177) andPoolEvent::Panic(lib.rs:3220) — before their trailingdispatch_pending.The existing
dispatch_pendingcall already bumpslast_activity, but only when it actually dispatches something. In the exact case this bug is about — a long turn finishing with an empty queue — it dispatches nothing and the clock stays stale. Hence a separate bump at settle time.Two commits, test first:
0956a58f5adds the seam and pins the contract. The re-anchor test fails at this commit.a09fd9fe5supplies the bump.Verification
All commands run on a clean tree at
a09fd9fe5(git status --shortempty, confirmed before and after each run).buzz-acpis not one of the nine packages inscripts/run-tests.sh unit, so the package test above is run separately and is the gate that actually executes these tests.Behavioural probe. Checked out the test-only commit
0956a58f5in a separate detached worktree — the seam and both call sites are present there, only the bump is absent, so the crate still compiles and the wiring is unchanged:Exactly the decision test, and nothing else. Removing the behaviour while keeping the wiring fails the test.
Known limitation
The test is decision-level: it calls
note_turn_settledand then assertsidle_pool_sleep_due. It does not drive the realtokio::select!loop, so it cannot catch someone deleting one of the two arm call sites individually — the unit tests cannot reach inside those arms without a refactor well beyond this fix.What it does cover: both arms call the same single-statement helper, so removing the shared bump disables both at once, which is what the probe above exercises. Stating the gap rather than claiming coverage the test does not have.
Test coverage limitation — stated deliberately
The two new tests call
note_turn_settleddirectly and then assertidle_pool_sleep_due. They pin thedecision rule, not the wiring:
tokio_main's event loop is not reachable from a unit test, so deletingeither call site leaves the suite green. The bump lives in one shared one-line function called
unconditionally by both settle arms, so the two arms cannot diverge, but reviewers should read the two
call sites rather than trust the tests to cover them. Flagging this rather than implying coverage the
tests do not provide.