dev-loops

State atlas

This page holds 8 diagrams.

dev-loops drives every pull request through closed, deterministic state machines. Workflow control lives in the graph; agent judgment enters only as bounded, explicit inputs, never as hidden orchestration. Exactly one state applies at a time, and each state exposes the legal transitions out of it.

Every diagram on this page except one is generated at site-build time from the code's own exported tables. They cannot drift from the code: change a transition table and this page changes with it. One diagram (the release pipeline) is authored from a documented contract that has no single code table.

The state names are not labels for a picture — they are the literal contract identifiers that appear in logs, handoff envelopes, and gate artifacts. Nodes are coloured by role: active / in-progress steps the loop advances itself, waiting-on-external states that block on something outside the loop (CI, Copilot, a human), blocked / fail-closed states that stop or reconcile rather than guess, and terminal states where the slice is complete.

Public dev-loop gate hub

Diagram generated from packages/core/src/loop/public-dev-loop-routing-contract.mjs — PUBLIC_DEV_LOOP_GATE_CONTRACT

The single public entrypoint, dev-loop, resolves the canonical current state to exactly one of 13 gates. Each gate carries a closed route-kind — route to an internal strategy, stop for a human decision or terminal work, or wait on an external signal — and the internal strategy it selects.

This is the table the startup resolver walks on every invocation: it is not a one-time setup step but the routing decision re-made each time. Ambiguous, conflicting, or unsupported state does not get a guessed route — it fails closed to fail_closed_reconcile. Edge labels below are the route-kind; each node names the gate and the strategy it selects.

flowchart LR router(["dev-loop router"]) router -->|stop| stop_blocked_or_not_authorized["stop_blocked_or_not_authorized — none"] router -->|stop| stop_done_terminal["stop_done_terminal — none"] router -->|route| final_approval["final_approval — final_approval"] router -->|stop| waiting_for_merge_authorization["waiting_for_merge_authorization — none"] router -->|wait| wait_watch["wait_watch — wait_watch"] router -->|route| local_implementation["local_implementation — local_implementation"] router -->|route| issue_intake["issue_intake — issue_intake"] router -->|route| external_pr_followup["external_pr_followup — external_pr_followup"] router -->|route| reviewer_fixer["reviewer_fixer — reviewer_fixer"] router -->|route| copilot_pr_followup["copilot_pr_followup — copilot_pr_followup"] router -->|route| ui_review["ui_review — ui_review"] router -->|route| review["review — review"] router -->|needs_reconcile| fail_closed_reconcile["fail_closed_reconcile — none"] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class stop_blocked_or_not_authorized stop class stop_done_terminal term class final_approval act class waiting_for_merge_authorization stop class wait_watch wait class local_implementation act class issue_intake act class external_pr_followup act class reviewer_fixer act class copilot_pr_followup act class ui_review act class review act class fail_closed_reconcile stop

Outer conductor routing

Diagram generated from packages/core/src/loop/conductor-routing.mjs — OUTER_STATE + OUTER_TRANSITIONS

Above the family-local machines, the outer conductor derives one routing outcome per tick: continue waiting, hand off to the Copilot loop, hand off to the reviewer loop, or stay with a live owner. The four active outcomes form a fully-connected core by design — routing is stateless per tick, so each tick re-derives the outcome from fresh detector state rather than following a remembered path.

The three remaining outcomes — stop_needs_human, done_terminal, and needs_reconcile — are absorbing: once reached, the outer loop does not route onward on its own.

stateDiagram-v2 continue_current_wait --> continue_current_wait continue_current_wait --> handoff_to_copilot_loop continue_current_wait --> handoff_to_reviewer_loop continue_current_wait --> stay_with_current_live_owner continue_current_wait --> stop_needs_human continue_current_wait --> done_terminal continue_current_wait --> needs_reconcile handoff_to_copilot_loop --> continue_current_wait handoff_to_copilot_loop --> handoff_to_copilot_loop handoff_to_copilot_loop --> handoff_to_reviewer_loop handoff_to_copilot_loop --> stay_with_current_live_owner handoff_to_copilot_loop --> stop_needs_human handoff_to_copilot_loop --> done_terminal handoff_to_copilot_loop --> needs_reconcile handoff_to_reviewer_loop --> continue_current_wait handoff_to_reviewer_loop --> handoff_to_copilot_loop handoff_to_reviewer_loop --> handoff_to_reviewer_loop handoff_to_reviewer_loop --> stay_with_current_live_owner handoff_to_reviewer_loop --> stop_needs_human handoff_to_reviewer_loop --> done_terminal handoff_to_reviewer_loop --> needs_reconcile stay_with_current_live_owner --> continue_current_wait stay_with_current_live_owner --> handoff_to_copilot_loop stay_with_current_live_owner --> handoff_to_reviewer_loop stay_with_current_live_owner --> stay_with_current_live_owner stay_with_current_live_owner --> stop_needs_human stay_with_current_live_owner --> done_terminal stay_with_current_live_owner --> needs_reconcile stop_needs_human --> [*] done_terminal --> [*] needs_reconcile --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class continue_current_wait act class handoff_to_copilot_loop act class handoff_to_reviewer_loop act class stay_with_current_live_owner act class stop_needs_human stop class done_terminal term class needs_reconcile stop

PR lifecycle contract

Diagram generated from packages/core/src/loop/pr-lifecycle.mjs — PR_LIFECYCLE_STATES + PR_LIFECYCLE_TRANSITIONS

One PR moves through a stable thirteen-state vocabulary from draft to merge. These identifiers are part of the contract surface even as the helper implementations around them change. Two local gates guard the path — draft_gate (draft to ready-for-review) and pre_approval_gate (before final approval) — and both are fail-closed fan-out reviews that run independent angle chains and must produce clean current-head evidence to pass.

All gate evidence is per-head: a new push re-opens the gates, and ready-to-draft resets the lifecycle back into draft-stage gating. A conflicted head detours through merge_conflict_resolution before any further gate progression — a conflicted PR is never treated as approval- or merge-ready, even if older gate comments and CI were green. Human approval and merge are explicit external waits, not hidden remediation states.

stateDiagram-v2 draft_local_review_gate --> draft_local_remediation draft_local_review_gate --> ready_state_needs_copilot_request draft_local_review_gate --> stopped_needs_user_decision draft_local_remediation --> draft_local_review_gate ready_state_needs_copilot_request --> waiting_for_copilot_review ready_state_needs_copilot_request --> stopped_needs_user_decision waiting_for_copilot_review --> copilot_feedback_remediation copilot_feedback_remediation --> copilot_reply_resolve_pending copilot_reply_resolve_pending --> ready_state_needs_copilot_request waiting_for_copilot_review --> merge_conflict_resolution merge_conflict_resolution --> waiting_for_copilot_review waiting_for_copilot_review --> final_local_preapproval_gate final_local_preapproval_gate --> final_gate_remediation final_local_preapproval_gate --> waiting_for_human_pr_approval final_gate_remediation --> final_local_preapproval_gate waiting_for_human_pr_approval --> waiting_for_merge waiting_for_human_pr_approval --> draft_local_review_gate waiting_for_merge --> terminal_slice_complete terminal_slice_complete --> [*] stopped_needs_user_decision --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class draft_local_review_gate act class draft_local_remediation act class ready_state_needs_copilot_request act class waiting_for_copilot_review wait class copilot_feedback_remediation act class copilot_reply_resolve_pending act class merge_conflict_resolution stop class final_local_preapproval_gate act class final_gate_remediation act class waiting_for_human_pr_approval wait class waiting_for_merge wait class terminal_slice_complete term class stopped_needs_user_decision stop

Copilot review/fix loop

Diagram generated from packages/core/src/loop/copilot-loop-state.mjs — STATE + TRANSITIONS

The inner loop requests Copilot review, watches for it, and remediates — all scoped to one PR head. Unresolved feedback always routes into fix and reply/resolve, never into a wait: the loop does not sleep on a PR that has open threads. Only once threads are resolved and CI is settled does it re-request or converge.

Re-requesting is bounded by maxCopilotRounds. At the cap a clean PR routes to round_cap_clean_fallback (proceed to the pre-approval gate) rather than dead-ending on a review that can never come, while a not-clean PR hard-stops at round_cap_reached; a significant head change is the escape hatch that re-opens auto re-request. A separate low-signal heuristic can end the loop early at low_signal_converged when extra rounds yield only minimal actionable feedback. These cap and convergence states are the ones older prose graphs omit.

stateDiagram-v2 no_pr --> [*] pr_draft --> pr_ready_no_feedback pr_ready_no_feedback --> waiting_for_copilot_review waiting_for_copilot_review --> unresolved_feedback_present waiting_for_copilot_review --> ready_to_rerequest_review waiting_for_copilot_review --> waiting_for_ci unresolved_feedback_present --> already_fixed_needs_reply_resolve unresolved_feedback_present --> unresolved_feedback_present already_fixed_needs_reply_resolve --> ready_to_rerequest_review ready_to_rerequest_review --> waiting_for_copilot_review ready_to_rerequest_review --> review_request_unavailable ready_to_rerequest_review --> done low_signal_converged --> [*] review_request_unavailable --> [*] waiting_for_ci --> pr_ready_no_feedback waiting_for_ci --> ready_to_rerequest_review waiting_for_ci --> blocked_needs_user_decision blocked_needs_user_decision --> [*] done --> [*] round_cap_reached --> [*] round_cap_clean_fallback --> [*] internal_tooling_direct_gate --> done copilot_unavailable --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class no_pr act class pr_draft act class pr_ready_no_feedback act class waiting_for_copilot_review wait class unresolved_feedback_present act class already_fixed_needs_reply_resolve act class ready_to_rerequest_review act class low_signal_converged act class review_request_unavailable stop class waiting_for_ci wait class blocked_needs_user_decision stop class done term class round_cap_reached act class round_cap_clean_fallback act class internal_tooling_direct_gate act class copilot_unavailable stop

Reviewer loop

Diagram generated from packages/core/src/loop/reviewer-loop-state.mjs — REVIEWER_STATE + REVIEWER_TRANSITIONS

The reviewer side plans a bounded set of review angles, runs them in parallel, merges the results into one draft review, and posts it — then submits. The external-wait boundaries are explicitly named states (waiting_for_review_request, waiting_for_user_submit) rather than implicit pauses, so a wait on a human is always a distinct, inspectable state.

If the reviewed head goes stale, review_invalidated discards the pending draft and re-enters at review_requested so the review is always produced for the current head.

stateDiagram-v2 waiting_for_review_request --> review_requested waiting_for_review_request --> submitted_review waiting_for_review_request --> blocked_needs_user_decision review_requested --> determine_review_plan review_requested --> submitted_review review_requested --> blocked_needs_user_decision determine_review_plan --> reviews_running determine_review_plan --> submitted_review determine_review_plan --> blocked_needs_user_decision reviews_running --> merge_results reviews_running --> submitted_review reviews_running --> blocked_needs_user_decision merge_results --> draft_review_ready merge_results --> submitted_review merge_results --> blocked_needs_user_decision draft_review_ready --> draft_review_posted draft_review_ready --> submitted_review draft_review_ready --> blocked_needs_user_decision draft_review_posted --> waiting_for_user_submit draft_review_posted --> review_invalidated draft_review_posted --> submitted_review draft_review_posted --> blocked_needs_user_decision waiting_for_user_submit --> submitted_review waiting_for_user_submit --> review_invalidated waiting_for_user_submit --> blocked_needs_user_decision submitted_review --> re_review_needed submitted_review --> review_requested submitted_review --> waiting_for_review_request submitted_review --> blocked_needs_user_decision re_review_needed --> review_requested re_review_needed --> submitted_review re_review_needed --> waiting_for_review_request re_review_needed --> blocked_needs_user_decision waiting_for_author_followup --> submitted_review waiting_for_author_followup --> review_requested waiting_for_author_followup --> waiting_for_review_request waiting_for_re_request --> review_requested waiting_for_re_request --> submitted_review review_invalidated --> review_requested review_invalidated --> blocked_needs_user_decision blocked_needs_user_decision --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class waiting_for_review_request wait class review_requested act class determine_review_plan act class reviews_running act class merge_results act class draft_review_ready act class draft_review_posted act class waiting_for_user_submit wait class submitted_review act class re_review_needed act class waiting_for_author_followup wait class waiting_for_re_request wait class review_invalidated stop class blocked_needs_user_decision stop

Refinement / grill sub-loop

Diagram generated from packages/core/src/loop/refinement-grill-state.mjs — GRILL_STATE + GRILL_TRANSITIONS

Before a slice enters the loop, the refinement grill runs as a closed, deterministic sub-loop over the issue, PR body, or plan file. It loads the target, detects spec gaps, and iterates detect-gaps to answer to synthesize to re-grill until it reaches a fixed point. The iteration lives entirely in the transition graph; the LLM answer and synthesis enter only as a bounded input consumed at the await_answers state, never as hidden orchestration in a coordinator script.

Write-back synthesizes only sharpened Acceptance criteria, Definition of done, and Non-goals into the body — the raw Q&A transcript never lands in the artifact. An uncitable gap stops honestly at needs_human_handoff naming the question rather than fabricating an answer to force convergence, and any load or parse failure fails closed to blocked_needs_user_decision.

stateDiagram-v2 load_target --> detect_gaps load_target --> blocked_needs_user_decision detect_gaps --> await_answers detect_gaps --> grill_clean detect_gaps --> needs_human_handoff detect_gaps --> blocked_needs_user_decision await_answers --> synthesize await_answers --> needs_human_handoff await_answers --> blocked_needs_user_decision synthesize --> re_grill synthesize --> blocked_needs_user_decision re_grill --> detect_gaps re_grill --> grill_clean re_grill --> needs_human_handoff re_grill --> blocked_needs_user_decision grill_clean --> [*] needs_human_handoff --> [*] blocked_needs_user_decision --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class load_target act class detect_gaps act class await_answers act class synthesize act class re_grill act class grill_clean act class needs_human_handoff stop class blocked_needs_user_decision stop

Gate fix loop

Diagram generated from packages/core/src/loop/fix-loop-state.mjs — FIX_LOOP_STATE + FIX_LOOP_TRANSITIONS

One fix sequence for a PR head is one state machine: the fixer commits and pushes a candidate in the full phase, CI settles on the pushed candidate, and a fixer-written handoff, verified at the candidate or carried to a descendant, closes the sequence. Every fail-closed state has a sanctioned exit, and a foreign commit (developer, CI fix, base merge) enters the head_moved state, which exits to a full gate round.

A full gate round on the live head is the fallback authority and always terminal. Transitions that later slices of issue 2787 implement are tracked as known gaps in the conformance harness.

stateDiagram-v2 act_pending --> full_emitted full_emitted --> pushed full_emitted --> no_commit full_emitted --> head_moved no_commit --> full_gate_round pushed --> ci_green pushed --> ci_red pushed --> head_moved ci_red --> act_pending ci_red --> head_moved ci_green --> disposition_complete ci_green --> delivery_incomplete ci_green --> head_moved delivery_incomplete --> disposition_complete delivery_incomplete --> full_gate_round delivery_incomplete --> head_moved disposition_complete --> full_gate_round disposition_complete --> head_moved head_moved --> full_gate_round head_moved --> disposition_complete full_gate_round --> [*] stopped --> [*] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class act_pending act class full_emitted act class no_commit act class pushed act class ci_red act class ci_green act class delivery_incomplete term class disposition_complete term class head_moved act class full_gate_round act class stopped stop

Release pipeline

Diagram generated from .github/workflows/release.yml (documented workflow)

Cutting a release is milestone-terminal. The version-bump PR itself goes through the same full gate pipeline as any other change — there is no privileged path to main. Pushing a v* tag is the only manual release step.

Everything after the tag fails closed: the release commit must be an ancestor of origin/main, the shipped @dev-loops/core dependency must be in major.minor lockstep with the release, an existing release short-circuits idempotently, and the CHANGELOG section must extract before gh release create runs. Any failed check stops the release rather than publishing a partial one.

flowchart TD push_tag(["push v* tag"]) push_tag --> ancestry{"commit is ancestor of origin/main?"} ancestry -->|no| stop_not_on_main["stopped: not on main"] ancestry -->|yes| lockstep{"@dev-loops/core dep in lockstep?"} lockstep -->|no| stop_core_mismatch["stopped: core version mismatch"] lockstep -->|yes| exists{"release already exists?"} exists -->|yes| done_idempotent_skip["done: idempotent skip"] exists -->|no| changelog{"CHANGELOG section extractable?"} changelog -->|no| stop_changelog_missing["stopped: changelog missing"] changelog -->|yes| create["gh release create --verify-tag"] create --> done_release_published["done: release published, fires npm-publish"] classDef act fill:#171532,stroke:#a78bfa,stroke-width:1px,color:#e5e7eb; classDef wait fill:#0f1d33,stroke:#93c5fd,stroke-width:1px,color:#e5e7eb; classDef term fill:#1c1a3a,stroke:#ddd6fe,stroke-width:1.5px,color:#f8fafc; classDef stop fill:#1a2233,stroke:#94a3b8,stroke-width:1px,color:#cbd5e1,stroke-dasharray:4 2; class push_tag act class ancestry act class lockstep act class exists act class changelog act class create act class done_release_published term class done_idempotent_skip term class stop_not_on_main stop class stop_core_mismatch stop class stop_changelog_missing stop