@ai-coach/vault-domain
Pure rules and models of the life vault. This package defines how a vault is laid out and what its notes mean: the PARA folders, wikilinks and link graphs, how a book is read and distilled into concept notes, sparring sessions, mastery and the climb, habits, Obsidian Tasks lines, and how projects, workstreams, areas, and plans fit together. Change this package when a vault rule or data model changes.
What it does not do
- No I/O or Node built-ins. Never read files, spawn processes, or import Node built-ins or external npm packages here; ESLint enforces this boundary.
- No YAML parsing, PDF reading, or full-text search. Callers pass a
FrontmatterParser,VaultListing, orVaultTreein from adapters. - No cross-scope imports. Only
@ai-coach/util-pathis allowed;scope:coachandscope:vault-viewcannot be imported here.
Architecture fit
- Scope:
scope:vault - Style:
architecture:hexagonal(type:domain) - Depends on:
@ai-coach/util-path - Used by:
@ai-coach/vault-application,@ai-coach/vault-adapter-markdown,@ai-coach/vault-adapter-view,@ai-coach/vault-mcp-server
[Vault application & adapters] ──▶ [@ai-coach/vault-domain] ──▶ [@ai-coach/util-path]
Internal architecture & rules
- Five folders under
src/lib/, named after the vault server's tool groups (DEC-AIC-0064), each re-exported through its ownindex.ts:note/— one note: PARA location (para), frontmatter (md), links,coach_ididentity, andVaultNoteparsing.vault/— the whole vault:VaultListing,VaultTreesnapshots, and the link graph.reading/— raw-resource paths, mark parsing and editing, reading progress, quote location and passage checks, and the concept-note format.climb/— sparring sessions, mastery, the tier-2 payload, and the climb's evidence, progress and structure rules.planning/— PARA plan paths and periods, task and habit parsing, task lines, the planning model, and assembling it from the vault.
- One-way dependencies:
note/depends on nothing else here;vault/onnote/;reading/onnote/andvault/;climb/onnote/andreading/;planning/onnote/andvault/. Inside a folder, import siblings directly, never the folder's ownindex.ts. - Pure functions and injected inputs: Every rule is deterministic. Pass dates as
YYYY-MM-DDstrings and pass vault snapshots viaVaultListingorVaultTree. - No comments in source code: Follow DEC-AIC-0011.
Public surface
- PARA & note parsing —
PARA_FOLDERS,PLANS_ROOT,classify,noteFromContent,VaultNote,FrontmatterParser. - Links, tree & graph —
extractLinks,VaultTree,noteResolver,buildVaultGraph. - Reading —
RAW_ROOT,parseMarks,applyMark,bookProgress,chapterProgress,withoutSummaries,locateQuote,checkPassages,conceptOf,renderConcept. - Climb, sessions & mastery —
CLIMB_STEPS,climbOf,structureOf,compareStructure,SessionRecord,renderSession,parseSession,histories,historyOf,tier2Payload. - Planning & tasks —
planning,parseTasks,TaskLine,planOf,planPathOf,periodOf,isoWeekOf,parseHabits,isHabitDue.
See the glossary for definitions of vault terms such as PARA, workstreams, and sparring sessions.
How to extend it
- Add or update the pure domain rule and its TypeScript types in the matching folder under
src/lib/(note/,vault/,reading/,climb/orplanning/), and export it from that folder'sindex.ts. - Re-export the new symbols from
src/index.ts. - Add unit tests next to the rule (
src/lib/<folder>/*.spec.ts) covering normal and edge cases. - Run
npm exec nx test @ai-coach/vault-domainandnpm exec nx lint @ai-coach/vault-domain.
Running & testing
npm exec nx test @ai-coach/vault-domain
npm exec nx lint @ai-coach/vault-domain
npm exec nx typecheck @ai-coach/vault-domain
npm exec nx build @ai-coach/vault-domain
Tests run in memory with Vitest using plain strings and in-memory VaultListing fixtures, with zero disk access.
Key ADRs
- DEC-AIC-0051 — Establishes the workspace hexagonal boundaries and
scope:vault/type:domaintags. - DEC-AIC-0052 — Separates pure vault domain rules from application use cases and I/O adapters.
- DEC-AIC-0064 — Groups the domain by the vault server's tool groups and moves the pure reading and climb rules here.
- DEC-AIC-0011 — Requires self-explanatory code without inline comments.