Skip to content

fix(v2): counter fixes, quota guards, /auto-resume pause, and code cleanup - #48

Closed
famewolf wants to merge 4 commits into
Mte90:masterfrom
famewolf:fix/counter-and-cleanup
Closed

famewolf wants to merge 4 commits into
Mte90:masterfrom
famewolf:fix/counter-and-cleanup

Conversation

@famewolf

@famewolf famewolf commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Bug fixes and code cleanup for the v2 auto-resume plugin.

Bug fixes

  • Counter invariants (I1/I2): own-prompt detection in execution.started prevents false counter resets; rung count claimed at rung start so consecutive nudges advance monotonically.
  • Quota guard: provider.free-limit and other quota error variants now matched; added fallback guard so quota-armed sessions don't inject mid-cooldown.
  • Counter persistence: syncCounters called in work/escalation paths and finally block; storage removed on genuine turn reset.
  • Back-to-back duplicate quota notices deduplicated (100ms guard).
  • msgAt/msgRole used instead of raw m.time.created/m.role for info-wrapped production messages.

Features

  • /auto-resume on|off|status slash command + CLI helper for pausing auto-resume (process-lifetime, cleared on restart).
  • syncCounters persists counters across plugin reloads/restarts.

Code cleanup (ponytail)

  • Quota guard deduplicated into shared quotaGuard() function (~25 lines removed).
  • isHardCompletionText inlined at call sites (~10 lines).
  • readPausedSet mtime cache removed (~5 lines).
  • FEATURE_GATED_OPTIONS comment compressed (~5 lines).
  • isRateLimitReason inlined (~1 line).
  • softLatchExpired comment compressed (~3 lines).

Testing

  • 55/0 pass across counter/quota/rate-limit/todo/own-prompt test files.
  • Live file deployed and verified (sha matches dist).

Docs

  • Added Complementary plugins section to README (todo + task-complete plugins).
  • Added efficiency proposal doc.

Test plan

  • Run full test suite: bun test
  • Verify quota cooldown holds for full ladder duration
  • Verify counter advances monotonically on consecutive nudges
  • Verify /auto-resume off pauses and /auto-resume on resumes

A completion latch inferred from text (stop phrase, done claim, celebration)
could only be cleared by a genuine user message, so one stop phrase parked a
live session until a human typed something (ses_e72df2be, 2026-10-30: latched
mid-turn, silent 20+ min).

- hard latch (task_complete tool, literal TASK COMPLETE tail) never expires
- soft latch re-opens once after COMPLETION_LATCH_TTL_MS (5m) with no user
  message, via the one-shot latchReopened guard
- COMPACTION_STALE_TTL_MS 30m -> 5m: a slow or wedged compaction must not mute
  the watchdog for half an hour
- completionLatchTtlMs option (default 5m) so the TTL is testable and tunable;
  added to RECOGNISED_OPTIONS so the startup warning stays honest.
- softLatchExpired sets pendingRecoveryArmed: the delayed inject drops an idle
  session's nudge unless a recovery is armed, so a re-opened latch detected the
  stall every tick and delivered nothing.
- new test file: soft latch re-opens and nudges, is one-shot, and a literal
  trailing TASK COMPLETE never re-opens.
…etionText inline, readPausedSet cache, softLatchExpired comment, FEATURE_GATED_OPTIONS comment, isRateLimitReason inline)
@famewolf famewolf closed this Oct 31, 2026
@famewolf

Copy link
Copy Markdown
Contributor Author

Sorry the bot got trigger happy when I asked for a draft to REVIEW.

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