--- name: factory-runbook description: Use when a factory run must post its changes — check out the run branch, commit a step's allowlisted paths, push only that branch, and open or reuse one draft MR/PR with milestone/assignee ownership. Also the shared home for factory run contracts (executor, tracker integration, lanes, brief and provider templates). reference-only: true disable-model-invocation: true --- # factory-runbook > **Scope rule**: scripts stay skill-local — never source a script from another skill. For another skill's operations, invoke that skill (e.g. `architect-clarify`, `product-clarify`, `team-boot`) via the Skill tool; for its documents, follow the `Requires` line. `scripts/` and `references/` below are relative to this skill. `{REPO_ROOT}` denotes the project root (where `.adlc/` lives). ## What this skill does `factory-runbook` is the shared run mechanics of the software factory. It has two halves: 1. **Publish procedure** (below) — the deterministic branch → commit → push → draft-MR/PR sequence every factory run ends with. Factory orchestrators read the procedure and run the helpers in `scripts/` directly for their publish step; the skill itself is never invoked. 2. **Run contracts** (`references/`) — the executor loop, tracker integration, lanes, brief/provider templates, and run-context rules that factory skills borrow by path instead of copying. It never approves or merges. The engine's gate after the step is the approval. **Reference-only rule:** this skill is reference-only — never invoke it via the Skill tool. Orchestrators read the procedure below and run the helpers in `scripts/` directly. **Direct-invocation guard:** publishing needs a run context — `ADLC_RUN_ID` (and usually `ADLC_ISSUE_REF` plus `ADLC_STEP_OUTPUT`) from a workflow run, the lane's `WORKFLOW_INPUTS` in a raw lane run (reviews, `autonomous` missions: `bash scripts/bash/run-context.sh` prints `factory_run=yes` and the `run_id` / `issue_ref` to use, and the helpers below adopt it on their own), or explicit orchestrator-provided args (orchestrator name, step id, output type, paths). Never invent a branch name, a step, paths to commit, or a run id, and never set `ADLC_RUN_ID` by hand. Without a run context and without them, state what is missing and stop. --- ## Publish procedure — read this first **Requires:** nothing — this skill is self-contained. (Borrowers declare the reverse: `adlc-cli skills add tikalk/adlc-team-skills --skill factory-runbook`.) 1. **Start:** `bash scripts/bash/run-branch.sh [--kind ]` — on Windows, the PowerShell twin (every helper has one under `scripts/powershell/`). Checks out the run branch (`factory/intent/-` from `ADLC_ISSUE_REF` for intent runs — the default; `factory/mission/-` with `--kind code` for mission code runs) in the project root, reusing it or continuing from `origin`. A new code branch starts from origin's default branch, never from the checked-out intent branch, so the intent step's drafts stay out of the code MR. **Target branch:** when the run was dispatched against another branch (`ADLC_TARGET_BRANCH`, else `WORKFLOW_INPUTS.target_branch`; `bash scripts/bash/target-branch.sh` prints it), that branch takes the default branch's place — a new run branch starts from `origin/`, and step 3 opens the MR into it. A target that is invalid or missing on `origin` stops the helper (exit 2): it never falls back to the default branch, and neither do you (`references/run-context.md`). Shared by both intent lanes and with re-dispatches. Without a run context (`ADLC_RUN_ID`, or the lane's `WORKFLOW_INPUTS.run_id` adopted through `scripts/bash/run-context.sh`) this is a no-op. 2. Run the lifecycle steps. After **each** step that changed files: `bash scripts/bash/commit-step.sh --orchestrator --step --output-type --summary "" --records -- `. Stages ONLY allowlisted paths; prints `sha: ` or `sha: none` for the step's bus marker. 3. **Before returning, always:** `bash scripts/bash/open-mr.sh [--kind ]` — pushes the run branch only, finds or opens one draft MR — into the run's target branch when it has one, else the default branch — (merge commit, no squash; Issue milestone applied inline, Issue assignees else the runner's own account, per `tracker-integration.md` Operation 11; the deterministic resolver `scripts/bash/resolve-mr-ownership.sh` itself runs at caller/completion, not inside `open-mr.sh`), and the `agent-authored` stamp likewise lives at completion (mission Phase 6, orchestrator §7 hygiene — not in this helper). It writes `mr_url` to `ADLC_STEP_OUTPUT`. Pass `--kind code` for code missions (`factory/mission/*` branch). Call it whatever the outcome — an empty run opens nothing and the gate shows no link. Also write a one-line `conclusion` into the same JSON object, preserving existing keys. 4. **Never ask for approval** or wait for an answer here. A helper's non-zero exit (refused path, missing committer identity, tracker scope) stops the run — report it, do not work around it. Outside a factory run the helpers do nothing unless the user opted in (`adlc.commit_steps: true` in `.adlc/init-options.json`, or `--commit` forwarded to `commit-step.sh`); `run-branch.sh` and `open-mr.sh` never act without a run context (`scripts/bash/run-context.sh` prints `factory_run=no`). Only a factory orchestrator following this procedure commits, pushes and opens the MR, and only through these helpers; lifecycle skills never do. **Lifecycle labels:** `bash scripts/bash/set-lifecycle.sh --issue --to ` is the Set Lifecycle step of `references/tracker-integration.md` Operation 9 as one command: it adds the target, removes every other lifecycle label in the same call, re-reads the labels and exits 0 only when exactly the target remains (1: another lifecycle label is still there; 2: usage or tracker error). `--issue` defaults to the run's issue. **Completion record:** `bash scripts/bash/post-completion.sh --outcome --conclusion "" [--mr-url ]... [--details-file ]` leaves a mission run's one completion record on its issue (``; blocked/failed records also carry the `factory-run:ended` marker). The run id comes from the run context only; a run whose newest record already says this outcome posts nothing, and a different outcome (the run was retried or resumed and ended differently) is posted as a record that names the one it replaces; the record is read back over every page of the thread (exit 0 only when it is on the issue). `--mr-url` repeats, one per MR/PR of the run; the record then carries ``, and the same outcome with a changed list (the pointer bump appended) is posted again so the newest record holds the whole list. **Settle the lifecycle:** `bash scripts/bash/settle-mission.sh ` answers rows 9 and 10 of the transition table from the merge state of every `mr_urls` entry: `done` only when all merged, `cancelled` on a close with an entry unmerged or nothing merged, otherwise `validation` — plus whether to close or reopen the issue and, for a workspace mission whose child MRs all merged, the merged SHAs to open the pointer-bump MR at. Pure computation: the caller reads the marker and the hosts; payload and output are in the script header. **Proof of work:** `bash scripts/bash/check-proof-of-work.sh --issue --summary-file ` checks the mission's ledger (`.adlc/workflows/runs//proof-of-work.json`, one entry per item of the issue's `## Definition of Done`) against the issue: exit 0 every item done (not-applicable items disclosed with their reason), 3 some skipped and disclosed, 1 an item unaccounted for / `done` without evidence / "pending" as a reason, 2 usage or read error — including an issue with no `## Definition of Done` section, where the mission skips the check and says so in the completion record. It checks that every item is accounted for in a ledger the mission wrote about itself, not the work: `"evidence": "done"` passes. The summary block goes into the completion record. Policy for skipped items (owner decision, SF-SKILL-07): accepted when disclosed (exit 3); pass `--fail-on-skip` to make any skip fail (exit 1). --- ## Run contracts (`references/`) | File | Borrowed by | |--|--| | `executor.md` | every Kind-A orchestrator (step schema, run state, lanes, gates, converge) | | `tracker-integration.md` | tracker-integrated skills (comment bus, labels, lease, provider ops, MR ownership) | | `lanes.md` | lane-based dispatch consumers | | `mission-brief-template.md` | brief/milestone authors (queue, orchestrator) — canonical home `mission-brief/references/` | | `issues-provider.yml` | provider resolution template (setup writes the repo copy) | | `run-context.md` | run-mode vs local-session rules | | `project-contract.md` | consumer projects — what their `REVIEW.md`, `AGENTS.md`, skills and workflow override may and may not change in a factory run | | `mission-template.yml` | run policy defaults (execution, supervision, budgets) |