Skip to content

fix(v2): re-open hard completion latch on a genuine user message - #54

Closed
famewolf wants to merge 3 commits into
Mte90:masterfrom
famewolf:fix/hard-completion-latch-rearm
Closed

famewolf wants to merge 3 commits into
Mte90:masterfrom
famewolf:fix/hard-completion-latch-rearm

Conversation

@famewolf

Copy link
Copy Markdown
Contributor

Summary

 noteInboundUserMessage(sid, w, messages)
   ... own prompts / synthetic interrupts return early ...
+  if (w.completionHard && newestUserMessageIsNewerThanLatch) {
+    w.completionHard = false
+  }
   if (w.completionSignaled) { ... }

task_complete and a literal trailing TASK COMPLETE set completionHard. That stopped both the stall ladder and the one-shot instant resume for the rest of the session. A new user message now clears the field. It uses the same timestamp guard as the other re-arm sites. The plugin ignores its own prompts, synthetic interruption messages, and user messages older than the latch.

This branch carries two commits: the instant resume after a non-user interruption, and this hard-latch fix. The tests for the fix exercise the instant-resume path; the earlier PR #53 (session-level pause) was closed by the maintainer and is not included here.

Evidence

  • New src/v2/index.completion-hard-rearm.test.ts — 8 tests: control latch, instant resume re-arm, regular stall re-arm, own prompt, synthetic interrupt, stale message, user interrupt, fresh task_complete re-latch.
  • RED/GREEN on a clean upstream master (v1.2.8): reverting only the production change produced 2 failures (12 pass / 2 fail); restored produced 14 pass / 0 fail across the instant-resume and hard-rearm files.
  • Full suite on the local v1.2.7-based branch: 1114 pass / 1 fail in 1115 tests. The one failure is the pre-existing dispatch.test.ts global-console-capture flake (passes 10/10 in isolation; also recorded on the earlier PR fix(v2): make /auto-resume pause strictly per-session, reset on restart #53).
  • Deployed to the author's live config, reloaded, and verified: artifact hash 6c9b2e37314db34a identical in both live copies and the dist; fix marker present; plugin load events after restart; only known recurring inotify errors in the post-restart window.

Merge Danger

Door: Two-way — the change is one conditional reset in noteInboundUserMessage plus tests; revert is a single commit.

Blast Radius: Recovery timing. After a completed turn, a user message re-arms auto-resume. The plugin ignores its own prompts, synthetic interrupt messages, and user messages older than the latch. User interrupts still stand down. A new task_complete call re-latches.

Duplicate scan: 5 PR + 4 issue keyword queries (completionHard, hard latch, task_complete user message, completion latch reopen, instant resume interruption, nudge after task_complete). All hits were closed, unrelated items (#37, #33, #28, #18); no prior PR covers this.

famewolf and others added 3 commits November 20, 2026 10:34
On a non-user interruption (shutdown/superseded/inactivity), auto-resume
marked the session idle with no recovery armed, leaving it silent until the
180s/600s stall timeout. Fire one immediate, fully-guarded continue before
that wait; user interrupts and unknown reasons default to stand-down.

- new SessionWatch.instantInterruptResumeFired (one-shot, reset by genuine
  user message), helper instantResumeAfterNonUserInterrupt, wired into the
  interrupted handler fire-and-forget.
- guards: userCancelled, completion latches + literal trailing TASK COMPLETE,
  lockKind, compacting, selfAbort, isWaitingOnUser, loop/lifetime budgets,
  injectIntervalMs + duplicate suppression via injectOnce.
- 6 bun:test tests: 3 non-user reasons resume, user/unknown/missing do not,
  TASK COMPLETE last line suppresses, one-shot per episode.
@famewolf

Copy link
Copy Markdown
Contributor Author

Closing this PR. Live testing found an additional bug in the user-interrupt path: a stop initiated by the operator could trigger an instant resume. The fix is being reworked and a new PR with corrected tests will be submitted.

@famewolf famewolf closed this Nov 20, 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