Local-first π§ memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly π΄ dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.
Variant 1: Layered foundation (schema β utilities β consumers)
- Approach: Build three horizontal layers bottom-up: a
page-meta/layer owning the new frontmatter atoms (lifecycle, tier, merged-pointer), atext/layer owning the deterministic helpers (NFKC+casefold normaliser, heuristic tokenizer, action-impact scorer), and the consumer layer that wires those into the ranker, digest, doctor, lint, context-pack, and footprint verbs. Strict DAG: consumers depend on layers, never on each other; one extendedmigrate-frontmatterpass covers all schema additions. - Shared building blocks:
src/core/brain/page-meta/lifecycle.tsβLifecycleenum, default resolver, staleness predicate (F1, F4, F8).src/core/brain/page-meta/confidence.tsβ generalises today's_confidenceto non-preference pages (F1).src/core/brain/page-meta/tier.tsβTierenum, defaultsupporting, tier-weight table (F2, F6, F8).src/core/brain/page-meta/page-id.tsβmerged_intopointer + canonical resolver (F3, F4).src/core/brain/text/normalize.tsβ NFKC + casefold dedup key (F7, F3).src/core/brain/text/tokenizer.tsβ single heuristic token counter (F5, F6, F8).src/core/brain/maintenance/action-scorer.tsβ impact-weighted action item builder (F8).- Extension of the existing
migrate-frontmatterverb to cover the new fields idempotently.
- Implementation order:
- F7 β pure refactor of
dedup-hash.tsto NFKC+casefold; unblocks F3 without schema churn. - F1 β confidence + lifecycle frontmatter via
page-meta/andmigrate-frontmatter. - F2 β tier frontmatter + ranker hook in
src/core/search/ranker.ts. - F3 β page dedup, consuming F7 normalisation, F1 lifecycle (skip deprecated/archived), and the
merged_intopointer. - F5 β token footprint verb + digest section, introducing the shared tokenizer.
- F6 β
brain_context_packMCP tool + CLI verb, composing tier + lifecycle + tokenizer. - F4 β
o2b brain lint --consolidatewith dry-run, using lifecycle for demotion and page-id for orphan-merge hints. - F8 β ranked action list, composing every prior layer through
action-scorer.tsand surfacing in digest + doctor.
- F7 β pure refactor of
- Trade-offs:
- Pros: Every shared concept has one owner file; future maintenance features add a peer module instead of recutting an abstraction.
- Pros: Tests mirror layers (
tests/core/brain/page-meta/*,tests/core/brain/text/*), so per-tool tests stay small. - Pros: One migration sweep covers F1+F2+F3 pointer; old pages keep parsing with default values.
- Cons: Touches more consumer files in one PR (ranker, digest, doctor, dream, inline-scan, sessions/import), so the diff feels wide even though each touch is small.
- Cons: Some readers have to chase logic across
page-meta/and the consumer, instead of seeing it inline.
- Complexity: medium
- Risk: low
Variant 2: Single maintenance index (one scan, many views)
- Approach: Introduce a
MaintenanceIndexthat walks the vault once (reusinginline-scan+backlinks+exploreroutputs) and exposes typed views βbyTier,byLifecycle,tokenByCategory,dedupCandidates,orphans,staleForDemotion. Every consumer (digest, doctor, lint, context-pack, footprint, action-list) reads from this index instead of re-scanning. The schema additions and normalisation helper feed the index; the eight features become "another view + thin verb" on top. - Shared building blocks:
src/core/brain/maintenance-index/types.tsβLifecycle,Tier,PageMeta,TokenCount,DedupCandidate,ActionItem(one schema home).src/core/brain/maintenance-index/builder.tsβ single-pass scanner producing the cached index.src/core/brain/maintenance-index/views.tsβ typed accessors per concern (F2, F3, F4, F5, F6, F8 all consume this).src/core/brain/text/normalize.tsβ NFKC + casefold helper (F7, also feeds dedup-hash + index).- Action-scorer is a function over the index, not its own module.
- Implementation order:
- F1 + F2 together β lifecycle + tier added to
FrontmatterMapandmigrate-frontmatter; both are pure schema bumps. - F7 β NFKC + casefold in
text/normalize.ts, called fromdedup-hash.ts. - Maintenance-index skeleton β scanner + empty views.
- F5 β first view (
tokenByCategory) wired to a CLI verb + digest section. - F3 β
dedupCandidatesview,merged_intowriter, wikilink patcher. - F4 β
lint --consolidatecomposingorphans+staleForDemotion+dedupCandidateswith--dry-run/--apply. - F6 β
context_packover the index, ordered by tier then recency under a token budget. - F8 β pure function over the index, replacing the vague "Recommendation" string in digest + doctor.
- F1 + F2 together β lifecycle + tier added to
- Trade-offs:
- Pros: One canonical scan per command β measurable perf win for larger vaults and fewer race-windows against the watcher.
- Pros: Tests concentrate on one well-typed module plus thin per-feature wrappers; views are easy to snapshot.
- Pros: Future maintenance features cost "one new view + one new action term".
- Cons: God-module risk β
maintenance-index/accumulates concerns and needs strict sub-file discipline. - Cons: Forces every feature through the same abstraction even where (F7) it is overkill, making early commits read as scaffolding.
- Cons: Sequential ordering β F3-F8 all wait on the index being non-trivial, so parallelisation inside the PR is limited.
- Complexity: medium
- Risk: medium
Variant 3: Per-feature modules with minimal shared atoms
- Approach: Each feature ships as a focused module under
src/core/brain/<feature>.tsplus its CLI verb file; the only shared surface is a tinypage-meta/types.ts(Lifecycle, Tier enums), one normaliser, and one tokenizer helper. Feature files compose existing primitives (inline-scan,backlinks,explorer) directly rather than through a new index or scorer module. - Shared building blocks:
src/core/brain/page-meta/types.tsβLifecycle,Tierenums + default/parse helpers (F1, F2, F3, F4, F8).src/core/brain/text/normalize.tsβ NFKC + casefold helper (F7, used by F3).src/core/brain/text/tokenizer.tsβ heuristic token counter (F5, F6, F8 each call directly).- Per-feature modules:
lifecycle-confidence.ts,tier.ts,page-dedup.ts,lint-consolidate.ts,token-footprint.ts,context-pack.ts,maintenance-actions.ts. - No central maintenance index; no central action-scorer module.
- Implementation order:
- F7 β refactor
dedup-hash.tsto NFKC + casefold; isolated. - F1 β confidence + lifecycle frontmatter + migrate-frontmatter.
- F2 β tier frontmatter + ranker hook.
- F5 β token footprint verb + digest section.
- F3 β page dedup using F7 normalisation and F1 lifecycle gating.
- F6 β context-pack using F2 tier + tokenizer.
- F4 β lint --consolidate using F1 lifecycle and F3 dedup hints.
- F8 β action list re-deriving inputs from each feature module.
- F7 β refactor
- Trade-offs:
- Pros: Smallest, most local diffs per feature; reviewers can read one file per feature; reverts stay surgical.
- Pros: Steps 1-5 are largely independent β subagent dispatch is straightforward.
- Pros: Lowest cognitive load to land the first few features quickly.
- Cons: Tokenization, lifecycle classification, tier scoring get inlined into multiple callers β future schema changes touch many files.
- Cons: F8 becomes a fat module that re-walks data prior features already computed; wasted vault walks per invocation.
- Cons: Test surface fragments; no single canonical maintenance view to snapshot-test, so coverage relies on disciplined per-verb tests.
- Complexity: small per file, medium overall
- Risk: medium (drift risk across future releases)
Recommended: Variant 1
Rationale: The eight features cleanly split into two horizontal concerns (frontmatter atoms, deterministic text/scoring helpers) feeding a vertical layer of mostly-additive consumer changes β a layered shape captures that without paying for the god-index of Variant 2 or accepting the duplication and drift risk of Variant 3. It also matches established OSB conventions: per-concern files alongside backlinks.ts and explorer.ts, one migrate-frontmatter sweep for the new fields, additive MCP surface, and consumer hooks (ranker.ts, digest.ts, doctor.ts) edited in narrow ways. Crucially, it keeps the door open for future maintenance features (freshness signal, tag taxonomy, vault-size policies) by adding a peer file under page-meta/ or text/ instead of re-cutting the schema.