{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/golden/universal-e2e-fixture.v1.schema.json",
  "title": "RootBlocks Universal End-to-End Golden Fixture v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "fixtureId",
    "profile",
    "language",
    "featureSpec",
    "construction",
    "builderx",
    "inventories",
    "functionalWorkflow",
    "layeredTests",
    "iac",
    "cicd",
    "release",
    "sourceMaps",
    "evidence"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.universal-e2e-fixture/v1"
    },
    "fixtureId": {
      "$ref": "#/$defs/id"
    },
    "profile": {
      "enum": ["ddd-clean", "component-pack", "vertical-slice", "mvc", "hexagonal", "custom"]
    },
    "language": {
      "enum": ["csharp", "typescript", "python", "java", "go", "rust", "custom"]
    },
    "featureSpec": {
      "$ref": "#/$defs/featureSpec"
    },
    "construction": {
      "$ref": "#/$defs/construction"
    },
    "builderx": {
      "$ref": "#/$defs/builderx"
    },
    "inventories": {
      "$ref": "#/$defs/inventories"
    },
    "functionalWorkflow": {
      "$ref": "#/$defs/functionalWorkflow"
    },
    "layeredTests": {
      "$ref": "#/$defs/layeredTests"
    },
    "iac": {
      "$ref": "#/$defs/iac"
    },
    "cicd": {
      "$ref": "#/$defs/cicd"
    },
    "release": {
      "$ref": "#/$defs/release"
    },
    "sourceMaps": {
      "$ref": "#/$defs/sourceMaps"
    },
    "evidence": {
      "$ref": "#/$defs/evidence"
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[A-Za-z0-9_./@-]+$"
    },
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[A-Za-z0-9.-]+)?(\\+[A-Za-z0-9.-]+)?$"
    },
    "featureSpec": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "featureId", "sections"],
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^docs/specs/.+\\.md$"
        },
        "featureId": {
          "$ref": "#/$defs/id"
        },
        "sections": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        }
      }
    },
    "construction": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "schemaVersion", "constructionId", "profile", "language"],
      "properties": {
        "path": {
          "$ref": "#/$defs/path"
        },
        "schemaVersion": {
          "const": "rootblocks.construction/v1"
        },
        "constructionId": {
          "$ref": "#/$defs/id"
        },
        "profile": {
          "const": "ddd-clean"
        },
        "language": {
          "const": "csharp"
        }
      }
    },
    "builderx": {
      "type": "object",
      "additionalProperties": false,
      "required": ["projectPath", "flowPaths"],
      "properties": {
        "projectPath": {
          "$ref": "#/$defs/path"
        },
        "flowPaths": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        }
      }
    },
    "inventories": {
      "type": "object",
      "additionalProperties": false,
      "required": ["flowIr", "applicationIr", "generatedSource", "iac", "cicd"],
      "properties": {
        "flowIr": {
          "$ref": "#/$defs/inventoryRef"
        },
        "applicationIr": {
          "$ref": "#/$defs/inventoryRef"
        },
        "generatedSource": {
          "$ref": "#/$defs/generatedSourceInventory"
        },
        "iac": {
          "$ref": "#/$defs/inventoryRef"
        },
        "cicd": {
          "$ref": "#/$defs/inventoryRef"
        }
      }
    },
    "inventoryRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "required"],
      "properties": {
        "path": {
          "$ref": "#/$defs/path"
        },
        "required": {
          "const": true
        }
      }
    },
    "generatedSourceInventory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "files"],
      "properties": {
        "path": {
          "$ref": "#/$defs/path"
        },
        "files": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/generatedFile"
          }
        }
      }
    },
    "generatedFile": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "layer", "sourceMapRequired"],
      "properties": {
        "path": {
          "$ref": "#/$defs/path"
        },
        "layer": {
          "enum": ["domain", "application", "infrastructure", "workflows", "host", "test", "infra", "cicd"]
        },
        "sourceMapRequired": {
          "const": true
        }
      }
    },
    "functionalWorkflow": {
      "type": "object",
      "additionalProperties": false,
      "required": ["workflowId", "nodes", "nodeOperations", "applicationOperations", "domainPolicies", "ports"],
      "properties": {
        "workflowId": {
          "$ref": "#/$defs/id"
        },
        "nodes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/workflowNode"
          }
        },
        "nodeOperations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/nodeOperation"
          }
        },
        "applicationOperations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/applicationOperation"
          }
        },
        "domainPolicies": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/domainPolicy"
          }
        },
        "ports": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/applicationPort"
          }
        }
      }
    },
    "workflowNode": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "operationId", "callsInfrastructureDirect"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "operationId": {
          "$ref": "#/$defs/id"
        },
        "callsInfrastructureDirect": {
          "const": false
        }
      }
    },
    "nodeOperation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "workflowNodeId", "applicationOperationId"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "workflowNodeId": {
          "$ref": "#/$defs/id"
        },
        "applicationOperationId": {
          "$ref": "#/$defs/id"
        }
      }
    },
    "applicationOperation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "domainPolicyId", "portRefs", "referencesBuilderX"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "domainPolicyId": {
          "$ref": "#/$defs/id"
        },
        "portRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "referencesBuilderX": {
          "const": false
        }
      }
    },
    "domainPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "forbiddenReferences"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "forbiddenReferences": {
          "type": "array",
          "maxItems": 0,
          "items": {
            "enum": ["application", "infrastructure", "builderx", "io", "logging", "settings", "cloud", "database", "http", "messaging"]
          }
        }
      }
    },
    "applicationPort": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "implementedByInfrastructure"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "implementedByInfrastructure": {
          "const": true
        }
      }
    },
    "layeredTests": {
      "type": "object",
      "additionalProperties": false,
      "required": ["suites"],
      "properties": {
        "suites": {
          "type": "array",
          "minItems": 2,
          "items": {
            "$ref": "#/$defs/testSuite"
          },
          "allOf": [
            {
              "contains": {
                "properties": {
                  "id": {
                    "const": "workflows-tests"
                  }
                },
                "required": ["id"]
              }
            },
            {
              "contains": {
                "properties": {
                  "id": {
                    "const": "workflow-regression-tests"
                  }
                },
                "required": ["id"]
              }
            }
          ]
        }
      }
    },
    "testSuite": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "path", "covers"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "enum": ["unit", "contract", "integration", "e2e", "workflow-regression", "static-analysis"]
        },
        "path": {
          "$ref": "#/$defs/path"
        },
        "covers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "iac": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "stateBackend", "resources"],
      "properties": {
        "tool": {
          "enum": ["terraform", "opentofu", "bicep", "pulumi", "cloud-native", "custom"]
        },
        "stateBackend": {
          "type": "object",
          "additionalProperties": false,
          "required": ["mode", "path"],
          "properties": {
            "mode": {
              "enum": ["remote", "managed-by-provider"]
            },
            "path": {
              "$ref": "#/$defs/path"
            }
          }
        },
        "resources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "cicd": {
      "type": "object",
      "additionalProperties": false,
      "required": ["provider", "immutableArtifact", "prodApprovalGate", "stages"],
      "properties": {
        "provider": {
          "enum": ["github-actions", "azure-devops", "gitlab-ci", "jenkins", "custom"]
        },
        "immutableArtifact": {
          "const": true
        },
        "prodApprovalGate": {
          "const": true
        },
        "stages": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["restore", "build", "unit-test", "contract-test", "workflow-regression", "iac-plan", "deploy", "smoke-test", "release"]
          },
          "uniqueItems": true
        }
      }
    },
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required", "sbom", "provenance"],
      "properties": {
        "required": {
          "type": "boolean"
        },
        "sbom": {
          "const": true
        },
        "provenance": {
          "const": true
        }
      }
    },
    "sourceMaps": {
      "type": "object",
      "additionalProperties": false,
      "required": ["paths", "nodeOperationCoverage"],
      "properties": {
        "paths": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "nodeOperationCoverage": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/nodeSourceMapCoverage"
          }
        }
      }
    },
    "nodeSourceMapCoverage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["nodeOperationId", "sourceMapPath"],
      "properties": {
        "nodeOperationId": {
          "$ref": "#/$defs/id"
        },
        "sourceMapPath": {
          "$ref": "#/$defs/path"
        }
      }
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["paths", "events"],
      "properties": {
        "paths": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "events": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["validated", "generated", "compiled", "tested", "regression-run", "infra-planned", "deployed", "released"]
          },
          "uniqueItems": true
        }
      }
    }
  }
}
