Move heartbeat service lifecycle under Idunn
This commit is contained in:
parent
bbd3f735b0
commit
68c47b7ffa
7 changed files with 91 additions and 107 deletions
|
|
@ -2,6 +2,7 @@ use anyhow::Context;
|
|||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use epiphany_core::GhostlightSceneParticipantSeed;
|
||||
use epiphany_core::EpiphanyCultMeshSwarmBrakeEntry;
|
||||
use epiphany_core::HeartbeatCompleteOptions;
|
||||
use epiphany_core::HeartbeatHeatUpdateOptions;
|
||||
use epiphany_core::HeartbeatPumpOptions;
|
||||
|
|
@ -411,13 +412,38 @@ fn main() -> Result<()> {
|
|||
)
|
||||
})?;
|
||||
let mut completed_iterations = 0_u64;
|
||||
let mut completed_routines = 0_u64;
|
||||
let mut refused_pulses = 0_u64;
|
||||
loop {
|
||||
if max_iterations > 0 && completed_iterations >= max_iterations {
|
||||
break;
|
||||
}
|
||||
assert_swarm_brake_allows_heartbeat(&local_verse_store, "serve")?;
|
||||
let iteration = completed_iterations + 1;
|
||||
let iteration_dir = artifact_dir.join(format!("pulse-{iteration:06}"));
|
||||
if let Some(brake) = active_swarm_brake(&local_verse_store)? {
|
||||
completed_iterations = iteration;
|
||||
refused_pulses += 1;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
"schemaVersion": "epiphany.heartbeat.serve_pulse.v0",
|
||||
"status": "refused-by-swarm-brake",
|
||||
"owner": "heartbeat",
|
||||
"lifecycleOwner": "Idunn",
|
||||
"iteration": iteration,
|
||||
"artifactDir": iteration_dir,
|
||||
"brakeId": brake.brake_id,
|
||||
"brakeScope": brake.scope,
|
||||
"reason": brake.reason,
|
||||
"privateStateExposed": false
|
||||
})
|
||||
);
|
||||
if max_iterations > 0 && completed_iterations >= max_iterations {
|
||||
break;
|
||||
}
|
||||
thread::sleep(Duration::from_secs(interval_seconds));
|
||||
continue;
|
||||
}
|
||||
let result = run_void_routine_store(
|
||||
&store_path,
|
||||
&iteration_dir,
|
||||
|
|
@ -428,6 +454,7 @@ fn main() -> Result<()> {
|
|||
},
|
||||
)?;
|
||||
completed_iterations = iteration;
|
||||
completed_routines += 1;
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::json!({
|
||||
|
|
@ -458,6 +485,8 @@ fn main() -> Result<()> {
|
|||
"artifactDir": artifact_dir,
|
||||
"intervalSeconds": interval_seconds,
|
||||
"completedIterations": completed_iterations,
|
||||
"completedRoutines": completed_routines,
|
||||
"refusedPulses": refused_pulses,
|
||||
"bounded": max_iterations > 0,
|
||||
"privateStateExposed": false
|
||||
})
|
||||
|
|
@ -488,26 +517,26 @@ fn next_value(args: &mut impl Iterator<Item = String>, name: &str) -> Result<Str
|
|||
}
|
||||
|
||||
fn usage() -> Result<()> {
|
||||
Err(anyhow!(
|
||||
"usage: epiphany-heartbeat-store init --store <path> [--profile epiphany|ghostlight-scene] [--scene-id <id>] [--scene-participant <id|name|speed|reaction|threshold|constraint;constraint>]\n epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [--local-verse-store <path>] [--coordinator-action <action>] [--agent-store <path> --apply-rumination] [--defer-completion]\n epiphany-heartbeat-store pump --store <path> --artifact-dir <path> [--local-verse-store <path>] [--agent-store <path>] [--urgency <0..1>] [--min-heartbeat-rate <n>] [--max-heartbeat-rate <n>] [--min-concurrency <n>] [--max-concurrency <n>] [--max-ticks <n>]\n epiphany-heartbeat-store heat --store <path> [--local-verse-store <path>] [--scope global|all|agent|role|arena|participant_kind|group] [--selector <id>] [--multiplier <n>] [--id <id>] [--label <text>] [--reason <text>] [--expires-after <scene-clock-delta>] [--clear]\n epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n epiphany-heartbeat-store repair-stale --store <path> --artifact-dir <path> [--max-age-seconds <n>] [--reason <text>] [--now-utc <rfc3339>]\n epiphany-heartbeat-store queue-mention --store <path> [--local-verse-store <path>] [--role Persona] --channel-id <id> --message-id <id> --author-id <id> --content <text> --visible-prompt <text> [--author-name <name>] [--reply-to-message-id <id>] [--source-surface <name>]\n epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n epiphany-heartbeat-store routine --store <path> --artifact-dir <path> [--local-verse-store <path>] [--agent-store <path>] [--source <source>] [--no-dream]\n epiphany-heartbeat-store smoke [--agent-store <path>]"
|
||||
))
|
||||
Err(anyhow!(concat!(
|
||||
"usage: epiphany-heartbeat-store init --store <path> [--profile epiphany|ghostlight-scene] [--scene-id <id>] [--scene-participant <seed>]\n",
|
||||
" epiphany-heartbeat-store tick --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store pump --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store heat --store <path> [options]\n",
|
||||
" epiphany-heartbeat-store complete --store <path> --artifact-dir <path> --role <role> [--action-id <id>]\n",
|
||||
" epiphany-heartbeat-store repair-stale --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store queue-mention --store <path> [options]\n",
|
||||
" epiphany-heartbeat-store status --store <path> [--artifact-dir <path>]\n",
|
||||
" epiphany-heartbeat-store routine --store <path> --artifact-dir <path> [options]\n",
|
||||
" epiphany-heartbeat-store serve --store <path> --artifact-dir <path> [--local-verse-store <path>] [--agent-store <path>] [--source <source>] [--no-dream] [--interval-seconds <n>] [--max-iterations <n>]\n",
|
||||
" epiphany-heartbeat-store smoke [--agent-store <path>]"
|
||||
)))
|
||||
}
|
||||
|
||||
fn assert_swarm_brake_allows_heartbeat(
|
||||
local_verse_store: &Option<PathBuf>,
|
||||
command: &str,
|
||||
) -> Result<()> {
|
||||
let Some(local_verse_store) = local_verse_store else {
|
||||
return Ok(());
|
||||
};
|
||||
if !local_verse_store.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
let Some(brake) = load_epiphany_cultmesh_swarm_brake(local_verse_store, "epiphany-local")?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
if brake.status == "engaged" {
|
||||
if let Some(brake) = active_swarm_brake(local_verse_store)? {
|
||||
anyhow::bail!(
|
||||
"epiphany-heartbeat-store {command} refusing to run: local Verse swarm brake engaged; scope={}; protected={}; affected={}; reason={}",
|
||||
brake.scope,
|
||||
|
|
@ -519,6 +548,22 @@ fn assert_swarm_brake_allows_heartbeat(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn active_swarm_brake(
|
||||
local_verse_store: &Option<PathBuf>,
|
||||
) -> Result<Option<EpiphanyCultMeshSwarmBrakeEntry>> {
|
||||
let Some(local_verse_store) = local_verse_store else {
|
||||
return Ok(None);
|
||||
};
|
||||
if !local_verse_store.exists() {
|
||||
return Ok(None);
|
||||
}
|
||||
Ok(load_epiphany_cultmesh_swarm_brake(
|
||||
local_verse_store,
|
||||
"epiphany-local",
|
||||
)?
|
||||
.filter(|brake| brake.status == "engaged"))
|
||||
}
|
||||
|
||||
fn parse_scene_participant(raw: &str) -> Result<GhostlightSceneParticipantSeed> {
|
||||
let parts = raw.split('|').collect::<Vec<_>>();
|
||||
if parts.len() != 6 {
|
||||
|
|
|
|||
|
|
@ -355,6 +355,13 @@ artifact identity and success, supports bounded clean shutdown through
|
|||
Heartbeat owns pulse timing; the next cut is to launch this binary through
|
||||
Idunn and prove restart/resume, swarm-brake observability, and lifecycle
|
||||
readback before demoting the PowerShell rumination vigil.
|
||||
That cut is now proven. An engaged brake produced two compact refused pulses
|
||||
without terminating `serve`; releasing it let the same persisted store complete
|
||||
a routine. Idunn then launched two pulses and a separate one-pulse restart from
|
||||
that store with empty stderr and lifecycle receipts. The attached PowerShell
|
||||
vigil is deleted. The remaining service boundary is durable Idunn policy and
|
||||
operator readback: advertise/configure the heartbeat service through typed
|
||||
daemon state so restart intent survives beyond one explicit `service-launch`.
|
||||
|
||||
This map must change when ownership changes. Historical scars belong in git,
|
||||
evidence, or an explicitly archived note—not in the machine's proprioception.
|
||||
|
|
|
|||
|
|
@ -2190,6 +2190,18 @@ completed two one-second pulses and stopped cleanly. Next launch the native
|
|||
serve loop through Idunn, prove persisted-state restart without duplicate
|
||||
pending turns, and make an engaged swarm brake observable without killing the
|
||||
service.
|
||||
That service proof is complete. Brake/resume smoke root
|
||||
`C:\Users\Meta\AppData\Local\Temp\epiphany-heartbeat-brake-4426a98f9c8e457784741fac5300d56c`
|
||||
recorded two `refused-by-swarm-brake` pulses, clean closure with zero routines,
|
||||
then one successful routine after release on the same store. Idunn launched
|
||||
service `idunn-epiphany-heartbeat` for two routines and
|
||||
`idunn-epiphany-heartbeat-restart` for a separate persisted-state restart; both
|
||||
had empty stderr and compact clean closure receipts. Lifecycle receipt ids are
|
||||
`daemon-service-lifecycle-receipt-idunn-epiphany-heartbeat-launch` and
|
||||
`daemon-service-lifecycle-receipt-idunn-epiphany-heartbeat-restart-launch`.
|
||||
The old `tools/epiphany_ruminate_until.ps1` attached loop is deleted. Next give
|
||||
Idunn a durable typed heartbeat service policy/readback so restart intent and
|
||||
current pulse status survive beyond an explicit operator `service-launch`.
|
||||
|
||||
## Immediate Re-entry Instruction
|
||||
|
||||
|
|
|
|||
|
|
@ -92,16 +92,18 @@ The first native loop is landed as `epiphany-heartbeat-store serve`. It reuses
|
|||
the existing routine state owner, writes per-pulse artifact directories, emits
|
||||
compact sealed pulse/closure receipts, refuses a zero interval, and supports
|
||||
bounded clean shutdown for verification. It does not spawn or own child
|
||||
lifecycle. `tools/epiphany_ruminate_until.ps1` still owns the old attached
|
||||
operator vigil and must be demoted after Idunn proves the native service path.
|
||||
lifecycle. The old attached PowerShell rumination vigil has been deleted; it no
|
||||
longer owns timing, loop survival, or cycle status.
|
||||
|
||||
### Intended change
|
||||
|
||||
Launch the native `serve` loop through the existing Idunn service lifecycle
|
||||
path. The heartbeat binary owns
|
||||
pulse timing and typed heartbeat receipts. Idunn owns child survival, restart,
|
||||
stdout/stderr artifacts, and lifecycle receipts. Self remains only the routing
|
||||
organ consuming heartbeat pressure.
|
||||
The bounded Idunn launch boundary is proven: the native loop survives brake
|
||||
refusals, resumes from the same persisted store, and can be launched again by
|
||||
Idunn without duplicate pending turns. The heartbeat binary owns pulse timing
|
||||
and typed heartbeat receipts. Idunn owns child launch, stdout/stderr artifacts,
|
||||
and lifecycle receipts. Self remains only the routing organ consuming heartbeat
|
||||
pressure. The remaining step is durable Idunn restart policy and compact
|
||||
operator readback for the heartbeat service, not another explicit launch smoke.
|
||||
|
||||
### Owner
|
||||
|
||||
|
|
@ -142,9 +144,8 @@ daemon is orchestration around those owners, not a second scheduler.
|
|||
|
||||
### Cut line
|
||||
|
||||
Demote `tools/epiphany_ruminate_until.ps1` to a historical/operator probe after
|
||||
the native loop and Idunn launch proof exist. Do not preserve its timing,
|
||||
status, or cycle-directory conventions as runtime authority.
|
||||
The attached PowerShell rumination vigil is deleted. Do not preserve its
|
||||
timing, status, or cycle-directory conventions as runtime authority.
|
||||
|
||||
### Verification
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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 native heartbeat service boundary selected by the refreshed Perfect Machine audit. Launch `epiphany-heartbeat-store serve` through Idunn, prove its lifecycle receipt and persisted-state restart without duplicate pending turns, keep an engaged swarm brake observable instead of terminating the service, then demote the attached PowerShell rumination vigil from runtime authority.
|
||||
next_action: Give Idunn durable typed ownership of the native heartbeat service beyond one explicit `service-launch`. Publish/configure the heartbeat serve command through existing daemon restart policy and operator readback surfaces, expose last pulse/brake/clean-stop state without opening routine payloads, and prove Idunn can reconcile/restart it from persisted heartbeat state without duplicate pending turns.
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
param(
|
||||
[string]$Until = "19:00",
|
||||
[string]$Root = (Resolve-Path ".").Path,
|
||||
[int]$IntervalSeconds = 120
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
Set-Location -LiteralPath $Root
|
||||
|
||||
$now = Get-Date
|
||||
$target = [datetime]::ParseExact($Until, "HH:mm", $null)
|
||||
$target = Get-Date -Year $now.Year -Month $now.Month -Day $now.Day -Hour $target.Hour -Minute $target.Minute -Second 0
|
||||
if ($target -le $now) {
|
||||
$target = $target.AddDays(1)
|
||||
}
|
||||
|
||||
$runId = "perfect-machine-" + $now.ToString("yyyyMMdd-HHmmss")
|
||||
$artifactDir = Join-Path $Root ".epiphany-rumination\$runId"
|
||||
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
||||
|
||||
$logPath = Join-Path $artifactDir "rumination.log"
|
||||
$statusPath = Join-Path $artifactDir "status.json"
|
||||
$summaryPath = Join-Path $artifactDir "summary.md"
|
||||
|
||||
$env:CARGO_TARGET_DIR = "C:\Users\Meta\.cargo-target-codex"
|
||||
|
||||
function Write-Log([string]$Message) {
|
||||
$line = "$(Get-Date -Format o) $Message"
|
||||
Add-Content -LiteralPath $logPath -Value $line
|
||||
}
|
||||
|
||||
Write-Log "Starting Perfect Machine rumination until $($target.ToString("o"))."
|
||||
|
||||
$cycles = 0
|
||||
$failures = 0
|
||||
|
||||
while ((Get-Date) -lt $target) {
|
||||
$cycles += 1
|
||||
Write-Log "Cycle ${cycles}: heartbeat routine."
|
||||
$cycleArtifactDir = Join-Path $artifactDir ("cycle-{0:D3}" -f $cycles)
|
||||
New-Item -ItemType Directory -Force -Path $cycleArtifactDir | Out-Null
|
||||
|
||||
& cargo run --manifest-path ".\epiphany-core\Cargo.toml" --bin epiphany-heartbeat-store -- routine --store ".\state\agent-heartbeats.msgpack" --artifact-dir $cycleArtifactDir --agent-store ".\state\agents.msgpack" --source "epiphany/perfect-machine-rumination" *> (Join-Path $cycleArtifactDir "routine.out")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$failures += 1
|
||||
Write-Log "Cycle ${cycles}: routine failed with exit code $LASTEXITCODE."
|
||||
} else {
|
||||
Write-Log "Cycle ${cycles}: routine completed."
|
||||
}
|
||||
|
||||
& cargo run --manifest-path ".\epiphany-core\Cargo.toml" --bin epiphany-heartbeat-store -- status --store ".\state\agent-heartbeats.msgpack" *> $statusPath
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$failures += 1
|
||||
Write-Log "Cycle ${cycles}: status failed with exit code $LASTEXITCODE."
|
||||
}
|
||||
|
||||
$remaining = ($target - (Get-Date)).TotalSeconds
|
||||
if ($remaining -le 0) {
|
||||
break
|
||||
}
|
||||
Start-Sleep -Seconds ([Math]::Min($IntervalSeconds, [Math]::Max(1, [int]$remaining)))
|
||||
}
|
||||
|
||||
@"
|
||||
# Perfect Machine Rumination
|
||||
|
||||
- started: $($now.ToString("o"))
|
||||
- finished: $((Get-Date).ToString("o"))
|
||||
- target: $($target.ToString("o"))
|
||||
- cycles: $cycles
|
||||
- failures: $failures
|
||||
- artifactDir: $artifactDir
|
||||
- log: $logPath
|
||||
- latestStatus: $statusPath
|
||||
|
||||
This pass repeatedly ran the native heartbeat routine over `state/agent-heartbeats.msgpack`,
|
||||
projecting memory resonance, thought lanes, appraisals, reactions, sleep, and dream
|
||||
maintenance through the typed Rust/CultCache surface.
|
||||
"@ | Set-Content -LiteralPath $summaryPath -Encoding UTF8
|
||||
|
||||
Write-Log "Completed Perfect Machine rumination with $cycles cycles and $failures failures."
|
||||
Reference in a new issue