{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://twinethos.com/schemas/source-v0.3.schema.json",
  "title": "Source Artifact (v0.3)",
  "description": "The canonical, once-only store of a source instrument's text and metadata. Rules and requirements anchor INTO this via source_anchors[]; they never embed text. This is the single source of truth for verbatim provisions, so a provision is stored once and referenced many times rather than duplicated across rules (review #2). Distribution builds may inline permitted excerpts (Tier A/B) from here; Tier C artifacts store structure and citations only, never text.",
  "type": "object",
  "required": [
    "source_artifact_id",
    "schema_version",
    "instrument_slug",
    "instrument_version",
    "source_text_license",
    "source_url",
    "retrieved_at",
    "retrieval_method",
    "document_hash",
    "provisions",
    "coverage"
  ],
  "additionalProperties": false,
  "properties": {
    "source_artifact_id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[._-][a-z0-9]+)*$",
      "description": "Stable id for this exact document version, e.g. 'eu-ai-act.2024-1689'. Anchors reference this."
    },
    "schema_version": {
      "type": "string",
      "const": "0.3"
    },
    "instrument_slug": {
      "type": "string",
      "description": "Registry slug, e.g. 'eu-ai-act'."
    },
    "instrument_version": {
      "type": "string",
      "description": "Version/date of the instrument, e.g. 'Regulation (EU) 2024/1689'."
    },
    "short_name": {
      "type": "string"
    },
    "source_text_license": {
      "type": "string",
      "enum": [
        "A",
        "B",
        "C",
        "S"
      ],
      "description": "A=government edict (text stored + distributable); B=incorporated standard (text stored, distribution flagged); C=sold standard (NO text stored — provisions carry citation/structure only). S = TwinEthos-authored derivation text (our own rationale; freely storable; never an external authority)."
    },
    "authoritative_language": {
      "type": "string",
      "description": "BCP-47 tag of the authoritative language version, e.g. 'en'."
    },
    "document_hash": {
      "type": "string",
      "description": "sha256 of the entire retrieved official document. 'The document was reissued' vs 'a clause changed' is decided here vs per-provision hashes.",
      "pattern": "^[a-f0-9]{64}$"
    },
    "source_url": {
      "type": "string",
      "format": "uri"
    },
    "retrieved_at": {
      "type": "string",
      "format": "date"
    },
    "retrieval_method": {
      "type": "string",
      "description": "How the text was obtained, e.g. 'official HTML', 'official PDF extraction'."
    },
    "public_scope_receipt": {
      "type": "object",
      "description": "Receipt for the public abstract, scope, or catalogue record used to author a Tier C citation-only rule. It must not contain licensed standard text.",
      "additionalProperties": false,
      "required": [
        "url",
        "retrieved_at",
        "content_hash",
        "summary_basis"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "retrieved_at": {
          "type": "string",
          "format": "date"
        },
        "content_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "summary_basis": {
          "type": "string",
          "minLength": 10
        }
      }
    },
    "provisions": {
      "type": "array",
      "minItems": 1,
      "description": "The addressable units (article, section, paragraph, point) rules anchor to. Stored once here. For Tier C, 'text' is omitted and only citation/structure is kept.",
      "items": {
        "type": "object",
        "required": [
          "citation",
          "citation_path",
          "provision_hash",
          "disposition"
        ],
        "additionalProperties": false,
        "properties": {
          "citation": {
            "type": "string",
            "description": "e.g. 'Article 50(1)'."
          },
          "citation_path": {
            "type": "string",
            "description": "Machine path, e.g. 'article-50/paragraph-1'."
          },
          "text": {
            "type": "string",
            "description": "Verbatim provision text. TIER A/B ONLY — omitted for Tier C."
          },
          "start_offset": {
            "type": "integer",
            "minimum": 0,
            "description": "Char offset of this provision within the source document (review #3)."
          },
          "end_offset": {
            "type": "integer",
            "minimum": 0
          },
          "provision_hash": {
            "type": "string",
            "description": "sha256 of the verbatim provision text (Tier A/B) or of the citation+structure descriptor (Tier C). Matches source_anchors[].quoted_text_hash on rules. THE change-detection join.",
            "pattern": "^[a-f0-9]{64}$"
          },
          "language": {
            "type": "string"
          },
          "translation_status": {
            "type": "string",
            "enum": [
              "authoritative",
              "official_translation",
              "unofficial_translation"
            ]
          },
          "disposition": {
            "type": "string",
            "enum": [
              "encoded",
              "out_of_scope",
              "deferred",
              "not_applicable"
            ],
            "description": "Disposition of this reviewed provision for the AI-integration corpus. Coverage is derived from these values."
          },
          "disposition_reason": {
            "type": "string",
            "description": "Why the provision was encoded, excluded, deferred, or found not applicable."
          }
        }
      }
    },
    "coverage": {
      "type": "object",
      "description": "Completeness of the reviewed source inventory. Pack coverage is computed from provision dispositions and these inventory facts.",
      "additionalProperties": false,
      "required": [
        "inventory_status",
        "scope_statement"
      ],
      "properties": {
        "inventory_status": {
          "type": "string",
          "enum": [
            "partial",
            "complete_for_scope"
          ],
          "description": "Whether every in-scope provision in the instrument has been inventoried and dispositioned."
        },
        "scope_statement": {
          "type": "string",
          "minLength": 10
        }
      }
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "captured_by": {
          "type": "string"
        },
        "captured_date": {
          "type": "string",
          "format": "date"
        },
        "notes": {
          "type": "string"
        }
      }
    }
  },
  "allOf": [
    {
      "$comment": "Tier C artifacts must not store provision text.",
      "if": {
        "properties": {
          "source_text_license": {
            "const": "C"
          }
        },
        "required": [
          "source_text_license"
        ]
      },
      "then": {
        "required": [
          "public_scope_receipt"
        ],
        "properties": {
          "provisions": {
            "type": "array",
            "items": {
              "not": {
                "required": [
                  "text"
                ]
              }
            }
          }
        }
      }
    }
  ]
}
