From 789f5cc9e63cc32f939fe0e2a1dc212f85901d19 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 12:18:19 +0100 Subject: [PATCH] Bind repo map admission to Modeling generation --- epiphany-core/src/bin/epiphany-work.rs | 64 ++++++++++++++++++++++ epiphany-core/src/cultmesh_integration.rs | 4 ++ epiphany-core/src/modeling_gateway.rs | 4 ++ epiphany-core/src/runtime_spine.rs | 10 +++- notes/epiphany-current-algorithmic-map.md | 7 +++ notes/fresh-workspace-handoff.md | 9 +++ state/ledgers.msgpack | Bin 422397 -> 422670 bytes state/map.yaml | 2 +- 8 files changed, 98 insertions(+), 2 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 4c972a72..861441c2 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -9903,6 +9903,8 @@ fn record_repo_work_map_admission( closure_review: &Value, modeling_summary: &str, modeling_finding_receipt_id: &str, + modeling_route_id: &str, + modeling_generation: u64, soul_verdict_receipt_id: &str, mind_gateway_review_id: &str, mind_state_commit_receipt_id: &str, @@ -9936,6 +9938,8 @@ fn record_repo_work_map_admission( publication_gate: "Bifrost".to_string(), durable_state_admitted: true, private_state_exposed: false, + modeling_route_id: modeling_route_id.to_string(), + modeling_generation, }; commit_repo_work_map_admission(runtime_store, &entry, mind_review, mind_commit)?; runtime_repo_work_map_entry(runtime_store, &entry.map_entry_id)? @@ -9993,6 +9997,8 @@ fn project_repo_work_map_entry_to_local_verse( format!("commit {}", entry.commit_sha), format!("family {}", entry.safe_action_family), format!("modeling {}", entry.modeling_finding_receipt_id), + format!("modelingRoute {}", entry.modeling_route_id), + format!("modelingGeneration {}", entry.modeling_generation), format!("mind {}", entry.mind_state_commit_receipt_id), format!("publicationGate {}", entry.publication_gate), "private false".to_string(), @@ -10012,6 +10018,8 @@ fn project_repo_work_map_entry_to_local_verse( safe_action_family: entry.safe_action_family.clone(), modeling_summary: entry.modeling_summary.clone(), modeling_finding_receipt_id: entry.modeling_finding_receipt_id.clone(), + modeling_route_id: entry.modeling_route_id.clone(), + modeling_generation: entry.modeling_generation, soul_verdict_receipt_id: entry.soul_verdict_receipt_id.clone(), mind_gateway_review_id: entry.mind_gateway_review_id.clone(), mind_state_commit_receipt_id: entry.mind_state_commit_receipt_id.clone(), @@ -10051,6 +10059,8 @@ fn repo_work_map_entry_json(entry: &RepoWorkMapEntry) -> Value { "safeActionFamily": entry.safe_action_family, "modelingSummary": entry.modeling_summary, "modelingFindingReceiptId": entry.modeling_finding_receipt_id, + "modelingRouteId": entry.modeling_route_id, + "modelingGeneration": entry.modeling_generation, "soulVerdictReceiptId": entry.soul_verdict_receipt_id, "mindGatewayReviewId": entry.mind_gateway_review_id, "mindStateCommitReceiptId": entry.mind_state_commit_receipt_id, @@ -11837,6 +11847,8 @@ fn run_closure_pipeline(args: CloseArgs, phase: ClosurePhase) -> Result { &closure_review, &modeling_finding.summary, &modeling_finding.receipt_id, + &modeling_route.route_id, + modeling_route.generation, &soul_verdict.receipt_id, &mind_review.gateway_id, &mind_commit.receipt_id, @@ -17069,6 +17081,8 @@ mod authority_tests { publication_gate: "Bifrost".to_string(), durable_state_admitted: true, private_state_exposed: false, + modeling_route_id: route.route_id.clone(), + modeling_generation: route.generation, }; assert!(commit_repo_work_map_admission(&store, &map, &review, &commit).is_err()); assert!(epiphany_core::runtime_mind_gateway_review(&store, &review.gateway_id)?.is_none()); @@ -17165,6 +17179,56 @@ mod authority_tests { request_id: request0.request_id.clone(), }; put_repo_work_modeling_finding(&store, &finding0)?; + let stale_map_review = MindGatewayReview { + schema_version: MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), + gateway_id: "stale-map-review".to_string(), + source_kind: "repo_work_closure".to_string(), + source_role_id: "modeling".to_string(), + decision: MindGatewayDecision::Accept, + allowed_effects: vec!["repoWork.map".to_string()], + refused_effects: Vec::new(), + reasons: vec!["attempt stale admission".to_string()], + contract: "test".to_string(), + }; + let stale_map_commit = mind_state_commit_receipt( + "stale-map-commit".to_string(), + &stale_map_review, + 1, + vec!["repoWork.map".to_string()], + "2026-07-12T00:00:02Z".to_string(), + ); + let stale_map = RepoWorkMapEntry { + schema_version: REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(), + map_entry_id: "stale-map".to_string(), + admitted_at: "2026-07-12T00:00:02Z".to_string(), + item: request0.item.clone(), + branch: "test".to_string(), + changed_paths: request0.changed_paths.clone(), + commit_sha: request0.commit_sha.clone(), + safe_action_family: "repo.status_section".to_string(), + modeling_summary: finding0.summary.clone(), + modeling_finding_receipt_id: finding0.receipt_id.clone(), + soul_verdict_receipt_id: soul.receipt_id.clone(), + mind_gateway_review_id: stale_map_review.gateway_id.clone(), + mind_state_commit_receipt_id: stale_map_commit.receipt_id.clone(), + execute_receipt_path: "execute.json".to_string(), + closure_review_path: "review.json".to_string(), + closure_receipt_path: "close.json".to_string(), + publication_gate: "Bifrost".to_string(), + durable_state_admitted: true, + private_state_exposed: false, + modeling_route_id: route0.route_id.clone(), + modeling_generation: 0, + }; + assert!( + commit_repo_work_map_admission( + &store, + &stale_map, + &stale_map_review, + &stale_map_commit, + ) + .is_err() + ); let review = MindGatewayReview { schema_version: MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), gateway_id: "route-g1-mind-review".to_string(), diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 1e14296d..f2804950 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -965,6 +965,10 @@ pub struct EpiphanyCultMeshRepoWorkMapEntry { pub notes: Vec, #[cultcache(key = 22)] pub modeling_finding_receipt_id: String, + #[cultcache(key = 23)] + pub modeling_route_id: String, + #[cultcache(key = 24)] + pub modeling_generation: u64, } #[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)] diff --git a/epiphany-core/src/modeling_gateway.rs b/epiphany-core/src/modeling_gateway.rs index e28c2b74..6a9c98b0 100644 --- a/epiphany-core/src/modeling_gateway.rs +++ b/epiphany-core/src/modeling_gateway.rs @@ -148,4 +148,8 @@ pub struct RepoWorkMapEntry { pub durable_state_admitted: bool, #[cultcache(key = 18)] pub private_state_exposed: bool, + #[cultcache(key = 19)] + pub modeling_route_id: String, + #[cultcache(key = 20)] + pub modeling_generation: u64, } diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index e69377ce..256b72e9 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -2056,6 +2056,7 @@ pub fn commit_repo_work_map_admission( &entry.modeling_finding_receipt_id, "repo-work map Modeling finding receipt id", )?; + validate_non_empty(&entry.modeling_route_id, "repo-work map Modeling route id")?; if !entry.durable_state_admitted || entry.private_state_exposed { return Err(anyhow!( "repo-work map admission requires admitted, private-state-sealed state" @@ -2075,14 +2076,21 @@ pub fn commit_repo_work_map_admission( let modeling = cache .get::(&entry.modeling_finding_receipt_id)? .ok_or_else(|| anyhow!("repo-work map admission requires typed Modeling finding"))?; + let route = cache + .get::(&entry.modeling_route_id)? + .ok_or_else(|| anyhow!("repo-work map admission requires current Modeling route"))?; if modeling.item != entry.item || modeling.soul_verdict_receipt_id != entry.soul_verdict_receipt_id || modeling.commit_sha != entry.commit_sha || modeling.changed_paths != entry.changed_paths || modeling.summary != entry.modeling_summary + || modeling.verdict.trim().to_ascii_lowercase() != "passed" + || route.item != entry.item + || route.generation != entry.modeling_generation + || route.request_id != modeling.request_id { return Err(anyhow!( - "repo-work map entry does not match its typed Modeling finding" + "repo-work map entry does not match its passing current-generation Modeling finding" )); } if let Some(existing) = cache.get::(&entry.map_entry_id)? { diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 0314362e..6611d9e5 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -289,6 +289,13 @@ checks in native launch/coordinator code reject renewed Codex route authority. | Verse privacy/authority | CultMesh/Verse focused smokes and typed receipt readbacks | | Public crossings | Persona/Bifrost bridge smokes with private-state seals | +Repo-work map admission is a canonical generation-bound transaction. A map +entry names its `RepoWorkModelingRoute` and generation; the runtime spine loads +that route and admits only a passing immutable finding selected by the route's +current request. CLI closure is a caller of this invariant, not its owner. +Non-passing findings and stale generations therefore cannot become durable Mind +state even through a forged-looking admission call. + ## Current Cut Line Keep: diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index f4ea45f9..0c587dd3 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2130,6 +2130,15 @@ type-check. Next add a native end-to-end generation-one smoke that begins with a non-passing runtime finding, exercises `revise-modeling`, launches `g1` through Idunn/preflight, and proves generation zero cannot close or regain current authority. +Map admission is now generation-bound at the canonical transaction boundary. +`RepoWorkMapEntry` carries the stable Modeling route id and generation, and +`commit_repo_work_map_admission` loads the current route and requires the +referenced immutable finding to be passing, current, and selected by that +route. The CLI is no longer the only thing preventing a non-passing or stale +finding from entering durable Mind state. The authority suite includes the +negative non-passing admission path and remains 4/4 green. The next move is +still the native generation-one workflow smoke; it must exercise these gates, +not recreate them in orchestration code. ## Immediate Re-entry Instruction diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 37b34e6d9710fcf5903572024be034ff70ed4fa7..4a4e2dfd89ee60917f72b4938c47f107ec7610ed 100644 GIT binary patch delta 312 zcmX|+u}Z{15Qg1&USntFVKZQBO2zQ`IQ7ed?p#i7VhZnE1joVJimyO^d?E<@)}>%$-3^<sFAXb=Krq zmK`uPtzq(jP@^Dr38t#rfQypg+G#3>)t#|=n4U_?18G=v5DJ34WhNUSbhRwmwSizs zmKXzy?P`<@z(x!?GK+A8j0UuN#|nBjp0N#uV-w_c^1(~Hd+|wW8}Hivf93oSguHMA delta 57 zcmeBsCi(ZV