{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/office-memory.schema.json",
  "title": "Institutional memory",
  "description": "What GET /v1/memory returns and `office-memory.mjs --json` prints: per repository, the code graph's age and size and how many learnings, past review findings and session notes the learning loop holds, with the newest learnings redacted and cut short. An empty shelf is reported, never left out.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "generatedAt", "shelves"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "x-sensitivity": "none"
    },
    "shelves": {
      "type": "array",
      "maxItems": 60,
      "x-sensitivity": "local",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "repo",
          "graph",
          "learnings",
          "findings",
          "sessionNotes",
          "recent",
          "lastWrite"
        ],
        "properties": {
          "repo": {
            "type": "string"
          },
          "graph": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["builtAt", "ageDays", "sizeKb"],
                "properties": {
                  "builtAt": {
                    "type": ["string", "null"]
                  },
                  "ageDays": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "sizeKb": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            ]
          },
          "learnings": {
            "type": "integer",
            "minimum": 0
          },
          "findings": {
            "type": "integer",
            "minimum": 0
          },
          "sessionNotes": {
            "type": "integer",
            "minimum": 0
          },
          "recent": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["kind", "statement", "at"],
              "properties": {
                "kind": {
                  "type": ["string", "null"]
                },
                "statement": {
                  "type": "string",
                  "maxLength": 120
                },
                "at": {
                  "type": ["string", "null"]
                }
              }
            }
          },
          "lastWrite": {
            "type": ["string", "null"]
          }
        }
      }
    }
  }
}
