Skip to content

feat(learning): HistoricalLogIndex — inverted index over session transcripts #124

Description

@xinhuagu

Roadmap Position: Step 5 of 6 — historical-learning strengthening layer
Depends on: core operating loop from #196, #128, #134, #131 being in place
Enables: #125, #126, richer historical queries, and stronger validation inputs

Parent Epic: #116

Problem

TranscriptStore has save/load per session but no query capability. Cannot answer "how many bash timeouts in last 30 days?" or "which sessions had PATH_NOT_FOUND errors?"

Solution

HistoricalLogIndex (aceclaw-memory)

public final class HistoricalLogIndex {
    void index(String sessionId, List<ConversationMessage> messages);
    
    // Query APIs
    List<ToolInvocationEntry> queryByTool(String toolName, Instant from, Instant to);
    List<ErrorEntry> queryByErrorClass(ErrorClass errorClass, Instant from, Instant to);
    Map<String, Integer> toolInvocationCounts(Instant from, Instant to);
    Map<ErrorClass, Integer> errorCounts(Instant from, Instant to);
}

Index Structure (JSONL files)

~/.aceclaw/index/
  tool_invocations.jsonl   # {sessionId, tool, timestamp, success, durationMs}
  errors.jsonl             # {sessionId, tool, errorClass, message, resolution}
  patterns.jsonl           # {sessionId, patternType, confidence, description}

Integration

  • Built incrementally: SessionAnalyzer calls index.index() after analysis
  • Periodic rebuild from TranscriptStore as fallback
  • TTL: 90 days, older entries archived

Acceptance Criteria

  • Index builds incrementally on session close
  • Query by tool name, error class, date range
  • Aggregate counts (tool usage, error frequency) queryable
  • Index files use append-only JSONL for crash safety

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew 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