{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.xyntherium.com/schemas/dependency-link.v0.json",
  "$comment": "MIT License, this schema file only. Copyright (c) 2026 AugustBrooks LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this schema file, to deal in it without restriction, subject to including this notice. THE SCHEMA IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND.",
  "title": "Xyntherium dependency link, v0",
  "description": "A saved answer's dependency on one fact in one version of a source document. A link with status \"confirmed\" was confirmed by code: the answer and the source state the same normalized fact (an amount, a duration and where it starts, a date, a percent, a count, a condition) about the same thing, or the source defines a term the answer uses. A model's suggestion that code could not confirm is kept with status \"unconfirmed\" and never raises an alert.",
  "type": "object",
  "required": ["schema", "answer_id", "source_id", "version_id", "fact_key", "link_type", "method", "status", "span", "answer_span", "checked_at"],
  "additionalProperties": false,
  "properties": {
    "schema": { "const": "dependency-link.v0" },
    "answer_id": { "type": "string", "minLength": 1, "description": "The saved answer that depends on the fact." },
    "source_id": { "type": "string", "minLength": 1, "description": "The source document." },
    "version_id": { "type": ["string", "null"], "description": "The source version the fact was read from; null when not recorded." },
    "fact_key": { "type": "string", "minLength": 1, "description": "The normalized fact, e.g. \"duration:s:2592000\" (30 days) or \"term:business day\"; \"suggested\" for an unconfirmed suggestion." },
    "link_type": { "enum": ["numeric", "duration_anchor", "defined_term", "condition", "entity", "approved"] },
    "method": { "enum": ["normalized_fact", "defined_term", "approved", "model_suggested"] },
    "status": { "enum": ["confirmed", "unconfirmed"] },
    "span": {
      "description": "Where the fact is in the source version, with a SHA-256 of the exact text; null for an unconfirmed suggestion.",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "required": ["start", "end", "sha256"],
          "additionalProperties": false,
          "properties": {
            "start": { "type": "integer", "minimum": 0 },
            "end": { "type": "integer", "minimum": 0 },
            "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
          }
        }
      ]
    },
    "answer_span": {
      "description": "Where the fact is in the answer; null when it is in the question, or not recorded.",
      "oneOf": [
        { "type": "null" },
        { "type": "object", "required": ["start", "end"], "additionalProperties": false, "properties": { "start": { "type": "integer", "minimum": 0 }, "end": { "type": "integer", "minimum": 0 } } }
      ]
    },
    "checked_at": { "type": "string", "format": "date-time" }
  }
}
