{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tenantatlas.local/specs/212/test-authoring-governance.schema.json",
  "title": "Test Authoring Governance Pack",
  "description": "Repository-owned contract for the constitution, authoring prompts, review guardrails, escalation policy, and validation scenarios introduced by Spec 212.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "constitutionSection",
    "specImpactPromptBlock",
    "planImpactPromptBlock",
    "taskGovernanceChecklist",
    "reviewGuardrailChecklist",
    "escalationPolicy",
    "contributorGuidance",
    "validationScenarios"
  ],
  "properties": {
    "schemaVersion": {
      "type": "string"
    },
    "constitutionSection": {
      "$ref": "#/$defs/constitutionSection"
    },
    "specImpactPromptBlock": {
      "$ref": "#/$defs/specImpactPromptBlock"
    },
    "planImpactPromptBlock": {
      "$ref": "#/$defs/planImpactPromptBlock"
    },
    "taskGovernanceChecklist": {
      "$ref": "#/$defs/checklist"
    },
    "reviewGuardrailChecklist": {
      "$ref": "#/$defs/reviewChecklist"
    },
    "escalationPolicy": {
      "$ref": "#/$defs/escalationPolicy"
    },
    "contributorGuidance": {
      "$ref": "#/$defs/contributorGuidance"
    },
    "validationScenarios": {
      "type": "array",
      "minItems": 2,
      "items": {
        "$ref": "#/$defs/validationScenario"
      }
    }
  },
  "$defs": {
    "constitutionSection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sectionId",
        "version",
        "classificationRule",
        "laneAwarenessRule",
        "heavyJustificationRule",
        "minimalFixtureRule",
        "expensiveDefaultBanRule",
        "reviewExpectationRule",
        "escalationRule",
        "linkedWorkflowSurfaces"
      ],
      "properties": {
        "sectionId": { "type": "string" },
        "version": { "type": "string" },
        "classificationRule": { "type": "string" },
        "laneAwarenessRule": { "type": "string" },
        "heavyJustificationRule": { "type": "string" },
        "minimalFixtureRule": { "type": "string" },
        "expensiveDefaultBanRule": { "type": "string" },
        "reviewExpectationRule": { "type": "string" },
        "escalationRule": { "type": "string" },
        "linkedWorkflowSurfaces": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        }
      }
    },
    "specImpactPromptBlock": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "blockId",
        "requiredFields",
        "narrowestProofRule",
        "naAllowanceRule",
        "escalationPrompt",
        "reviewerHandOff"
      ],
      "properties": {
        "blockId": { "type": "string" },
        "requiredFields": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "narrowestProofRule": { "type": "string" },
        "naAllowanceRule": { "type": "string" },
        "escalationPrompt": { "type": "string" },
        "reviewerHandOff": { "type": "string" }
      }
    },
    "planImpactPromptBlock": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "blockId",
        "changedTestTypes",
        "helperOrFixtureImpact",
        "laneReshapeQuestion",
        "closingValidationRule",
        "driftDocumentationRule"
      ],
      "properties": {
        "blockId": { "type": "string" },
        "changedTestTypes": {
          "type": "array",
          "items": { "type": "string" }
        },
        "helperOrFixtureImpact": { "type": "string" },
        "laneReshapeQuestion": { "type": "string" },
        "closingValidationRule": { "type": "string" },
        "driftDocumentationRule": { "type": "string" }
      }
    },
    "checklist": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "checklistId",
        "items",
        "appliesWhen",
        "evidenceTarget"
      ],
      "properties": {
        "checklistId": { "type": "string" },
        "items": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "appliesWhen": { "type": "string" },
        "evidenceTarget": { "type": "string" }
      }
    },
    "reviewChecklist": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "checklistId",
        "questions",
        "expectedOutcomeSet",
        "maxReviewMinutes",
        "escalationReference"
      ],
      "properties": {
        "checklistId": { "type": "string" },
        "questions": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "expectedOutcomeSet": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "keep",
              "split",
              "document-in-feature",
              "follow-up-spec",
              "reject-or-split"
            ]
          }
        },
        "maxReviewMinutes": {
          "type": "integer",
          "minimum": 1
        },
        "escalationReference": { "type": "string" }
      }
    },
    "escalationPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "policyId",
        "triggers",
        "outcomes",
        "followUpThresholdRule"
      ],
      "properties": {
        "policyId": { "type": "string" },
        "triggers": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "new-heavy-family",
              "new-browser-coverage",
              "material-lane-cost-shift",
              "broad-filament-livewire-governance-surface",
              "revived-expensive-default",
              "budget-or-baseline-relevant-change",
              "major-suite-reshaping"
            ]
          }
        },
        "outcomes": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "none",
              "document-in-feature",
              "follow-up-spec",
              "reject-or-split"
            ]
          }
        },
        "followUpThresholdRule": { "type": "string" }
      }
    },
    "contributorGuidance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "guidanceId",
        "decisionPoints",
        "examplePatterns",
        "entryPoints",
        "sharedVocabulary"
      ],
      "properties": {
        "guidanceId": { "type": "string" },
        "decisionPoints": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "examplePatterns": {
          "type": "array",
          "items": { "type": "string" }
        },
        "entryPoints": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "sharedVocabulary": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        }
      }
    },
    "validationScenario": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "scenarioId",
        "scenarioType",
        "representativeArtifact",
        "expectedPromptPattern",
        "expectedEscalationOutcome",
        "status"
      ],
      "properties": {
        "scenarioId": { "type": "string" },
        "scenarioType": {
          "type": "string",
          "enum": ["low-impact", "high-impact"]
        },
        "representativeArtifact": { "type": "string" },
        "expectedPromptPattern": { "type": "string" },
        "expectedEscalationOutcome": {
          "type": "string",
          "enum": [
            "none",
            "document-in-feature",
            "follow-up-spec",
            "reject-or-split"
          ]
        },
        "status": {
          "type": "string",
          "enum": ["planned", "validated", "needs-tuning"]
        },
        "notes": {
          "type": "string"
        }
      }
    }
  }
}