diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..4dbcdd26 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + # The release the optional evidence replay checker runs on. + - package-ecosystem: pip + directory: /docs/examples/evidence-replay + target-branch: dev + schedule: + interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 742332e2..8152be74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,3 +155,21 @@ jobs: - name: cargo check (MSRV) run: cargo check --workspace + + evidence-checker: + name: Evidence replay checker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + # The optional checker's release is pinned, with hashes, in + # requirements.txt; Dependabot proposes each new release. + - name: Install the pinned checker release + run: python -m pip install --require-hashes -r docs/examples/evidence-replay/requirements.txt + + - name: Run the checker controls + run: python -m unittest discover -s docs/examples/evidence-replay -p test_checker.py -v diff --git a/atomic-canonical/src/triage_ref.rs b/atomic-canonical/src/triage_ref.rs index c9b8a19d..8a8175b4 100644 --- a/atomic-canonical/src/triage_ref.rs +++ b/atomic-canonical/src/triage_ref.rs @@ -34,6 +34,11 @@ pub struct TriagePins { pub candidate_changes: Vec, /// Intent id → `intentSubstanceHash` at review time. pub intent_substance_hashes: BTreeMap, + /// Content hashes of attached retained evidence-replay reports. Sorted + /// before hashing; omitted from the canonical form when empty so existing + /// triage references stay stable. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub evidence_report_hashes: Vec, } /// The `urn:atomic:triage:` reference for a set of pins. @@ -45,6 +50,7 @@ pub struct TriagePins { pub fn triage_reference(pins: &TriagePins) -> String { let mut canonical_pins = pins.clone(); canonical_pins.candidate_changes.sort(); + canonical_pins.evidence_report_hashes.sort(); let value = serde_json::to_value(&canonical_pins).expect("TriagePins serialization is infallible"); let canonical = jcs::canonicalize(&value); @@ -72,6 +78,7 @@ mod tests { view_merkle: "MERKLEBASE32".to_string(), candidate_changes: vec!["CH2".to_string(), "CH1".to_string(), "CH3".to_string()], intent_substance_hashes: substance, + evidence_report_hashes: Vec::new(), } } @@ -117,6 +124,20 @@ mod tests { .intent_substance_hashes .insert("urn:atomic:intent:a".to_string(), "blake3:zzz".to_string()); assert_ne!(triage_reference(&substance), base); + + let mut evidence = pins(); + evidence + .evidence_report_hashes + .push("blake3:report".to_string()); + assert_ne!(triage_reference(&evidence), base); + evidence.evidence_report_hashes = vec!["blake3:b".to_string(), "blake3:a".to_string()]; + let mut reordered = evidence.clone(); + reordered.evidence_report_hashes.reverse(); + assert_eq!( + triage_reference(&evidence), + triage_reference(&reordered), + "report hashes are a set" + ); } #[test] diff --git a/atomic-canonical/src/vocab.rs b/atomic-canonical/src/vocab.rs index 8076a04c..6a3b5734 100644 --- a/atomic-canonical/src/vocab.rs +++ b/atomic-canonical/src/vocab.rs @@ -98,6 +98,11 @@ pub const FINDING_CODE: &[&str] = &[ "OPEN_REMEDIATION", "UNREVIEWED_CHANGE", "PUBLICATION_GATE", + "EVIDENCE_REPLAY_SUPPORTED", + "EVIDENCE_REPLAY_CONTRADICTED", + "EVIDENCE_REPLAY_NOT_ESTABLISHED", + "EVIDENCE_REPLAY_STALE", + "EVIDENCE_REPLAY_UNRELATED", ]; /// Directive names recognized by the parser + lift (closed set). diff --git a/atomic-cli/src/commands/rpc.rs b/atomic-cli/src/commands/rpc.rs index 1d8a3e8f..43aedfe4 100644 --- a/atomic-cli/src/commands/rpc.rs +++ b/atomic-cli/src/commands/rpc.rs @@ -6834,11 +6834,24 @@ pub(crate) fn triage_review( let Some(session) = Service::open()? else { return Ok(None); }; + let evidence_reports = args + .evidence_reports + .iter() + .map(|path| { + intent_evidence::read_report_bytes(path) + .map(|payload| pb::VersionedBytes { + schema: intent_evidence::REPORT_DOCUMENT_SCHEMA.to_string(), + payload, + }) + .map_err(evidence_cli_error) + }) + .collect::>>()?; let request = pb::GenerateTriageReviewRequest { repository: Some(session.reference.clone()), from_view: args.feature.clone().unwrap_or_default(), to_view: args.into.clone().unwrap_or_default(), report: None, + evidence_reports, }; let response = session.generate_triage_review(request)?; let Some(bundle) = response diff --git a/atomic-cli/src/commands/triage/mod.rs b/atomic-cli/src/commands/triage/mod.rs index fa1e36fc..51cd1bb7 100644 --- a/atomic-cli/src/commands/triage/mod.rs +++ b/atomic-cli/src/commands/triage/mod.rs @@ -11,6 +11,7 @@ use std::process::{Command as ProcessCommand, Stdio}; use clap::{Parser, Subcommand}; use clap_complete::engine::ArgValueCompleter; +use atomic_repository::intent_evidence; use atomic_repository::{Repository, RepositoryError}; use crate::commands::complete::complete_view_names; @@ -25,7 +26,9 @@ pub mod model { } pub mod output; pub mod project { - pub use atomic_repository::triage::report::{build_report, build_walkthrough, TaskFact}; + pub use atomic_repository::triage::report::{ + build_report, build_report_with_evidence, build_walkthrough, TaskFact, + }; } /// Triage a feature view against a target before insert. @@ -299,6 +302,12 @@ pub struct TriageReview { #[arg(long)] pub json: bool, + /// Attach a retained evidence-replay report produced by + /// `atomic intent validate --json --replay-evidence ...`. Repeatable; the + /// report's pins must still match the current intent/view state. + #[arg(long = "evidence-report", value_name = "PATH")] + pub evidence_reports: Vec, + /// Print the guided walkthrough: the candidate changes grouped into /// ordered semantic layers (foundations first), with each layer's /// rationale, files, and inspect commands. Bounded — never a diff dump. @@ -343,11 +352,28 @@ impl Command for TriageReview { let repo = Repository::open(&root).map_err(CliError::Repository)?; let (feature, into) = resolve_views(&repo, self.feature.as_deref(), self.into.as_deref())?; - let report = project::build_report(&repo, &feature, &into)?; + let evidence_reports = self + .evidence_reports + .iter() + .map(|path| intent_evidence::read_report(path).map_err(evidence_error)) + .collect::>>()?; + let report = + project::build_report_with_evidence(&repo, &feature, &into, &evidence_reports)?; render_report(self, &report) } } +/// Map a retained-report failure into the CLI's exit-code surface. +fn evidence_error(error: intent_evidence::EvidenceError) -> CliError { + match error { + intent_evidence::EvidenceError::Repository(error) => CliError::Repository(error), + intent_evidence::EvidenceError::Io(error) => CliError::Io(error), + other => CliError::InvalidArgument { + message: other.to_string(), + }, + } +} + /// The output selection, shared by the routed and the local body: attest > /// html > json > walkthrough > CLI dashboard. fn render_report( @@ -559,6 +585,19 @@ mod tests { assert!(msg.contains("omit --into"), "unexpected: {msg}"); } + #[test] + fn evidence_report_flag_is_repeatable() { + let review = TriageReview::try_parse_from([ + "review", + "--evidence-report", + "one.json", + "--evidence-report", + "two.json", + ]) + .unwrap(); + assert_eq!(review.evidence_reports.len(), 2); + } + #[test] fn candidates_parses_the_same_optional_pair_as_review() { let cmd = TriageCandidates::try_parse_from(["candidates"]).unwrap(); diff --git a/atomic-cli/src/commands/triage/output.rs b/atomic-cli/src/commands/triage/output.rs index 0b7f9ce0..1505d8b0 100644 --- a/atomic-cli/src/commands/triage/output.rs +++ b/atomic-cli/src/commands/triage/output.rs @@ -860,6 +860,7 @@ mod tests { candidate_changes: vec!["HASH1".to_string()], closure_additions: vec![], intent_substance_hashes: BTreeMap::new(), + evidence_reports: Vec::new(), }, summary: Summary { changes: 1, @@ -884,6 +885,7 @@ mod tests { satisfied_by: vec!["HASH1".to_string()], }], reviewed_by: Some("did:atomic:&co".to_string()), + evidence_replays: Vec::new(), }], changes: vec![ChangeReport { id: "HASH1".to_string(), diff --git a/atomic-repository/src/intent_evidence.rs b/atomic-repository/src/intent_evidence.rs index 2fd7985b..96c14d1c 100644 --- a/atomic-repository/src/intent_evidence.rs +++ b/atomic-repository/src/intent_evidence.rs @@ -85,12 +85,25 @@ pub struct EvidenceDecision { pub details: Value, } -#[derive(Debug, Serialize)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct EvidenceReport { - pub schema_version: &'static str, + pub schema_version: String, pub decisions: Vec, } +/// The retained report document produced by +/// `atomic intent validate --json --replay-evidence ...`. Unknown top-level +/// fields (`conforms`, `results`) are ignored so the full validate output is a +/// valid input. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct EvidenceReportDocument { + pub evidence_context: EvidenceContext, + pub evidence_replay: EvidenceReport, +} + +/// Wire/schema name for a retained replay report payload. +pub const REPORT_DOCUMENT_SCHEMA: &str = "atomic.intent.evidence-replay.v1"; + impl EvidenceReport { /// Map every non-supported decision to a canonical-gate violation. pub fn violations(&self) -> Vec { @@ -122,6 +135,14 @@ pub enum EvidenceError { ViewCycle, #[error("evidence replay manifest exceeds 1 MiB")] ManifestTooLarge, + #[error("evidence replay report exceeds 1 MiB")] + ReportTooLarge, + #[error("evidence replay report admission refused: {0}")] + ReportAdmission(String), + #[error("invalid evidence replay report: {0}")] + InvalidReport(String), + #[error("unsupported evidence replay report schema: {0}")] + UnsupportedReportSchema(String), #[error("evidence replay manifest admission refused: {0}")] ManifestAdmission(String), #[error("invalid evidence replay manifest: {0}")] @@ -212,6 +233,48 @@ pub fn read_manifest(path: &Path) -> Result, EvidenceError> { Ok(bytes) } +/// Parse a retained `atomic intent validate --json --replay-evidence` report. +/// Unknown top-level validate fields are ignored; the replay document itself is +/// strict. +pub fn parse_report(bytes: &[u8]) -> Result { + if bytes.len() as u64 > MANIFEST_LIMIT { + return Err(EvidenceError::ReportTooLarge); + } + let value = atomic_canonical::jcs::admit_document(bytes) + .map_err(|error| EvidenceError::ReportAdmission(error.to_string()))?; + let document: EvidenceReportDocument = serde_json::from_value(value) + .map_err(|error| EvidenceError::InvalidReport(error.to_string()))?; + if document.evidence_replay.schema_version != "atomic-evidence-replay-report/v1" { + return Err(EvidenceError::UnsupportedReportSchema( + document.evidence_replay.schema_version, + )); + } + Ok(document) +} + +/// Read a retained report within the protocol ceiling. +pub fn read_report_bytes(path: &Path) -> Result, EvidenceError> { + let file = std::fs::File::open(path)?; + let mut bytes = Vec::new(); + file.take(MANIFEST_LIMIT + 1).read_to_end(&mut bytes)?; + if bytes.len() as u64 > MANIFEST_LIMIT { + return Err(EvidenceError::ReportTooLarge); + } + Ok(bytes) +} + +/// Read and parse a retained report within the protocol ceiling. +pub fn read_report(path: &Path) -> Result { + parse_report(&read_report_bytes(path)?) +} + +/// Canonical content hash of a retained report document. Triage binds this hash +/// into its reference and signed report. +pub fn report_hash(document: &EvidenceReportDocument) -> Result { + let value = serde_json::to_value(document)?; + Ok(atomic_canonical::hash::content_hash(&value)) +} + /// Read and replay a manifest file. Relative artifact roots resolve against the /// manifest's parent directory. pub fn replay( @@ -292,7 +355,7 @@ pub fn replay_bytes( decisions.push(decision); } Ok(EvidenceReport { - schema_version: "atomic-evidence-replay-report/v1", + schema_version: "atomic-evidence-replay-report/v1".into(), decisions, }) } @@ -508,7 +571,7 @@ mod tests { assert!(!valid_decision(&decision, &claim, "request-2")); assert_eq!( EvidenceReport { - schema_version: "test", + schema_version: "test".into(), decisions: vec![decision] } .violations() @@ -519,7 +582,7 @@ mod tests { decision.decision = "contradicted".into(); assert_eq!( EvidenceReport { - schema_version: "test", + schema_version: "test".into(), decisions: vec![decision] } .violations() @@ -529,7 +592,7 @@ mod tests { decision = unknown(&claim, "request-1", "all_selected_spans_present"); decision.decision = "supported".into(); assert!(EvidenceReport { - schema_version: "test", + schema_version: "test".into(), decisions: vec![decision] } .violations() @@ -564,6 +627,44 @@ mod tests { assert_eq!(current.view_chain[1].name, parent); } + #[test] + fn retained_report_parses_hashes_and_ignores_validate_skins() { + let node = node(); + let current = context(&node); + let claim = manifest(&node).claims.remove(0); + let document = EvidenceReportDocument { + evidence_context: current.clone(), + evidence_replay: EvidenceReport { + schema_version: "atomic-evidence-replay-report/v1".into(), + decisions: vec![unknown(&claim, "request-1", "missing_artifact")], + }, + }; + let bytes = serde_json::to_vec(&document).unwrap(); + assert_eq!(parse_report(&bytes).unwrap(), document); + let hash = report_hash(&document).unwrap(); + assert!(hash.starts_with("blake3:")); + let mut changed = document.clone(); + changed.evidence_replay.decisions[0].reason = "different".into(); + assert_ne!(hash, report_hash(&changed).unwrap()); + + // The full `intent validate --json` document is accepted; its + // conforms/results fields are outside the replay document. + let wrapped = json!({ + "conforms": false, + "results": [{"message": "unattested"}], + "evidence_context": current, + "evidence_replay": document.evidence_replay, + }); + assert!(parse_report(&serde_json::to_vec(&wrapped).unwrap()).is_ok()); + + let mut unsupported = serde_json::to_value(&document).unwrap(); + unsupported["evidence_replay"]["schema_version"] = json!("other"); + assert!(matches!( + parse_report(&serde_json::to_vec(&unsupported).unwrap()), + Err(EvidenceError::UnsupportedReportSchema(_)) + )); + } + #[cfg(unix)] fn checker(script: &str) -> tempfile::TempPath { use std::os::unix::fs::PermissionsExt; diff --git a/atomic-repository/src/triage/mod.rs b/atomic-repository/src/triage/mod.rs index 98ba5e41..aa4240bb 100644 --- a/atomic-repository/src/triage/mod.rs +++ b/atomic-repository/src/triage/mod.rs @@ -13,4 +13,7 @@ pub mod model; pub mod report; pub use model::*; -pub use report::{build_report, count_hunk_atoms, hunk_display_summaries, HunkDisplaySummary}; +pub use report::{ + build_report, build_report_with_evidence, count_hunk_atoms, hunk_display_summaries, + HunkDisplaySummary, +}; diff --git a/atomic-repository/src/triage/model.rs b/atomic-repository/src/triage/model.rs index 5ae7b4b6..b1a20c82 100644 --- a/atomic-repository/src/triage/model.rs +++ b/atomic-repository/src/triage/model.rs @@ -45,8 +45,22 @@ pub const F_UNREVIEWED_CHANGE: &str = FINDING_CODE[10]; /// provenance evidence fails the trusted publication gate (CB-12B). Blocking /// for shared targets only; content correctness is separate. pub const F_PUBLICATION_GATE: &str = FINDING_CODE[11]; +/// A retained evidence-replay report supports its declared claim at the +/// current intent/view pins. +pub const F_EVIDENCE_REPLAY_SUPPORTED: &str = FINDING_CODE[12]; +/// A retained evidence-replay report contradicts its declared claim. +pub const F_EVIDENCE_REPLAY_CONTRADICTED: &str = FINDING_CODE[13]; +/// A retained evidence-replay report could not establish its claim. +pub const F_EVIDENCE_REPLAY_NOT_ESTABLISHED: &str = FINDING_CODE[14]; +/// A retained evidence-replay report no longer matches the current intent or +/// view-chain pins. +pub const F_EVIDENCE_REPLAY_STALE: &str = FINDING_CODE[15]; +/// A retained evidence-replay report addresses an intent outside the candidate +/// set (surfaced, never silently dropped). +pub const F_EVIDENCE_REPLAY_UNRELATED: &str = FINDING_CODE[16]; -// All twelve closed-vocabulary finding codes are now populated by `build_report`. +// All closed-vocabulary finding codes are recognized here; the +// EVIDENCE_REPLAY_* codes appear only when retained reports are attached. // ── Severities ────────────────────────────────────────────────────────────── @@ -100,6 +114,10 @@ pub struct Inputs { /// Intent id → `intentSubstanceHash` at review time. `BTreeMap` for a /// canonical, reproducible key order. pub intent_substance_hashes: BTreeMap, + /// Sorted content hashes of attached retained evidence-replay reports. + /// Omitted when empty, preserving existing report shapes. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub evidence_reports: Vec, } /// Bounded counts — the summary skin the CLI leads with. @@ -126,6 +144,43 @@ pub struct IntentReport { /// covers this work intent's changes, when one exists. #[serde(default, skip_serializing_if = "Option::is_none")] pub reviewed_by: Option, + /// Retained evidence-replay reports attached to this intent, with their + /// current-pin freshness. Empty when no report was supplied. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub evidence_replays: Vec, +} + +/// One attached retained replay report summarized for the triage report. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct EvidenceReplaySummary { + /// `blake3:` content hash of the parsed report document. + pub report_hash: String, + /// The native intent URN the report is bound to. + pub intent_id: String, + pub schema_version: String, + /// True iff the report's intent/view pins equal the current pins. + pub fresh: bool, + pub decisions: Vec, +} + +/// One replay decision, without the checker's unbounded `details` payload. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct EvidenceReplayDecision { + pub criterion_id: String, + pub claim_type: String, + pub decision: String, + pub reason: String, + /// The checker release the response names in `details.checker`, so a + /// reviewer can hold the decision to the checker they allowlisted. `None` + /// when the response names none, or names it in any other shape. + pub checker: Option, +} + +/// The package and version a replay checker reports for itself. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct CheckerRelease { + pub package: String, + pub version: String, } /// A single acceptance criterion under an intent (a "testcase"). @@ -303,6 +358,17 @@ mod tests { assert_eq!(F_VIEW_VERIFY_FAIL, "VIEW_VERIFY_FAIL"); assert_eq!(F_BLAST_UNREVIEWED, "BLAST_UNREVIEWED"); assert_eq!(F_UNREVIEWED_CHANGE, "UNREVIEWED_CHANGE"); + assert_eq!(F_EVIDENCE_REPLAY_SUPPORTED, "EVIDENCE_REPLAY_SUPPORTED"); + assert_eq!( + F_EVIDENCE_REPLAY_CONTRADICTED, + "EVIDENCE_REPLAY_CONTRADICTED" + ); + assert_eq!( + F_EVIDENCE_REPLAY_NOT_ESTABLISHED, + "EVIDENCE_REPLAY_NOT_ESTABLISHED" + ); + assert_eq!(F_EVIDENCE_REPLAY_STALE, "EVIDENCE_REPLAY_STALE"); + assert_eq!(F_EVIDENCE_REPLAY_UNRELATED, "EVIDENCE_REPLAY_UNRELATED"); for c in [ F_VIEW_VERIFY_FAIL, @@ -316,6 +382,12 @@ mod tests { F_STALE_TRIAGE, F_OPEN_REMEDIATION, F_UNREVIEWED_CHANGE, + F_PUBLICATION_GATE, + F_EVIDENCE_REPLAY_SUPPORTED, + F_EVIDENCE_REPLAY_CONTRADICTED, + F_EVIDENCE_REPLAY_NOT_ESTABLISHED, + F_EVIDENCE_REPLAY_STALE, + F_EVIDENCE_REPLAY_UNRELATED, ] { assert!(is_known_finding_code(c), "{c} must be in the closed set"); } diff --git a/atomic-repository/src/triage/report.rs b/atomic-repository/src/triage/report.rs index 5e7abf6d..919974af 100644 --- a/atomic-repository/src/triage/report.rs +++ b/atomic-repository/src/triage/report.rs @@ -27,6 +27,7 @@ use atomic_core::types::{Base32, Hash}; use crate::diff_engine::{change_file_diffs, DiffFormat, DiffOutputConfig, FileChangeStatus}; use crate::error::RepositoryError; use crate::intent_bridge as bridge; +use crate::intent_evidence::{self, EvidenceReportDocument}; use crate::Repository; use super::model::*; @@ -81,11 +82,59 @@ fn failing_view_verification(node: &CanonicalNode) -> Option { None } +/// Longest package name or version accepted from a checker's self-report. +const CHECKER_FIELD_MAX: usize = 128; + +/// The `{package, version}` a checker names in `details.checker`. Anything +/// else -- a missing member, an extra member, a non-string, an empty or +/// overlong value -- names no release, so a summary never shows a guess. +fn checker_release(details: &serde_json::Value) -> Option { + let checker = details.get("checker")?.as_object()?; + if checker.len() != 2 { + return None; + } + let field = |name: &str| { + checker + .get(name)? + .as_str() + .filter(|value| !value.is_empty() && value.len() <= CHECKER_FIELD_MAX) + .map(str::to_owned) + }; + Some(CheckerRelease { + package: field("package")?, + version: field("version")?, + }) +} + +/// Map a replay/report failure into the repository error surface. Repository +/// failures stay typed; report parsing/hash failures are invalid operations. +fn evidence_error(error: intent_evidence::EvidenceError) -> RepositoryError { + match error { + intent_evidence::EvidenceError::Repository(error) => error, + other => RepositoryError::InvalidOperation { + message: other.to_string(), + }, + } +} + /// Build the canonical triage report for `feature` relative to `target`. pub fn build_report( repo: &Repository, feature: &str, target: &str, +) -> Result { + build_report_with_evidence(repo, feature, target, &[]) +} + +/// Build the report with retained evidence-replay reports attached. Reports are +/// bound by content hash into the triage reference and summarized per intent; +/// a report whose pins no longer match the current intent/view chain is stale +/// and never contributes a supported/contradicted verdict of its own. +pub fn build_report_with_evidence( + repo: &Repository, + feature: &str, + target: &str, + evidence_reports: &[EvidenceReportDocument], ) -> Result { // 1. The candidate set (T0): only-in-feature, closure additions, baggage. let set = repo.triage_candidate_set(feature, target)?; @@ -97,6 +146,28 @@ pub fn build_report( // view, but is only a warning into a draft. Resolved once here. let target_is_shared = repo.get_view_info(target)?.scope.is_shared(); + // Retained replay reports: dedupe by content hash, then group by the intent + // they pin. Deterministic hash order keeps findings stable. + let mut parsed_reports: Vec<(String, &EvidenceReportDocument)> = evidence_reports + .iter() + .map(|document| Ok((intent_evidence::report_hash(document)?, document))) + .collect::>() + .map_err(evidence_error)?; + parsed_reports.sort_by(|a, b| a.0.cmp(&b.0)); + parsed_reports.dedup_by(|a, b| a.0 == b.0); + let evidence_report_hashes: Vec = parsed_reports + .iter() + .map(|(hash, _)| hash.clone()) + .collect(); + let mut evidence_by_intent: BTreeMap> = + BTreeMap::new(); + for (hash, document) in &parsed_reports { + evidence_by_intent + .entry(child_kg_id(&document.evidence_context.intent_id)) + .or_default() + .push((hash.clone(), document)); + } + // 3. The change → intent join. // // The change's modified files come from the change itself @@ -269,6 +340,95 @@ pub fn build_report( let current_substance = intent_substance_hash(&node); intent_substance_hashes.insert(intent_kg_id.clone(), current_substance.clone()); + // Attached retained replay reports. Only a report whose + // intent/source/view-chain pins still match the current state + // may contribute a supported or contradicted verdict; a stale + // report is surfaced and its decisions are not promoted. + let attached = evidence_by_intent.remove(intent_kg_id).unwrap_or_default(); + let mut evidence_replays = Vec::new(); + if !attached.is_empty() { + let current_context = + intent_evidence::read_context(repo, bare).map_err(evidence_error)?; + for (report_hash, document) in attached { + let fresh = document.evidence_context == current_context; + evidence_replays.push(EvidenceReplaySummary { + report_hash: report_hash.clone(), + intent_id: document.evidence_context.intent_id.clone(), + schema_version: document.evidence_replay.schema_version.clone(), + fresh, + decisions: document + .evidence_replay + .decisions + .iter() + .map(|decision| EvidenceReplayDecision { + criterion_id: decision.criterion_id.clone(), + claim_type: decision.claim_type.clone(), + decision: decision.decision.clone(), + reason: decision.reason.clone(), + checker: checker_release(&decision.details), + }) + .collect(), + }); + if !fresh { + findings.push( + Finding::new( + F_EVIDENCE_REPLAY_STALE, + SEV_WARN, + intent_kg_id.clone(), + format!( + "evidence replay report {report_hash} no longer matches \ + intent {intent_kg_id}'s substance/source or view-chain pins" + ), + ) + .with_remedy( + "re-run `atomic intent validate --json --replay-evidence \ + --evidence-checker ` against the current \ + state; a stale report cannot support or contradict a claim", + ), + ); + continue; + } + for decision in &document.evidence_replay.decisions { + let (code, severity, remedy) = match decision.decision.as_str() { + "supported" => ( + F_EVIDENCE_REPLAY_SUPPORTED, + SEV_INFO, + "none — the claim is supported at the pinned state", + ), + "contradicted" => ( + F_EVIDENCE_REPLAY_CONTRADICTED, + if target_is_shared { + SEV_BLOCK + } else { + SEV_WARN + }, + "treat the claim as false; fix the artifact or leave the \ + review criterion unmet", + ), + _ => ( + F_EVIDENCE_REPLAY_NOT_ESTABLISHED, + SEV_WARN, + "re-run replay with the declared artifacts and a checker that \ + can establish the claim", + ), + }; + findings.push( + Finding::new( + code, + severity, + decision.criterion_id.clone(), + format!( + "evidence replay {report_hash} for {intent_kg_id} \ + ({}) {}: {}", + decision.claim_type, decision.decision, decision.reason + ), + ) + .with_remedy(remedy), + ); + } + } + } + // STALE_TRIAGE (warn, T5b): a granted `done` whose reviewable // substance drifted from the pin recorded at grant time. The // intent still says done, but its definition moved afterward, so @@ -532,6 +692,7 @@ pub fn build_report( gate_violations, criteria, reviewed_by, + evidence_replays, }); } Err(e) => { @@ -554,11 +715,34 @@ pub fn build_report( gate_violations: vec![msg], criteria: Vec::new(), reviewed_by: None, + evidence_replays: Vec::new(), }); } } } + // A supplied report that did not match a reached intent is visible, never + // silently dropped. This also covers intents that failed to load above. + for (intent_id, attached) in evidence_by_intent { + for (report_hash, _) in attached { + findings.push( + Finding::new( + F_EVIDENCE_REPLAY_UNRELATED, + SEV_INFO, + intent_id.clone(), + format!( + "evidence replay report {report_hash} addresses {intent_id}, which is \ + outside this candidate set or could not be loaded" + ), + ) + .with_remedy( + "attach reports only for intents in this promotion; a report for another \ + intent does not participate in this verdict", + ), + ); + } + } + // 5. BAGGAGE_DEP (warn): closure additions not under a covered intent. for b in &set.baggage { findings.push( @@ -827,6 +1011,7 @@ pub fn build_report( view_merkle: view_merkle.clone(), candidate_changes: set.only_in_feature.clone(), intent_substance_hashes: intent_substance_hashes.clone(), + evidence_report_hashes: evidence_report_hashes.clone(), }; let reference = triage_reference(&pins); @@ -854,6 +1039,7 @@ pub fn build_report( candidate_changes: set.only_in_feature.clone(), closure_additions: set.closure_additions.clone(), intent_substance_hashes, + evidence_reports: evidence_report_hashes, }, summary, intents: intent_reports, @@ -1371,6 +1557,34 @@ mod tests { use atomic_core::change::ChangeHeader; use tempfile::TempDir; + #[test] + fn checker_release_reads_only_the_exact_self_report() { + use serde_json::json; + let named = |details: serde_json::Value| checker_release(&details); + assert_eq!( + named( + json!({"checker": {"package": "probity-verify", "version": "0.2.0"}, "scope": {}}) + ), + Some(CheckerRelease { + package: "probity-verify".into(), + version: "0.2.0".into(), + }) + ); + let long = "v".repeat(CHECKER_FIELD_MAX + 1); + for details in [ + serde_json::Value::Null, + json!({}), + json!({"checker": "probity-verify 0.2.0"}), + json!({"checker": {"package": "probity-verify"}}), + json!({"checker": {"package": "probity-verify", "version": 2}}), + json!({"checker": {"package": "", "version": "0.2.0"}}), + json!({"checker": {"package": "probity-verify", "version": long}}), + json!({"checker": {"package": "p", "version": "1", "extra": "x"}}), + ] { + assert_eq!(named(details.clone()), None, "{details}"); + } + } + fn record_all(repo: &Repository, message: &str) { let header = ChangeHeader::new(message); let options = RecordOptions::new() @@ -1516,6 +1730,166 @@ mod tests { repo.vault_index_kg(intent_file).unwrap(); } + /// Fresh reports contribute scoped findings and bind into the reference; + /// stale reports are surfaced but never trusted; contradicted reports block + /// for a shared target; unrelated reports stay visible. + #[test] + fn review_ingests_fresh_stale_and_unrelated_evidence_reports() { + use crate::intent_evidence::{EvidenceDecision, EvidenceReport, EvidenceReportDocument}; + + let temp = TempDir::new().unwrap(); + let mut repo = Repository::init(temp.path()).unwrap(); + repo.init_vault().unwrap(); + let working_copy = repo.require_working_copy_id().unwrap(); + let base_view = repo.current_view().to_string(); + let shared = repo.get_view_info(&base_view).unwrap().scope.is_shared(); + + let file = temp.path().join("a.txt"); + std::fs::write(&file, "base\n").unwrap(); + repo.add(working_copy, "a.txt", Default::default()).unwrap(); + record_all(&repo, "base change"); + + let body = "\ +:::why +Because a.txt matters. +::: + +:::acceptance-criterion{#a-ac-1 status=unmet} +a.txt is correct. +::: + +:::task{#a-1 status=unmet criteria=a-ac-1} +Edit a.txt. +::file-ref{path=a.txt} +:::"; + let a = repo.vault_intent_create(intent_opts("Intent A")).unwrap(); + let a_node_id = format!("intent:{}", a.uid.to_uppercase()); + + repo.create_view_from("feature", &base_view).unwrap(); + repo.switch_view(working_copy, "feature").unwrap(); + // Install after the switch: materializing the base view would otherwise + // restore the scaffold body and hide the directive body from the lift. + install_intent_body(&repo, &a.intent_file, body, None); + std::fs::write(&file, "base\nfeature edit\n").unwrap(); + repo.record( + working_copy, + ChangeHeader::new("feature change"), + RecordOptions::new() + .with_all(true) + .save_to_store(true) + .apply_after_record(true) + .enrich_kg(true) + .sync_vault(false), + ) + .unwrap(); + + let context = intent_evidence::read_context(&repo, &a.uid).unwrap(); + let entry = repo.vault_retrieve(&a.intent_file).unwrap().unwrap(); + let frontmatter: serde_json::Map = + serde_json::from_str(&entry.frontmatter_json).unwrap(); + let body = String::from_utf8(entry.content_bytes).unwrap(); + let node = atomic_canonical::lift::lift_intent(&frontmatter, &body).unwrap(); + assert!( + !node.has_acceptance_criterion.is_empty(), + "installed body must lift an acceptance criterion: {body:?}" + ); + let criterion = node.has_acceptance_criterion[0].id.clone(); + + let document = EvidenceReportDocument { + evidence_context: context, + evidence_replay: EvidenceReport { + schema_version: "atomic-evidence-replay-report/v1".into(), + decisions: vec![EvidenceDecision { + schema_version: "atomic-evidence-replay-response/v1".into(), + request_digest: "blake3:request".into(), + criterion_id: criterion, + claim_type: "source_text_coverage/v1".into(), + decision: "supported".into(), + reason: "all_selected_spans_present".into(), + details: serde_json::json!({ + "checker": {"package": "probity-verify", "version": "0.2.0"} + }), + }], + }, + }; + + let without = build_report(&repo, "feature", &base_view).unwrap(); + let with = build_report_with_evidence( + &repo, + "feature", + &base_view, + std::slice::from_ref(&document), + ) + .unwrap(); + assert_ne!( + with.reference, without.reference, + "reports bind into the reference" + ); + assert_eq!(with.inputs.evidence_reports.len(), 1); + let intent_report = with + .intents + .iter() + .find(|intent| intent.id == a_node_id) + .expect("reached intent"); + assert_eq!(intent_report.evidence_replays.len(), 1); + assert!(intent_report.evidence_replays[0].fresh); + assert_eq!( + intent_report.evidence_replays[0].decisions[0].checker, + Some(CheckerRelease { + package: "probity-verify".into(), + version: "0.2.0".into(), + }), + "the summary carries the checker release the response names" + ); + assert!(with + .findings + .iter() + .any(|finding| finding.code == F_EVIDENCE_REPLAY_SUPPORTED + && finding.severity == SEV_INFO)); + + let mut stale = document.clone(); + stale.evidence_context.view_chain[0].merkle = "stale".into(); + let stale_report = + build_report_with_evidence(&repo, "feature", &base_view, &[stale]).unwrap(); + let stale_intent = stale_report + .intents + .iter() + .find(|intent| intent.id == a_node_id) + .expect("reached intent"); + assert!(!stale_intent.evidence_replays[0].fresh); + assert!(stale_report + .findings + .iter() + .any(|finding| finding.code == F_EVIDENCE_REPLAY_STALE)); + assert!( + !stale_report + .findings + .iter() + .any(|finding| finding.code == F_EVIDENCE_REPLAY_SUPPORTED), + "stale evidence must not support a claim" + ); + + let mut contradicted = document.clone(); + contradicted.evidence_replay.decisions[0].decision = "contradicted".into(); + let contradicted_report = + build_report_with_evidence(&repo, "feature", &base_view, &[contradicted]).unwrap(); + let finding = contradicted_report + .findings + .iter() + .find(|finding| finding.code == F_EVIDENCE_REPLAY_CONTRADICTED) + .expect("contradicted finding"); + assert_eq!(finding.severity, if shared { SEV_BLOCK } else { SEV_WARN }); + + let mut unrelated = document; + unrelated.evidence_context.intent_id = "urn:atomic:intent:01UNRELATED".into(); + let unrelated_report = + build_report_with_evidence(&repo, "feature", &base_view, &[unrelated]).unwrap(); + assert!(unrelated_report + .findings + .iter() + .any(|finding| finding.code == F_EVIDENCE_REPLAY_UNRELATED)); + } + /// Build a report where intent A (reached by a candidate change that edits /// `a.txt`) is remediated by intent B. `b_done` controls whether the /// remediation is resolved. diff --git a/docs/examples/evidence-replay/README.md b/docs/examples/evidence-replay/README.md index e779f096..b375365d 100644 --- a/docs/examples/evidence-replay/README.md +++ b/docs/examples/evidence-replay/README.md @@ -22,15 +22,21 @@ On Windows, select a local executable implementing the protocol below. A checker that cannot start, fails, or returns an invalid response remains `not_established`; it cannot make validation pass. -Use a dedicated Python environment for the optional checker. The pinned Verify -revision below implements the four claim adapters listed later in this document: +Use a dedicated Python 3.11 or newer environment for the optional checker. +`requirements.txt` pins the probity-verify release, with hashes for it and every +dependency; that release implements the four claim adapters listed later in this +document. CI installs the same file and runs the checker controls below, and each +response names the installed release in `details.checker`: ```sh python3 -m venv /tmp/atomic-evidence-python -/tmp/atomic-evidence-python/bin/pip install \ - 'git+https://github.com/probityai/probity-verify.git@e835ce2bd6a960e7a1cc2fa6522f16d55dce728a' +/tmp/atomic-evidence-python/bin/pip install --require-hashes \ + -r /path/to/atomic/docs/examples/evidence-replay/requirements.txt ``` +To move to a newer release, change `requirements.in` and regenerate the lock with +`uv pip compile requirements.in --generate-hashes --python-version 3.11 --universal -o requirements.txt`. + Create a **draft** with one criterion in an Atomic repository: ```sh diff --git a/docs/examples/evidence-replay/probity-checker.py b/docs/examples/evidence-replay/probity-checker.py index 8bed5f7d..329e4f5c 100755 --- a/docs/examples/evidence-replay/probity-checker.py +++ b/docs/examples/evidence-replay/probity-checker.py @@ -1,17 +1,22 @@ #!/usr/bin/env python3 """Optional local Atomic checker using Probity Verify's bounded adapters. -Install probity-verify in the Python environment selected by this executable. -This wrapper authenticates neither witnesses nor Atomic signatures. Its result +Install the pinned probity-verify from requirements.txt in the Python +environment selected by this executable. Every response names the installed +probity-verify version in `details.checker`, so a retained report records which +release produced it. This wrapper authenticates neither witnesses nor Atomic signatures. Its result only applies to the selected claim, retained bytes, and supplied consumer policy. """ import json import sys +from importlib.metadata import version from pathlib import Path from probity_verify.common import CaseError from probity_verify.core import adjudicate +CHECKER = {"package": "probity-verify", "version": version("probity-verify")} + def check(envelope): if not isinstance(envelope, dict) or set(envelope) != {"request", "request_digest"}: @@ -42,9 +47,10 @@ def check(envelope): if assessment["claim_type"] != claim["claim_type"]: raise CaseError("claim type differs from consumer policy") result = adjudicate(case, policy, Path(claim["artifact_root"])) - response.update(decision=result["decision"], reason=result["reason"], details=result) + response.update(decision=result["decision"], reason=result["reason"], + details={**result, "checker": CHECKER}) except (CaseError, KeyError, TypeError, ValueError, OSError) as error: - response["details"] = {"error": str(error)} + response["details"] = {"error": str(error), "checker": CHECKER} return response diff --git a/docs/examples/evidence-replay/requirements.in b/docs/examples/evidence-replay/requirements.in new file mode 100644 index 00000000..aa149b20 --- /dev/null +++ b/docs/examples/evidence-replay/requirements.in @@ -0,0 +1 @@ +probity-verify==0.2.0 diff --git a/docs/examples/evidence-replay/requirements.txt b/docs/examples/evidence-replay/requirements.txt new file mode 100644 index 00000000..a2dcf75b --- /dev/null +++ b/docs/examples/evidence-replay/requirements.txt @@ -0,0 +1,252 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in --generate-hashes --python-version 3.11 --universal -o requirements.txt +agent-evidence-vocabulary==0.5.0 \ + --hash=sha256:0d46b62e0ebe20345b89838cb75d4369d59d12b8c064fba1d575a7b2270fa338 \ + --hash=sha256:dfdb0d011ac9e9b3c476c3d2173a36e7a6cfac664a0c14a9a5dd5da045975337 + # via probity-verify +cffi==2.1.1 ; platform_python_implementation != 'PyPy' \ + --hash=sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e \ + --hash=sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66 \ + --hash=sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2 \ + --hash=sha256:154852545011f779917b11c78db2358d095da62a9a172b78ad0a583ee5adc0d0 \ + --hash=sha256:194cffa889098ced9976c3fc6340305e43f6303657d298da55366907c05c22d6 \ + --hash=sha256:19ee6127ee34de7d83ce3d371ebc5ed91addbdcc39f9ab15ce4eb35a4e534971 \ + --hash=sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c \ + --hash=sha256:1aa5645c30469b09530c4ebca77ebf8f17618293c58f8549cb1a543a50236e7d \ + --hash=sha256:1dea0e4d7d4f11f619fe8c1d76caf49e24405b4b5743c0e3be16a500ecd930c9 \ + --hash=sha256:208f941bb9d18e768138677f0a6d2ce01f590df56043dda1df1535ac57c88517 \ + --hash=sha256:210019b6c7cf07f081b4c54635c8cf744377001350e29cc0f81c4377b4797735 \ + --hash=sha256:246fa40ce8645a614ff682e0b70f37134e460eaf93a775e0cbe3cca585a67a80 \ + --hash=sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f \ + --hash=sha256:27350daa11d4f10c540e6e89dada4c54feb7256ad03e9a4dc075ebad7ba360d1 \ + --hash=sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29 \ + --hash=sha256:2ae64be792b8966f2c69538199728b290e34726562896df1e5dc8ffd8d8188e8 \ + --hash=sha256:31348097ff5bbe827ccc41795d4dd099d9f0625e7def00ee653c137a490c2a6c \ + --hash=sha256:3143d81e29e1e20a9ce10901ec369012947876596f75a222235965f2b7ae832e \ + --hash=sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48 \ + --hash=sha256:3311ed60d36f83378794e1009ac6258bafbf81f7888b4caa7b35a521e3f95813 \ + --hash=sha256:334644fbac4eff73d985a17a91226df55d0f394160c4cfb880e084c8f7161cac \ + --hash=sha256:34e261f78cb6ceaaa36f42f2613f4380d94d9c759a9c73c769ee6e0247364632 \ + --hash=sha256:363e05fa78e15116c3c32c210ee36884fd6b9afa6d440e47112c3bd511d64cb6 \ + --hash=sha256:398aff33cee2767e3e781d2554c54bd0dff386bb437581e0d8011fde1a942ec1 \ + --hash=sha256:3d22a20b1fb1632cc72c22f95f7b0d2961c3e1c235f245ba4c606c4771035659 \ + --hash=sha256:42a494cee34437f05546455144f2b5d9ac09b1face62bcfce597d2e521066688 \ + --hash=sha256:42e2f76b9455f5a9a844f770bf3e200ed3da0e15f5df3db9c31fe80b04b3d004 \ + --hash=sha256:42f6930c31dc7f50732c9ae793c2786c7b6b044195967bbdde40bb9be81c4cc0 \ + --hash=sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062 \ + --hash=sha256:471cee653ae88de62096552e6d24ccb4a5adb8c8c9f10b5054d0122c15bf2779 \ + --hash=sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94 \ + --hash=sha256:4a7c934f7360e8cd64fe9efadcbd10c7c6364f531e432b9a4bf5ccbc9e0e8b50 \ + --hash=sha256:4be96343e422f2dfcd12ab5c9f5aebe03f82f737c6bffeca6830b3875cb44aab \ + --hash=sha256:4f42141fc14250de6dde5ee7ea4432be017252d91f19c5ad043c084cea629cac \ + --hash=sha256:507a24c282e0f42f8ed737cf048572cbf580468da5555764a8331735e9c736b6 \ + --hash=sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676 \ + --hash=sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1 \ + --hash=sha256:5a59cc1c4442bc3d5c703bf720b51138d0bfc173618807c9ee2490a7541dd3d9 \ + --hash=sha256:5bb4e7ea95dcd6a014a6fef62e62467d67d8e582326443f3d68e71d6320a9fcf \ + --hash=sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13 \ + --hash=sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e \ + --hash=sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e \ + --hash=sha256:63bbfd5ded17c4840ac07cd8f1c21ba9d9708141f840b324f422f41b207e3973 \ + --hash=sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527 \ + --hash=sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72 \ + --hash=sha256:68e62fe11f30d5ca8289242866f0a5291402d8529ca2178ab8afc5c9694ae890 \ + --hash=sha256:6a8dddef476fab96d066d578fc88526767b836ab5ab21754e1d5bf3879c31c7c \ + --hash=sha256:6e192623c49c94421616a5778fba35cf0d5a8d000650c1967ef4448ee5cdd990 \ + --hash=sha256:7225e4514edb64eb6740324353e0da0711954fd8d7da4576755b1c6e09b697cd \ + --hash=sha256:75f80557d1389eddbd0de2681f6a390a0c5338c31ddaa821381c203fc3fd50d9 \ + --hash=sha256:770de9db11e84213beec501cfcaa013b019820ca881e03344dea5844f7876d94 \ + --hash=sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3 \ + --hash=sha256:7bde5e4cc5c10140859842b9d383af292b22639a4dffb725314baf45968cef80 \ + --hash=sha256:7ce713ace7c0e4520535b42b77eaa742c16dab813978064913e5a3cf82973b41 \ + --hash=sha256:7da0c5eff80f0197f3b3d1232ec5a682a9325f4ae9016a78f5f5ca35f9ced1f5 \ + --hash=sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c \ + --hash=sha256:811bd1e21d32de12efca32393a0ab3f5133b54fce9bd44b8bd77ab07da14bf6a \ + --hash=sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4 \ + --hash=sha256:937c0052c05a31ca1daf18de3158eed4dbfcb9cc107adbea227728d647be701e \ + --hash=sha256:9d2055050ea716bd38b7f7f1579c275386646b4894c155a3e2f3cd62ed41b7c6 \ + --hash=sha256:9f8d177621de5cb38ee3e731eda45d421db093ec0739f46a5594babda7987a98 \ + --hash=sha256:a2d7755bef5a12ed488f4ef1f1b69ee9191d7396083b755a5d2295f6edb4768b \ + --hash=sha256:a48d62ab9d6f4f98c983223a547af44be6ca3691074c31cecced6facd3ba2dc1 \ + --hash=sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03 \ + --hash=sha256:a6e721d4b0e45d5b65e87534470e67b18dcd092c83f68fba09f152b9cbc061af \ + --hash=sha256:a730a083190634c65cca36ba5f489531576ebd79bcd5c8e172130f6453127231 \ + --hash=sha256:a931079504ecc49efed7744c476a5c343a92fabf66dec2db95edb1b2fdc770e2 \ + --hash=sha256:aa9511c62d14da7aacc9b4bf51f3f697a621e83b2d6919008243c3aad168eea3 \ + --hash=sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836 \ + --hash=sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5 \ + --hash=sha256:aeae0e330c9f6acd681f647d46cefd30c29f93e3392882e792e82080c9691399 \ + --hash=sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96 \ + --hash=sha256:b5bdfd1c873d4e093aabc0ca84c4ca6dbc4f752afb5c86f146d9742580c9da2e \ + --hash=sha256:baed1e86cc735622097354b9d1281406caf42ff42a886d29faa8e8d1630333be \ + --hash=sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf \ + --hash=sha256:c26608d2222fb1e94487e4a387d85f13eb55d5ed725cb25a0c589ac4ee60e7bc \ + --hash=sha256:c7659f22557c5a0bc4855cd635f55edec690cc008a40768527762cb9fb263455 \ + --hash=sha256:c8c69575568085ba0b1b10c0249d779a214aea6f6522e949a0fc9fb0fcb449d0 \ + --hash=sha256:c8d2c9fd1f2d16f780d15127abb050d13d1a76c03a4bd87d7e4980e45e511e12 \ + --hash=sha256:ca82be1a1d406ecfe1d25dc16cb33488e5a16bf4438c9fb590484ea29d92478b \ + --hash=sha256:cc572dace3f60ef98d7b12ff411d20f5362feb31a0439eab0085bbfd349982d7 \ + --hash=sha256:d18e5ac0f2f03f4f518d3e23db0f0cad7faa1da8620e9c09461d443bbf6e6692 \ + --hash=sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54 \ + --hash=sha256:d9c275eaacd24aa73f94ffd6de08fc3f932424d8b6c376f4bed7cde376fe7bc3 \ + --hash=sha256:da0e573f9f97159390c89d9f1a9e41908b66d408cc5b58d08cf3847d844c531b \ + --hash=sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be \ + --hash=sha256:dddad92b554513a31f272570678ba307fb9f618f05e3d4a5eacafff9eae03e1d \ + --hash=sha256:df423d40ee8654634421812bc3b196da3f9bd7d32929da813f8394c4348a5358 \ + --hash=sha256:df913725b79db7bcf03448f36b7bf8815363417d5b58deecf9305e3e30f0f21a \ + --hash=sha256:e0bcb7e0f677f543555d2adff3bf19c05f66cdb4796e5ff602442ab2fe3c4ef7 \ + --hash=sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc \ + --hash=sha256:e6e8cff14d6fb0be70a09c0bdc58096f501952d04624ebf867e0e56da2df8960 \ + --hash=sha256:f16c709686a78c727bbbf059f92b0bf41c6fc60deec706d2dc19f529175a6125 \ + --hash=sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb \ + --hash=sha256:f53e442b08449d42821fa4a4fba000095af9f62742a500f978a9f557ec44339a \ + --hash=sha256:f5cfbc5fe74540d335175b656c725d74d90e3730c626d92575eea35029d9afaa \ + --hash=sha256:f81b3b8f3d4e343550fa4baa0e479bba9f2d29ce9c2e9b51d1ce1718d7442fcf \ + --hash=sha256:f8ec5e643a9a937f64e1999eb9f75d072263751912dc5cd06d3c85f8f44be7c3 \ + --hash=sha256:fb92203a88b3d3053034db775110081c49d28be6551923805e039924093761e4 \ + --hash=sha256:fcd22650c908d7b7da162bbfaab594a1227a15d1643a98c68b122ac642fa2264 + # via cryptography +cryptography==50.0.2 \ + --hash=sha256:0ddc924c04591c2811ca024d62ecad4f7f6f08af8939c211438f48a16bd23602 \ + --hash=sha256:0ec5f09541743261e66e291b4a0cbf0fb2997aeaab6d9e9c740b9dba1b58d1c2 \ + --hash=sha256:0ecbc5652bdb6fc9eaf89a7d196e20941adfe812f43bc4ca05d9150496821047 \ + --hash=sha256:1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c \ + --hash=sha256:1ba34f04897fcdaa73f74145c25f3ec146fbd56593853e88adc2e811303c5f42 \ + --hash=sha256:241449bf940a5d27309bd317e6f9a2af6932113818bb2b8f5c59ddc7ef16da18 \ + --hash=sha256:25784ce8b9621c90c643efb9e1e2162ab3b0224cae446ad5e70e7fcb1ce18b51 \ + --hash=sha256:3dc4fd8058cea1644971207d530e1a03a184a805ffc8ebdddf0599d78a331b81 \ + --hash=sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856 \ + --hash=sha256:4a20ce1e5cb4284a86692fdcba7cb8754185c6b2e5c56fcef3751cf451d3cdc2 \ + --hash=sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de \ + --hash=sha256:58a0c478eeca76fe5e07993c5a0703def34a6dc6a0cda4f5564639b33112ffe7 \ + --hash=sha256:58ddb5a8e3179d12f19e4ea34d2d32e9d63a4baa142c875c1eb59f41b7243acd \ + --hash=sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2 \ + --hash=sha256:6f8700550aa1474a91e5dc07049c46f98b423b5b1ddd0483e0b51362eeeaf5be \ + --hash=sha256:78198641e5be9521beea5aa782bb551a58068d10e6eb04c9c680c1b69f2e7d45 \ + --hash=sha256:79def8d059362e7831389ed3be0ecdf58a89386e1271e35dd9f5af84e81bffd0 \ + --hash=sha256:7a8701d6b584d76e909e3d305b7d126b41439876a5aaf76cddc67fc230eafa2e \ + --hash=sha256:7afa5a6602a9f29af1f3a2965f831bae7c9d5d597b7cbb716d41ab3b7d89879c \ + --hash=sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5 \ + --hash=sha256:7b75de3c8b3be1cdb1052747c929440c3eea46c1bc2cb8a6e3a48388e9b7b452 \ + --hash=sha256:7c6d0330c472d96f6a6afe24d80dfdf15176c33096f0a4397ae4c60f3dd3be48 \ + --hash=sha256:828d49b0ff5a0e3975865571c5d91dbbdd0d38d8289b249a163e9425413a5e05 \ + --hash=sha256:84f964e537f916e2cc85199e5a88742e964939b575ac8598b3f9d6cc416cdaf1 \ + --hash=sha256:85d0d9a31b9098e98534226d5686b47264b95e62ce459dc2e62fdfc809f9fe93 \ + --hash=sha256:87e9ce85beb6b328ba370cc6e6aea483c92617b4c95b1d33a49297eb662bfb04 \ + --hash=sha256:8c71ba2cd31fc93748c38e1b613200ff1c2665cbfd5341fe3a61cfde35a1430e \ + --hash=sha256:92e665960f25fcdc73725b9cec7a3824f279ba97a98653afe9ffac2e43668f67 \ + --hash=sha256:94e5e9f108ee10471288214d3d233fbfbb492840a8457eb85178d643ddeb32c7 \ + --hash=sha256:9c8402a82ea0dc4ceeab793db05f0fafa8ca139ca34fcde5df0f596103c74107 \ + --hash=sha256:9dab55f57c74c3cad24c323bacbbd04be4705ba6eb0d92e920b1fc4837ed5079 \ + --hash=sha256:a582ab2ae1d34f67112cadc86702774c9ea4374df6bca6afe672817203c99134 \ + --hash=sha256:a6557e5f38e065ca9fbdaf7cfc7435ecb1d113aa81a022d1b51921ee7432e227 \ + --hash=sha256:a9f7355e6fab51f6c369b86fb7571cffa05edee2c2121e0380a37fb9ac1cd5c1 \ + --hash=sha256:ab50ee449bf968271e820086f10a33d101dd060370abc10bcd22279be2656539 \ + --hash=sha256:ac9ed99d81760c62fe89d5f0815cdfa1ba9a35141cf30f1c2d044f04b4803d2e \ + --hash=sha256:b13478603dcd0a2479ff8e87e2c19a7d525734686fe3c49542472293a204212d \ + --hash=sha256:c423ab384a46c4dff7217b2ea5ba2e11cffdeab6441acd04cf65a369caf0366c \ + --hash=sha256:c5e67125c7dca78d199ec4e116aa93dbb83494808ecbb8211a2cb09b1bf41dbd \ + --hash=sha256:c71be1cbfa5cd9a41ee452acf1eccd82b2c05950358b106ec8ceb83411d1a020 \ + --hash=sha256:cbc8738fd8526d80f35cb3a40d41f41a2e7030bb3b18b09a6778ef63d291c2fd \ + --hash=sha256:ce47f66801c20ec6c6632453bb5960fe38939e9306970b48b3a5a26de7745d94 \ + --hash=sha256:d370b8d1dfcdf7130178137f6fbee6140774a1acc6cacefc4b42643ec11d0a3a \ + --hash=sha256:d38cdff612d06fa6a32840d5e1b1f7a27cee4a349aa9085d94a67789d6bfd408 \ + --hash=sha256:d8947001be83df1394050758ce0e745dd74fb134eef0a4b5124208dfc3a68c37 \ + --hash=sha256:deb9fde5c60e437ee4821bc9bc39ff31b42135c27e1dc61ef0a629389c1de62e \ + --hash=sha256:dfe9763530994147d9af1def057a5b9658b00e8f8fe8743d144d1e0911c2e454 \ + --hash=sha256:e105ab60406787da31fccc883fc0f733af1efd78f0136a4599692c4083a73d0c \ + --hash=sha256:e275096ea1e60cc595cda2836fd4a6c725d1125108b868be17f53684d164e2cc \ + --hash=sha256:edc3342adf8f697fc5f59c887a304356f147b397809440ed64e2fa6af2f50f37 \ + --hash=sha256:ee247f5c245c9a2fe7c8e2214e295918838e44e00a45a6718451e4004219e767 \ + --hash=sha256:eef4c2f3423810b3070ab391f85436d2f8bbfcb286ac15cbc73190b3563b1f1a \ + --hash=sha256:f21e8a22c8605750c7af886bab299a363721264061b4ac0a30efb73cfd58efc5 \ + --hash=sha256:f265528741e048bce55c3463ed721fb0aa45a5888d8add8cfeccb3035451bbdc \ + --hash=sha256:f2f9bd7f90c64fe89253f0a2c05e3c4856072660429ce8831b4235bf29403a67 \ + --hash=sha256:f785f6161f202ab04d8ca194158968798e480ca058943907972da5f12e2881e8 \ + --hash=sha256:f9f6143a8c75945eb960d9eb98905a441394abfa24afaae239d514ffb2586480 \ + --hash=sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb \ + --hash=sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b + # via probity-verify +probity-verify==0.2.0 \ + --hash=sha256:2066124630b36309adf21a01ba545506f7f9aec311d11c983f1703092a9cf8c8 \ + --hash=sha256:9cf0491d707ac7e18e1a2069b10eef605d1c63ccd3594acf0510a67bc3688bb3 + # via -r requirements.in +pycparser==3.12 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy' \ + --hash=sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e \ + --hash=sha256:f03387877eab82ce01bbdfd0ba7252ee55a90b1c708d5129e2ce915475cf1db6 + # via cffi +pyyaml==6.0.3 \ + --hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \ + --hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \ + --hash=sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3 \ + --hash=sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956 \ + --hash=sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6 \ + --hash=sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c \ + --hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \ + --hash=sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a \ + --hash=sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0 \ + --hash=sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b \ + --hash=sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1 \ + --hash=sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6 \ + --hash=sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7 \ + --hash=sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e \ + --hash=sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007 \ + --hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \ + --hash=sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4 \ + --hash=sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9 \ + --hash=sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295 \ + --hash=sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea \ + --hash=sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0 \ + --hash=sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e \ + --hash=sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac \ + --hash=sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9 \ + --hash=sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7 \ + --hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \ + --hash=sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb \ + --hash=sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b \ + --hash=sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69 \ + --hash=sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5 \ + --hash=sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b \ + --hash=sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c \ + --hash=sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369 \ + --hash=sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd \ + --hash=sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824 \ + --hash=sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198 \ + --hash=sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065 \ + --hash=sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c \ + --hash=sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c \ + --hash=sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764 \ + --hash=sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196 \ + --hash=sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b \ + --hash=sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00 \ + --hash=sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac \ + --hash=sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8 \ + --hash=sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e \ + --hash=sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28 \ + --hash=sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3 \ + --hash=sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5 \ + --hash=sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4 \ + --hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b \ + --hash=sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf \ + --hash=sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5 \ + --hash=sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702 \ + --hash=sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8 \ + --hash=sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788 \ + --hash=sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da \ + --hash=sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d \ + --hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc \ + --hash=sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c \ + --hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \ + --hash=sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f \ + --hash=sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917 \ + --hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \ + --hash=sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26 \ + --hash=sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f \ + --hash=sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b \ + --hash=sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be \ + --hash=sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c \ + --hash=sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3 \ + --hash=sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6 \ + --hash=sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926 \ + --hash=sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0 + # via probity-verify diff --git a/docs/examples/evidence-replay/test_checker.py b/docs/examples/evidence-replay/test_checker.py index 082d2dc7..fc5facfb 100644 --- a/docs/examples/evidence-replay/test_checker.py +++ b/docs/examples/evidence-replay/test_checker.py @@ -3,8 +3,10 @@ import hashlib import importlib.util import json +import re import tempfile import unittest +from importlib.metadata import version from pathlib import Path spec = importlib.util.spec_from_file_location("checker", Path(__file__).with_name("probity-checker.py")) @@ -12,6 +14,15 @@ spec.loader.exec_module(checker) +def pinned_verify_version(): + """The probity-verify version requirements.txt pins.""" + text = Path(__file__).with_name("requirements.txt").read_text(encoding="utf-8") + pins = re.findall(r"^probity-verify==([^\s;\\]+)", text, flags=re.MULTILINE) + if len(pins) != 1: + raise AssertionError(f"requirements.txt pins probity-verify {len(pins)} times") + return pins[0] + + class ReplayCheckerTests(unittest.TestCase): def setUp(self): self.temp = tempfile.TemporaryDirectory() @@ -45,6 +56,15 @@ def setUp(self): "artifact_root": str(root), "case": case, "policy": policy}, }} + def test_installed_verify_is_the_pinned_release(self): + self.assertEqual(version("probity-verify"), pinned_verify_version()) + + def test_every_response_names_the_checker_release(self): + pinned = {"package": "probity-verify", "version": pinned_verify_version()} + self.assertEqual(checker.check(self.request)["details"]["checker"], pinned) + (self.root / "record.txt").unlink() + self.assertEqual(checker.check(self.request)["details"]["checker"], pinned) + def test_supported_preserves_binding_and_bounded_scope(self): result = checker.check(self.request) self.assertEqual(result["decision"], "supported") diff --git a/docs/triage.md b/docs/triage.md index f26239d9..ac70e17a 100644 --- a/docs/triage.md +++ b/docs/triage.md @@ -148,6 +148,41 @@ draft merkle B: npm run serve → PASS (observed @B, supersedes the @A failur promoted. `npm run serve` failing lands here by default; if diagnosably attributable to a change, it also attaches to that change's AC. +## Attached evidence replay + +`atomic triage review --into --json --evidence-report ` +attaches a retained report produced by: + +```sh +atomic intent validate --json \ + --replay-evidence retained/manifest.json \ + --evidence-checker /trusted/checker > retained/replay-report.json +``` + +The reviewer runs replay with a checker they trust; the author supplies the +manifest and artifacts, never the executable. Triage re-reads the current intent +and view chain and compares them to the report's `evidence_context`: + +- a **fresh** report contributes per-intent `evidence_replays[]` summaries and + `EVIDENCE_REPLAY_*` findings; +- a **stale** report is surfaced, but its decisions are never treated as + supported or contradicted; +- a report for an intent outside the candidate set is surfaced as + `EVIDENCE_REPLAY_UNRELATED`, never silently dropped. + +Each summarized decision carries `checker`, the `{package, version}` the +checker's response named in `details.checker`, or `null` when it named none in +that exact shape. A reviewer who allowlists a checker release can hold every +decision to it; the example checker reports the probity-verify release it ran. + +The report content hashes are bound into `inputs.evidence_reports` and the +`urn:atomic:triage:` reference, so attaching or changing a report changes +the reference. `--attest` signs the summaries as part of the report. + +The full reviewer procedure lives in the `triage-review` skill. See +[examples/evidence-replay/README.md](./examples/evidence-replay/README.md) for the +manifest/checker protocol. + ## The three invalidation axes A granted `done` is a **standing grant conditioned on freshness**. Three @@ -406,13 +441,22 @@ Both the shapes and the skill branch on `code`, so it is a closed vocabulary. | `STALE_TRIAGE` | warn | intent | pinned inputs no longer match current state | | `OPEN_REMEDIATION` | info | intent | promoted code has a `remediates`-linked intent in flight | | `UNREVIEWED_CHANGE` | block →shared / warn draft | intent | no `done`, independent (non-author) review covers this intent's changes | +| `EVIDENCE_REPLAY_SUPPORTED` | info | ac | attached replay report supports its claim at the current pins | +| `EVIDENCE_REPLAY_CONTRADICTED` | block →shared / warn draft | ac | retained bytes contradict the claim | +| `EVIDENCE_REPLAY_NOT_ESTABLISHED` | warn | ac | missing/unknown/failed/timed-out checker result | +| `EVIDENCE_REPLAY_STALE` | warn | intent | report pins no longer match the intent/source/view chain | +| `EVIDENCE_REPLAY_UNRELATED` | info | intent | report addresses an intent outside this candidate set | ## The review skill `triage-review` drives the content judgment the gate deliberately leaves honest ("presence is enforced; content is left honest"): -1. `atomic triage --into --json` → the worklist. +1. `atomic triage review --into --json --evidence-report ` + → the worklist. When the author sealed a claim, run replay yourself first and + attach the report; a supported claim can back a met review criterion, while + contradicted/not-established/stale leaves it unmet (see "Attached evidence + replay"). 2. For each `block` finding and every `judgment_required` criterion, investigate with the code-intelligence tools (`callers`, `entities`, `code`) and **read the actual diffs** (`atomic change `, `atomic diff -c --word-diff`) — @@ -552,6 +596,10 @@ edge, a `ReviewShape` gate rule, `atomic intent new --review`, and the - `atomic-repository/src/repository/content.rs` — `diff_views` (candidate set), `get_file_content_via_filter`. +- `atomic-repository/src/intent_evidence.rs` — bounded replay core and retained + report parsing/hashing. +- `atomic-repository/src/triage/report.rs` — report ingestion, pin freshness, + and `EVIDENCE_REPLAY_*` findings. - `atomic-cli/src/commands/query/mod.rs` — `neighbors`, `callers` (blast radius), `entities`, `graph` / `emit_html` (the HTML surface), `plan`. - `atomic-cli/src/commands/provenance/command.rs` — `provenance trace` (the PROV diff --git a/libatomic/proto/atomic/services/triage/triage_messages.proto b/libatomic/proto/atomic/services/triage/triage_messages.proto index 1f30e9f2..37abb557 100644 --- a/libatomic/proto/atomic/services/triage/triage_messages.proto +++ b/libatomic/proto/atomic/services/triage/triage_messages.proto @@ -45,6 +45,10 @@ message GenerateTriageReviewRequest { // — the walkthrough/dashboard/JSON renders run client-side over the // wire-carried domain report. optional VersionedBytes report = 4; + // Retained evidence-replay reports (schema + // "atomic.intent.evidence-replay.v1"). Each document's pins are re-checked + // against current state; stale reports are surfaced, never trusted. + repeated VersionedBytes evidence_reports = 5; } message GenerateTriageReviewResponse { repeated TriageLayer layers = 1; // ordered semantic walkthrough layers diff --git a/libatomic/src/daemon/services_triage.rs b/libatomic/src/daemon/services_triage.rs index 6e64dedf..2597c1f0 100644 --- a/libatomic/src/daemon/services_triage.rs +++ b/libatomic/src/daemon/services_triage.rs @@ -14,6 +14,7 @@ use std::sync::Arc; use crate::atomic::ErrorCode; use crate::atomic::*; +use atomic_repository::intent_evidence; use atomic_repository::Repository; use tonic::{Request, Response, Status}; @@ -129,6 +130,7 @@ impl triage_service_server::TriageService for TriageImpl { let _gate = gate_handle.exclusive().await; let feature_arg = request.from_view.clone(); let into_arg = request.to_view.clone(); + let evidence_payloads = request.evidence_reports; let report = tokio::task::spawn_blocking(move || { let repo = handle.repository_readonly()?; // Empty strings read as "not given" — the same defaults the @@ -136,8 +138,27 @@ impl triage_service_server::TriageService for TriageImpl { let feature = (!feature_arg.is_empty()).then_some(feature_arg.as_str()); let into = (!into_arg.is_empty()).then_some(into_arg.as_str()); let (feature, target) = resolve_triage_views(&repo, feature, into)?; - let report = atomic_repository::triage::build_report(&repo, &feature, &target) - .map_err(repository_error)?; + let evidence_reports = evidence_payloads + .iter() + .map(|bytes| { + if bytes.schema != intent_evidence::REPORT_DOCUMENT_SCHEMA { + return Err(domain_status( + ErrorCode::InvalidArgument, + format!("unsupported evidence report schema: {}", bytes.schema), + )); + } + intent_evidence::parse_report(&bytes.payload).map_err(|error| { + domain_status(ErrorCode::InvalidArgument, error.to_string()) + }) + }) + .collect::, _>>()?; + let report = atomic_repository::triage::build_report_with_evidence( + &repo, + &feature, + &target, + &evidence_reports, + ) + .map_err(repository_error)?; let payload = serde_json::to_vec(&report) .map_err(|error| Status::internal(format!("triage report encode: {error}")))?; Ok::<_, Status>(payload) diff --git a/libatomic/tests/triage_service_test.rs b/libatomic/tests/triage_service_test.rs index 82952bc4..14240108 100644 --- a/libatomic/tests/triage_service_test.rs +++ b/libatomic/tests/triage_service_test.rs @@ -23,8 +23,9 @@ use tempfile::TempDir; use tonic::{Code, Request}; use atomic_core::change::ChangeHeader; +use atomic_repository::intent_evidence; use libatomic::atomic::triage_service_server::TriageService; -use libatomic::atomic::{GenerateTriageReviewRequest, RepositoryRef}; +use libatomic::atomic::{GenerateTriageReviewRequest, RepositoryRef, VersionedBytes}; fn write(root: &std::path::Path, rel: &str, content: &str) { let path = root.join(rel); @@ -97,6 +98,7 @@ async fn the_review_arrives_as_the_wire_report_shape() { from_view: "feat".into(), to_view: "dev".into(), report: None, + evidence_reports: Vec::new(), })) .await .expect("the handler serves the report"); @@ -142,8 +144,74 @@ async fn an_unknown_view_is_refused() { from_view: "nope".into(), to_view: "dev".into(), report: None, + evidence_reports: Vec::new(), })) .await .expect_err("refused"); assert_eq!(refused.code(), Code::InvalidArgument, "{refused}"); } + +/// Retained replay reports ride the wire, bind into the report's pinned inputs, +/// and surface an unmatched report instead of trusting it. +#[tokio::test] +async fn evidence_reports_are_carried_and_bound_into_the_wire_report() { + let (_dir, _root, state, repository) = host(); + let triage = TriageImpl { state }; + let document = serde_json::json!({ + "evidence_context": { + "intent_id": "urn:atomic:intent:01UNRELATED", + "intent_substance_hash": "blake3:substance", + "intent_source_hash": "blake3:source", + "view_chain": [{"name": "feat", "merkle": "STALE", "scope": "draft"}] + }, + "evidence_replay": { + "schema_version": "atomic-evidence-replay-report/v1", + "decisions": [{ + "schema_version": "atomic-evidence-replay-response/v1", + "request_digest": "blake3:request", + "criterion_id": "urn:atomic:ac:01UNRELATED-ac-1", + "claim_type": "source_text_coverage/v1", + "decision": "supported", + "reason": "all_selected_spans_present", + "details": null + }] + } + }); + let response = triage + .generate_triage_review(Request::new(GenerateTriageReviewRequest { + repository: Some(repository.clone()), + from_view: "feat".into(), + to_view: "dev".into(), + report: None, + evidence_reports: vec![VersionedBytes { + schema: intent_evidence::REPORT_DOCUMENT_SCHEMA.into(), + payload: serde_json::to_vec(&document).unwrap(), + }], + })) + .await + .expect("the handler serves the report"); + let bundle = response.into_inner().report.expect("report bundle"); + let report: atomic_repository::triage::TriageReport = + serde_json::from_slice(&bundle.payload).unwrap(); + assert_eq!(report.inputs.evidence_reports.len(), 1); + assert!(report.inputs.evidence_reports[0].starts_with("blake3:")); + assert!(report + .findings + .iter() + .any(|finding| finding.code == "EVIDENCE_REPLAY_UNRELATED")); + + let refused = triage + .generate_triage_review(Request::new(GenerateTriageReviewRequest { + repository: Some(repository), + from_view: "feat".into(), + to_view: "dev".into(), + report: None, + evidence_reports: vec![VersionedBytes { + schema: "wrong".into(), + payload: serde_json::to_vec(&document).unwrap(), + }], + })) + .await + .expect_err("unsupported schema refused"); + assert_eq!(refused.code(), Code::InvalidArgument, "{refused}"); +}