Repository navigation
Description
Summary
Make the accepted-note flow easier to follow by extracting preparation behavior from the oversized EntityService and reducing structural data protocols that do not represent external capabilities.
Why
The shared runtime is correctly designed around explicit sessions and real local/cloud variation, but the current accepted-note path carries a high concept count:
EntityServiceis over 2,000 lines and owns preparation, file-first CRUD, Markdown editing, graph persistence, permalink resolution, moves, and directory operations;- accepted-note composition constructs the full service primarily to call its prepare methods;
- the accepted-note runtime/runner files define many property-only
*Sourceprotocols for different projections of the same entity and content state; - tests mirror this surface with large sets of handwritten fake protocol implementations.
Protocols for storage, queues, repositories, and schedulers are real capabilities. Property-only protocols used as anonymous read models are a weaker tradeoff: they multiply shapes without making the domain flow clearer.
This follow-up applies the /pythonic-code guidance introduced in #1095 to the runtime from #1002, after the first collapse campaign in #1054.
Proposed Direction
- Inventory the accepted-note protocols against actual local and cloud consumers.
- Retain narrow behavioral protocols at genuine runtime boundaries.
- Replace cohesive property-only source shapes with a small number of frozen typed values at the boundary.
- Extract create/update/edit/move Markdown preparation into explicit module-level functions operating on
PreparedEntityWrite,PreparedEntityMove, and their direct dependencies. - Bind dependencies with ordinary arguments or
functools.partialwhere that creates a clearer composition root. - Keep
EntityServicefocused on file/DB orchestration. - Prefer real SQLite-backed regression tests or reusable typed fixtures over one fake class per protocol.
Avoid creating a replacement Manager, strategy hierarchy, or dynamic registry.
Acceptance Criteria
- A reader can trace route → prepare → persist → materialize without reconstructing a chain of data-shape protocols.
- Accepted-note preparation does not require constructing the full
EntityServicesolely for prepare-only behavior. - The targeted protocol and fake-class count decreases materially while retaining explicit local/cloud capability boundaries.
- File-first and DB-first Markdown, permalink, conflict, and edit semantics remain byte/behavior compatible.
- Focused core tests, type checking, and paired cloud contract tests pass.
Activity
claude commentedon Jul 18, 2026
Claude finished @phernandez's task in 1m 34s —— View job
Triage complete
Classification
EntityService,runtime/indexingprotocols). This repo's label set doesn't have a dedicated "core" component label — closest existing labels are already applied (cloud, since the accepted-note runtime spans local/cloud routing).src/basic_memory/services/entity_service.py(currently 2,115 lines, confirming the issue's premise) plus the*Sourceprotocols insrc/basic_memory/runtime/andsrc/basic_memory/indexing/accepted_note_*files, with matching fake-protocol test surface intests/runtime/andtests/indexing/.Duplicate check: Searched open/closed issues for related terms — no duplicate found. This is a legitimate, well-scoped follow-up to prior merged/closed work: #1002 (merged — added the shared runtime), #1054 (merged — prior structure-collapse campaign), #1053 (closed, precursor scoping issue), and #1095 (open — introduces the
/pythonic-codeguidance this issue applies). References check out.bug,question,documentation,duplicate) — none of these apply. The labeling script here only supports adding labels, not removing them, and I don't have permission to remove labels directly. A maintainer will need to manually removebug,question,documentation, andduplicatefrom this issue. Apologies for the noise. The only label I intended and correctly applied isenhancement, which was already present alongside the pre-existingcloudandpythonlabels.This issue is a clear, actionable refactor proposal with well-defined acceptance criteria — no clarification needed from the author. Per my triage-only instructions, I'm stopping here without implementing changes.