From ec38f704c99a7e180d1e4f0d1ab8379b1348a186 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 12 Jul 2026 08:27:47 +0100 Subject: [PATCH] Make repo map admission atomic --- epiphany-core/src/bin/epiphany-work.rs | 198 ++++++++++----------- epiphany-core/src/lib.rs | 5 + epiphany-core/src/modeling_gateway.rs | 45 +++++ epiphany-core/src/runtime_spine.rs | 80 +++++++++ notes/epiphany-current-algorithmic-map.md | 7 + notes/epiphany-fork-implementation-plan.md | 7 +- notes/fresh-workspace-handoff.md | 9 + state/ledgers.msgpack | Bin 418005 -> 418514 bytes state/map.yaml | 2 +- 9 files changed, 250 insertions(+), 103 deletions(-) diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 6a7492db..2674d850 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -27,7 +27,9 @@ use epiphany_core::MIND_GATEWAY_REVIEW_SCHEMA_VERSION; use epiphany_core::MindGatewayDecision; use epiphany_core::MindGatewayReview; use epiphany_core::PersonaMemoryCacheConfig; +use epiphany_core::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION; use epiphany_core::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION; +use epiphany_core::RepoWorkMapEntry; use epiphany_core::RepoWorkModelingFinding; use epiphany_core::RuntimeSpineInitOptions; use epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION; @@ -38,6 +40,7 @@ use epiphany_core::WeksaInterlinguaInput; use epiphany_core::WeksaSpeakerContext; use epiphany_core::build_weksa_interlingua_packet; use epiphany_core::build_weksa_target_lowering_request; +use epiphany_core::commit_repo_work_map_admission; use epiphany_core::hands_action_review_for_intent; use epiphany_core::hands_command_receipt_for_review; use epiphany_core::hands_commit_receipt_for_review; @@ -63,8 +66,6 @@ use epiphany_core::put_hands_command_receipt; use epiphany_core::put_hands_commit_receipt; use epiphany_core::put_hands_patch_receipt; use epiphany_core::put_hands_pr_receipt; -use epiphany_core::put_mind_gateway_review; -use epiphany_core::put_mind_state_commit_receipt; use epiphany_core::put_repo_work_modeling_finding; use epiphany_core::put_soul_verdict_receipt; use epiphany_core::put_substrate_gate_repo_access_grant_receipt; @@ -74,6 +75,7 @@ use epiphany_core::runtime_hands_action_intent; use epiphany_core::runtime_hands_action_review; use epiphany_core::runtime_hands_commit_receipt; use epiphany_core::runtime_latest_hands_receipt_chain_after; +use epiphany_core::runtime_repo_work_map_entry; use epiphany_core::runtime_repo_work_modeling_finding; use epiphany_core::write_epiphany_cultmesh_repo_work_map_entry; use epiphany_core::write_epiphany_cultmesh_repo_work_overview; @@ -83,8 +85,6 @@ use epiphany_core::write_epiphany_cultmesh_repo_work_readiness_review; use epiphany_core::write_epiphany_cultmesh_weksa_lowering_receipt; use epiphany_state_model::EpiphanyMemoryContextQuery; use epiphany_state_model::EpiphanyMemoryProfile; -use serde::Deserialize; -use serde::Serialize; use serde_json::Value; use serde_json::json; use sha2::Digest; @@ -95,41 +95,6 @@ use std::path::Path; use std::path::PathBuf; use std::process::Command; -const REPO_WORK_MAP_STORE_SCHEMA_VERSION: &str = "epiphany.repo_work_map_store.v0"; -const REPO_WORK_MAP_ENTRY_SCHEMA_VERSION: &str = "epiphany.repo_work_map_entry.v0"; - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -struct RepoWorkMapStore { - schema_version: String, - updated_at: String, - entries: Vec, - private_state_exposed: bool, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -struct RepoWorkMapEntry { - schema_version: String, - admitted_at: String, - item: String, - branch: String, - changed_paths: Vec, - commit_sha: String, - safe_action_family: String, - modeling_summary: String, - modeling_finding_receipt_id: String, - soul_verdict_receipt_id: String, - mind_gateway_review_id: String, - mind_state_commit_receipt_id: String, - execute_receipt_path: String, - closure_review_path: String, - closure_receipt_path: String, - publication_gate: String, - durable_state_admitted: bool, - private_state_exposed: bool, -} - fn main() -> Result<()> { let mut args = env::args().skip(1); let Some(command) = args.next() else { @@ -9870,46 +9835,8 @@ fn closure_mind_adoption_review(execute_receipt: &Value) -> Result<(Value, bool) )) } -fn repo_work_map_store_path(workspace: &Path) -> PathBuf { - workspace - .join(".epiphany") - .join("state") - .join("repo-work-map.msgpack") -} - -fn load_repo_work_map_store(path: &Path) -> Result { - if !path.exists() { - return Ok(RepoWorkMapStore { - schema_version: REPO_WORK_MAP_STORE_SCHEMA_VERSION.to_string(), - updated_at: Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true), - entries: Vec::new(), - private_state_exposed: false, - }); - } - let bytes = fs::read(path).with_context(|| format!("failed to read {}", path.display()))?; - let store: RepoWorkMapStore = rmp_serde::from_slice(&bytes) - .with_context(|| format!("failed to decode {}", path.display()))?; - if store.schema_version != REPO_WORK_MAP_STORE_SCHEMA_VERSION { - return Err(anyhow!( - "unsupported repo work map schema {} in {}", - store.schema_version, - path.display() - )); - } - Ok(store) -} - -fn write_repo_work_map_store(path: &Path, store: &RepoWorkMapStore) -> Result<()> { - if let Some(parent) = path.parent() { - fs::create_dir_all(parent) - .with_context(|| format!("failed to create {}", parent.display()))?; - } - let bytes = rmp_serde::to_vec_named(store).context("failed to encode repo work map store")?; - fs::write(path, bytes).with_context(|| format!("failed to write {}", path.display())) -} - fn record_repo_work_map_admission( - workspace: &Path, + runtime_store: &Path, item: &str, branch: &str, changed_paths: Vec, @@ -9923,15 +9850,16 @@ fn record_repo_work_map_admission( execute_receipt_path: &Path, closure_review_path: &Path, closure_receipt_path: &Path, -) -> Result<(PathBuf, RepoWorkMapEntry)> { - let map_store_path = repo_work_map_store_path(workspace); - let mut store = load_repo_work_map_store(&map_store_path)?; + mind_review: &MindGatewayReview, + mind_commit: &epiphany_core::MindStateCommitReceipt, +) -> Result { let now = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true); let safe_action_family = string_from_json(closure_review, &["familyAssertions", "safeActionFamily"]) .unwrap_or_else(|| "manual-or-unknown".to_string()); let entry = RepoWorkMapEntry { schema_version: REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(), + map_entry_id: format!("repo-work-map-{}", sanitize(item)), admitted_at: now.clone(), item: item.to_string(), branch: branch.to_string(), @@ -9950,15 +9878,9 @@ fn record_repo_work_map_admission( durable_state_admitted: true, private_state_exposed: false, }; - store.entries.retain(|existing| existing.item != item); - store.entries.push(entry.clone()); - store - .entries - .sort_by(|left, right| left.item.cmp(&right.item)); - store.updated_at = now; - store.private_state_exposed = false; - write_repo_work_map_store(&map_store_path, &store)?; - Ok((map_store_path, entry)) + commit_repo_work_map_admission(runtime_store, &entry, mind_review, mind_commit)?; + runtime_repo_work_map_entry(runtime_store, &entry.map_entry_id)? + .ok_or_else(|| anyhow!("committed repo-work map entry could not be reread")) } fn resolve_local_verse_store_from_execute_receipt( @@ -10058,6 +9980,30 @@ fn project_repo_work_map_entry_to_local_verse( write_epiphany_cultmesh_repo_work_map_entry(local_verse_store, map_entry) } +fn repo_work_map_entry_json(entry: &RepoWorkMapEntry) -> Value { + json!({ + "schemaVersion": entry.schema_version, + "mapEntryId": entry.map_entry_id, + "admittedAt": entry.admitted_at, + "item": entry.item, + "branch": entry.branch, + "changedPaths": entry.changed_paths, + "commitSha": entry.commit_sha, + "safeActionFamily": entry.safe_action_family, + "modelingSummary": entry.modeling_summary, + "modelingFindingReceiptId": entry.modeling_finding_receipt_id, + "soulVerdictReceiptId": entry.soul_verdict_receipt_id, + "mindGatewayReviewId": entry.mind_gateway_review_id, + "mindStateCommitReceiptId": entry.mind_state_commit_receipt_id, + "executeReceiptPath": entry.execute_receipt_path, + "closureReviewPath": entry.closure_review_path, + "closureReceiptPath": entry.closure_receipt_path, + "publicationGate": entry.publication_gate, + "durableStateAdmitted": entry.durable_state_admitted, + "privateStateExposed": entry.private_state_exposed, + }) +} + fn short_commit(commit_sha: &str) -> String { commit_sha.chars().take(12).collect::() } @@ -11575,7 +11521,6 @@ fn run_close(args: CloseArgs) -> Result { ], contract: "Mind review for repo-work closure; admits the verified Modeling summary and publication gate without granting merge or service authority.".to_string(), }; - put_mind_gateway_review(&runtime_store, &mind_review)?; let mind_commit_id = format!("repo-work-close-{item_slug}-mind-commit"); let mind_commit = mind_state_commit_receipt( mind_commit_id.clone(), @@ -11588,11 +11533,9 @@ fn run_close(args: CloseArgs) -> Result { ], Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true), ); - put_mind_state_commit_receipt(&runtime_store, &mind_commit)?; - let branch = git_output(&workspace, &["branch", "--show-current"])?; - let (repo_map_store_path, repo_map_entry) = record_repo_work_map_admission( - &workspace, + let repo_map_entry = record_repo_work_map_admission( + &runtime_store, &item, &branch, declared_changed_paths.clone(), @@ -11606,6 +11549,8 @@ fn run_close(args: CloseArgs) -> Result { &execute_receipt_path, &closure_review_path, &closure_receipt_path, + &mind_review, + &mind_commit, )?; let runtime_id = string_from_json(&execute_receipt, &["runtimeId"]) .unwrap_or_else(|| "repo-swarm-local".to_string()); @@ -11618,7 +11563,7 @@ fn run_close(args: CloseArgs) -> Result { local_verse_store, &runtime_id, &workspace, - &repo_map_store_path, + &runtime_store, &repo_map_entry, )?; json!({ @@ -11676,8 +11621,8 @@ fn run_close(args: CloseArgs) -> Result { "stateCommitReceiptId": mind_commit.receipt_id, "stateRevision": mind_commit.state_revision, "changedFields": mind_commit.changed_fields, - "repoMapStorePath": normalize_path_for_receipt(&repo_map_store_path), - "repoMapEntry": repo_map_entry, + "repoMapStorePath": normalize_path_for_receipt(&runtime_store), + "repoMapEntry": repo_work_map_entry_json(&repo_map_entry), "repoMapLocalVerseProjection": repo_map_local_verse_projection }, "authority": { @@ -16240,6 +16185,8 @@ mod authority_tests { assert!(!tick.contains("run_close(CloseArgs")); assert!(tick.contains("await-modeling")); assert!(tick.contains("explicit model-authored Modeling finding")); + assert!(!source.contains(&["RepoWork", "MapStore"].concat())); + assert!(!source.contains(&["repo-work-map", ".msgpack"].concat())); } #[test] @@ -16289,7 +16236,60 @@ mod authority_tests { put_repo_work_modeling_finding(&store, &finding)?; assert_eq!( runtime_repo_work_modeling_finding(&store, &finding.receipt_id)?, - Some(finding) + Some(finding.clone()) + ); + + let review = MindGatewayReview { + schema_version: MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), + gateway_id: "mind-review-1".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!["typed Modeling finding reread".to_string()], + contract: "test".to_string(), + }; + let commit = mind_state_commit_receipt( + "mind-commit-1".to_string(), + &review, + 1, + vec!["repoWork.map".to_string()], + "2026-07-12T00:00:02Z".to_string(), + ); + let mut map = RepoWorkMapEntry { + schema_version: REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(), + map_entry_id: "repo-work-map-item-1".to_string(), + admitted_at: "2026-07-12T00:00:02Z".to_string(), + item: finding.item.clone(), + branch: "test".to_string(), + changed_paths: finding.changed_paths.clone(), + commit_sha: finding.commit_sha.clone(), + safe_action_family: "repo.status_section".to_string(), + modeling_summary: "counterfeit".to_string(), + modeling_finding_receipt_id: finding.receipt_id.clone(), + soul_verdict_receipt_id: finding.soul_verdict_receipt_id.clone(), + mind_gateway_review_id: review.gateway_id.clone(), + mind_state_commit_receipt_id: 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, + }; + 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()); + assert!( + epiphany_core::runtime_mind_state_commit_receipt(&store, &commit.receipt_id)?.is_none() + ); + assert!(runtime_repo_work_map_entry(&store, &map.map_entry_id)?.is_none()); + + map.modeling_summary = finding.summary.clone(); + commit_repo_work_map_admission(&store, &map, &review, &commit)?; + assert_eq!( + runtime_repo_work_map_entry(&store, &map.map_entry_id)?, + Some(map) ); Ok(()) } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index b5613981..957b75ae 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -653,8 +653,11 @@ pub use mind_gateway::mind_review_allows_state; pub use mind_gateway::mind_review_reorient_acceptance; pub use mind_gateway::mind_review_role_acceptance; pub use mind_gateway::mind_state_commit_receipt; +pub use modeling_gateway::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION; +pub use modeling_gateway::REPO_WORK_MAP_ENTRY_TYPE; pub use modeling_gateway::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION; pub use modeling_gateway::REPO_WORK_MODELING_FINDING_TYPE; +pub use modeling_gateway::RepoWorkMapEntry; pub use modeling_gateway::RepoWorkModelingFinding; pub use organ_dependencies::EPIPHANY_LAUNCH_ORGAN_CONTRACT_SCHEMA_VERSION; pub use organ_dependencies::EPIPHANY_ORGAN_DEPENDENCY_SCHEMA_VERSION; @@ -766,6 +769,7 @@ pub use runtime_spine::RuntimeSpineJobResultOptions; pub use runtime_spine::RuntimeSpineSessionOptions; pub use runtime_spine::append_runtime_event; pub use runtime_spine::clear_epiphany_job_binding_backend; +pub use runtime_spine::commit_repo_work_map_admission; pub use runtime_spine::complete_runtime_job; pub use runtime_spine::create_runtime_job; pub use runtime_spine::create_runtime_session; @@ -806,6 +810,7 @@ pub use runtime_spine::runtime_latest_hands_receipt_chain_after; pub use runtime_spine::runtime_mind_gateway_review; pub use runtime_spine::runtime_mind_state_commit_receipt; pub use runtime_spine::runtime_reorient_worker_result; +pub use runtime_spine::runtime_repo_work_map_entry; pub use runtime_spine::runtime_repo_work_modeling_finding; pub use runtime_spine::runtime_role_worker_result; pub use runtime_spine::runtime_schema_catalog_response; diff --git a/epiphany-core/src/modeling_gateway.rs b/epiphany-core/src/modeling_gateway.rs index bde5116a..18588d10 100644 --- a/epiphany-core/src/modeling_gateway.rs +++ b/epiphany-core/src/modeling_gateway.rs @@ -3,6 +3,8 @@ use cultcache_rs::DatabaseEntry; pub const REPO_WORK_MODELING_FINDING_TYPE: &str = "epiphany.modeling.repo_work_finding"; pub const REPO_WORK_MODELING_FINDING_SCHEMA_VERSION: &str = "epiphany.modeling.repo_work_finding.v0"; +pub const REPO_WORK_MAP_ENTRY_TYPE: &str = "epiphany.repo_work.map_entry"; +pub const REPO_WORK_MAP_ENTRY_SCHEMA_VERSION: &str = "epiphany.repo_work.map_entry.v0"; #[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)] #[cultcache( @@ -37,3 +39,46 @@ pub struct RepoWorkModelingFinding { #[cultcache(key = 12)] pub contract: String, } + +#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)] +#[cultcache(type = "epiphany.repo_work.map_entry", schema = "RepoWorkMapEntry")] +pub struct RepoWorkMapEntry { + #[cultcache(key = 0)] + pub schema_version: String, + #[cultcache(key = 1)] + pub map_entry_id: String, + #[cultcache(key = 2)] + pub admitted_at: String, + #[cultcache(key = 3)] + pub item: String, + #[cultcache(key = 4)] + pub branch: String, + #[cultcache(key = 5)] + pub changed_paths: Vec, + #[cultcache(key = 6)] + pub commit_sha: String, + #[cultcache(key = 7)] + pub safe_action_family: String, + #[cultcache(key = 8)] + pub modeling_summary: String, + #[cultcache(key = 9)] + pub modeling_finding_receipt_id: String, + #[cultcache(key = 10)] + pub soul_verdict_receipt_id: String, + #[cultcache(key = 11)] + pub mind_gateway_review_id: String, + #[cultcache(key = 12)] + pub mind_state_commit_receipt_id: String, + #[cultcache(key = 13)] + pub execute_receipt_path: String, + #[cultcache(key = 14)] + pub closure_review_path: String, + #[cultcache(key = 15)] + pub closure_receipt_path: String, + #[cultcache(key = 16)] + pub publication_gate: String, + #[cultcache(key = 17)] + pub durable_state_admitted: bool, + #[cultcache(key = 18)] + pub private_state_exposed: bool, +} diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 822ee2c5..dd0e4c1c 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -40,8 +40,11 @@ use crate::mind_gateway::MIND_VERSE_ADOPTION_RECEIPT_SCHEMA_VERSION; use crate::mind_gateway::MIND_VERSE_ADOPTION_RECEIPT_TYPE; use crate::mind_gateway::MindGatewayReview; use crate::mind_gateway::MindStateCommitReceipt; +use crate::modeling_gateway::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION; +use crate::modeling_gateway::REPO_WORK_MAP_ENTRY_TYPE; use crate::modeling_gateway::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION; use crate::modeling_gateway::REPO_WORK_MODELING_FINDING_TYPE; +use crate::modeling_gateway::RepoWorkMapEntry; use crate::modeling_gateway::RepoWorkModelingFinding; use crate::organ_dependencies::EpiphanyLaunchOrganContract; use crate::soul_gateway::SoulVerdictReceipt; @@ -727,6 +730,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef) -> Result { cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; + cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; cache.register_entry_type::()?; @@ -1770,6 +1774,67 @@ pub fn runtime_repo_work_modeling_finding( cache.get::(receipt_id) } +pub fn commit_repo_work_map_admission( + store_path: impl AsRef, + entry: &RepoWorkMapEntry, + mind_review: &MindGatewayReview, + mind_commit: &MindStateCommitReceipt, +) -> Result { + if entry.schema_version != REPO_WORK_MAP_ENTRY_SCHEMA_VERSION { + return Err(anyhow!("unsupported repo-work map entry schema")); + } + validate_non_empty(&entry.map_entry_id, "repo-work map entry id")?; + validate_non_empty(&entry.item, "repo-work map item")?; + validate_non_empty( + &entry.modeling_finding_receipt_id, + "repo-work map Modeling finding receipt id", + )?; + if !entry.durable_state_admitted || entry.private_state_exposed { + return Err(anyhow!( + "repo-work map admission requires admitted, private-state-sealed state" + )); + } + if entry.mind_gateway_review_id != mind_review.gateway_id + || entry.mind_state_commit_receipt_id != mind_commit.receipt_id + || mind_commit.gateway_id != mind_review.gateway_id + { + return Err(anyhow!( + "repo-work map entry and Mind witnesses do not share one identity" + )); + } + let mut cache = runtime_spine_cache(store_path)?; + cache.pull_all_backing_stores()?; + require_identity(&cache)?; + let modeling = cache + .get::(&entry.modeling_finding_receipt_id)? + .ok_or_else(|| anyhow!("repo-work map admission requires typed Modeling finding"))?; + 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 + { + return Err(anyhow!( + "repo-work map entry does not match its typed Modeling finding" + )); + } + let (review_envelope, _) = cache.prepare_entry(&mind_review.gateway_id, mind_review)?; + let (commit_envelope, _) = cache.prepare_entry(&mind_commit.receipt_id, mind_commit)?; + let (map_envelope, _) = cache.prepare_entry(&entry.map_entry_id, entry)?; + cache.put_prepared_batch(vec![review_envelope, commit_envelope, map_envelope])?; + Ok(entry.clone()) +} + +pub fn runtime_repo_work_map_entry( + store_path: impl AsRef, + map_entry_id: &str, +) -> Result> { + validate_non_empty(map_entry_id, "repo-work map entry id")?; + let mut cache = runtime_spine_cache(store_path)?; + cache.pull_all_backing_stores()?; + cache.get::(map_entry_id) +} + pub fn put_continuity_recovery_receipt( store_path: impl AsRef, receipt: &ContinuityRecoveryReceipt, @@ -2371,6 +2436,21 @@ fn epiphany_mutation_contracts() -> Vec { "Schedulers and raw CLI fields cannot substitute for this persisted receipt.", ], ), + mutation_contract( + REPO_WORK_MAP_ENTRY_TYPE, + REPO_WORK_MAP_ENTRY_SCHEMA_VERSION, + vec![ + CultNetDocumentOperation::Snapshot, + CultNetDocumentOperation::ReceiptWatch, + ], + CultNetMutationAuthority::ReadOnly, + vec![], + vec![], + vec![ + "Repo-work map entries are Mind-admitted durable state committed atomically with their Mind witnesses.", + "CultMesh rows are projections of this entry, not a second map owner.", + ], + ), mutation_contract( MIND_THOUGHT_TYPE, MIND_THOUGHT_SCHEMA_VERSION, diff --git a/notes/epiphany-current-algorithmic-map.md b/notes/epiphany-current-algorithmic-map.md index 6de079a7..c4bf44fb 100644 --- a/notes/epiphany-current-algorithmic-map.md +++ b/notes/epiphany-current-algorithmic-map.md @@ -113,6 +113,13 @@ accepted interpretation is persisted as commit, and changed paths. Mind rereads that typed receipt and the admitted repo map plus CultMesh projection carry its receipt ID. +The canonical repo-work map entry is `epiphany.repo_work.map_entry.v0` in the +same runtime CultCache. `commit_repo_work_map_admission` validates it against +the persisted Modeling finding, then publishes the map entry, Mind review, and +Mind commit in one prepared batch. The former bespoke +`.epiphany/state/repo-work-map.msgpack` owner is deleted. CultMesh remains a +projection after admission and cannot repair or override the canonical entry. + Manual edits and programmatic actions converge at the same receipt and Mind admission boundaries. A later action cannot retroactively make an unrecorded consequence valid. diff --git a/notes/epiphany-fork-implementation-plan.md b/notes/epiphany-fork-implementation-plan.md index 261b0109..53e48dd4 100644 --- a/notes/epiphany-fork-implementation-plan.md +++ b/notes/epiphany-fork-implementation-plan.md @@ -118,9 +118,10 @@ Status: active. The scheduler can no longer impersonate Modeling/Mind after Hands execution, and closure refuses deterministic fallback or a passing verdict without an explicit model-authored finding. That finding now persists as a typed runtime document backed by a passing Soul receipt; Mind rereads it, -and repo-map/CultMesh admission carries its receipt ID. The remaining wound is -atomicity: Mind receipts and the custom repo-map MessagePack store still commit -through separate persistence paths. +and repo-map/CultMesh admission carries its receipt ID. Repo-map admission is +now atomic: the typed canonical map entry and both Mind witnesses publish in one +CultCache batch, while CultMesh lowers the committed entry. The custom map +MessagePack owner is deleted. - Prove Hands → Soul → Modeling → Mind → Self on a fresh repository without supervisor implementation or direct worker-thought inspection. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index eab628a2..1f6ef362 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -2021,6 +2021,15 @@ smoke at `.epiphany-smoke/closure-model-typed-rerun/stdout.json` passed explicit Modeling admission and refusal. Next collapse Mind receipts plus repo-map admission into one typed transaction; the custom repo-map MessagePack write is still a second persistence authority. +That second authority is deleted. `RepoWorkMapEntry` is now a registered typed +runtime document. `commit_repo_work_map_admission` verifies its persisted +Modeling dependency and atomically publishes the map, Mind review, and Mind +commit; failed validation leaves all three absent. The old +`repo-work-map.msgpack` structs, reader, writer, and path are gone, guarded by a +source test. CultMesh projects the reread canonical entry. Next inspect crash +and retry semantics across the earlier Soul and Modeling phase receipts versus +the final atomic Mind/map admission; do not add a repair loop to hide partial +phase ownership. ## Immediate Re-entry Instruction diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 4c0834c7301e133bb4defdddd83e55d0e2058c68..4ce0da24140a50e2689ceb24081a462e06fba1fa 100644 GIT binary patch delta 472 zcmXw#ze^lZ5Xaq97crKCULg#mu)2*N!UY8pe{^1o5D2mG9N&(&FZbTQ=X-DOxJtpo zE=@SL^IwQykuG47bQTI}Q{*pkc1?<5ika`{`;=n0;OB0HfR( ztSUToWu9`vp`_897kC2isE4vziKrBW%n<>edL{t-v9HD;vaNdB-gwIa z9RUYmdt~xI!T(z!EYu^5-Y2kM-kikCpS-TV#9p6Cuq^Pw0&|l~feKua2dN3F*bFm8 bKdT?pC7;y}!cl#2Za8Qk#kgKQlZujO2&<}? delta 57 zcmca~RPyRU$qf>W+=k{>28L0`7}(-BZB}M1WMq8UJe8?^Dib3RgJ@?Ngc9 G9O3{uUlK|H diff --git a/state/map.yaml b/state/map.yaml index 4e97d231..803bdf6b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -659,4 +659,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`. Gjallar 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: Unify repo-work map admission under typed CultCache transaction ownership. Mind review/commit, the typed Modeling finding reference, and the durable repo-map entry currently cross separate runtime and custom MessagePack writes; move the map entry into the typed store and make partial admission structurally impossible before preserving its CultMesh projection. + next_action: Audit the remaining repo-work closure orchestration boundary. Soul verdict and Modeling finding are persisted before the atomic Mind/map batch; determine whether closure needs one larger transaction or explicit recoverable phase receipts, then make crash/retry behavior idempotent without adding a reconciliation owner.