Validate and order work-loop evidence
This commit is contained in:
parent
d5f6060ce9
commit
c355eb4a90
5 changed files with 134 additions and 3 deletions
|
|
@ -5183,13 +5183,99 @@ pub fn write_epiphany_cultmesh_work_loop_telemetry(
|
|||
store_path: impl AsRef<Path>,
|
||||
telemetry: EpiphanyCultMeshWorkLoopTelemetryEntry,
|
||||
) -> Result<EpiphanyCultMeshWorkLoopTelemetryEntry> {
|
||||
validate_work_loop_telemetry(&telemetry)?;
|
||||
let mut node = open_epiphany_cultmesh_node(&store_path, telemetry.runtime_id.clone())?;
|
||||
let written = node.put(telemetry.telemetry_id.clone(), &telemetry)?;
|
||||
node.put(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY, &written)?;
|
||||
let current_latest = node.get::<EpiphanyCultMeshWorkLoopTelemetryEntry>(
|
||||
EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY,
|
||||
)?;
|
||||
if current_latest.as_ref().is_none_or(|current| {
|
||||
work_loop_telemetry_event_key(&written) >= work_loop_telemetry_event_key(current)
|
||||
}) {
|
||||
node.put(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_LATEST_KEY, &written)?;
|
||||
}
|
||||
node.flush()?;
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
fn validate_work_loop_telemetry(telemetry: &EpiphanyCultMeshWorkLoopTelemetryEntry) -> Result<()> {
|
||||
if telemetry.verse_id != EPIPHANY_CULTMESH_INTERNAL_VERSE_ID {
|
||||
return Err(anyhow!(
|
||||
"work-loop telemetry must remain in the internal Verse"
|
||||
));
|
||||
}
|
||||
for (label, value) in [
|
||||
("schema version", telemetry.schema_version.as_str()),
|
||||
("runtime id", telemetry.runtime_id.as_str()),
|
||||
("telemetry id", telemetry.telemetry_id.as_str()),
|
||||
("source stage", telemetry.source_stage.as_str()),
|
||||
("Hands intent id", telemetry.hands_intent_id.as_str()),
|
||||
("Hands review id", telemetry.hands_review_id.as_str()),
|
||||
(
|
||||
"Hands runtime job id",
|
||||
telemetry.hands_runtime_job_id.as_str(),
|
||||
),
|
||||
(
|
||||
"Substrate Gate grant receipt id",
|
||||
telemetry.substrate_gate_grant_receipt_id.as_str(),
|
||||
),
|
||||
(
|
||||
"Hands patch receipt id",
|
||||
telemetry.hands_patch_receipt_id.as_str(),
|
||||
),
|
||||
(
|
||||
"Hands command receipt id",
|
||||
telemetry.hands_command_receipt_id.as_str(),
|
||||
),
|
||||
(
|
||||
"Hands commit receipt id",
|
||||
telemetry.hands_commit_receipt_id.as_str(),
|
||||
),
|
||||
("command", telemetry.command.as_str()),
|
||||
("commit SHA", telemetry.commit_sha.as_str()),
|
||||
("branch", telemetry.branch.as_str()),
|
||||
] {
|
||||
if value.trim().is_empty() {
|
||||
return Err(anyhow!("work-loop telemetry missing {label}"));
|
||||
}
|
||||
}
|
||||
if telemetry.target_stages.is_empty()
|
||||
|| telemetry
|
||||
.target_stages
|
||||
.iter()
|
||||
.any(|stage| stage.trim().is_empty())
|
||||
|| telemetry.changed_paths.is_empty()
|
||||
|| telemetry
|
||||
.changed_paths
|
||||
.iter()
|
||||
.any(|path| path.trim().is_empty())
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"work-loop telemetry requires nonempty target stages and changed paths"
|
||||
));
|
||||
}
|
||||
let produced_at = DateTime::parse_from_rfc3339(&telemetry.produced_at_utc)
|
||||
.map_err(|error| anyhow!("work-loop telemetry has invalid produced at: {error}"))?;
|
||||
let lower_bound = DateTime::parse_from_rfc3339(&telemetry.lower_bound_receipt_at)
|
||||
.map_err(|error| anyhow!("work-loop telemetry has invalid receipt lower bound: {error}"))?;
|
||||
if lower_bound > produced_at {
|
||||
return Err(anyhow!(
|
||||
"work-loop telemetry receipt lower bound occurs after packet production"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn work_loop_telemetry_event_key(
|
||||
telemetry: &EpiphanyCultMeshWorkLoopTelemetryEntry,
|
||||
) -> (DateTime<FixedOffset>, &str) {
|
||||
(
|
||||
DateTime::parse_from_rfc3339(&telemetry.produced_at_utc)
|
||||
.expect("validated work-loop telemetry timestamp"),
|
||||
telemetry.telemetry_id.as_str(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn load_latest_epiphany_cultmesh_work_loop_telemetry(
|
||||
store_path: impl AsRef<Path>,
|
||||
runtime_id: impl Into<String>,
|
||||
|
|
@ -7923,7 +8009,7 @@ mod tests {
|
|||
produced_at_utc: "2026-06-12T00:00:00Z".to_string(),
|
||||
source_stage: "hands".to_string(),
|
||||
target_stages: vec!["soul".to_string(), "Modeling".to_string()],
|
||||
lower_bound_receipt_at: "2026-06-12T00:00:01Z".to_string(),
|
||||
lower_bound_receipt_at: "2026-06-11T23:59:59Z".to_string(),
|
||||
hands_intent_id: "hands-intent-test".to_string(),
|
||||
hands_review_id: "hands-review-test".to_string(),
|
||||
hands_runtime_job_id: "hands-job-test".to_string(),
|
||||
|
|
@ -7976,6 +8062,35 @@ mod tests {
|
|||
.binding(EPIPHANY_CULTMESH_WORK_LOOP_TELEMETRY_TYPE)
|
||||
.is_some()
|
||||
);
|
||||
|
||||
let mut newer = telemetry.clone();
|
||||
newer.telemetry_id = "work-loop-telemetry-newer".to_string();
|
||||
newer.produced_at_utc = "2026-06-12T01:00:00Z".to_string();
|
||||
write_epiphany_cultmesh_work_loop_telemetry(&store, newer.clone())?;
|
||||
|
||||
let mut delayed = telemetry.clone();
|
||||
delayed.telemetry_id = "work-loop-telemetry-delayed".to_string();
|
||||
delayed.produced_at_utc = "2026-06-11T23:30:00Z".to_string();
|
||||
delayed.lower_bound_receipt_at = "2026-06-11T23:00:00Z".to_string();
|
||||
write_epiphany_cultmesh_work_loop_telemetry(&store, delayed)?;
|
||||
assert_eq!(
|
||||
load_latest_epiphany_cultmesh_work_loop_telemetry(&store, "epiphany-test")?,
|
||||
Some(newer)
|
||||
);
|
||||
|
||||
let mut future_bound = telemetry.clone();
|
||||
future_bound.telemetry_id = "work-loop-telemetry-future-bound".to_string();
|
||||
future_bound.lower_bound_receipt_at = "2026-06-12T00:00:01Z".to_string();
|
||||
let err = write_epiphany_cultmesh_work_loop_telemetry(&store, future_bound)
|
||||
.expect_err("future receipt lower bound must be refused");
|
||||
assert!(err.to_string().contains("after packet production"));
|
||||
|
||||
let mut wrong_verse = telemetry;
|
||||
wrong_verse.telemetry_id = "work-loop-telemetry-wrong-verse".to_string();
|
||||
wrong_verse.verse_id = EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string();
|
||||
let err = write_epiphany_cultmesh_work_loop_telemetry(&store, wrong_verse)
|
||||
.expect_err("work-loop evidence outside internal Verse must be refused");
|
||||
assert!(err.to_string().contains("internal Verse"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -549,3 +549,16 @@ operator/Self discovery even though runtime-spine remains the lifecycle owner.
|
|||
Coordinator mirrors now require a valid RFC3339 creation time and advance
|
||||
`latest` only by `(creation time, receipt ID)`. Delayed runs remain immutable
|
||||
history without becoming the current outcome.
|
||||
|
||||
## Unvalidated work-loop packet presented as current evidence
|
||||
|
||||
Internal work-loop telemetry feeds Soul and Modeling with the Hands
|
||||
intent/review/grant/patch/command/commit consequence chain, but its writer had
|
||||
no validation and used arrival order for `latest`. An arbitrary or delayed
|
||||
packet could therefore become the selected verification body. Telemetry now
|
||||
must remain in the internal Verse, carry the complete named Hands chain plus
|
||||
nonempty command/commit/branch/path/stage evidence, and use valid RFC3339
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -140,6 +140,9 @@ The confirmed conceptual substitutions have been cut:
|
|||
supersession readbacks cannot rewind Self/operator coordination context.
|
||||
- `coordinator-run-receipt/latest` is creation-time-owned. Delayed runs cannot
|
||||
replace the current final action or artifact projection.
|
||||
- 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.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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, and coordinator-run latest mirrors are validated event-time projections rather than arrival-owned state. Continue auditing other 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; 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.
|
||||
|
|
|
|||
Reference in a new issue