Skip to content

State Management

State Management

Overview

All pipeline state is managed through the Go MCP server (forge-state), which exposes 47 typed tool calls. State is persisted in state.json within the workspace directory.

State Machine

state.json Structure

Key fields in state.json:

FieldDescription
specNameWorkspace name (e.g., 20260320-fix-auth)
workspaceFull path to .specs/{specName}/
statusCurrent status: initialized, in_progress, completed, failed, abandoned
currentPhaseActive phase ID (e.g., phase-3, checkpoint-a)
effortEffort level: S, M, L (XS is not supported)
flowTemplateSelected template: light, standard, full
branchGit branch name
autoApproveBoolean; set via --auto flag (defaults to false)
phasesArray of phase records (status, timestamps, logs)
tasksArray of task records (impl/review status)
revisionsRevision counters per artifact
skippedPhasesPhases skipped by flow template (e.g., ["phase-4b", "checkpoint-b", "phase-7"] for effort S)
phaseLogArray of phase metrics: {phase, tokens, duration_ms, model, timestamp}

MCP Tool Categories

The Go MCP server exposes 47 typed tool calls across 8 categories:

CategoryToolsDescription
Lifecycle5Pipeline initialization and advancement (init, pipeline_init, pipeline_next_action, etc.)
Phase Management6Phase transitions (phase_start, phase_complete, checkpoint, abandon, etc.)
Revision Control4APPROVE/REVISE cycle management (revision_bump, inline_revision_bump, etc.)
Configuration7Runtime settings (set_effort, set_auto_approve, set_branch, etc.)
Task Management2Per-task tracking (task_init, task_update)
Metrics & Query9State queries, history search, BM25 pattern matching
Analytics3Pipeline statistics and cost predictions
Validation & Utility8Input/artifact validation, AST analysis, dependency graphs

For the complete tool reference with descriptions, see MCP Tools.

MCP Handler Guards

The MCP server enforces these guards deterministically (not via hooks):

GuardToolCondition
Artifact requiredphase_completeBlocks if expected artifact file is missing
Checkpoint requiredphase_completeBlocks unless awaiting_human status set
Phase orderingphase_startBlocks if previous phase not completed

Released under the MIT License.