Skip to content

Workflow Engine

The workflow engine is the orchestration hub. It powers the MCP advance tool: given the graph and a task, it computes the next step. It never calls an LLM and never writes — advance() is a pure function of graph state plus inputs, so the same inputs always produce the same step.

1. advance(component, task_type, mode) → { step, action, requires_user_input, ready }
2. Perform the action (get_step_prompt, add_component, record_decision, …)
3. If requires_user_input: present the prompt, collect the user's response
4. advance again, passing step_evidence
5. Repeat until ready: true
6. get_context → implement, constrained by the brief

If task_type is omitted, the engine infers it from graph state (empty component → new_component/learn/bootstrap by mode; existing component → feature). An explicit task_type always wins. Two combinations are pinned: learn requires interactive mode, bootstrap requires agent mode.

Each task type walks its own step sequence. The engine picks the next step by checking postconditions against the graph, so it can’t skip ahead.

Task typeStep sequence (happy path)
new_componentregisterdefine_scopecover_concernspattern_detectiondesign_checkready
featureverify_constraintscover_concernspattern_detectiondesign_checkready
fixverify_constraints → [cover_concerns] → impact_checkready
learnwarm_upanalyze_codewalk_decisionsdesign_checkready
reviewwalk_decisionsdrift_checkcoverage_auditpattern_detectiondesign_checkready
hardencoverage_auditcover_concernspattern_detectionready
bootstrapscan_projectextract_decisions* → project_rulespattern_detectionready

Steps in [brackets] are conditional (e.g. fix runs cover_concerns only when the component has no decisions and the task touches an uncovered concern). extract_decisions* repeats once per discovered component. impact_check only fires when the component has connections.

A gated step returns requires_user_input: true. The agent must present its prompt, collect a real response (at least 20 bytes), and pass it back as step_evidence — a map of { "step_name": "user's response" }. The engine refuses to advance past a gated step without sufficient evidence. This is how human authorship is enforced: the agent facilitates, the human decides.

Ungated (autonomous): register, scan_project, extract_decisions, project_rules, ready. Gated (need evidence): everything else.

StepGatedPurpose
registerNoCreate the component node in the graph
define_scopeYesDefine what the component is responsible for
analyze_codeYesRead existing source for context
cover_concernsYesAddress uncovered architectural concern areas
walk_decisionsYesReview a component’s existing decisions
verify_constraintsYesConfirm existing decisions still hold for the task
impact_checkYesAssess effects on connected components
pattern_detectionYesIdentify cross-cutting patterns across decisions
design_checkYesPractical comprehension check before proceeding
drift_checkYesChallenge decisions that may be stale
coverage_auditYesAudit which concern areas lack decisions
scan_projectNoBootstrap: scan structure, identify components
extract_decisionsNoBootstrap: extract decisions from a component’s code
project_rulesNoBootstrap: record project-wide rules
warm_upYesLearn: opener that surfaces the user’s mental model
readyNoComplete — switch to get_context and implement

The step names summary_gate and user_explains are accepted as legacy aliases for design_check and warm_up. Use the canonical names.

get_step_prompt returns a transport-agnostic prompt for a step — system instructions, component context, and step-specific focus. In interactive mode the prompt carries the interaction protocol that tells the agent how to facilitate the Socratic conversation. In agent mode the prompts drive autonomous analysis. See Design Conversations and Bootstrap for the two modes in action.

The engine tracks ten concern areas (security, error handling, concurrency, integrity, performance, external interfaces, storage, serialization, dependencies, migration), matching each against decision content by keyword. During cover_concerns and coverage_audit, uncovered concerns surface in priority order — security before style. When a task description is supplied, coverage is filtered to task-relevant gaps instead of walking every one.