{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nova.dev/schemas/submission-readiness.schema.json",
  "title": "Nova Submission-Readiness Gate",
  "description": "Defines what is acceptable to start — a superset gate ABOVE contract.schema.json validity. The contract schema defines the SHAPE (id/name/environment/infrastructure); this schema defines the READINESS gate: required Nova tags, per-env mandatory metadata (W3.E), declared policy preconditions, profile:agentic markers, and the appSource pointer. The validator (core/submission_readiness.py, REQ-218) calls contract.schema.json validation first, then these readiness checks. On fail → citizen-developer-facing error (not a stack trace); on pass → proceeds to existing contract ingestion.",
  "type": "object",
  "required": ["contractId", "environment", "tags", "policyPreconditions", "profile", "appSource"],
  "properties": {
    "contractId": {
      "type": "string",
      "minLength": 1,
      "description": "The contract identifier (UUID or operational id). Non-empty."
    },
    "environment": {
      "type": "string",
      "enum": ["dev", "qa", "prod", "dr"],
      "description": "Target environment. Determines the per-env mandatory fields (allOf below)."
    },
    "tags": {
      "type": "object",
      "description": "The 5 required Nova tags (D-054). References schemas/tagging-standard.json.",
      "required": ["nova:owner", "nova:contract", "nova:environment", "nova:cost-center", "nova:ref"],
      "properties": {
        "nova:owner": {"type": "string", "minLength": 1},
        "nova:contract": {"type": "string", "minLength": 1},
        "nova:environment": {"type": "string", "enum": ["dev", "qa", "prod", "dr"]},
        "nova:cost-center": {"type": "string", "minLength": 1},
        "nova:ref": {"type": "string", "minLength": 1}
      },
      "additionalProperties": false
    },
    "policyPreconditions": {
      "type": "object",
      "description": "Declared policy expectations the platform will enforce. The citizen developer states what the platform should check; the platform enforces it at apply time. Missing a declared precondition is POLICY_PRECONDITION_MISSING.",
      "properties": {
        "public-ingress": {"type": "boolean", "default": false},
        "encryption_enabled": {"type": "boolean", "default": true},
        "deletion_protection": {"type": "boolean", "default": true}
      },
      "additionalProperties": true
    },
    "profile": {
      "type": "string",
      "enum": ["developer", "agentic"],
      "description": "developer = L3A (technical); agentic = L3B (non-technical, requires naturalLanguageIntent + confidenceAtSubmission + agentTrace per REQ-22 / W3.E)."
    },
    "appSource": {
      "type": "object",
      "description": "Pointer to the consumer application code so the platform can fetch at run time.",
      "required": ["repo", "ref"],
      "properties": {
        "repo": {"type": "string", "minLength": 1, "description": "Repository URL or owner/repo shorthand."},
        "ref": {"type": "string", "minLength": 1, "description": "Git ref (branch, tag, or SHA)."}
      },
      "additionalProperties": false
    },
    "naturalLanguageIntent": {
      "type": "string",
      "description": "Required when profile=agentic (L3B). The citizen developer's plain-language intent."
    },
    "confidenceAtSubmission": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Required when profile=agentic (L3B). The submitter's self-assessed confidence."
    },
    "agentTrace": {
      "type": "string",
      "description": "Required when profile=agentic (L3B). The agent's trace/reasoning for the submission."
    },
    "validation": {
      "type": "object",
      "description": "Per-env mandatory metadata (W3.E). qa requires e2eSuite + loadTest; prod requires runbook + dashboard + oncall; dr requires drDrillRef.",
      "properties": {
        "e2eSuite": {"type": "boolean"},
        "loadTest": {"type": "boolean"}
      },
      "additionalProperties": true
    },
    "runbook": {"type": "string", "description": "Required when environment=prod (W3.E)."},
    "dashboard": {"type": "string", "description": "Required when environment=prod (W3.E)."},
    "oncall": {"type": "string", "description": "Required when environment=prod (W3.E)."},
    "drDrillRef": {"type": "string", "description": "Required when environment=dr (W3.E)."}
  },
  "allOf": [
    {
      "if": {"properties": {"environment": {"const": "qa"}}},
      "then": {"required": ["validation"], "properties": {"validation": {"required": ["e2eSuite", "loadTest"]}}}
    },
    {
      "if": {"properties": {"environment": {"const": "prod"}}},
      "then": {"required": ["runbook", "dashboard", "oncall"]}
    },
    {
      "if": {"properties": {"environment": {"const": "dr"}}},
      "then": {"required": ["drDrillRef"]}
    },
    {
      "if": {"properties": {"profile": {"const": "agentic"}}},
      "then": {"required": ["naturalLanguageIntent", "confidenceAtSubmission", "agentTrace"]}
    }
  ],
  "additionalProperties": true
}