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.
Item 1 / Variant 1: Dedicated spec module beside the other two consumers
- Approach: Add
src/cli/brain/maintenance-cron-template.tsexporting aCronRecipeSpec(title,cronNameosb-maintenance,operatorScriptPath, script body that runso2b brain maintenance run --vault <resolved> [--window H-H --tz ZONE], verify commando2b brain maintenance status), mirroringsearch-cron-template.tsandpartner-codegraph-cron.ts. The verb gains--cron-template [--interval], prints the rendered recipe before any vault or lease work, and mapsCronTemplateErrorto usage exit 2. The Hermes jobs default becomesjoin(homedir(), ".hermes", "cron", "jobs.json")with an optionalHERMES_HOMEoverride. - Trade-offs:
- Pro: identical shape to the two existing consumers, so the lane owner touches only the verb, one new file and the manifest.
- Pro: spec body is unit-testable without the lane; existing reindex fixtures untouched.
- Con: a third near-identical spec file; the three consumers still share nothing beyond the kernel.
- Complexity: small
- Risk: low
Item 1 / Variant 2: Spec inlined in the maintenance verb
- Approach: Build the
CronRecipeSpecinline insidesrc/cli/brain/verbs/maintenance.tswhere the resolved vault,--windowand--tzare already parsed, and callrenderCronRecipedirectly. Same Hermes path fix. - Trade-offs:
- Pro: fewest files; the recipe body sits next to the flags it embeds.
- Con: the verb file is already large and owns exit-code logic; recipe text mixed in hurts readability and the byte-pinned fixture test would import the verb.
- Con: breaks the one-consumer-one-module pattern the other two recipes established.
- Complexity: small
- Risk: low
Item 1 / Variant 3: Generic self-recipe helper on the kernel
- Approach: Extend
cron-recipe.tswithspecFromCommand({cronName, argv, verify})that turns anyo2bargv into a spec, then have all three consumers call it. Maintenance passes its own argv (vault, window, tz). - Trade-offs:
- Pro: removes future duplication for any verb that wants a recipe.
- Con: refactoring the two existing consumers risks the byte-pinned search fixtures and widens the lane's file ownership into files other lanes may touch (item 4 also edits the kernel).
- Con: over-general for a wave whose kernel is already being changed by item 4.
- Complexity: medium
- Risk: medium
Item 1 / Recommended: Variant 1
Rationale: It matches the proven consumer pattern exactly, keeps the byte-pinned search fixtures out of the diff, and stays inside files only this lane owns. Variant 3 collides with item 4's kernel edits in the same worktree; Variant 2 buries operator-facing text in an already dense verb file.
Item 2 / Variant 1: Fault state in src/mcp, installer in src/cli, mirroring the drain split
- Approach: Add
src/mcp/fault-state.tswith a smallFaultCounter(rejections survived, suppressed-by-rate-limit count, last fault summary) thathttp.tsreads into the/healthbody asfaults: {rejections, suppressed}. Addsrc/cli/mcp-fault-guard.tswithinstallMcpFaultGuard({counter, stderr, exit}):unhandledRejectionlogs one named line (o2b mcp: unhandled rejection survived: <message>), rate-limited to N per minute with a periodic "suppressed K more" line;uncaughtExceptionlogs and callsexit(EXIT_FAULT = 70)so WAL checkpoint and lock unlink hooks run.cmdMcpinstalls it next toinstallMcpSignalDrainand uninstalls on normal close. Tests: in-process with injected stderr/exit; spawned-process test runs a tiny Bun script that imports the installer and throws asynchronously, asserting exit 70 and the stderr line (no production inject seam). - Trade-offs:
- Pro: respects
src/mcpnever importingsrc/cliwhile letting/healthsee the count; same seam style asmcp-drain.ts. - Pro: exit via
process.exitkeeps the existing exit-hook ordering guarantee. - Con: two small modules and a shared counter object to thread through
serveHttp. - Con: rate-limit window and cap are new constants to name and document.
- Pro: respects
- Complexity: medium
- Risk: low
Item 2 / Variant 2: Everything inside src/mcp/fault-guard.ts
- Approach: One module in
src/mcpowns the counter, the handlers and the exit call;cmdMcpcallsinstallFaultGuard()andhttp.tsimports the counter from the same module. - Trade-offs:
- Pro: single file, trivial
/healthwiring. - Con: a transport-layer module registering process-global handlers is exactly the "two signal conventions" smell
mcp-drain.tsdocuments avoiding; exit codes would be defined outsidesrc/cli/interrupt.tswhere the project's exit vocabulary lives. - Con: harder to inject
exitfrom a CLI-side test without exporting the seam fromsrc/mcp.
- Pro: single file, trivial
- Complexity: small
- Risk: medium
Item 2 / Variant 3: Extend installMcpSignalDrain to cover faults
- Approach: Widen
McpSignalDrainOptionswith fault handling so one installer registers signals,unhandledRejectionanduncaughtException; on uncaught exception it runs the same drain-then-exit path with code 70. - Trade-offs:
- Pro: one install/uninstall call site, and an uncaught exception could drain in-flight requests before exiting.
- Con: draining after an uncaught exception runs code in a possibly corrupted process; the premise asks for log-and-exit, not drain.
- Con: couples two unrelated concerns in a module whose docblock is precise about its narrow job; existing drain tests must be revisited.
- Complexity: medium
- Risk: medium
Item 2 / Recommended: Variant 1
Rationale: It reproduces the architecture the project already chose for signals, keeps the import direction rule intact, and gives /health the count through a plain shared object. It also avoids draining inside a process that just threw, which is the one behaviour Variant 3 would add that the premise explicitly does not want.
Item 3 / Variant 1: Prefix keys in the install-owned config, shared task builder
- Approach: Declare custom tasks as
maintenance_task_<name>: <shell command>in the flat config file (XDG config dir, never the vault), with the existingsafeguard_timeout_<name>_secondsconvention supplying the per-task deadline. Addsrc/core/brain/maintenance/tasks.tswithbuildLaneTasks(vault, config)returning built-ins plus custom tasks, used by both the CLI verb and the MCP tool; widenLaneTasktostring(keepBUILTIN_LANE_TASKfor the four), validate--retry/retry_tasksagainst the built list and cap at its length. Custom tasks run viashellArgvwith the vault path in env, captured output capped and redacted, non-zero exit or timeout recorded as a named failure. - Trade-offs:
- Pro: reuses the per-operation timeout key pattern and
discoverConfigthat already returns every key; no new file, no new parser. - Pro: removes the CLI/MCP duplication as a side effect.
- Con: name validation (
^[a-z][a-z0-9_-]{0,31}$, no collision with built-ins) and key scanning need tests; a reserved prefix in a flat namespace is slightly implicit. - Con: MCP tool description must be trimmed to mention custom tasks within 300 characters.
- Pro: reuses the per-operation timeout key pattern and
- Complexity: medium
- Risk: medium
Item 3 / Variant 2: Separate install-owned tasks file
- Approach: Read
maintenance-tasks.yamlfrom the same config directory, onename: commandline per task through the existing flat parser; the rest (shared builder, widenedLaneTask, retry validation) as in Variant 1. - Trade-offs:
- Pro: clean separation from the main config; the file's sole purpose is obvious to an operator and to
doctor. - Con: a second discovery path to document, test for env/XDG precedence, and surface in
doctor; more lane-owned files touched (config discovery). - Con: the per-task timeout still has to live in the main config or grow a second syntax.
- Pro: clean separation from the main config; the file's sole purpose is obvious to an operator and to
- Complexity: medium
- Risk: medium
Item 3 / Variant 3: CLI-only custom tasks, MCP keeps built-ins
- Approach: Same prefix-key declaration and shared builder, but the MCP tool passes
customTasks: falsesobrain_maintenanceruns and retries only the four built-ins; the cron lane via CLI is the only runner of operator commands. - Trade-offs:
- Pro: no MCP description change; operator commands never run from an agent-triggered call.
- Con: the two surfaces disagree on what the lane is, and a streak refusal visible in the journal cannot be retried from MCP.
- Con: security gain is nominal since the command source is the install-owned config either way.
- Complexity: small
- Risk: low
Item 3 / Recommended: Variant 1
Rationale: It satisfies the security constraint by construction (commands come only from the install-owned config, never from vault or tool arguments) while reusing two existing conventions, the flat config and the per-operation timeout key. Variant 2 adds a discovery surface for little gain, and Variant 3 leaves the two lane surfaces inconsistent.
Item 4 / Variant 1: Sibling renderer sharing the spec
- Approach: Add
renderSystemdRecipe(spec, interval, opts)besiderenderCronRecipeincron-recipe.ts, reusing the sameCronRecipeSpec, the heredoc script section andparseInterval's human label, but emitting~/.config/systemd/user/<cronName>.serviceand.timerheredocs (OnBootSec/OnUnitActiveSec=<interval>,Persistent=true) plussystemctl --user daemon-reload && enable --now. A--format cron|systemdflag on the three recipe verbs dispatches between the two; defaultcron, unknown value exits with the verb's usage code. - Trade-offs:
- Pro:
renderCronRecipeis not edited, so the byte-pinned search fixtures stay identical by construction. - Pro:
OnUnitActiveSectakes<N>m|h|ddirectly, so the day-bound refusal inparseIntervalis still honoured for consistency without any cron expression math. - Con: the shared script section is extracted into a helper, a small refactor of the existing renderer body.
- Con: three verbs each gain a flag plus a manifest entry; item 1's new verb must adopt it too.
- Pro:
- Complexity: medium
- Risk: low
Item 4 / Variant 2: Format parameter on renderCronRecipe
- Approach: Add an optional
formatargument torenderCronRecipe; whensystemd, swap the crontab and Hermes sections for unit-file sections. Verbs pass the parsed--format. - Trade-offs:
- Pro: one entry point, minimal call-site change.
- Con: branching inside the renderer that the byte-pinned fixtures cover; any slip in the default path breaks them.
- Con: the name
renderCronRecipebecomes misleading.
- Complexity: small
- Risk: medium
Item 4 / Variant 3: Format-agnostic section table
- Approach: Rework the kernel into
renderRecipe(spec, interval, {format})with a per-format table of section builders (cron,systemd), and re-express today's output as thecronentry. - Trade-offs:
- Pro: adding a future format (launchd) is one table entry.
- Con: a wholesale rewrite of the renderer with byte-identical output as the acceptance test, in the same wave where item 1 adds a consumer.
- Con: nothing in scope needs a third format.
- Complexity: large
- Risk: medium
Item 4 / Recommended: Variant 1
Rationale: It leaves the existing renderer path untouched, which is the only way to guarantee the byte-pinned fixtures without a careful diff, and it reuses the spec so each consumer declares nothing new. Variant 2 saves little code while putting the fixtures at risk, and Variant 3 is a rewrite for a format count of two.