Operational run commands
Operational run commands
These subcommands read the saved run state in the repository’s runsDir (default .loop/runs). Run them from the repository or any subdirectory. If the run uses a config file outside the repository, pass --config path/to/loop.config.mjs. The path is resolved from the current directory.
Every operational command supports --json, and aloop <command> --help prints its usage and options. If you don’t pass a config file and there’s no loop.config.mjs, the package defaults apply. A config file that exists but can’t be imported is an error, not a silent fallback to defaults.
Commands find runs from the repository root and the configured runsDir, so running from a different subdirectory doesn’t create a second run inventory.
Inspecting runs
aloop listaloop status my-specaloop inspect my-speclistshows saved runs, newest first: name, derived status, current phase, branch, update time, and the pull-request URL if one was recorded.statusprints the same summary for one run, including when the current phase started.inspectadds the run directory. In JSON mode it includes the full saved state and manifest. In human mode it prints per-phase evidence: input and output SHAs, prompt and configuration hashes, engine, verdicts, gate receipts, and artifact paths.
The derived status is one of running, interrupted, completed, stalled, cancelled, or unknown.
- A live lock or active command counts as
running, so a process that’s still shutting down isn’t mistaken for a stale run. - A saved
runningstate with no live runner or command isinterrupted. Resume it withaloop --name <name> --resume, or mark it cancelled withaloop cancel <name>.
Watching runs
watch polls one or more repositories and writes one compact NDJSON object for each change it sees. It never writes run output or manifest contents. It polls every 15 seconds by default. Use --interval to change that, with a minimum of 1 second. A change that starts and ends between polls is coalesced, so only the net state is reported.
# Stream changes from multiple repositoriesaloop watch --repo ../warden-core --repo ../warden-app
# Wake a caller after the next status-related change, with an idle limitaloop watch --once --timeout 30m --only status --repo ../warden-app
# Include a snapshot so changes between starting aloop and watch are visiblealoop watch --initial --repo .- Positional run names limit events to matching run slugs.
--repocan be repeated and defaults to the current directory.--configapplies to each repository.--only statushides phase-only,decision, and evidence events.--initialwrites asnapshotevent for every run found on the first poll. Snapshots don’t end--onceor reset its idle timeout.
Every line has a type and a UTC at timestamp:
| Type | Meaning | from / to |
|---|---|---|
snapshot | An existing run, included by --initial | null |
appeared | A run first seen after startup | null |
removed | A previously seen run disappeared | null |
status | Derived status changed. Carries the latest phase. | Previous / current status |
phase | A new phase or sub-phase started with no status change | Previous / current phase |
decision | A repeated-blocker judge decision or review override | null |
evidence-started | The evidence phase began | null |
evidence-scenario-finished | A selected scenario produced a receipt | null |
evidence-finished | The phase recorded its overall evidence result | null |
timeout | The idle timeout elapsed | Not applicable |
Run events include repo, name, status, currentPhase, phaseStartedAt, verdict, gateStatus, branch, prUrl, and runDir. A stalled run includes only its phase and a reason cut to 300 characters. A timeout line includes idleMs.
Details worth knowing:
- If status and phase both change in one poll, you get a single
statusevent. - A
decisionevent addsdecisionwithphase,round,outcome(repeated,not-repeated,skipped,failed-closed, orreview-override), andmessage, the same one-line summary the run log prints. Each recorded decision is reported once, after anystatusorphaseevent from the same poll. See Repeated-blocker judge. - Evidence events add
approvedSha. A scenario event includesreceiptand the final event includesevidence. The events are read from the saved manifest even if the phase finishes between polls. See Evidence scenarios. - Reviewers and repair phases appear under their own names, including moves back to review or gate on later attempts.
- A phase that starts and finishes between polls may be missed. A change to
phaseStartedAtalone emits nothing. - Runs created before phase entries were recorded report the last non-skipped manifest phase (completed or stalled), with a null
phaseStartedAt.
Exit codes: 0 for a --once event or a clean signal exit, 1 for startup errors, and 2 when --timeout elapses. Without --once or --timeout, the command streams until you stop it. A background caller can run aloop watch --once --timeout 20m --only status --repo <repo> and restart it after each event. That keeps the monitor idle between changes.
To avoid missing early changes, start aloop watch --initial before launching runs. You then get the initial state and all later events from one process.
Replaying recorded evidence
aloop replay my-specaloop replay my-spec --jsonreplay rebuilds a run’s history from what was recorded. It’s read-only: it never calls an agent and never changes the run. The JSON timeline keeps each phase’s status, input and output SHAs, verdicts, gate receipts, and prompt-verification result. The human view prints a one-line summary per phase. Use --json when you need the full evidence.
For each new-format agent entry, replay re-renders the saved template body with the exact saved variables and any operator note, then compares the SHA-256 of the result with promptHash. The outcome is verified, mismatch, or unverifiable. Older entries that didn’t save their prompt inputs are unverifiable. Their hash alone is never treated as proof.
Replay also reports divergences, without failing just because evidence is old or was tampered with. These include a missing snapshot, an unavailable base commit or worktree, a configuration-hash mismatch, and a prompt-hash mismatch. It only reports what’s available. It doesn’t recreate a worktree, restore a commit, or re-run anything.
Cancelling an active run
aloop cancel my-specaloop cancel my-spec --jsoncancel works only on an active run. It stops the runner and its recorded command, including its process group where supported. For hermetic phases it also removes the named container and verifies that the runtime reports it gone. It then records status: "cancelled" and cancelReason: "cancelled by operator" and releases the run lock. If termination doesn’t finish, the command fails and keeps the lock, so a process that’s still running can’t be mistaken for a cancelled one. The run directory, manifest, logs, and worktree are kept for inspection.
Cleaning completed runs
aloop cleanaloop clean --older-than 14aloop clean --older-than 14 --yesaloop clean --older-than 14 --dry-run --jsonaloop clean --yes --branchesclean considers only runs with derived status completed whose updatedAt (or startedAt if that’s missing) is at least the given number of days old. The default is 30 days.
Without --yes, it previews the candidates and changes nothing. --dry-run asks for the same preview explicitly. With --yes, Git removes registered external worktrees that aloop created before aloop removes their run directories. Manually created checkouts and legacy checkouts with unknown ownership are preserved, including with --force. If another retained run uses an aloop-owned checkout, the checkout and its owner’s run record are kept. If a worktree is already gone, aloop prunes stale Git metadata and removes the run directory. An existing unregistered directory is left in place.
Worktrees with uncommitted changes, including untracked files, and their run directories are kept by default. Commit or stash changes before retrying, or pass --force to discard them. Cleanup lists successful removals and failures separately. The exit code is 1 if any candidate fails, including with --json.
Pass --branches to also delete each removed run’s local branch when its tip is merged into the base. Clean checks local and remote-tracking base branches, then asks the configured GitHub or GitLab backend for a merged request whose head contains the local tip. This also covers squash merges. A custom backend supports this check only if it implements the optional mergedRequests operation. See Custom backends. Checked-out branches and branches without merge confirmation are kept. Forge lookup failures produce a warning and do not affect the exit code. If a branch can’t be deleted after its run is removed, that counts as a failure, and the exit code is 1.
Diagnosing local prerequisites
Doctor also checks every configured named agent, including specialized reviewers: whether it is resolvable, committed where worktrees can see it, and able to write artifacts. See Named agents. Agent warnings render as ⚠, with an indented → hint and docs link. They keep ok: true and exit zero; the summary becomes Doctor: OK (N warnings). JSON checks expose warn, hint, docs, and the diagnostic code.
aloop doctoraloop doctor --config ./loop.config.mjs --jsondoctor checks that:
- the configuration is valid;
- Git and Git worktree support are available;
- the executable exists for every agent engine your phases use;
- the configured backend passes its precheck, when the pipeline includes a publish phase.
It reports every check, so a missing engine or CLI shows up before a run reaches the affected phase. It exits with a failure if any check fails. GitHub checks gh authentication. GitLab checks glab authentication for the configured remote’s host. Doctor reports a skip for pipelines without a publish phase and a warning for custom backends without a precheck.
Checking static contracts
npm run typecheckThis runs TypeScript’s strict, no-emit JSDoc check over the source, CLI, and test files. Use it after changing src/types.d.ts, JSDoc type imports, or any JavaScript the checker covers. CI runs it before the tests. See Architecture and module boundaries for who owns those contracts and how to opt out.