# Module Map

This document is the source of truth for LaPis module ownership. Update it whenever a PR adds, removes, renames, or changes the dependency boundary of a module.

## Source modules

| Feature area | Module directory | Entry point | Owns | Allowed dependencies | Must not depend on |
| --- | --- | --- | --- | --- | --- |
| CLI command gateway | `src/cli/` | `src/cli/gateway.js` | Command map composition and feature router registration. | Feature command routers and feature service modules. | Raw feature implementation details beyond router delegation; Pi extension state. |
| Declarative memory domain | `src/memory-domain/` | `src/memory-domain/index.js` | Observations, memory search, context loading, sessions, recall logging, dedupe, compaction, and workspaces. | Storage/repository helpers, configuration, ranking constants, project identity. | Code/doc parsers, code-analysis internals, Pi extension state. |
| Procedural workflow memory | `src/workflow-memory/` | `src/workflow-memory/index.js` | Saved workflows, ordered steps, step outcomes, and workflow scoring. | Storage/repository helpers and project identity. | Observation ranking internals, code/doc parsers, Pi extension state. |
| Code indexing and retrieval | `src/code-index/` | `src/code-index/index.js` | Repository registration, scanning, language/parser selection, symbol extraction, import/call edge extraction, incremental indexing, and source retrieval. | Filesystem utilities, parser registry, hashing, code-index storage repositories. | Memory observation ranking, doc-index internals, Pi extension state. |
| Code analysis and intelligence | `src/code-analysis/` | `src/code-analysis/index.js` | Import/call graph queries, blast radius, dead code, complexity, hotspots, cycles, importance, coupling, hierarchy, signal chains, layer violations, query winnowing, and risk analysis. | Code-index read model/repositories, git metrics, analysis formatters. | Pi extension state, memory observation CRUD, parser write-path internals. |
| Documentation indexing and intelligence | `src/doc-index/` | `src/doc-index/index.js` | Markdown parsing, doc repository indexing, section search, backlinks, broken links, glossary terms, tutorial paths, code examples, stale/duplicate/orphan analytics, and doc coverage reports. | Markdown/doc storage repositories; a narrow code-symbol lookup for coverage only. | Memory-domain internals, code-analysis internals, Pi extension state. |
| Trust synchronization | `src/trust-sync/` | `src/trust-sync/index.js` | Memory-to-code-symbol links, related memory lookup, trust policy, and code-change detection for trust updates. | Memory repositories, code-symbol repositories, git/code change metadata. | Unrelated feature internals; direct doc-index behavior. |
| Platform services | `src/platform/` | `src/platform/storage/index.js`, `src/platform/protocol/envelope.js` | Shared storage composition, repository construction, protocol envelopes, compact output, and LLM-facing transformations. | Database adapters, repository factories, typed feature results, constants. | Feature business logic, Pi extension state, command parsing. |

## Extension and support modules

| Area | Directory | Owns | Boundary |
| --- | --- | --- | --- |
| Pi extension integration | `extensions/memory-layer/` | Pi hook registration, tool schemas, context injection, passive capture, trust-sync hooks, project detection, native dependency health checks, and tool result formatting. | Adapter layer only; do not add raw SQL, parser internals, or backend feature business logic here. |
| Legacy/runtime CLI entry | `memory-store.js`, `cli.js`, `commands/` | Backwards-compatible command entry points and legacy command modules while extraction continues. | Prefer moving new feature behavior into `src/` modules and routing through `src/cli/`. |
| Data access helpers | `data-access/` | Repository-style SQL helpers used by current runtime code. | Keep SQL ownership clear; do not mix presentation formatting into repositories. |
| Crosshash Rust engine | `crosshash/` | Rust code-intelligence engine experiments and future backend work. | Keep behind a command/API boundary until it replaces the JavaScript code-intelligence path. |

## When to update this file

Update this module map when a change:

- Adds or removes a top-level `src/` feature module.
- Renames a module, entry point, or feature router.
- Moves ownership of a command, table, repository, parser, formatter, or analysis routine.
- Changes which modules are allowed to depend on each other.
- Adds a new integration boundary between two feature modules.

Also update the matching module-boundary comment in the relevant entry point so the code and docs stay aligned.
