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: Bottom-up primitives, feature-by-feature wiring
- Approach: Implement the three shared primitives as small standalone modules (
integrity.tsfor hash + revision compute,workrun.tsfor JSONL phase log, and a thin re-export of the existingdream({dryRun:true})path). Each of the five features then ships as its own commit that imports the primitives and modifies the existing call sites directly β collision checks added inline atwritePreference, gates added inline at the dream promote/retire steps, workrun calls scattered throughscanBrainphases, doctor gets a new check appended,brain_review_candidatesadded next totoolBrainDream. - Trade-offs:
- Pro: minimal new abstraction; matches the existing pure-function,
scan β compute β applystyle of the codebase. - Pro: each feature has a tight, isolated blast radius β easy to write a failing test per file in
tests/core/brain/<feature>.test.ts. - Pro: lowest review burden per commit; reviewers see exactly which call site changed.
- Con: integrity logic gets sprinkled across
writePreferenceand dream's promote/retire β the same "compare expected vs actual" idea expressed in two places. - Con: if a sixth gate is added later, both call sites need parallel edits; drift between the two paths is possible.
- Pro: minimal new abstraction; matches the existing pure-function,
- Complexity: medium
- Risk: low
Variant 2: Single transactional write-path chokepoint
- Approach: Refactor
writePreferenceinto a thin faΓ§ade over a newwritePreferenceTxn(vault, input, expectations, options)that wrapsproper-lockfile(mirroringtransitionRequestfromapproval.ts:361): acquire lock β re-read current frontmatter β run all gates as ordered checks (revision/staleness, content-hash drift observer, shrink, duplicate-window, source-lock) β mutate βwriteFrontmatterAtomicβ release. Dream's promote and retire steps call into the same txn with feature-specific expectations (shrink-gate and retire-from-confirmed gate become two moreexpectationspredicates). Workrun stays a separate concern β a small context object threaded through dream phases β andbrain_review_candidatesis a thin MCP wrapper over the existingdryRunpath. - Trade-offs:
- Pro: every collision/gate mode lives in one auditable function; one place to add a future gate, one place to read for invariants.
- Pro: direct writes via
writePreferenceand indirect writes via dream share enforcement guarantees identically β no skew possible. - Pro: the lockfile recipe is already proven in-tree; reusing it keeps "no new external deps" trivially true.
- Con: requires up-front refactor of
writePreferenceand all its callers before tests can be made green; first commit is heavier. - Con: the txn signature grows (an
expectationsobject) β slightly more API surface to learn than the current(vault, input, options).
- Complexity: medium
- Risk: medium
Variant 3: Validator-chain pipeline
- Approach: Model every mutation as a
PreferenceIntentflowing throughvalidate β check β applystages. Each gate (StaleUpdate, UnsafeShrink, SourceLock, DuplicateWrite, ShrinkGate, RetireFromConfirmedGate, drift observer) becomes a pure validator returningok | block | warn. Workrun becomes a pipeline observer that records phase transitions;brain_review_candidatesis the same pipeline with theapplystage swapped forreport. The dream pass is rewritten to feed intents through the pipeline rather than callingwritePreferencedirectly. - Trade-offs:
- Pro: maximally extensible; each validator is independently testable as a pure function.
- Pro: a single mental model β projection, enforcement, and observation all derived from the same chain.
- Con: introduces a framework the codebase does not have today; conflicts with the "no premature abstraction" stance and the recent v0.11.0 cleanup that retired pre-1.0 shims.
- Con: reviewers must understand the framework before they can review any feature; the diff balloons and the first commit no longer maps cleanly to one user-visible feature.
- Con: dream's scan/compute/apply structure has to be inverted into a push-style pipeline β bigger blast radius than the task warrants.
- Complexity: large
- Risk: medium-high
Recommended: Variant 2
Rationale: Variant 2 centralises every collision and gate on the one place the project already needs to harden β the preference write path β and reuses the proper-lockfile recipe already proven in transitionRequest, so it adds no new abstraction the codebase has to learn. Workrun and brain_review_candidates stay as small, independent pieces alongside the txn rather than being folded into a unified framework, which keeps the diff legible while still giving the five features a single chokepoint they can share. Variant 1 risks drift between the two write paths and Variant 3 invents a pipeline framework the v0.11.0 line explicitly avoided.