{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scriptgrain-com/json-schema/scriptgrain-com-memory-summary-schema.json",
  "title": "MemorySummary",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scriptgrain-com-openapi.json#/components/schemas/MemorySummary",
  "type": "object",
  "required": [
    "items",
    "units",
    "topics",
    "ideas",
    "stories",
    "claims",
    "frameworks",
    "changes",
    "last_synced",
    "brain"
  ],
  "properties": {
    "items": {
      "type": "integer",
      "description": "Pieces in the brain that are not forgotten (hand-added memories excluded)."
    },
    "units": {
      "type": "integer",
      "description": "Memories counted among the 400 most recent."
    },
    "topics": {
      "type": "array",
      "description": "Up to 40 topics with at least one memory, most memories first.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "unit_count",
          "last_seen"
        ],
        "properties": {
          "id": {
            "$ref": "#/$defs/Uuid"
          },
          "label": {
            "type": "string"
          },
          "unit_count": {
            "type": "integer"
          },
          "last_seen": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "ideas": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MemoryUnit"
      },
      "description": "Up to 12, most repeated first."
    },
    "stories": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MemoryUnit"
      },
      "description": "Up to 8."
    },
    "claims": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MemoryUnit"
      },
      "description": "Up to 10."
    },
    "frameworks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MemoryUnit"
      },
      "description": "Up to 6."
    },
    "changes": {
      "type": "array",
      "description": "Up to 12 claims the author later contradicted or refined.",
      "items": {
        "type": "object",
        "required": [
          "link_id",
          "relation",
          "note",
          "earlier",
          "later"
        ],
        "properties": {
          "link_id": {
            "$ref": "#/$defs/Uuid"
          },
          "relation": {
            "type": "string",
            "enum": [
              "contradicts",
              "refines"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "earlier": {
            "type": "object",
            "required": [
              "text",
              "quote",
              "published_at"
            ],
            "properties": {
              "text": {
                "type": "string"
              },
              "quote": {
                "type": "string"
              },
              "published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "later": {
            "type": "object",
            "required": [
              "text",
              "quote",
              "published_at"
            ],
            "properties": {
              "text": {
                "type": "string"
              },
              "quote": {
                "type": "string"
              },
              "published_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      }
    },
    "last_synced": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "brain": {
      "$ref": "#/$defs/BrainInfo"
    }
  },
  "$defs": {
    "BrainInfo": {
      "type": "object",
      "required": [
        "id",
        "name",
        "voices",
        "shared"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/Uuid"
        },
        "name": {
          "type": "string"
        },
        "voices": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "$ref": "#/$defs/Uuid"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "shared": {
          "type": "boolean",
          "description": "True when more than one voice uses this brain."
        }
      }
    },
    "MemoryUnit": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "text",
        "quote",
        "context",
        "item_id",
        "item_title",
        "item_kind",
        "published_at",
        "times",
        "voice",
        "edited"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/Uuid"
        },
        "kind": {
          "type": "string"
        },
        "text": {
          "type": "string",
          "description": "The memory in one sentence."
        },
        "quote": {
          "type": "string",
          "description": "A verbatim quote from the source piece."
        },
        "context": {
          "type": [
            "string",
            "null"
          ]
        },
        "item_id": {
          "$ref": "#/$defs/Uuid",
          "description": "The source piece."
        },
        "item_title": {
          "type": [
            "string",
            "null"
          ]
        },
        "item_kind": {
          "type": "string",
          "description": "The kind of source piece (for example `generation`, `imported`, `published`)."
        },
        "published_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "times": {
          "type": "integer",
          "description": "How many pieces say the same thing (other pieces linking to it as a repeat, plus one)."
        },
        "voice": {
          "type": [
            "string",
            "null"
          ],
          "description": "Name of the voice that wrote the piece; set only when the brain is shared."
        },
        "edited": {
          "type": "boolean",
          "description": "The user reworded, re-kinded or moved this memory."
        }
      }
    },
    "Uuid": {
      "type": "string",
      "format": "uuid",
      "description": "A UUID. Path ids that are not UUID-shaped never match a route (404 `not_found`)."
    }
  }
}