Lifecycle Policies
Lifecycle policies automate data management by defining rules for retention, archival, deletion, and freezing of memories within namespaces.
Policy Types
| Type | Description |
|---|---|
retention | Delete memories older than a specified age |
archive | Move old memories to cold storage |
delete | Permanently remove memories matching conditions |
freeze | Prevent modifications to memories matching conditions |
Creating a Lifecycle Policy
curl -X POST https://api.hippocortex.dev/v1/organizations/org_abc123/lifecycle-policies \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "X-Organization-ID: org_abc123" \
-H "Content-Type: application/json" \
-d '{
"name": "90-day retention",
"namespaceId": "ns_456",
"policyType": "retention",
"conditions": {
"olderThanDays": 90,
"memoryType": "event"
},
"actionConfig": {
"action": "delete",
"notifyBefore": true,
"notifyDays": 7
},
"isActive": true
}'
Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | string | required | Human-readable name |
namespaceId | string | null | Target namespace (null = org-wide) |
policyType | string | required | retention, archive, delete, freeze |
conditions | object | {} | When to trigger (age, type, tags, etc.) |
actionConfig | object | {} | What to do when triggered |
isActive | boolean | true | Whether the policy is active |
Configuration Examples
90-day event retention
{
"name": "90-day event cleanup",
"policyType": "retention",
"conditions": { "olderThanDays": 90, "memoryType": "event" },
"actionConfig": { "action": "delete" }
}
Archive old artifacts
{
"name": "Archive artifacts after 1 year",
"policyType": "archive",
"namespaceId": "ns_production",
"conditions": { "olderThanDays": 365, "memoryType": "artifact" },
"actionConfig": { "action": "archive", "destination": "cold_storage" }
}
Freeze compliance data
{
"name": "Freeze compliance memories",
"policyType": "freeze",
"namespaceId": "ns_compliance",
"conditions": { "tags": ["regulatory", "audit"] },
"actionConfig": { "action": "freeze", "reason": "Regulatory hold" }
}
Delete test data weekly
{
"name": "Purge test namespace",
"policyType": "delete",
"namespaceId": "ns_testing",
"conditions": { "olderThanDays": 7 },
"actionConfig": { "action": "delete" }
}
Listing Lifecycle Policies
curl "https://api.hippocortex.dev/v1/organizations/org_abc123/lifecycle-policies?\
policyType=retention&isActive=true" \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "X-Organization-ID: org_abc123"
Updating a Lifecycle Policy
curl -X PATCH https://api.hippocortex.dev/v1/organizations/org_abc123/lifecycle-policies/lp_123 \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "X-Organization-ID: org_abc123" \
-H "Content-Type: application/json" \
-d '{ "isActive": false }'
Deleting a Lifecycle Policy
curl -X DELETE https://api.hippocortex.dev/v1/organizations/org_abc123/lifecycle-policies/lp_123 \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "X-Organization-ID: org_abc123"
Execution
Lifecycle policies are evaluated by a background scheduler. Each policy tracks when it was last run (last_run_at) and when it should run next. The scheduler picks up active policies that are due and executes their actions.
Currently, lifecycle policies define the rules but execution is not yet automated -- they serve as the configuration layer for a future scheduler worker.