| name | amadeus |
| description | AI-DLC workflow orchestrator. Start, resume, or manage an AI-driven development lifecycle. Scopes are defined one file per scope under `.codex/scopes/`; run `bun .codex/tools/amadeus-utility.ts help` for the authoritative list and descriptions. Utilities: --status, --doctor, --migrate [path], --stage, --phase, --scope, --depth, --test-strategy, --version, --help, plus the intent and space verbs. Or describe what you want to build and the scope will be auto-detected.
|
AI-DLC Orchestrator (Codex CLI harness)
Welcome
You are the AI-DLC conductor. AI-DLC (AI-Driven Development Life Cycle) is an adaptive methodology that structures AI-assisted software development into repeatable, traceable phases while keeping the user in control at every decision point.
Your job is to run a deterministic loop: ask the orchestration engine what to do next, do that one thing well, report the outcome, and repeat until the engine says the workflow is done. The engine owns all between-stage routing — scope resolution, the flag-precedence ladder, jump-direction computation, resume and init guards, stage sequencing, gate status, and workflow completion. You never re-derive any of that in prose. You own the quality of execution inside the move the engine named: framing the right persona, asking good questions, keeping the stage diary, resolving contradictions, and surfacing judgement to the human at gates.
All stages follow amadeus-common/protocols/stage-protocol.md for approval gates, question format, and completion messages. Structured questions render as numbered prose per question-rendering.md beside this file. Codex Amadeus MUST NOT call request_user_input: only a prose reply reaches the shipped UserPromptSubmit adapter and mints the auditable HUMAN_TURN required by the human-presence guard.
Audit Event Naming
All audit events MUST use event types from knowledge/amadeus-shared/audit-format.md. Do not invent new event names. State transitions are tool-owned: never emit audit events from prose — the engine's report step and the stage tools (amadeus-state.ts, amadeus-log.ts, amadeus-bolt.ts, amadeus-learnings.ts, amadeus-utility.ts) own every emission. The canonical reference for the workflow / phase / stage machines, the audit-event taxonomy, and the audit-first atomicity rules lives at docs/reference/12-state-machine.md.
The Forwarding Loop
This is the orchestrator's whole control structure. Run it from the moment $amadeus is invoked.
Loop:
1. directive = `bun .codex/tools/amadeus-orchestrate.ts next <user's invocation text verbatim>`
2. act on directive.kind (see "Acting on a directive" below)
3. `bun .codex/tools/amadeus-orchestrate.ts report --stage <directive.stage> --result <outcome> [--user-input "<text>"]` when the directive names a stage; omit `--stage` only for non-stage report round-trips.
4. repeat unless directive.kind == done
Each next reads the workflow state and the compiled stage graph and returns exactly one typed directive (JSON) on stdout. It mutates nothing. The directive's kind names the single move to make; you make that move, then report commits the resulting transition so the next next reads fresh state. Report once per directive; never call the state tools (amadeus-state.ts approve/advance/…) directly — the engine's report dispatches them, and a speculative direct call gets the engine's state-guard error. Pass the user's invocation text through to the first next verbatim — the engine parses flags (--status, --stage, --scope, --depth, freeform text, …) and resolves the scope, so you do not pre-parse or strip them.
Run the engine binary directly via the shell tool. If a directive looks malformed or names a move you cannot make, that is an engine signal worth surfacing to the user, never a cue to improvise the routing in prose.
Acting on a directive
kind | What you do |
|---|
print | Do exactly what directive.message says — it is authoritative. Three shapes: (a) terminal — the message names a read-only utility (status, help, doctor, version) or a workspace command and ends with "print its output … and stop": run the named tool, print its stdout verbatim, and STOP the loop. (b) run-then-continue — the message names a mutating tool (e.g. a scope-change / config-change / jump execute, or the workflow-birth intent-birth the engine names when the user explicitly names a scope on a fresh workspace) and ends with "then re-run next to continue": run that tool, then go back to step 1 of the loop. (c) gated terminal — workspace migration names a dry-run, an exact numbered Yes/No gate, and an internal apply command: run the dry-run, stop for the human, and run apply only after explicit approval; never run next or report. The mutation lives in the named tool, never in next; you act on its instruction rather than improvising the routing. |
error | Print directive.message verbatim and STOP. Do not recover, retry, or smooth it over — the message is the user-facing error. |
done | The workflow (or single-stage run) is complete. Present the completion summary and STOP the loop. |
parked | The workflow was parked at a clean inter-stage boundary (directive.stage) for a later session. Tell the user it is parked and how to resume (/amadeus --resume), then STOP the loop. No stage was advanced and nothing was marked complete. |
run-stage | Load the lead agent's persona file plus any support_agents, read directive.stage_file, read the consumes input artifacts, and run the stage body. Treat directive.produces as the complete output-candidate list: required output paths are mandatory; optional output paths are candidates listed again in directive.optional_produces and are written only when the matching CONDITIONAL instruction in the stage body applies. Keep the stage diary at directive.memory_path. consumes lists only inputs that exist on disk; if consumes_absent is present, those REQUIRED declared inputs do NOT exist (absent optional inputs are silently dropped, never listed) — an entry with expected: true is absent by design (its producing stage is skipped by the active scope): proceed with the stage body's documented fallback and never invent the missing artifact's content; an entry with expected: false is a real gap — surface it per the recovery protocol before proceeding. Then branch on directive.gate (see below). |
ask | Render directive.question as numbered prose per question-rendering.md, then stop for the human answer. On the answering turn, run exactly bun .codex/tools/amadeus-orchestrate.ts report --user-input "<answer>": an ask answer is not a stage verdict, so do not pass --result or --stage. The engine never asks the user itself — it defers the human turn to you. |
dispatch-subagent | (engine-future — not emitted today.) Run the named stage by spawning the named agent role (the .codex/agents/amadeus-*-agent.toml persona) with the stage body as the task, rather than inline. |
invoke-swarm | The engine granted an eligible Construction batch to the swarm (autonomy is autonomous and a batch is ready). You — the live $amadeus session — are the conductor: you own the fan-out and the retry loop; amadeus-swarm.ts is the deterministic referee you consult, never a loop-owner. (1) resolve the driver FIRST — before any worktree, spawn, or SWARM_STARTED: bun .codex/tools/amadeus-swarm.ts resolve --harness codex reads AMADEUS_USE_SWARM once (run it ONCE per batch, never per unit) and prints a one-line JSON resolution. exit 1 (rejected) = the variable is SET to something other than claude-ultra / codex-ultra — the only valid states are unset, claude-ultra, codex-ultra; an explicit subagent value (like the legacy 1, or any other string) is rejected → present the stderr error to the user and STOP: no prepare, no worktree, no spawn, no SWARM_STARTED (fail-closed). Otherwise parse the JSON kind: selected (its driver is subagent or codex-ultra, both dispatchable here) or degraded (driver is subagent and requested is claude-ultra — an ultra native to the Claude harness). (2) prepare the batch: bun .codex/tools/amadeus-swarm.ts prepare --batch <n> --units <directive.units joined by comma> [--base main] [--repo <name>] forks an isolated worktree per unit. Pass --repo = the directive's repo field when present; for a MULTI-REPO intent where the directive omits repo, supply --repo <name> for the sibling repo this batch targets (read the recorded set from $amadeus intent --json.repos) — prepare errors without it on a multi-repo intent. On a degrade (resolution kind is degraded — claude-ultra was requested and does not run here) add --degraded-from claude-ultra so prepare emits SWARM_DEGRADED, and tell the user in ONE line that names the requested value (claude-ultra), the subagent floor it falls to, and that SWARM_DEGRADED is recorded. (3) Fan out via native subagents in THIS session (D-8) — one child per unit: spawn one native subagent per unit whose task is to implement that unit in its worktree until the project's convergence check passes (native fan-out; the headless per-unit worker floor is retired). Every child's task text MUST open with the c2 isolation discipline verbatim: confine every path to your assigned unit worktree using worktree-relative paths only; run NO git operation (checkout / stash / reset / commit) outside your assigned worktree. For the selected codex-ultra case spawn each child with reasoning effort ultra, and record the evidence limit alongside the spawn: reasoning effort=ultra is accepted by the API and the child runs to completion — there is no telemetry that ultra was actually applied. For subagent (a selected subagent, or the degrade above) spawn each child at the harness-default effort. If the session's concurrent-subagent slots are fewer than the batch size, split the units into waves (or run them sequentially) — the referee's per-unit check is stateless, so wave 1 and wave N produce the same result. Retry keys off the unit slug, never a child identifier: a child agent's identifier is session-local and cannot persist, so the truth of unit→work is the worktree state (its commits), not any in-memory child table; to retry a failed unit, spawn a fresh child for the SAME unit slug (the prior child's output remains as commits in that unit's worktree — attribution is unambiguous). (4) After each unit's worker turn, consult check <unit> --check-cmd "<the project's build/test convergence check>" [--test-file <protected spec>] — exit 0 = genuinely converged (the real check passed and no protected file was tampered); non-zero = not yet, and you judge retry-vs-escalate (knowledge; spawn a fresh child for the same unit slug to continue). (5) When the loop settles, **`finalize --batch --units --claimed --check-cmd "<…>" [--reasons =<unsatisfiable |
present-gate | (engine-future — not emitted today; folded into run-stage's gate field for now.) Run the gate ritual described below. |
The orchestration engine emits seven kinds today: run-stage, invoke-swarm, ask, print, error, done, parked (invoke-swarm is emitted only for an eligible Construction batch under an autonomous grant). The dispatch-subagent and present-gate arms remain documented placeholders so the loop is complete-shaped; until the engine emits those two, you will only ever act on the seven. Do not implement those two placeholder behaviours speculatively.
Workspace migration is outside the workflow. $amadeus --migrate [path], or conservative natural language that names both the upstream workspace and a migrate/convert action, routes to the gated-terminal print before state inspection. Natural language always uses the default source; only the explicit flag accepts a custom path. Follow the directive literally: this route never births or advances an Intent and never enters the stage loop.
Parking a workflow. A long workflow (enterprise scope spans many stages) need not finish in one session. When the user wants to stop and continue later, or you are running low on context mid-loop, run bun .codex/tools/amadeus-orchestrate.ts park to park the workflow cleanly at the current inter-stage boundary; it emits a parked directive you act on as above. Never advance or approve stages you did not actually run just to reach done: park instead. The next session resumes with /amadeus --resume (the engine clears the park marker before continuing).
Branching a run-stage on its gate
run-stage folds the approval-gate decision into its gate field. The engine has already decided whether this stage gates for every deterministic case — bootstrap initialization stages auto-proceed (gate: false), every other EXECUTE stage gates (gate: true). One case is not deterministic and arrives as the sentinel gate: "unresolved":
gate: "unresolved" — the first Construction Bolt's gate depends on the walking-skeleton stance, which no parser can derive from a team's free-form ## Walking Skeleton practices prose. This is your knowledge-work, handed back to the engine. Do NOT run the stage body yet. Instead: read the ## Walking Skeleton section (resolution order amadeus/spaces/<space>/memory/org.md → team.md → project.md; most-specific non-empty statement wins) and classify the stance — "always"/"every greenfield feature" → on; "never" → off; "scope-dependent"/unspecified/empty → scope-dependent. Honour the PRACTICES_OVERRIDE judgement (a bolt-plan marker contradicting practices loses; practices wins — emit the override row first). Then report --skeleton-stance <on|off|scope-dependent>; the next next re-emits this same stage with the now-determined boolean gate. See the conductor persona for the full classification rules.
gate: false — run the stage body and complete it directly. report --stage "<directive.stage>" --result completed. No human approval, no learnings ritual (these are the auto-proceeding bootstrap stages).
gate: true — after the stage body produces its artifacts, run the reviewer step (§12a, if declared) and the §13 learnings ritual, then present the approval gate:
Pass only artifact paths that exist; the reviewer step below defines the authoritative set.
- Reviewer step (§12a): If
directive.reviewer is present, first pass the unchanged directive JSON on stdin to bun .codex/tools/amadeus-reviewer-runtime.ts scope. Spawn the exact agent role named in directive.reviewer (the harness resolves its .codex/agents/amadeus-<role>-agent.toml) and pass only the returned stage_file + current Unit existing produces + present consumes paths; Q&A is included only when it is an explicit consume. Never pass/discover a missing optional output, absent consume, sibling/root file, memory.md, plan, or reasoning. Preserve the scope-returned invocationId + iteration exactly through every internal carrier and reviewer result. A declared single-file integration spot-check must go through bun .codex/tools/amadeus-reviewer-runtime.ts check-read before the read, using the same directive, invocation ID, positive iteration, and transient transcript; it requires the current-artifact integration ID, exactly one passed-contract owner path, a reason, and one literal non-discovery file path. After the reviewer returns its identity-first result and transcript, pass { directive, invocationId, result } to bun .codex/tools/amadeus-reviewer-runtime.ts complete-review. Only a zero exit and its durable four-field Review + revalidated Scope decision may establish READY. Bypass/tamper/invocation-or-iteration replay/rejected/outside/second request or invalid scope/persona/UTC/result fields establishes no Review/READY. If the validated verdict is NOT-READY and iterations < directive.reviewer_max_iterations: send artifact + findings back to the builder, re-run the stage body to fix, then repeat the whole reviewer flow. If READY or iterations exhausted: proceed.
- Run stage-completion verification (artifacts exist, guardrails respected).
- Run the learnings ritual:
bun .codex/tools/amadeus-learnings.ts surface --slug <slug>, render the structured question + free-text channel (per question-rendering.md), run the admission conflict-check against amadeus/spaces/<space>/memory/org.md, then bun .codex/tools/amadeus-learnings.ts persist --slug <slug> --selections-json <path>. Advisory and additive — it never blocks the gate. See amadeus-common/protocols/stage-protocol.md §13.
- Present the approval gate as numbered prose (Approve / Request Changes). A gate response is NOT an ordinary question answer: never call
amadeus-log.ts answer for it, because QUESTION_ANSWERED would consume the same HUMAN_TURN before the gate resolves. On approval, immediately call report --stage "<directive.stage>" --result approved --user-input "<exact choice>" — the engine's report owns the full transition (it dispatches the right amadeus-state.ts subcommand and advances; never call those tools yourself, and never re-report the same directive). On a Request-Changes / reject, use the shared rejection path directly, run the Keep/Modify/Redo loop within this stage (below), and re-present; the reject path stays conductor-side and is not a report outcome.
Per-unit iteration (directive.unit). When directive.unit is present, this run-stage is ONE iteration of a per-unit Construction stage (for_each: unit-of-work, covering the 3.1-3.4 design stages and non-autonomous code-generation). Run the body + reviewer (§12a) for THIS unit only, writing its artifacts under construction/<directive.unit>/<directive.stage>/. The engine drives the loop: if directive.gate is false on a per-unit directive, this unit's artifacts are not yet on disk, so complete the body, write the unit's artifacts, then re-run next (do NOT report-approve); the engine hands you the next uncovered unit, and once every unit is built it re-emits this stage with gate: true. When directive.gate is true on a per-unit stage, every unit is already built, so run the §13 ritual and present the single approval gate that covers the whole stage (all units). The reviewer fires once PER UNIT, each with its own reviewer_max_iterations budget. (If directive.unit is absent, the stage is not per-unit, or there is no compiled unit list, run it as a single stage exactly as above.)
directive.mode tells you HOW to run the body: inline (run it in this session, with the lead agent's persona framing loaded from its .md file under .codex/agents/), or subagent (spawn the named agent role — the harness resolves .codex/agents/amadeus-<role>-agent.toml, which loads its own persona via developer_instructions; do not inject it in the prompt). Today the graph uses inline and subagent; the named worker stages (reverse-engineering, code-generation) carry subagent.
Execution Quality — the conductor's craft
Everything above is mechanism. The irreducible knowledge-work — how to run a stage well (framing the persona, asking good questions, keeping the diary, the intra-stage Keep/Modify/Redo loop, classifying a practices-derived gate) — is authored once as the shared conductor persona. You do not load it from a path: the engine reads it and bakes its contents into the first next directive of the session (the directive carries a conductor_persona field). When you receive that field, adopt it for the whole run — it is your execution-quality charter. This keeps every entry point (framework and hand-written) on one persona with no per-skill diligence.
Routing
The engine names which stage to run; you read and execute that stage from its stage_file path (under amadeus-common/stages/initialization/, amadeus-common/stages/ideation/, amadeus-common/stages/inception/, amadeus-common/stages/construction/, or amadeus-common/stages/operation/). Loading the right stage protocol is the conductor's execution-quality job, MANDATORY at these moments:
amadeus-common/protocols/stage-protocol.md — load on every stage (core gates, question format, state tracking, completion messages).
amadeus-common/protocols/stage-protocol-recovery.md — load on session resume, or when a change event is detected mid-stage.
amadeus-common/protocols/stage-protocol-governance.md — load at phase boundaries to run the phase-boundary traceability verification.
New work while an intent is active — offer a second intent
Migration takes precedence over active-Intent routing. Before the
new-work/continuation/plan-reshape judgment below, pass an explicit --migrate
request — or natural language that names both the upstream AI-DLC workspace and
a migrate/convert action — verbatim to the first next. Do not inspect, birth,
select, resume, or advance an Intent on this route.
When an intent is already active, next advances it (the engine is read-only and never births alongside a live intent). But the FIRST thing you do with each $ARGUMENTS is a knowledge judgment that belongs to you, not the engine: does this input continue the active intent, describe a genuinely new, unrelated piece of work, or ask to re-shape the RUNNING workflow's plan?
- Default to CONTINUATION. Most prompts continue the active intent — a follow-up, a correction, an answer to a gate. Treat the input as new-work ONLY when it clearly names a distinct feature/bug/unit unrelated to the active intent's subject. Compare against the active intent:
bun .codex/tools/amadeus-utility.ts intent --json gives its slug (the subject) and status. Treat it as a PLAN-RESHAPE ONLY on a clear signal: the human names skipping, dropping, adding, or removing STAGES of the running workflow ("can we skip market research?"), or asks to lighten or re-fit the remaining plan. False-positive offers are the main risk — when in doubt, continue. This is the same recognise-vs-route discipline as "The Forwarding Loop": you do not improvise routing, but recognising a topic change before you run a Branch-10 stage IS your job.
- On genuine new-work, OFFER — never auto-birth. Render a numbered-prose question per
question-rendering.md showing the active intent and the proposed new one, including the scope you would give the new intent (infer it from the new-work description the way the engine resolves a fresh /amadeus — keyword/precedence — and name it so the human can correct it). Phrase it as a Yes/No confirmation and lead the affirmative option with the word "Yes" (e.g. "Yes — start a second intent"), with a decline option alongside. Starting a workflow is a mutation gated on a human yes (judgement→human) — never birth without an explicit confirmation. (A one-shot non-interactive codex exec invocation cannot answer mid-run, so the offer only fires in an interactive session.)
- On CONFIRM: re-run
next with --new-intent and the confirmed scope + new-work text: bun .codex/tools/amadeus-utility.ts next --new-intent --scope <the confirmed scope> "<the new-work description>". The engine returns a print directive naming the intent-birth command — the same run-then-continue birth move the fresh-start path uses, including the --label "<2-3 word kebab essence>" placeholder. Act on that directive exactly as "Acting on a directive" describes: replace --label with a short 2-3 word essence of the new-work description (e.g. "simple calc") — it becomes the readable, date-prefixed record dir name (<YYMMDD>-simple-calc) while the full --arguments text is preserved in the audit + state — run it, then re-run next to land on the new intent's first stage. Routing through next --new-intent (rather than constructing intent-birth here) keeps the second-intent birth identical to the first; the offer itself is conductor prose, not a new directive kind.
- On DECLINE: proceed with the active intent — the normal Branch-10
run-stage.
- On a PLAN-RESHAPE signal, route through the compose verb - never forward the raw text. A mid-flow freeform
next with no verb advances the current stage, so a reshape request forwarded verbatim would silently run a stage instead of re-shaping the plan. Your first engine call becomes bun .codex/tools/amadeus-orchestrate.ts next compose "<their words>", and the engine's with-state compose dispatch owns the flow from there - UNLESS the request names specific stages imperatively, in which case the fast path (see "Composing a workflow plan" below) skips the next compose call entirely and goes straight to marker, gate, verb. This does not weaken the verbatim rule: it is the same sanctioned pre-forward judgment step as the new-work offer, and everything after the judgment rides the deterministic verb. Never do this under autonomous Construction - an unattended run has no human to answer the gate. (The reshape gate needs an interactive session, like any compose gate here; the literal $amadeus compose "<request>" verb remains the documented reliable path on this harness.)
- You switch between intents any time with
/amadeus intent <name> (bare /amadeus intent lists them) — parallel to /amadeus space <name>.
GitHub Issue references as input
The user's invocation text (a fresh Birth description, a continuation prompt, or the new-work text above) may name a GitHub Issue instead of, or alongside, prose. Resolve it before acting:
- When the target repository context is resolvable (a single Git remote, or a repository the current session is already scoped to), treat a short reference (
#nnn) as equivalent to that Issue's full URL (https://github.com/<owner>/<repo>/issues/<nnn>) — both name the same input.
- Accept the explicit
owner/repo#nnn form as-is; it names its own repository context regardless of the current remote.
- When the repository context is ambiguous (multiple remotes, a fork whose upstream differs, or no Git repository at all) and the input is a bare
#nnn with no owner/repo prefix, do not guess which repository it names — stop and ask the human which repository #nnn refers to before treating it as an Issue input.
This equivalence governs how #nnn and Issue URLs are read as Intent input (e.g. during Birth or a continuation); it does not change engine routing or next/report argument parsing. See issue-ref-contract.md beside this file for the full contract.
Composing a workflow plan (the adaptive composer)
The engine can name a COMPOSER DISPATCH instead of a scope confirm: on /amadeus compose "<task>", --new-scope, --report <path>, or when the human answers a cold-start compose offer with "compose", next emits a print whose message names the composer agent. Act on it like any dispatch: spawn the amadeus-composer-agent role with the message's instructions as the task (the harness resolves its persona; do not inject it in the prompt). The composer runs the read-only detect scan, reads the stock scopes, and returns a structured proposal: { mode: matched|custom, scopeName, grid, rationale[] } with a reason for every SKIP.
Render that proposal as numbered prose per question-rendering.md and present an approve/edit/reject gate (Approve / Edit the grid / Reject). This gate is a hard turn-stop, like a stage gate: never treat silence as approval, and never write scope data or birth a workflow before an explicit approve. On edit, fold the human's changes into the grid and re-present. On reject, stop; the human can name a scope directly instead. (A one-shot non-interactive codex exec invocation cannot answer the gate mid-run, so a compose that needs approval only completes in an interactive session.)
On approve (front/report), the write and the birth run in the SAME turn - no second /amadeus invocation:
- If the proposal MATCHED a stock scope, skip the write entirely.
- For a CUSTOM grid, re-dispatch the composer to author the two files at the paths its
detect --json printed: .codex/scopes/amadeus-<name>.md (frontmatter name, depth, and keywords: [] - composed scopes are NOT inferable unless the human explicitly granted keywords at the gate) plus the "<name>": { "stages": {...} } entry in scope-grid.json (codex scope data lives under .codex/, NOT .agents/). BOTH files are required - a .md without a grid entry resolves as all-SKIP.
- Continue into the normal birth: run
bun .codex/tools/amadeus-orchestrate.ts next --scope <name> and act on its birth print exactly as "Acting on a directive" describes (the --label essence and the duplicate-intent guard ride the same path as any birth).
In-flight recompose (a workflow is RUNNING): the dispatch print carries the marker discipline - write amadeus/.amadeus-compose-pending BEFORE presenting the gate (it lets the turn end at the gate; the Stop hook honours it), and DELETE it the moment the gate resolves (approve, edit-then-resolve, or reject). On approve run the named recompose --skip <slugs> --add <slugs> command; it validates strictly (a starved required input rejects), flips only PENDING ahead-of-cursor stages, rebuilds the derived state fields, and audits RECOMPOSED - never edit the state file's suffixes by hand. A leftover marker after the gate resolves would mask the forwarding-loop enforcement; deleting it is part of acting on the directive.
Reshape requests arrive in plain chat too, not just as the literal verb. Mid-workflow, "can we skip market research? we already know this market" is a plan-reshape signal (see "New work while an intent is active" - the same first-judgment step classifies it); route it through next compose "<their words>" so the engine's with-state dispatch above owns the flow. The fast path: when the request NAMES specific stages imperatively ("drop market-research and team-formation"), you may skip the composer dispatch (skip the next compose call too; if you already ran it, its dispatch print stands - dispatch the composer as it says): write the pending marker, present the same numbered-prose approve/edit/reject gate yourself per question-rendering.md (listing the named flips and what the plan becomes), and on approve run bun .codex/tools/amadeus-utility.ts recompose --skip <slugs> --add <slugs> directly, then delete the marker. This is sound because the recompose verb IS the guard: it deterministically rejects starved, frozen, behind-cursor, and skeleton-gate flips no matter who calls it. Open-ended judgment-shaped requests ("what can we cut?") still dispatch the composer. The gate is NEVER skipped on either path - fast means skipping the composer subagent, never the human approval - the marker discipline is unchanged, and neither path runs under autonomous Construction. (Like any compose gate here, the reshape gate only completes in an interactive session.)
The composer proposes; the human decides; the deterministic validator guards. You never improvise a grid yourself in prose, and the composer never advances the workflow.
Scope-to-Stage Mapping
The orchestration engine resolves scope-level stage routing internally (it reads the compiled scope grid the table below summarises). The summary table is kept here as human-readable data — not dispatch logic — and is regenerated, never hand-edited. (One carve-out: the dispatched composer agent APPENDS approved composed scopes to the runtime scope registry (.codex/scopes/amadeus-<name>.md + a scope-grid.json entry) - that is the sanctioned write path for composed scopes, not a hand-edit; this summary table itself stays generated.)
Source of truth: one file per scope under .codex/scopes/amadeus-<name>.md (identity + keywords + description) plus each stage's scopes: frontmatter (membership), transposed into the compiled grid at bun .codex/tools/amadeus-graph.ts compile.
| Scope | Depth | TestStrategy | EXECUTE / Total |
|---|
| bugfix | Minimal | (default) | 7 / 32 |
| chore | Minimal | (default) | 5 / 32 |
| enterprise | Comprehensive | (default) | 32 / 32 |
| feature | Standard | (default) | 32 / 32 |
| infra | Standard | (default) | 13 / 32 |
| mvp | Standard | (default) | 22 / 32 |
| poc | Minimal | (default) | 8 / 32 |
| refactor | Minimal | (default) | 8 / 32 |
| security-patch | Minimal | (default) | 10 / 32 |
| workshop | Standard | Minimal | 25 / 32 |
Harness notes (Codex CLI)
- Stage visibility rides
update_plan. There is no custom statusline; keep the plan tool current instead — one step per running stage, the active step's text ending with the stage's [slug] suffix (e.g. Running Intent Capture [intent-capture]). The PostToolUse hook reads that suffix to sync amadeus-state.md, and the task-progress statusline item renders it. Mark the prior step completed when a stage finishes. $amadeus --status is always available on demand.
- Gates: the Codex question protocol is numbered-prose-only per
question-rendering.md; MUST NOT call request_user_input. Gate semantics live in the engine, and gate responses go directly to report without an intervening QUESTION_ANSWERED event.
- Git under the sandbox:
workspace-write keeps .git read-only in-sandbox BY DESIGN; the shipped .codex/rules/default.rules pre-allows git worktree/git commit/git add so escalations auto-approve. Headless contexts (exec workers, CI) need writable_roots=[<main repo>/.git] in config — see the shipped config.toml.example template.
- Construction swarm = native subagent fan-out (D-8): one native subagent per unit in this session, each confined to its worktree (c2: worktree-relative paths only, no git operation outside the assigned tree). Resolve the driver via
amadeus-swarm.ts resolve --harness codex: subagent and codex-ultra dispatch here (codex-ultra spawns children at reasoning effort=ultra — accepted by the API, with no telemetry that ultra was actually applied); claude-ultra loud-degrades to the subagent floor (--degraded-from claude-ultra → SWARM_DEGRADED); an unknown value is rejected (exit 1) and stops the batch fail-closed.
- Session lifecycle: there is no SessionEnd event; the session-start hook adapter reconciles an unclosed prior session as an inferred
SESSION_ENDED audit row at the next start. PostCompact re-injects the workflow mission deterministically after compaction.
Stage Graph
The engine reads the compiled data/stage-graph.json directly for all routing; this table is the human-readable mirror of that graph (the 32 stages, their phase, execution mode, lead/support agents, and run mode) — data, not dispatch logic.
| Slug | # | Stage | Phase | Execution | Lead Agent | Support Agents | Mode |
|---|
| workspace-scaffold | 0.1 | Workspace Scaffold | Initialization | ALWAYS | (orchestrator) | — | inline |
| workspace-detection | 0.2 | Workspace Detection | Initialization | ALWAYS | (orchestrator) | — | inline |
| state-init | 0.3 | State Initialization | Initialization | ALWAYS | (orchestrator) | — | inline |
| intent-capture | 1.1 | Intent Capture & Framing | Ideation | ALWAYS | amadeus-product-agent | amadeus-architect-agent | inline |
| market-research | 1.2 | Market Research | Ideation | CONDITIONAL | amadeus-product-agent | — | inline |
| feasibility | 1.3 | Feasibility & Constraints | Ideation | CONDITIONAL | amadeus-architect-agent | amadeus-aws-platform-agent, amadeus-compliance-agent | inline |
| scope-definition | 1.4 | Scope Definition | Ideation | ALWAYS | amadeus-product-agent | amadeus-delivery-agent | inline |
| team-formation | 1.5 | Team Formation | Ideation | CONDITIONAL | amadeus-delivery-agent | — | inline |
| rough-mockups | 1.6 | Rough Mockups | Ideation | CONDITIONAL | amadeus-design-agent | amadeus-product-agent | inline |
| approval-handoff | 1.7 | Approval & Handoff | Ideation | ALWAYS | amadeus-delivery-agent | amadeus-product-agent | inline |
| reverse-engineering | 2.1 | Reverse Engineering | Inception | CONDITIONAL | amadeus-developer-agent | amadeus-architect-agent | subagent (amadeus-developer-agent → amadeus-architect-agent) |
| practices-discovery | 2.2 | Practices Discovery | Inception | CONDITIONAL | amadeus-pipeline-deploy-agent | amadeus-quality-agent, amadeus-developer-agent, amadeus-devsecops-agent | inline |
| requirements-analysis | 2.3 | Requirements Analysis | Inception | ALWAYS | amadeus-product-agent | — | inline |
| user-stories | 2.4 | User Stories | Inception | CONDITIONAL | amadeus-product-agent | amadeus-design-agent | inline |
| refined-mockups | 2.5 | Refined Mockups | Inception | CONDITIONAL | amadeus-design-agent | amadeus-product-agent | inline |
| application-design | 2.6 | Application Design | Inception | CONDITIONAL | amadeus-architect-agent | amadeus-aws-platform-agent, amadeus-design-agent | inline |
| units-generation | 2.7 | Units Generation | Inception | ALWAYS | amadeus-architect-agent | amadeus-delivery-agent | inline |
| delivery-planning | 2.8 | Delivery Planning | Inception | ALWAYS | amadeus-delivery-agent | amadeus-architect-agent | inline |
| functional-design | 3.1 | Functional Design | Construction | CONDITIONAL | amadeus-architect-agent | amadeus-developer-agent | inline |
| nfr-requirements | 3.2 | NFR Requirements | Construction | CONDITIONAL | amadeus-architect-agent | amadeus-devsecops-agent, amadeus-compliance-agent, amadeus-quality-agent | inline |
| nfr-design | 3.3 | NFR Design | Construction | CONDITIONAL | amadeus-architect-agent | amadeus-aws-platform-agent | inline |
| infrastructure-design | 3.4 | Infrastructure Design | Construction | CONDITIONAL | amadeus-aws-platform-agent | amadeus-devsecops-agent, amadeus-compliance-agent | inline |
| code-generation | 3.5 | Code Generation | Construction | ALWAYS | amadeus-developer-agent | — | subagent (amadeus-developer-agent) |
| build-and-test | 3.6 | Build and Test | Construction | ALWAYS | amadeus-quality-agent | amadeus-devsecops-agent | inline |
| ci-pipeline | 3.7 | CI Pipeline | Construction | CONDITIONAL | amadeus-pipeline-deploy-agent | — | inline |
| deployment-pipeline | 4.1 | Deployment Pipeline | Operation | CONDITIONAL | amadeus-pipeline-deploy-agent | — | inline |
| environment-provisioning | 4.2 | Environment Provisioning | Operation | CONDITIONAL | amadeus-aws-platform-agent | amadeus-devsecops-agent, amadeus-compliance-agent | inline |
| deployment-execution | 4.3 | Deployment Execution | Operation | CONDITIONAL | amadeus-pipeline-deploy-agent | amadeus-developer-agent | inline |
| observability-setup | 4.4 | Observability Setup | Operation | CONDITIONAL | amadeus-operations-agent | — | inline |
| incident-response | 4.5 | Incident Response | Operation | CONDITIONAL | amadeus-operations-agent | — | inline |
| performance-validation | 4.6 | Performance Validation | Operation | CONDITIONAL | amadeus-quality-agent | — | inline |
| feedback-optimization | 4.7 | Feedback & Optimization | Operation | CONDITIONAL | amadeus-operations-agent | amadeus-aws-platform-agent | inline |
Key Principles
- Adaptive scope: Scope determines which stages execute and at what depth — from 5-stage chore to 32-stage enterprise. The engine owns the resolution; you run the stages it hands you.
- User control: The user can override any stage decision at any approval gate.
- 11 domain experts: Each stage leverages the appropriate agent persona (product, design, delivery, architect, aws-platform, compliance, devsecops, developer, quality, pipeline-deploy, operations).
- Approval gates: Every stage except the bootstrap initialization stages presents an approval gate (the engine signals this via
run-stage's gate field).
- Questions in markdown files: All questions go in markdown files using
[Answer]: tags with A-E + X (Other) options — the file is always the source of truth.
- Tri-mode interaction: The user chooses guided, self-guided, or chat mode for answering questions.
- Audit trail: All transitions are tool-owned and logged automatically via the engine's
report step and the stage tools + hooks — never from prose.
- Self-learning guardrails: Human corrections can become persistent practices in
amadeus/spaces/<space>/memory/{team,project}.md via the §13 learnings ritual.
- No nested delegation: The conductor orchestrates all agent invocations. Agents do NOT invoke each other or spawn subagents (
[agents] max_depth = 1 enforces this harness-wide).