Phase 7 follow-up: 1-month body retention and actions_log cap (AUD-75)

Implements the AGENTS.md §7 data rule: keep message bodies for one month, and
size-cap the append-only action log.

- internal/store/retention.go: Store.Retain clears messages.body_text older
  than the window (metadata stays) and deletes actions_log rows beyond the
  newest N, in one transaction.
- internal/config: EMAIL_AGENT_RETENTION_DAYS (30) and
  EMAIL_AGENT_ACTIONS_LOG_MAX_ROWS (50000).
- cmd/email-agent: bounded -retain flag for the n8n schedule.
- Tests for body clearing, metadata retention, log cap, and disabled policy.
This commit is contained in:
Builder
2026-10-13 10:40:52 +11:00
parent 55a08524b5
commit e5cce1c93a
9 changed files with 380 additions and 5 deletions

View File

@@ -1,7 +1,8 @@
-- Email Agent schema (AGENTS.md §7).
--
-- Every statement is idempotent (CREATE ... IF NOT EXISTS) so this file can be
-- executed on every start. Retention/capping jobs belong to later phases.
-- executed on every start. The retention/capping job (AGENTS.md §7) lives in
-- internal/store/retention.go and runs from the CLI `-retain` flag.
--
-- Attribution: created for the Email Agent Phase 1 skeleton.