{
  "workflowId": "requirement-implementation",
  "displayName": "Requirement → Implementation → Knowledge",
  "steps": [
    {
      "id": "extract-fields",
      "type": "extract",
      "agent": "extractor",
      "template": "./templates/requirements-template.md",
      "timeout": 120
    },
    {
      "id": "requirement",
      "type": "agent",
      "mode": "chat",
      "agent": "requirements-engineer",
      "inputFrom": "extract-fields",
      "instruction": "The field status above shows which requirement fields were extracted from the user's input and which are still open. Start from Phase 2: batch-confirm all EXTRACTED fields in one question, then fill each OPEN field with one focused question per turn. Set stepComplete: true only after all mandatory fields are confirmed and the user approves the requirements document.",
      "timeout": 900
    },
    {
      "id": "cp-requirement",
      "type": "checkpoint",
      "description": "Review the elicited requirements. Approve to proceed to analysis — or reject with corrections to refine the requirements further.",
      "showArtifactsFrom": [
        "requirement"
      ],
      "rejectGoTo": "requirement"
    },
    {
      "id": "as-is",
      "type": "agent",
      "mode": "auto",
      "agent": "as-is-analyst",
      "instruction": "Analyze and document the current state of the system or domain described in the requirements. Inspect all available sources. Identify problems, gaps, and dependencies that the solution must address.",
      "inputFrom": "requirement",
      "timeout": 900
    },
    {
      "id": "to-be",
      "type": "agent",
      "mode": "auto",
      "agent": "to-be-analyst",
      "instruction": "Design the target state based on the requirements and as-is analysis. Map each requirement to a target-state element. Identify the transformation gap and any unresolved design decisions.",
      "inputFrom": "as-is",
      "timeout": 900
    },
    {
      "id": "cp-analysis",
      "type": "checkpoint",
      "description": "Review the as-is and to-be analyses. Approve to proceed to solution design — or reject with feedback to revise the analysis.",
      "showArtifactsFrom": [
        "as-is",
        "to-be"
      ],
      "rejectGoTo": "as-is"
    },
    {
      "id": "design",
      "type": "agent",
      "mode": "auto",
      "agent": "solution-designer",
      "instruction": "Translate the to-be analysis into a concrete implementation blueprint. Define all components, their specifications, and implementation guidelines. The developer must be able to implement from this document without ambiguity. For every node classified as having no confirmed relationship: explicitly check columns ending in 'ID' and columns named 'LastEditedBy' against existing Key objects in the repository, and document why each was included or excluded.",
      "inputFrom": "to-be",
      "timeout": 1200
    },
    {
      "id": "cp-design",
      "type": "checkpoint",
      "description": "Review the solution design. Approve to proceed to implementation — or reject with feedback to revise the design.",
      "showArtifactsFrom": [
        "design"
      ],
      "rejectGoTo": "design"
    },
    {
      "id": "implementation",
      "type": "agent",
      "mode": "auto",
      "agent": "developer",
      "instruction": "Implement the solution according to the design blueprint. Read before you write — inspect every existing artifact before modifying it. Log all write operations in your execution report.",
      "inputFrom": "design",
      "timeout": 1800
    },
    {
      "id": "testing",
      "type": "agent",
      "mode": "auto",
      "agent": "tester",
      "instruction": "Test the implementation for technical correctness and functional coverage against the requirements and solution design. For each finding, specify the artifact ID, expected state, actual state, and severity. Set payload passed: true only when zero blocking findings remain.",
      "inputFrom": "implementation",
      "timeout": 900
    },
    {
      "id": "testing-gate",
      "type": "condition",
      "check": "testing.payload.passed == true",
      "onTrue": "cp-acceptance",
      "onFalse": "implementation",
      "maxIterations": 5
    },
    {
      "id": "cp-acceptance",
      "type": "checkpoint",
      "description": "Review the test results and implementation. Approve to finalize — or reject with feedback to request corrections.",
      "showArtifactsFrom": [
        "testing"
      ],
      "rejectGoTo": "implementation"
    },
    {
      "id": "knowledge-proposal",
      "type": "agent",
      "mode": "auto",
      "agent": "knowledge-collector",
      "instruction": "Review all workflow artifacts and propose 2–5 reusable Ogham episodes — not insights. Use the episode format exactly: situation, decisionChosenOption, decisionReasoning, domainTags, confidence. Do not write to Ogham.",
      "inputFrom": "testing",
      "timeout": 600
    },
    {
      "id": "cp-knowledge",
      "type": "checkpoint",
      "description": "Review the proposed knowledge entries. Approve the entries you want saved to the KnowledgeStore — or reject to revise the proposals.",
      "showArtifactsFrom": [
        "knowledge-proposal"
      ],
      "rejectGoTo": "knowledge-proposal"
    },
    {
      "id": "indexing",
      "type": "agent",
      "mode": "auto",
      "agent": "knowledge-architect",
      "instruction": "Process the episode proposals from the Knowledge Collector. For each: (1) evaluate whether it is a genuine experience, (2) query Ogham for near-duplicates, (3) submit as episode via submit_episode, (4) link to an existing insight if finalScore > 0.7. Only call create_insight if at least 2 episodes have been successfully submitted in this run AND finalScore < 0.3 across all queries for the converging pattern. Never create insights without first submitting the supporting episodes.",
      "inputFrom": "knowledge-proposal",
      "timeout": 600
    }
  ]
}