{
  "version": "3.16",
  "name": "AutoTest Pipeline",
  "registry": {
    "params": [],
    "services": [],
    "apis": [],
    "components": [],
    "vars": [
      "$compileResult(OBJECT)",
      "$metadata(OBJECT)",
      "$testCases(OBJECT)",
      "$runResults(OBJECT)",
      "$evaluations(OBJECT)",
      "$fixResults(OBJECT)"
    ],
    "files": {
      "inputs": [],
      "artifacts": []
    },
    "docs": {}
  },
  "steps": [
    {
      "id": "Local_Compile",
      "meta": { "title": "1. Compile Preview" },
      "in": { "max_tokens": 4096 },
      "out": { "$compileResult": "_result" },
      "next": "Extract_Metadata"
    },
    {
      "id": "Extract_Metadata",
      "meta": { "title": "2. Extract Metadata" },
      "in": { "max_tokens": 4096 },
      "out": { "$metadata": "_result" },
      "next": "Generate_Tests"
    },
    {
      "id": "Generate_Tests",
      "meta": { "title": "3. Generate Test Cases" },
      "in": {
        "max_tokens": 16000,
        "messages": [
          { "role": "user", "content": "Generate test cases from metadata" }
        ]
      },
      "out": { "$testCases": "_result" },
      "next": "Run_Playwright"
    },
    {
      "id": "Run_Playwright",
      "meta": { "title": "4. Run Playwright Tests" },
      "in": { "max_tokens": 4096 },
      "out": { "$runResults": "_result" },
      "next": "Evaluate_Results"
    },
    {
      "id": "Evaluate_Results",
      "meta": { "title": "5. Evaluate Results" },
      "in": { "max_tokens": 4096 },
      "out": { "$evaluations": "_result" },
      "next": "Branch_Pass_Fail"
    },
    {
      "id": "Branch_Pass_Fail",
      "meta": { "title": "6. Pass / Fail?" },
      "type": "Branch_",
      "in": {
        "expression": "=$evaluations.allPassed"
      },
      "branches": [
        ["true", "Report_Success"],
        ["false", "Analyze_Failures"]
      ]
    },
    {
      "id": "Analyze_Failures",
      "meta": { "title": "7a. Analyze Failures" },
      "in": {
        "max_tokens": 16000,
        "messages": [
          { "role": "user", "content": "Analyze test failures and suggest fixes" }
        ]
      },
      "out": { "$fixResults": "_result" },
      "next": "User_Decision"
    },
    {
      "id": "User_Decision",
      "meta": { "title": "8. Choose Action" },
      "type": "Branch_",
      "in": {
        "expression": "=$userChoice"
      },
      "branches": [
        ["fix_and_rerun", "Apply_Fixes"],
        ["report_only", "Report_Failures"],
        ["skip", "Stop_Pipeline"]
      ]
    },
    {
      "id": "Apply_Fixes",
      "meta": { "title": "9. Apply VL Fixes" },
      "in": { "max_tokens": 8192 },
      "next": "Recompile"
    },
    {
      "id": "Recompile",
      "meta": { "title": "10. Recompile" },
      "in": { "max_tokens": 4096 },
      "next": "Run_Playwright"
    },
    {
      "id": "Report_Success",
      "meta": { "title": "Report: All Passed" },
      "type": "Stop_",
      "in": {}
    },
    {
      "id": "Report_Failures",
      "meta": { "title": "Report: With Failures" },
      "type": "Stop_",
      "in": {}
    },
    {
      "id": "Stop_Pipeline",
      "meta": { "title": "Pipeline Stopped" },
      "type": "Stop_",
      "in": {}
    }
  ]
}
