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.
TypeScript
What the machine already has - implementation plan
Eleven atomic units across nine tracker items, on one branch, each its own commit. Every unit is test-first: the test is written, run, and observed failing for the expected reason before the implementation exists.
Tracker mapping:
| unit | tracker item |
|---|---|
| 1, 3, 4 | t_9f5b974b, t_367a31c1 |
| 2 | t_85cc975b |
| 5 | t_9b209fbe |
| 6, 7 | t_53e77d0a |
| 8 | t_553ce8f6 |
| 9 | t_3745dd4b |
| 10 | t_7c89c306 |
| 11 | t_2866fef9 |
Tasks
Task 1: Runtime facts substrate
- Files:
src/core/runtime/host-facts.ts(new);src/core/install/types.ts;tests/core/runtime/host-facts.test.ts(new);tests/core/architecture/host-facts-census.test.ts(new);tests/core/architecture/verdict-vocabulary-census.test.ts - Acceptance:
INSTALL_TARGET_ID/InstallTargetId/INSTALL_TARGET_IDS/isInstallTargetIdfollow the house closed-vocabulary pattern and are enrolled in the vocabulary census.TOOL_CEILING_KINDhas exactly three members andunknowncarries a reason. A census derives the target population fromregisterAllAdapters().targets()and asserts it equals theRUNTIME_FACTSkey set in both directions; the census fails if the population is empty.InstallAdapter.targetis typedInstallTargetId. - Depends on: none
Task 2: Committed vault tier and config provenance
- Files:
src/core/validate.ts;src/core/config.ts;src/core/brain/policy/load.ts;src/core/brain/policy/blocks/install.ts(new);src/core/install/payload.ts;src/core/install/grok-asset.ts;tests/core/config-origin.test.ts(new);tests/core/brain/policy/install-block.test.ts(new) - Acceptance:
CONFIG_ORIGINis a closed vocabulary (env,user-config,vault-config,default).resolveWithOriginreturns value plus origin andenvOrConfigdelegates to it with no call-site change - proved by a test that asserts the two agree on every branch. Aninstall:block in<vault>/Brain/_brain.yamlsupplieshook_timeout_secondsandtool_profile; an env var beats it, a user-level key loses to it, and each resolution reports its origin. An unreadable or malformed vault config makes install and hook generation refuse by name rather than default. Regeneration from identical inputs stays byte-identical. - Depends on: none
Task 3: Ceiling-aware tool profile in the generated payload
- Files:
src/core/install/payload.ts;src/core/install/payload-equals.ts;src/core/install/adapters/_json-mcp.ts,cursor.ts,opencode.ts,grok.ts,copilot-cli.ts;src/mcp/capabilities.ts;install/cursor.md;tests/core/install/tool-ceiling.test.ts(new);tests/mcp/profiles.test.ts - Acceptance: for every target whose
RUNTIME_FACTSrow declares a ceiling, the generatedfullentry carries--tool-profile <name>and the advertised tool count under that profile is at or under the ceiling - asserted with the realbuildToolTablecount, pinned as an equality, and driven by the derived population so a new target with a ceiling cannot avoid the check. A target with anunknownceiling gets no profile andsecond_brain_capabilitiesreports the ceiling as unchecked with its reason.verify()still reconstructs the expected payload fromInstallEnvalone and reports no drift on a fresh apply.install/cursor.md's expected-output block is updated to whateververify()now prints, andtests/docs/install-verify-conformance.test.tsis the check that the two agree. - Precedence, stated once:
OPEN_SECOND_BRAIN_MCP_TOOL_PROFILEbeats aninstall:blocktool_profilein<vault>/Brain/_brain.yaml, which beats the profile declared on theRUNTIME_FACTSrow, which beats no profile at all. Each resolution reports itsCONFIG_ORIGIN, and a test drives all four layers. - Depends on: 1, 2
Task 4: Adapter friction diff and keyless host probe
- Files:
src/core/install/friction.ts(new);src/core/install/types.ts;src/cli/install/install.ts;src/cli/install/render.ts;src/cli/command-manifest.ts;docs/cli-reference.md;tests/core/install/friction.test.ts(new);tests/cli/install-friction.test.ts(new) - Acceptance:
o2b install --friction [--base <t> --compare <t>] [--json]renders one row per capability dimension per target, derived fromRUNTIME_FACTSand the adapter registry rather than a hand-written table, and a diff form names which dimensions differ. For a target declaring a host probe,verify()returns either a real registration-shape answer or a named skip reason; the blanket "no MCP handshake attempted" note survives only where no probe is declared, and a test asserts that string no longer appears for probe-bearing targets. The probe runner is injectable and both branches are driven. - Depends on: 1
Task 5: Lane vocabulary, step deadline, maintenance retry, parity census
- Files:
src/core/brain/maintenance/lane.ts;src/core/brain/dream-step.ts;src/core/brain/dream-scan.ts;src/core/brain/heal-run.ts;src/mcp/brain/feedback-tools.ts;src/mcp/brain/admin-tools.ts;src/cli/brain/verbs/maintenance.ts;docs/mcp.md;docs/cli-reference.md;tests/mcp/maintenance-parity-census.test.ts(new);tests/mcp/long-running-tools.test.ts;tests/cli/brain-maintenance.test.ts;tests/core/brain/maintenance/maintenance.test.ts - Acceptance:
LANE_TASKis a closed vocabulary with a guard, and both the CLI task list and the MCP task list are built from it - a source census asserts neither module contains a bare lane-name literal.runDreamStep(vault, step, opts)accepts a safeguard and a progress sink,scanBrainandrunHealEnrichmenthonour checkpoints, and a jumping-clock test provesbrain_dream action=run step=<x>trips the deadline and names the operation.brain_maintenanceacceptsretry_tasks,busy_minutes,busy_thresholdandlimit; an unknown retry name is refused by name, matching the CLI. Theforcedescription names every gate it disables. A parity census derives the CLI flag set from the verb's flag table and the MCP property set from the tool definition and requires each to map or carry a declared exemption with a written reason; it fails if either population is empty. Thedocs/mcp.mddeadline row forstepno longer reads none. - Depends on: none
Task 6: State surface inventory
- Files:
src/core/state/surfaces.ts(new);src/core/install/ownership.ts;src/core/doctor.ts;src/mcp/tools.ts;src/cli/brain/verbs/state.ts(new);src/cli/state-render.ts(new);src/cli/main.ts;src/cli/command-manifest.ts;tests/core/state/surfaces.test.ts(new);tests/core/architecture/state-surface-census.test.ts(new) - Acceptance:
STATE_SURFACE_IDis a closed vocabulary; every row carries a resolver, tier, override env key, override config key, whether it carries memory, and a written reason.inventoryStateSurfaces(vault)returns per-surface resolved path, reachability as a tri-state with a reason, and the origin that placed it, rendered through one value with two renderings (o2b state statusand thevault_healthfield). A source census sweeps for path builders under the derived-store directory and demands each be attributed to a row or excused with a reason of a minimum length; it fails if the population is empty, and its count is pinned as an equality. - Depends on: 2
Task 7: State migrate, rollback, and graceful drain
- Files:
src/core/state/migrate.ts(new);src/mcp/http.ts;src/mcp/stdio.ts;src/cli/brain/verbs/state.ts;src/cli/main.ts;docs/cli-reference.md;tests/core/state/migrate.test.ts(new);tests/mcp/http-drain.test.ts(new) - Acceptance:
o2b state migrate --to <dir>plans by default and mutates only under--apply --yes, refused non-interactively without--yes, following thebrain upgradeladder. The manifest binds source type, canonical roots, the path inventory, byte counts and SHA-256 digests throughsha256HexandcanonicalJson. It refuses before committing on a symlink, a special file, a destination conflict, insufficient space, a reserved namespace, or a held writer lock.o2b state rollbackrestores only manifest-bound content whose digest still matches and refuses to delete anything that changed after the migration, naming each. On SIGTERM or SIGINT the HTTP transport stops accepting, reportsdrainingon/health, awaits in-flight requests to a bounded deadline, then closes - proved by a test holding a request open across the signal - and the exit hooks that checkpoint the search index and release locks still run afterwards. The drain deadline defaults to ten seconds and is overridable; when it expires, the still-open requests are named on stderr rather than dropped silently. - Depends on: 6
Task 8: Codex CLI install adapter
- Files:
src/core/install/adapters/codex.ts(new);src/core/install/adapters/all.ts;src/core/runtime/host-facts.ts;install/codex.md;tests/core/install/adapters/codex.test.ts(new);tests/docs/install-verify-conformance.test.ts - Acceptance: the adapter registers both server keys through an injectable
CodexRunnerdrivingcodex mcp add|remove|list --json, with a TOML section merge into~/.codex/config.tomlas the fallback when the binary is absent; unrelated sections and the existing[plugins."..."]and[marketplaces....]blocks survive byte-for-byte.detect,plan,apply,uninstallandverifyare driven on both branches, apply is idempotent, andinstall/codex.mdcarries an expected-output block matchingverify(). ItsPIPELINE_HOSTED_DOCSexemption is removed, and the conformance test binds it like any other adapter. - Depends on: 1, 4
Task 9: Machine-wide session discovery and coverage status
- Files:
src/core/brain/sessions/discover.ts(new);src/core/brain/sessions/types.ts;src/core/install/types.tsand all ten adapters (sessionPathsimplementations);src/core/discipline/transcripts/index.ts;src/cli/brain/verbs/import-session.ts;src/cli/brain/help-text.ts;src/cli/command-manifest.ts;src/core/brain/safeguard.ts;tests/core/brain/sessions/discover.test.ts(new);tests/cli/session-discovery.test.ts(new);tests/cli/progress-emitter-census.test.ts - Acceptance:
sessionPaths()is a required member returning roots fromRUNTIME_FACTSand aSessionAdapterId; a runtime that stores no session logs (generic,aider,pi) returnsnull, which is a stated answer rather than an absent member. The orphan"claude-jsonl" | "codex-json" | "cursor-sqlite"union is gone from the tree.o2b brain import-session --discoverreports what would import without importing;--statusreports per runtime the found count, the imported count and the gap, keyed by content hash in a manifest under the derived-store directory so an unchanged file is reported as imported without re-parsing.--discover --allimports the gap. Roots are read once:src/core/discipline/transcripts/consumes the same declaration, proved by a test that changes a root inRUNTIME_FACTSand observes both consumers move. If the sweep carries a safeguard it carries a progress sink and satisfies the emitter census with a drivable entry point; if it carries neither, that is stated in the module. - Depends on: 1, 8
Task 10: Streaming session parse
- Files:
src/core/brain/sessions/read-lines.ts(new); five session adapters;src/core/brain/sessions/import.ts;tests/core/brain/sessions/read-lines.test.ts(new);tests/core/brain/sessions/streaming-memory.test.ts(new) - Acceptance: all five adapters consume a shared line reader that yields without
materialising the whole file, and autodetect reads only the first chunk instead of the
whole file a second time. A test drives a synthetic session larger than the previous
whole-file path would comfortably hold and asserts peak retained bytes stay bounded,
and every existing session-import test still passes with byte-identical vault output.
ImportSessionOptionsgains a safeguard and a progress sink together, or neither. - Depends on: 9
Task 11: Session transcript dataset export
- Files:
src/core/brain/export.ts;src/core/brain/export-transcripts.ts(new);src/cli/brain/verbs/export.ts;src/core/egress/registry.ts;src/cli/brain/help-text.ts;docs/cli-reference.md;tests/core/brain/export-transcripts.test.ts(new);tests/cli/brain-export.test.ts;tests/core/architecture/egress-census.test.ts - Acceptance:
ExportFormatbecomes a closed vocabulary with a guard and is the single dispatch - a source test asserts the CLI verb no longer inlines format literals. A transcript format emits JSONL conversation records built from the streaming reader, filterable by runtime and date range. Every branch callsredactForEgressbefore producing bytes, the guard-call count meets the destination-declaration count in the module, the site is declared inEGRESS_SITESwith a written reason, and a refused verdict writes nothing and exits non-zero. A record carrying a secret-shaped identifier is refused by name in a test. - Depends on: 10