Skip to content

Workflow Engine

The workflow engine is the orchestration hub for multi-step design and implementation workflows. It powers both the MCP advance tool and trurlic design sessions.

Every interaction follows the same pattern:

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

advance() is a pure function — it computes the next step from the current graph state without any side effects. Same inputs always produce the same output.

Full design workflow for a new component. Steps: define_scopecover_concernspattern_detectionsummary_gateready.

The developer defines the component’s scope, answers concern questions, reviews detected patterns, and confirms the summary before implementation begins. Multiple steps are gated (require human input).

Add functionality to an existing component. Steps: verify_constraintscover_concernspattern_detectionsummary_gateready.

Starts by verifying that existing decisions still hold for the new feature, then addresses any uncovered concern areas relevant to the task. When a task description is provided, concern coverage is focused on task-relevant gaps via keyword matching.

Apply a bugfix within existing constraints. Steps: verify_constraints → [cover_concerns] → impact_checkready.

Checks that the fix respects existing decisions. The cover_concerns step fires conditionally — only when the component has zero decisions and the task description touches an uncovered concern area, preventing unguarded fixes in areas that have never been designed. impact_check assesses cross-component effects when the component has connections.

Study existing decisions before implementing. Steps: user_explainsanalyze_codewalk_decisionssummary_gateready.

The user first describes the component from memory, then the agent reads source code, reviews decisions, and the user confirms comprehension via the summary gate.

Challenge decisions for drift or staleness. Steps: walk_decisionsdrift_checkcoverage_auditpattern_detectionsummary_gateready.

Interactive workflow for re-examining whether existing decisions still hold. Stale decisions are flagged during drift check, coverage gaps are audited, patterns are reassessed, and the user confirms findings.

Strengthen coverage for uncovered concern areas. Steps: coverage_auditcover_concernspattern_detectionready.

Identifies gaps in concern coverage, guides the developer through addressing them, and detects patterns in the newly recorded decisions.

Autonomous project scan from source code. Steps: scan_projectextract_decisionsproject_rulespattern_detectionready.

Fully autonomous — no gated steps. The agent reads source code and records what it finds. All decisions attributed as agent.

If task_type is omitted from an advance call, the workflow engine infers it from the graph state:

  • Component has no decisions → new_component
  • Component has decisions → feature (default for existing components)

Explicit task_type always overrides inference.

Steps marked requires_user_input: true are gated. The agent must present the step’s prompt to the user, collect a meaningful response (minimum 20 bytes), and pass it back as step_evidence. This is how Trurlic enforces human authorship of architectural decisions.

Evidence is passed as a map: { "step_name": "user's response text" }. The workflow engine validates that gated steps have sufficient evidence before progressing.

Gated steps (require human input): define_scope, analyze_code, cover_concerns, walk_decisions, verify_constraints, impact_check, pattern_detection, summary_gate, drift_check, coverage_audit, user_explains.

Ungated steps (autonomous): register, scan_project, extract_decisions, project_rules, ready.

get_step_prompt returns structured prompts for each step, including system instructions, component context, and step-specific focus areas. Prompts are transport-agnostic — the same prompts are consumed by MCP agents and CLI sessions.

The INTERACTION_PROTOCOL is embedded in every interactive step prompt, instructing the agent on how to facilitate the Socratic conversation.

StepGatedDescription
registerNoRegister a new component in the graph
define_scopeYesDefine what the component is responsible for
analyze_codeYesRead existing source code for context
cover_concernsYesAddress uncovered architectural concern areas
walk_decisionsYesReview existing decisions for a component
verify_constraintsYesConfirm decisions are consistent with each other
impact_checkYesAssess impact of changes on connected components
pattern_detectionYesIdentify cross-cutting patterns across decisions
summary_gateYesHuman confirms the design summary before proceeding
drift_checkYesChallenge decisions that may be stale or outdated
coverage_auditYesAudit which concern areas lack decisions
scan_projectNoScan source code for architectural components
extract_decisionsNoExtract decisions from source code analysis
project_rulesNoDefine project-wide inviolable rules
user_explainsYesUser provides task context or explanation
readyNoWorkflow complete — implementation can proceed

The workflow engine tracks ten architectural concern areas with keyword matching against decision content. During cover_concerns steps, uncovered concerns are surfaced in priority order. The engine determines which concerns are addressed by existing decisions and which need attention.

When a task description is provided (e.g. --task "add caching"), the cover_concerns step filters to concerns whose keywords match the task, focusing the conversation on what’s relevant instead of walking all gaps.