From b6f14ccfdd9c768d4a53c3c27167fcd803bd66e7 Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 13 Nov 2026 14:58:12 -0500 Subject: [PATCH] fix: accept reviewed set-aside intents as complete review scope The subject scope-completeness rule only recognized includesIntent, but the resolver pins icebox intents under includesSetAside. A change whose retained receipts observe an intent that was later set aside could never pass validation, even when the review intent explicitly reviews it. Accept either relation for scope completeness. Managed-change coverage still requires includesIntent, so a set-aside intent cannot stand in as implementation evidence (covered by the existing retired_intent_cannot_supply_managed_change_coverage test). Note: the shapes file participates in profile_hash, so previously signed reviews will read as stale and need a superseding signature. --- atomic-core/ontology/shapes/review-1.0.0.ttl | 11 +++- .../repository/publication_review/tests.rs | 62 ++++++++++++++----- .../publication_review/tests/observations.rs | 57 +++++++++++++++++ docs/retrospective-publication-review.md | 3 + 4 files changed, 117 insertions(+), 16 deletions(-) diff --git a/atomic-core/ontology/shapes/review-1.0.0.ttl b/atomic-core/ontology/shapes/review-1.0.0.ttl index 3d51c6df..86884c81 100644 --- a/atomic-core/ontology/shapes/review-1.0.0.ttl +++ b/atomic-core/ontology/shapes/review-1.0.0.ttl @@ -76,13 +76,20 @@ shape:Subject a sh:NodeShape ; } """ ] ; + # Scope completeness: every intent a reviewed change observed must be in the + # review scope, either as current work (includesIntent) or as an explicitly + # reviewed set-aside disposition (includesSetAside). Only includesIntent can + # supply managed-change coverage below; set-aside membership never does. sh:sparql [ - sh:message "Include the observed work intent in the original review intent's reviews references, then re-run review. Selected-review lifecycle receipts are context, not work requiring self-review." ; + sh:message "Include the observed intent in the original review intent's reviews references (as current work or an explicitly reviewed set-aside disposition), then re-run review. Selected-review lifecycle receipts are context, not work requiring self-review." ; sh:select """ PREFIX atomic: SELECT DISTINCT $this ?value WHERE { $this atomic:reviewsChange ?change . ?change atomic:hasReviewEvidence ?evidence . ?evidence atomic:observedIntent ?value ; atomic:observationRole "work" . - FILTER NOT EXISTS { $this atomic:includesIntent ?value . ?review atomic:reviewsClosure $this ; atomic:reviewIntent ?intent . ?intent atomic:reviews ?value } + FILTER NOT EXISTS { + { $this atomic:includesIntent ?value } UNION { $this atomic:includesSetAside ?value } + ?review atomic:reviewsClosure $this ; atomic:reviewIntent ?intent . ?intent atomic:reviews ?value + } } """ ] ; diff --git a/atomic-repository/src/repository/publication_review/tests.rs b/atomic-repository/src/repository/publication_review/tests.rs index 665d7e51..9e7d81fe 100644 --- a/atomic-repository/src/repository/publication_review/tests.rs +++ b/atomic-repository/src/repository/publication_review/tests.rs @@ -81,11 +81,25 @@ fn signed_intent( } fn receipt_node(work: &str) -> atomic_core::change::provenance_graph::ProvenanceNode { + receipt_node_for(&[work]) +} + +/// One retained receipt node attesting every listed intent in a single +/// multi-command invocation, exactly as a session transcript would retain it. +fn receipt_node_for(intents: &[&str]) -> atomic_core::change::provenance_graph::ProvenanceNode { + let command = intents + .iter() + .map(|id| format!("atomic intent attest {id}")) + .collect::>() + .join("; "); + let output = intents + .iter() + .map(|id| format!("Attested intent: {id}\n")) + .collect::(); serde_json::from_value(json!({ "id":"fixture-receipt", "kind":"execution", "timestamp":0, "summary":"Retained lifecycle receipt", "classified":false, - "detail":json!({"command":format!("atomic intent attest {work}"), - "output_summary":format!("Attested intent: {work}\n")}).to_string() + "detail":json!({"command":command,"output_summary":output}).to_string() })) .unwrap() } @@ -105,6 +119,17 @@ fn sign_intent(repo: &Repository, id: &str, signer: &Identity, pair: &KeyPair) { impl Fixture { fn new() -> Self { + Self::build(false).0 + } + + /// Like `new`, but the retained receipt also observes a second, independent + /// work intent by the same author. Returns that intent's UID. + fn with_second_observed_intent() -> (Self, String) { + let (fixture, second) = Self::build(true); + (fixture, second.expect("second observed intent")) + } + + fn build(second_observed: bool) -> (Self, Option) { let dir = tempfile::tempdir().unwrap(); let mut repo = Repository::init(dir.path()).unwrap(); repo.init_vault().unwrap(); @@ -120,6 +145,8 @@ impl Fixture { store.save(&author).unwrap(); store.save(&reviewer).unwrap(); let work = signed_intent(&repo, &author, &author_key, "feature", None); + let second = + second_observed.then(|| signed_intent(&repo, &author, &author_key, "feature", None)); let dependency = repo .save_change(&Change::empty(ChangeHeader::new("unmanaged dependency"))) .unwrap(); @@ -139,7 +166,11 @@ impl Fixture { .unwrap(); let change = repo.save_change(&change).unwrap(); let graph = ProvenanceGraphBuilder::new(SESSION, "fixture") - .add_node(receipt_node(&work)) + .add_node(receipt_node_for( + &std::iter::once(work.as_str()) + .chain(second.as_deref()) + .collect::>(), + )) .changes_explained(vec![change]) .build(); repo.save_provenance_graph(&graph).unwrap(); @@ -149,17 +180,20 @@ impl Fixture { ) .unwrap(); let review = signed_intent(&repo, &reviewer, &reviewer_key, "review", Some(&work)); - Self { - _dir: dir, - repo, - change, - author, - author_key, - reviewer, - reviewer_key, - work, - review, - } + ( + Self { + _dir: dir, + repo, + change, + author, + author_key, + reviewer, + reviewer_key, + work, + review, + }, + second, + ) } fn keys(&self, did: &str) -> Option<[u8; 32]> { [&self.author, &self.reviewer] diff --git a/atomic-repository/src/repository/publication_review/tests/observations.rs b/atomic-repository/src/repository/publication_review/tests/observations.rs index 26456fbd..3e6865a0 100644 --- a/atomic-repository/src/repository/publication_review/tests/observations.rs +++ b/atomic-repository/src/repository/publication_review/tests/observations.rs @@ -534,6 +534,63 @@ fn terminal_disposition_does_not_approve_historical_implementation_goals() { assert!(!f.conforms(&f.sign(forged), &f.config())); } +#[test] +fn reviewed_set_aside_intent_observed_by_a_change_does_not_block() { + let (f, retired) = Fixture::with_second_observed_intent(); + retire_fixture_work(&f, &retired, &f.author, &f.author_key); + extend_fixture_review(&f, &retired); + let signed = f.signed(); + assert_eq!(signed.subject.work.len(), 1); + assert_eq!(signed.subject.set_aside.len(), 1); + let observed: Vec<_> = signed + .subject + .changes + .iter() + .flat_map(|pin| pin.observations.iter()) + .filter_map(|observation| observation.intent.clone()) + .collect(); + assert!( + observed.contains(&format!("urn:atomic:intent:{retired}")), + "the retained receipt observes the set-aside intent" + ); + let report = f + .repo + .validate_publication_review(&signed, &f.config(), &|did| f.keys(did)) + .unwrap(); + assert!( + report.conforms, + "an explicitly reviewed set-aside intent is complete review scope: {:#?}", + report.results + ); +} + +#[test] +fn unreviewed_set_aside_intent_observed_by_a_change_still_blocks() { + let (f, retired) = Fixture::with_second_observed_intent(); + retire_fixture_work(&f, &retired, &f.author, &f.author_key); + // The review never references the retired intent, so the resolver pins + // nothing for it: inactive status alone must not complete the scope. + let signed = f.signed(); + assert!(signed.subject.set_aside.is_empty()); + let report = f + .repo + .validate_publication_review(&signed, &f.config(), &|did| f.keys(did)) + .unwrap(); + assert!(!report.conforms); + let retired_iri = + atomic_core::kg::iri::mint_intent(&f.repo.project_id().unwrap(), &retired).unwrap(); + assert!( + report.results.iter().any(|r| { + r["value"].as_str() == Some(retired_iri.as_str()) + && r["source_shape"] + .as_str() + .is_some_and(|shape| shape.ends_with("#Subject")) + }), + "the scope rule names the unreviewed set-aside intent: {:#?}", + report.results + ); +} + #[test] fn terminal_disposition_still_requires_an_independent_key() { let f = Fixture::new(); diff --git a/docs/retrospective-publication-review.md b/docs/retrospective-publication-review.md index f735f4f9..ff3a302a 100644 --- a/docs/retrospective-publication-review.md +++ b/docs/retrospective-publication-review.md @@ -183,6 +183,9 @@ attest a current `icebox` disposition with an explanation and retained originals The completed independent review must explicitly reference that intent. The resolver pins it in `ReviewSubject.set_aside`, separate from `work`, and the ontology projects `includesSetAside`, not active `includesIntent` coverage. +A reviewed change whose retained receipts observe that set-aside intent is +still complete review scope; only `includesIntent` can supply managed-change +coverage. SHACL requires fresh, valid, canonically conforming source, the explicit completed review and different authenticated signing keys for these dispositions too. It does **not** assert that historical implementation goals hold in today's product.