{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://muthu4all.github.io/compile-once-enterprise/spec/schemas/constellation.schema.json",
  "title": "Compile-Once Constellation",
  "description": "A composition of capsules across spheres that completes a bigger job, with explicit decision points for people. Draft v0.1.",
  "type": "object",
  "required": ["spec", "constellation", "version", "purpose", "owner", "steps", "tests"],
  "properties": {
    "spec": { "const": "compile-once/constellation/v0.1" },
    "constellation": { "type": "string", "pattern": "^[a-z][a-z0-9-]{1,60}$" },
    "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "purpose": { "type": "string" },
    "owner": { "type": "object", "required": ["team", "approver"], "properties": { "team": { "type": "string" }, "approver": { "type": "string" } } },
    "trigger": { "type": "string", "description": "Event or schedule that starts a run." },
    "steps": {
      "type": "array", "minItems": 2,
      "items": {
        "type": "object", "required": ["id", "type"],
        "properties": {
          "id": { "type": "string" },
          "type": { "enum": ["capsule", "decision-point"] },
          "capsule": { "type": "string", "description": "capsule-id@version, required when type is capsule." },
          "inputs_from": { "type": "array", "items": { "type": "string" } },
          "on_failure": { "enum": ["stop", "skip", "route-to-person"], "default": "route-to-person" },
          "decided_by": { "type": "string", "description": "Role that decides, required when type is decision-point." }
        }
      }
    },
    "tests": { "type": "object", "required": ["passed", "total"], "properties": { "passed": { "type": "integer" }, "total": { "type": "integer" } } },
    "build": { "type": "object", "properties": { "by": { "const": "forge" }, "model_use": { "const": "build-time-only" } } },
    "runtime": { "type": "object", "properties": { "llm_calls": { "const": "none" }, "audit_log": { "type": "boolean", "default": true } } }
  },
  "additionalProperties": false
}
