Skip to content

Latest commit

 

History

History
224 lines (158 loc) · 32.7 KB

tracker-loop.md

File metadata and controls

224 lines (158 loc) · 32.7 KB
description Run ONE iteration of an unattended loop — babysit a PR to green, clear an epic leaf by leaf, or poll a label and dispatch /work-issue — with budgets and stop conditions kept on disk. Recurrence comes from /loop, a session cron, or a scheduled task (--cron-id schtasks:<TaskName>).

/tracker-loop [ref] [--label ] [--merge | --draft] [--restart] [--cron-id schtasks:] | status | stop []

One iteration per invocation. /tracker-loop never schedules itself and never calls ScheduleWakeup; recurrence is external:

Recurrence How
Self-paced (preferred) /loop /agent-issue-tracker:tracker-loop babysit #42 — the harness picks each delay; this command ends every iteration with a pacing hint the self-paced loop follows
Fixed interval /loop 15m /agent-issue-tracker:tracker-loop poll
Armed by a driver /work-issue #42 --start --loop or /resume-initiative #9 --start --loop creates a session cron that fires this command (see those commands)
Scheduled task (long-lived) Windows Task Scheduler runs claude -p "/agent-issue-tracker:tracker-loop poll --cron-id \"schtasks:<TaskName>\"" every loops.interval, each fire a fresh session; see Recurring mode below. keel's keel tasks install registers one per project as Tracker Loop <project>

Session crons expire after seven days and end with the conversation. A scheduled task outlives every session and is the documented answer for a loop that runs for weeks; /schedule (cloud routines) is the other, and is not wrapped here.

Modes

/tracker-loop babysit [<pr-number> | <issue-ref>] [--merge] [--restart] [--cron-id schtasks:<TaskName>]
/tracker-loop clear <epic-ref> [--draft | --merge] [--restart] [--cron-id schtasks:<TaskName>]
/tracker-loop poll [--label <name>] [--draft | --merge] [--restart] [--cron-id schtasks:<TaskName>]
/tracker-loop status
/tracker-loop stop [<loop-id>]

--cron-id names the external scheduler that fires this loop and selects Recurring mode (below). It must start with schtasks: (the task's name follows, spaces allowed; quote it); refuse any other value with a one-line message, since a session cron is never passed on the command line (the drivers record theirs with LR set-cron). Without --cron-id every step below behaves as it always has.

--draft and --merge are mutually exclusive; refuse with a one-line message if both are passed. They pass straight through to the /work-issue invocations a loop makes and to the babysit merge rule. When neither is on the command line, the loaded record's options.merge / options.draft apply (a loop armed by a driver, or re-armed from a resume note, keeps the flags it was created with); a flag on the command line wins over the record for that iteration. "The effective --merge" / "the effective --draft" below means this resolved value. --restart creates a fresh record even when a stopped one already exists for that mode and ref (see step 2).

Configuration

Optional loops: block in the effective config (defaults shown; examples/issue-tracker.yaml.example documents it; README "Where the config is found"):

loops:
  interval: 15m          # cron cadence for --loop; poll idle cadence
  max_iterations: 50
  max_hours: 24
  idle_stop_after: 12    # consecutive no-change iterations
  pr_mode: draft         # draft | ready — PRs opened by unattended loops
  poll_label: agent-ready
  # claim_label: agent-claimed
  # max_concurrent: 1

Read each key with "${CLAUDE_PLUGIN_ROOT}/scripts/lib/common.sh"'s ait_config_get loops.<key>; an unset key takes the default above.

The iteration skeleton (every mode)

All bookkeeping goes through "${CLAUDE_PLUGIN_ROOT}/scripts/loop-record.sh" (LR below). Every subcommand prints JSON.

  1. Collect. Run "${CLAUDE_PLUGIN_ROOT}/scripts/session-brief-collect.sh" for the current branch (SB below). It runs first, before the record is loaded, because step 2 needs SB (the babysit ref and the session transcript). Modes clear and poll also read the tracker in their own step.

  2. Load or create the record. The record's <ref> is: poll → the poll label in use (--label, else loops.poll_label, default agent-ready); babysit with no argument → SB.ticket.key, else #<SB.pr.number>, else the current branch name; babysit <arg> → that argument, normalised: strip a leading #; a bare number is then a PR number when gh pr view <n> resolves one, else an issue number, and either way is recorded as #<n> (the form the no-argument case uses), so babysit 128 and babysit #128 find the same record; owner/repo#N and any other issue ref are kept as-is; clear → the epic ref. LR find and LR create always take the normalised ref.

    LR find <mode> <ref>; if it returns a live record whose cron_job_id starts with schtasks:, it belongs to a scheduled task: print loop <id> is driven by <cron_job_id>; not acting and end the iteration without acting (pacing hint stopped), and never adopt it. If it returns any other live record, use it. Otherwise, unless --restart was passed, LR find --any --no-scheduled <mode> <ref> (--no-scheduled leaves out every record a scheduled task owns, so this path never reopens one or reports its stop reason):

    • null → create (below).
    • the newest record is stopped with a stop_reason beginning checkpoint: → a checkpoint continues only in a different session. If SB.session.transcript is non-null and differs from the record's stop_transcript, LR reopen <id> and continue with that record: its started time, iterations, prs_opened, budgets and options are kept, so the budgets keep counting, and its cron_job_id is cleared, since the checkpointing session's cron ended with that session. Otherwise print loop <id> is checkpointed for a fresh session; press Esc to end this /loop, then start a new session with the resume note (or pass --restart) and end the iteration without acting, with pacing hint stopped: a same-session /loop keeps firing into this message until the operator presses Esc.
    • the newest record is stopped for any other reason → print loop <id> is stopped (<reason>); pass --restart to begin a new loop and end the iteration without creating or acting.

    --restart skips the find --any check above and always creates a fresh record.

    With --cron-id, step 2 follows Recurring mode "Load or create" instead of the three bullets above.

    reopen never resets started: a reopened record's max_hours budget includes the gap between the checkpointing session and the one that reopened it. That is by design; --restart is the way to a fresh clock.

    Create: LR create <mode> <ref> <branch> [--merge] [--draft] --max-iterations … --max-hours … --idle-stop-after … --interval … with the configured budgets and the command-line flags. <branch> is the current branch for babysit, the epic ref's slug for clear, and "" for poll. Refuse to create a second live loop of the same mode and ref; report the existing id instead.

    Flags. With the record loaded, resolve the effective --merge / --draft (see Modes): the command line wins; otherwise the record's options.merge / options.draft.

  3. Budget check. LR check <id>. On ok: false with recurring: true (a scheduled loop whose window budget is spent), do not stop: LR append <id> wait "<reason>" --noop, print step 7's report line with next: <window_ends>, then the window line (Recurring mode), and end the iteration. On any other ok: false, go to step 8 with the reason. max_iterations counts the record's iterations[] entries whose action is not skip: skip entries are clear-mode bookkeeping, so a cascade of skips does not burn the iteration budget, and iterations[] can be longer than the count LR check reports.

  4. Decide. The mode's table yields exactly one action, or wait, or stop <reason>.

  5. Act. Perform that one action through the existing skills and commands. An "action" is one mutating work action — a push, a rebase, a branch update, a merge, or a /work-issue dispatch; bookkeeping (the skip comment, LR append … skip) doesn't count against the limit. Never two mutating actions in one iteration, except where a mode's table below says otherwise (poll, clear).

  6. Checkpoint. Apply the /session-brief verdict table (commands/session-brief.md Step 3) to SB.session. On a fresh session verdict, in this order: run step 7's LR append for the action just taken (so it is on the record), write the resume note exactly as /session-brief Step 4 does, including the **Loop:** re-arm line, then LR stop <id> "checkpoint: fresh session" --transcript <SB.session.transcript> (omit --transcript when that is null) and go to step 8, which does not stop the record a second time.

    • The **Loop:** re-arm line is written from the record this iteration holds (its mode, ref and effective --merge / --draft), not from SB.loop: the collector matches SB.loop by branch, so it is null for a clear or poll loop.
    • A /compact verdict does not checkpoint: continue to step 7 and append · suggest /compact to its report line. The loop never compacts itself.
    • The verdict applies only to the loop's own session. When this command runs inside a subagent, SB.session describes the parent's transcript whatever its transcript_source (env, session-id or discovered); treat the verdict as keep going there. Branches a clear or poll loop entered itself (its leaves' and PRs' worktrees) do not count toward the table's "more than one branch or ticket" row; only the turn, span and compaction rows can checkpoint such a loop.
  7. Record and report. LR append <id> <action> "<detail>" [--noop] — append wait-ci without --noop for the CI-in-progress wait (babysit table row 8; it doesn't count toward idle_stop_after), and wait with --noop for the idle wait (row 9) and any other no-op iteration. No other action takes --noop. Then print one line:

    loop <id> · <mode> <ref> · iteration <n> · <action or noop> · next: <pacing hint>

    A scheduled loop (Recurring mode) then runs LR window <id> and prints its line as the last line of the iteration's output, on its own: loop <id> window ok when something acted since this fire's LR check, else loop <id> window skipped. The wrapper that runs the task may parse it: keel's keel run keeps it as the run's summary and records the run as ok either way, since an idle fire is a healthy one.

  8. Stop. LR stop <id> "<reason>" (already done by step 6 for a checkpoint); if the printed cron_job_id is set and does not start with schtasks:, CronDelete it. A schtasks: id is never passed to CronDelete: the task belongs to Task Scheduler, not to this session, and stopping the record does not unregister it; a scheduled loop runs LR window <id> before LR stop and ends with that line (Recurring mode "Window line"). For a checkpoint, first print step 7's report line with next: stopped for the action step 6 appended. Print the reason. When the reason is NEEDS YOU, print the NEEDS YOU block (author, path:line, excerpt) exactly as /session-brief would. A loop stopped with reason checkpoint: fresh session continues only from a different session: a fire whose SB.session.transcript differs from the record's stop_transcript reopens it (step 2) with its iterations, prs_opened and budgets intact, while a fire from the same session reports it checkpointed and takes no action. A loop stopped for any other reason stays stopped: the next fire's step 2 reports it and takes no action. --restart begins a fresh record in either case.

Mode: babysit

Work source, by case:

  • The current branch has a PR → SB.pr.
  • The ref is a PR number (step 2's normalised #<n> that gh pr view resolved) → gh pr view <n> --repo <nwo> --json headRefName gives the branch; enter the worktree /work-issue Step 3's worktree lookup returns for it (ait_worktree_for_branch <branch>: whichever directory under .claude/worktrees/ has the branch checked out) when there is one, else operate from the primary checkout, and collect SB there.
  • The ref is an issue ref → derive its branch with /work-issue Step 3's naming, then gh pr list --repo <nwo> --head <branch> finds the PR; enter that branch's worktree as above.

gh must have answered before the table is read. Whenever SB.repo.gh_ok is false or SB.errors[] names a failed gh step (for example gh api user failed (auth?), gh pr view failed, gh graphql review threads failed), the iteration's action is wait (hint: 5m), recorded with --noop, regardless of SB.pr, SB.ci or SB.review: the table's inputs are then untrustworthy (with no viewer, no thread is marked awaiting_you, so an open change request would be invisible to the merge rows). A gh outage that never clears still ends the loop through idle_stop_after. The table below is consulted only when the collector reports no gh errors; only then does a null SB.pr mean the branch has no PR (see Failure modes).

Before the table, classify every SB.review.threads[] with awaiting_you == true as code (a concrete, actionable change request: rename, split, add a test, handle a case) or judgement (a question, a design objection, or anything a reasonable engineer would want the author to answer in prose).

Also before the table, when pr.state is OPEN, read the merge-readiness fields and attach them to pr: gh pr view <pr.number> --repo <nwo> --json headRefOid,mergeStateStatus,reviews. The collector does not carry them, and the BEHIND row and the merge rows cannot be decided without them. This read is the command's own, not a collector step in SB.errors: if it fails, leave the fields absent rather than waiting out the iteration. The PR is then not review-clear this iteration, every other row still applies, and the iteration's detail says merge readiness could not be read.

Observation (first match wins) Action
pr.state is MERGED or CLOSED stop: done — when pr.state == MERGED and the record's ref is an issue ref (or SB.ticket.key resolves one), the stop action is /work-issue <ref> --finish; a failure there is a WARN in the stop line, never a reason to keep looping
pr.mergeable == "CONFLICTING" rebase onto git.base, resolve, push
pr.mergeStateStatus == "BEHIND", pr.reviewDecision is empty ("") and the PR is not a draft update-branch: gh pr update-branch <pr.number> --repo <nwo> (its default, a merge of the base into the PR branch made on the server; never --rebase, which would need the force-push the safety rails forbid), then git pull --ff-only in the PR's worktree. Where that command is unavailable: git fetch, git merge origin/<git.base> and a plain push. GitHub reports BEHIND only where the base branch requires an up-to-date head, so the PR cannot merge until it is updated, and a BEHIND PR has no conflict to resolve. A PR that is approved or waiting on a reviewer is left alone: an update there can dismiss the approval or churn CI under the reviewer. On a base that keeps moving this row can fire again after every CI run; max_iterations and max_hours bound it
ci.conclusion == "failure" fix-ci: superpowers:systematic-debugging on ci.failed_jobs, superpowers:test-driven-development for the fix, push
an awaiting thread classified code address-review: make the change, push, reply on the thread naming the commit SHA, resolve the thread
an awaiting thread classified judgement stop: needs-you — quote author, path:line, excerpt
the PR is review-clear (defined below) and the effective --merge merge: gh pr merge --<merge_method> --match-head-commit <pr.headRefOid> --auto (merge_method from the effective config, default squash; falls back to a direct merge with the same method and pin only where auto-merge is unavailable; never --delete-branch). A direct merge lands immediately: run /work-issue <ref> --finish and stop: done. An armed auto-merge lands when the checks pass: record the action and keep iterating (wait-ci while checks run), so the first row observes pr.state == MERGED and runs --finish at its stop
the PR is review-clear, no effective --merge stop: ready-to-merge — the operator's call
ci.status is queued, in_progress, requested, waiting or pending, or a ci.all_workflows entry on the PR head has one of those statuses wait-ci (hint: CI in progress) — recorded without --noop; does not count toward idle_stop_after
anything else wait (hint: idle, see Pacing hint) — recorded with --noop; counts toward idle_stop_after

Review-clear means the merge-readiness fields were read (pr.headRefOid is set), the PR is not a draft (pr.isDraft is false), and one of:

  • Approved: pr.reviewDecision == "APPROVED".
  • No review required, and green on its head. All of:
    • pr.reviewDecision is present and empty (""). GitHub returns that when the base branch requires no review, so nobody will ever approve the PR. A null or absent decision is not empty; do not coerce one into "".
    • no reviewer's standing verdict in pr.reviews is CHANGES_REQUESTED. A reviewer's standing verdict is their newest review (by submittedAt) whose state is APPROVED, CHANGES_REQUESTED or DISMISSED; a later COMMENTED review, which every thread reply creates, does not withdraw a change request. Without required reviews the decision can stay empty after someone requests changes, and a review with only a top-level body opens no thread for the rows above to catch.
    • pr.mergeStateStatus is CLEAN (or HAS_HOOKS). That is GitHub's own verdict for the current head: no conflict, not blocked or behind, and every check on it passing, including workflows and checks the collector does not look at.
    • the runs the collector saw on the PR head are finished and one is green. The runs on the head are ci itself and the entries of ci.all_workflows whose sha pr.headRefOid starts with. At least one has conclusion == "success", and none has a status other than completed. That ties the green to the commit that would merge, not to an earlier push. Any workflow counts, because a path-filtered primary workflow does not run on every push; CLEAN above already rules out a failing check, and the "none still running" half covers a workflow whose checks GitHub has not registered yet. A head no workflow succeeded on is not green.

On the no-review branch green checks stand in for the approval, which is why it asks for more than the approved branch does. A PR that misses a condition falls through: to wait-ci while CI is running, otherwise to wait. Babysit therefore never merges a PR on a base branch that has neither required reviews nor CI; merge that by hand, or through /work-issue --merge, which verifies locally before it merges.

REVIEW_REQUIRED and CHANGES_REQUESTED are never review-clear, and neither is a draft, with or without --merge.

Replies to humans are always code-backed: a pushed commit plus a comment naming it. The loop never argues a review point in prose; that is a NEEDS YOU.

Mode: clear

Work source: /resume-initiative <epic-ref>'s next-up derivation (commands/resume-initiative.md "Deriving child state" and "Tree traversal"), reused as written — depth cap, cycle guard, and legacy branch included.

Observation (first match wins) Action
no open leaf stop: initiative clear
the next leaf carries the needs_design_label, or its body fails the agent-prompt bail criteria (skills/feature-request/SKILL.md) skip (bookkeeping, not this iteration's action — see step 5): upsert_comment on the leaf with marker <!-- tracker-loop:skip --> and a body naming the gap, LR append … skip, move to the next open leaf; three consecutive skips stop: stop: three skips
the next leaf already has an open PR run one babysit iteration against it (enter its worktree; table above) instead of starting a new leaf
the next leaf is workable start: /work-issue <leaf> --start with the effective --draft / --merge passed through; LR add-pr <id> <pr-ref> when it opens a PR. That PR is this loop's babysit target on later iterations

The skip comment goes through upsert_comment, so it is idempotent: a later iteration that derives the same leaf as next-up again replaces that one marker comment instead of adding another.

Skipping may cascade within one iteration — the skip row moves to the next open leaf without ending the iteration — but at most one start may follow a run of skips in the same iteration, once a workable (or already-open-PR) leaf is found; that start (or babysit action) is the iteration's one action. Each skip is its own LR append … skip entry, and step 3's LR check does not count skip entries toward max_iterations.

The checkpoint after each leaf is the reason this mode exists: a long clearing run compacts or hands off instead of degrading.

Mode: poll

Work source: list_open_issues({label: <poll_label>}) through the configured backend.

Claimed issues are skipped. An issue is claimed when any of:

  • a worktree for its ref exists (the branch /work-issue Step 3's naming derives is checked out in any worktree: a branch refs/heads/<branch> line in git worktree list --porcelain, with no .claude/worktrees/ gate, since a branch checked out anywhere is a claim; or a worktrees[] entry in tracker-brief-collect.sh output whose ref matches),
  • an open PR in this repo references it (gh pr list --repo <nwo> --state open --search "<ref>"),
  • another live loop record names it (LR list): its ref equals the issue ref, or one of its prs_opened PRs has the issue ref in its body (gh pr view <n> --repo <nwo> --json body),
  • it carries loops.claim_label, when that key is set.

Per iteration (at most one mutating action — see step 5):

  1. If this record's prs_opened has any still-open PR, babysit only the oldest one, entering its worktree (table above). A babysit stop reason of done drops that PR from consideration; needs-you stops the whole loop.
  2. A new issue may be dispatched in this same iteration only when step 1 found no open PR, or that babysit iteration took no mutating action of its own: its outcome was wait, wait-ci or stop: done. A mutating action (rebase, update-branch, fix-ci, address-review, merge) or needs-you permits no dispatch. If fewer than max_concurrent (default 1) of this record's PRs are open, take the oldest unclaimed issue (the lowest issue number on GitHub; elsewhere the earliest created when list_open_issues returns it, else the backend's listing order), apply claim_label via add_label when configured, and dispatch /work-issue <ref> --start. The PR mode: an effective --merge on the loop wins over loops.pr_mode and is passed through as --merge; otherwise an effective --draft passes --draft; otherwise loops.pr_mode decides (draft, the default, passes --draft; ready passes neither). LR add-pr <id> <pr-ref> once the PR exists.
  3. Nothing to do → wait (hint: loops.interval).

No remove_label operation exists in the contract, so a claim_label stays on the issue until a human removes it or the issue closes. Two machines polling the same label without a claim_label can collide; the local claim signals do not cross machines.

Recurring mode (scheduled tasks)

A loop fired by Windows Task Scheduler (--cron-id schtasks:<TaskName>, recorded as the record's cron_job_id) runs for weeks, one fresh claude -p session per fire. Session budgets would end it within hours while every fire exits green, so a schtasks: record counts its budgets per window instead. The scheduler, not this command, decides when the next fire comes; the pacing hint is informational.

  • Windows. budget.max_hours long, back to back from the record's started. max_iterations counts the window's acting entries: an action other than wait, wait-ci or skip, not a noop. When they are spent, LR check returns ok: false, recurring: true, reason: "window: max_iterations" and the window's later fires do nothing (step 3) until the next window. max_hours is the window length and never stops the loop; idle_stop_after never stops it either, because idle is a scheduled loop's normal state and the scheduler pays for the fire whatever happens (LR check still reports trailing_noops). LR append keeps the current and the previous window's entries only.
  • Load or create (step 2). One call, LR claim <mode> <ref> <branch> --cron-id <cron-id> [--restart] [--merge] [--draft] --max-iterations … --max-hours … --idle-stop-after … --interval … with the configured budgets, decides; read its action:
    • use / create / reopen → continue with its id. use is the live record this task owns; reopen is this task's own checkpoint: record, reopened with the cron id restored (every fire is a fresh session); create is a fresh record carrying the cron id, as --restart would make. --restart is implicit apart from the pause below.
    • refuse → print its message, then its line (loop <id> window skipped) as the last line, and end the fire without acting. It refuses when a live loop of the same mode and ref is driven by anything else and is still alive (an interactive /loop or a session cron in a checkout that shares the project key, message loop <id> is owned by …; not acting): that loop is never adopted, so it keeps its own budgets exactly as before. Such a loop counts as abandoned, and claim stops it and goes on to create, when its own next LR check would stop it anyway (its max_iterations, max_hours or idle_stop_after, in that order; the stop reason is the same budget: …), or when nothing has iterated it for four of its pacing steps (its options.interval, at least 30 minutes, the slowest idle hint a session loop gets; reason orphaned: no iteration in <n> min): a closed or Esc'd /loop, or the cron-less record a 1.12.0-era poll --restart fire left live. Both refusal messages start loop <id> is owned by or loop <id> is stopped, which keel's keel run records as a skipped run. It also refuses when this task's newest record was stopped with reason operator stop (an operator paused the scheduled loop, see stop): loop <id> is stopped (operator stop); pass --restart to begin a new loop.
    • A stop of another driver's record never pauses the task; only a record whose cron_job_id is this task's is reopened or paused on.
  • Checkpoint (step 6). Each fire is its own session, so the verdict is almost always keep going; when it is not, the checkpoint stop and the next fire's reopen above carry the loop on.
  • Stop (step 8). A mode's stop row (done, needs-you, initiative clear, …) stops the record as usual and never calls CronDelete; the next fire starts a fresh record. That is how a needs-you PR is left to the operator while the poll carries on with other issues: the PR stays open and claimed, and the fresh record's prs_opened does not hold it.
  • Window line. Every fire ends with a window line as its last output line: LR window <id>'s line after step 7, and on a stop path LR window <id> run before LR stop (a record that is no longer live always reports skipped); a fire LR claim refused prints the line it returned. loop <id> window ok means an acting entry was appended in this fire, loop <id> window skipped that nothing acted.

To pause a scheduled loop without touching Task Scheduler, /tracker-loop stop <id> (reason operator stop); to resume it, run the task's own prompt once by hand with --restart added; the pause holds until then. To end it for good, unregister the task (keel tasks uninstall, or Task Scheduler itself).

keel reporting

When the keel CLI is on PATH, LR reports to it through keel's local spool (keel … --spool, never a network call): loop.created on create, loop.iteration for each non-noop entry, loop.stopped with the reason on stop, and a loop:<id> heartbeat (payload cron_id, mode, ref) on create, on each check of a live loop and on reopen. The project is the slug in the repo's .keel/project.yaml. Without keel, or with AIT_KEEL=0, nothing is reported and nothing else changes.

Pacing hint

The last line of every iteration. A self-paced /loop follows it; a fixed-interval loop ignores it.

State Hint
CI in progress the duration of that workflow's last completed run, from one call: gh run list --repo <nwo> --workflow <name> --branch <branch> --status completed --limit 1 --json databaseId,startedAt,updatedAt (updatedAt − startedAt), floor 3m, cap 30m
a fix was just pushed 5m — CI is about to start
gh could not answer (gh_ok false or a gh entry in errors[]) 5m
waiting on a reviewer 30m
idle (babysit wait: nothing to act on) 30m, as waiting on a reviewer
poll found nothing loops.interval
clear just started a leaf none — the leaf's pipeline ran inline in this turn; next hint is 5m
stopped none — say stopped

status and stop

  • status: LR list, printed one line per live loop (id · mode ref · iteration n · last action · cron armed|none), followed by the last three stopped records with their reasons. <state-dir> is ait_state_dir "$PWD" from "${CLAUDE_PLUGIN_ROOT}/scripts/lib/common.sh" (${XDG_CACHE_HOME:-~/.cache}/agent-issue-tracker/<project-key>/); list <state-dir>/loops/*.json and LR get each stopped one.
  • stop [<id>]: with an id, LR stop <id> "operator stop" and CronDelete its cron_job_id if set and not a schtasks: id. A scheduled loop stopped this way stays paused (Recurring mode): say so, and name its task. Without an id and exactly one live loop, stop that one; with several, list them and ask which.

Prerequisites

An unattended loop commits while nobody is at the keyboard, so on a machine that signs commits it needs a signer that never prompts. A 1Password desktop signer (op-ssh-sign) fails while the app is locked, and the iteration ends with its work staged and uncommitted. The documented answer is scripts/git-sign.sh as gpg.ssh.program: it tries op-ssh-sign first and falls back to a dedicated agent key read through the 1Password Automation service account (setup in the script's header). /tracker-doctor Phase 4 warns when it is missing. Never bypass signing to get a loop past a commit.

Safety rails

  • Never merge without --merge; never open a ready PR on red (/work-issue Step 5 already refuses); never force-push.
  • Never delete a remote branch; GitHub's deleteBranchOnMerge setting owns that.
  • At most one mutating action per iteration (step 5's definition; poll and clear's controlled exceptions are spelled out in their tables); a NEEDS YOU always stops the loop over continuing.
  • Every tracker write is a contract op (backends/_interface.md): add_label for the claim label, upsert_comment for the skip comment (marker <!-- tracker-loop:skip -->). Every git-host write is one /work-issue already documents.
  • Budgets are enforced from the record on disk (LR check), before acting.
  • /tracker-loop stop, CronDelete, and Esc on a /loop all end a loop; the record says which when it was stop. A scheduled loop is ended by unregistering its task; stop pauses it.
  • Never CronDelete a schtasks: id: it is not a session cron.

Failure modes

  • LR find/create cannot write the state dir → report the path and stop; nothing else runs.
  • gh could not answer in babysit (SB.repo.gh_ok false, or SB.errors[] names a failed gh step) → wait (hint: 5m) with --noop, whatever SB.pr, SB.ci and SB.review say: never stop: no PR, and never a merge, rebase, branch update or review action on inputs gh did not fully deliver. An auth or network blip must not end the loop, delete its cron, or merge over a thread it could not see. A gh outage that never clears ends through idle_stop_after.
  • SB.pr is null in babysit and gh answered → no PR on this branch; stop with reason no PR and print the /work-issue line that would open one.
  • The tracker is unreachable in clear/poll → the backend reports it; stop with the reason and point at /tracker-doctor. Do not fall back to gh issue or an MCP call.
  • A leaf is not workable (needs-design label, vague body) → that is the clear skip row, checked here before any dispatch: /work-issue does not refuse a leaf for scope and leaves no comment. The skip row's own upsert_comment (marker <!-- tracker-loop:skip -->) is the record.
  • Iteration exceeds the session cron's interval (a full /work-issue pipeline can) → the harness skips fires while the REPL is busy and does not catch up; nothing to do, the next fire picks up from the record.