fix(tools): propagate ClaimSource and ErrorDomain to AuditEntry#2319
Merged
fix(tools): propagate ClaimSource and ErrorDomain to AuditEntry#2319
Conversation
#2299) All AuditEntry construction sites in ShellExecutor and WebScrapeExecutor previously hardcoded claim_source/error_domain as None, making the audit trail always null for both fields despite ToolOutput setting them correctly. - log_audit() in shell/mod.rs and scrape.rs now takes Option<&ToolError> - Blocked/error call sites pass Some(&err); success paths pass None - error_category and error_domain are derived via ToolErrorCategory::domain() - claim_source is now Some(ClaimSource::Shell) / Some(ClaimSource::WebScrape) - policy_gate.rs retains claim_source: None (not a tool execution result) - Add ClaimSource serde roundtrip test (all 8 variants) - Add AuditEntry.claim_source JSON serialization tests (None omitted, Some present) Closes #2308, closes #2299
be2ca12 to
56d46b9
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
AuditEntryconstruction sites inShellExecutorandWebScrapeExecutorthat hardcodedclaim_source: Noneanderror_domain: None, making the audit trail always null for both fields despiteToolOutputsetting them correctly since PR feat(tools): ClaimSource provenance, ErrorDomain recovery, MCP tool pruning #2293ClaimSourceandAuditEntry.claim_sourceserializationChanges
crates/zeph-tools/src/shell/mod.rslog_audit()now takesOption<&ToolError>;claim_sourceis alwaysSome(ClaimSource::Shell)Some(&err), success/timeout paths passNoneerror_categoryanderror_domainderived viaToolErrorCategory::domain()crates/zeph-tools/src/scrape.rsclaim_sourceis alwaysSome(ClaimSource::WebScrape)crates/zeph-tools/src/audit.rsclaim_source_serde_roundtrip: all 8ClaimSourcevariants serialize to snake_case JSON and deserialize backaudit_entry_claim_source_none_omitted:None→ field absent from JSON outputaudit_entry_claim_source_some_present:Some(ClaimSource::Shell)→"claim_source":"shell"policy_gate.rsretainsclaim_source: None— policy checks are not tool execution results.Test plan
cargo +nightly fmt --check— passcargo clippy --all-targets --all-features --workspace -- -D warnings— pass (0 warnings)cargo nextest run --workspace --all-features --lib --bins— 6913 passed (+3 new tests)Closes #2308
Closes #2299