{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "5002.catalog/0.2",
  "title": "Organism 5002 catalog for agents",
  "description": "One record per offer or media property, and a list of the organism's published work. Offers carry the full set of fields an agent needs to judge fit. English first; the same ids and keys translated under \"es\".",
  "type": "object",
  "required": ["schema", "organism", "lang", "updated_at", "records"],
  "properties": {
    "schema": { "const": "5002.catalog/0.2" },
    "organism": { "type": "string" },
    "lang": { "const": "en" },
    "updated_at": { "type": "string", "format": "date" },
    "records": { "type": "array", "items": { "$ref": "#/$defs/record" } },
    "work": { "type": "array", "items": { "$ref": "#/$defs/work" } }
  },
  "$defs": {
    "status": { "enum": ["active", "pilot", "exploration", "design", "planned", "paused"] },
    "strings": { "type": "array", "items": { "type": "string" } },
    "pricing": {
      "type": "object",
      "required": ["model", "published"],
      "properties": {
        "model": { "type": "string" },
        "published": { "type": "boolean", "description": "false while no price has been approved for publication" },
        "note": { "type": "string" }
      }
    },
    "record": {
      "type": "object",
      "required": ["id", "kind", "version", "status", "pricing", "evidence", "updated_at", "next_actions"],
      "properties": {
        "id": { "type": "string", "pattern": "^(offer|media)\\.[a-z0-9-]+$" },
        "kind": { "enum": ["offer", "media-property"] },
        "version": { "type": "string" },
        "status": { "$ref": "#/$defs/status" },
        "pricing": { "$ref": "#/$defs/pricing" },
        "evidence": { "type": "array", "items": { "type": "string", "pattern": "^work\\.[a-z0-9-]+$" }, "description": "ids of the published work that shows this record, in the work list" },
        "updated_at": { "type": "string", "format": "date" },
        "next_actions": { "$ref": "#/$defs/strings" },
        "es": { "type": "object" }
      },
      "if": { "properties": { "kind": { "const": "offer" } } },
      "then": {
        "required": ["name", "summary", "problem", "fit", "not_fit", "inputs", "outputs", "acceptance", "dependencies", "es"],
        "properties": {
          "inputs": { "$ref": "#/$defs/strings" },
          "outputs": { "$ref": "#/$defs/strings" },
          "dependencies": { "$ref": "#/$defs/strings" }
        }
      },
      "else": { "required": ["label"] }
    },
    "work": {
      "type": "object",
      "description": "A piece of the organism's own work, not a client's. path is relative to the site root; url is an external page.",
      "required": ["id", "record", "name", "kind", "summary", "figure", "as_of", "es"],
      "properties": {
        "id": { "type": "string", "pattern": "^work\\.[a-z0-9-]+$" },
        "record": { "type": "string", "pattern": "^(offer|media)\\.[a-z0-9-]+$" },
        "name": { "type": "string" },
        "kind": { "type": "string" },
        "summary": { "type": "string" },
        "figure": { "type": "string" },
        "as_of": { "type": "string", "format": "date" },
        "path": { "type": "string", "pattern": "^work/[a-z0-9-]+/" },
        "url": { "type": "string", "pattern": "^https://" },
        "link_label": { "type": "string" },
        "es": { "type": "object", "required": ["kind", "summary", "figure"] }
      }
    }
  }
}
