test(core)+fix(core): unit tests and debug_assert! for commit_speculative_tier#3655
Merged
test(core)+fix(core): unit tests and debug_assert! for commit_speculative_tier#3655
Conversation
…tive_tier Add four focused unit tests for `Agent::commit_speculative_tier` covering all branches from issues #3652: - engine = None returns empty map (fast path) - cache miss returns empty map - Ok result stamps tool_started_ats and emits ToolStartEvent { speculative: true } - Err result is still present in the commit map Extend MockChannel with a `tool_starts` field so tests can assert that ToolStartEvent events are emitted with the correct speculative flag. Add test-local AlwaysOkSpecExec and AlwaysErrSpecExec stubs that implement ToolExecutor to exercise both result paths without external dependencies. Add a #[cfg(debug_assertions)] guard in commit_speculative_tier (issue #3653) that emits tracing::error! if a committed speculative result carries ToolError::ConfirmationRequired, making the invariant machine-checkable in debug builds at zero release cost. Closes #3652 Closes #3653
f05c4c7 to
2f5bec7
Compare
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.
Summary
#[tokio::test]unit tests for the privateAgent::commit_speculative_tierhelper (issue test(core): add unit tests for commit_speculative_tier #3652), covering all result branches:engine = None→ returns empty map (fast path)Okresult → index in map,tool_started_ats[idx]stamped,ToolStartEvent { speculative: true }emittedErrresult → index still in map with the errorMockChannelwith atool_starts: Arc<Mutex<Vec<ToolStartEvent>>>field +send_tool_startimpl so tests can assert emitted speculative events#[cfg(debug_assertions)]guard incommit_speculative_tier(issue fix(core): add debug_assert! in commit_speculative_tier to guard ConfirmationRequired invariant #3653) that emitstracing::error!when a committed speculative result carriesToolError::ConfirmationRequired, catching the invariant violation in debug builds at zero release costTest plan
cargo nextest run -p zeph-core -E 'test(commit_speculative_tier)'— 4 tests passcargo nextest run --workspace --lib --bins— 8925 tests pass, no regressionscargo +nightly fmt --check— cleancargo clippy --workspace -- -D warnings— cleanCloses #3652
Closes #3653