{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://standards.rootblocks.com/schemas/construction/construction-language.v1.schema.json",
  "title": "RootBlocks Construction Intermediate Language v1",
  "description": "Canonical YAML/JSON contract used by RootBlocks Console to describe what must be built and by BuilderX to validate, visualize, compile, orchestrate, test, deploy, and audit it.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "constructionId",
    "name",
    "version",
    "standard",
    "project",
    "architecture",
    "runtime",
    "catalogs",
    "workflows",
    "quality",
    "infrastructure",
    "delivery",
    "generation",
    "semanticEngines",
    "sourceMaps",
    "evidence",
    "policies"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rootblocks.construction/v1"
    },
    "constructionId": {
      "$ref": "#/$defs/id"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "version": {
      "$ref": "#/$defs/semver"
    },
    "standard": {
      "$ref": "#/$defs/standardRef"
    },
    "project": {
      "$ref": "#/$defs/project"
    },
    "architecture": {
      "$ref": "#/$defs/architecture"
    },
    "runtime": {
      "$ref": "#/$defs/runtime"
    },
    "catalogs": {
      "$ref": "#/$defs/catalogs"
    },
    "componentOutputs": {
      "$ref": "#/$defs/componentOutputs"
    },
    "workflows": {
      "$ref": "#/$defs/workflows"
    },
    "quality": {
      "$ref": "#/$defs/quality"
    },
    "infrastructure": {
      "$ref": "#/$defs/infrastructure"
    },
    "delivery": {
      "$ref": "#/$defs/delivery"
    },
    "generation": {
      "$ref": "#/$defs/generation"
    },
    "semanticEngines": {
      "$ref": "#/$defs/semanticEngines"
    },
    "documentation": {
      "$ref": "#/$defs/documentation"
    },
    "sourceMaps": {
      "$ref": "#/$defs/sourceMaps"
    },
    "evidence": {
      "$ref": "#/$defs/evidencePolicy"
    },
    "policies": {
      "$ref": "#/$defs/policies"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "infrastructure": {
            "properties": {
              "mode": {
                "const": "managed"
              }
            },
            "required": ["mode"]
          }
        },
        "required": ["infrastructure"]
      },
      "then": {
        "properties": {
          "infrastructure": {
            "required": ["provider", "iac", "environments", "resources", "operations"]
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "delivery": {
            "properties": {
              "mode": {
                "const": "managed"
              }
            },
            "required": ["mode"]
          }
        },
        "required": ["delivery"]
      },
      "then": {
        "properties": {
          "delivery": {
            "required": ["provider", "pipelines"]
          }
        }
      }
    }
  ],
  "$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.-]+)?$"
    },
    "standardRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["bundleId", "version", "hash"],
      "properties": {
        "bundleId": {
          "$ref": "#/$defs/id"
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64,128}$"
        }
      }
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "kind", "language", "targetRuntime", "sourceRoot", "builderxRoot", "docsRoot"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "kind": {
          "enum": ["application", "component-pack", "library", "worker", "service", "custom"]
        },
        "language": {
          "enum": ["csharp", "typescript", "python", "java", "go", "custom"]
        },
        "targetRuntime": {
          "type": "string",
          "minLength": 1
        },
        "targetFramework": {
          "type": "string",
          "minLength": 1
        },
        "sourceRoot": {
          "$ref": "#/$defs/path"
        },
        "builderxRoot": {
          "$ref": "#/$defs/path"
        },
        "docsRoot": {
          "$ref": "#/$defs/path"
        }
      }
    },
    "architecture": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profile", "profileVersion", "renderer"],
      "properties": {
        "profile": {
          "enum": ["ddd-clean", "component-pack", "vertical-slice", "mvc", "hexagonal", "custom"]
        },
        "profileVersion": {
          "$ref": "#/$defs/semver"
        },
        "renderer": {
          "enum": ["builderx-structured-project", "builderx-component-pack", "template-only", "custom"]
        },
        "decisions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": ["engine", "runner", "debugLevel", "requiredCapabilities"],
      "properties": {
        "engine": {
          "enum": ["builderx", "external", "custom"]
        },
        "runner": {
          "enum": ["api", "console", "worker", "library", "component-pack", "test", "custom"]
        },
        "debugLevel": {
          "enum": ["none", "trace", "workflow", "native"]
        },
        "requiredCapabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "catalogs": {
      "type": "object",
      "additionalProperties": false,
      "required": ["rootblocks", "organization", "local"],
      "properties": {
        "rootblocks": {
          "$ref": "#/$defs/catalogRefArray"
        },
        "organization": {
          "$ref": "#/$defs/catalogRefArray"
        },
        "local": {
          "$ref": "#/$defs/catalogRefArray"
        },
        "custom": {
          "$ref": "#/$defs/catalogRefArray"
        }
      }
    },
    "catalogRefArray": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/catalogRef"
      }
    },
    "catalogRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version", "source"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "source": {
          "enum": ["rootblocks-global", "organization-registry", "local-project", "custom-repository"]
        },
        "visibility": {
          "enum": ["public", "private", "organization", "local"]
        }
      }
    },
    "workflows": {
      "type": "object",
      "additionalProperties": false,
      "required": ["application", "infrastructure", "delivery", "tests"],
      "properties": {
        "application": {
          "$ref": "#/$defs/workflowBindingArray"
        },
        "infrastructure": {
          "$ref": "#/$defs/workflowBindingArray"
        },
        "delivery": {
          "$ref": "#/$defs/workflowBindingArray"
        },
        "tests": {
          "$ref": "#/$defs/workflowBindingArray"
        },
        "softwareProcesses": {
          "$ref": "#/$defs/workflowBindingArray"
        }
      }
    },
    "workflowBindingArray": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/workflowBinding"
      }
    },
    "workflowBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "path", "critical", "sourceMapRef"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "enum": ["business", "infra", "cicd", "test", "software-process", "component", "custom"]
        },
        "path": {
          "$ref": "#/$defs/path"
        },
        "critical": {
          "type": "boolean"
        },
        "sourceMapRef": {
          "$ref": "#/$defs/path"
        },
        "regressionSuiteRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "resourceRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "pipelineRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "quality": {
      "type": "object",
      "additionalProperties": false,
      "required": ["testSuites", "coveragePolicy", "regressionPolicy"],
      "properties": {
        "testSuites": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/testSuite"
          }
        },
        "coveragePolicy": {
          "type": "object",
          "additionalProperties": false,
          "required": ["minimumLineCoverage", "criticalPathCoverageRequired"],
          "properties": {
            "minimumLineCoverage": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "criticalPathCoverageRequired": {
              "type": "boolean"
            }
          }
        },
        "regressionPolicy": {
          "type": "object",
          "additionalProperties": false,
          "required": ["requiredForCriticalWorkflows", "staleCaseBehavior"],
          "properties": {
            "requiredForCriticalWorkflows": {
              "type": "boolean"
            },
            "staleCaseBehavior": {
              "enum": ["block", "warn", "ignore"]
            }
          }
        }
      }
    },
    "testSuite": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "runner", "path", "covers", "required"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "enum": ["unit", "contract", "integration", "e2e", "workflow-regression", "static-analysis"]
        },
        "runner": {
          "type": "string",
          "minLength": 1
        },
        "path": {
          "$ref": "#/$defs/path"
        },
        "covers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "required": {
          "type": "boolean"
        },
        "gateRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "infrastructure": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode"],
      "properties": {
        "mode": {
          "enum": ["none", "managed", "external"]
        },
        "provider": {
          "enum": ["azure", "aws", "gcp", "kubernetes", "custom"]
        },
        "iac": {
          "$ref": "#/$defs/iac"
        },
        "environments": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["dev", "qa", "prod"]
          },
          "uniqueItems": true
        },
        "resources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/resource"
          }
        },
        "operations": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["validate", "plan", "apply", "drift", "backup", "destroy", "capture-outputs"]
          },
          "uniqueItems": true
        }
      }
    },
    "iac": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "outputPath", "stateStrategy"],
      "properties": {
        "tool": {
          "enum": ["terraform", "opentofu", "bicep", "pulumi", "cloud-native", "custom"]
        },
        "outputPath": {
          "$ref": "#/$defs/path"
        },
        "stateStrategy": {
          "enum": ["local", "remote", "managed-by-provider", "external"]
        }
      }
    },
    "resource": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "name", "environmentScope", "lifecycle", "config"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9.-]{2,127}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "environmentScope": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["dev", "qa", "prod"]
          },
          "uniqueItems": true
        },
        "lifecycle": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["create", "read", "update", "replace", "delete", "backup", "restore"]
          },
          "uniqueItems": true
        },
        "dependsOn": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "config": {
          "type": "object"
        },
        "secretRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "outputs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/outputRef"
          }
        },
        "backup": {
          "type": "object",
          "additionalProperties": false,
          "required": ["eligible", "defaultSelected"],
          "properties": {
            "eligible": {
              "type": "boolean"
            },
            "defaultSelected": {
              "type": "boolean"
            },
            "policyRef": {
              "$ref": "#/$defs/id"
            }
          }
        },
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "outputRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "sensitive"],
      "properties": {
        "name": {
          "$ref": "#/$defs/id"
        },
        "sensitive": {
          "type": "boolean"
        }
      }
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode"],
      "properties": {
        "mode": {
          "enum": ["none", "managed", "external"]
        },
        "provider": {
          "enum": ["github-actions", "azure-devops", "gitlab-ci", "jenkins", "custom"]
        },
        "pipelines": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/pipeline"
          }
        }
      }
    },
    "pipeline": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "path", "stages", "gates", "rollback"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "path": {
          "$ref": "#/$defs/path"
        },
        "stages": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["restore", "build", "unit-test", "contract-test", "integration-test", "e2e-test", "workflow-regression", "security-scan", "iac-validate", "iac-plan", "deploy", "smoke-test", "release"]
          },
          "uniqueItems": true
        },
        "gates": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/gate"
          }
        },
        "rollback": {
          "type": "object",
          "additionalProperties": false,
          "required": ["strategy"],
          "properties": {
            "strategy": {
              "enum": ["manual", "previous-artifact", "iac-rollback", "custom"]
            }
          }
        }
      }
    },
    "gate": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "requiredFor"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "enum": ["approval", "policy", "test", "security", "health-check", "evidence", "manual"]
        },
        "requiredFor": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["qa", "prod", "release", "deploy", "destroy", "critical-change"]
          },
          "uniqueItems": true
        }
      }
    },
    "generation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode", "sourceOutput", "testOutput", "builderxOutput", "docsOutput", "compiledOutput", "protectedZones"],
      "properties": {
        "mode": {
          "enum": ["builderx-compiler", "agent-codegen-governed", "hybrid"]
        },
        "authority": {
          "enum": ["builderx", "rootblocks-console", "darkfactory", "shared"]
        },
        "fallbackAllowed": {
          "type": "boolean"
        },
        "agentCodegen": {
          "$ref": "#/$defs/agentCodegenPolicy"
        },
        "sourceOutput": {
          "$ref": "#/$defs/path"
        },
        "testOutput": {
          "$ref": "#/$defs/path"
        },
        "builderxOutput": {
          "$ref": "#/$defs/path"
        },
        "docsOutput": {
          "$ref": "#/$defs/path"
        },
        "compiledOutput": {
          "$ref": "#/$defs/path"
        },
        "protectedZones": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "customZones": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        }
      }
    },
    "agentCodegenPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["allowed", "reason", "requiresBuilderXValidation", "requiresSourceMaps", "requiresTests", "requiresEvidence", "allowedZones"],
      "properties": {
        "allowed": {
          "type": "boolean"
        },
        "reason": {
          "enum": ["renderer-unavailable", "bootstrap", "user-enabled", "custom-zone-only", "not-applicable"]
        },
        "requiresBuilderXValidation": {
          "type": "boolean"
        },
        "requiresSourceMaps": {
          "type": "boolean"
        },
        "requiresTests": {
          "type": "boolean"
        },
        "requiresEvidence": {
          "type": "boolean"
        },
        "allowedZones": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "blockedZones": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "requiredProfiles": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "requiredRuleRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "requiredMappingRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        }
      }
    },
    "documentation": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "specRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "workflowDocRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        },
        "architectureDocRefs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/path"
          },
          "uniqueItems": true
        }
      }
    },
    "semanticEngines": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ruleEngine", "mappingEngine", "queryEngine"],
      "properties": {
        "ruleEngine": {
          "$ref": "#/$defs/ruleEngineDecl"
        },
        "mappingEngine": {
          "$ref": "#/$defs/mappingEngineDecl"
        },
        "queryEngine": {
          "$ref": "#/$defs/queryEngineDecl"
        }
      }
    },
    "ruleEngineDecl": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode", "defaultMissingContextDecision", "ruleSetRefs"],
      "properties": {
        "mode": {
          "enum": ["enforced", "advisory", "disabled"]
        },
        "defaultMissingContextDecision": {
          "enum": ["block", "warn"]
        },
        "ruleSetRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/semanticEngineAssetRef"
          }
        }
      }
    },
    "mappingEngineDecl": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode", "sourceMapPolicy", "mappingSetRefs"],
      "properties": {
        "mode": {
          "enum": ["enforced", "advisory", "disabled"]
        },
        "sourceMapPolicy": {
          "enum": ["required-for-critical", "always-required", "advisory"]
        },
        "mappingSetRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/semanticEngineAssetRef"
          }
        },
        "criticalMappings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/criticalMapping"
          }
        }
      }
    },
    "criticalMapping": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "from", "to", "sourceMapRequired", "impactAnalysis"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "from": {
          "$ref": "#/$defs/semanticDomain"
        },
        "to": {
          "$ref": "#/$defs/semanticDomain"
        },
        "sourceMapRequired": {
          "type": "boolean"
        },
        "impactAnalysis": {
          "enum": ["required", "supported", "not-supported"]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "to": {
                "enum": ["generated-source", "iac", "cicd", "regression-suite", "evidence"]
              }
            },
            "required": ["to"]
          },
          "then": {
            "properties": {
              "sourceMapRequired": {
                "const": true
              }
            }
          }
        }
      ]
    },
    "queryEngineDecl": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode", "secretResultPolicy", "freshnessPolicy", "sourceRefs", "indexRefs", "querySetRefs"],
      "properties": {
        "mode": {
          "enum": ["enforced", "advisory", "disabled"]
        },
        "secretResultPolicy": {
          "enum": ["references-only"]
        },
        "freshnessPolicy": {
          "enum": ["block-critical-stale", "warn-stale", "offline-cache-allowed"]
        },
        "sourceRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "indexRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "querySetRefs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/semanticEngineAssetRef"
          }
        }
      }
    },
    "semanticEngineAssetRef": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version", "source", "path"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "source": {
          "enum": ["rootblocks-global", "organization-registry", "local-project", "custom-repository"]
        },
        "path": {
          "$ref": "#/$defs/path"
        }
      }
    },
    "semanticDomain": {
      "enum": [
        "spec",
        "construction",
        "project",
        "workflow",
        "flow-ir",
        "application-ir",
        "package-ir",
        "generated-source",
        "test-plan",
        "test-suite",
        "regression-suite",
        "infra-resource-graph",
        "iac",
        "cicd",
        "source-map",
        "evidence",
        "catalog",
        "component",
        "template",
        "architecture-profile",
        "runtime"
      ]
    },
    "componentOutputs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/componentOutput"
      }
    },
    "componentOutput": {
      "type": "object",
      "additionalProperties": false,
      "required": ["componentId", "version", "sourceMode", "manifestPath", "buildPackPath", "packageArtifacts", "sync"],
      "properties": {
        "componentId": {
          "$ref": "#/$defs/id"
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "sourceMode": {
          "enum": ["builderx-compiler", "agent-generated", "manual-governed", "imported"]
        },
        "manifestPath": {
          "$ref": "#/$defs/path"
        },
        "buildPackPath": {
          "$ref": "#/$defs/path"
        },
        "packageArtifacts": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/componentPackageArtifact"
          }
        },
        "sync": {
          "$ref": "#/$defs/componentSync"
        }
      }
    },
    "componentPackageArtifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "language", "name", "version", "path"],
      "properties": {
        "kind": {
          "enum": ["builderx-buildpack", "nuget", "npm", "pypi", "maven", "gradle", "cargo", "go-module", "composer", "gem", "docker-oci", "custom"]
        },
        "language": {
          "enum": ["csharp", "typescript", "javascript", "python", "java", "kotlin", "go", "rust", "php", "ruby", "custom"]
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "version": {
          "$ref": "#/$defs/semver"
        },
        "path": {
          "$ref": "#/$defs/path"
        }
      }
    },
    "componentSync": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "targetScope", "importCommand", "syncCommand", "evidencePath"],
      "properties": {
        "tool": {
          "const": "rbstd"
        },
        "targetScope": {
          "enum": ["global", "organization", "project", "personal"]
        },
        "importCommand": {
          "type": "string",
          "pattern": "^rbstd components import .+$"
        },
        "syncCommand": {
          "type": "string",
          "pattern": "^rbstd components sync .+$"
        },
        "evidencePath": {
          "$ref": "#/$defs/path"
        }
      }
    },
    "sourceMaps": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/sourceMapBinding"
      }
    },
    "sourceMapBinding": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "path", "maps"],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "path": {
          "$ref": "#/$defs/path"
        },
        "maps": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["spec", "workflow-node", "generated-source", "test-suite", "infra-resource", "cicd-stage", "evidence"]
          },
          "uniqueItems": true
        }
      }
    },
    "evidencePolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required", "events", "retention"],
      "properties": {
        "required": {
          "type": "boolean"
        },
        "events": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": ["validated", "generated", "compiled", "tested", "regression-run", "infra-planned", "infra-applied", "deployed", "debugged", "released", "failed"]
          },
          "uniqueItems": true
        },
        "retention": {
          "enum": ["project", "release", "organization-policy"]
        }
      }
    },
    "policies": {
      "type": "object",
      "additionalProperties": false,
      "required": ["validationMode", "secretPolicy", "antiOmissionMode", "missingDomainBehavior", "rawCodePolicy"],
      "properties": {
        "validationMode": {
          "enum": ["strict", "compatible", "advisory"]
        },
        "secretPolicy": {
          "enum": ["references-only"]
        },
        "antiOmissionMode": {
          "enum": ["enforced", "advisory"]
        },
        "missingDomainBehavior": {
          "enum": ["block", "warn"]
        },
        "rawCodePolicy": {
          "enum": ["forbid", "allow-in-custom-zones", "allow-with-review"]
        }
      }
    }
  }
}
