Skip to content

feat(#892): durable halt-and-resume for waitable rate-limit windows - #895

Merged
admarble merged 3 commits into
mainfrom
feature/892-feat-run-durable-halt-and-resume-for-waitable-
Aug 4, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/892-feat-run-durable-halt-and-resume-for-waitable-

Conversation

@admarble

@admarble admarble commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Durable halt-and-resume for waitable rate-limit windows (#892) — the follow-up the #860 decision record filed. A run halting on a waitable window (five_hour/seven_day with a future reset) now writes windowHalt: { resumeAt, phase, reentries } to issue state before exiting cleanly (lock released via existing exit handlers), and the new sequant resume command re-enters once the window reopens.

  • Halt side: recordWindowHaltState at both batch-executor halt sites; resumeAt = resetsAt + AUTO_WAIT_BUFFER_MS (same clock as auto-wait). Billing/transient failures never write; any phase success or non-window failure clears the record.
  • Re-entry: sequant resume [issues...] [--dry-run] — clean no-op (exit 0) before resumeAt, safe for cron/launchd; after, consumes one bounded re-entry (2/issue, mirroring AUTO_WAIT_MAX_WAITS) and delegates to the normal run path with --resume semantics (fix(chain): --chain --ready-gate resume re-executes already-gated links (COMPLETED_STATUSES misses waiting_for_human_merge/blocked) #837 completed-issue + phase-marker skipping). Exhausted bound → today's labeled terminal message, exit 1.
  • Surfaces: sequant status + MCP status show "⏸ Halted … resumable at "; docs/reference/halt-and-resume.md ships the copy-pasteable cron/launchd recipe; README/run-command/decision-record cross-linked; CHANGELOG entry.

AC Verification

AC Status Evidence
AC-1 resumeAt + lock release at halt ✅ Implemented Wiring tests at both halt sites; lock release covered by existing releaseAll() exit-handler tests
AC-2 no-op before resumeAt, continues after ✅ Implemented Injected-clock planner tests incl. at-boundary; live smoke: exit 0 pre-resumeAt
AC-3 bounded re-entries, labeled terminal message ✅ Implemented Counter preserved across repeated halts; live smoke: "(2/2)" message, exit 1
AC-4 reboot-safe ✅ Implemented Fresh-StateManager persistence test; smokes ran in fresh processes
AC-5 cron/launchd recipe ✅ Implemented Gate test scoped to recipe:start/end markers

Mutation result (gate test, per CLAUDE.md): deleting the recipe payload between the recipe:start/recipe:end markers in docs/reference/halt-and-resume.md fails exactly the AC-5 gate test (ships cron and launchd recipes… — 1 failed / 11 passed in resume.test.ts); restored after verification.

Test plan

  • Full suite: 4913 passed (234 files); build + lint clean
  • New: 8 state-manager windowHalt tests, 4 windowHaltResumeAtMs + 4 wiring tests, 12 resume-command tests
  • Live CLI smokes: --help, --dry-run, pre-resumeAt no-op (exit 0), exhausted bound (exit 1), empty state (exit 0)

QA verdict: AC_MET_BUT_NOT_A_PLUS — recommendation-grade notes only (see issue comment).

Fixes #892

🤖 Generated with Claude Code

A waitable-window halt (#860 classification) now writes
windowHalt: { resumeAt, phase, reentries } to issue state before exiting
(lock released on exit as usual), and the new `sequant resume` command
re-enters once the window reopens: a clean no-op (exit 0) before resumeAt,
bounded re-entries (2/issue, mirroring AUTO_WAIT_MAX_WAITS) after, delegating
to the normal run path with --resume semantics. Any phase success or a
non-window failure clears the record so re-entry never fires on a stale or
non-waitable halt. Status surfaces (CLI + MCP) show halted issues as
resumable-at; docs ship the cron/launchd recipe.

Fixes #892
Mutation result (gate test, per CLAUDE.md): deleting the recipe payload
between the recipe:start/end markers in docs/reference/halt-and-resume.md
fails exactly 'ships cron and launchd recipes invoking sequant resume in
the delimited region' (1 failed / 11 passed in resume.test.ts); restored.
…ommand-shell tests

1. A due issue whose per-issue lock is held by another session is now
   skipped WITHOUT consuming one of its bounded re-entries (read-only
   LockManager.check probe before the increment; the race window shrinks
   from 'any concurrent holder' to the probe-to-acquire gap).
2. formatIssueState exported @internal; windowHalt/autoWait pause lines
   pinned by status-format.test.ts (present + absent cases).
3. resumeCommand shell covered via injected deps against a real
   StateManager on a temp state file: arg validation, all exit-code
   paths, persisted re-entry consumption, dry-run non-consumption,
   lock-skip, subset runs, requested-issue filtering (10 tests).
   bin/cli.ts wraps the action so commander's Command third positional
   cannot land in the deps param.
@admarble
admarble merged commit f1db4f0 into main Aug 4, 2026
5 checks passed
@admarble
admarble deleted the feature/892-feat-run-durable-halt-and-resume-for-waitable- branch August 4, 2026 14:28
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.

feat(run): durable halt-and-resume for waitable rate-limit windows — write resumeAt, release the lock, survive reboots

1 participant