feat(Phase 4): Memory & Intelligence — memory, log, summarization, skills #91

Merged
jason.woltje merged 7 commits from feat/p4-001-memory-stores into main 2026-03-13 13:56:51 +00:00
Owner

Summary

  • P4-001: @mosaic/memory package — PreferencesRepo (CRUD + upsert) and InsightsRepo (CRUD + pgvector semantic search + relevance decay)
  • P4-002: EmbeddingService using OpenAI-compatible API (text-embedding-3-small), wired into insight creation and POST /api/memory/search
  • P4-003: @mosaic/log package — AgentLogsRepo with structured ingest, flexible query, tiered storage (hot→warm→cold→purge)
  • P4-004: SummarizationService (cheap LLM compresses hot logs into insights) + CronService (node-cron: summarization every 6h, tier management daily)
  • P4-005: Memory tools injected into agent sessions (search, get_preferences, save_preference, save_insight)
  • P4-006: SkillsService + SkillsController at /api/skills (CRUD, toggle enable/disable)
  • P4-007: Full verification — typecheck/lint/format/build/test all green

DB Schema additions

  • — user preference KV store with categories
  • — knowledge store with pgvector embedding column (1536 dims)
  • — structured log storage with tier management
  • — skill catalog with source/config/enabled
  • — job tracking for summarization runs

New API endpoints

  • — CRUD + upsert
  • — CRUD with embedding generation
  • — semantic search via pgvector
  • — ingest + query with filtering
  • — CRUD + toggle

Closes #34, #35, #36, #37, #38, #39, #40

## Summary - **P4-001**: @mosaic/memory package — PreferencesRepo (CRUD + upsert) and InsightsRepo (CRUD + pgvector semantic search + relevance decay) - **P4-002**: EmbeddingService using OpenAI-compatible API (text-embedding-3-small), wired into insight creation and POST /api/memory/search - **P4-003**: @mosaic/log package — AgentLogsRepo with structured ingest, flexible query, tiered storage (hot→warm→cold→purge) - **P4-004**: SummarizationService (cheap LLM compresses hot logs into insights) + CronService (node-cron: summarization every 6h, tier management daily) - **P4-005**: Memory tools injected into agent sessions (search, get_preferences, save_preference, save_insight) - **P4-006**: SkillsService + SkillsController at /api/skills (CRUD, toggle enable/disable) - **P4-007**: Full verification — typecheck/lint/format/build/test all green ### DB Schema additions - — user preference KV store with categories - — knowledge store with pgvector embedding column (1536 dims) - — structured log storage with tier management - — skill catalog with source/config/enabled - — job tracking for summarization runs ### New API endpoints - — CRUD + upsert - — CRUD with embedding generation - — semantic search via pgvector - — ingest + query with filtering - — CRUD + toggle Closes #34, #35, #36, #37, #38, #39, #40
jason.woltje added 7 commits 2026-03-13 13:56:41 +00:00
Add memory tables to DB schema (preferences, insights with pgvector
embedding column, agent_logs, skills, summarization_jobs). Implement
PreferencesRepo (CRUD + upsert) and InsightsRepo (CRUD + semantic
search + relevance decay). Define VectorStore and EmbeddingProvider
interfaces for future provider abstraction. Wire MemoryModule into
gateway with REST endpoints at /api/memory/*.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add EmbeddingService using OpenAI-compatible embeddings API (supports
text-embedding-3-small, configurable via EMBEDDING_MODEL and
EMBEDDING_API_URL env vars). Wire embedding generation into insight
creation and semantic search endpoint. POST /api/memory/search now
generates a query embedding and performs cosine distance search via
pgvector when OPENAI_API_KEY is configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement AgentLogsRepo with structured log ingest (single + batch),
flexible query builder (filter by session, level, category, tier,
date range), and tiered storage management (hot→warm→cold→purge).
Add getLogsForSummarization() for the summarization pipeline.
Wire LogModule into gateway with REST endpoints at /api/logs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add SummarizationService that reads hot agent logs (>24h), groups by
session, calls a cheap LLM (gpt-4o-mini default, configurable via
SUMMARIZATION_MODEL) to extract key insights, stores them with
embeddings in the insights table, and transitions processed logs to
warm tier. Add CronService with node-cron for scheduled execution
(summarization every 6h, tier management daily at 3am). Tier
management promotes warm→cold (30d) and purges cold logs (90d).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add memory tools (search, get_preferences, save_preference,
save_insight) to agent sessions via Pi SDK custom tools. Agent
sessions now have access to semantic memory search, preference
storage, and insight capture. EmbeddingService injected into
AgentService for embedding generation during tool execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add SkillsService with CRUD operations against the skills table,
toggle enable/disable, and findByName lookup. Wire SkillsController
with REST endpoints at /api/skills (list, get, create, update,
toggle, delete). Skills support builtin/community/custom sources
with JSON config storage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All baseline gates pass (typecheck 18/18, lint 18/18, format clean),
build succeeds across all packages, 10 tests pass. Phase 4 complete.
Memory + log + skills system fully implemented.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jason.woltje merged commit 9eb48e1d9b into main 2026-03-13 13:56:51 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#91