Akashik Protocol
Operations

COMPACT

Archive, summarize, or purge aged memory units.

Purpose

COMPACT manages the lifecycle of older memory units. As the Field accumulates knowledge over time, COMPACT allows agents to archive, summarize, or purge units that are no longer actively needed in the hot path — while preserving the event log's integrity.

Conformance Level

Level 2+ — Level 0 and Level 1 implementations MAY omit COMPACT.

Request

{
  "strategy": "summarize | archive | purge",
  "filter": {
    "max_age_epochs": "<number | null>",
    "session_id": "<string | null>",
    "types": ["<MemoryType>"],
    "status": ["<string>"]
  }
}
FieldRequiredDescription
strategyHow to handle matching memory units.
filter.max_age_epochsOnly affect units older than this epoch count.
filter.session_idOnly affect units from a specific session.
filter.typesOnly affect units of these memory types.
filter.statusOnly affect units with these status values.

Strategies

StrategyDescriptionRequired Level
archiveMove matching units to cold storage. Excluded from ATTUNE results unless explicitly requested.2+
summarizeCreate synthesis memory units from matching originals, then archive the originals.2+
purgePermanently delete matching units from the active store. Event log retains a tombstone.3
COMPACT MUST NOT delete entries from the append-only event log, regardless of strategy. For purge, the event log MUST retain a tombstone record containing the unit ID, deletion timestamp, and reason.

Response

{
  "status": "ok",
  "units_affected": "<number>",
  "synthesis_units_created": "<number>",
  "storage_reclaimed_bytes": "<number | null>"
}

Behavioral Requirements

Level 2+ COMPACT MUST NOT delete entries from the append-only event log.

Level 2+ For summarize, the Field MUST create new memory units of type "synthesis" with elaborates relations pointing to the originals, then archive the originals.

Level 2+ For archive, archived units MUST be excluded from ATTUNE results unless the agent explicitly requests archived content in scope.

Level 3 For purge, the event log MUST retain a tombstone record (unit ID, deletion timestamp, reason).

Level 2+ If no units match the filter, the Field MUST return units_affected: 0 and status "ok" — not an error.

Example

Archive all superseded hypothesis units older than 100 epochs:

{
  "protocol": "akashik",
  "version": "0.1.0",
  "id": "msg-080",
  "operation": "COMPACT",
  "agent_id": "maintenance-01",
  "session_id": null,
  "epoch": 200,
  "payload": {
    "strategy": "archive",
    "filter": {
      "max_age_epochs": 100,
      "status": ["superseded"],
      "types": ["assumption", "observation"]
    }
  }
}

Response:

{
  "status": "ok",
  "units_affected": 47,
  "synthesis_units_created": 0,
  "storage_reclaimed_bytes": null
}

Summarize a completed session:

{
  "payload": {
    "strategy": "summarize",
    "filter": {
      "session_id": "session-q1-2026",
      "status": ["active", "superseded"]
    }
  }
}

Response:

{
  "status": "ok",
  "units_affected": 124,
  "synthesis_units_created": 8,
  "storage_reclaimed_bytes": null
}

Error Codes

CodeConditionRecoverable
STORAGE_FULLPersistence store at capacity (cannot complete summarize writes)No — run archive/purge first or expand storage
AGENT_NOT_REGISTEREDagent_id is not a registered active agentYes — call REGISTER first
UNSUPPORTED_OPERATIONThis conformance level does not support COMPACTNo