Skip to content

fix: omp watcher stale replay handoff cleanup - #13

Merged
rafaelreis-r merged 1 commit into
mainfrom
fm/fm-omp-watch-stale-replay-handoff
Sep 18, 2026
Merged

rafaelreis-r merged 1 commit into
mainfrom
fm/fm-omp-watch-stale-replay-handoff

Conversation

@rafaelreis-r

Copy link
Copy Markdown
Owner

Fixes the stale-replay bug where session-replacement-actionable.json accumulates records for closed panes/migrated tasks that are never consumed. Records whose backing file/pane no longer exists and queue is empty are now finalized and dropped. Consumption at message_start closes record on first delivery to prevent re-delivery.

…delivery

Fixes the stale-replay and unbounded-growth bug in session-replacement-actionable.json.

Changes:
- Added loadAndFilterReplacementHandoff() that filters out handoff records whose
  backing task no longer exists (no state files, no queued wakes) and rewrites
  the handoff file.
- Added isTaskAlive() and extractTaskId() helpers to determine if a task is
  still live by checking for state files (.meta, .status, .inbox, .progress,
  .turn-ended) and the durable wake queue.
- Modified activateOwnedWatch() to use loadAndFilterReplacementHandoff() instead
  of loadReplacementHandoff().
- consumeWake() already calls finishPendingActionable() which clears the handoff
  record on first delivery at before_agent_start/message_start, preventing replay
  on the next session start.

Tests:
- test_watch_extension_drops_stale_replacement_records: verifies stale records
  for ghost tasks (no state files, no queued wakes) are dropped at load time,
  while valid records with state files are preserved.
- test_watch_extension_consumption_clears_handoff: verifies the handoff is
  cleared after consumption at before_agent_start, and a subsequent actionable
  does not ride the replacement handoff.
@rafaelreis-r
rafaelreis-r merged commit e161e8c into main Sep 18, 2026
rafaelreis-r added a commit that referenced this pull request Sep 19, 2026
… 2026-09-19, rule 2026-09-16)

Resolves conflicts by taking upstream, plus one semantic reconciliation the
auto-merge got wrong (captain-approved 2026-09-19):

- AGENTS.md: add .dead-reported-* watcher internals file (PR kunchenguid#4775)
- bin/fm-contributions.{jq,sh}: adopt upstream settle_final/final rename (PR kunchenguid#4710, kunchenguid#4661)
- tests/fm-contributions.test.sh: align with upstream test reorganization
- bin/fm-watch.sh: dead/missing endpoint now reports once via upstream wedge_dead_record
  (PR kunchenguid#4775); removed the fork-only retire_gone_window_records silent-retire subsystem
  (retire_gone_window_records, window_retired, prune_orphan_window_records, .retired-*)
  that shadowed it. Safer: warns to check unlanded work before cleanup.
- tests/fm-watch-triage.test.sh: removed the fork tests for the retired subsystem

All 9 fork PRs (#4..#13) preserved. No force push, no rebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant