Skip to content

feat(learning): Consolidation Scheduler — auto-trigger memory maintenance #127

Description

@xinhuagu

Roadmap Position: Step 5 of 6 — historical-learning strengthening layer
Depends on: #123, #124, #125, #126, plus cron infrastructure
Enables: automatic execution of the retrospective learning pipeline

Parent Epic: #138 (Cron Infrastructure)
Related Epic: #116 (Historical Learning — this issue is the bridge)

Problem

MemoryConsolidator exists but only runs when manually called. PRD requires automatic triggers: after every N sessions, when memory exceeds size threshold, and during daemon idle.

Solution

Integration with CronScheduler

Register consolidation jobs during daemon startup:

// In AceClawDaemon.start()
cronScheduler.register(new CronJob(
    "memory-consolidation",
    "*/6h",  // every 6 hours
    () -> {
        memoryConsolidator.consolidate(autoMemoryStore, projectPath, archiveDir);
        sessionAnalyzer.analyzeRecentSessions(transcriptStore, indexer);
        crossSessionMiner.mine(index, memory, 20);
        trendDetector.detect(index, 10);
    }
));

Triggers

  1. Time-based: every 6 hours via CronScheduler
  2. Session-count: after every 10 session closes
  3. Size-based: when any memory JSONL exceeds 50KB
  4. Idle-based: when daemon has no active sessions for 5 minutes

Pipeline Order

  1. MemoryConsolidator (dedup + merge + prune)
  2. SessionAnalyzer (analyze un-analyzed sessions)
  3. HistoricalLogIndex rebuild (if stale)
  4. CrossSessionPatternMiner
  5. TrendDetector
  6. Feed results to AutoMemoryStore + SkillProposalEngine

Dependencies

Acceptance Criteria

  • Consolidation runs automatically on schedule (no manual trigger needed)
  • Session-count trigger works (every 10 sessions)
  • Size-based trigger works (50KB threshold)
  • Full pipeline executes in order on virtual thread

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-harnessLong-running task reliabilityenhancementNew feature or requesthistorical-learningCross-session log analysis and learningp1Priority 1 roadmap item

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions