Skip to content

fix(omp): prevent task-inbox messages from stranding idle secondmates - #126

Closed
dnth wants to merge 4 commits into
mainfrom
fm/fm-omp-doorbell-idle-strand
Closed

dnth wants to merge 4 commits into
mainfrom
fm/fm-omp-doorbell-idle-strand

Conversation

@dnth

@dnth dnth commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner

Intent

Fix the OMP task-inbox doorbell silently stranding steering messages delivered to an idle secondmate

What Changed

  • Track idle OMP doorbell requests until turn_start, with a bounded sendUserMessage fallback and durable failure status when no turn starts.
  • Requeue ambiguous claims when a session retires, preventing steering messages from being silently stranded.
  • Document the revised supervision protocol and expand doorbell tests for deferred turns, fallback escalation, and recovery paths.

Risk Assessment

✅ Low: The reviewed changes preserve durable request markers, recover ambiguous claims on retirement, and coalesce idle wake fallback delivery without a source-verifiable correctness defect.

Testing

Exercised the focused doorbell suite, including the idle/deferred-turn end-to-end path, forced user-turn fallback, durable failure escalation, native routing, and bounded unacknowledged behavior; also ran the focused OMP primary suite. All targeted checks passed and the worktree remained clean.

Evidence: Targeted OMP doorbell behavior output
ok - OMP doorbell forces a user turn when the client defers an agent-initiated turn
ok - fm-send: refused and unacknowledged OMP steers stay bounded, durable and non-resend-inviting

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • 🚨 .omp/extensions/lib/fm-task-inbox-doorbell.ts:205 - retire() clears pendingAcks without resolving the corresponding .pending.ambiguous files (lines 199-208). Concrete sequence: an idle request is sent, moved to .ambiguous, and waits for turnStarted; session_shutdown then calls retire() before any turn starts, leaving the ambiguous file behind. A later activate() only reconciles .processing.<pid> files (line 264), so this request is never redelivered, marked failed, or otherwise surfaced. This can still silently strand the exact idle-session message this change claims to fix. The remedy requires choosing/authorizing the durable terminal-state policy for unresolved claims (for example, recover or explicitly fail them on retirement).
  • ⚠️ .omp/extensions/fm-primary-omp.ts:275 - The primary watcher fallback uses one mutable timer but does not coalesce or cancel an existing timer before scheduling another (wakeFallbackTimer = setTimeout(...) at lines 265-286). If two idle wake notifications arrive within the ACK window, each schedules a timer; if the first forced sendUserMessage has not emitted turn_start by the time the second fires, both raw wake contents are submitted as user turns. This can duplicate watcher prompts and produce multiple turns for one idle period. The fix needs an explicit product choice for coalescing/ordering multiple pending wake contents, so the remedy is not safely inferable from the current intent.

🔧 Fix: Recovered retired claims and coalesced watcher fallback wakes
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-omp-task-inbox-doorbell.test.sh
  • bash tests/fm-omp-primary.test.sh
  • Repeated bash tests/fm-omp-task-inbox-doorbell.test.sh three times to check timing-sensitive fallback behavior
  • git status --short to confirm tests left no worktree artifacts
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

dnth and others added 3 commits September 9, 2026 08:58
The extension's void-returning `sendMessage` can be downgraded when the
ACP client defers agent-initiated turns, leaving a doorbell request
silently renamed to `.delivered` with no turn ever running.

- `installTaskInboxDoorbell` now tracks `sessionIdle`, waits for an
  observable `turnStarted`/`turnEnded` signal, and only marks a request
  `.delivered` after a turn actually starts.
- If an idle turn is deferred, it falls back to `sendUserMessage` to force
  a user-owned turn; if that also fails, it renames the request `.failed`
  and appends a durable status note.
- Exposed `turnStarted`/`turnEnded` on the returned doorbell object so the
  primary adapter can drive them from its own OMP event handlers, avoiding
  conflicting `omp.on` subscriptions.
- Applied the same idle-deferred boundary to `sendWakeNotification` in the
  primary watcher, with a bounded fallback to `sendUserMessage`.
- Added `test_omp_idle_deferred_no_turn_forces_user_turn` to assert the
  deferred no-turn path and its escalation.

Tests and checks run:
- bash tests/fm-omp-task-inbox-doorbell.test.sh
- bash tests/fm-omp-branch-supervision.test.sh
- bash tests/fm-omp-primary.test.sh
- bash tests/fm-omp-fleet-hooks.test.sh
- tests/fm-omp-branch-types.test.sh
- bin/fm-lint.sh
- bin/fm-ensure-agents-md.sh

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@dnth dnth changed the title fix: OMP task-inbox doorbell stranding idle secondmate sessions fix(omp): prevent task-inbox messages from stranding idle secondmates Sep 9, 2026
…` so a synchronous durable move of the matching inbox record into `handled/` is treated as the authoritative delivery receipt, even when the OMP client does not emit `turn_start`. This resolves the failing bound remote OMP delivery while preserving deferred-turn fallback behavior. Verified with `bash tests/fm-omp-task-inbox-doorbell.test.sh` and `git diff --check`
@dnth

dnth commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

Superseded: the OMP idle-turn defect is being addressed by porting upstream's fixes (kunchenguid/firstmate kunchenguid#3497/kunchenguid#3946/kunchenguid#3943/kunchenguid#3823/kunchenguid#3767 et al.) and adapting them to the OMP branch, in one coherent task, rather than reinventing. This branch's analysis + reproduction are referenceable by that task.

@dnth dnth closed this Sep 9, 2026
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