Skip to content

fix(v2): counter fixes, quota guards, and code cleanup - #49

Merged
Mte90 merged 6 commits into
Mte90:masterfrom
famewolf:fix/counter-and-cleanup-v2
Nov 2, 2026
Merged

Mte90 merged 6 commits into
Mte90:masterfrom
famewolf:fix/counter-and-cleanup-v2

Conversation

@famewolf

Copy link
Copy Markdown
Contributor

Summary

Bug fixes and code cleanup for the v2 auto-resume plugin. Does not include the /auto-resume pause feature or docs (already on base branch).

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.
  • msgAt/msgRole used instead of raw m.time.created/m.role for info-wrapped production messages.

Code cleanup

  • 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).

Test plan

  • Run full test suite: bun test
  • Verify quota cooldown holds for full ladder duration
  • Verify counter advances monotonically on consecutive nudges

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 marked this pull request as ready for review October 31, 2026 16:36
@Mte90
Mte90 merged commit a193f0d into Mte90:master Nov 2, 2026
1 check passed
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.

2 participants