daily sync: 0 added, 1 modified, 0 deleted
This commit is contained in:
parent
1ddfd5e34a
commit
8a98faf2e9
@ -1,29 +1,30 @@
|
||||
---
|
||||
id: 8d365483-701f-49fe-a55e-4d524ae2eff3
|
||||
type: problem
|
||||
title: "cognitive-memory client.py at 3260 lines needs modular refactor"
|
||||
title: "cognitive-memory client.py at 3348 lines needs modular refactor"
|
||||
tags: [cognitive-memory, refactoring, architecture, tech-debt]
|
||||
importance: 0.7
|
||||
confidence: 0.8
|
||||
confidence: 0.9
|
||||
created: "2026-02-19T20:57:01.898902+00:00"
|
||||
updated: "2026-02-19T20:57:01.898902+00:00"
|
||||
updated: "2026-02-28T00:00:00+00:00"
|
||||
---
|
||||
|
||||
client.py has grown to 3260 lines with 47 methods in a single CognitiveMemoryClient class. Breakdown by concern:
|
||||
client.py has grown to 3348 lines with 66 methods (was 3260/47 on 2026-02-19). Breakdown by concern with accurate line counts:
|
||||
|
||||
- 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
|
||||
- **common.py** (~548 lines): Constants, imports, YAML/frontmatter parsing, slugify, decay calc, embedding helpers, cosine similarity, edge filename/frontmatter helpers
|
||||
- **client.py** (~1008 lines): CognitiveMemoryClient class — __init__, internal helpers (_ensure_dirs, _load/_save index/state, _resolve paths, _git_commit, _update_index_entry), store, recall, get, search, update, delete, related, stats, recent, episode, reindex, pin
|
||||
- **edges.py** (~274 lines): relate, edge_get, edge_search, edge_update, edge_delete + edge index helpers (_update_edge_index, _remove_edge_index, _scan_for_edge, _resolve_edge_path)
|
||||
- **embeddings.py** (~208 lines): _get_embedding_provider, _embed_texts_with_fallback, embed, semantic_recall
|
||||
- **analysis.py** (~839 lines): decay, core (CORE.md gen), tags_list/related/suggest, reflect, merge, reflection_summary — biggest chunk
|
||||
- **cli.py** (~471 lines): argparse parser + dispatch + main()
|
||||
|
||||
Approach: mixin classes. Each module defines a Mixin class; CognitiveMemoryClient inherits from all mixins. This preserves `self` access and keeps the public API identical.
|
||||
|
||||
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)
|
||||
- MCP server imports `from client import CognitiveMemoryClient` — needs re-export or updated import
|
||||
- CLI wrapper at `/home/cal/.local/bin/claude-memory` uses `exec uv run python client.py` — cli.py must be runnable
|
||||
- Systemd services (daily/weekly timers) depend on the wrapper — must test after
|
||||
- mcp_server.py also imports `_load_memory_config, MEMORY_DIR` from client — move to common.py
|
||||
- 4 module-level helper functions are used across concerns — belong in common.py
|
||||
|
||||
Priority: near-future. Nothing is broken but finding anything requires line-number hunting.
|
||||
Priority: active. Line count growing, 66 methods in one class makes navigation painful.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user