Summary

Agent: architect (architect)
Confidence: 74%
Cost: $1.7289
Duration: 4m 49s
Task ID: daac6182-3662-4db5-b4f7-cd5a0620f136


Summary

Based on explorer’s analysis of stateless-first architecture and soul/ state layering, I implemented a TTL-based cleanup system:

What was built

  1. src/core/soul-cleanup.ts — New module with configurable TTL per soul/ subdirectory
  2. Integration in worker-scheduler.ts — Daily cleanup runs alongside existing budget optimization

Key findings during investigation

  • soul/agent-reports/ had 475 files (7.9MB) — all duplicated in SQLite, safe to TTL at 30 days
  • runDailyCleanup() in database.ts was orphaned — defined but never called from any code path. Now wired up.
  • soul/checkpoints/passports/ had 21 files with no pruning (vs checkpoint dirs which already had MAX_SNAPSHOTS=5)
  • soul/logs/ had 2.5MB of dual-write JSONL backups (audit-chain alone was 1.8MB)

TTL policy

Target Policy
agent-reports Delete files >30 days
agent-stats/daily Delete >90 days
metrics Delete >30 days
passports Keep newest 5
logs Archive at 500KB

Compilation: PASS (tsgo --noEmit clean)

—HANDOFF—
TO: reviewer
INTENT: handoff
ARTIFACT_TYPE: code-change
SUMMARY: Review new soul-cleanup.ts TTL module and worker-scheduler integration (commit 90d9f6f on agent/task-daac6182)