{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "solution-archetype-trigger-presentation-projection-v2.1.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "artifact_type",
    "projection_version",
    "archetype",
    "method_versions",
    "representation_status",
    "diagnostic_problem",
    "expression",
    "coverage",
    "other_requirements_and_context",
    "supporting_context_groundings",
    "presentation_policy",
    "provenance"
  ],
  "properties": {
    "artifact_type": {
      "const": "SOLUTION_ARCHETYPE_TRIGGER_PRESENTATION_PROJECTION"
    },
    "projection_version": {
      "const": "2.1"
    },
    "archetype": {
      "$ref": "#/$defs/archetype"
    },
    "method_versions": {
      "type": "object",
      "additionalProperties": false,
      "required": ["prime_relink", "dsa_reconciliation", "presentation"],
      "properties": {
        "prime_relink": {"const": "production-v1.2"},
        "dsa_reconciliation": {"const": "dsa-reconciliation-production-v2"},
        "presentation": {"const": "trigger-presentation-v2.1"}
      }
    },
    "representation_status": {
      "$ref": "#/$defs/representation_status"
    },
    "diagnostic_problem": {
      "$ref": "#/$defs/diagnostic_problem"
    },
    "expression": {
      "$ref": "#/$defs/expression"
    },
    "coverage": {
      "$ref": "#/$defs/coverage"
    },
    "other_requirements_and_context": {
      "type": "array",
      "items": {"$ref": "#/$defs/nontrigger_condition"}
    },
    "supporting_context_groundings": {
      "type": "array",
      "items": {"$ref": "#/$defs/supporting_context_grounding"}
    },
    "presentation_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "predicate_is_authoritative",
        "explanations_may_not_change_logic",
        "grounding_is_not_confidence",
        "supporting_context_is_not_trigger",
        "candidate_decision_ledgers_default_hidden"
      ],
      "properties": {
        "predicate_is_authoritative": {"const": true},
        "explanations_may_not_change_logic": {"const": true},
        "grounding_is_not_confidence": {"const": true},
        "supporting_context_is_not_trigger": {"const": true},
        "candidate_decision_ledgers_default_hidden": {"const": true}
      }
    },
    "provenance": {
      "$ref": "#/$defs/provenance"
    }
  },
  "$defs": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:_[a-z0-9]+)*$"
    },
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "archetype": {
      "type": "object",
      "additionalProperties": false,
      "required": ["slug", "name", "page_ref"],
      "properties": {
        "slug": {"$ref": "#/$defs/slug"},
        "name": {"type": "string", "minLength": 1},
        "page_ref": {
          "type": "string",
          "pattern": "^solution_archetype:[a-z0-9]+(?:_[a-z0-9]+)*$"
        }
      }
    },
    "representation_status": {
      "type": "object",
      "additionalProperties": false,
      "required": ["code", "label", "explanation"],
      "properties": {
        "code": {
          "enum": [
            "FULLY_CATALOG_GROUNDED_SET",
            "PARTIAL_CATALOG_GROUNDING",
            "NO_CATALOG_GROUNDING"
          ]
        },
        "label": {"type": "string", "minLength": 1},
        "explanation": {"type": "string", "minLength": 1}
      }
    },
    "diagnostic_problem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["summary", "explanation", "explanation_source"],
      "properties": {
        "summary": {"type": "string", "minLength": 1},
        "explanation": {"type": "string", "minLength": 1},
        "explanation_source": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "field"],
          "properties": {
            "kind": {"const": "AUTHORED_ARCHETYPE_FIELD"},
            "field": {
              "enum": [
                "prose_structural_problem",
                "structural_problem",
                "diagnostic_head"
              ]
            }
          }
        }
      }
    },
    "expression": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "condition_structure",
        "between_sets_operator",
        "within_sets_operator",
        "condition_sets"
      ],
      "properties": {
        "condition_structure": {
          "enum": ["CONJUNCTIVE", "DISJUNCTIVE", "MIXED"]
        },
        "between_sets_operator": {
          "type": ["string", "null"],
          "enum": ["OR", null]
        },
        "within_sets_operator": {"const": "AND"},
        "condition_sets": {
          "type": "array",
          "minItems": 0,
          "items": {"$ref": "#/$defs/condition_set"}
        }
      }
    },
    "condition_set": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "condition_set_id",
        "label",
        "within_set_operator",
        "fully_catalog_grounded",
        "conditions",
        "audit"
      ],
      "properties": {
        "condition_set_id": {"type": "string", "pattern": "^B[1-9][0-9]*$"},
        "label": {"type": "string", "minLength": 1},
        "within_set_operator": {"const": "AND"},
        "fully_catalog_grounded": {"type": "boolean"},
        "conditions": {
          "type": "array",
          "minItems": 1,
          "items": {"$ref": "#/$defs/condition"}
        },
        "audit": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sufficiency_argument", "removal_argument"],
          "properties": {
            "sufficiency_argument": {"type": "string", "minLength": 1},
            "removal_argument": {"type": "string", "minLength": 1}
          }
        }
      }
    },
    "condition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "condition_id",
        "scope",
        "predicate",
        "function",
        "source_conditions",
        "explanation",
        "grounding_status",
        "groundings",
        "supporting_groundings",
        "open_issue",
        "audit_history"
      ],
      "properties": {
        "condition_id": {"type": "string", "minLength": 1},
        "scope": {"enum": ["ATOM", "HEAD", "HEAD_RESIDUAL"]},
        "predicate": {"type": "string", "minLength": 1},
        "function": {"const": "STRUCTURAL_TRIGGER"},
        "source_conditions": {
          "type": "array",
          "uniqueItems": true,
          "items": {"type": "integer", "minimum": 1}
        },
        "explanation": {"$ref": "#/$defs/explanation"},
        "grounding_status": {
          "enum": [
            "PRIME_GROUNDED",
            "DSA_GROUNDED",
            "PARTIALLY_DSA_GROUNDED",
            "OPEN",
            "SOURCE_REVIEW_REQUIRED",
            "NON_ABSTRACTION_RECLASSIFIED"
          ]
        },
        "groundings": {
          "type": "array",
          "items": {"$ref": "#/$defs/grounding"}
        },
        "supporting_groundings": {
          "type": "array",
          "items": {"$ref": "#/$defs/grounding"}
        },
        "open_issue": {
          "oneOf": [
            {"type": "null"},
            {"$ref": "#/$defs/open_issue"}
          ]
        },
        "audit_history": {
          "type": "object",
          "additionalProperties": false,
          "required": ["prime_relink_representation", "dsa_atomic_units"],
          "properties": {
            "prime_relink_representation": {"type": "object"},
            "dsa_atomic_units": {
              "type": "array",
              "items": {"$ref": "#/$defs/dsa_unit"}
            }
          }
        }
      }
    },
    "explanation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "paragraph",
        "source_kind",
        "source_condition_indexes",
        "source_texts",
        "semantic_guardrail"
      ],
      "properties": {
        "paragraph": {"type": "string", "minLength": 1},
        "source_kind": {
          "enum": [
            "AUTHORED_TRIGGER_NOTE_SYNTHESIS",
            "AUTHORED_CONTEXT_SYNTHESIS",
            "SOURCE_CONDITION_CONTEXT",
            "GENERATED_LOGIC_CLARIFICATION"
          ]
        },
        "source_condition_indexes": {
          "type": "array",
          "uniqueItems": true,
          "items": {"type": "integer", "minimum": 1}
        },
        "source_texts": {
          "type": "array",
          "uniqueItems": true,
          "items": {"type": "string", "minLength": 1}
        },
        "semantic_guardrail": {"const": "PRESENTATION_ONLY_NO_LOGIC_CHANGE"}
      }
    },
    "grounding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "catalog_type",
        "slug",
        "name",
        "one_liner",
        "page_ref",
        "edge_tier",
        "qualifier",
        "why_it_fits",
        "role_mapping",
        "source_unit_id",
        "authoritative_provenance"
      ],
      "properties": {
        "catalog_type": {"enum": ["PRIME", "DOMAIN_SPECIFIC"]},
        "slug": {"$ref": "#/$defs/slug"},
        "name": {"type": "string", "minLength": 1},
        "one_liner": {"type": "string"},
        "page_ref": {
          "type": "string",
          "pattern": "^(prime|domain_specific):[a-z0-9]+(?:_[a-z0-9]+)*$"
        },
        "edge_tier": {"type": "string", "minLength": 1},
        "qualifier": {
          "oneOf": [
            {"type": "null"},
            {"$ref": "#/$defs/guard"}
          ]
        },
        "why_it_fits": {"type": "string", "minLength": 1},
        "role_mapping": {"type": "string"},
        "source_unit_id": {"type": ["string", "null"]},
        "authoritative_provenance": {"type": "string", "minLength": 1},
        "relationship_clause": {
          "type": "array",
          "items": {"type": "object"}
        },
        "counterexample_attempt": {"type": "string", "minLength": 1}
      }
    },
    "guard": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "guard_type",
        "predicate",
        "normalized_key",
        "fills_obligation_ids",
        "rationale"
      ],
      "properties": {
        "kind": {"enum": ["CONTEXT_GUARD", "INTERPRETIVE_BRIDGE"]},
        "guard_type": {"type": "string", "minLength": 1},
        "predicate": {"type": "string", "minLength": 1},
        "normalized_key": {"$ref": "#/$defs/slug"},
        "fills_obligation_ids": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {"type": "string", "minLength": 1}
        },
        "rationale": {"type": "string", "minLength": 1}
      }
    },
    "open_issue": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "normalized_requirement",
        "prior_prime_residual_kind",
        "why_open",
        "research_disposition",
        "nearest_primes",
        "dsa_review"
      ],
      "properties": {
        "normalized_requirement": {"type": "string", "minLength": 1},
        "prior_prime_residual_kind": {"type": "string", "minLength": 1},
        "why_open": {"type": "string", "minLength": 1},
        "research_disposition": {
          "enum": [
            "SOURCE_REVIEW_REQUIRED",
            "NON_ABSTRACTION_RECLASSIFIED",
            "PARTIAL_EXISTING_DSA_GROUNDING",
            "EXISTING_DSA_SHORTLIST_OPEN",
            "DSA_REVIEW_NO_TRIGGER_PROJECTION",
            "NOT_CHECKED_IN_DSA_RECONCILIATION"
          ]
        },
        "nearest_primes": {
          "type": "array",
          "items": {"type": "object"}
        },
        "dsa_review": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "eligible_units",
            "resolved_units",
            "unresolved_units",
            "non_abstraction_units",
            "source_defect_units"
          ],
          "properties": {
            "status": {"enum": ["REVIEWED", "NOT_IN_RECONCILIATION_POPULATION"]},
            "eligible_units": {"type": "integer", "minimum": 0},
            "resolved_units": {"type": "integer", "minimum": 0},
            "unresolved_units": {"type": "integer", "minimum": 0},
            "non_abstraction_units": {"type": "integer", "minimum": 0},
            "source_defect_units": {"type": "integer", "minimum": 0}
          }
        }
      }
    },
    "dsa_unit": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "case_id",
        "unit_id",
        "predicate",
        "structural_head",
        "function",
        "semantic_scope",
        "resolution",
        "live_residual",
        "enumeration_semantics",
        "obligations",
        "dnf"
      ],
      "properties": {
        "case_id": {"type": "string", "minLength": 1},
        "unit_id": {"type": "string", "minLength": 1},
        "predicate": {"type": "string", "minLength": 1},
        "structural_head": {"type": "string", "minLength": 1},
        "function": {"enum": ["STRUCTURAL_TRIGGER", "SUPPORTING_CONTEXT"]},
        "semantic_scope": {
          "enum": ["ELIGIBLE_RELATIONAL", "NON_ABSTRACTION", "SOURCE_DEFECT"]
        },
        "resolution": {
          "enum": [
            "RETAINED_EXISTING_DSA",
            "UNRESOLVED",
            "NON_ABSTRACTION_RESIDUAL",
            "SOURCE_DEFECT"
          ]
        },
        "live_residual": {"type": "boolean"},
        "enumeration_semantics": {
          "enum": ["TRUE_DISJUNCTION", "ILLUSTRATIVE_MANIFESTATIONS", "NOT_APPLICABLE"]
        },
        "obligations": {"type": "array", "items": {"type": "object"}},
        "dnf": {
          "type": "array",
          "items": {"type": "array", "items": {"type": "string"}}
        }
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "structural_conditions",
        "catalog_grounded_conditions",
        "prime_grounded_conditions",
        "dsa_grounded_conditions",
        "partially_dsa_grounded_conditions",
        "open_conditions",
        "source_review_conditions",
        "non_abstraction_reclassified_conditions",
        "condition_sets",
        "fully_catalog_grounded_condition_sets",
        "statement"
      ],
      "properties": {
        "structural_conditions": {"type": "integer", "minimum": 0},
        "catalog_grounded_conditions": {"type": "integer", "minimum": 0},
        "prime_grounded_conditions": {"type": "integer", "minimum": 0},
        "dsa_grounded_conditions": {"type": "integer", "minimum": 0},
        "partially_dsa_grounded_conditions": {"type": "integer", "minimum": 0},
        "open_conditions": {"type": "integer", "minimum": 0},
        "source_review_conditions": {"type": "integer", "minimum": 0},
        "non_abstraction_reclassified_conditions": {"type": "integer", "minimum": 0},
        "condition_sets": {"type": "integer", "minimum": 0},
        "fully_catalog_grounded_condition_sets": {"type": "integer", "minimum": 0},
        "statement": {"type": "string", "minLength": 1}
      }
    },
    "nontrigger_condition": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_condition_index",
        "text",
        "display_text",
        "function",
        "explanation",
        "separation_note"
      ],
      "properties": {
        "source_condition_index": {"type": "integer", "minimum": 1},
        "text": {"type": "string", "minLength": 1},
        "display_text": {"type": "string", "minLength": 1},
        "function": {
          "enum": [
            "GOAL",
            "SOLUTION_FEASIBILITY",
            "APPLICATION_GATE",
            "DEPLOYMENT_CONSTRAINT",
            "SUPPORTING_CONTEXT",
            "MALFORMED",
            "OTHER_NON_TRIGGER"
          ]
        },
        "explanation": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "paragraph",
            "source_kind",
            "source_condition_indexes",
            "source_texts",
            "semantic_guardrail"
          ],
          "properties": {
            "paragraph": {"type": "string", "minLength": 1},
            "source_kind": {
              "enum": [
                "AUTHORED_TRIGGER_NOTE_SYNTHESIS",
                "AUTHORED_CONTEXT_SYNTHESIS",
                "SOURCE_CONDITION_CONTEXT",
                "GENERATED_ROLE_CLARIFICATION"
              ]
            },
            "source_condition_indexes": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {"type": "integer", "minimum": 1}
            },
            "source_texts": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {"type": "string", "minLength": 1}
            },
            "semantic_guardrail": {"const": "PRESENTATION_ONLY_NO_LOGIC_CHANGE"}
          }
        },
        "separation_note": {"type": "string", "minLength": 1}
      }
    },
    "supporting_context_grounding": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source_residual_occurrence_id", "unit", "groundings", "publication_role"],
      "properties": {
        "source_residual_occurrence_id": {"type": "string", "minLength": 1},
        "unit": {"$ref": "#/$defs/dsa_unit"},
        "groundings": {
          "type": "array",
          "minItems": 1,
          "items": {"$ref": "#/$defs/grounding"}
        },
        "publication_role": {"const": "SUPPORTING_CONTEXT_ONLY"}
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "base_projection",
        "base_projection_sha256",
        "dsa_projection_sha256",
        "archetype_catalog_sha256",
        "prime_catalog_sha256",
        "dsa_catalog_sha256"
      ],
      "properties": {
        "base_projection": {"type": "object"},
        "base_projection_sha256": {"$ref": "#/$defs/sha256"},
        "dsa_projection_sha256": {"$ref": "#/$defs/sha256"},
        "archetype_catalog_sha256": {"$ref": "#/$defs/sha256"},
        "prime_catalog_sha256": {"$ref": "#/$defs/sha256"},
        "dsa_catalog_sha256": {"$ref": "#/$defs/sha256"}
      }
    }
  }
}
