{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://local.llm.platform/schemas/1c-moxel-schema-registry.schema.json",
  "title": "1C MOXCEL Schema Registry",
  "type": "object",
  "required": ["schema", "generated_at", "sources", "policy", "rules", "counts"],
  "properties": {
    "schema": {
      "type": "string",
      "const": "codex_1c_moxel_schema_registry.v1"
    },
    "generated_at": {
      "type": "string"
    },
    "sources": {
      "type": "array",
      "items": { "type": "string" }
    },
    "policy": {
      "type": "object",
      "required": ["read_use", "write_use"],
      "properties": {
        "read_use": { "type": "string" },
        "write_use": { "type": "string" }
      },
      "additionalProperties": true
    },
    "rules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "target", "confidence", "read_status", "write_status", "evidence", "source_rule"],
        "properties": {
          "id": { "type": "string" },
          "target": { "type": "string" },
          "expression": { "type": ["string", "null"] },
          "raw_scalar_indexes": {
            "type": ["array", "null"],
            "items": { "type": "integer" }
          },
          "confidence": {
            "type": "string",
            "enum": ["none", "low", "medium", "high"]
          },
          "read_status": {
            "type": "string",
            "enum": ["verified_read", "candidate_read", "needs_more_evidence"]
          },
          "write_status": {
            "type": "string",
            "enum": ["blocked_until_roundtrip", "blocked_until_verified_read", "verified_roundtrip"]
          },
          "evidence": {
            "type": "object",
            "additionalProperties": true
          },
          "source_rule": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    },
    "counts": {
      "type": "object",
      "required": ["rules", "verified_read", "candidate_read", "write_enabled"],
      "properties": {
        "rules": { "type": "integer", "minimum": 0 },
        "verified_read": { "type": "integer", "minimum": 0 },
        "candidate_read": { "type": "integer", "minimum": 0 },
        "write_enabled": { "type": "integer", "minimum": 0 }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
