Skip to content

test(core)+fix(core): unit tests and debug_assert! for commit_speculative_tier#3655

Merged
bug-ops merged 3 commits intomainfrom
3652-commit-speculative-tests
May 6, 2026
Merged

test(core)+fix(core): unit tests and debug_assert! for commit_speculative_tier#3655
bug-ops merged 3 commits intomainfrom
3652-commit-speculative-tests

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 6, 2026

Summary

  • Adds four #[tokio::test] unit tests for the private Agent::commit_speculative_tier helper (issue test(core): add unit tests for commit_speculative_tier #3652), covering all result branches:
    • engine = None → returns empty map (fast path)
    • cache miss → returns empty map
    • Ok result → index in map, tool_started_ats[idx] stamped, ToolStartEvent { speculative: true } emitted
    • Err result → index still in map with the error
  • Extends MockChannel with a tool_starts: Arc<Mutex<Vec<ToolStartEvent>>> field + send_tool_start impl so tests can assert emitted speculative events
  • Adds a #[cfg(debug_assertions)] guard in commit_speculative_tier (issue fix(core): add debug_assert! in commit_speculative_tier to guard ConfirmationRequired invariant #3653) that emits tracing::error! when a committed speculative result carries ToolError::ConfirmationRequired, catching the invariant violation in debug builds at zero release cost

Test plan

  • cargo nextest run -p zeph-core -E 'test(commit_speculative_tier)' — 4 tests pass
  • cargo nextest run --workspace --lib --bins — 8925 tests pass, no regressions
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — clean

Closes #3652
Closes #3653

@github-actions github-actions Bot added tests Test-related changes size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate and removed tests Test-related changes labels May 6, 2026
bug-ops added 2 commits May 6, 2026 14:27
…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
@bug-ops bug-ops enabled auto-merge (squash) May 6, 2026 12:27
@bug-ops bug-ops force-pushed the 3652-commit-speculative-tests branch from f05c4c7 to 2f5bec7 Compare May 6, 2026 12:27
@github-actions github-actions Bot added the tests Test-related changes label May 6, 2026
@github-actions github-actions Bot added tests Test-related changes and removed tests Test-related changes labels May 6, 2026
@bug-ops bug-ops merged commit f86710d into main May 6, 2026
32 checks passed
@bug-ops bug-ops deleted the 3652-commit-speculative-tests branch May 6, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/L Large PR (201-500 lines) tests Test-related changes

Projects

None yet

1 participant