Skip to content

Commit 8c7487f

Browse files
docs: update specs and changelog for v2026.3.70 (T134 Brain Memory Automation)
- CLEO-API.md: Section 15.10 — new CLI commands, config section, contract types, internal exports, @xenova/transformers dependency - CORE-PACKAGE-SPEC.md: Updated memory module description, config types, runtime dependencies, new Section 15.9 for T134 - CLEOOS-VISION.md: Updated Brain Intelligence section with shipped features (vector similarity, summarization, bridge automation, maintenance, transcript) - CHANGELOG.md: v2026.3.70 entry with all 12 T134 tasks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 08e1154 commit 8c7487f

4 files changed

Lines changed: 162 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
## [Unreleased]
44

5+
## [2026.3.70] — 2026-03-23
6+
7+
### Added
8+
- **Brain Memory Automation** (T134 epic, 12 tasks):
9+
- `BrainConfig` typed configuration section with defaults and templates (T135)
10+
- Local embedding provider via `@xenova/transformers` all-MiniLM-L6-v2, dynamic import (T136)
11+
- Embedding worker thread + async queue for non-blocking processing (T137)
12+
- Memory bridge refresh wired to lifecycle hooks with 30s debounce (T138)
13+
- Context-aware memory bridge generation using `hybridSearch()` + token budget (T139)
14+
- Session summarization: dual-mode prompt + structured `SessionSummaryInput` response (T140)
15+
- Auto-link observations to focused task via `brain_memory_links` (T141)
16+
- Embedding backfill with progress reporting: `cleo backfill --embeddings` (T142)
17+
- Brain maintenance command: `cleo brain maintenance` with `--skip-decay`, `--skip-consolidation`, `--skip-embeddings` (T143)
18+
- Cross-provider transcript hook on `AdapterHookProvider` + Claude Code adapter implementation (T144)
19+
- Updated CLEO-INJECTION.md templates with Memory Automation section (T145)
20+
- Updated CLEO-BRAIN-SPECIFICATION.md to v2.0.0 (T146)
21+
22+
### Dependencies
23+
- Added `@xenova/transformers` ^2.17.2 to `@cleocode/core` (external, dynamic import)
24+
525
## [2026.3.69] - 2026-03-23
626

727
### Fixed

docs/concepts/CLEOOS-VISION.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ The BRAIN system in `@cleocode/core` stores observations, patterns, learnings, a
147147

148148
- **Three-layer retrieval** (shipped): search/timeline/fetch with ~10x token savings over traditional RAG
149149
- **FTS5 full-text search** (shipped): keyword search across all brain tables
150-
- **Vector similarity** (in progress): SQLite-vec integration for semantic retrieval
150+
- **Vector similarity** (shipped): Local embedding via `@xenova/transformers` all-MiniLM-L6-v2 — dynamic import, zero overhead when disabled (T136)
151+
- **Session summarization** (shipped): Dual-mode prompt + structured `SessionSummaryInput` ingestion on `session.end` (T140)
152+
- **Memory bridge automation** (shipped): Hook-driven refresh on `session.end` and `tasks.complete` with 30-second debounce; context-aware generation via `hybridSearch()` within configurable token budget (T138, T139)
153+
- **Brain maintenance** (shipped): `cleo brain maintenance` combines temporal decay + consolidation + embedding backfill into a single governed command (T143)
154+
- **Cross-provider transcript extraction** (shipped): Optional `getTranscript()` on `AdapterHookProvider`; Claude Code adapter implementation auto-extracts observation candidates from session transcripts (T144)
151155
- **Knowledge graph** (planned): relationship-based discovery (updates/extends/derives) with temporal reasoning
152156
- **Active circulation** (planned): Living BRAIN reinforces useful memories, detects contradictions, and surfaces relevant context proactively
153157

@@ -240,6 +244,7 @@ The kernel is shipped and operational:
240244
- Task work on facade: `tasks.start/stop/current` — no direct barrel imports needed (T126)
241245
- Bootstrap injection chain: legacy template sync, CAAMP sanitization, post-bootstrap health check (T124)
242246
- Migration resilience: journal reconciliation and `ensureRequiredColumns()` safety net (v2026.3.61)
247+
- Brain Memory Automation (T134 epic, v2026.3.70): `BrainConfig` typed section, local embedding via `@xenova/transformers` all-MiniLM-L6-v2, async embedding queue, lifecycle-driven bridge refresh with debounce, context-aware bridge generation, session summarization (dual-mode), auto-link observations to focused task, embedding backfill CLI (`cleo backfill --embeddings`), brain maintenance command (`cleo brain maintenance`), cross-provider transcript extraction via adapter hook, updated injection templates and CLEO-BRAIN-SPECIFICATION.md v2.0.0
243248

244249
### What Is Specified (Runtime, Conduit)
245250

docs/specs/CLEO-API.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,69 @@ Sixteen GitHub issues (#63–#78) resolved across five point releases. Key fixes
557557
- `paginate()` null guard (v2026.3.64)
558558
- `detect-drift` user project detection (v2026.3.65)
559559

560+
### 15.10 T134 — Brain Memory Automation (v2026.3.70)
561+
562+
The T134 epic (12 tasks, T135–T146) delivers the first full automation layer for BRAIN memory: local embeddings, lifecycle-driven bridge refresh, session summarization, cross-provider transcript extraction, and a combined maintenance command.
563+
564+
#### New CLI Commands (T134)
565+
566+
| Command | Purpose |
567+
|---------|---------|
568+
| `cleo brain maintenance` | Combined brain maintenance: temporal decay + consolidation + embedding backfill (T143) |
569+
| `cleo brain maintenance --skip-decay` | Skip temporal decay step |
570+
| `cleo brain maintenance --skip-consolidation` | Skip memory consolidation step |
571+
| `cleo brain maintenance --skip-embeddings` | Skip embedding backfill step |
572+
| `cleo backfill --embeddings` | Retroactive embedding backfill with progress reporting (T142) |
573+
574+
#### New Config Section (T135)
575+
576+
The `brain` section is now a first-class typed config block in `CleoConfig`:
577+
578+
| Key | Type | Default | Purpose |
579+
|-----|------|---------|---------|
580+
| `brain.autoCapture` | `boolean` | `true` | Auto-capture observations on lifecycle events |
581+
| `brain.embedding.enabled` | `boolean` | `false` | Enable local embedding provider |
582+
| `brain.embedding.provider` | `'local' \| 'openai' \| 'custom'` | `'local'` | Embedding provider selection |
583+
| `brain.memoryBridge.autoRefresh` | `boolean` | `true` | Auto-refresh bridge on session/task lifecycle events |
584+
| `brain.memoryBridge.contextAware` | `boolean` | `false` | Use `hybridSearch()` for context-aware bridge content |
585+
| `brain.memoryBridge.maxTokens` | `number` | `2000` | Token budget for bridge content |
586+
| `brain.summarization.enabled` | `boolean` | `false` | Enable session summarization on `session.end` |
587+
588+
#### New Contract Types (T134)
589+
590+
| Type | Purpose |
591+
|------|---------|
592+
| `BrainConfig` | Top-level brain config section in `CleoConfig` |
593+
| `BrainEmbeddingConfig` | `brain.embedding.*` sub-interface |
594+
| `BrainMemoryBridgeConfig` | `brain.memoryBridge.*` sub-interface |
595+
| `BrainSummarizationConfig` | `brain.summarization.*` sub-interface |
596+
| `SessionSummaryInput` | Structured session summary type for ingestion |
597+
598+
**Updated interfaces:**
599+
600+
- `AdapterHookProvider` gains an optional `getTranscript()` method for cross-provider transcript extraction (T144)
601+
- `SessionEndResult` gains `memoryPrompt?: string` for dual-mode summarization
602+
- `SessionEndParams` gains `sessionSummary?: SessionSummaryInput` for structured summary ingestion
603+
604+
#### New Internal Exports (T134)
605+
606+
| Export | Source | Purpose |
607+
|--------|--------|---------|
608+
| `initDefaultProvider` | `memory/brain-embedding.ts` | Initialize local all-MiniLM-L6-v2 embedding provider (T136) |
609+
| `generateContextAwareContent` | `memory/memory-bridge.ts` | Scope-aware bridge generation using `hybridSearch()` (T139) |
610+
| `buildSummarizationPrompt` | `memory/session-memory.ts` | Build agent summarization prompt for dual-mode output (T140) |
611+
| `ingestStructuredSummary` | `memory/session-memory.ts` | Auto-ingest structured `SessionSummaryInput` to brain.db (T140) |
612+
| `extractFromTranscript` | `memory/auto-extract.ts` | Extract observations from provider transcript via hook (T144) |
613+
| `runBrainMaintenance` | `memory/brain-maintenance.ts` | Combined maintenance: decay + consolidation + embedding backfill (T143) |
614+
| `LocalEmbeddingProvider` | `memory/embedding-local.ts` | all-MiniLM-L6-v2 ONNX embedding via `@xenova/transformers` (T136) |
615+
| `EmbeddingQueue` | `memory/embedding-queue.ts` | Async embedding queue for non-blocking background processing (T137) |
616+
617+
#### New Dependency (T136)
618+
619+
| Package | Version | Load Strategy |
620+
|---------|---------|---------------|
621+
| `@xenova/transformers` | `^2.17.2` | Dynamic import — only loads when `brain.embedding.enabled: true` |
622+
560623
---
561624

562625
## 9. Document Hierarchy

docs/specs/CORE-PACKAGE-SPEC.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ The public barrel (`packages/core/src/index.ts`) re-exports all public modules a
161161
| `issue` | `packages/core/src/issue/` | Issue and bug tracking | Yes |
162162
| `lib` | `packages/core/src/lib/` | General-purpose utilities: `withRetry` (exponential backoff), `computeDelay`. No database coupling. | No |
163163
| `lifecycle` | `packages/core/src/lifecycle/` | RCASD-IVTR+C gate enforcement, stage transitions | Yes (SQLite lifecycle tables) |
164-
| `memory` | `packages/core/src/memory/` | Brain.db observations, search, 3-layer retrieval | No (uses brain.db directly) |
164+
| `memory` | `packages/core/src/memory/` | Brain.db observations, search, 3-layer retrieval, **local embedding provider, async embedding queue, context-aware bridge, session summarization, brain maintenance** | No (uses brain.db directly) |
165165
| `metrics` | `packages/core/src/metrics/` | Telemetry, value tracking, provider detection | No |
166166
| `migration` | `packages/core/src/migration/` | Schema version detection and migration execution | Yes (SQLite) |
167167
| `nexus` | `packages/core/src/nexus/` | Cross-project registry operations (nexus.db) | No (uses nexus.db) |
@@ -405,7 +405,7 @@ The public barrel re-exports all types from `@cleocode/contracts` via `export *
405405
| LAFS types | `LafsSuccess`, `LafsError`, `LafsEnvelope`, `LAFSMeta`, `LAFSPage`, `Warning`, `MVILevel`, `GatewayEnvelope` |
406406
| DataAccessor | `DataAccessor`, `TaskQueryFilters`, `QueryTasksResult`, `TaskFieldUpdates`, `TransactionAccessor` |
407407
| Exit codes | `ExitCode`, `isErrorCode`, `isSuccessCode`, `getExitCodeName` |
408-
| Config types | `CleoConfig`, `HierarchyConfig`, `SessionConfig`, `LifecycleConfig`, `BackupConfig`. Note: `enforcement.*` and `verification.*` sections are live at runtime but not yet declared in `CleoConfig` — they are read via untyped dot-path. The T101 config audit reduced the declared schema from ~283 to ~113 fields. |
408+
| Config types | `CleoConfig`, `HierarchyConfig`, `SessionConfig`, `LifecycleConfig`, `BackupConfig`, `BrainConfig`, `BrainEmbeddingConfig`, `BrainMemoryBridgeConfig`, `BrainSummarizationConfig`. Note: `enforcement.*` and `verification.*` sections are live at runtime but not yet declared in `CleoConfig` — they are read via untyped dot-path. The T101 config audit reduced the declared schema from ~283 to ~113 fields. The T135 task added the `brain` section as a fully typed block in `CleoConfig` with four sub-interfaces. |
409409
| Status registry | `TASK_STATUSES`, `SESSION_STATUSES`, `STATUS_REGISTRY`, `isValidStatus` |
410410
| Adapter types | `CLEOProviderAdapter`, `AdapterManifest`, `DetectionPattern`, `AdapterCapabilities` |
411411
| WarpChain types | `WarpChain`, `WarpChainInstance`, `WarpStage`, `ChainShape`, `GateContract` |
@@ -566,6 +566,7 @@ The following are internal implementation details, not part of the public contra
566566
| `write-file-atomic` | `^6.0.0` | Atomic file write operations |
567567
| `yaml` | `^2.8.2` | YAML parsing and serialization |
568568
| `zod` | `^3.25.76` | Runtime validation schemas (used via drizzle-orm Zod integration) |
569+
| `@xenova/transformers` | `^2.17.2` | Local ONNX embedding (all-MiniLM-L6-v2), dynamic importonly loads when `brain.embedding.enabled: true` | No |
569570

570571
### 9.2 Dev Dependencies
571572

@@ -874,6 +875,76 @@ Sixteen GitHub issues (#63–#78) resolved across five point releases:
874875
| `paginate()` null guard | v2026.3.64 | Handles undefined/null input arrays |
875876
| `detect-drift` user projects | v2026.3.65 | Distinguishes CLEO source repo from user projects |
876877
878+
### 15.9 New Features in T134 Brain Memory Automation (v2026.3.70)
879+
880+
The T134 epic (12 tasks, T135–T146) delivers the BRAIN memory automation layer: typed config, local embeddings, lifecycle-driven bridge refresh, session summarization, cross-provider transcript extraction, and a combined maintenance command.
881+
882+
#### T135 — BrainConfig Typed Configuration
883+
884+
The `brain` section is now a first-class typed block in `CleoConfig` with four sub-interfaces declared in `@cleocode/contracts`:
885+
886+
| Interface | Purpose |
887+
|-----------|---------|
888+
| `BrainConfig` | Top-level `brain` config section |
889+
| `BrainEmbeddingConfig` | `brain.embedding.*` settings |
890+
| `BrainMemoryBridgeConfig` | `brain.memoryBridge.*` settings |
891+
| `BrainSummarizationConfig` | `brain.summarization.*` settings |
892+
893+
Config templates ship with strict defaults (`autoCapture: true`, `embedding.enabled: false`, `memoryBridge.autoRefresh: true`).
894+
895+
#### T136 — Local Embedding Provider
896+
897+
`LocalEmbeddingProvider` in `memory/embedding-local.ts` provides all-MiniLM-L6-v2 embeddings via `@xenova/transformers`. The dependency is dynamically imported — zero overhead unless `brain.embedding.enabled: true`. Exposed via internal barrel as `initDefaultProvider`.
898+
899+
#### T137 — Async Embedding Queue
900+
901+
`EmbeddingQueue` in `memory/embedding-queue.ts` provides a non-blocking worker-thread queue for background embedding generation. Observations written to brain.db are queued for embedding without blocking the write path.
902+
903+
#### T138 — Memory Bridge Lifecycle Hooks
904+
905+
Bridge refresh is now wired to `session.end` and `tasks.complete` lifecycle hooks with a 30-second debounce to prevent thrashing during rapid completions.
906+
907+
#### T139 — Context-Aware Bridge Generation
908+
909+
`generateContextAwareContent` in `memory/memory-bridge.ts` uses `hybridSearch()` scoped to the current session and focused task to generate bridge content within the `brain.memoryBridge.maxTokens` budget. Activated when `brain.memoryBridge.contextAware: true`.
910+
911+
#### T140 — Session Summarization
912+
913+
`buildSummarizationPrompt` and `ingestStructuredSummary` in `memory/session-memory.ts` deliver dual-mode summarization:
914+
915+
- **Prompt mode**: Returns a `memoryPrompt` string on `SessionEndResult` for agent-side summarization
916+
- **Ingestion mode**: Accepts a structured `SessionSummaryInput` via `sessionSummary` on `SessionEndParams` and auto-ingests to brain.db
917+
918+
#### T141 — Auto-Link to Focused Task
919+
920+
Observations written during a focused-task session are automatically linked to that task via `brain_memory_links`, enabling task-scoped brain retrieval.
921+
922+
#### T142 — Embedding Backfill CLI
923+
924+
`cleo backfill --embeddings` retroactively generates embeddings for existing brain entries with progress reporting. Dispatches to `runEmbeddingBackfill()` in the memory module.
925+
926+
#### T143 — Brain Maintenance Command
927+
928+
`cleo brain maintenance` runs combined maintenance in order: temporal decay → consolidation → embedding backfill. Individual steps can be skipped via `--skip-decay`, `--skip-consolidation`, `--skip-embeddings`. The `runBrainMaintenance()` function is exported from the internal barrel.
929+
930+
#### T144 — Cross-Provider Transcript Extraction
931+
932+
`AdapterHookProvider` gains an optional `getTranscript()` method. The Claude Code adapter implements this to expose session transcript content. `extractFromTranscript()` in `memory/auto-extract.ts` processes the transcript and emits observation candidates.
933+
934+
#### T145 — Updated Injection Templates
935+
936+
`CLEO-INJECTION.md` templates updated with a Memory Automation section documenting `brain.embedding`, `brain.memoryBridge`, and `brain.summarization` config keys for agent awareness.
937+
938+
#### T146 — CLEO-BRAIN-SPECIFICATION.md v2.0.0
939+
940+
Updated brain specification to v2.0.0 reflecting the full automation layer: embedding pipeline, lifecycle hooks, summarization protocol, and maintenance command.
941+
942+
#### New Runtime Dependency
943+
944+
| Package | Version | Load Strategy |
945+
|---------|---------|---------------|
946+
| `@xenova/transformers` | `^2.17.2` | Dynamic import (only when `brain.embedding.enabled: true`) |
947+
877948
---
878949
879950
## 16. Build Architecture

0 commit comments

Comments
 (0)