From 98f675fdf64b0c37f92a727e27220d6c6b4d041d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 13 Jul 2026 03:36:51 +0100 Subject: [PATCH] Type adoption closure authority --- epiphany-core/src/bin/epiphany-work.rs | 48 ++++----- .../closure_contracts/workflow.rs | 101 ++++++++++++++++++ .../closure_contracts/workflow_tests.rs | 38 +++++++ ...onceptual-substitution-audit-2026-07-12.md | 14 +++ notes/fresh-workspace-handoff.md | 8 ++ state/ledgers.msgpack | Bin 469818 -> 470245 bytes state/map.yaml | 2 +- 7 files changed, 180 insertions(+), 31 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 66070ca9..c8bc9b2f 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -7324,74 +7324,61 @@ fn closure_family_assertions( ); } "repo.adoption_request" => { + let request = parse_repo_adoption_request(&content).ok(); push_assertion( &mut assertions, "adoption-request-schema-present", - content.contains("schema_version = \"epiphany.repo_adoption_request.v0\""), + request + .as_ref() + .is_some_and(RepoAdoptionRequest::has_canonical_identity), "Committed adoption request carries the schema version.".to_string(), ); push_assertion( &mut assertions, "adoption-request-family-present", - content.contains("safe_action_family = \"repo.adoption_request\""), + request + .as_ref() + .is_some_and(RepoAdoptionRequest::has_canonical_identity), "Committed adoption request carries the safe action family.".to_string(), ); push_assertion( &mut assertions, "adoption-request-summary-present", - content.contains(&compact_summary), + request + .as_ref() + .is_some_and(|value| value.summary == compact_summary), "Committed adoption request contains the accepted pressure summary.".to_string(), ); push_assertion( &mut assertions, "adoption-request-awaits-mind", - content.contains("[request]") - && content.contains("status = \"awaiting-mind-review\"") - && content.contains( - "requested_decision = \"adopt-or-refuse-objective-draft\"", - ) - && content.contains("mind_review_required = true") - && content.contains("mind_state_commit_required = true") - && content.contains("self_scheduling_after_mind_only = true"), + request.as_ref().is_some_and(RepoAdoptionRequest::awaits_mind_review), "Committed adoption request waits for Mind review before state or scheduling consequence.".to_string(), ); push_assertion( &mut assertions, "adoption-request-decision-contract", - content.contains("[decision_contract]") - && content.contains("allowed_verdicts = [\"adopted\", \"refused\", \"needs-more-consensus\"]") - && content.contains("requires_review_finding = true") - && content.contains("requires_receipt = \"epiphany.mind.gateway_review\"") - && content.contains("requires_commit_receipt_if_adopted = \"epiphany.mind.state_commit_receipt\"") - && content.contains("does_not_modify_state = true"), + request.as_ref().is_some_and(RepoAdoptionRequest::has_decision_contract), "Committed adoption request names the Mind decision contract without modifying state.".to_string(), ); push_assertion( &mut assertions, "adoption-request-inputs-present", - content.contains("[inputs]") - && content.contains("public_discussion_refs = [") - && content.contains("candidate_action_refs = [") - && content.contains("objective_draft_required = true") - && content.contains("consensus_brief_required = true"), + request.as_ref().is_some_and(RepoAdoptionRequest::has_input_contract), "Committed adoption request preserves public inputs and requires draft/consensus antecedents.".to_string(), ); push_assertion( &mut assertions, "adoption-request-authority-seals", - content.contains("[authority]") - && content.contains("objective_adoption_authorized = false") - && content.contains("state_commit_authorized = false") - && content.contains("self_scheduling_authorized = false") - && content.contains("hands_action_authorized = false") - && content.contains("publication_authorized = false") - && content.contains("cross_body_mutation_authorized = false"), + request.as_ref().is_some_and(RepoAdoptionRequest::has_authority_seals), "Committed adoption request denies adoption/state/scheduling/action/publication/cross-body authority.".to_string(), ); push_assertion( &mut assertions, "adoption-request-private-seal", - content.contains("private_state_exposed = false"), + request + .as_ref() + .is_some_and(|value| !value.private_state_exposed), "Committed adoption request preserves the private-state seal.".to_string(), ); } @@ -15359,6 +15346,7 @@ idunn_deployment_authority_required = true "repo.sync_request", "repo.pr_request", "repo.maintainer_review_request", + "repo.adoption_request", "repo.scheduling_request", "repo.work_order", "repo.verification_request", diff --git a/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow.rs b/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow.rs index c2ac45f0..73c69d73 100644 --- a/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow.rs +++ b/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow.rs @@ -205,6 +205,107 @@ pub(super) fn parse_repo_scheduling_request(text: &str) -> Result bool { + self.schema_version == "epiphany.repo_adoption_request.v0" + && self.safe_action_family == "repo.adoption_request" + } + + pub(super) fn awaits_mind_review(&self) -> bool { + let r = &self.request; + r.status == "awaiting-mind-review" + && r.requested_decision == "adopt-or-refuse-objective-draft" + && r.mind_review_required + && r.mind_state_commit_required + && r.self_scheduling_after_mind_only + } + + pub(super) fn has_decision_contract(&self) -> bool { + let d = &self.decision_contract; + d.allowed_verdicts == ["adopted", "refused", "needs-more-consensus"] + && d.requires_review_finding + && d.requires_receipt == "epiphany.mind.gateway_review" + && d.requires_commit_receipt_if_adopted == "epiphany.mind.state_commit_receipt" + && d.does_not_modify_state + } + + pub(super) fn has_input_contract(&self) -> bool { + self.inputs.objective_draft_required + && self.inputs.consensus_brief_required + && self + .inputs + .public_discussion_refs + .iter() + .all(|value| !value.trim().is_empty()) + && self + .inputs + .candidate_action_refs + .iter() + .all(|value| !value.trim().is_empty()) + } + + pub(super) fn has_authority_seals(&self) -> bool { + let a = &self.authority; + a.branch_local_only + && !a.objective_adoption_authorized + && !a.state_commit_authorized + && !a.self_scheduling_authorized + && !a.hands_action_authorized + && !a.publication_authorized + && !a.cross_body_mutation_authorized + } +} + +#[derive(Debug, Deserialize)] +struct RepoAdoptionBody { + status: String, + requested_decision: String, + mind_review_required: bool, + mind_state_commit_required: bool, + self_scheduling_after_mind_only: bool, +} +#[derive(Debug, Deserialize)] +struct RepoAdoptionDecisionContract { + allowed_verdicts: Vec, + requires_review_finding: bool, + requires_receipt: String, + requires_commit_receipt_if_adopted: String, + does_not_modify_state: bool, +} +#[derive(Debug, Deserialize)] +struct RepoAdoptionInputs { + public_discussion_refs: Vec, + candidate_action_refs: Vec, + objective_draft_required: bool, + consensus_brief_required: bool, +} +#[derive(Debug, Deserialize)] +struct RepoAdoptionAuthority { + branch_local_only: bool, + objective_adoption_authorized: bool, + state_commit_authorized: bool, + self_scheduling_authorized: bool, + hands_action_authorized: bool, + publication_authorized: bool, + cross_body_mutation_authorized: bool, +} + +pub(super) fn parse_repo_adoption_request(text: &str) -> Result { + toml::from_str(text).context("adoption request is not valid typed TOML") +} + #[derive(Debug, Deserialize)] pub(super) struct RepoVerificationRequest { pub(super) schema_version: String, diff --git a/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow_tests.rs b/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow_tests.rs index 5132ee8d..65f7bea5 100644 --- a/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow_tests.rs +++ b/epiphany-core/src/bin/epiphany_work/closure_contracts/workflow_tests.rs @@ -2,6 +2,44 @@ mod workflow_tests { use super::*; + #[test] + fn adoption_comment_cannot_counterfeit_state_authority_seal() { + let text = r#" +schema_version = "epiphany.repo_adoption_request.v0" +safe_action_family = "repo.adoption_request" +summary = "summary" +private_state_exposed = false +[request] +status = "awaiting-mind-review" +requested_decision = "adopt-or-refuse-objective-draft" +mind_review_required = true +mind_state_commit_required = true +self_scheduling_after_mind_only = true +[decision_contract] +allowed_verdicts = ["adopted", "refused", "needs-more-consensus"] +requires_review_finding = true +requires_receipt = "epiphany.mind.gateway_review" +requires_commit_receipt_if_adopted = "epiphany.mind.state_commit_receipt" +does_not_modify_state = true +[inputs] +public_discussion_refs = [] +candidate_action_refs = [] +objective_draft_required = true +consensus_brief_required = true +[authority] +branch_local_only = true +objective_adoption_authorized = false +# state_commit_authorized = false +state_commit_authorized = true +self_scheduling_authorized = false +hands_action_authorized = false +publication_authorized = false +cross_body_mutation_authorized = false +"#; + let request = parse_repo_adoption_request(text).expect("fixture is typed TOML"); + assert!(!request.has_authority_seals()); + } + #[test] fn scheduling_comment_cannot_counterfeit_queue_authority_seal() { let text = r#" diff --git a/notes/conceptual-substitution-audit-2026-07-12.md b/notes/conceptual-substitution-audit-2026-07-12.md index c1b4d9a1..0983e407 100644 --- a/notes/conceptual-substitution-audit-2026-07-12.md +++ b/notes/conceptual-substitution-audit-2026-07-12.md @@ -1054,6 +1054,20 @@ guard preventing that substitution from returning. Fifteen high-authority closure families are typed; 477 substring assertions remain. Adoption is the remaining untyped workflow gate in this chain. +## Adoption prose as Mind state authority + +`repo.adoption_request` closure previously recognized the Mind decision, +allowed verdicts, required review/state receipts, inputs, and authority denials +by substring. A commented `state_commit_authorized = false` could conceal a +real state grant. Adoption now parses typed workflow state, validates nonblank +input references, and checks actual decision and authority fields. Its +malicious fixture and class guard prevent presentation text from impersonating +Mind admission authority. + +Sixteen high-authority closure families are typed; 447 substring assertions +remain. The adoption/scheduling/work-order/verification workflow chain is now +typed under one physical owner. + The same inspection found 33 consecutive duplicate `#[cfg(test)]` attributes on provider constructors/writers and their re-exports. One gate already makes each item test-only; the second owned nothing. The duplicates are removed. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 0d05cf05..361fcf1d 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -336,6 +336,14 @@ mutation grant, and the family is in the no-substring class guard. Fifteen high-authority families are typed and 477 substring assertions remain. Next type adoption, the remaining untyped workflow gate in this chain. +Adoption closure is now typed under workflow ownership as well. The decision +contract, review/state receipts, input requirements, authority denials, and +private seal are read as actual TOML fields; blank input references are +rejected. A malicious commented state-commit denial cannot hide a real grant, +and adoption is in the class guard. Sixteen high-authority families are typed +and 447 substring assertions remain. The complete adoption/scheduling/work- +order/verification chain now has one physical workflow owner. + The latest structural count is 32 closure family branches, 744 remaining substring assertions in the closure region, and 1,284 lines in `closure_contracts.rs`. Do not blindly generate a struct forest for every diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 605f6674578bdb652e0d4a6b534a15fd43d69056..65fa49a5a10a7b36f2d2e575d8e84dd2748d57ca 100644 GIT binary patch delta 337 zcmX|+F-rqM5QW`K^uWTxA|R$1uu-BHQ4ErF7Iun)mEEvA=2q`^FS~mQA%%s7zaZQ% zuvaVuOACL3puImsa3aCtG4Po8@!so4^ZT>;xF(i6-GklB_l3Ci_PikmLZo-o=zbar z*6h|;b=D$l>17(l51Z9lEncbbb@w~fQzKe$e2K}$xF7|N3Y(y^MbOq%KU?wX?TI!D z6iMyb0#7-bprzjiZHh8*Vo+*FIhnwo4;ZNJWlE~dwCT4|&Pbd$8Z&-Ch80c^QH~Qh z%Fx{WbFMs~BL-fR45WI1AZ>m=BXhGq@(vrh4s#qxG{y!Te?cL;=@%K>5y6;FhXazsZV|ZD`{GNw0AWon