feat(FN-1420): add pluggable memory backend system

- Add FileMemoryBackend with atomic writes, persistence, and conflict resolution
- Add ReadOnlyMemoryBackend for read-only/external memory management
- Add memoryBackendType setting to select backend type (file or readonly)
- Add GET /api/memory/backend endpoint to query current backend status and capabilities
- Update AGENTS.md, README.md, and docs with architecture and settings guidance
- Add memory-backend.test.ts with comprehensive tests for all backends
- Add routes.test.ts coverage for /api/memory/backend endpoint
- Fix settings parity test to include new memoryBackendType key
This commit is contained in:
gsxdsm
2026-04-11 12:13:25 -07:00
parent 12c38ef0ea
commit 18f242b2bc
12 changed files with 1316 additions and 6 deletions

View File

@@ -149,11 +149,34 @@ From `packages/core/src/index.ts` exports:
Fusion includes a pluggable memory backend system for storing durable project learnings:
- **Two-stage memory**: Working memory (`memory.md`) + distilled insights (`memory-insights.md`)
- **Plugin architecture**: `MemoryBackend` interface enables alternative storage backends
- **Settings integration**: `memoryEnabled` toggle controls agent prompt injection
- **Insight extraction**: Scheduled AI-powered distillation of patterns, principles, pitfalls
- **Memory pruning**: Daily extraction automatically prunes transient content from working memory
**Two-stage memory:**
- Working memory (`memory.md`) accumulates agent learnings during task execution
- Distilled insights (`memory-insights.md`) preserve patterns, principles, pitfalls
**Pluggable backends (`memory-backend.ts`):**
| Backend | Type | Capabilities |
|---------|------|-------------|
| `FileMemoryBackend` | `file` | Read/Write, Atomic writes, Persistent |
| `ReadOnlyMemoryBackend` | `readonly` | Read only, Non-persistent |
**Backend registration:**
```typescript
import { registerMemoryBackend, resolveMemoryBackend } from "@fusion/core";
// Register custom backend
registerMemoryBackend(customBackend);
// Resolve based on settings
const backend = resolveMemoryBackend(settings);
```
**Settings integration:**
- `memoryEnabled`: Toggle controls whether memory instructions are injected into prompts
- `memoryBackendType`: Select which backend to use (`file` or `readonly`)
**Dashboard API:**
- `GET /api/memory/backend` — Returns current backend status and capabilities
See [Memory Plugin Contract](./memory-plugin-contract.md) for the full specification.