From 5b5d4de5db4ec9a78dd62dec8b42b3724d2894bd Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 11 Jul 2026 19:47:04 +0100 Subject: [PATCH] Publish state and Mind witness atomically --- epiphany-core/src/coordinator_acceptance.rs | 119 ++++++++++++++++++++ epiphany-core/src/lib.rs | 2 + notes/fresh-workspace-handoff.md | 9 ++ state/ledgers.msgpack | Bin 401583 -> 401866 bytes state/map.yaml | 2 +- 5 files changed, 131 insertions(+), 1 deletion(-) diff --git a/epiphany-core/src/coordinator_acceptance.rs b/epiphany-core/src/coordinator_acceptance.rs index 80b17838..67583725 100644 --- a/epiphany-core/src/coordinator_acceptance.rs +++ b/epiphany-core/src/coordinator_acceptance.rs @@ -256,6 +256,43 @@ pub fn reorient_acceptance_claimed_effects() -> Vec { ] } +pub fn coordinator_acceptance_cache(store_path: &Path) -> anyhow::Result { + let mut cache = runtime_spine_cache(store_path)?; + cache.register_entry_type::()?; + cache.pull_all_backing_stores()?; + Ok(cache) +} + +pub fn commit_state_with_mind_witness( + store_path: &Path, + thread_id: &str, + state: &EpiphanyThreadState, + mind_review: &MindGatewayReview, + commit_receipt: &MindStateCommitReceipt, +) -> anyhow::Result { + if commit_receipt.gateway_id != mind_review.gateway_id { + return Err(anyhow::anyhow!( + "Mind commit receipt gateway {:?} does not match review {:?}", + commit_receipt.gateway_id, + mind_review.gateway_id + )); + } + if commit_receipt.state_revision != state.revision { + return Err(anyhow::anyhow!( + "Mind commit receipt revision {} does not match state revision {}", + commit_receipt.state_revision, + state.revision + )); + } + let mut cache = coordinator_acceptance_cache(store_path)?; + let state_entry = EpiphanyThreadStateEntry::from_state(thread_id, state)?; + let (state_envelope, _) = cache.prepare_entry(THREAD_STATE_KEY, &state_entry)?; + let (review_envelope, _) = cache.prepare_entry(&mind_review.gateway_id, mind_review)?; + let (commit_envelope, _) = cache.prepare_entry(&commit_receipt.receipt_id, commit_receipt)?; + cache.put_prepared_batch(vec![state_envelope, review_envelope, commit_envelope])?; + Ok(state.clone()) +} + pub fn build_native_role_acceptance_update( expected_revision: Option, role_id: EpiphanyRoleResultRoleId, @@ -464,4 +501,86 @@ mod tests { ) ); } + + #[test] + fn state_and_mind_witness_publish_in_one_acceptance_snapshot() -> anyhow::Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("acceptance.cc"); + let state = EpiphanyThreadState { + revision: 7, + objective: Some("Atomic acceptance".to_string()), + ..Default::default() + }; + let review = MindGatewayReview { + schema_version: MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), + gateway_id: "mind-review-7".to_string(), + source_kind: "role".to_string(), + source_role_id: "modeling".to_string(), + decision: MindGatewayDecision::Accept, + allowed_effects: vec!["state".to_string()], + refused_effects: Vec::new(), + reasons: Vec::new(), + contract: "test".to_string(), + }; + let receipt = mind_state_commit_receipt( + "mind-commit-7".to_string(), + &review, + 7, + vec!["Objective".to_string()], + "2026-07-11T00:00:00Z".to_string(), + ); + commit_state_with_mind_witness(&store, "thread-7", &state, &review, &receipt)?; + + let cache = coordinator_acceptance_cache(&store)?; + assert_eq!( + cache + .get_required::(THREAD_STATE_KEY)? + .state()? + .objective + .as_deref(), + Some("Atomic acceptance") + ); + assert_eq!( + cache.get_required::("mind-review-7")?, + review + ); + assert_eq!( + cache.get_required::("mind-commit-7")?, + receipt + ); + Ok(()) + } + + #[test] + fn invalid_witness_cannot_publish_state() -> anyhow::Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("acceptance.cc"); + let state = EpiphanyThreadState { + revision: 3, + ..Default::default() + }; + let review = MindGatewayReview { + schema_version: MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(), + gateway_id: "review-3".to_string(), + source_kind: "role".to_string(), + source_role_id: "modeling".to_string(), + decision: MindGatewayDecision::Accept, + allowed_effects: Vec::new(), + refused_effects: Vec::new(), + reasons: Vec::new(), + contract: "test".to_string(), + }; + let receipt = mind_state_commit_receipt( + "commit-4".to_string(), + &review, + 4, + Vec::new(), + "2026-07-11T00:00:00Z".to_string(), + ); + assert!( + commit_state_with_mind_witness(&store, "thread-3", &state, &review, &receipt).is_err() + ); + assert!(!store.exists()); + Ok(()) + } } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 8819c0f6..c5c48e8c 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -128,8 +128,10 @@ pub use coordinator_acceptance::EpiphanyRoleAcceptanceUpdate; pub use coordinator_acceptance::acceptance_launch_contract_for_binding; pub use coordinator_acceptance::build_native_reorient_acceptance_update; pub use coordinator_acceptance::build_native_role_acceptance_update; +pub use coordinator_acceptance::commit_state_with_mind_witness; pub use coordinator_acceptance::completed_reorient_finding; pub use coordinator_acceptance::completed_role_finding; +pub use coordinator_acceptance::coordinator_acceptance_cache; pub use coordinator_acceptance::enforce_acceptance_receipt_proofs; pub use coordinator_acceptance::load_launch_organ_contract; pub use coordinator_acceptance::reorient_acceptance_claimed_effects; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 2f98e95e..11d7da68 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -728,6 +728,15 @@ Epiphany acceptance must register thread state plus Mind/prerequisite receipt families on one authoritative store and commit them through this batch before the bridge persistence sequence can be deleted. +The first unified acceptance store is now executable. +`coordinator_acceptance_cache` registers the full runtime-spine catalog plus +`EpiphanyThreadStateEntry` before pulling, and +`commit_state_with_mind_witness` prepares state, Mind review, and Mind commit +receipt then publishes them in one snapshot. Reload proves the complete triad; +a mismatched revision fails before a store is created. Add Eyes/Substrate Gate, +Soul, and Continuity prerequisite receipts to the same prepared batch next, +then replace bridge acceptance persistence. + Bridge identity correction from 2026-06-22: Epiphany owns swarm execution, repo Body work, branch-local lanes, memory, evidence, and Persona cognition. Bifrost owns GameCult identity, governed crossings into GitHub/Discord/Reddit diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index ee92f92b72822cd016692d748aea58e937272c8c..ae58dbf0de9cd1a1c4f723975eaf8461ea4b7fe5 100644 GIT binary patch delta 305 zcmXX=u}T9`5cHy^uoR1^5Eg8ckPE>`#45FoXp?U9ZqF>-y?4IdOG*n1KR^##J4*!% z(M|*l|G;n1kMJc}%MC?YgQ(0gJyH zuokfXQq}4^&CT1_Ubna3?he{S7N`-3|iN4rPgzh{{~RBFL7+a$PVO!F3C;7h@{JZFVDt0fU& z3(gW0o(lA#d{kySTDFSCLZ(hTa6*~GBzW8`q^oC44k2gBQNz6CKdUK_B4+{$ MVsVWpRCc!W2ekrhdjJ3c delta 56 zcmX?gSYrJ_i4BsBTt-&LMp4HY*yMXQD>D`{GVW}i%G5rUi4llFG&2yh05R+KsZ4BA FasUlT5b^*3 diff --git a/state/map.yaml b/state/map.yaml index 57ff076b..c6f4a735 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: Complete the co-located acceptance transaction specified in `notes/native-coordinator-liberation-map.md`. CultCache now supports validated heterogeneous single-store batch publication. Build one acceptance store registering thread state plus Mind/prerequisite/commit receipt families, publish accepted state and witnesses through one prepared batch, and inject failures to prove no unwitnessed state becomes authoritative. Then delegate bridge acceptance, extract launch, and remove `thread/epiphany/*` JSON-RPC from `epiphany-mvp-coordinator`. + next_action: Finish the co-located acceptance transaction specified in `notes/native-coordinator-liberation-map.md`. State, Mind review, and Mind commit receipt now publish in one unified runtime-spine snapshot with mismatch refusal. Add role-specific Eyes/Substrate Gate, Soul, and Continuity prerequisite receipts to that prepared batch, inject batch-write failure, then delegate bridge role/reorient acceptance and remove the old cross-store sequence.