{
  "schema_version": "1.0",
  "catalog_version": 1,
  "workflows": [
    {
      "id": "session.start",
      "version": 1,
      "description": "Validate configuration and canonical state, then load a bounded project status snapshot.",
      "inputs": {},
      "steps": [
        {
          "id": "mailbox",
          "action": "requests.pull"
        },
        {
          "id": "config",
          "action": "config.audit"
        },
        {
          "id": "services",
          "action": "services.audit"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "status",
          "action": "state.query",
          "with": {
            "tool": "prd_status",
            "arguments": {}
          }
        },
        {
          "id": "substrate",
          "action": "substrate.preflight"
        },
        {
          "id": "notices",
          "action": "substrate.notices"
        },
        {
          "id": "goals",
          "action": "substrate.goals"
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "config",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "services",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "state",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "status",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "session.stop",
      "version": 1,
      "description": "Run deterministic stop checks, choose configured reflection questions, and build a source-backed summary bundle.",
      "inputs": {},
      "steps": [
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "goals",
          "action": "substrate.goals"
        },
        {
          "id": "staleness",
          "action": "staleness.audit"
        },
        {
          "id": "reflections",
          "action": "reflection.list",
          "with": {
            "entity": "all",
            "enabled": true
          }
        },
        {
          "id": "bundle",
          "action": "reporting.bundle",
          "with": {
            "task": "session_summary"
          }
        },
        {
          "id": "delegated",
          "action": "reporting.delegate",
          "with": {
            "bundle": "${steps.bundle.output}"
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "state",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "bundle",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "request.intake",
      "version": 1,
      "description": "Create a local request through the canonical duplicate-safe state tool from fully classified inputs.",
      "inputs": {
        "summary": {
          "type": "string",
          "required": true
        },
        "request_type": {
          "type": "string",
          "required": true,
          "allowed": [
            "bug",
            "change",
            "feature",
            "compat",
            "method"
          ]
        },
        "severity": {
          "type": "string",
          "required": true,
          "allowed": [
            "low",
            "medium",
            "high"
          ]
        },
        "scope": {
          "type": "string",
          "default": "local"
        },
        "rationale": {
          "type": "string",
          "default": ""
        },
        "affected_areas": {
          "type": "array",
          "default": []
        },
        "expected_behavior": {
          "type": "string",
          "default": ""
        }
      },
      "steps": [
        {
          "id": "create",
          "action": "state.mutate",
          "with": {
            "tool": "prd_file_request",
            "arguments": {
              "summary": "${inputs.summary}",
              "request_type": "${inputs.request_type}",
              "severity": "${inputs.severity}",
              "scope": "${inputs.scope}",
              "rationale": "${inputs.rationale}",
              "affected_areas": "${inputs.affected_areas}",
              "expected_behavior": "${inputs.expected_behavior}"
            }
          }
        },
        {
          "id": "confirm",
          "action": "state.query",
          "with": {
            "tool": "prd_get",
            "arguments": {
              "id": "${steps.create.output.id}"
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "confirm",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "request.import",
      "version": 1,
      "description": "Import a hub inbox package into canonical requests with transport provenance through the validated duplicate-safe tool.",
      "inputs": {
        "package_path": {
          "type": "string",
          "required": true
        },
        "agent": {
          "type": "string",
          "default": "AGENT-MCP"
        }
      },
      "steps": [
        {
          "id": "import",
          "action": "state.mutate",
          "with": {
            "tool": "prd_import_request",
            "arguments": {
              "package_path": "${inputs.package_path}",
              "agent": "${inputs.agent}"
            }
          }
        },
        {
          "id": "confirm",
          "action": "state.query",
          "with": {
            "tool": "prd_get",
            "arguments": {
              "id": "${steps.import.output.id}"
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "confirm",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "planning.requirements",
      "version": 1,
      "description": "Validate existing state then request only the irreducible requirements judgment from bounded sources.",
      "inputs": {
        "instructions": {
          "type": "string",
          "required": true
        },
        "source_refs": {
          "type": "array",
          "required": true
        }
      },
      "steps": [
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "context",
          "action": "substrate.enrich",
          "with": {
            "query": "${inputs.instructions}",
            "source_refs": "${inputs.source_refs}"
          }
        },
        {
          "id": "requirements",
          "action": "judgment.request",
          "with": {
            "task": "requirements",
            "instructions": "${inputs.instructions}",
            "source_refs": "${inputs.source_refs}",
            "result_schema": {
              "type": "object",
              "required": [
                "summary",
                "requirements",
                "source_refs"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "requirements": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "source_refs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "requirements",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "engineering.debug",
      "version": 1,
      "description": "Collect exact repository facts and ask an LLM only to diagnose competing causal explanations.",
      "inputs": {
        "instructions": {
          "type": "string",
          "required": true
        },
        "source_refs": {
          "type": "array",
          "required": true
        }
      },
      "steps": [
        {
          "id": "git",
          "action": "git.status"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "context",
          "action": "substrate.enrich",
          "with": {
            "query": "${inputs.instructions}",
            "source_refs": "${inputs.source_refs}"
          }
        },
        {
          "id": "diagnosis",
          "action": "judgment.request",
          "with": {
            "task": "debugging",
            "instructions": "${inputs.instructions}",
            "source_refs": "${inputs.source_refs}",
            "result_schema": {
              "type": "object",
              "required": [
                "summary",
                "hypotheses",
                "source_refs"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "hypotheses": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "source_refs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "diagnosis",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "engineering.code-review",
      "version": 1,
      "description": "Build the exact verification scope and ask for source-backed defect judgment only after mechanical checks.",
      "inputs": {
        "base_ref": {
          "type": "string",
          "default": ""
        },
        "source_refs": {
          "type": "array",
          "required": true
        }
      },
      "steps": [
        {
          "id": "diff",
          "action": "git.diff_check"
        },
        {
          "id": "verification",
          "action": "verification.plan",
          "with": {
            "base_ref": "${inputs.base_ref}",
            "release": false
          }
        },
        {
          "id": "context",
          "action": "substrate.enrich",
          "with": {
            "query": "Review the changed code and its causal neighbours",
            "source_refs": "${inputs.source_refs}"
          }
        },
        {
          "id": "review",
          "action": "judgment.request",
          "with": {
            "task": "code_review",
            "instructions": "Find material correctness, robustness, security, compatibility, or test gaps; do not restate mechanical facts.",
            "source_refs": "${inputs.source_refs}",
            "result_schema": {
              "type": "object",
              "required": [
                "summary",
                "findings",
                "source_refs"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "findings": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "source_refs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "review",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "engineering.verify",
      "version": 1,
      "description": "Build a conservative local verification plan and require all deterministic repository gates.",
      "inputs": {
        "base_ref": {
          "type": "string",
          "default": ""
        },
        "release": {
          "type": "boolean",
          "default": false
        }
      },
      "steps": [
        {
          "id": "plan",
          "action": "verification.plan",
          "with": {
            "base_ref": "${inputs.base_ref}",
            "release": "${inputs.release}"
          }
        },
        {
          "id": "execute",
          "action": "verification.execute",
          "with": {
            "plan": "${steps.plan.output}"
          }
        },
        {
          "id": "diff",
          "action": "git.diff_check"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "gate",
          "action": "state.gate"
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "plan",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "execute",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "gate",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "evidence.record",
      "version": 1,
      "description": "Record supplied verification evidence through the canonical evidence tool.",
      "inputs": {
        "summary": {
          "type": "string",
          "required": true
        },
        "type": {
          "type": "string",
          "default": "validation"
        },
        "linked_ids": {
          "type": "array",
          "default": []
        },
        "commands": {
          "type": "array",
          "default": []
        },
        "limitations": {
          "type": "string",
          "default": ""
        }
      },
      "steps": [
        {
          "id": "record",
          "action": "state.mutate",
          "with": {
            "tool": "prd_record_evidence",
            "arguments": {
              "summary": "${inputs.summary}",
              "type": "${inputs.type}",
              "linked_ids": "${inputs.linked_ids}",
              "commands": "${inputs.commands}",
              "limitations": "${inputs.limitations}"
            }
          }
        },
        {
          "id": "confirm",
          "action": "state.query",
          "with": {
            "tool": "prd_get",
            "arguments": {
              "id": "${steps.record.output.id}"
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "confirm",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "project.closeout",
      "version": 1,
      "description": "Prove repository state is gate-clean and build a bounded closeout judgment request without mutating closure state.",
      "inputs": {
        "source_refs": {
          "type": "array",
          "required": true
        }
      },
      "steps": [
        {
          "id": "gate",
          "action": "state.gate"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "summary",
          "action": "judgment.request",
          "with": {
            "task": "closeout",
            "instructions": "Summarize verified outcomes, limitations, and remaining work using only the supplied evidence.",
            "source_refs": "${inputs.source_refs}",
            "result_schema": {
              "type": "object",
              "required": [
                "summary",
                "remaining_work",
                "source_refs"
              ],
              "properties": {
                "summary": {
                  "type": "string"
                },
                "remaining_work": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "source_refs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "summary",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "project.maintenance",
      "version": 1,
      "description": "Audit config, state, staleness, traceability, and optional substrate projection deterministically.",
      "inputs": {
        "repo_id": {
          "type": "string",
          "default": "local"
        }
      },
      "steps": [
        {
          "id": "config",
          "action": "config.audit"
        },
        {
          "id": "services",
          "action": "services.audit"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "staleness",
          "action": "staleness.audit"
        },
        {
          "id": "graph",
          "action": "graph.build"
        },
        {
          "id": "substrate",
          "action": "substrate.preflight"
        },
        {
          "id": "goals",
          "action": "substrate.goals"
        },
        {
          "id": "telemetry",
          "action": "substrate.telemetry"
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "config",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "services",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "state",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "graph",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "install.update-check",
      "version": 1,
      "description": "Validate installed configuration and state after an additive install or update.",
      "inputs": {},
      "steps": [
        {
          "id": "config",
          "action": "config.audit"
        },
        {
          "id": "services",
          "action": "services.audit"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "gate",
          "action": "state.gate"
        },
        {
          "id": "substrate",
          "action": "substrate.preflight"
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "config",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "services",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "gate",
          "equals": "completed"
        }
      ]
    },
    {
      "id": "hub.release",
      "version": 1,
      "description": "Run the single release-boundary full verification, release/gap checks, package check, and state gates.",
      "inputs": {},
      "steps": [
        {
          "id": "diff",
          "action": "git.diff_check"
        },
        {
          "id": "config",
          "action": "config.audit"
        },
        {
          "id": "state",
          "action": "state.consistency"
        },
        {
          "id": "workflow_audit",
          "action": "process.fixed",
          "with": {
            "operation": "workflow_chml_audit"
          }
        },
        {
          "id": "substrate_audit",
          "action": "process.fixed",
          "with": {
            "operation": "substrate_capability_audit"
          }
        },
        {
          "id": "suite",
          "action": "process.fixed",
          "with": {
            "operation": "local_workflow_check"
          }
        },
        {
          "id": "release",
          "action": "process.fixed",
          "with": {
            "operation": "release_check"
          }
        },
        {
          "id": "gaps",
          "action": "process.fixed",
          "with": {
            "operation": "gap_audit"
          }
        },
        {
          "id": "package",
          "action": "process.fixed",
          "with": {
            "operation": "package_check"
          }
        },
        {
          "id": "gate",
          "action": "state.gate"
        }
      ],
      "postconditions": [
        {
          "type": "step_status",
          "step": "workflow_audit",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "substrate_audit",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "suite",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "release",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "gaps",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "package",
          "equals": "completed"
        },
        {
          "type": "step_status",
          "step": "gate",
          "equals": "completed"
        }
      ]
    }
  ]
}
