You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a typed multi-project directory snapshot for Cloud tree assembly #1186
Cloud observability issue #1661 confirmed a project-tree request that fanned out into 26 single-project directory/structure requests.
Core's DirectoryService and v2 directory router currently resolve exactly one project per call. Cloud can remove the fanout only by duplicating Core's directory-tree semantics or by receiving one typed multi-project snapshot from Core. The typed Core boundary is the smaller and safer change.
Outcome
Expose a service-level batch directory snapshot for a set of already-authorized project external IDs. Cloud will call it once per tenant workspace and assemble its aggregate explorer tree without one ASGI request per project.
This is a narrow Core capability for the parallel Cloud PR. It is not a new public MCP tool or a general directory API redesign.
Acceptance criteria
A typed request identifies a bounded set of project external IDs and whether file nodes are included.
A typed response maps every requested, active project to its DirectoryNode snapshot and reports missing/inactive projects explicitly.
The implementation reads all requested projects/entities with O(1) database round trips per tenant, not one query per project.
Tree construction preserves the existing /directory/tree and /directory/structure node semantics.
Authorization remains a Cloud responsibility; the Core service accepts only the already-authorized project ID set.
After Core merges, Cloud will pin that commit and replace _fetch_project_trees() fanout in WebV2RuntimeService with one batch snapshot per workspace. Tree counts will reuse the same normalized snapshot.
Type: Feature request — adds a new batch/typed capability to DirectoryService and the v2 directory router; not a defect in existing behavior.
Priority: Medium — no user-facing breakage today; it removes an internal fanout inefficiency (26 single-project requests per tree) surfaced by a Cloud observability issue, but Core itself isn't broken.
Component: Cloud-adjacent Core service/API — the issue targets src/basic_memory/services/directory_service.py and src/basic_memory/api/v2/routers/directory_router.py, which I confirmed exist in this repo. The consuming caller (WebV2RuntimeService._fetch_project_trees()) lives in the separate basic-memory-cloud repo, so this is a narrow, well-scoped typed-boundary addition to Core.
Complexity: Medium–Complex — well-specified with clear acceptance criteria (typed request/response, O(1) DB round trips per tenant, preserved tree/node semantics, explicit missing/inactive project handling, empty-project handling, and required test coverage across several scenarios). Not a quick fix, but scoped tightly enough to avoid architectural changes to existing single-project endpoints.
Duplicates: Searched open/closed issues for related terms (directory snapshot, multi-project directory, DirectoryService batch) — no duplicates found.
Note on labeling: While probing which labels exist in this repo (the label set in my instructions turned out to be stale/broader than what's actually configured here — only bug, enhancement, documentation, question, duplicate, and cloud exist, no priority/component/complexity labels), I mistakenly applied bug, documentation, question, and duplicate to this issue before confirming they didn't apply. My tooling for this triage task is add-only (no label removal permission), so I could not undo that. Correct labels for this issue are enhancement and cloud, both of which are applied. Could a maintainer please manually remove bug, documentation, question, and duplicate from this issue? Apologies for the noise.
Per my triage-only scope, I have not implemented the change, edited files, or opened a branch/PR for this.
Closing this because it puts the optimization at the wrong boundary.
The measured 26-request trace came from Cloud's aggregate /api/v2/projects/tree handler fanning one browser request out across every project. Core already has the correct single-project directory API. Adding a tenant-wide batch snapshot to Core would make the server responsible for client aggregation, increase the size and invalidation scope of the response, and remove the natural per-project cache key.
The Cloud correction is:
the browser loads the already-cached project catalog;
it requests one tree resource per project through a single-project Cloud endpoint;
the shared web-v2 store caches those resources by project ID and composes the aggregate explorer locally;
live updates invalidate only the affected project;
the aggregate Cloud tree/count handlers and their server-side project fanout are removed.
No Basic Memory Core change is needed for this fanout. The Cloud implementation remains tracked in basicmachines-co/basic-memory-cloud#1661.
Activity
claude commentedon Aug 4, 2026
Claude finished @phernandez's task in 1m 59s —— View job
Triage complete
Type: Feature request — adds a new batch/typed capability to
DirectoryServiceand the v2 directory router; not a defect in existing behavior.Priority: Medium — no user-facing breakage today; it removes an internal fanout inefficiency (26 single-project requests per tree) surfaced by a Cloud observability issue, but Core itself isn't broken.
Component: Cloud-adjacent Core service/API — the issue targets
src/basic_memory/services/directory_service.pyandsrc/basic_memory/api/v2/routers/directory_router.py, which I confirmed exist in this repo. The consuming caller (WebV2RuntimeService._fetch_project_trees()) lives in the separatebasic-memory-cloudrepo, so this is a narrow, well-scoped typed-boundary addition to Core.Complexity: Medium–Complex — well-specified with clear acceptance criteria (typed request/response, O(1) DB round trips per tenant, preserved tree/node semantics, explicit missing/inactive project handling, empty-project handling, and required test coverage across several scenarios). Not a quick fix, but scoped tightly enough to avoid architectural changes to existing single-project endpoints.
Duplicates: Searched open/closed issues for related terms (
directory snapshot,multi-project directory,DirectoryService batch) — no duplicates found.Note on labeling: While probing which labels exist in this repo (the label set in my instructions turned out to be stale/broader than what's actually configured here — only
bug,enhancement,documentation,question,duplicate, andcloudexist, no priority/component/complexity labels), I mistakenly appliedbug,documentation,question, andduplicateto this issue before confirming they didn't apply. My tooling for this triage task is add-only (no label removal permission), so I could not undo that. Correct labels for this issue areenhancementandcloud, both of which are applied. Could a maintainer please manually removebug,documentation,question, andduplicatefrom this issue? Apologies for the noise.Per my triage-only scope, I have not implemented the change, edited files, or opened a branch/PR for this.
phernandez commentedon Aug 4, 2026
Closing this because it puts the optimization at the wrong boundary.
The measured 26-request trace came from Cloud's aggregate
/api/v2/projects/treehandler fanning one browser request out across every project. Core already has the correct single-project directory API. Adding a tenant-wide batch snapshot to Core would make the server responsible for client aggregation, increase the size and invalidation scope of the response, and remove the natural per-project cache key.The Cloud correction is:
No Basic Memory Core change is needed for this fanout. The Cloud implementation remains tracked in basicmachines-co/basic-memory-cloud#1661.