From c300b4ca912edbdafb72d21410b7cfe818f036b8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 13 Jul 2026 00:43:27 +0100 Subject: [PATCH] Order repo work maps by Mind admission --- epiphany-core/src/cultmesh_integration.rs | 82 +++++++++++++++++- ...onceptual-substitution-audit-2026-07-12.md | 10 +++ notes/fresh-workspace-handoff.md | 2 + state/ledgers.msgpack | Bin 452089 -> 452413 bytes state/map.yaml | 2 +- 5 files changed, 94 insertions(+), 2 deletions(-) diff --git a/epiphany-core/src/cultmesh_integration.rs b/epiphany-core/src/cultmesh_integration.rs index 240a5108..7bd8bf39 100644 --- a/epiphany-core/src/cultmesh_integration.rs +++ b/epiphany-core/src/cultmesh_integration.rs @@ -5527,7 +5527,14 @@ pub fn write_epiphany_cultmesh_repo_work_map_entry( validate_repo_work_map_entry(&map_entry)?; let mut node = open_epiphany_cultmesh_node(&store_path, map_entry.runtime_id.clone())?; let written = node.put(map_entry.map_entry_id.clone(), &map_entry)?; - node.put(EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY, &written)?; + let current_latest = node.get::( + EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY, + )?; + if current_latest.as_ref().is_none_or(|current| { + repo_work_map_admission_key(&written) >= repo_work_map_admission_key(current) + }) { + node.put(EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY, &written)?; + } node.flush()?; Ok(written) } @@ -5711,6 +5718,15 @@ fn validate_repo_work_map_entry(entry: &EpiphanyCultMeshRepoWorkMapEntry) -> Res "repo work map entry projection requires admitted durable state" )); } + let admitted_at = DateTime::parse_from_rfc3339(&entry.admitted_at) + .map_err(|error| anyhow!("repo work map entry has invalid admitted_at: {error}"))?; + let mirrored_at = DateTime::parse_from_rfc3339(&entry.mirrored_at) + .map_err(|error| anyhow!("repo work map entry has invalid mirrored_at: {error}"))?; + if mirrored_at < admitted_at { + return Err(anyhow!( + "repo work map entry was mirrored before Mind admission" + )); + } if entry.tui_rows.is_empty() { return Err(anyhow!("repo work map entry requires compact TUI rows")); } @@ -5726,6 +5742,16 @@ fn validate_repo_work_map_entry(entry: &EpiphanyCultMeshRepoWorkMapEntry) -> Res Ok(()) } +fn repo_work_map_admission_key( + entry: &EpiphanyCultMeshRepoWorkMapEntry, +) -> (DateTime, &str) { + ( + DateTime::parse_from_rfc3339(&entry.admitted_at) + .expect("validated repo work map admission timestamp"), + entry.map_entry_id.as_str(), + ) +} + fn validate_repo_work_public_proof(proof: &EpiphanyCultMeshRepoWorkPublicProofEntry) -> Result<()> { if proof.private_state_exposed { return Err(anyhow!( @@ -7374,6 +7400,60 @@ mod tests { Ok(()) } + #[test] + fn repo_work_map_latest_follows_mind_admission_not_mirror_arrival() -> Result<()> { + let temp = tempfile::tempdir()?; + let store = temp.path().join("repo-work-map-order.ccmp"); + let older = EpiphanyCultMeshRepoWorkMapEntry { + schema_version: EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(), + runtime_id: "repo-work-test".to_string(), + verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(), + map_entry_id: "repo-work-map-older".to_string(), + admitted_at: "2026-07-13T01:00:00Z".to_string(), + mirrored_at: "2026-07-13T01:00:01Z".to_string(), + workspace: "E:/Projects/test".to_string(), + item: "test-item".to_string(), + branch: "main".to_string(), + changed_paths: vec!["src/lib.rs".to_string()], + commit_sha: "older".to_string(), + safe_action_family: "planning-note".to_string(), + modeling_summary: "Older admitted map.".to_string(), + soul_verdict_receipt_id: "soul-older".to_string(), + mind_gateway_review_id: "mind-review-older".to_string(), + mind_state_commit_receipt_id: "mind-commit-older".to_string(), + publication_gate: "bifrost".to_string(), + durable_state_admitted: true, + source_store_path: "state/runtime.cc".to_string(), + tui_rows: vec!["MAP test-item older".to_string()], + private_state_exposed: false, + notes: Vec::new(), + modeling_finding_receipt_id: "modeling-finding-older".to_string(), + modeling_route_id: "modeling-route-older".to_string(), + modeling_generation: 1, + }; + let mut newer = older.clone(); + newer.map_entry_id = "repo-work-map-newer".to_string(); + newer.admitted_at = "2026-07-13T02:00:00Z".to_string(); + newer.mirrored_at = "2026-07-13T02:00:01Z".to_string(); + newer.commit_sha = "newer".to_string(); + newer.modeling_generation = 2; + + write_epiphany_cultmesh_repo_work_map_entry(&store, newer.clone())?; + write_epiphany_cultmesh_repo_work_map_entry(&store, older.clone())?; + assert_eq!( + load_latest_epiphany_cultmesh_repo_work_map_entry(&store, "repo-work-test")?, + Some(newer) + ); + + let mut impossible = older; + impossible.map_entry_id = "repo-work-map-impossible".to_string(); + impossible.mirrored_at = "2026-07-13T00:59:59Z".to_string(); + let err = write_epiphany_cultmesh_repo_work_map_entry(&store, impossible) + .expect_err("map projection before Mind admission must be refused"); + assert!(err.to_string().contains("before Mind admission")); + Ok(()) + } + #[test] fn scheduler_latest_mirror_refuses_delayed_replay() -> Result<()> { let temp = tempfile::tempdir()?; diff --git a/notes/conceptual-substitution-audit-2026-07-12.md b/notes/conceptual-substitution-audit-2026-07-12.md index b3c5df4e..d1498f1d 100644 --- a/notes/conceptual-substitution-audit-2026-07-12.md +++ b/notes/conceptual-substitution-audit-2026-07-12.md @@ -562,3 +562,13 @@ production/lower-bound times with the accepted-verification lower bound no later than packet production. `latest` advances by `(production time, telemetry ID)`. The old fixture's future lower bound was corrected rather than blessed as prophecy. + +## Mirror arrival presented as latest Mind-admitted repo map + +The repo-work map is a projection of Mind-admitted durable state and drives +queue visibility, but its `latest` mirror was overwritten by arrival order and +its admission/mirror timestamps were unchecked strings. A delayed projection +of an older admission could therefore become the queue's current map. Map +entries now require valid RFC3339 admission/mirror times, reject projection +before Mind admission, and advance `latest` by `(admission time, map entry ID)`. +Mirror latency is metadata; it does not own state progression. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 14660d36..304f2ebc 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -143,6 +143,8 @@ The confirmed conceptual substitutions have been cut: - Work-loop telemetry is now validated internal evidence and production-time ordered. Delayed or wrong-Verse packets cannot replace Soul/Modeling's current Hands consequence chain; future receipt lower bounds are refused. +- Repo-work map `latest` is Mind-admission-time-owned. Delayed older projections + cannot rewind the queue map, and mirroring before admission is refused. The presentation boundary is now plain: `swarm overview` is a generic compact read-only projection. Gjallar is a downstream TUI application on Nightwing and is not an Epiphany organ, provider, owner, runtime, or architectural dependency. Eve/CultUI graphs may be lowered or composited downstream without Epiphany caring which presentation client does it. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 502490ae63951b4a49f2f920175c698a71e747b2..dc54b25670a89314bc117b94de953253c889f29b 100644 GIT binary patch delta 296 zcmX|*u}TCn7=+ELX>2U6P}kxYTUXJX2igkPU1Mn%FaJq&H`z?$F_ykMd!A8Nt z%GO5k0c;c&do^FyKo8O(5UmyMs~zYvZ7$#( zCzi7R8fZ_KCY7IK(kM`v%NtZ+bA^sRZk8U#(ij_vtLYp}E36QFpy_zq@^v?Ngc9 HQXT^UNMaKo diff --git a/state/map.yaml b/state/map.yaml index 6a4bf345..58323833 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 modeling pass beyond receipt writers. Publication/closure/Hands authority is single-sourced; Idunn lifecycle, scheduler, Hands gate, role-review, coordinator-run, and internal work-loop latest mirrors are validated event-time projections rather than arrival-owned state. Continue auditing other evidence-, security-, or coordination-relevant latest mirrors, service configuration claims, adapters, and destructive path consumers for borrowed authority. + next_action: Continue the conceptual-substitution modeling pass beyond receipt writers. Publication/closure/Hands authority is single-sourced; operational/evidence latest mirrors are validated event-time projections; repo-work map latest is owned by Mind admission time rather than mirror arrival. Continue auditing repo-work overview/readiness projections, other evidence/security mirrors, service configuration claims, adapters, and destructive path consumers for borrowed authority.