The orchestrator inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/8BitTacoSupreme/flowstate/llms.txt
Use this file to discover all available pages before exploring further.
flowstate/orchestrator.py is the single file that owns pipeline sequencing. It creates the MemoryStore and EventBus, calls write_context_files(), dispatches each tool adapter through _run_step(), runs the discipline audit, then prints a summary and next-step commands. Tools that fail are marked BLOCKED and the pipeline continues — a failure in research does not prevent strategy or discipline from running.
Constants: TOOL_ORDER, STEP_LABELS, STEP_STYLES
Three module-level dicts drive the ordered rendering of every tool inprint_status() and the colored step headers printed during run_pipeline():
run_pipeline().
run_pipeline()
run_pipeline(state, root) is the top-level entry point called by cli.py after the interview completes. It returns the mutated FlowStateModel with all tool statuses and artifact paths populated.
Bridge construction and dry-run fallback
_make_bridge(root, dry_run, preferences) constructs a ClaudeBridge from a BridgeConfig. If dry_run=False but the claude CLI is not found on PATH, the orchestrator silently falls back to a dry-run bridge:MemoryStore and EventBus setup
A new
MemoryStore (SQLite FTS5) and EventBus are created at the start of every pipeline run. A run_id is generated as a 12-character UUID hex prefix to group all memories from this run:Interview answers stored as a decision memory
Before any tool runs, the interview answers are written to
memory.db as a MemoryKind.DECISION entry. This means subsequent pipeline runs can inject prior problem/vision context into research prompts:Step 1 — Context Generation (deterministic)
write_context_files(state, root) is called directly — not through _run_step() — because it is pure Python and cannot fail with a ToolResult. The five context files are written synchronously. If an exception is raised, it is caught and printed in red, but the pipeline continues. save_state is called immediately after.Step 2 — Research (ResearchAdapter)
A
ResearchAdapter is instantiated with the shared bridge and memory, then dispatched through _run_step(). On success, the artifact path is recorded in state.artifacts["research_report"].Step 3 — Strategy (StrategyAdapter)
A
StrategyAdapter is instantiated and dispatched. On success, state.artifacts["strategy_report"] is populated. This step always runs regardless of whether research succeeded or failed.Step 4 — GSD Management (GSDAdapter)
GSDAdapter.new_project(state) re-runs write_context_files() from inside the adapter (or writes the mock roadmap in dry-run mode). The artifact is recorded in state.artifacts["roadmap"].Step 5 — Discipline Audit (pure Python)
check_setup(root) is called directly (not via _run_step()) because it returns an AuditResult, not a ToolResult. The tool status is manually set to RUNNING then COMPLETED. The audit never marks itself BLOCKED.Close MemoryStore, print summary, show next steps
After all five steps,
memory.close() flushes and closes the SQLite connection. _print_summary() renders completed/blocked counts and the list of context files. print_next_steps() from launcher.py detects installed tools and prints suggested commands._run_step() — The Generic Step Runner
_run_step() is used for steps 2–4 (research, strategy, gsd). It handles the full lifecycle of a tool execution:
_run_step():
- Prints a colored step header using
STEP_STYLESandSTEP_LABELS - Calls
update_tool(state, tool_name, status=ToolStatus.RUNNING)andsave_state() - Calls
execute_fn()— the adapter method wrapped in a lambda - On success: sets status to
COMPLETED, appends each artifact, prints the first 300 chars of output, emitsStepCompleted - On failure: sets status to
BLOCKED, stores the error string, prints it in red, emitsStepFailed - Calls
save_state()again — state is always persisted whether the step succeeded or failed
print_status()
print_status(root) loads flowstate.json and renders a Rich table. It is called by flowstate status:
READY → dim, RUNNING → yellow, COMPLETED → green, BLOCKED → red. After the table, context files and named artifacts are listed separately, followed by the project name and state file path.
run_phase()
run_phase(state, root, phase) prints the native session command for executing a specific GSD phase. It delegates to launch_command("gsd", phase, root) from launcher.py and does not call any tool itself:
Bridge Construction and Preferences
_make_bridge() reads three optional preferences from ProjectPreferences when constructing the BridgeConfig. All three are optional — passing None leaves the bridge using its defaults:
The same
bridge instance is shared across all three adapters (research, strategy, gsd). This means all three bridge calls in a single pipeline run use the same model, budget, and effort settings.