{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://marloweaudit.com/sovereign-audit-nodes.schema.json",
  "title": "MARLOWE Sovereign Audit — 372-Node Canonical Record Schema",
  "description": "Validates sovereign-audit-nodes.json — the 372-row bilateral 186/186 grid. Const-locks all canonical figures and prior-art anchors per Work Order. USPTO Anchor 99745529 — Symmetrical Grid™ / 186/186 Node Symmetry™.",
  "type": "object",
  "required": [
    "schema_version", "record_id", "framework", "architect", "publisher",
    "prior_art_anchor", "sealed", "build_version", "total_nodes", "symmetry",
    "uspto_anchor", "canonical_figures", "signature_lines", "appendix_counts",
    "global_groups", "source_essays", "dual_ordering_note", "nodes"
  ],
  "properties": {
    "schema_version":   {"type": "string", "const": "1.0"},
    "record_id":        {"type": "string", "const": "MARLOWE-SOVEREIGN-AUDIT-NODES-372"},
    "framework":        {"type": "string", "const": "Architecture of Dependency and Autonomy™"},
    "architect":        {"type": "string", "const": "L.M. Marlowe"},
    "publisher":        {"type": "string", "const": "L.M. Marlowe LLC"},
    "site":             {"type": "string", "const": "https://marloweaudit.com"},
    "license":          {"type": "string", "const": "https://marloweaudit.com/reservation-of-rights.html"},
    "prior_art_anchor": {"type": "string", "const": "2025-11-07"},
    "sealed":           {"type": "string", "const": "2026-01-30"},
    "build_version":    {"type": "string", "const": "v34.23"},
    "build_date":       {"type": "string", "format": "date"},
    "generated":        {"type": "string", "format": "date-time"},
    "total_nodes":      {"type": "integer", "const": 372},
    "symmetry":         {"type": "string", "const": "186/186"},
    "uspto_anchor":     {"type": "string", "const": "99745529"},
    "uspto_mark":       {"type": "string", "const": "Symmetrical Grid™ / 186/186 Node Symmetry™"},

    "canonical_figures": {
      "type": "object",
      "required": [
        "annual_domestic_ghost_load_usd",
        "thirty_four_state_enclave_usd",
        "global_symmetrical_usd",
        "combined_annual_27_sectors_usd",
        "medura_math_gap_usd",
        "hyacinth_fund_distributable_usd"
      ],
      "properties": {
        "annual_domestic_ghost_load_usd":  {"type": "integer", "const": 1530000000000},
        "thirty_four_state_enclave_usd":   {"type": "integer", "const": 1340000000000},
        "global_symmetrical_usd":          {"type": "integer", "const": 345000000000000},
        "combined_annual_27_sectors_usd":  {"type": "integer", "const":   5000000000000},
        "medura_math_gap_usd":             {"type": "integer", "const":  84000000000000},
        "hyacinth_fund_distributable_usd": {"type": "integer", "const":  45500000000000}
      },
      "additionalProperties": false
    },

    "signature_lines": {
      "type": "object",
      "required": ["line_70", "line_111", "line_186"],
      "properties": {
        "line_70": {
          "type": "object",
          "properties": {
            "designation": {"type": "string", "const": "TAG 70 — The Origin"},
            "anchor_date": {"type": "string", "const": "2025-11-07"}
          },
          "required": ["designation", "anchor_date"]
        },
        "line_111": {
          "type": "object",
          "properties": {
            "designation": {"type": "string", "const": "The Constitutional Terminus"}
          },
          "required": ["designation"]
        },
        "line_186": {
          "type": "object",
          "properties": {
            "designation": {"type": "string", "const": "The Anchor — Manual Override™"},
            "mechanism":   {"type": "string", "const": "Marlowe Empowerment Trust"}
          },
          "required": ["designation", "mechanism"]
        }
      }
    },

    "appendix_counts": {
      "type": "object",
      "properties": {
        "A_human":                      {"type": "integer", "const": 186},
        "B_institutional":              {"type": "integer", "const": 186},
        "audit_refresh_status_covered": {"type": "integer", "minimum": 180, "maximum": 186},
        "D_global":                     {"type": "integer", "const": 186},
        "total_domestic":               {"type": "integer", "const": 186},
        "total_global":                 {"type": "integer", "const": 186},
        "total_372":                    {"type": "integer", "const": 372}
      },
      "required": ["A_human", "B_institutional", "audit_refresh_status_covered",
                    "D_global", "total_domestic", "total_global", "total_372"]
    },

    "global_groups": {
      "type": "array",
      "minItems": 8,
      "maxItems": 8,
      "items": {
        "type": "object",
        "required": ["group", "name", "range", "function", "combined_value"],
        "properties": {
          "group":          {"type": "string"},
          "name":           {"type": "string"},
          "range":          {"type": "string", "pattern": "^\\d+-\\d+$"},
          "function":       {"type": "string"},
          "combined_value": {"type": "string"}
        }
      }
    },

    "source_essays":      {"type": "object"},
    "dual_ordering_note": {"type": "string", "minLength": 50},
    "build_note":         {"type": "array",  "items": {"type": "string"}},
    "canonical_companions": {"type": "object"},
    "copyright_notice":   {"type": "string", "pattern": "L\\.M\\. Marlowe.*Prior Art.*2025.*Sealed.*2026"},

    "nodes": {
      "type": "array",
      "minItems": 372,
      "maxItems": 372,
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/domestic_row" },
          { "$ref": "#/$defs/global_row"   }
        ]
      }
    }
  },
  "$defs": {
    "domestic_row": {
      "type": "object",
      "required": ["id", "side", "line", "sector", "uspto_anchor",
                    "html_page", "appendix_b", "appendix_a", "source_essay"],
      "properties": {
        "id":   {"type": "string", "pattern": "^DOM-\\d{3}$"},
        "side": {"type": "string", "const": "domestic"},
        "line": {"type": "integer", "minimum": 1, "maximum": 186},
        "sector":       {"type": "string"},
        "uspto_anchor": {"type": "string", "const": "99745529"},
        "html_page":    {"type": "string", "pattern": "^nodes/node-\\d{1,3}\\.html$"},

        "appendix_b": {
          "type": ["object", "null"],
          "properties": {
            "institution":    {"type": "string"},
            "executive":      {"type": "string"},
            "systemic_force": {"type": "string"}
          }
        },
        "appendix_a": {
          "type": ["object", "null"],
          "properties": {
            "victim":       {"type": "string"},
            "fallen_angel": {"type": "string"}
          }
        },
        "audit_refresh_node": {
          "type": ["object", "null"],
          "properties": {
            "node_name":              {"type": "string"},
            "status":                 {"type": "string"},
            "federal_anchor":         {"type": "string"},
            "cuts_since_2025_11_07":  {"type": "string"}
          }
        },
        "source_essay":          {"type": "object"},
        "signature_line":        {"type": "boolean"},
        "signature_designation": {"type": "string"},
        "signature_note":        {"type": "string"}
      }
    },
    "global_row": {
      "type": "object",
      "required": ["id", "side", "node_number", "group", "group_name",
                    "group_range", "group_function", "group_description",
                    "group_combined_value", "uspto_anchor", "status",
                    "source_essay"],
      "properties": {
        "id":          {"type": "string", "pattern": "^GLB-\\d{3}$"},
        "side":        {"type": "string", "const": "global"},
        "node_number": {"type": "integer", "minimum": 1, "maximum": 186},
        "group":                 {"type": "string", "enum": ["A","B","C","D","E","F","G-I","J"]},
        "group_name":            {"type": "string"},
        "group_range":           {"type": "string", "pattern": "^\\d+-\\d+$"},
        "group_function":        {"type": "string"},
        "group_description":     {"type": "string"},
        "group_combined_value":  {"type": "string"},
        "uspto_anchor":          {"type": "string", "const": "99745529"},
        "name":                  {"type": ["string", "null"]},
        "category":              {"type": "string"},
        "value_aum":             {"type": "string"},
        "ghost_load_logic":      {"type": "string"},
        "status":                {"type": "string", "enum": ["essay-named", "group-mapped"]},
        "source_essay":          {"type": "string"},
        "signature_line":        {"type": "boolean"},
        "signature_designation": {"type": "string"},
        "signature_note":        {"type": "string"}
      },
      "if":   { "properties": { "status": { "const": "essay-named" } } },
      "then": { "required":   ["name", "category"], "properties": { "name": { "type": "string" } } },
      "else": { "properties": { "name": { "type": "null"   } } }
    }
  }
}
