30 lines
1.4 KiB
Markdown
30 lines
1.4 KiB
Markdown
---
|
|
id: 8d365483-701f-49fe-a55e-4d524ae2eff3
|
|
type: problem
|
|
title: "cognitive-memory client.py at 3260 lines needs modular refactor"
|
|
tags: [cognitive-memory, refactoring, architecture, tech-debt]
|
|
importance: 0.7
|
|
confidence: 0.8
|
|
created: "2026-02-19T20:57:01.898902+00:00"
|
|
updated: "2026-02-19T20:57:01.898902+00:00"
|
|
---
|
|
|
|
client.py has grown to 3260 lines with 47 methods in a single CognitiveMemoryClient class. Breakdown by concern:
|
|
|
|
- Constants + module helpers: ~548 lines → common.py
|
|
- Core CRUD (store/get/delete/search/recall): ~435 lines → stays in client.py
|
|
- Edges (relate/edge_get/edge_search/edge_update/edge_delete): ~352 lines → edges.py
|
|
- Embeddings (embed/semantic_recall/provider fallback): ~209 lines → embeddings.py
|
|
- Decay/Core/Reflect (decay scoring, CORE.md gen, reflection): ~1097 lines → analysis.py (biggest chunk)
|
|
- CLI parser + dispatch: ~463 lines → cli.py or __main__.py
|
|
- Index/state/git plumbing: ~115 lines → internal helpers
|
|
|
|
Refactor considerations:
|
|
- MCP server imports `from client import CognitiveMemoryClient` — needs updating
|
|
- CLI wrapper `claude-memory` uses `exec uv run python client.py` — needs package structure
|
|
- Systemd services depend on the wrapper — must test after
|
|
- Could use mixin classes or composition to split the monolithic class
|
|
- Similar to the Major Domo CLI modular refactor (that went well)
|
|
|
|
Priority: near-future. Nothing is broken but finding anything requires line-number hunting.
|