fix-pi-continuation-exit-epoch-fence

Fix Pi continuation/exit process-epoch fencing

Metadata

Statusdone
Assignedagent-924
Modelpi:openai-codex:gpt-5.6-sol
Created2026-07-28T08:03:26.708702744+00:00
Started2026-07-28T08:52:18.685939446+00:00
Completed2026-07-28T09:58:22.873045933+00:00
Tokens35683161 in / 44656 out

Description

Objective

Fix the process-epoch split exposed by implement-lazy-evaluation attempt attempt-0-22: a same-session continuation must not make the live current process exit/terminal receipts appear stale and strand retained WIP.

Incident evidence

  • Lifecycle remained pi_process_epoch=1 for exact PID 3536136 while watchdog state advanced to process_epoch=2, continuation_epoch=1 after an in-process same-session continuation prompt.
  • The exact current wrapper then received stale_process_epoch for terminal/exit reconciliation three times; no terminal receipt was accepted, no rescue transaction was created, and coordinator marked the attempt Lost via process_identity_dead.
  • 27 modified/untracked source files and the substantive session journal survived; this is a fencing defect, not source failure.

Requirements

  • Define and enforce process epoch separately from continuation/prompt epoch: an in-process prompt/continuation on the same exact PID/start/boot/nonce must not impersonate a replacement process epoch.
  • A real replacement process must atomically update lifecycle and watchdog process epoch/identity before any progress, terminal, or exit receipt is accepted.
  • Wrapper exit reconciliation must obtain/attest the current exact epoch rather than use stale launch-time assumptions; truly old process receipts remain rejected.
  • Terminal, process-exit, continuation-budget, native stream follower, finalizer, and dead-agent reconciliation must share one epoch authority and remain idempotent across restart.
  • Preserve first-terminal-wins, exact route/session/worktree/fence/lease guards, and no cross-runtime fallback.

Validation

  • RED Fake-Pi case performs a same-PID continuation then exits with/without wg_done; current receipt is accepted or classified for exact-session completion, never stale_process_epoch.
  • Replacement-PID case updates lifecycle+watchdog atomically; old PID exit is evidence-only and new PID terminal/exit succeeds exactly once.
  • Restart at each epoch boundary converges without Lost, duplicate charge, or missing rescue.
  • Regression replays attempt-0-22 shape and preserves dirty WIP/session bytes.
  • Existing watchdog, native activity/session proof, crash-safe finalization, observer, and TUI smokes pass.
  • cargo fmt --check, cargo clippy, focused/full tests and owned smoke pass; commit/push and wg done complete normally.

Depends on

Required by

Messages 1 message (1 unread)

  1. #1implement-lazy-evaluation2026-07-28T08:43:02.386233581+00:00delivered
    Lazy evaluation now relies on lifecycle attempt-running proof emitted at serialized launch-gate release and candidate-checkpointed emitted in the final completion commit. Continuation/exit fencing must preserve the current attempt generation/fence and must not synthesize candidate completion during reconciliation.

Log