Files
loki/docs/architecture/knowledge-map.md
Cato 85192684b9 feat(memory): explore project connections and export agent handoffs (#1735)
* feat(memory): explore project connections and export portable agent handoffs

* fix(memory): use the last report when development log dates tie
2026-11-15 17:00:52 +01:00

3.4 KiB

Memory map

The authenticated /memory page projects existing owned records into a graph. It inherits the private layout's session and private-zone PIN boundary. It is not the public fleet map and does not grant access across a connection.

Layers

  • src/lib/knowledge-map/model.ts: versioned JSON contract, deterministic neighborhood layout and focused Markdown handoff. No database or React.
  • src/lib/knowledge-map/build.ts: allowlisted projection, identity resolution and endpoint ownership checks. Runtime projects and their remembered entity appear once. No database writes or automatic relationship inference.
  • src/db/queries/knowledge-map.ts: owner-scoped, bounded reads. Every package observation is joined to an owned active project. Both relationship endpoints must survive the owned entity projection. Bounds are disclosed in the map.
  • src/components/memory/KnowledgeMap.tsx: shared SearchKit and ChatKit search, a focused eight-neighbor constellation, history, relationship list and exports. Search and directory pagination operate on the snapshot; no unbounded DOM graph.
  • src/lib/knowledge-map/facts.ts: the same recorded project, goal and package connections as grounded agent facts. Relational questions enable this through the existing project source, for both seed retrieval and list_projects.

Database failures propagate rather than becoming invented empty neighborhoods. Snapshot generation is a read, not a scan trigger. Package observation dates are shown; a manifest observation does not claim a version is deployed or current. Development-log tests are explicitly reported, not independent verification.

Sharing and continuity

The project handoff includes only its purpose, latest reported work and direct project/goal/package links. It omits contacts, resources, notes and raw metadata. Prose may itself be private: the interface asks the owner to review before sharing. A deliberate JSON download exports the private snapshot, including remembered personal entities, with an explicit disclosure before download. Neither export publishes a URL or changes access.

A future public or investor map needs an independently allowlisted projection of published project records, not a client-side filter over this private graph. A second product consuming the map experience should first extract the pure contract, navigation and renderer into a fleet package. Loki retains data and authorization adapters. The current bounds are a first snapshot limit; larger workspaces should gain server-side search and cursor-based neighborhoods before raising those limits. This first slice does not claim arbitrary graph scale.

Design references

Obsidian's Graph view documents local graphs and interactive filtering. The local neighborhood informs the focus view here. React Flow's performance guidance recommends memoization, collapsing large trees and simple node/edge styles. The renderer uses those principles without adding a diagram editor dependency.

Run the real-component preview with node scripts/preview/build-knowledge-map-preview.mjs; the interactive browser check is node scripts/preview/test-knowledge-map.mjs after rendering. Synthetic preview records are explicitly examples, not claims about the owner's projects.