Ghostlight/crates
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Meta Vens a397132223 Tolerate Idunn's activation-publication gap in the daemon's own Warming path
Soul's diagnosis: Idunn publishes Expected and starts the unit before it
observes the running process on a later tick and publishes the activation
(Idunn/src/control_plane.rs). Until that activation exists, Odin refuses
every Warming presence this daemon publishes ("no exact current activation
and provider anchor"), and the daemon's single initial publish_warming()
call, and every heartbeat inside wait_for_write_lease, propagated that
refusal through `?` and killed the process. Muninn tolerates the same gap by
re-publishing every 2s and only logging failures
(Muninn/crates/muninn-daemon/src/main.rs); this cut matches that posture in
Ghostlight, touching only the daemon.

1. initialize_production_admission now retries the initial publish_warming()
   at a 2s cadence (matching Muninn), bounded by the same 120s window
   wait_for_write_lease already used — pulled into one named constant,
   WRITE_LEASE_WAIT_TIMEOUT, reused by both rather than inventing a second
   value. Each retried publish is a genuinely new message, not a duplicate
   Odin would drop: signed_record increments publisher_sequence and refreshes
   observed_at_unix_millis on every call (verified by reading it, not
   assumed). Every failed attempt is logged at warn with its error; the loop
   exits only when the window expires, and returns the accepted presence so
   it carries forward into wait_for_write_lease's recent_warming_proofs
   exactly as the single call used to.

   The retry policy is retry_until_deadline, generic over the attempt
   closure and a sleep/clock seam (no trait hierarchy on the publisher) so
   it's unit-testable without waiting real time out: production passes
   tokio::time::sleep and Instant::now, a test passes a no-op sleep paired
   with a fake clock that only advances when the sleep seam is called.

2. wait_for_write_lease's own heartbeat publish no longer propagates a
   failure through `?`; it logs a warning and keeps waiting, exactly like
   the initial-publish retry, until the wait's own outer deadline.

3. Tests (crates/ghostlight-dungeon/src/runtime.rs, idunn_health.rs):
   - retry_until_deadline_returns_the_first_accepted_value: refused twice
     then accepted succeeds and returns the accepted value, via a fake
     clock — runs in 0.00s, no real waiting.
   - retry_until_deadline_fails_with_the_last_error_after_the_window:
     always-refused fails once the fake clock crosses the deadline,
     carrying the last attempt's own error.
   - a_failed_heartbeat_does_not_abort_the_wait_for_lease: a real fixture
     publisher pointed at a closed port (127.0.0.1:9, the existing fixture
     convention) so every publish fails fast; proves the wait survives past
     one heartbeat interval and only ends at its own outer timeout, not the
     heartbeat's own error. This one uses real timing (~6s) since
     wait_for_write_lease's internal loop has no clock seam and adding one
     was out of scope for this cut; verified by mutation that it would have
     caught the old bug (see below).

Mutations, all verified and reverted (diff-clean after):
   - retry_until_deadline: made the first failure unconditionally fatal
     (`if true || now() >= deadline`) -> both new retry tests fail, the
     first on attempt 1 instead of retrying to attempt 3. Restored.
   - wait_for_write_lease's heartbeat: restored the old `?`-propagating
     form -> a_failed_heartbeat_does_not_abort_the_wait_for_lease fails in
     ~5.6s with "publishing Warming heartbeat ... timed out connecting" (the
     pre-fix symptom), instead of running to the 6s outer deadline. Restored.

Decisions made without a further ruling:
   - Named the shared timeout constant WRITE_LEASE_WAIT_TIMEOUT (both the
     initial-publish retry and wait_for_write_lease's own timeout parameter
     use it) rather than threading one Duration value through both call
     sites by hand.
   - Put retry_until_deadline in runtime.rs, beside
     initialize_production_admission, its only caller — not in
     idunn_health.rs, which owns the publisher/protocol, not retry policy.
   - The heartbeat-tolerance test uses real timing rather than adding a
     clock seam to wait_for_write_lease's own internal loop; that loop's
     shape (poll write-lease file + sleep 100ms + heartbeat check) is
     unrelated to this fix and reworking it for a seam felt like scope creep
     against the operator's instruction to avoid a trait hierarchy.

cargo test -p ghostlight-dungeon --bin ghostlight-dungeon: 190 passed, 0
failed, 4 ignored (was 186 before this pass; +3 new tests here, +1 from
Self's own commits since the last pass).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 17:38:31 +02:00
..
ghostlight Cut CodexConnector out of managed admission; fix Heimdall's dependency kind and recipe/binary drift 2026-09-23 15:59:09 +02:00
ghostlight-dungeon Tolerate Idunn's activation-publication gap in the daemon's own Warming path 2026-09-23 17:38:31 +02:00
ghostlight-persona-projection Fix batch 8a-fix5: dispatch call body durable before its effects PA.f125-PA.f132 2026-09-22 21:31:30 +02:00