jig-harness/jig

Drive end states and exit codes

stable · Version 2

A drive (the loop that works a pull request’s review rounds until it is ready to merge) reports how a round, or the whole drive, ended in two places. The round script, drive-status.ts, exits with a code and, with --json, writes a report whose state field names the terminal state. The driver, drive.ts, exits with a code and writes no report. The two scripts share one numbering but not one meaning for every number: drive-status.ts exits 0 for ROUND_READY, while drive.ts exits 0 for CONVERGED, so that a harness reading a zero exit as success reads a converged drive as one. A dispatcher reads drive.ts’s column; a program that runs a round itself reads drive-status.ts’s.

Several states share a code. A drive-status.ts report tells them apart by its state; a drive.ts exit is only its code, and states that share one are not told apart. A reader that meets a code this chapter does not list treats the drive as failed and does not re-arm it. A withdrawn code stays listed as a tombstone and is never given another meaning.

The kinds are the code’s own categories: a state a report can carry; a class-label, the name of a family of states that share a code; a tombstone, a withdrawn code; a driver-only exit, which drive.ts returns with no report; and a helper exit, which one of the drive’s helper scripts returns and neither drive-status.ts nor drive.ts ends with. “Ends the drive” says whether the drive stops without the caller re-arming it on its own.

How a drive reaches each state, and the evidence behind it: drive-pr’s terminal states. The same values, for a program in any language: data/drive-exits.json.

When a converged pull request moves

A converged pull request waits for a person to merge it. A clean merge of the base can carry forward the review of its unchanged contribution. The dispatcher holds the re-drive while required checks on the new head are pending. Once those checks pass, it refreshes the ledger and merge-ready claim for the new head, and the board pins the merge command to that head. The refresh runs without review rounds or commits.

A changed contribution or an unreadable proof takes the ordinary stale re-drive path. A conflict re-drives once for the pull request head and base head, then goes to a person if it remains at that pair. An explicit rearm also starts a drive. Whenever a drive spends its round budget (MAX_ROUNDS, exit 6), the ended row hands it to a person to investigate using the closing-report instruction below. A pull request that spends its round ceiling (drive.max_total_rounds) or its wall-clock cap (drive.max_wall_clock_hours), or whose rounds diverge, stops HITL_PARKED (exit 8) on a round-ceiling or divergence-stop decision: a rearm grants no rounds past the ceiling, and only a person’s override raises it.

When the drive parks itself on structural churn

A drive’s head can keep moving while it converges on nothing, so the STALLED stop never fires. Its structural-churn brake stops that churn. After a counting drive-status.ts gate that found work, before the round’s pass runs, the gate judges the rounds recorded since the brake last parked. It parks the drive when one file drew findings in each of the last drive.churn_rounds consecutive rounds (4 by default, 0 turns the brake off), none of those rounds carrying a high or blocker finding, and the file was rewritten between each; or when a file’s content at one round’s head came back at a later round’s head after a different one in between, among the rounds in which the file drew a finding, whatever the severity. A round with a high or blocker finding never counts toward the same-file streak.

The park carries a framed decision under the structural-churn decision class, keyed structural-churn-r<round>: the question names the files and the rounds, and the options are to ship as is and defer the rest, to constrain the scope, or to continue driving. The gate then reports HITL_PARKED (exit 8). While that park stands, every gate reports HITL_PARKED, even with work left, unless the reconciliation guard degrades that read to INDETERMINATE (a status read that did not complete the replied-thread sweep, --no-count included); the park stays live either way. On a pull request that conflicts with its base, those gates report PR_CONFLICTING (exit 9) instead, as they do before any park. If the round’s evidence or the park could not be recorded, or a trip meets a replied-thread sweep that did not complete, the gate reports INDETERMINATE (exit 1). That ends drive.ts; a person re-arms the drive once the failure is addressed. A repository’s autonomy.park_classes cannot remove the class.

The states and exits of drive-status.ts and drive.ts

StateKinddrive-status.ts exitsdrive.ts exitsEnds the driveMeaning
ROUND_READYstate0—noWork is left for this round: open review threads or unanswered summary findings. The caller runs a pass; drive.ts runs it itself and never ends with this state.
INDETERMINATEstate11yesThe state could not be read, or a step failed: drive.ts also ends with it when a pass fails. A probe stop marked as a read failure keeps the read diagnostic, and the dispatcher re-drives it once per pull-request head. A second such stop on the same head needs a person.
UNSUPPORTED_CLIdriver-only—2yesA prerequisite is missing. drive.ts exits 2, with no state report (a dispatcher closing report may still be written), when it refuses to start: a command line it cannot use, or a working tree or pull request it cannot drive as they stand (uncommitted changes, commits the pull request does not have, a head in a fork). It prints which. drive-status.ts also exits 2, before there is a pull request to report on and naming no state, on arguments it cannot use and when its startup cannot resolve the repository or the pull request selector, which can be a network or authentication failure rather than an argument error. The same exit can end a drive already running: when a later round’s drive-status.ts fails that way, the driver passes the 2 on, after earlier rounds’ passes may have changed the tree or the pull request, so read the handoff file before assuming no work occurred.
CONVERGEDstate30yesReview work is settled: either no AI reviewer is configured, the reviewer reviewed this exact head, the draft-only skip is provisional until the PR is marked Ready and reviewed, an earlier reviewed head has the same pull-request diff after a current-head skip notice, or a current-head skip notice and configured excluded-path proof establish there is nothing to review. Nothing is left open. drive.ts exits 0 only after its own working tree is clean and its exact-head required CI proof passes; convergence alone does not make the pull request ready to merge.
HEAD_LAGstate44noThe pull request’s head on the forge and the local head disagree, and the reason says how: a local head ahead with no record of a push (push it through guarded-push.ts), a push the forge does not show yet (wait), a tree behind (update it), or diverged history (reconcile it). Then read again.
AWAITING_REVIEWERstate44noThe reviewer has not reviewed this head yet. Wait, then read again.
STALE_REVIEWstate44noThe reviewer’s latest review describes an earlier head. Wait for its review of this one, then read again.
HEAD_MOVEDstate44noThe head or the base moved while the round was being judged, so nothing read about it holds. Read again.
MERGEABILITY_UNKNOWNstate44noThe forge has not yet worked out whether the pull request merges cleanly. Read again.
POLL_BUDGET_SPENTstate44noThe poll budget ended before the next iteration or before a pull-request read could start. The probe reports how long it waited. A request that was sent and failed retains its read failure.
NOT_SETTLEDclass-label44noThe name of every state that shares exit 4: the pull request is not ready to judge yet. Never itself a state; the caller waits and runs the drive again. drive.ts also exits 4 after the review converged when another driver holds the mark-Ready lease, when the head moved, the CI hold label changed or the forge could not be read as the hold was released, when a read of the cancelled-run recovery kept failing in a way waiting can clear, when no fresh result of a required check came in time (where a skipped or cancelled check means waiting cannot help: re-run the check, then re-arm), and when the drive keeps a draft that the reviewer skips (mark it Ready, then re-arm).
PR_NOT_OPENstate55yesThe pull request was merged or closed. Stop, and push nothing to it.
MAX_ROUNDSdriver-only—6yesThe drive spent its round budget (--max-rounds, with any rounds a re-arm granted) without converging. Read the handoff file before re-arming: a re-arm a person asks for grants one more round budget, never past the pull request’s round ceiling (drive.max_total_rounds), whose spending parks the drive instead.
REVIEWER_FAILEDstate77yesThe reviewer’s check failed or says the review did not complete. The drive stops. The dispatcher can retry a neutral check that reports an incomplete review and escalate repeated stops on that head.
HITL_PARKEDstate88yesEverything left waits on a person’s decision, each framed on its thread or, for a park with no thread, as a pull-request comment answer <key>, or the drive parked itself on structural churn (class structural-churn), a park that holds even live work. The drive does not wake itself: once every one is answered, re-arm it.
PR_CONFLICTINGstate99yesThe pull request conflicts with its base and has no other workable finding, or the drive parked itself on structural churn on a conflicting pull request, whose live work then waits for that answer; drive.ts ends with it once its conflict-repair passes are spent. Merge the base in, then re-arm.
RETIREDtombstone———Withdrawn: it once stopped a drive on a draft pull request, which is now driven like any other. Never exited, and never given another meaning.
SESSION_LEASE_HELDstate1111yesAnother live session in this working tree holds the drive’s lease for this pull request. Nothing was changed: wait for it, or clear its lease once its process is gone.
SINGLE_INSTANCE_LOCKdriver-only—11yesAnother driver already holds this pull request’s or this working tree’s lock, so the drive is already armed. Nothing was changed.
WORKTREE_UNCLEANdriver-only—12yesThe working tree holds work no round shipped: uncommitted edits, an unfinished git operation or a commit nobody reviewed. Settle it, then re-arm in this tree.
DRIVE_HELD_BY_OTHER_WORKTREEstate1313yesAnother live working tree, or a driver in another clone, is driving this pull request. Nothing was changed; that driver is the one to finish.
STALLEDdriver-only—14yesRounds stopped changing anything the drive can see. Read what the passes decided, and what the tree still holds, before re-arming.
PASS_DEADLINEdriver-only—15yesA pass ran past its deadline and was stopped more often than the drive restarts one. Check the tree for the stopped pass’s leftovers before re-arming.
QUOTA_PARKEDdriver-only—16yesA pass hit an agent subscription’s usage limit that does not reset soon. Re-arm after the reset, or from a session that bills another account. drive.ts also exits 16 when it refuses such a re-arm while the limit holds, from a session that bills the same account or one it cannot tell.
MAILBOX_STOPPEDdriver-only—18yesA person or a tool told the drive to stop through its mailbox, and it stopped at a round boundary. A stop that names this driver’s generation ends this driver alone; one that names none stops every later driver too, so resume it before re-arming.
MAILBOX_PAUSE_TIMEOUTdriver-only—19yesA pause sent through the drive’s mailbox lasted longer than the drive waits. Resume it, then re-arm.
TAKEN_OVERdriver-only—20yesAnother clone took the drive over and drives it now. Nothing to recover here.
CI_REPAIR_SPENTdriver-only—21yesThe diagnosing CI-repair session could not complete the repair on the failing head. The handoff carries its diagnosis and tracker issue when available.
REVIEW_SKIPPEDstate2222yesThe reviewer reported a skip or pause for this Ready PR head. An earlier review does not cover it, a skip notice has no stamp and Jig cannot verify that the diff is empty after the configured exclusions, or a review-object check reports Review paused… or Review skipped…; a draft-only skip instead remains provisional while the drive marks the PR Ready and waits for review. A person resumes the reviewer or has this head reviewed, then re-arms.
CI_INFRA_PERSISTEDdriver-only—23yesThe review converged, but checks kept failing on the CI service’s own infrastructure after the drive re-ran them. Nothing in the code needs repair; re-arm once the service recovers.
FORGE_RATE_LIMITEDstate2424yesThe forge’s rate limit for the drive’s credential is spent: nothing more is sent before it resets. The report names the reset (rateLimit.until). The driver then waits out a reset within its bound (DRIVE_PR_RATE_LIMIT_WAIT) and goes on, or stops on one further off. Re-arm after the reset.
CHECK_RUNS_UNREADABLEstate2525yesThe head’s check-runs listing could not be read whole: a page or the whole listing ran out of time, or it has more pages than a read may take. The reason names the pages read. Nothing about the pull request was judged; run the drive again, and treat a second such stop on the same head as a systematic read failure.

The exits the drive’s helper scripts take from the same numbering

Most of the drive’s helper scripts number their exits on their own. An exit a caller could mistake for one of the drive’s takes a code from this numbering instead, and is listed here so that no state or exit is given it.

StateKindExitExited byEnds the driveMeaning
PUSH_HELDhelper17guarded-push.ts and push-hold-recheck.ts (PUSH_HELD_EXIT)noA hold-push directive in the drive’s mailbox is in force, so nothing was pushed; the pre-push hook’s recheck exits with it to stop a push already under way. Not an end state: clear the hold, then push again.

What drive.ts’s closing report says at each exit

When a dispatcher runs a drive, drive.ts writes a closing report when it stops (closing-report/v1, written by the driver). Its concluded opens with the stop’s text, after the pull request’s name and before the exit, followed by what the last round report of the same launch concluded; its cause and suggested_next are the ones this table gives the exit. A park’s text names the first parked decision’s question and how many more wait, and a usage-limit stop’s names the limit and when it resets. A pass failure (exit 1) whose usage-limit scan was cut short before it found a wall says so in its text, and has cause unknown and a next step that looks for a usage-limit notice first: a limit the scan did not reach is not a tool failure. An exit this table does not list has cause unknown and a next step a person investigates. A cause is absent where the drive did not fall short of its goal.

Statedrive.ts exitsThe stop’s textcauseNext: ownerNext: actNext: step
INDETERMINATE1stopped on a failure; the drive’s log says what failedtool-failedpersonInvestigateRead what the drive’s log says failed, then re-arm the drive.
UNSUPPORTED_CLI2stopped: a usage error, or a gh that cannot report the pull requestenvironmentpersonInvestigateRead the drive’s message, fix the command line, the working tree or the gh install it names, then re-arm the drive.
CONVERGED0converged: review evidence covers its head and nothing is left open—personMergeMerge the pull request once its required checks pass.
NOT_SETTLED4stopped before the pull request could be judged: it has not settled yet—line—The line drives it again once the pull request settles.
PR_NOT_OPEN5ended: the pull request was merged or closed—none—Nothing is left for the drive; a merge’s follow-up settles what the merge owes.
MAX_ROUNDS6used its round budget without convergingdeadlinepersonInvestigateRead the handoff file for what keeps the review open, then re-arm the drive, which grants it one more round budget (jig send drive@<repo> <PR> rearm, or --rearm-budget on the arm command), or take the work over.
REVIEWER_FAILED7stopped: the posting reviewer’s check reported a failuretool-failedpersonInvestigateLook at the reviewer’s failed check, then re-arm the drive.
HITL_PARKED8parked: a decision waits for a personneeds-personpersonDecideAnswer each parked decision (on its thread, or in a pull-request comment answer <key>: …), then re-arm the drive.
PR_CONFLICTING9stopped: it conflicts with its base and has nothing left that the drive can work (work held by a park waits for its answer)needs-personpersonDoMerge the base in and resolve the conflicts, then re-arm the drive.
SINGLE_INSTANCE_LOCK11refused: another driver already holds this pull request’s or this working tree’s lockrefusedline—The driver that holds the lock goes on driving.
WORKTREE_UNCLEAN12converged, but its worktree holds changes no round shippedenvironmentline—A re-armed drive settles the working tree, then reports convergence.
DRIVE_HELD_BY_OTHER_WORKTREE13refused: another working tree or clone drives this pull requestrefusedline—The driver in the other working tree or clone finishes the drive.
STALLED14stalled: its passes changed nothingunknownpersonInvestigateRead what the passes decided and what the working tree holds, then re-arm the drive.
PASS_DEADLINE15stopped: its passes kept running out of timedeadlinepersonInvestigateCheck the working tree for the stopped pass’s leftovers, then re-arm the drive.
QUOTA_PARKED16stopped on a usage limitusage-limitline—The line re-arms the drive after the limit resets, or on an account the limit does not hold.
MAILBOX_STOPPED18stopped: a person or a tool told it to stop through its mailbox—none—Nothing until a person re-arms the drive.
MAILBOX_PAUSE_TIMEOUT19stopped: a pause sent through its mailbox outlasted its waitdeadlinepersonDoResume the drive through its mailbox, then re-arm it.
TAKEN_OVER20stopped: another clone took the drive over—line—The clone that took the drive over drives it now.
CI_REPAIR_SPENT21stopped: the diagnosing CI-repair session could not complete the repairtool-failedpersonInvestigateRead the diagnosing session’s handoff and address the blocker it recorded.
REVIEW_SKIPPED22stopped: the reviewer skipped its head and will not review itenvironmentpersonDoResume the reviewer or have this head reviewed, then re-arm the drive.
CI_INFRA_PERSISTED23stopped: checks kept failing on the CI service’s own infrastructureenvironmentline—The line re-arms the drive once the CI service recovers.
FORGE_RATE_LIMITED24stopped: the forge’s rate limit for its credential is spentenvironmentline—The line drives it again once the forge’s rate limit resets.
CHECK_RUNS_UNREADABLE25stopped: its head’s check-runs listing could not be read wholetool-failedline—The line re-drives it once for this head; a second such stop on the head is a systematic read failure for a person.

Machine-readable files

Source: plugin/protocol/drive-exits.md