{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aaas-design.web.app/registry.schema.json",
  "title": "AaaS Design Registry",
  "description": "Machine-readable index of every file under design/. Generated by scripts/build-design-registry.ts. Both humans and AI agents consume this file.",
  "type": "object",
  "required": ["generatedAt", "entries"],
  "properties": {
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp of the most recent generation"
    },
    "generator": {
      "type": "string",
      "description": "Path (relative to repo root) of the script that produced this file"
    },
    "schemaVersion": {
      "type": "string",
      "description": "Semantic version of this schema",
      "default": "1.0.0"
    },
    "entryCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Total number of registered entries"
    },
    "statusCounts": {
      "type": "object",
      "description": "Count of entries per status for quick dashboard roll-up",
      "properties": {
        "live": { "type": "integer", "minimum": 0 },
        "stale": { "type": "integer", "minimum": 0 },
        "deprecated": { "type": "integer", "minimum": 0 },
        "archived": { "type": "integer", "minimum": 0 },
        "broken": { "type": "integer", "minimum": 0 }
      },
      "additionalProperties": false
    },
    "entries": {
      "type": "array",
      "items": { "$ref": "#/$defs/entry" }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "entry": {
      "type": "object",
      "required": ["id", "path", "url", "title", "status", "lastModified"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-/_]*$",
          "description": "Stable slug derived from path (lowercase, slashes allowed for nested pages)"
        },
        "path": {
          "type": "string",
          "description": "Repo-relative path, e.g. design/strategy/verticalisation.html"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Public URL under aaas-design.web.app"
        },
        "title": {
          "type": "string",
          "description": "Extracted from <title> tag; falls back to humanised path if missing"
        },
        "status": {
          "type": "string",
          "enum": ["live", "stale", "deprecated", "archived", "broken"],
          "description": "See AGENTS.md §2 for vocabulary. Default: live; auto-flips to stale after 30 days of no lastVerified update."
        },
        "statusReason": {
          "type": ["string", "null"],
          "description": "Why this status — e.g. 'superseded by X', 'pending render fix'. Populated via registry.overrides.yaml."
        },
        "lastVerified": {
          "type": ["string", "null"],
          "format": "date",
          "description": "Last date an owner confirmed the content is accurate. Drives stale auto-flip."
        },
        "lastModified": {
          "type": "string",
          "format": "date-time",
          "description": "From `git log -1 --format=%cI <path>`. Deterministic."
        },
        "owner": {
          "type": ["string", "null"],
          "description": "Email address of the human responsible for re-verifying this page"
        },
        "markdownSource": {
          "type": ["string", "null"],
          "description": "Repo-relative path to the markdown source that generates this HTML, if any (e.g. docs/audits/ecosystem-context.md)"
        },
        "replacedBy": {
          "type": ["string", "null"],
          "description": "Entry id of the replacement, when status is deprecated/archived"
        },
        "issue": {
          "type": ["string", "null"],
          "format": "uri",
          "description": "Link to the tracking issue when status is broken"
        },
        "tags": {
          "type": "array",
          "items": { "type": "string" },
          "uniqueItems": true,
          "description": "Free-form labels (e.g. 'dashboard', 'brand', 'concept', 'agent-showcase')"
        },
        "checksum": {
          "type": "string",
          "pattern": "^sha256:[a-f0-9]{64}$",
          "description": "sha256 hex of file contents, prefixed with 'sha256:'. Used to detect drift."
        },
        "size": {
          "type": "integer",
          "minimum": 0,
          "description": "File size in bytes"
        }
      },
      "additionalProperties": false
    }
  }
}
