Skip to content

fix(core): add debug_assert! in commit_speculative_tier to guard ConfirmationRequired invariant #3653

@bug-ops

Description

@bug-ops

Description

commit_speculative_tier (native.rs) silently accepts any Err variant in committed speculative results, including a theoretical ToolError::ConfirmationRequired. The invariant that confirmation-required tools are never speculatively dispatched is enforced at try_dispatch time, but there is no machine-checkable assertion at the commit boundary.

Recommended fix

Add a debug_assert! (or explicit if cfg!(debug_assertions) guard) in commit_speculative_tier after if let Err(ref e) = result:

#[cfg(debug_assertions)]
if matches!(e, zeph_tools::ToolError::ConfirmationRequired) {
    tracing::error!("invariant violated: committed speculative result is ConfirmationRequired");
}

This makes the invariant explicit and catchable in debug builds without runtime cost in release.

Environment

Metadata

Metadata

Assignees

Labels

P3Research — medium-high complexityenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions