{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://deft.dev/schemas/swarm-spec-pack-0.1.schema.json",
  "title": "Swarm Spec Pack 0.1",
  "description": "Canonical source schema for the swarm-spec-pack-0.1 tier-3 extension pack (#1637, candidate from the #1283 Q-list, design #1283, ADR-001, generalizing the #1294 lessons pilot + #1295 skills pack + #1296 rules/strategies packs). The structured JSON at packs/swarm-spec/swarm-spec-pack-0.1.json is the SOURCE OF TRUTH for swarm-specification ROUTING METADATA: for every swarm/*.md it records id (the doc stem), title (the leading `# ` heading), description (the leading description paragraph), triggers (the doc stem as an invocation keyword, used by the `by-trigger` slice), and the path. The swarm spec is a single canonical document today, so its one entry is the designated proof and carries its full body, regenerated as a banner-marked, drift-checked projection (scripts/pack_render.py). The `x-sliceRegistry` block is the schema-declared, agent-facing slice API (mirrors lessons + skills + strategies + patterns): a named-slice registry mapping slice name -> { path (a constrained dotted path into the source -- NOT JSONPath), filters[] (the fixed trigger vocabulary), description }. Agents query by slice NAME only. The `x-display` block declares how scripts/packs_slice.py renders an entry as text (heading field, labelled metadata fields, optional body field, and the empty-result noun) so the slice formatter stays pack-agnostic.",
  "type": "object",
  "additionalProperties": false,
  "required": ["pack", "version", "entries"],
  "properties": {
    "pack": {
      "const": "swarm-spec-pack-0.1",
      "description": "Versioned pack identifier. The version lives in the name per #1283 Q6 (pack version is part of the pack name)."
    },
    "version": {
      "const": "0.1",
      "description": "Pack major.minor, mirrored from the pack name suffix."
    },
    "generated_from": {
      "type": "string",
      "description": "Provenance: the sources the one-shot migration (scripts/pack_migrate_swarm_spec.py) parsed to build this pack (swarm/*.md)."
    },
    "entries": {
      "type": "array",
      "description": "One entry per discovered swarm-spec doc (swarm/*.md). Order is the sorted path order.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "description", "triggers", "path", "body"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[a-z0-9][a-z0-9-]*$",
            "description": "Entry id: the slugified doc stem (e.g. swarm)."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "description": "The doc's leading `# ` heading text, stored verbatim."
          },
          "description": {
            "type": "string",
            "description": "The leading description paragraph after the title (Legend / See-also / chrome lines skipped), folded to a single normalised string. Empty when the doc has no leading paragraph."
          },
          "triggers": {
            "type": "array",
            "description": "Invocation keywords for this entry (the doc stem). Empty when the entry has no derivable trigger. The `by-trigger` slice filters on this field.",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "path": {
            "type": "string",
            "pattern": "^swarm/.+\\.md$",
            "description": "Repo-relative path to the swarm-spec markdown."
          },
          "body": {
            "type": ["string", "null"],
            "description": "Full doc body (banner-stripped, verbatim) for entries whose markdown is regenerated as a banner-marked, drift-checked projection; null for metadata-only entries. The single swarm spec doc is the proof and carries its body."
          }
        }
      }
    }
  },
  "x-display": {
    "heading": "id",
    "fields": ["title", "description", "triggers", "path"],
    "body": null,
    "noun": "swarm-spec entries"
  },
  "x-sliceRegistry": {
    "by-trigger": {
      "path": "entries",
      "filters": ["trigger"],
      "description": "Swarm-spec entries whose invocation keywords include any of the requested --trigger values (case-insensitive, repeatable or comma-listed)."
    },
    "list": {
      "path": "entries",
      "filters": [],
      "description": "Every swarm-spec entry with its title, description, triggers, and path."
    }
  }
}
