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

@@ -1821,6 +1821,69 @@ Directory for backup files, relative to the project root. The directory is creat
- Must be a relative path (no leading `/` or `\`)
- Must not contain parent directory traversal (`..`)
### `memoryEnabled` (default: `true`)
When enabled, agents consult and update `.fusion/memory.md` with durable project learnings. When disabled, agents will not include memory instructions in their prompts and will not read or write to `.fusion/memory.md`.
**Configuration:**
```json
{
"settings": {
"memoryEnabled": false
}
}
```
**Notes:**
- When toggled from `false` to `true`, the memory file is bootstrapped automatically
- Existing memory content is never overwritten
### `memoryBackendType` (default: `"file"`)
Memory backend type for pluggable memory storage.
**Available backends:**
| Backend | Description | Capabilities |
|---------|-------------|--------------|
| `file` | File-based storage in `.fusion/memory.md` | Read/Write, Atomic writes, Persistent |
| `readonly` | Read-only backend (for external memory management) | Read only, Non-persistent |
**Configuration:**
```json
{
"settings": {
"memoryBackendType": "file"
}
}
```
**Verifying active backend:**
```bash
curl http://localhost:4040/api/memory/backend
```
**Response:**
```json
{
"currentBackend": "file",
"capabilities": {
"readable": true,
"writable": true,
"supportsAtomicWrite": true,
"hasConflictResolution": false,
"persistent": true
},
"availableBackends": ["file", "readonly"]
}
```
**Fallback behavior:**
- If an unknown backend type is configured, Fusion falls back to `file` backend
- Read failures return empty content instead of errors
- Write failures to non-writable backends throw `MemoryBackendError` with code `READ_ONLY`
### `autoSummarizeTitles` (default: `false`)
When enabled, tasks created without titles but with descriptions longer than 140 characters will automatically receive an AI-generated title (max 60 characters).