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 605f6674..65fa49a5 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 04608239..472d37b6 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -660,4 +660,4 @@ current_status: - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Continue the conceptual-substitution pass. Fifteen high-authority closure families are typed and guarded; 477 substring assertions remain. Workflow owns typed verification, work-order, and scheduling closure plus counterfeit-authority fixtures. Scheduling comments can no longer impersonate Self queue authority. Direct rustfmt is required because Cargo fmt misses the lexically included files. Next type adoption, the remaining untyped workflow gate in this chain, with a negative Mind/state-authority proof. External governance should converge on tooling plus publication/accounting; operations retains policy/deployment. Provider chronology is explicitly external and guarded as arrival order. Continue auditing evidence/security mirrors and adapters for borrowed authority. + next_action: Continue the conceptual-substitution pass. Sixteen high-authority closure families are typed and guarded; 447 substring assertions remain. Workflow physically owns typed adoption, scheduling, work-order, and verification closure plus counterfeit-authority fixtures. Presentation comments can no longer impersonate Mind admission, Self queue, Hands work-order, or Soul verification authority in this chain. Direct rustfmt is required because Cargo fmt misses the lexically included files. Next remap the remaining untyped closure families by owner and consequence before selecting another cut; do not assume the residual families belong in workflow. External governance should converge on tooling plus publication/accounting; operations retains policy/deployment. Provider chronology is explicitly external and guarded as arrival order. Continue auditing evidence/security mirrors and adapters for borrowed authority.