Publish state and Mind witness atomically

This commit is contained in:
Meta Vens 2026-07-11 19:47:04 +01:00
commit 5b5d4de5db
5 changed files with 131 additions and 1 deletions

View file

@ -256,6 +256,43 @@ pub fn reorient_acceptance_claimed_effects() -> Vec<EpiphanyReceiptEffectKind> {
]
}
pub fn coordinator_acceptance_cache(store_path: &Path) -> anyhow::Result<CultCache> {
let mut cache = runtime_spine_cache(store_path)?;
cache.register_entry_type::<EpiphanyThreadStateEntry>()?;
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<EpiphanyThreadState> {
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<u64>,
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::<EpiphanyThreadStateEntry>(THREAD_STATE_KEY)?
.state()?
.objective
.as_deref(),
Some("Atomic acceptance")
);
assert_eq!(
cache.get_required::<MindGatewayReview>("mind-review-7")?,
review
);
assert_eq!(
cache.get_required::<MindStateCommitReceipt>("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(())
}
}

View file

@ -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;

View file

@ -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

Binary file not shown.

View file

@ -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.