COMPACT
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>"]
}
}
| Field | Required | Description |
|---|---|---|
strategy | ✓ | How to handle matching memory units. |
filter.max_age_epochs | Only affect units older than this epoch count. | |
filter.session_id | Only affect units from a specific session. | |
filter.types | Only affect units of these memory types. | |
filter.status | Only affect units with these status values. |
Strategies
| Strategy | Description | Required Level |
|---|---|---|
archive | Move matching units to cold storage. Excluded from ATTUNE results unless explicitly requested. | 2+ |
summarize | Create synthesis memory units from matching originals, then archive the originals. | 2+ |
purge | Permanently delete matching units from the active store. Event log retains a tombstone. | 3 |
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
| Code | Condition | Recoverable |
|---|---|---|
STORAGE_FULL | Persistence store at capacity (cannot complete summarize writes) | No — run archive/purge first or expand storage |
AGENT_NOT_REGISTERED | agent_id is not a registered active agent | Yes — call REGISTER first |
UNSUPPORTED_OPERATION | This conformance level does not support COMPACT | No |