[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71E1QPJ3DBV6KWNWWHNRE8H":3,"skill-same:01M71E1QPJ3DBV6KWNWWHNRE8H":139},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M71E1QPJ3DBV6KWNWWHNRE8H","run-project",null,"Execute a project's PRD stories through HQ worker lanes that survive compaction. Interactive mode runs in the parent.","indigoai-us\u002Fhq-core","indigoai-us","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F122242446?v=4","01M71DTQ5NGD10GT1Z7E6XKWC5","HQ","01M71DTQ6BKSYYBNC9RAKT3YDK",95,"MIT","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"run","run project","project","work","sleep","create","dry","Bash","workflow","ralph","MCP","worker","mkdir","mode","pipeline","runner","show","mesh","bind","ls","2026-11-10 10:12:30",false,"---\nname: run-project\ndescription: \"Execute a project's PRD stories through HQ worker lanes that survive compaction. Interactive mode runs in the parent.\"\nallowed-tools: Read, spawn_agent, wait_agent, Bash(hq lanes create:*), Bash(hq lanes list:*), Bash(hq lanes wait:*), Bash(hq lanes message:*), Bash(hq lanes questions:*), Bash(hq lanes story:*), Bash(bash core\u002Fscripts\u002Fhq-session.sh:*), Bash(bash core\u002Fscripts\u002Frun-project-state.sh:*), Bash(node core\u002Fscripts\u002Fworkflow-runner.mjs:*), Bash(bash core\u002Fscripts\u002Fhq-detach.sh:*), Bash(ps:*), Bash(grep:*), Bash(bash:*), Bash(jq:*), Bash(cat:*), Bash(tail:*), Bash(kill:*), Bash(ls:*), Bash(mkdir:*), Bash(echo:*), Bash(sleep:*), Bash(qmd:*), Bash(test:*), Bash(bash core\u002Fscripts\u002Fwork-mesh-live-bind-trusted.sh:*), Bash(sh core\u002Fscripts\u002Fpipeline-lane-rows.sh:*), Bash(bash core\u002Fscripts\u002Fpipeline-conductor.sh:*), Bash(bash core\u002Fscripts\u002Fpipeline-worker-table.sh:*), Bash(sh core\u002Fscripts\u002Fpipeline-driver.sh:*), Bash, Write, AskUserQuestion, Task, mcp__visualize__read_me, mcp__visualize__show_widget\nargument-hint: \"{project} [--status] [--resume] [--dry-run] [--inline] [--interactive] [--ralph-mode] [--pipeline] [--in-place] [--timeout N]\"\n---\n\n# Run Project — Codex Router\n\nCodex does not use Claude Code's `Task`, `Plan` sub-agents, `ExitPlanMode`, `\u002Fcheckpoint`, or `\u002Fcompact` primitives. The default story path creates an HQ worker lane for each story. If lane execution is unavailable, Codex can use the documented in-session `spawn_agent` \u002F `wait_agent` fallback.\n\n**Default story execution:** one HQ worker lane for each active story, created\nwith `hq lanes create` and this session as senior. Interactive mode stays in the\nparent; the pipeline lane behavior below remains separate.\n\n**Pipeline mode (`--pipeline`) live children: one loop lane per confirmed\nworker-table row, plus the regression-gate lane.** `hq lanes create` enforces\ncompany admission and capacity. A capacity refusal leaves the story queued for\nthe next driver tick. The pipeline driver that routes phases is a detached\nscript, not a lane, and takes no lane slot.\n\n**User's input:** $ARGUMENTS\n\n## Script Resolution\n\nResolve the shell orchestrator before any shell delegation:\n\n1. Prefer `core\u002Fscripts\u002Frun-project.sh` if it exists.\n2. Otherwise use `.claude\u002Fscripts\u002Frun-project.sh`.\n3. If neither exists, stop with a clear error.\n\nStore the chosen path as `{run_project_script}`. In this HQ workspace today, the expected path is `.claude\u002Fscripts\u002Frun-project.sh`.\n\n## Work Mesh Live — trusted bind (do this first)\n\nBefore any other tool call that touches project work, bind the session per\n`.claude\u002Fskills\u002F_shared\u002Fwork-mesh-live-bind.md` (US-011):\n\n```bash\nbash core\u002Fscripts\u002Fwork-mesh-live-bind-trusted.sh \\\n  --company \"{co}\" --project \"{project}\" --task \"{task}\"\n```\n\nOmit `--task` when unknown. This writes `workspace\u002Fsessions\u002F\u003Csid>\u002Fmeta.yaml`\nand reconciles with `observation.trustedContext` (no `--trusted` CLI flag).\n\n**Story claims.** Each story is claimed on the Work Mesh when it starts. Lanes\nrunning `\u002Fexecute-task` claim in its step 1.6. In `--interactive` mode the\nparent claims before editing:\n`hq mesh claim --company \"{co}\" --project \"{project}\" --story \"{story-id}\"`.\nOn `STORY_ASSIGNEE_CONFLICT`, skip that story, report its holder, and ask the\nuser before re-running with `--force`. A missing `hq` or an older CLI without\n`claim` does not block the run.\n\n## Step 1 — Parse Arguments\n\nExtract from `$ARGUMENTS`:\n\n- `{project}` — project name, required unless `--status` or `--help`\n- `--status` — show orchestrator status, then stop\n- `--dry-run` — show story order, then stop\n- `--resume` — pass through to the chosen execution path\n- `--inline` — the default: dispatch each story through `\u002Fexecute-task` in an HQ worker lane (Step 3). The name is historical; it means story-delegated execution, as opposed to `--interactive` parent-driven editing.\n- `--interactive` or `--session-mode` — parent-driven Codex execution\n- `--ralph-mode` — the same HQ lane story loop as default, run unattended: skip the preflight approval, auto-advance through every story without between-story pauses, and report once at the end\n- `--pipeline` — opt-in pipeline mode (Step 3P): one persistent loop-mode lane per worker for the whole run, plus a detached driver script (`core\u002Fscripts\u002Fpipeline-driver.sh`) that routes story phases through them. Without this flag nothing in Step 3P applies and the default coordinator path (Step 3) runs unchanged.\n- `--in-place` — (ralph) skip feature-branch pre-creation; work on the current checkout\n- `--timeout N` — (ralph) per-story wall-clock budget in minutes before a story is marked `blocked: TIMEOUT`. This is the waiter's `deadline` file (dispatch protocol §4-§5), not the runner's `timeoutSecs` — that one only warns and never kills, so it cannot bound anything on its own.\n- `--resume` continues from the next incomplete story (read from `state.json`)\n\nIf no execution mode is supplied, route to `--inline`. Each story runs through `\u002Fexecute-task` in its own HQ worker lane, so the parent holds coordination state only.\n\nUse `--interactive` only when the user asks to steer edits directly in the parent session; it is the one mode that does not dispatch lanes at all. Use `--ralph-mode` for long unattended runs where you do not want to be prompted between stories — it executes the identical worker-authoritative lane loop, just without the pauses.\n\n**Recommendation posture:** always recommend `--inline`. It runs **continuously — no pause between stories** — except when either condition holds:\n\n1. The PRD has **more than 10 incomplete stories** → pause at the preflight plan for one approval, then run continuously.\n2. A story **requires session mode** (its notes or classification demand parent-driven interactive steering) → pause before that story only, run it interactively, then resume continuous flow.\n\nEverything else auto-continues exactly like ralph-mode. Failed or blocked stories still stop the queue.\n\n> **Note on the legacy detached orchestrator — not the same thing as a lane.** Earlier versions of this skill launched a detached shell subprocess (`nohup bash run-project.sh … --engine claude`) that ran one headless `claude -p` builder per story, outside the pool and outside the worker system. *That* path is retired: `run-project.sh`'s execution loop is frozen and kept only for `--status`, `--dry-run`, and `--help`; it no longer runs stories, and it has no `claude` builder. The `--engine`\u002F`--builder`, `--swarm`, `--tmux`, `--codex-autofix`, and `--no-monitor` flags belonged to it and are not accepted.\n>\n> Current story lanes are created through `hq lanes create`, carry the invoking session as senior, and run `\u002Fexecute-task` rather than a bare headless builder.\n\n## Step 2 — Status, Help, and Dry Run\n\nUse `{run_project_script}`:\n\n```bash\nbash {run_project_script} --status\nbash {run_project_script} --help\nbash {run_project_script} --dry-run {project}\n```\n\nDisplay the important output to the user and stop.\n\n## Step 2.5 — Design-Lock Check (soft gate)\n\nBefore execution, read the project's `prd.json` and check `metadata.designLocked`.\n\n- If `designLocked: true` (or the project has no UI surface) — proceed silently.\n- If the PRD is **UI-bearing** (stories reference screens, pages, components, or `metadata.designRef`\u002F`audiences` imply a user-facing interface) and `designLocked` is absent or false — surface a one-line **soft warning**: \"Heads up — design isn't locked for `{project}`. Consider `\u002Fstoryboard {project}` first to lock visuals and fold any design changes into the PRD before building. Proceed anyway? [Y\u002Fn]\"\n\nThis is advisory, not a hard stop — many projects (CLIs, infra, libraries) have no visual surface and should proceed without friction. Honor an explicit \"yes\u002Fproceed\" and continue.\n\n## Step 3 — Default Execution: Story Lanes\n\nThe parent plans and coordinates. Each story runs through `\u002Fexecute-task` in a\nworker lane created with `hq lanes create`; the lane is attributed to the bound\ncompany, project, and story, and this invoking session is its senior. The lane\nruns the existing worker phases, quality gates, handoffs, and commit checks in\n`.claude\u002Fskills\u002Fexecute-task\u002FSKILL.md`.\n\nResolve the engine and model choices once for the run using the current\ninteractive decision gate. Record the selected values with the run state and\nreuse them for each story. Pass `--provider`, `--model`, and `--effort` to lane\ncreation only when a worker profile or an explicit `\u002Fconduct --workers` pin\nsupplies that value. If no provider CLI is available, retain the existing\nin-session `spawn_agent`\u002F`wait_agent` fallback and say which path is in use.\n\n### 3a. Preflight Plan\n\nKeep the existing preflight: resolve the PRD and company, validate the target\nrepo and story dependencies, classify incomplete stories with `\u002Fexecute-task`\nrules, read applicable hard policies, and present the ordered plan. For ten or\nfewer incomplete stories with no session-mode requirement, proceed without an\nextra approval pause. Otherwise ask the user to approve or adjust the plan,\nswitch to `--interactive` or `--ralph-mode`, or stop. The parent may use a read-only explorer to produce the plan; it does not own a story or change board status.\n\nBefore dispatch, record the run's company, project, session id, provider choice,\nmodel, and effort in `workspace\u002Forchestrator\u002F{project}\u002Fstate.json` with the\nstate helper. Do not write state.json by hand: the progress band reads the\nstandard shape (`prd_path`, `progress`, `current_tasks`, `completed_tasks`,\n`failed_tasks`) that `.claude\u002Fscripts\u002Frun-project.sh` writes, and a hand-written\nfile shows 0\u002F0.\n\n```bash\nbash core\u002Fscripts\u002Frun-project-state.sh init {project} --company {company} \\\n  --session-id {session-id} --provider {provider} --model {model} --effort {effort}\n```\n\nOn resume, run the same `init`: it keeps the original `started_at`, session id\nand finished tasks, drops the earlier session's running entries, and refuses a\ndifferent `--company` than the one recorded. Run `start` again for each story\nwhose lane is still live. Keep lane ownership. Never infer company from cwd.\n\n### 3b. Story Loop\n\nFor each approved incomplete story:\n\n1. Announce the story id, title, and worker sequence. Keep the existing branch\n   setup and best-effort Linear sync. Record the story as running:\n   `bash core\u002Fscripts\u002Frun-project-state.sh start {project} {story-id}`.\n2. Write the story brief to a file and create the story worker lane:\n\n   ```bash\n   hq lanes create --company \"{company}\" --project \"{project}\" \\\n     --story \"{story-id}\" --worker \"{worker-id}\" \\\n     --brief-file \"{brief path}\" --senior \"session:{session-id}\" \\\n     --account auto --json\n   ```\n\n   Replace `--account auto` with `--account {id}` only when a\n   `conduct_child_account` session pin or a user `--account` flag names an\n   account. A `no_account_with_room` refusal leaves the story queued; report\n   the soonest reset from `next_reset` in one line and never pick an account by\n   hand. The brief tells the lane to run `\u002Fexecute-task {project}\u002F{story-id}` and\n   includes `RETURN CONTRACT: json`, applicable policies, the target repo, and\n   the `verify-story-deliverables.sh` evidence gate. Use\n   the same story id for every lane created for its phases. A repeat create for\n   the same worker under the same senior continues that worker's previous\n   thread. If its lane is live, send the follow-up with `hq lanes message`.\n   Read the JSON body for `ok`, `lane_id`, and admission\u002Fcapacity errors. A\n   capacity refusal leaves the story queued for the next tick.\n3. Start and verify the policy-required detached watcher, then wait with `hq lanes wait --any {lane-id} --for envelope\n   --for question --for state --timeout {seconds} --json`. Questions use the\n   existing user decision flow and `hq lanes questions` commands.\n4. Read the latest lane envelope from `hq lanes list --json` and its\n   `last_envelope.ref`. Parse the envelope with `jq -e`, then validate the story id, worker proof, artifacts,\n   back-pressure results, and parent-visible commits before advancing. Retry\n   malformed JSON exactly once with the existing stricter reminder; if the\n   second result is malformed, mark the story blocked with\n   `INVALID_RETURN_FORMAT` and stop the queue.\n5. Preserve the one-line story narration and bounded parent reads. Keep detailed\n   logs and long notes on disk. Do not use conduct pool state as the result\n   source.\n6. Update story status through the board and `hq lanes story` wherever the\n   skill already updates status. Do not add status fields to local `prd.json`;\n   `passes` remains spec acceptance data, not a board column. Mark `passes: true`\n   only after the existing evidence and quality gates pass.\n7. Update state.json after every story, before dispatching the next one. A\n   verified story: `bash core\u002Fscripts\u002Frun-project-state.sh complete {project} {story-id} --commit {sha}`\n   (after `passes: true` is written; the last one marks the run completed). A\n   failed story: `bash core\u002Fscripts\u002Frun-project-state.sh fail {project} {story-id} --error \"{reason}\"`;\n   add `--blocked` for `INVALID_RETURN_FORMAT`, `NEEDS_INTERACTION`, `TIMEOUT`\n   and other blocks. When the run stops early, `bash core\u002Fscripts\u002Frun-project-state.sh finish {project}`\n   marks it `paused`. Each command recomputes `progress` from prd.json.\n\nStories are dispatched one at a time by default. Independent stories may run\nconcurrently only when their worker ids differ, they have no dependency or file\nconflict, and lane admission accepts each create. A same-worker story reuses its\nexisting lane. Do not create a second lane for a worker that is still live; use\n`hq lanes message` for its next brief. Admission and capacity refusals remain\nqueued for a later tick rather than bypassing the lane limit.\n\n### 3c. Regression Gates\n\nKeep the existing budget-aware regression cadence: every three completed\nstories, run the applicable `metadata.qualityGates` for repos touched since the\nlast gate. Run the full matrix at final completion, before deploy, after a\nhigh-risk cross-repo contract change, or when explicitly requested. A gate may\nrun in a worker lane with the same `--company`, `--project`, `--story`,\n`--brief-file`, and session senior mapping; read its result from its lane\nenvelope. Keep detailed logs on disk and the parent transcript to compact JSON.\nA failed gate stops story advancement and follows the existing user decision\npath.\n\n### 3d. Budget and Recovery\n\n- Worker lanes are created with `hq lanes create`; admission and capacity are\n  owned by HQ lanes. Keep only one lane per worker and senior, and use\n  `hq lanes message` while it is live.\n- A completed phase's result comes from its lane envelope. `hq lanes list\n  --json` provides lane state and the latest envelope reference; it is not a\n  substitute for reading the envelope itself.\n- A lane that is still live after the parent turn is resumable. On recovery,\n  list only lanes owned by the original `session:{session-id}` and this project,\n  re-arm watchers for live lanes, and do not dispatch the same story again\n  while its lane is running.\n- Keep one story active by default. Independent stories can overlap only under\n  the constraints in 3b and only when create succeeds.\n- Do not simulate `\u002Fexecute-task` by spawning worker-phase agents from the\n  parent. If the story lane cannot run `\u002Fexecute-task`, use the existing\n  in-session fallback or pause with the current blocker.\n- Read bounded output only. Use compact envelopes and short tails, not raw test\n  logs or full output files.\n\n## Step 3P — Pipeline Mode (`--pipeline`)\n\nOnly with `--pipeline`. Without the flag, skip this whole step: the default\npath is the story coordinator lanes of Step 3, and nothing below changes it.\n\nIn pipeline mode each worker gets one `hq lanes` loop lane for the whole run.\nA detached driver, `core\u002Fscripts\u002Fpipeline-driver.sh`, owns the story queue: it\ncalls `core\u002Fscripts\u002Fpipeline-conductor.sh` to route each phase with\n`hq lanes enqueue`, accepts each phase's handoff, and re-checks acceptance criteria.\nThe driver makes no engine calls. The parent does not run story coordinators.\nPaths below are under `workspace\u002Forchestrator\u002F{project}\u002Fpipeline\u002F`; `{state}`\nis its `state\u002F` subdirectory.\n\nThere is no conductor lane. A lane cannot keep a child process alive past its\nown engine call, so a routing loop started inside a lane dies when that call\nends. The `pipeline-conductor` worker (`core\u002Fworkers\u002Fpublic\u002Fdev-team\u002Fpipeline-conductor\u002F`)\nstays as the written reference for the routing rules the driver follows; it is\nnot launched, gets no worker-table row, and takes no lane slot.\n\n**3P.1 — Pre-flight first, unchanged.** Run Step 2.5 and the Step 3a preflight\nexactly as they run today, including their pauses. If preflight finds stale\nstate (wrong branch, dirty tree, stale file anchors, missing auth, an unlocked\ndesign), pause and surface it the same way; launch no lane until it is\nresolved. Record `session_id` in `state.json` as Step 3 describes. Step 3's\nsingle engine question is replaced by the worker table below. The preflight\nlane is separate from the loop lanes created for the pipeline phases.\n\n**3P.2 — Worker sequences, worker table, confirm once.**\n\nA story's worker sequence (`worker_preference`, or the overlay below) is the\nfull phase sequence for that story, in order: implementer first, then the\nreviewers and testers. The lanes are the union of every story's sequence.\n\nFirst put the preflight's sequences in run state. The Step 3a preflight\nexplorer emits `ordered_stories[]` with a `worker_sequence` per story; save its\nJSON block as `pipeline\u002Fpreflight-plan.json` and import it into the run's\noverlay (`{state}\u002Foverlay.json`; prd.json is not edited):\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh classify --prd {prd.json} --state {state} --overlay pipeline\u002Fpreflight-plan.json\n```\n\nAn overlay entry wins over `worker_preference`, which wins over the keyword\nfallback. Correct one story without a heredoc:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh overlay set --state {state} --story {id} --sequence backend-dev,qa-tester\nbash core\u002Fscripts\u002Fpipeline-conductor.sh overlay show --state {state}\n```\n\nA story the run should not take (out of scope, waiting on someone) goes on the\nskip list instead of being deleted from prd.json:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh skip --state {state} --story {id} --prd {prd.json} --note \"{why}\"\n```\n\nSkipping a story that others depend on prints the dependents it strands and\nneeds `--force`; `unskip --state {state} --story {id}` reverses it.\n\nThen propose the table from the same sequences:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-worker-table.sh {prd.json} --overlay {state}\u002Foverlay.json\n```\n\nIt proposes one `row` for every worker any sequence names (architect and\nqa-tester included). Show every `row` (worker, engine, model, effort, status,\nstories), every `hint` (a story's model_hint) and every `unclassified` story.\nA worker with no `worker.yaml` is reported on stderr with the roots searched and\nthe known ids; fix the sequence rather than answering its row. Then:\n\n- Every row with status `needs-answer` must be answered (engine and model)\n  before anything launches. Ask one question per flagged row (AskUserQuestion,\n  text fallback per `core\u002Fpolicies\u002Fhq-codex-decision-gate-fallback.md`). An\n  `unclassified` story needs an overlay entry (`overlay set`) or goes on the\n  skip list.\n- Do not add a `pipeline-conductor` row: it is not a lane.\n- `HQ_DISABLED_ENGINES` (comma-separated `claude`, `codex`, `grok`) turns any\n  row seeded with a listed engine into `needs-answer` with an empty engine and\n  model, and makes `--confirmed` exit 2 on a lane that names one.\n- A `model_hint` does not override a confirmed row: the lane's model wins, and\n  `--confirmed` prints each hint commented out as \"hint ignored, table pins\n  \u003Cmodel>\". A bare alias (`opus`, `sonnet`, `haiku`) is never passed to an\n  engine. To run a story on another model, change that lane's row.\n- Then confirm the whole table **once**, before the first dispatch. Until the\n  owner confirms and every flagged row is answered, no lane starts and the\n  driver does not start.\n\nWrite the confirmed table (one `\u003Cworker> \u003Cengine> \u003Cmodel> [\u003Ceffort>]` line per\nlane) to `pipeline\u002Ftable.tsv` and check the run against it:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh classify --prd {prd.json} --state {state} --table pipeline\u002Ftable.tsv\n```\n\nWithout `--story` it checks every story that is not passing or skipped and\nwrites no story state. It must exit 0 before launch. It exits 1 and lists each\nproblem when a worker id has no `worker.yaml` (naming the nearest known id),\nwhen a story that declares code files has a sequence that starts with a\nverifier or reader (it suggests prepending an implementer or marking the story\n`\"docs_only\": true`), or when a sequence worker has no row in the table. Its\n`WARN` lines cover one-worker sequences (architect and qa phases will not run),\nmodel hints, and a story whose acceptance criteria or files need a later story\nthat is not in its `dependsOn` (it prints the `dependsOn` line to use). Relay\nthe warnings to the owner; they do not block launch.\n\nTurn the table into per-lane exports:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-worker-table.sh --confirmed pipeline\u002Ftable.tsv --overlay {state}\u002Foverlay.json {prd.json} > pipeline\u002Flanes.env\n```\n\nIt exits 2 on an empty model or an engine other than `claude`\u002F`codex`\u002F`grok`;\ntreat that as an unanswered row. Each lane block exports `HQ_CONDUCT_ENGINE`\n(the engine its phases run on) and that engine's model and effort pins.\n\n**3P.3 — Lane admission.** The conductor creates one `hq lanes` loop lane the\nfirst time a worker is routed, then reuses that lane for the worker's later\nphases. The CLI applies lane capacity and company admission. If `create` returns\n`ok:false` with an admission or capacity error code, the story stays queued and\nthe driver retries on its next tick. The driver itself is not a lane.\n\n**3P.4 — Approval holds.** Every dev-team implementation worker's worker.yaml\nsets `approval_required: true` (`context-manager` and `pipeline-conductor` do\nnot), so the driver's `route` call holds each phase for those workers\n(`route` prints `HELD`, writes `{state}\u002Fdecisions\u002F\u003Cstory>-\u003Cworker>.md`, exits\n10) until the parent releases it. After the table is confirmed, ask once\nwhether to approve the confirmed workers for the whole run; for each approved\nworker run:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh release --state {state} --worker {worker}\n```\n\nA hold that was not pre-approved becomes a decision item (3P.6); release that\nstory alone with `release --state {state} --story {story-id} --worker {worker}`.\nRelease marks the decision `approved` and returns the held story to `queued`.\n\nThe whole-run worker approval does not release a story that needs an explicit\ngo. A story needs one when it carries `approval: \"explicit\"` (the canonical\nkey; `needsApproval: true` is read as an alias), or when the conductor's\nrelease detector flags it: its declared files or acceptance criteria mention\ndeploy, release, production, or merging to the base branch (the patterns are\n`RELEASE_PATTERNS` in `pipeline-conductor.sh`). Such a story is held\n`awaiting_go` before its first implementing phase, whatever the worker's\n`approval_required` says (a release story on `qa-tester` is held too), with\n`{state}\u002Fdecisions\u002F\u003Cstory>-go.md`. `release` does not apply to it. After the\nowner says go:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh go --state {state} --story {story-id}\n```\n\n`resolve` and `park` work on an `awaiting_go` story. The driver keeps routing\nthe rest, lists `awaiting_go` stories on its `TICK` lines in `driver.log` and in\n`report.md` `FINAL:`, and exits 21 naming them once nothing else can move.\n\n**3P.5a — Repos, worktrees and branches.** Each story's repo is resolved from\nits `repoPath`, then (when the PRD lists more than one repo) from the repo that\nowns the story's first declared file, then from `metadata.repoPath`. The repo\nlist is `metadata.repos[]` (canonical: path strings or objects with `path`);\n`metadata.repoPaths[]` is read as an alias. A story whose repo has no worktree\nis held `blocked_needs_owner` with a decision item naming the repo; it is never\nrouted to another repo's tree.\n\nBranch modes:\n\n- Default: one feature branch per repo for the run (`metadata.branchName`, else\n  `feature\u002F{project}`). Every story of that repo commits on it in dependency\n  order, so a dependent story starts from its dependency's commits. One story\n  is in flight per repo branch at a time.\n- `--story-branches` (pass it to the driver): one branch and worktree per story\n  (`pipeline\u002F{story-id}`), cut when the story first routes, from the branch of\n  the last verified story it depends on in the same repo (stacked), else from\n  the base. A story whose dependency branch is missing is held, not routed.\n\nEvery cut starts from `origin\u002F{baseBranch}` when that ref exists after a fetch,\nelse from local `{baseBranch}`, never from the repo's HEAD (`metadata.baseBranch`,\ndefault `main`). The exact ref is printed as `CUT \u003Cbranch> from \u003Cref> \u003Csha>`;\nwhen neither ref exists the cut fails with that message.\n\nDecide before launch (one choice for the run):\n\n| Stories | Worktrees | `PC_MAX_STORIES` |\n|---|---|---|\n| one repo, or dependent stories in each repo (the usual case) | `worktree --shared` once per repo, default branch mode | the number of repos; the conductor lowers a higher value to that and prints `MAX_STORIES` |\n| independent stories that should run side by side in one repo | `--story-branches` | the number of stories to run at once, bounded by the worktrees and lane admission |\n| a repo that is not a git repo, or the owner wants one story at a time | serial: bare `--worktree {dir}` | 1 |\n\nCut one worktree per repo before launch and pass each to the driver:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh worktree --state {state} --repo {repo} --shared --prd {prd.json}\n```\n\nThe cut lands at `workspace\u002Fworktrees\u002F{project}\u002F{repo-name}\u002F` under the HQ root\n(`{repo-name}-{story}` with `--story-branches`), in every mode, never beside\nthe repo under `repos\u002F`. A worktree must sit inside the HQ root for lanes to cd\ninto it, and it must not sit under `repos\u002F`: the core Write\u002FEdit guard blocks\neditor-tool writes there, so a lane that edits with Write or Edit stalls as\n`blocked_needs_owner`. An explicit `--worktree {dir}` or\n`--worktree {repo}={dir}` (on `worktree`, `tick`, `classify` or the driver)\nthat resolves under `repos\u002F` is refused with exit 2 and a message saying why.\nPass `--allow-repos-worktree` only when the owner wants that tree anyway; then\nevery phase envelope routed into it carries one constraint line telling the\nworker to edit through the shell or `apply_patch`.\n\n**3P.5 — Launch the driver.** The driver creates a company-bound loop lane\nthe first time each worker is routed and records `{worker_id: lane_id}` in\n`{state}\u002Flanes.json`. It reads engine, model, and effort from the confirmed\nworker table. The session must have a company bound before the first route.\nRun-wide hard limits (no push, no deploy, branch rules) go one per line in\n`{state}\u002Fconstraints.txt`; every phase envelope quotes them. Launch the driver\ndetached from the HQ root with `HQ_SESSION_ID` exported:\n\n```bash\nbash core\u002Fscripts\u002Fhq-detach.sh --logfile {state}\u002Fdriver\u002Fdetach.log -- \\\n  sh core\u002Fscripts\u002Fpipeline-driver.sh --prd {prd.json} --state {state} \\\n    --worktree {repo-a}={worktree-a} --worktree {repo-b}={worktree-b} \\\n    --table pipeline\u002Ftable.tsv\n```\n\nFor a single-repo PRD the bare `--worktree {worktree}` form still works.\n`--table` makes the driver refuse to route a phase whose worker has no row\n(exit 27) instead of leaving the story in flight. Add\n`--story-branches` for the stacked mode in 3P.5a. Set `PC_MAX_STORIES` in the\ndriver's environment as 3P.5a says.\n\nIt refuses to start (exit 24) while another driver runs against the same\n`{state}`, so launching it twice is safe. The parent then arms one background\nwaiter on it, with a tool timeout longer than the longest phase deadline:\n\n```bash\nuntil [ -f {state}\u002Fdriver\u002Fexit ]; do sleep 30; done; cat {state}\u002Fdriver\u002Fexit\n```\n\nThe driver polls every 15 seconds (`--interval`). Each pass it accepts every\nhandoff a lane wrote to `result_path`, runs `recheck` for finished stories,\nand ticks the conductor helper to route the next phase or start the next\nstory. It appends one line per action to `{state}\u002Fdriver\u002Fdriver.log`. When it\nexits it writes `{state}\u002Fdriver\u002Fexit` as `\u003Ccode> \u003Creason>`:\n\n| Code | Meaning | Parent action |\n|---|---|---|\n| 0 | every story finished (verified, failed after its one reroute, accepted as a partial draft, or parked); `report.md` has its `FINAL:` line | 3P.8 |\n| 2 | usage error | fix the command |\n| 20 | a regression gate is due | run the gate in the `regression-gate` slot (Step 3c), record `pipeline-conductor.sh gate result pass\\|fail --state {state}` (add `--story {id} --note \"...\"` to a `fail` caused by one verified story: it reopens that story, see 3P.6), relaunch the driver |\n| 21 | a decision is needed: a story is held for approval; a phase returned `blocked`, a story has no worktree for its repo, or a story is `awaiting_go`, and nothing else can move; the gate failed; a phase returned `failed` `--max-phase-fails` times; or a phase's engine exited early twice (`engine_exited_early`, see below) (the reason names the status or `engine_exited_early` and the attempt count; the story is then held as `blocked_needs_owner` with `{state}\u002Fdecisions\u002F\u003Cstory>-blocked-\u003Cphase>.md` carrying each failed handoff's text) | 3P.6: read the decision item, ask the owner once, run the matching command (`resolve --as retry --prd \u003Cprd>` re-reads the story's phases, so fix the sequence first with `overlay set` when the lane was wrong; the attempt count starts over), relaunch the driver |\n| 22 | an in-flight phase passed its deadline with no handoff | check the lane with `hq lanes list --json`, then relaunch the driver or stop the run |\n| 23 | the conductor helper printed something unexpected | read the last lines of `driver.log`, surface them, do not relaunch blindly |\n| 24 | another driver already runs against `{state}` | leave it; re-arm the waiter on it |\n| 25 | retired: the stall check now fires the stall event and exits 28 | - |\n| 26 | lane down: `hq lanes enqueue` reports `loop_not_running`; the story stays `queued` and its worker mapping is removed | restart the driver; the next route creates a fresh loop lane |\n| 27 | no lane: a phase's worker has no row in `pipeline\u002Ftable.tsv`; the reason names the worker and the story stays `queued` | add the row (ask the owner for its engine and model), launch that worker's loop lane as 3P.5 does, relaunch the driver |\n| 28 | a loop lane parked its phase after repeated stalls and raised a question | list its pending question with `hq lanes questions list --company {company} --json`, answer it, then restart the driver |\n| 29 | stopped on request: the parent ran `pipeline-conductor.sh stop` (see \"Stopping a run\" below) | relaunch the driver when the owner wants to resume |\n| 130, 143 | interrupted or terminated; in-flight phases are marked `interrupted` first | relaunch the driver; it routes interrupted stories first |\n\n**Early engine exit.** When a loop lane's engine call for a phase returns\nwithout a usable handoff, the lane writes a failed handoff with\n`exit_reason: \"engine_exited_early\"` and a `phase-exit` event (reason, elapsed\nseconds) to its `journal.jsonl`. A handoff whose status is not `passed`,\n`failed` or `blocked` is not accepted; with a `phase-exit` event since the\nphase was routed it counts the same way. On the next tick the driver logs\n`EARLY_EXIT \u003Cstory>\u002F\u003Cphase> after \u003Cn>s` and accepts it as a failed phase, which\nroutes the phase once more to the same lane. A second early exit of that phase\nholds the story for the owner (exit 21 naming `engine_exited_early`; the\ndecision item carries the reason). A phase whose engine is still running keeps\nthe deadline path (exit 22).\n\n**Loop lane admission.** `hq lanes create --loop` applies lane admission and\ncapacity rules. Admission or capacity refusals leave the story queued for the\nnext tick. A stopped or failed lane is removed from `lanes.json` and recreated\non the next route.\n\n**Stopping a run.** Stop with\n`bash core\u002Fscripts\u002Fpipeline-conductor.sh stop --state {state} --note \"{why}\"`.\nWith a live driver it writes `{state}\u002Fdriver\u002Fstop.json` (a stop envelope,\n`{\"kind\":\"stop\"}`) and the driver exits 29 on its next pass; with no live\ndriver it marks the stories itself. Every stop path (that command, SIGTERM,\nSIGINT, and a loop lane that exited on a stop envelope while a story was in\nflight on it) marks each `in_flight` story `interrupted` with the phase and\ntime in `stories\u002F\u003Cid>.json`, withdraws its envelope from the lane queue when no\nlane picked it up, and keeps a partial handoff as\n`handoffs\u002F\u003Cid>-\u003Cphase>.interrupted.\u003Cn>.json`. A phase whose handoff already\nfinished it is left for the next driver to accept. The relaunched driver routes\ninterrupted stories first, before reopened ones, at the interrupted phase; the\nenvelope carries `resumed_after_interrupt: true` and `prior_handoff` when a\npartial handoff exists. `TICK` lines in `driver.log` and the `FINAL:` line name\ninterrupted stories until they are routed again.\n\nA handoff with status `failed` is routed again until it has failed\n`--max-phase-fails` times (default 2). A handoff with status `blocked` is never\nrouted again: a rerun cannot help. The conductor holds that story as\n`blocked_needs_owner`, writes `{state}\u002Fdecisions\u002F\u003Cstory>-blocked-\u003Cphase>.md`\nwith the story, phase, lane and the worker's own blocker text, and the driver\nkeeps routing every story that does not depend on it. A blocked story does not\ntake a slot under `PC_MAX_STORIES`.\n\nEvery relaunch uses the same command. The driver reads all of its state from\n`{state}`, so a relaunch resumes where the last one stopped and does not run a\nfinished phase again.\n\nNo step here starts a background shell loop inside a lane. The driver is the\nonly loop, and it runs outside every lane.\n\n**3P.6 — Relay, do not drive.** While the run is live the parent:\n\n- Ends every turn in which a pipeline lane is live with the lane rows. Pull\n  them once with\n  `sh core\u002Fscripts\u002Fpipeline-lane-rows.sh --state {state} --session-id {session_id}`\n  (one JSON array: an item per mapped hq loop lane and one\n  `kind: \"driver\"` item). Call `mcp__visualize__read_me` with `[\"mockup\"]`\n  once per session first, silently, then render `mcp__visualize__show_widget`\n  in HTML mode from the template `.claude\u002Fskills\u002Fconduct\u002Flane-rows.html`: one\n  `.row` per worker lane plus one for the driver, the CSS untouched, flex rows,\n  never a grid or cards. Per lane row: the worker; the phase chip from\n  `phase_label`; the meta from `phase_elapsed_s`, `quiet_s` and\n  `inbox_pending`; a rough percentage from `phase_index` of `phase_count`\n  (`(phase_index - 1) \u002F phase_count`, never 100% before the story is\n  verified); the story title in plain words; `last_line` in plain words; the PR\n  link when `pr` is set. Dot: green when the lane runs and is active; yellow\n  when it waits on an envelope, on the owner, or has been quiet 20 minutes or\n  more (`quiet_s` >= 1200); red when `pid_alive` is false on a lane that has\n  not exited, or the driver exited non-zero; blue on a lane that exited 0\n  (`exit` is `0`). The driver row carries the story counts (verified,\n  in_flight, queued, blocked, parked, skipped, interrupted, awaiting_go) and\n  its `last_line`. Then the one-line reply. Nothing the owner must decide goes\n  in a row: that is `\u002Fdecision-queue`, after the rows. Zero live lanes means no\n  rows.\n- Relays the per-story report lines from `{state}\u002Freport.md` (one line per\n  finished story, one `FINAL:` line at the end). It does not report per\n  phase.\n- Surfaces decision items through the decision queue (`\u002Fdecision-queue`), one\n  at a time: approval items in `{state}\u002Fdecisions\u002F` marked `status: pending`,\n  and loop lane questions with `hq lanes questions list --company {company}\n  --json`. Answer with `hq lanes questions answer`. Apply\n  each answer with `pipeline-conductor.sh release`, or as the item's options\n  describe, then relaunch the driver.\n- On exit 21 for a blocked story (`decisions\u002F\u003Cstory>-blocked-\u003Cphase>.md`,\n  `status: pending`): read the decision item, ask the owner once and quote the\n  worker's blocker text from it, run the one command that matches the answer,\n  then relaunch the driver with the same command as before. None of these is\n  ever applied without the owner's answer.\n\n  | Owner's answer | Command |\n  |---|---|\n  | accept it as a partial draft; let dependents start | `bash core\u002Fscripts\u002Fpipeline-conductor.sh resolve --state {state} --story {id} --as accepted-partial --note \"{owner's reason}\"` |\n  | run the phase again with this answer | `bash core\u002Fscripts\u002Fpipeline-conductor.sh resolve --state {state} --story {id} --as retry --note \"{owner's answer}\"` |\n  | set it aside with everything that depends on it | `bash core\u002Fscripts\u002Fpipeline-conductor.sh park --state {state} --story {id} --note \"{why}\"` |\n  | bring a parked story back | `bash core\u002Fscripts\u002Fpipeline-conductor.sh unpark --state {state} --story {id}` |\n  | leave a story out of the run | `bash core\u002Fscripts\u002Fpipeline-conductor.sh skip --state {state} --story {id} --prd {prd.json} --note \"{why}\"` (add `--force` only after the owner accepts the stranded dependents it lists) |\n  | go for a story held `awaiting_go` | `bash core\u002Fscripts\u002Fpipeline-conductor.sh go --state {state} --story {id}` |\n\n  `accepted-partial` is a terminal state, separate from `verified`: it counts\n  as done for `dependsOn`, its report line and the `FINAL:` line list the\n  owner's note and the unmet acceptance criteria, and `passes` stays unset.\n  Do not write `passes: true` for it. `retry` routes the phase as a fresh call\n  with the owner's note in the envelope. `park` holds every story that depends\n  on the parked one, directly or not, as `parked_dependency`; the `FINAL:` line\n  lists parked stories and why. `park` prints `PARK_CLOSURE \u003Cid> \u003Cn>: \u003Cids>`\n  before it acts; when it would park more than `PC_PARK_CONFIRM` (default 5)\n  stories it refuses until it is repeated with `--force`. Show the owner that\n  list and ask before adding `--force`. `unpark` prints what it releases. Park,\n  unpark, skip and unskip each add a line to `{state}\u002Fdecisions.log`. Each command refuses a story in a state it\n  does not apply to (exit 1) and prints `ALREADY` when repeated.\n- On exit 20, if the gate fails because of one story the run already\n  verified (its own QA passed because the guard test lives outside its suite),\n  record the failure naming that story instead of a plain `fail`:\n  `bash core\u002Fscripts\u002Fpipeline-conductor.sh gate result fail --state {state} --story {id} --note \"{what the gate found}\"`.\n  The conductor reopens the story and sets the gate to `reopened`, which does\n  not stop routing; the relaunched driver routes that story first. The same\n  works after a plain `gate result fail` was already recorded. To send a\n  story back without a gate, run\n  `bash core\u002Fscripts\u002Fpipeline-conductor.sh reopen --state {state} --story {id} --note \"{why}\" [--from-phase {phase}]`.\n  Reopen applies to a `verified` or `accepted_partial` story. It queues the\n  story at `--from-phase` (default: the first phase whose worker is not a\n  reviewer or tester), archives that phase's and later handoffs as\n  `handoffs\u002F\u003Cid>-\u003Cphase>.reopened.\u003Cn>.json`, starts the attempt count over,\n  puts the note in the next envelope (`reopen_note` and a constraint line),\n  and sets `passes` back to false in prd.json if it was true, saying so.\n  Stories that depend on it and are already verified are not reopened; the\n  `FINAL:` line lists them as \"verified before {id} was reopened\" for the\n  owner to decide. Once every reopened story verifies again the gate is due\n  (exit 20): run it and record `pass` or `fail` as usual. Reopen refuses\n  other states (exit 1) and prints `ALREADY` when repeated.\n- Records `passes: true` in prd.json for a story only after the report says it\n  is verified; the driver and the conductor helper never write `passes`.\n\n**3P.7 — After a parent compaction, recover from disk.** The run state lives\nin files, not in the parent's context. After a compaction or in a new session,\nrebuild it from `state.json` (`session_id`), `pipeline\u002Ftable.tsv`,\n`{state}\u002Fstories\u002F` (each story's phase and state), `{state}\u002Freport.md`,\n`{state}\u002Fdecisions\u002F`, `{state}\u002Fdriver\u002F` (`driver.pid` while it runs, `exit`\nonce it stopped, `driver.log`), `workspace\u002Fsessions\u002F\u003Cid>\u002Fdecisions.jsonl`, and\n`hq lanes list --json` filtered to ids in `{state}\u002Flanes.json` for live lanes.\nDo not relaunch a lane whose loop state is `waiting` or `running`. If `driver.pid`\nnames a live process, re-arm the waiter; if `exit` is present, act on its code;\nif neither, relaunch the driver.\n\n**3P.8 — Run end: stop every lane.** The driver stops each lane id in\n`{state}\u002Flanes.json`. It reports completion only when `hq lanes list --json`\nshows every owned loop state as `stopped` or the lane is absent from the list.\nIt clears the mapping after confirmation so a resumed run creates fresh lanes.\nThen continue with Step 6.\n\n## Step 4 — Parent-Driven Interactive Codex Execution\n\nInteractive mode is parent-driven. It replaces Claude session-mode for Codex.\n\nUse when the project is small enough for the parent session and the user may want to steer implementation decisions.\n\nCodex interactive mode is direct parent execution, not proof that the HQ worker pipeline ran. If the user asks for worker-backed execution, or if a PRD\u002Fstory requires `workers_run`, worker handoffs, or `\u002Fexecute-task` semantics, stop and route to Ralph\u002Fheadless (the unattended inline worker loop).\n\nProcess:\n\n1. Resolve and read `prd.json`.\n2. Read only applicable policy frontmatter first; read full rule text only for hard rules that apply to the project.\n3. Write a durable plan file to `workspace\u002Forchestrator\u002F{project}\u002Fcodex-session-plan.md` containing:\n   - project, company, repo path, branch base, resume state\n   - incomplete story order\n   - acceptance criteria and declared files\n   - applicable policy rules\n   - quality gates\n   - chosen mode: `interactive`\n4. Ask the user to approve, adjust, or switch to Ralph\u002Fheadless mode.\n5. Execute one story at a time in the parent session:\n   - make edits directly\n   - run back-pressure checks\n   - commit per story\n   - mark `passes: true` only after verification (worker proof, commits, and the evidence check `verify-story-deliverables.sh --evidence-json … --commits-json … --write` exit 0)\n   - do not claim `workers_run` or worker-backed completion unless `\u002Fexecute-task` actually ran through the worker system\n   - update `workspace\u002Forchestrator\u002F{project}\u002Fstate.json` with `core\u002Fscripts\u002Frun-project-state.sh` (`init` once, then `start` and `complete`\u002F`fail` per story, as in Step 3b)\n6. Pause between stories and ask continue \u002F adjust \u002F stop.\n\nDo not spawn an end-to-end `\u002Fexecute-task` sub-agent in Codex interactive mode unless the user explicitly asks for delegated agent work. Bounded helper agents are okay only when explicitly requested or clearly available, and they must return compact structured output.\n\n## Step 5 — Ralph\u002FHeadless Unattended Execution\n\nUse when the project is long-running and the user wants it to run to completion without being prompted between stories.\n\nRalph\u002Fheadless is **the same pooled, detached story loop as Step 3, run unattended.** Same lanes, same pool, same return contract; it differs only in that it does not pause.\n\n**What detachment does and does not buy here — say this plainly, because the\ndifference matters to anyone leaving a run going.** The *stories* are detached:\nthe in-flight one keeps running and keeps committing when the parent session\nends, where the previous in-session loop died with its parent mid-story. The\n*coordinator* is not. The waiter, the result validation, the slot release and\nthe decision to dispatch the next story all live in the parent. So a session\nthat ends mid-run leaves exactly one story running to completion and then\nstops — it does not auto-advance to story N+1 unattended. \"Unattended\" here\nmeans no prompts between stories **within a session**, not a run that drives\nitself after the session is gone.\n\nThat makes the run *resumable*, not *self-driving*, and resuming takes a new\nsession: `hq lanes list --json` shows the lanes launched by the session, and\n`state.json` says which stories are done. A genuinely self-driving run would\nneed the loop itself dispatched as a lane — an extra coordinator level with its\nown lane accounting — which does not exist today. Do not tell a user their run\nwill finish on its own after they close the session.\n\n**5.0 — Pre-flight (run ONCE, before the loop starts).** Skipping the *approval pause* (operational step 1 below) must not skip *validation*. Before auto-advancing, the orchestrator must:\n\n1. **Pre-create the feature branch** from `metadata.baseBranch` unless `--in-place` was passed — never let an unattended run discover mid-loop that it has been committing to the wrong branch (`run-project-precreate-branch-before-ralph`).\n2. **Scan the PRD for stories whose acceptance requires interactive input** (a decision the worker would surface via `AskUserQuestion`) and mark them `blocked` up front with reason `NEEDS_INTERACTION` — do not let them wedge the loop mid-run (`hq-cmd-run-project-no-askuserquestion-stories-in-ralph-mode`). Workers in ralph mode never call `AskUserQuestion`.\n3. **Verify the target repo + branch resolve and the tree is clean.** Abort with a clear message if not — an unattended run on a dirty or missing tree is never correct.\n\nIf any pre-flight check cannot be satisfied, stop and surface it; do not start the loop.\n\nThe operational differences from default inline are then:\n\n1. **Skip the preflight approval gate (Step 3a).** Still run the preflight explorer slot to build the plan (claimed or resumed the same way), but do not pause for approval — log the plan to `workspace\u002Forchestrator\u002F{project}\u002Fcodex-session-plan.md` and proceed.\n2. **Auto-advance.** Run the Step 3b story loop for every approved incomplete story back to back. Do not pause between stories (Step 3b.10 already auto-advances; ralph-mode also skips the >10-story and session-mode pauses). All per-story invariants still hold: JSON-validate the worker return, enforce the worker-proof gate, verify parent-visible commits, mark `passes: true` only after verification, and update `state.json` after each story with `core\u002Fscripts\u002Frun-project-state.sh` (Step 3b.7).\n3. **Run regression gates on cadence.** Apply Step 3c every 3 completed stories exactly as in inline mode.\n4. **Report once.** Emit one compact line per story to the transcript (`[{story_id}] {status} · {files_changed} files · {first_commit_short_sha}`); send anything longer to `workspace\u002Fthreads\u002Fjournal\u002F\u003Cdate>\u002F\u003Cstory-id>.md`. Surface a single summary at the end rather than pausing throughout.\n5. **Bound wedge time.** A lane that never returns must not stall the run forever. Set the waiter's `deadline` file from the per-story budget (default ~20 min; honor `--timeout N` minutes if passed) — **not** the runner's `timeoutSecs`, which only prints a repeating warning and never kills, so on its own it bounds nothing and the waiter would loop for a `CONDUCT_EXIT` marker that never arrives. When the waiter returns `outcome: deadline`, the lane is **still running**: ask the runner to stop and wait for its `CONDUCT_EXIT` marker (dispatch protocol §5 — signalling the wrapper group never reaches the engine, which the runner spawns detached into a group of its own). Mark the story `blocked` with reason `TIMEOUT`, stop, and surface it either way. Retire the slot with `recycle --force` **only if the lane stopped cleanly and §5's confirmation reported `engine_gone=yes`** — that confirmation runs on every outcome, not just this one, so a `died` or `never-started` lane with a surviving engine group is held back the same way; if the marker never arrived or the group still has members, leave the slot `running`, say the engine may still be live, and let the user decide — reusing an unconfirmed slot puts the next worker in a lane the old one is still writing to. Do not silently move on. Slow back-pressure (e.g. heavy E2E) is the usual cause.\n\nStop and surface to the user mid-run only on a hard blocker: a story that lands `blocked` (including `INVALID_RETURN_FORMAT`, `NEEDS_INTERACTION`, or `TIMEOUT`), a failed regression gate (coarse 3-story gate or a per-story `all_story_tests_pass: false`), or a worker that cannot run `\u002Fexecute-task`. Do not silently skip past a blocked story to the next one — auto-advance applies to *passed* stories only.\n\nEvery story lane has a PID, a run dir, and a `lane.log`, so **a new session** can pick the run back up — nothing picks itself back up.\n\n**Resume against the original session id, not the new one.** Read `session_id`\nout of `state.json` and pass it explicitly; the pool and the run dirs are both\nkeyed by the session that created them, and a bare `list` in a fresh session\nreports an empty pool while the old lanes are still live:\n\n```bash\nhq lanes list --json --senior \"session:$(jq -r .session_id workspace\u002Forchestrator\u002F{project}\u002Fstate.json)\"\n```\n\nThat listing names the live lanes and their current state. Re-arm a waiter (dispatch\nprotocol §5) on every lane still `running` **before** doing anything else — an\nunwatched live lane is a lane nobody is running — and do not re-dispatch a story\nwhose lane is still up, however incomplete `state.json` says it is. A story\nmarked incomplete with a live lane is a story mid-flight, not a story to start\nagain. `record`, `recycle` and `cancel` all take `--session-id` too; a recovery\nthat omits it operates on the wrong pool silently.\n\nProgress also lives in `state.json` and `progress.txt`, which the loop updates as it goes; `--status` and `--dry-run` against `{run_project_script}` remain available for out-of-band inspection.\n\n## Step 6 — Completion\n\nAfter either mode completes:\n\n1. Confirm all intended stories have `passes: true`.\n2. Confirm commits exist for completed stories.\n3. Run project quality gates or report why they were skipped.\n4. Run `qmd update 2>\u002Fdev\u002Fnull || true`.\n5. **Auto-checkpoint** \u003C!-- AUTO-CHECKPOINT-ON-COMPLETION -->. Save a lightweight checkpoint so a fresh session can resume without a manual handoff. Codex does **not** use the `\u002Fcheckpoint` primitive — write the thread file DIRECTLY: `workspace\u002Fthreads\u002FT-{UTC YYYYMMDD-HHMMSS}-auto-run-project-{project}.json` with `thread_id`, `version: 1`, `type: \"auto-checkpoint\"`, `created_at`, `updated_at`, `workspace_root`, `cwd`, `git: { branch, current_commit, dirty }`, `conversation_summary` (stories passed \u002F blocked this run), `files_touched`, `next_steps`, and `metadata: { title: \"Auto: run-project {project}\", tags: [\"auto-checkpoint\", \"run-project\"], trigger: \"run-project-complete\" }`. **Dedup:** if an auto-checkpoint thread (`workspace\u002Fthreads\u002FT-*-auto-*.json`) was already written for this run, upgrade\u002Freuse it instead of writing a duplicate. Cheap only — no INDEX\u002F`recent.md`\u002F`qmd` rebuild.\n6. Ask whether to document release, run a retrospective, or end here.\n\n## Rules\n\n- **Do not reference `.Codex\u002Fcommands\u002Frun-project.md` as required source** — this skill is the Codex router.\n- **Do not assume Claude-only primitives** — `Task`, `ExitPlanMode`, `\u002Fcheckpoint`, and `\u002Fcompact` are not Codex requirements.\n- **Default stories run through `\u002Fexecute-task` in an HQ worker lane** created with `hq lanes create`, using the bound company, project, story, worker, brief file, and `--senior session:{id}`. Interactive mode stays parent-driven.\n- **Carry trusted company and story context into every lane** — resolve the company from the run state and pass the project and story explicitly. Never infer a company from cwd.\n- **Use lane results as the delivery record** — inspect `hq lanes list --json`, then read the latest envelope. Do not infer success from local process state or exit code.\n- **Preserve HQ invariants** — PRD acceptance data, board status, file locks, active-run coordination, commits per story, JSON returns, evidence, and quality gates remain required in every mode.\n- **Ask before mode changes** — switching from the default story-lane path to parent-driven interactive or Ralph\u002Fheadless is a user-facing execution semantic. Preserve the decision gate with text fallback if needed.\n- **Budget mode is default** — prefer low-reasoning story execution, compact JSON returns, bounded log reads, changed-repo regression gates, and no parent-side phase fanout.\n","# Run Project — Codex Router\n\nCodex does not use Claude Code's `Task`, `Plan` sub-agents, `ExitPlanMode`, `\u002Fcheckpoint`, or `\u002Fcompact` primitives. The default story path creates an HQ worker lane for each story. If lane execution is unavailable, Codex can use the documented in-session `spawn_agent` \u002F `wait_agent` fallback.\n\n**Default story execution:** one HQ worker lane for each active story, created\nwith `hq lanes create` and this session as senior. Interactive mode stays in the\nparent; the pipeline lane behavior below remains separate.\n\n**Pipeline mode (`--pipeline`) live children: one loop lane per confirmed\nworker-table row, plus the regression-gate lane.** `hq lanes create` enforces\ncompany admission and capacity. A capacity refusal leaves the story queued for\nthe next driver tick. The pipeline driver that routes phases is a detached\nscript, not a lane, and takes no lane slot.\n\n**User's input:** $ARGUMENTS\n\n## Script Resolution\n\nResolve the shell orchestrator before any shell delegation:\n\n1. Prefer `core\u002Fscripts\u002Frun-project.sh` if it exists.\n2. Otherwise use `.claude\u002Fscripts\u002Frun-project.sh`.\n3. If neither exists, stop with a clear error.\n\nStore the chosen path as `{run_project_script}`. In this HQ workspace today, the expected path is `.claude\u002Fscripts\u002Frun-project.sh`.\n\n## Work Mesh Live — trusted bind (do this first)\n\nBefore any other tool call that touches project work, bind the session per\n`.claude\u002Fskills\u002F_shared\u002Fwork-mesh-live-bind.md` (US-011):\n\n```bash\nbash core\u002Fscripts\u002Fwork-mesh-live-bind-trusted.sh \\\n  --company \"{co}\" --project \"{project}\" --task \"{task}\"\n```\n\nOmit `--task` when unknown. This writes `workspace\u002Fsessions\u002F\u003Csid>\u002Fmeta.yaml`\nand reconciles with `observation.trustedContext` (no `--trusted` CLI flag).\n\n**Story claims.** Each story is claimed on the Work Mesh when it starts. Lanes\nrunning `\u002Fexecute-task` claim in its step 1.6. In `--interactive` mode the\nparent claims before editing:\n`hq mesh claim --company \"{co}\" --project \"{project}\" --story \"{story-id}\"`.\nOn `STORY_ASSIGNEE_CONFLICT`, skip that story, report its holder, and ask the\nuser before re-running with `--force`. A missing `hq` or an older CLI without\n`claim` does not block the run.\n\n## Step 1 — Parse Arguments\n\nExtract from `$ARGUMENTS`:\n\n- `{project}` — project name, required unless `--status` or `--help`\n- `--status` — show orchestrator status, then stop\n- `--dry-run` — show story order, then stop\n- `--resume` — pass through to the chosen execution path\n- `--inline` — the default: dispatch each story through `\u002Fexecute-task` in an HQ worker lane (Step 3). The name is historical; it means story-delegated execution, as opposed to `--interactive` parent-driven editing.\n- `--interactive` or `--session-mode` — parent-driven Codex execution\n- `--ralph-mode` — the same HQ lane story loop as default, run unattended: skip the preflight approval, auto-advance through every story without between-story pauses, and report once at the end\n- `--pipeline` — opt-in pipeline mode (Step 3P): one persistent loop-mode lane per worker for the whole run, plus a detached driver script (`core\u002Fscripts\u002Fpipeline-driver.sh`) that routes story phases through them. Without this flag nothing in Step 3P applies and the default coordinator path (Step 3) runs unchanged.\n- `--in-place` — (ralph) skip feature-branch pre-creation; work on the current checkout\n- `--timeout N` — (ralph) per-story wall-clock budget in minutes before a story is marked `blocked: TIMEOUT`. This is the waiter's `deadline` file (dispatch protocol §4-§5), not the runner's `timeoutSecs` — that one only warns and never kills, so it cannot bound anything on its own.\n- `--resume` continues from the next incomplete story (read from `state.json`)\n\nIf no execution mode is supplied, route to `--inline`. Each story runs through `\u002Fexecute-task` in its own HQ worker lane, so the parent holds coordination state only.\n\nUse `--interactive` only when the user asks to steer edits directly in the parent session; it is the one mode that does not dispatch lanes at all. Use `--ralph-mode` for long unattended runs where you do not want to be prompted between stories — it executes the identical worker-authoritative lane loop, just without the pauses.\n\n**Recommendation posture:** always recommend `--inline`. It runs **continuously — no pause between stories** — except when either condition holds:\n\n1. The PRD has **more than 10 incomplete stories** → pause at the preflight plan for one approval, then run continuously.\n2. A story **requires session mode** (its notes or classification demand parent-driven interactive steering) → pause before that story only, run it interactively, then resume continuous flow.\n\nEverything else auto-continues exactly like ralph-mode. Failed or blocked stories still stop the queue.\n\n> **Note on the legacy detached orchestrator — not the same thing as a lane.** Earlier versions of this skill launched a detached shell subprocess (`nohup bash run-project.sh … --engine claude`) that ran one headless `claude -p` builder per story, outside the pool and outside the worker system. *That* path is retired: `run-project.sh`'s execution loop is frozen and kept only for `--status`, `--dry-run`, and `--help`; it no longer runs stories, and it has no `claude` builder. The `--engine`\u002F`--builder`, `--swarm`, `--tmux`, `--codex-autofix`, and `--no-monitor` flags belonged to it and are not accepted.\n>\n> Current story lanes are created through `hq lanes create`, carry the invoking session as senior, and run `\u002Fexecute-task` rather than a bare headless builder.\n\n## Step 2 — Status, Help, and Dry Run\n\nUse `{run_project_script}`:\n\n```bash\nbash {run_project_script} --status\nbash {run_project_script} --help\nbash {run_project_script} --dry-run {project}\n```\n\nDisplay the important output to the user and stop.\n\n## Step 2.5 — Design-Lock Check (soft gate)\n\nBefore execution, read the project's `prd.json` and check `metadata.designLocked`.\n\n- If `designLocked: true` (or the project has no UI surface) — proceed silently.\n- If the PRD is **UI-bearing** (stories reference screens, pages, components, or `metadata.designRef`\u002F`audiences` imply a user-facing interface) and `designLocked` is absent or false — surface a one-line **soft warning**: \"Heads up — design isn't locked for `{project}`. Consider `\u002Fstoryboard {project}` first to lock visuals and fold any design changes into the PRD before building. Proceed anyway? [Y\u002Fn]\"\n\nThis is advisory, not a hard stop — many projects (CLIs, infra, libraries) have no visual surface and should proceed without friction. Honor an explicit \"yes\u002Fproceed\" and continue.\n\n## Step 3 — Default Execution: Story Lanes\n\nThe parent plans and coordinates. Each story runs through `\u002Fexecute-task` in a\nworker lane created with `hq lanes create`; the lane is attributed to the bound\ncompany, project, and story, and this invoking session is its senior. The lane\nruns the existing worker phases, quality gates, handoffs, and commit checks in\n`.claude\u002Fskills\u002Fexecute-task\u002FSKILL.md`.\n\nResolve the engine and model choices once for the run using the current\ninteractive decision gate. Record the selected values with the run state and\nreuse them for each story. Pass `--provider`, `--model`, and `--effort` to lane\ncreation only when a worker profile or an explicit `\u002Fconduct --workers` pin\nsupplies that value. If no provider CLI is available, retain the existing\nin-session `spawn_agent`\u002F`wait_agent` fallback and say which path is in use.\n\n### 3a. Preflight Plan\n\nKeep the existing preflight: resolve the PRD and company, validate the target\nrepo and story dependencies, classify incomplete stories with `\u002Fexecute-task`\nrules, read applicable hard policies, and present the ordered plan. For ten or\nfewer incomplete stories with no session-mode requirement, proceed without an\nextra approval pause. Otherwise ask the user to approve or adjust the plan,\nswitch to `--interactive` or `--ralph-mode`, or stop. The parent may use a read-only explorer to produce the plan; it does not own a story or change board status.\n\nBefore dispatch, record the run's company, project, session id, provider choice,\nmodel, and effort in `workspace\u002Forchestrator\u002F{project}\u002Fstate.json` with the\nstate helper. Do not write state.json by hand: the progress band reads the\nstandard shape (`prd_path`, `progress`, `current_tasks`, `completed_tasks`,\n`failed_tasks`) that `.claude\u002Fscripts\u002Frun-project.sh` writes, and a hand-written\nfile shows 0\u002F0.\n\n```bash\nbash core\u002Fscripts\u002Frun-project-state.sh init {project} --company {company} \\\n  --session-id {session-id} --provider {provider} --model {model} --effort {effort}\n```\n\nOn resume, run the same `init`: it keeps the original `started_at`, session id\nand finished tasks, drops the earlier session's running entries, and refuses a\ndifferent `--company` than the one recorded. Run `start` again for each story\nwhose lane is still live. Keep lane ownership. Never infer company from cwd.\n\n### 3b. Story Loop\n\nFor each approved incomplete story:\n\n1. Announce the story id, title, and worker sequence. Keep the existing branch\n   setup and best-effort Linear sync. Record the story as running:\n   `bash core\u002Fscripts\u002Frun-project-state.sh start {project} {story-id}`.\n2. Write the story brief to a file and create the story worker lane:\n\n   ```bash\n   hq lanes create --company \"{company}\" --project \"{project}\" \\\n     --story \"{story-id}\" --worker \"{worker-id}\" \\\n     --brief-file \"{brief path}\" --senior \"session:{session-id}\" \\\n     --account auto --json\n   ```\n\n   Replace `--account auto` with `--account {id}` only when a\n   `conduct_child_account` session pin or a user `--account` flag names an\n   account. A `no_account_with_room` refusal leaves the story queued; report\n   the soonest reset from `next_reset` in one line and never pick an account by\n   hand. The brief tells the lane to run `\u002Fexecute-task {project}\u002F{story-id}` and\n   includes `RETURN CONTRACT: json`, applicable policies, the target repo, and\n   the `verify-story-deliverables.sh` evidence gate. Use\n   the same story id for every lane created for its phases. A repeat create for\n   the same worker under the same senior continues that worker's previous\n   thread. If its lane is live, send the follow-up with `hq lanes message`.\n   Read the JSON body for `ok`, `lane_id`, and admission\u002Fcapacity errors. A\n   capacity refusal leaves the story queued for the next tick.\n3. Start and verify the policy-required detached watcher, then wait with `hq lanes wait --any {lane-id} --for envelope\n   --for question --for state --timeout {seconds} --json`. Questions use the\n   existing user decision flow and `hq lanes questions` commands.\n4. Read the latest lane envelope from `hq lanes list --json` and its\n   `last_envelope.ref`. Parse the envelope with `jq -e`, then validate the story id, worker proof, artifacts,\n   back-pressure results, and parent-visible commits before advancing. Retry\n   malformed JSON exactly once with the existing stricter reminder; if the\n   second result is malformed, mark the story blocked with\n   `INVALID_RETURN_FORMAT` and stop the queue.\n5. Preserve the one-line story narration and bounded parent reads. Keep detailed\n   logs and long notes on disk. Do not use conduct pool state as the result\n   source.\n6. Update story status through the board and `hq lanes story` wherever the\n   skill already updates status. Do not add status fields to local `prd.json`;\n   `passes` remains spec acceptance data, not a board column. Mark `passes: true`\n   only after the existing evidence and quality gates pass.\n7. Update state.json after every story, before dispatching the next one. A\n   verified story: `bash core\u002Fscripts\u002Frun-project-state.sh complete {project} {story-id} --commit {sha}`\n   (after `passes: true` is written; the last one marks the run completed). A\n   failed story: `bash core\u002Fscripts\u002Frun-project-state.sh fail {project} {story-id} --error \"{reason}\"`;\n   add `--blocked` for `INVALID_RETURN_FORMAT`, `NEEDS_INTERACTION`, `TIMEOUT`\n   and other blocks. When the run stops early, `bash core\u002Fscripts\u002Frun-project-state.sh finish {project}`\n   marks it `paused`. Each command recomputes `progress` from prd.json.\n\nStories are dispatched one at a time by default. Independent stories may run\nconcurrently only when their worker ids differ, they have no dependency or file\nconflict, and lane admission accepts each create. A same-worker story reuses its\nexisting lane. Do not create a second lane for a worker that is still live; use\n`hq lanes message` for its next brief. Admission and capacity refusals remain\nqueued for a later tick rather than bypassing the lane limit.\n\n### 3c. Regression Gates\n\nKeep the existing budget-aware regression cadence: every three completed\nstories, run the applicable `metadata.qualityGates` for repos touched since the\nlast gate. Run the full matrix at final completion, before deploy, after a\nhigh-risk cross-repo contract change, or when explicitly requested. A gate may\nrun in a worker lane with the same `--company`, `--project`, `--story`,\n`--brief-file`, and session senior mapping; read its result from its lane\nenvelope. Keep detailed logs on disk and the parent transcript to compact JSON.\nA failed gate stops story advancement and follows the existing user decision\npath.\n\n### 3d. Budget and Recovery\n\n- Worker lanes are created with `hq lanes create`; admission and capacity are\n  owned by HQ lanes. Keep only one lane per worker and senior, and use\n  `hq lanes message` while it is live.\n- A completed phase's result comes from its lane envelope. `hq lanes list\n  --json` provides lane state and the latest envelope reference; it is not a\n  substitute for reading the envelope itself.\n- A lane that is still live after the parent turn is resumable. On recovery,\n  list only lanes owned by the original `session:{session-id}` and this project,\n  re-arm watchers for live lanes, and do not dispatch the same story again\n  while its lane is running.\n- Keep one story active by default. Independent stories can overlap only under\n  the constraints in 3b and only when create succeeds.\n- Do not simulate `\u002Fexecute-task` by spawning worker-phase agents from the\n  parent. If the story lane cannot run `\u002Fexecute-task`, use the existing\n  in-session fallback or pause with the current blocker.\n- Read bounded output only. Use compact envelopes and short tails, not raw test\n  logs or full output files.\n\n## Step 3P — Pipeline Mode (`--pipeline`)\n\nOnly with `--pipeline`. Without the flag, skip this whole step: the default\npath is the story coordinator lanes of Step 3, and nothing below changes it.\n\nIn pipeline mode each worker gets one `hq lanes` loop lane for the whole run.\nA detached driver, `core\u002Fscripts\u002Fpipeline-driver.sh`, owns the story queue: it\ncalls `core\u002Fscripts\u002Fpipeline-conductor.sh` to route each phase with\n`hq lanes enqueue`, accepts each phase's handoff, and re-checks acceptance criteria.\nThe driver makes no engine calls. The parent does not run story coordinators.\nPaths below are under `workspace\u002Forchestrator\u002F{project}\u002Fpipeline\u002F`; `{state}`\nis its `state\u002F` subdirectory.\n\nThere is no conductor lane. A lane cannot keep a child process alive past its\nown engine call, so a routing loop started inside a lane dies when that call\nends. The `pipeline-conductor` worker (`core\u002Fworkers\u002Fpublic\u002Fdev-team\u002Fpipeline-conductor\u002F`)\nstays as the written reference for the routing rules the driver follows; it is\nnot launched, gets no worker-table row, and takes no lane slot.\n\n**3P.1 — Pre-flight first, unchanged.** Run Step 2.5 and the Step 3a preflight\nexactly as they run today, including their pauses. If preflight finds stale\nstate (wrong branch, dirty tree, stale file anchors, missing auth, an unlocked\ndesign), pause and surface it the same way; launch no lane until it is\nresolved. Record `session_id` in `state.json` as Step 3 describes. Step 3's\nsingle engine question is replaced by the worker table below. The preflight\nlane is separate from the loop lanes created for the pipeline phases.\n\n**3P.2 — Worker sequences, worker table, confirm once.**\n\nA story's worker sequence (`worker_preference`, or the overlay below) is the\nfull phase sequence for that story, in order: implementer first, then the\nreviewers and testers. The lanes are the union of every story's sequence.\n\nFirst put the preflight's sequences in run state. The Step 3a preflight\nexplorer emits `ordered_stories[]` with a `worker_sequence` per story; save its\nJSON block as `pipeline\u002Fpreflight-plan.json` and import it into the run's\noverlay (`{state}\u002Foverlay.json`; prd.json is not edited):\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh classify --prd {prd.json} --state {state} --overlay pipeline\u002Fpreflight-plan.json\n```\n\nAn overlay entry wins over `worker_preference`, which wins over the keyword\nfallback. Correct one story without a heredoc:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh overlay set --state {state} --story {id} --sequence backend-dev,qa-tester\nbash core\u002Fscripts\u002Fpipeline-conductor.sh overlay show --state {state}\n```\n\nA story the run should not take (out of scope, waiting on someone) goes on the\nskip list instead of being deleted from prd.json:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh skip --state {state} --story {id} --prd {prd.json} --note \"{why}\"\n```\n\nSkipping a story that others depend on prints the dependents it strands and\nneeds `--force`; `unskip --state {state} --story {id}` reverses it.\n\nThen propose the table from the same sequences:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-worker-table.sh {prd.json} --overlay {state}\u002Foverlay.json\n```\n\nIt proposes one `row` for every worker any sequence names (architect and\nqa-tester included). Show every `row` (worker, engine, model, effort, status,\nstories), every `hint` (a story's model_hint) and every `unclassified` story.\nA worker with no `worker.yaml` is reported on stderr with the roots searched and\nthe known ids; fix the sequence rather than answering its row. Then:\n\n- Every row with status `needs-answer` must be answered (engine and model)\n  before anything launches. Ask one question per flagged row (AskUserQuestion,\n  text fallback per `core\u002Fpolicies\u002Fhq-codex-decision-gate-fallback.md`). An\n  `unclassified` story needs an overlay entry (`overlay set`) or goes on the\n  skip list.\n- Do not add a `pipeline-conductor` row: it is not a lane.\n- `HQ_DISABLED_ENGINES` (comma-separated `claude`, `codex`, `grok`) turns any\n  row seeded with a listed engine into `needs-answer` with an empty engine and\n  model, and makes `--confirmed` exit 2 on a lane that names one.\n- A `model_hint` does not override a confirmed row: the lane's model wins, and\n  `--confirmed` prints each hint commented out as \"hint ignored, table pins\n  \u003Cmodel>\". A bare alias (`opus`, `sonnet`, `haiku`) is never passed to an\n  engine. To run a story on another model, change that lane's row.\n- Then confirm the whole table **once**, before the first dispatch. Until the\n  owner confirms and every flagged row is answered, no lane starts and the\n  driver does not start.\n\nWrite the confirmed table (one `\u003Cworker> \u003Cengine> \u003Cmodel> [\u003Ceffort>]` line per\nlane) to `pipeline\u002Ftable.tsv` and check the run against it:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh classify --prd {prd.json} --state {state} --table pipeline\u002Ftable.tsv\n```\n\nWithout `--story` it checks every story that is not passing or skipped and\nwrites no story state. It must exit 0 before launch. It exits 1 and lists each\nproblem when a worker id has no `worker.yaml` (naming the nearest known id),\nwhen a story that declares code files has a sequence that starts with a\nverifier or reader (it suggests prepending an implementer or marking the story\n`\"docs_only\": true`), or when a sequence worker has no row in the table. Its\n`WARN` lines cover one-worker sequences (architect and qa phases will not run),\nmodel hints, and a story whose acceptance criteria or files need a later story\nthat is not in its `dependsOn` (it prints the `dependsOn` line to use). Relay\nthe warnings to the owner; they do not block launch.\n\nTurn the table into per-lane exports:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-worker-table.sh --confirmed pipeline\u002Ftable.tsv --overlay {state}\u002Foverlay.json {prd.json} > pipeline\u002Flanes.env\n```\n\nIt exits 2 on an empty model or an engine other than `claude`\u002F`codex`\u002F`grok`;\ntreat that as an unanswered row. Each lane block exports `HQ_CONDUCT_ENGINE`\n(the engine its phases run on) and that engine's model and effort pins.\n\n**3P.3 — Lane admission.** The conductor creates one `hq lanes` loop lane the\nfirst time a worker is routed, then reuses that lane for the worker's later\nphases. The CLI applies lane capacity and company admission. If `create` returns\n`ok:false` with an admission or capacity error code, the story stays queued and\nthe driver retries on its next tick. The driver itself is not a lane.\n\n**3P.4 — Approval holds.** Every dev-team implementation worker's worker.yaml\nsets `approval_required: true` (`context-manager` and `pipeline-conductor` do\nnot), so the driver's `route` call holds each phase for those workers\n(`route` prints `HELD`, writes `{state}\u002Fdecisions\u002F\u003Cstory>-\u003Cworker>.md`, exits\n10) until the parent releases it. After the table is confirmed, ask once\nwhether to approve the confirmed workers for the whole run; for each approved\nworker run:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh release --state {state} --worker {worker}\n```\n\nA hold that was not pre-approved becomes a decision item (3P.6); release that\nstory alone with `release --state {state} --story {story-id} --worker {worker}`.\nRelease marks the decision `approved` and returns the held story to `queued`.\n\nThe whole-run worker approval does not release a story that needs an explicit\ngo. A story needs one when it carries `approval: \"explicit\"` (the canonical\nkey; `needsApproval: true` is read as an alias), or when the conductor's\nrelease detector flags it: its declared files or acceptance criteria mention\ndeploy, release, production, or merging to the base branch (the patterns are\n`RELEASE_PATTERNS` in `pipeline-conductor.sh`). Such a story is held\n`awaiting_go` before its first implementing phase, whatever the worker's\n`approval_required` says (a release story on `qa-tester` is held too), with\n`{state}\u002Fdecisions\u002F\u003Cstory>-go.md`. `release` does not apply to it. After the\nowner says go:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh go --state {state} --story {story-id}\n```\n\n`resolve` and `park` work on an `awaiting_go` story. The driver keeps routing\nthe rest, lists `awaiting_go` stories on its `TICK` lines in `driver.log` and in\n`report.md` `FINAL:`, and exits 21 naming them once nothing else can move.\n\n**3P.5a — Repos, worktrees and branches.** Each story's repo is resolved from\nits `repoPath`, then (when the PRD lists more than one repo) from the repo that\nowns the story's first declared file, then from `metadata.repoPath`. The repo\nlist is `metadata.repos[]` (canonical: path strings or objects with `path`);\n`metadata.repoPaths[]` is read as an alias. A story whose repo has no worktree\nis held `blocked_needs_owner` with a decision item naming the repo; it is never\nrouted to another repo's tree.\n\nBranch modes:\n\n- Default: one feature branch per repo for the run (`metadata.branchName`, else\n  `feature\u002F{project}`). Every story of that repo commits on it in dependency\n  order, so a dependent story starts from its dependency's commits. One story\n  is in flight per repo branch at a time.\n- `--story-branches` (pass it to the driver): one branch and worktree per story\n  (`pipeline\u002F{story-id}`), cut when the story first routes, from the branch of\n  the last verified story it depends on in the same repo (stacked), else from\n  the base. A story whose dependency branch is missing is held, not routed.\n\nEvery cut starts from `origin\u002F{baseBranch}` when that ref exists after a fetch,\nelse from local `{baseBranch}`, never from the repo's HEAD (`metadata.baseBranch`,\ndefault `main`). The exact ref is printed as `CUT \u003Cbranch> from \u003Cref> \u003Csha>`;\nwhen neither ref exists the cut fails with that message.\n\nDecide before launch (one choice for the run):\n\n| Stories | Worktrees | `PC_MAX_STORIES` |\n|---|---|---|\n| one repo, or dependent stories in each repo (the usual case) | `worktree --shared` once per repo, default branch mode | the number of repos; the conductor lowers a higher value to that and prints `MAX_STORIES` |\n| independent stories that should run side by side in one repo | `--story-branches` | the number of stories to run at once, bounded by the worktrees and lane admission |\n| a repo that is not a git repo, or the owner wants one story at a time | serial: bare `--worktree {dir}` | 1 |\n\nCut one worktree per repo before launch and pass each to the driver:\n\n```bash\nbash core\u002Fscripts\u002Fpipeline-conductor.sh worktree --state {state} --repo {repo} --shared --prd {prd.json}\n```\n\nThe cut lands at `workspace\u002Fworktrees\u002F{project}\u002F{repo-name}\u002F` under the HQ root\n(`{repo-name}-{story}` with `--story-branches`), in every mode, never beside\nthe repo under `repos\u002F`. A worktree must sit inside the HQ root for lanes to cd\ninto it, and it must not sit under `repos\u002F`: the core Write\u002FEdit guard blocks\neditor-tool writes there, so a lane that edits with Write or Edit stalls as\n`blocked_needs_owner`. An explicit `--worktree {dir}` or\n`--worktree {repo}={dir}` (on `worktree`, `tick`, `classify` or the driver)\nthat resolves under `repos\u002F` is refused with exit 2 and a message saying why.\nPass `--allow-repos-worktree` only when the owner wants that tree anyway; then\nevery phase envelope routed into it carries one constraint line telling the\nworker to edit through the shell or `apply_patch`.\n\n**3P.5 — Launch the driver.** The driver creates a company-bound loop lane\nthe first time each worker is routed and records `{worker_id: lane_id}` in\n`{state}\u002Flanes.json`. It reads engine, model, and effort from the confirmed\nworker table. The session must have a company bound before the first route.\nRun-wide hard limits (no push, no deploy, branch rules) go one per line in\n`{state}\u002Fconstraints.txt`; every phase envelope quotes them. Launch the driver\ndetached from the HQ root with `HQ_SESSION_ID` exported:\n\n```bash\nbash core\u002Fscripts\u002Fhq-detach.sh --logfile {state}\u002Fdriver\u002Fdetach.log -- \\\n  sh core\u002Fscripts\u002Fpipeline-driver.sh --prd {prd.json} --state {state} \\\n    --worktree {repo-a}={worktree-a} --worktree {repo-b}={worktree-b} \\\n    --table pipeline\u002Ftable.tsv\n```\n\nFor a single-repo PRD the bare `--worktree {worktree}` form still works.\n`--table` makes the driver refuse to route a phase whose worker has no row\n(exit 27) instead of leaving the story in flight. Add\n`--story-branches` for the stacked mode in 3P.5a. Set `PC_MAX_STORIES` in the\ndriver's environment as 3P.5a says.\n\nIt refuses to start (exit 24) while another driver runs against the same\n`{state}`, so launching it twice is safe. The parent then arms one background\nwaiter on it, with a tool timeout longer than the longest phase deadline:\n\n```bash\nuntil [ -f {state}\u002Fdriver\u002Fexit ]; do sleep 30; done; cat {state}\u002Fdriver\u002Fexit\n```\n\nThe driver polls every 15 seconds (`--interval`). Each pass it accepts every\nhandoff a lane wrote to `result_path`, runs `recheck` for finished stories,\nand ticks the conductor helper to route the next phase or start the next\nstory. It appends one line per action to `{state}\u002Fdriver\u002Fdriver.log`. When it\nexits it writes `{state}\u002Fdriver\u002Fexit` as `\u003Ccode> \u003Creason>`:\n\n| Code | Meaning | Parent action |\n|---|---|---|\n| 0 | every story finished (verified, failed after its one reroute, accepted as a partial draft, or parked); `report.md` has its `FINAL:` line | 3P.8 |\n| 2 | usage error | fix the command |\n| 20 | a regression gate is due | run the gate in the `regression-gate` slot (Step 3c), record `pipeline-conductor.sh gate result pass\\|fail --state {state}` (add `--story {id} --note \"...\"` to a `fail` caused by one verified story: it reopens that story, see 3P.6), relaunch the driver |\n| 21 | a decision is needed: a story is held for approval; a phase returned `blocked`, a story has no worktree for its repo, or a story is `awaiting_go`, and nothing else can move; the gate failed; a phase returned `failed` `--max-phase-fails` times; or a phase's engine exited early twice (`engine_exited_early`, see below) (the reason names the status or `engine_exited_early` and the attempt count; the story is then held as `blocked_needs_owner` with `{state}\u002Fdecisions\u002F\u003Cstory>-blocked-\u003Cphase>.md` carrying each failed handoff's text) | 3P.6: read the decision item, ask the owner once, run the matching command (`resolve --as retry --prd \u003Cprd>` re-reads the story's phases, so fix the sequence first with `overlay set` when the lane was wrong; the attempt count starts over), relaunch the driver |\n| 22 | an in-flight phase passed its deadline with no handoff | check the lane with `hq lanes list --json`, then relaunch the driver or stop the run |\n| 23 | the conductor helper printed something unexpected | read the last lines of `driver.log`, surface them, do not relaunch blindly |\n| 24 | another driver already runs against `{state}` | leave it; re-arm the waiter on it |\n| 25 | retired: the stall check now fires the stall event and exits 28 | - |\n| 26 | lane down: `hq lanes enqueue` reports `loop_not_running`; the story stays `queued` and its worker mapping is removed | restart the driver; the next route creates a fresh loop lane |\n| 27 | no lane: a phase's worker has no row in `pipeline\u002Ftable.tsv`; the reason names the worker and the story stays `queued` | add the row (ask the owner for its engine and model), launch that worker's loop lane as 3P.5 does, relaunch the driver |\n| 28 | a loop lane parked its phase after repeated stalls and raised a question | list its pending question with `hq lanes questions list --company {company} --json`, answer it, then restart the driver |\n| 29 | stopped on request: the parent ran `pipeline-conductor.sh stop` (see \"Stopping a run\" below) | relaunch the driver when the owner wants to resume |\n| 130, 143 | interrupted or terminated; in-flight phases are marked `interrupted` first | relaunch the driver; it routes interrupted stories first |\n\n**Early engine exit.** When a loop lane's engine call for a phase returns\nwithout a usable handoff, the lane writes a failed handoff with\n`exit_reason: \"engine_exited_early\"` and a `phase-exit` event (reason, elapsed\nseconds) to its `journal.jsonl`. A handoff whose status is not `passed`,\n`failed` or `blocked` is not accepted; with a `phase-exit` event since the\nphase was routed it counts the same way. On the next tick the driver logs\n`EARLY_EXIT \u003Cstory>\u002F\u003Cphase> after \u003Cn>s` and accepts it as a failed phase, which\nroutes the phase once more to the same lane. A second early exit of that phase\nholds the story for the owner (exit 21 naming `engine_exited_early`; the\ndecision item carries the reason). A phase whose engine is still running keeps\nthe deadline path (exit 22).\n\n**Loop lane admission.** `hq lanes create --loop` applies lane admission and\ncapacity rules. Admission or capacity refusals leave the story queued for the\nnext tick. A stopped or failed lane is removed from `lanes.json` and recreated\non the next route.\n\n**Stopping a run.** Stop with\n`bash core\u002Fscripts\u002Fpipeline-conductor.sh stop --state {state} --note \"{why}\"`.\nWith a live driver it writes `{state}\u002Fdriver\u002Fstop.json` (a stop envelope,\n`{\"kind\":\"stop\"}`) and the driver exits 29 on its next pass; with no live\ndriver it marks the stories itself. Every stop path (that command, SIGTERM,\nSIGINT, and a loop lane that exited on a stop envelope while a story was in\nflight on it) marks each `in_flight` story `interrupted` with the phase and\ntime in `stories\u002F\u003Cid>.json`, withdraws its envelope from the lane queue when no\nlane picked it up, and keeps a partial handoff as\n`handoffs\u002F\u003Cid>-\u003Cphase>.interrupted.\u003Cn>.json`. A phase whose handoff already\nfinished it is left for the next driver to accept. The relaunched driver routes\ninterrupted stories first, before reopened ones, at the interrupted phase; the\nenvelope carries `resumed_after_interrupt: true` and `prior_handoff` when a\npartial handoff exists. `TICK` lines in `driver.log` and the `FINAL:` line name\ninterrupted stories until they are routed again.\n\nA handoff with status `failed` is routed again until it has failed\n`--max-phase-fails` times (default 2). A handoff with status `blocked` is never\nrouted again: a rerun cannot help. The conductor holds that story as\n`blocked_needs_owner`, writes `{state}\u002Fdecisions\u002F\u003Cstory>-blocked-\u003Cphase>.md`\nwith the story, phase, lane and the worker's own blocker text, and the driver\nkeeps routing every story that does not depend on it. A blocked story does not\ntake a slot under `PC_MAX_STORIES`.\n\nEvery relaunch uses the same command. The driver reads all of its state from\n`{state}`, so a relaunch resumes where the last one stopped and does not run a\nfinished phase again.\n\nNo step here starts a background shell loop inside a lane. The driver is the\nonly loop, and it runs outside every lane.\n\n**3P.6 — Relay, do not drive.** While the run is live the parent:\n\n- Ends every turn in which a pipeline lane is live with the lane rows. Pull\n  them once with\n  `sh core\u002Fscripts\u002Fpipeline-lane-rows.sh --state {state} --session-id {session_id}`\n  (one JSON array: an item per mapped hq loop lane and one\n  `kind: \"driver\"` item). Call `mcp__visualize__read_me` with `[\"mockup\"]`\n  once per session first, silently, then render `mcp__visualize__show_widget`\n  in HTML mode from the template `.claude\u002Fskills\u002Fconduct\u002Flane-rows.html`: one\n  `.row` per worker lane plus one for the driver, the CSS untouched, flex rows,\n  never a grid or cards. Per lane row: the worker; the phase chip from\n  `phase_label`; the meta from `phase_elapsed_s`, `quiet_s` and\n  `inbox_pending`; a rough percentage from `phase_index` of `phase_count`\n  (`(phase_index - 1) \u002F phase_count`, never 100% before the story is\n  verified); the story title in plain words; `last_line` in plain words; the PR\n  link when `pr` is set. Dot: green when the lane runs and is active; yellow\n  when it waits on an envelope, on the owner, or has been quiet 20 minutes or\n  more (`quiet_s` >= 1200); red when `pid_alive` is false on a lane that has\n  not exited, or the driver exited non-zero; blue on a lane that exited 0\n  (`exit` is `0`). The driver row carries the story counts (verified,\n  in_flight, queued, blocked, parked, skipped, interrupted, awaiting_go) and\n  its `last_line`. Then the one-line reply. Nothing the owner must decide goes\n  in a row: that is `\u002Fdecision-queue`, after the rows. Zero live lanes means no\n  rows.\n- Relays the per-story report lines from `{state}\u002Freport.md` (one line per\n  finished story, one `FINAL:` line at the end). It does not report per\n  phase.\n- Surfaces decision items through the decision queue (`\u002Fdecision-queue`), one\n  at a time: approval items in `{state}\u002Fdecisions\u002F` marked `status: pending`,\n  and loop lane questions with `hq lanes questions list --company {company}\n  --json`. Answer with `hq lanes questions answer`. Apply\n  each answer with `pipeline-conductor.sh release`, or as the item's options\n  describe, then relaunch the driver.\n- On exit 21 for a blocked story (`decisions\u002F\u003Cstory>-blocked-\u003Cphase>.md`,\n  `status: pending`): read the decision item, ask the owner once and quote the\n  worker's blocker text from it, run the one command that matches the answer,\n  then relaunch the driver with the same command as before. None of these is\n  ever applied without the owner's answer.\n\n  | Owner's answer | Command |\n  |---|---|\n  | accept it as a partial draft; let dependents start | `bash core\u002Fscripts\u002Fpipeline-conductor.sh resolve --state {state} --story {id} --as accepted-partial --note \"{owner's reason}\"` |\n  | run the phase again with this answer | `bash core\u002Fscripts\u002Fpipeline-conductor.sh resolve --state {state} --story {id} --as retry --note \"{owner's answer}\"` |\n  | set it aside with everything that depends on it | `bash core\u002Fscripts\u002Fpipeline-conductor.sh park --state {state} --story {id} --note \"{why}\"` |\n  | bring a parked story back | `bash core\u002Fscripts\u002Fpipeline-conductor.sh unpark --state {state} --story {id}` |\n  | leave a story out of the run | `bash core\u002Fscripts\u002Fpipeline-conductor.sh skip --state {state} --story {id} --prd {prd.json} --note \"{why}\"` (add `--force` only after the owner accepts the stranded dependents it lists) |\n  | go for a story held `awaiting_go` | `bash core\u002Fscripts\u002Fpipeline-conductor.sh go --state {state} --story {id}` |\n\n  `accepted-partial` is a terminal state, separate from `verified`: it counts\n  as done for `dependsOn`, its report line and the `FINAL:` line list the\n  owner's note and the unmet acceptance criteria, and `passes` stays unset.\n  Do not write `passes: true` for it. `retry` routes the phase as a fresh call\n  with the owner's note in the envelope. `park` holds every story that depends\n  on the parked one, directly or not, as `parked_dependency`; the `FINAL:` line\n  lists parked stories and why. `park` prints `PARK_CLOSURE \u003Cid> \u003Cn>: \u003Cids>`\n  before it acts; when it would park more than `PC_PARK_CONFIRM` (default 5)\n  stories it refuses until it is repeated with `--force`. Show the owner that\n  list and ask before adding `--force`. `unpark` prints what it releases. Park,\n  unpark, skip and unskip each add a line to `{state}\u002Fdecisions.log`. Each command refuses a story in a state it\n  does not apply to (exit 1) and prints `ALREADY` when repeated.\n- On exit 20, if the gate fails because of one story the run already\n  verified (its own QA passed because the guard test lives outside its suite),\n  record the failure naming that story instead of a plain `fail`:\n  `bash core\u002Fscripts\u002Fpipeline-conductor.sh gate result fail --state {state} --story {id} --note \"{what the gate found}\"`.\n  The conductor reopens the story and sets the gate to `reopened`, which does\n  not stop routing; the relaunched driver routes that story first. The same\n  works after a plain `gate result fail` was already recorded. To send a\n  story back without a gate, run\n  `bash core\u002Fscripts\u002Fpipeline-conductor.sh reopen --state {state} --story {id} --note \"{why}\" [--from-phase {phase}]`.\n  Reopen applies to a `verified` or `accepted_partial` story. It queues the\n  story at `--from-phase` (default: the first phase whose worker is not a\n  reviewer or tester), archives that phase's and later handoffs as\n  `handoffs\u002F\u003Cid>-\u003Cphase>.reopened.\u003Cn>.json`, starts the attempt count over,\n  puts the note in the next envelope (`reopen_note` and a constraint line),\n  and sets `passes` back to false in prd.json if it was true, saying so.\n  Stories that depend on it and are already verified are not reopened; the\n  `FINAL:` line lists them as \"verified before {id} was reopened\" for the\n  owner to decide. Once every reopened story verifies again the gate is due\n  (exit 20): run it and record `pass` or `fail` as usual. Reopen refuses\n  other states (exit 1) and prints `ALREADY` when repeated.\n- Records `passes: true` in prd.json for a story only after the report says it\n  is verified; the driver and the conductor helper never write `passes`.\n\n**3P.7 — After a parent compaction, recover from disk.** The run state lives\nin files, not in the parent's context. After a compaction or in a new session,\nrebuild it from `state.json` (`session_id`), `pipeline\u002Ftable.tsv`,\n`{state}\u002Fstories\u002F` (each story's phase and state), `{state}\u002Freport.md`,\n`{state}\u002Fdecisions\u002F`, `{state}\u002Fdriver\u002F` (`driver.pid` while it runs, `exit`\nonce it stopped, `driver.log`), `workspace\u002Fsessions\u002F\u003Cid>\u002Fdecisions.jsonl`, and\n`hq lanes list --json` filtered to ids in `{state}\u002Flanes.json` for live lanes.\nDo not relaunch a lane whose loop state is `waiting` or `running`. If `driver.pid`\nnames a live process, re-arm the waiter; if `exit` is present, act on its code;\nif neither, relaunch the driver.\n\n**3P.8 — Run end: stop every lane.** The driver stops each lane id in\n`{state}\u002Flanes.json`. It reports completion only when `hq lanes list --json`\nshows every owned loop state as `stopped` or the lane is absent from the list.\nIt clears the mapping after confirmation so a resumed run creates fresh lanes.\nThen continue with Step 6.\n\n## Step 4 — Parent-Driven Interactive Codex Execution\n\nInteractive mode is parent-driven. It replaces Claude session-mode for Codex.\n\nUse when the project is small enough for the parent session and the user may want to steer implementation decisions.\n\nCodex interactive mode is direct parent execution, not proof that the HQ worker pipeline ran. If the user asks for worker-backed execution, or if a PRD\u002Fstory requires `workers_run`, worker handoffs, or `\u002Fexecute-task` semantics, stop and route to Ralph\u002Fheadless (the unattended inline worker loop).\n\nProcess:\n\n1. Resolve and read `prd.json`.\n2. Read only applicable policy frontmatter first; read full rule text only for hard rules that apply to the project.\n3. Write a durable plan file to `workspace\u002Forchestrator\u002F{project}\u002Fcodex-session-plan.md` containing:\n   - project, company, repo path, branch base, resume state\n   - incomplete story order\n   - acceptance criteria and declared files\n   - applicable policy rules\n   - quality gates\n   - chosen mode: `interactive`\n4. Ask the user to approve, adjust, or switch to Ralph\u002Fheadless mode.\n5. Execute one story at a time in the parent session:\n   - make edits directly\n   - run back-pressure checks\n   - commit per story\n   - mark `passes: true` only after verification (worker proof, commits, and the evidence check `verify-story-deliverables.sh --evidence-json … --commits-json … --write` exit 0)\n   - do not claim `workers_run` or worker-backed completion unless `\u002Fexecute-task` actually ran through the worker system\n   - update `workspace\u002Forchestrator\u002F{project}\u002Fstate.json` with `core\u002Fscripts\u002Frun-project-state.sh` (`init` once, then `start` and `complete`\u002F`fail` per story, as in Step 3b)\n6. Pause between stories and ask continue \u002F adjust \u002F stop.\n\nDo not spawn an end-to-end `\u002Fexecute-task` sub-agent in Codex interactive mode unless the user explicitly asks for delegated agent work. Bounded helper agents are okay only when explicitly requested or clearly available, and they must return compact structured output.\n\n## Step 5 — Ralph\u002FHeadless Unattended Execution\n\nUse when the project is long-running and the user wants it to run to completion without being prompted between stories.\n\nRalph\u002Fheadless is **the same pooled, detached story loop as Step 3, run unattended.** Same lanes, same pool, same return contract; it differs only in that it does not pause.\n\n**What detachment does and does not buy here — say this plainly, because the\ndifference matters to anyone leaving a run going.** The *stories* are detached:\nthe in-flight one keeps running and keeps committing when the parent session\nends, where the previous in-session loop died with its parent mid-story. The\n*coordinator* is not. The waiter, the result validation, the slot release and\nthe decision to dispatch the next story all live in the parent. So a session\nthat ends mid-run leaves exactly one story running to completion and then\nstops — it does not auto-advance to story N+1 unattended. \"Unattended\" here\nmeans no prompts between stories **within a session**, not a run that drives\nitself after the session is gone.\n\nThat makes the run *resumable*, not *self-driving*, and resuming takes a new\nsession: `hq lanes list --json` shows the lanes launched by the session, and\n`state.json` says which stories are done. A genuinely self-driving run would\nneed the loop itself dispatched as a lane — an extra coordinator level with its\nown lane accounting — which does not exist today. Do not tell a user their run\nwill finish on its own after they close the session.\n\n**5.0 — Pre-flight (run ONCE, before the loop starts).** Skipping the *approval pause* (operational step 1 below) must not skip *validation*. Before auto-advancing, the orchestrator must:\n\n1. **Pre-create the feature branch** from `metadata.baseBranch` unless `--in-place` was passed — never let an unattended run discover mid-loop that it has been committing to the wrong branch (`run-project-precreate-branch-before-ralph`).\n2. **Scan the PRD for stories whose acceptance requires interactive input** (a decision the worker would surface via `AskUserQuestion`) and mark them `blocked` up front with reason `NEEDS_INTERACTION` — do not let them wedge the loop mid-run (`hq-cmd-run-project-no-askuserquestion-stories-in-ralph-mode`). Workers in ralph mode never call `AskUserQuestion`.\n3. **Verify the target repo + branch resolve and the tree is clean.** Abort with a clear message if not — an unattended run on a dirty or missing tree is never correct.\n\nIf any pre-flight check cannot be satisfied, stop and surface it; do not start the loop.\n\nThe operational differences from default inline are then:\n\n1. **Skip the preflight approval gate (Step 3a).** Still run the preflight explorer slot to build the plan (claimed or resumed the same way), but do not pause for approval — log the plan to `workspace\u002Forchestrator\u002F{project}\u002Fcodex-session-plan.md` and proceed.\n2. **Auto-advance.** Run the Step 3b story loop for every approved incomplete story back to back. Do not pause between stories (Step 3b.10 already auto-advances; ralph-mode also skips the >10-story and session-mode pauses). All per-story invariants still hold: JSON-validate the worker return, enforce the worker-proof gate, verify parent-visible commits, mark `passes: true` only after verification, and update `state.json` after each story with `core\u002Fscripts\u002Frun-project-state.sh` (Step 3b.7).\n3. **Run regression gates on cadence.** Apply Step 3c every 3 completed stories exactly as in inline mode.\n4. **Report once.** Emit one compact line per story to the transcript (`[{story_id}] {status} · {files_changed} files · {first_commit_short_sha}`); send anything longer to `workspace\u002Fthreads\u002Fjournal\u002F\u003Cdate>\u002F\u003Cstory-id>.md`. Surface a single summary at the end rather than pausing throughout.\n5. **Bound wedge time.** A lane that never returns must not stall the run forever. Set the waiter's `deadline` file from the per-story budget (default ~20 min; honor `--timeout N` minutes if passed) — **not** the runner's `timeoutSecs`, which only prints a repeating warning and never kills, so on its own it bounds nothing and the waiter would loop for a `CONDUCT_EXIT` marker that never arrives. When the waiter returns `outcome: deadline`, the lane is **still running**: ask the runner to stop and wait for its `CONDUCT_EXIT` marker (dispatch protocol §5 — signalling the wrapper group never reaches the engine, which the runner spawns detached into a group of its own). Mark the story `blocked` with reason `TIMEOUT`, stop, and surface it either way. Retire the slot with `recycle --force` **only if the lane stopped cleanly and §5's confirmation reported `engine_gone=yes`** — that confirmation runs on every outcome, not just this one, so a `died` or `never-started` lane with a surviving engine group is held back the same way; if the marker never arrived or the group still has members, leave the slot `running`, say the engine may still be live, and let the user decide — reusing an unconfirmed slot puts the next worker in a lane the old one is still writing to. Do not silently move on. Slow back-pressure (e.g. heavy E2E) is the usual cause.\n\nStop and surface to the user mid-run only on a hard blocker: a story that lands `blocked` (including `INVALID_RETURN_FORMAT`, `NEEDS_INTERACTION`, or `TIMEOUT`), a failed regression gate (coarse 3-story gate or a per-story `all_story_tests_pass: false`), or a worker that cannot run `\u002Fexecute-task`. Do not silently skip past a blocked story to the next one — auto-advance applies to *passed* stories only.\n\nEvery story lane has a PID, a run dir, and a `lane.log`, so **a new session** can pick the run back up — nothing picks itself back up.\n\n**Resume against the original session id, not the new one.** Read `session_id`\nout of `state.json` and pass it explicitly; the pool and the run dirs are both\nkeyed by the session that created them, and a bare `list` in a fresh session\nreports an empty pool while the old lanes are still live:\n\n```bash\nhq lanes list --json --senior \"session:$(jq -r .session_id workspace\u002Forchestrator\u002F{project}\u002Fstate.json)\"\n```\n\nThat listing names the live lanes and their current state. Re-arm a waiter (dispatch\nprotocol §5) on every lane still `running` **before** doing anything else — an\nunwatched live lane is a lane nobody is running — and do not re-dispatch a story\nwhose lane is still up, however incomplete `state.json` says it is. A story\nmarked incomplete with a live lane is a story mid-flight, not a story to start\nagain. `record`, `recycle` and `cancel` all take `--session-id` too; a recovery\nthat omits it operates on the wrong pool silently.\n\nProgress also lives in `state.json` and `progress.txt`, which the loop updates as it goes; `--status` and `--dry-run` against `{run_project_script}` remain available for out-of-band inspection.\n\n## Step 6 — Completion\n\nAfter either mode completes:\n\n1. Confirm all intended stories have `passes: true`.\n2. Confirm commits exist for completed stories.\n3. Run project quality gates or report why they were skipped.\n4. Run `qmd update 2>\u002Fdev\u002Fnull || true`.\n5. **Auto-checkpoint** \u003C!-- AUTO-CHECKPOINT-ON-COMPLETION -->. Save a lightweight checkpoint so a fresh session can resume without a manual handoff. Codex does **not** use the `\u002Fcheckpoint` primitive — write the thread file DIRECTLY: `workspace\u002Fthreads\u002FT-{UTC YYYYMMDD-HHMMSS}-auto-run-project-{project}.json` with `thread_id`, `version: 1`, `type: \"auto-checkpoint\"`, `created_at`, `updated_at`, `workspace_root`, `cwd`, `git: { branch, current_commit, dirty }`, `conversation_summary` (stories passed \u002F blocked this run), `files_touched`, `next_steps`, and `metadata: { title: \"Auto: run-project {project}\", tags: [\"auto-checkpoint\", \"run-project\"], trigger: \"run-project-complete\" }`. **Dedup:** if an auto-checkpoint thread (`workspace\u002Fthreads\u002FT-*-auto-*.json`) was already written for this run, upgrade\u002Freuse it instead of writing a duplicate. Cheap only — no INDEX\u002F`recent.md`\u002F`qmd` rebuild.\n6. Ask whether to document release, run a retrospective, or end here.\n\n## Rules\n\n- **Do not reference `.Codex\u002Fcommands\u002Frun-project.md` as required source** — this skill is the Codex router.\n- **Do not assume Claude-only primitives** — `Task`, `ExitPlanMode`, `\u002Fcheckpoint`, and `\u002Fcompact` are not Codex requirements.\n- **Default stories run through `\u002Fexecute-task` in an HQ worker lane** created with `hq lanes create`, using the bound company, project, story, worker, brief file, and `--senior session:{id}`. Interactive mode stays parent-driven.\n- **Carry trusted company and story context into every lane** — resolve the company from the run state and pass the project and story explicitly. Never infer a company from cwd.\n- **Use lane results as the delivery record** — inspect `hq lanes list --json`, then read the latest envelope. Do not infer success from local process state or exit code.\n- **Preserve HQ invariants** — PRD acceptance data, board status, file locks, active-run coordination, commits per story, JSON returns, evidence, and quality gates remain required in every mode.\n- **Ask before mode changes** — switching from the default story-lane path to parent-driven interactive or Ralph\u002Fheadless is a user-facing execution semantic. Preserve the decision gate with text fallback if needed.\n- **Budget mode is default** — prefer low-reasoning story execution, compact JSON returns, bounded log reads, changed-repo regression gates, and no parent-side phase fanout.\n",{"name":5,"description":7,"allowed-tools":44,"argument-hint":45},"Read, spawn_agent, wait_agent, Bash(hq lanes create:*), Bash(hq lanes list:*), Bash(hq lanes wait:*), Bash(hq lanes message:*), Bash(hq lanes questions:*), Bash(hq lanes story:*), Bash(bash core\u002Fscripts\u002Fhq-session.sh:*), Bash(bash core\u002Fscripts\u002Frun-project-state.sh:*), Bash(node core\u002Fscripts\u002Fworkflow-runner.mjs:*), Bash(bash core\u002Fscripts\u002Fhq-detach.sh:*), Bash(ps:*), Bash(grep:*), Bash(bash:*), Bash(jq:*), Bash(cat:*), Bash(tail:*), Bash(kill:*), Bash(ls:*), Bash(mkdir:*), Bash(echo:*), Bash(sleep:*), Bash(qmd:*), Bash(test:*), Bash(bash core\u002Fscripts\u002Fwork-mesh-live-bind-trusted.sh:*), Bash(sh core\u002Fscripts\u002Fpipeline-lane-rows.sh:*), Bash(bash core\u002Fscripts\u002Fpipeline-conductor.sh:*), Bash(bash core\u002Fscripts\u002Fpipeline-worker-table.sh:*), Bash(sh core\u002Fscripts\u002Fpipeline-driver.sh:*), Bash, Write, AskUserQuestion, Task, mcp__visualize__read_me, mcp__visualize__show_widget","{project} [--status] [--resume] [--dry-run] [--inline] [--interactive] [--ralph-mode] [--pipeline] [--in-place] [--timeout N]","main","205cf61728a27ef15e9153aa38df5856fc8d82f5",".claude\u002Fskills\u002Frun-project",18,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core","https:\u002F\u002Fgithub.com\u002Findigoai-us","https:\u002F\u002Fhqforwork.com\u002F","The AI Context Layer for Teams","2026-11-12 06:53:38",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add indigoai-us\u002Fhq-core --skill run-project",{"tool":61,"command":62},"bunx","bunx skills add indigoai-us\u002Fhq-core --skill run-project",{"tool":64,"command":65},"pnpm","pnpm dlx skills add indigoai-us\u002Fhq-core --skill run-project","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002FSKILL.md",true,[69,75,81,85,89,95,99,103,107,111,115,119,123,127,131,135],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},".claude-plugin\u002Fplugin.json","REFERENCE","参考文档",249,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002F.claude-plugin\u002Fplugin.json",{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},".gitignore","OTHER","其他",91,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002F.gitignore",{"path":82,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":83,"sourceHtmlUrl":84},"agents\u002Fopenai.yaml",119,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fagents\u002Fopenai.yaml",{"path":86,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":87,"sourceHtmlUrl":88},"hooks\u002Fhooks.json",34,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002Fhooks.json",{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"hooks\u002Fprogress.ts","SCRIPT","脚本",2307,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002Fprogress.ts",{"path":96,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":97,"sourceHtmlUrl":98},"hooks\u002FREADME.md",4109,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002FREADME.md",{"path":100,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":101,"sourceHtmlUrl":102},"hooks\u002Fregister.tsx",14983,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002Fregister.tsx",{"path":104,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":105,"sourceHtmlUrl":106},"hooks\u002Frun-state.ts",8782,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002Frun-state.ts",{"path":108,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":109,"sourceHtmlUrl":110},"hooks\u002Fscope.ts",2954,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Fhooks\u002Fscope.ts",{"path":112,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":113,"sourceHtmlUrl":114},"tests\u002Ffixtures.ts",1715,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftests\u002Ffixtures.ts",{"path":116,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":117,"sourceHtmlUrl":118},"tests\u002Fmod.test.tsx",18641,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftests\u002Fmod.test.tsx",{"path":120,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":121,"sourceHtmlUrl":122},"tests\u002Fprogress.test.ts",2709,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftests\u002Fprogress.test.ts",{"path":124,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":125,"sourceHtmlUrl":126},"tests\u002Frun-state.test.ts",7773,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftests\u002Frun-state.test.ts",{"path":128,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":129,"sourceHtmlUrl":130},"tests\u002Fscope.test.ts",3585,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftests\u002Fscope.test.ts",{"path":132,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":133,"sourceHtmlUrl":134},"tsconfig.json",56,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftsconfig.json",{"path":136,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":137,"sourceHtmlUrl":138},"types\u002Findex.d.ts",1095,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frun-project\u002Ftypes\u002Findex.d.ts",[140,148,155,162,169,176],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":147},"01M73NTNKZ3T2KJNDP2ZF23645","job","Deprecated alias for \u002Fschedule — Outpost recurring agent jobs. Prefer \u002Fschedule.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fjob\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":147},"01M73NTE0H9DQTT6DNHDKRWTXW","import-claude","Deprecated alias for \u002Fimport-context — bootstrap HQ from your prior AI footprint (Claude Code, Codex, Grok, claude.ai history plus on-disk artifacts).","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimport-claude\u002FSKILL.md",[],[],{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":147},"01M73NT67433KKX96CCJWDQQ0X","hq-whoami","Show current HQ Cognito identity and session expiry.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-whoami\u002FSKILL.md",[],[],{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":147},"01M73NT17SVXZV2QPT14C2RPJP","hq-share","Share HQ vault paths through single-use links or direct ACL grants.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-share\u002FSKILL.md",[],[],{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":175,"publishedAt":147},"01M73NSXYFMD7EHGT8TFDZA3C8","hq-secrets","Use HQ CLI secrets safely through env injection or one-off exec.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-secrets\u002FSKILL.md",[],[],{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":182,"publishedAt":147},"01M73NSWCXJK29Q8CNG8AS3ZZQ","hq-logout","Sign out of HQ Cognito and clear local tokens.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-logout\u002FSKILL.md",[],[]]