{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/phases.json",
  "description": "The phase contract, in one place: the phase ids and names, which phases each mode runs, the per-phase token ceilings and the phase numbers other code compares against. gen-mode-dispatch.mjs, render-work-summary.sh, the autopilot runner, runs-index.mjs, usage-report.mjs and gen-facts.mjs read it; smoke-phase-contract.sh holds every copy that cannot read it (the phase docs and prose counts, agent-state.schema.json, token-budget.json, phase-tracker.sh, phase-banner.sh, gc-abandoned.sh) to it. Adding or merging a phase means editing here. A mode with `names` runs the same six slots under its own step names (analysis gathers evidence and synthesises where development plans and builds), and its tracker and task widget show those names. A mode with `commits: false` delivers no commit in its Phase 4 (analysis publishes a document), so lib/run-completion.mjs asks it for no commit evidence before `status: complete`; any other mode commits. `steps` is the phase's sub-step list, in order: `phase-tracker.sh add` registers each one as a pending sub-phase so the run's widget carries them from the first boundary, and the phase moves its own with `sub`. Dev declares none because its sub-steps are Phase 1's plan tasks, attached by `phase-tracker.sh plan`. Ceilings are measured against the current phase documents, never summed from earlier ones: smoke-token-budget.sh fails a ceiling more than 25% above the measurement.",
  "contractVersion": "2.0.0",
  "phaseSchema": 2,
  "phaseSchemaNote": "The phase vocabulary generation. metrics.jsonl is append-only and v19.0.0 renumbered the phases, so every line written from v19.0.0 on carries this number and a line without the field is generation 1. Aggregators pick their name table from it; without it phase 3 means Dev in old rows and Review in new ones and no reader can tell them apart.",
  "legacyPhaseNames": {
    "0": "Init",
    "1": "Analysis",
    "2": "Planning",
    "3": "Dev",
    "4": "Review",
    "5": "Test",
    "6": "Commit",
    "7": "Report",
    "note": "Generation 1 phase names, kept so an aggregator can label a historical metrics.jsonl row correctly instead of printing the current name for a number that meant something else. Read-only history: nothing emits these any more. The generation 1 -> 2 number map is not repeated here, it is the `was` array on each phase above."
  },
  "phases": [
    {
      "id": 0,
      "name": "Init",
      "steps": ["Intake", "Workspace", "Task contract"],
      "doc": "phase-0-init.md",
      "maxTokens": 13600,
      "was": [0]
    },
    {
      "id": 1,
      "name": "Plan",
      "steps": ["Context", "Exploration", "Task breakdown"],
      "doc": "phase-1-plan.md",
      "maxTokens": 10250,
      "roles": ["critic"],
      "was": [1, 2]
    },
    {
      "id": 2,
      "name": "Dev",
      "doc": "phase-2-dev.md",
      "maxTokens": 10410,
      "roles": ["critic"],
      "was": [3]
    },
    {
      "id": 3,
      "name": "Review",
      "steps": ["Gates", "Review panel", "Triage"],
      "doc": "phase-3-review.md",
      "maxTokens": 17500,
      "roles": ["reviewer", "review panel", "triage", "triyaj"],
      "was": [4, 5]
    },
    {
      "id": 4,
      "name": "Commit",
      "steps": ["Commit", "Push", "Pull request"],
      "doc": "phase-4-commit.md",
      "maxTokens": 6650,
      "roles": ["commit step"],
      "was": [6]
    },
    {
      "id": 5,
      "name": "Report",
      "steps": ["Channels dispatch", "Log + telemetry", "Knowledge + memory"],
      "doc": "phase-5-report.md",
      "maxTokens": 5800,
      "roles": ["triage", "triyaj"],
      "was": [7]
    }
  ],
  "totalMaxTokens": 63990,
  "modes": {
    "full": {
      "phases": [0, 1, 2, 3, 4, 5],
      "autopilot": false
    },
    "autopilot": {
      "phases": [0, 1, 2, 3, 4, 5],
      "autopilot": true
    },
    "analysis": {
      "phases": [0, 1, 2, 3, 4, 5],
      "names": {
        "0": "Intake",
        "1": "Evidence",
        "2": "Synthesis",
        "3": "Review",
        "4": "Publish",
        "5": "Report"
      },
      "autopilot": false,
      "commits": false
    },
    "analysis-autopilot": {
      "phases": [0, 1, 2, 3, 4, 5],
      "names": {
        "0": "Intake",
        "1": "Evidence",
        "2": "Synthesis",
        "3": "Review",
        "4": "Publish",
        "5": "Report"
      },
      "autopilot": true,
      "commits": false
    }
  },
  "thresholds": {
    "waitingFromPhase": 4,
    "mcpAllowedThroughPhase": 1,
    "note": "Phase numbers other code compares against, named here so a renumbering moves them with the contract. waitingFromPhase: runs-index.mjs groups a run as 'waiting on you' from Commit on. mcpAllowedThroughPhase: Figma MCP is reachable only through Plan; smoke-no-mcp-in-dev-phases.sh flags any recorded Figma call at a higher phase. Analysis runs inside Plan, so the permitted set is {0,1}."
  }
}
