{
  "chapter": "drive-exits",
  "title": "Drive end states and exit codes",
  "version": 2,
  "status": "stable",
  "fields": {
    "name": {
      "type": "string",
      "nullable": false,
      "required": true,
      "identifies": true,
      "comparedAs": "exact",
      "description": "The state's name as a drive-status.ts --json report's state field carries it, or the name of a class of states, a withdrawn code or an exit with no report."
    },
    "kind": {
      "type": "string",
      "nullable": false,
      "required": true,
      "identifies": false,
      "comparedAs": "exact",
      "description": "state, class-label, tombstone, driver-only or helper, as the code names its categories."
    },
    "exit": {
      "type": "integer",
      "nullable": false,
      "required": true,
      "identifies": true,
      "comparedAs": "exact",
      "description": "The code this entry holds in the drive's numbering."
    },
    "driveStatusExit": {
      "type": "integer",
      "nullable": true,
      "required": true,
      "identifies": false,
      "comparedAs": "exact",
      "description": "The code drive-status.ts exits with when it reports this state; null when it reports no such state. A class label (NOT_SETTLED) is never itself reported: its row holds the exit its member states share. A startup refusal that names no state (UNSUPPORTED_CLI's exit 2 from drive-status.ts) is not a report, so it stays null. Not part of identity: a withdrawn code keeps its row with this null."
    },
    "driveExit": {
      "type": "integer",
      "nullable": true,
      "required": true,
      "identifies": false,
      "comparedAs": "exact",
      "description": "The code drive.ts ends with for it; null when drive.ts never does."
    },
    "endsDrive": {
      "type": "boolean",
      "nullable": true,
      "required": true,
      "identifies": false,
      "comparedAs": "exact",
      "description": "Whether it ends the drive without the caller re-arming it on its own; null for a withdrawn code."
    },
    "meaning": {
      "type": "string",
      "nullable": false,
      "required": true,
      "identifies": false,
      "comparedAs": "prose",
      "description": "What it means to a reader that branches on it, and what that reader does next."
    },
    "stop": {
      "type": "string",
      "nullable": false,
      "required": false,
      "identifies": false,
      "comparedAs": "prose",
      "description": "For a state drive.ts ends with: the stop in one phrase, as its closing report's concluded field opens with it after the pull request's name."
    },
    "cause": {
      "type": "string",
      "nullable": false,
      "required": false,
      "identifies": false,
      "comparedAs": "exact",
      "description": "For a state drive.ts ends with short of its goal: the closing report's cause, one of the closed list of causes."
    },
    "nextOwner": {
      "type": "string",
      "nullable": false,
      "required": false,
      "identifies": false,
      "comparedAs": "exact",
      "description": "For a state drive.ts ends with: who takes the next step its closing report suggests, line, person or none."
    },
    "nextAct": {
      "type": "string",
      "nullable": false,
      "required": false,
      "identifies": false,
      "comparedAs": "exact",
      "description": "When the next step is a person's: what the person does, one of Merge, Decide, Authorize, Reply, Do or Investigate."
    },
    "nextStep": {
      "type": "string",
      "nullable": false,
      "required": false,
      "identifies": false,
      "comparedAs": "prose",
      "description": "For a state drive.ts ends with: the next step its closing report suggests."
    }
  },
  "values": [
    {
      "name": "ROUND_READY",
      "kind": "state",
      "exit": 0,
      "driveStatusExit": 0,
      "driveExit": null,
      "endsDrive": false,
      "meaning": "Work 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."
    },
    {
      "name": "INDETERMINATE",
      "kind": "state",
      "exit": 1,
      "driveStatusExit": 1,
      "driveExit": 1,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped on a failure; the drive's log says what failed",
      "cause": "tool-failed",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Read what the drive's log says failed, then re-arm the drive."
    },
    {
      "name": "UNSUPPORTED_CLI",
      "kind": "driver-only",
      "exit": 2,
      "driveStatusExit": null,
      "driveExit": 2,
      "endsDrive": true,
      "meaning": "A 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.",
      "stop": "stopped: a usage error, or a gh that cannot report the pull request",
      "cause": "environment",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Read the drive's message, fix the command line, the working tree or the gh install it names, then re-arm the drive."
    },
    {
      "name": "CONVERGED",
      "kind": "state",
      "exit": 3,
      "driveStatusExit": 3,
      "driveExit": 0,
      "endsDrive": true,
      "meaning": "Review 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.",
      "stop": "converged: review evidence covers its head and nothing is left open",
      "nextOwner": "person",
      "nextAct": "Merge",
      "nextStep": "Merge the pull request once its required checks pass."
    },
    {
      "name": "HEAD_LAG",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The 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."
    },
    {
      "name": "AWAITING_REVIEWER",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The reviewer has not reviewed this head yet. Wait, then read again."
    },
    {
      "name": "STALE_REVIEW",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The reviewer's latest review describes an earlier head. Wait for its review of this one, then read again."
    },
    {
      "name": "HEAD_MOVED",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The head or the base moved while the round was being judged, so nothing read about it holds. Read again."
    },
    {
      "name": "MERGEABILITY_UNKNOWN",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The forge has not yet worked out whether the pull request merges cleanly. Read again."
    },
    {
      "name": "POLL_BUDGET_SPENT",
      "kind": "state",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The 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."
    },
    {
      "name": "NOT_SETTLED",
      "kind": "class-label",
      "exit": 4,
      "driveStatusExit": 4,
      "driveExit": 4,
      "endsDrive": false,
      "meaning": "The 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).",
      "stop": "stopped before the pull request could be judged: it has not settled yet",
      "nextOwner": "line",
      "nextStep": "The line drives it again once the pull request settles."
    },
    {
      "name": "PR_NOT_OPEN",
      "kind": "state",
      "exit": 5,
      "driveStatusExit": 5,
      "driveExit": 5,
      "endsDrive": true,
      "meaning": "The pull request was merged or closed. Stop, and push nothing to it.",
      "stop": "ended: the pull request was merged or closed",
      "nextOwner": "none",
      "nextStep": "Nothing is left for the drive; a merge's follow-up settles what the merge owes."
    },
    {
      "name": "MAX_ROUNDS",
      "kind": "driver-only",
      "exit": 6,
      "driveStatusExit": null,
      "driveExit": 6,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "used its round budget without converging",
      "cause": "deadline",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Read 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."
    },
    {
      "name": "REVIEWER_FAILED",
      "kind": "state",
      "exit": 7,
      "driveStatusExit": 7,
      "driveExit": 7,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: the posting reviewer's check reported a failure",
      "cause": "tool-failed",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Look at the reviewer's failed check, then re-arm the drive."
    },
    {
      "name": "HITL_PARKED",
      "kind": "state",
      "exit": 8,
      "driveStatusExit": 8,
      "driveExit": 8,
      "endsDrive": true,
      "meaning": "Everything 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.",
      "stop": "parked: a decision waits for a person",
      "cause": "needs-person",
      "nextOwner": "person",
      "nextAct": "Decide",
      "nextStep": "Answer each parked decision (on its thread, or in a pull-request comment `answer <key>: …`), then re-arm the drive."
    },
    {
      "name": "PR_CONFLICTING",
      "kind": "state",
      "exit": 9,
      "driveStatusExit": 9,
      "driveExit": 9,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: it conflicts with its base and has nothing left that the drive can work (work held by a park waits for its answer)",
      "cause": "needs-person",
      "nextOwner": "person",
      "nextAct": "Do",
      "nextStep": "Merge the base in and resolve the conflicts, then re-arm the drive."
    },
    {
      "name": "RETIRED",
      "kind": "tombstone",
      "exit": 10,
      "driveStatusExit": null,
      "driveExit": null,
      "endsDrive": null,
      "meaning": "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."
    },
    {
      "name": "SESSION_LEASE_HELD",
      "kind": "state",
      "exit": 11,
      "driveStatusExit": 11,
      "driveExit": 11,
      "endsDrive": true,
      "meaning": "Another 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."
    },
    {
      "name": "SINGLE_INSTANCE_LOCK",
      "kind": "driver-only",
      "exit": 11,
      "driveStatusExit": null,
      "driveExit": 11,
      "endsDrive": true,
      "meaning": "Another driver already holds this pull request's or this working tree's lock, so the drive is already armed. Nothing was changed.",
      "stop": "refused: another driver already holds this pull request's or this working tree's lock",
      "cause": "refused",
      "nextOwner": "line",
      "nextStep": "The driver that holds the lock goes on driving."
    },
    {
      "name": "WORKTREE_UNCLEAN",
      "kind": "driver-only",
      "exit": 12,
      "driveStatusExit": null,
      "driveExit": 12,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "converged, but its worktree holds changes no round shipped",
      "cause": "environment",
      "nextOwner": "line",
      "nextStep": "A re-armed drive settles the working tree, then reports convergence."
    },
    {
      "name": "DRIVE_HELD_BY_OTHER_WORKTREE",
      "kind": "state",
      "exit": 13,
      "driveStatusExit": 13,
      "driveExit": 13,
      "endsDrive": true,
      "meaning": "Another live working tree, or a driver in another clone, is driving this pull request. Nothing was changed; that driver is the one to finish.",
      "stop": "refused: another working tree or clone drives this pull request",
      "cause": "refused",
      "nextOwner": "line",
      "nextStep": "The driver in the other working tree or clone finishes the drive."
    },
    {
      "name": "STALLED",
      "kind": "driver-only",
      "exit": 14,
      "driveStatusExit": null,
      "driveExit": 14,
      "endsDrive": true,
      "meaning": "Rounds stopped changing anything the drive can see. Read what the passes decided, and what the tree still holds, before re-arming.",
      "stop": "stalled: its passes changed nothing",
      "cause": "unknown",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Read what the passes decided and what the working tree holds, then re-arm the drive."
    },
    {
      "name": "PASS_DEADLINE",
      "kind": "driver-only",
      "exit": 15,
      "driveStatusExit": null,
      "driveExit": 15,
      "endsDrive": true,
      "meaning": "A 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.",
      "stop": "stopped: its passes kept running out of time",
      "cause": "deadline",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Check the working tree for the stopped pass's leftovers, then re-arm the drive."
    },
    {
      "name": "QUOTA_PARKED",
      "kind": "driver-only",
      "exit": 16,
      "driveStatusExit": null,
      "driveExit": 16,
      "endsDrive": true,
      "meaning": "A 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.",
      "stop": "stopped on a usage limit",
      "cause": "usage-limit",
      "nextOwner": "line",
      "nextStep": "The line re-arms the drive after the limit resets, or on an account the limit does not hold."
    },
    {
      "name": "PUSH_HELD",
      "kind": "helper",
      "exit": 17,
      "driveStatusExit": null,
      "driveExit": null,
      "endsDrive": false,
      "meaning": "A `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."
    },
    {
      "name": "MAILBOX_STOPPED",
      "kind": "driver-only",
      "exit": 18,
      "driveStatusExit": null,
      "driveExit": 18,
      "endsDrive": true,
      "meaning": "A 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.",
      "stop": "stopped: a person or a tool told it to stop through its mailbox",
      "nextOwner": "none",
      "nextStep": "Nothing until a person re-arms the drive."
    },
    {
      "name": "MAILBOX_PAUSE_TIMEOUT",
      "kind": "driver-only",
      "exit": 19,
      "driveStatusExit": null,
      "driveExit": 19,
      "endsDrive": true,
      "meaning": "A pause sent through the drive's mailbox lasted longer than the drive waits. Resume it, then re-arm.",
      "stop": "stopped: a pause sent through its mailbox outlasted its wait",
      "cause": "deadline",
      "nextOwner": "person",
      "nextAct": "Do",
      "nextStep": "Resume the drive through its mailbox, then re-arm it."
    },
    {
      "name": "TAKEN_OVER",
      "kind": "driver-only",
      "exit": 20,
      "driveStatusExit": null,
      "driveExit": 20,
      "endsDrive": true,
      "meaning": "Another clone took the drive over and drives it now. Nothing to recover here.",
      "stop": "stopped: another clone took the drive over",
      "nextOwner": "line",
      "nextStep": "The clone that took the drive over drives it now."
    },
    {
      "name": "CI_REPAIR_SPENT",
      "kind": "driver-only",
      "exit": 21,
      "driveStatusExit": null,
      "driveExit": 21,
      "endsDrive": true,
      "meaning": "The diagnosing CI-repair session could not complete the repair on the failing head. The handoff carries its diagnosis and tracker issue when available.",
      "stop": "stopped: the diagnosing CI-repair session could not complete the repair",
      "cause": "tool-failed",
      "nextOwner": "person",
      "nextAct": "Investigate",
      "nextStep": "Read the diagnosing session’s handoff and address the blocker it recorded."
    },
    {
      "name": "REVIEW_SKIPPED",
      "kind": "state",
      "exit": 22,
      "driveStatusExit": 22,
      "driveExit": 22,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: the reviewer skipped its head and will not review it",
      "cause": "environment",
      "nextOwner": "person",
      "nextAct": "Do",
      "nextStep": "Resume the reviewer or have this head reviewed, then re-arm the drive."
    },
    {
      "name": "CI_INFRA_PERSISTED",
      "kind": "driver-only",
      "exit": 23,
      "driveStatusExit": null,
      "driveExit": 23,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: checks kept failing on the CI service's own infrastructure",
      "cause": "environment",
      "nextOwner": "line",
      "nextStep": "The line re-arms the drive once the CI service recovers."
    },
    {
      "name": "FORGE_RATE_LIMITED",
      "kind": "state",
      "exit": 24,
      "driveStatusExit": 24,
      "driveExit": 24,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: the forge's rate limit for its credential is spent",
      "cause": "environment",
      "nextOwner": "line",
      "nextStep": "The line drives it again once the forge's rate limit resets."
    },
    {
      "name": "CHECK_RUNS_UNREADABLE",
      "kind": "state",
      "exit": 25,
      "driveStatusExit": 25,
      "driveExit": 25,
      "endsDrive": true,
      "meaning": "The 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.",
      "stop": "stopped: its head's check-runs listing could not be read whole",
      "cause": "tool-failed",
      "nextOwner": "line",
      "nextStep": "The line re-drives it once for this head; a second such stop on the head is a systematic read failure for a person."
    }
  ]
}
