Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions atomic-core/ontology/shapes/review-1.0.0.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://atomic.dev/ns/workflow#>
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
}
}
"""
] ;
Expand Down
62 changes: 48 additions & 14 deletions atomic-repository/src/repository/publication_review/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.join("; ");
let output = intents
.iter()
.map(|id| format!("Attested intent: {id}\n"))
.collect::<String>();
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()
}
Expand All @@ -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<String>) {
let dir = tempfile::tempdir().unwrap();
let mut repo = Repository::init(dir.path()).unwrap();
repo.init_vault().unwrap();
Expand All @@ -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();
Expand All @@ -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::<Vec<_>>(),
))
.changes_explained(vec![change])
.build();
repo.save_provenance_graph(&graph).unwrap();
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions docs/retrospective-publication-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down