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.
Trust-Surface Hardening — variants
The three variants below are reproduced verbatim from the consultant reply stored at cli-output/consultant.md (see the provenance note at the end for why that file and not claude.md).
Variant 1: Substrate-first consolidation (shared crypto and seal modules, reject-at-write)
- Approach: Sequence the wave around two shared modules built before their consumers. First
src/core/brain/secrets/envelope.ts: the scrypt KDF (scryptSync/timingSafeEqualfrom node:crypto, explicitN/r/p/maxmem, random salt, parameters recorded inside a versioned envelope, wrong-passphrase detected by the GCM tag), the wrapped-keyfile format that replaces the raw 32-byte keyfile on opt-in (card 1), and the bundle envelope of card 3; card 2 then routes through the same substrate's decrypt with a read-only resolve variant so$secret:resolution avoids theresolveSecretForExecwriter side (last_used_at stamp plus custody audit). Second, liftsealManifest/manifestVerifies(src/core/state/migrate.ts:186-194) intosrc/core/integrity/digest.tsbesidesha256Hex/canonicalJsonso both adoption-plan seals (card 7) and the extraction-contract fingerprint (card 9) pass through one primitive. Cards 4 and 6 reject at write time - the composers refuse tag values failing thesrc/core/tags.tsrule and capture refuses an undeclared kind beforeallocateAndCreate- and cards 5 and 8 extend the existing response envelopes additively (digest_count/divergenton both single-session reads, anotekey on the CLI{ ok: true }envelope). - Trade-offs:
- Pros: one spelling of the KDF and one of the seal matches the DRY posture
src/core/tags.ts:8-11already demands of the tag rule; card 3 shares the KDF with card 1 by card statement, so the substrate is load-bearing rather than speculative; rejection-before-allocation reuses the existing typed-refusal shapes (CaptureContractError,SchemaVocabularyError) and the guard orderingstore.ts:119-124already mandates. - Cons: hard rejection on topic shape breaks live MCP/CLI feedback and any lane that writes
brain/topic/foo bartoday until callers slugify; rejecting capture kinds in vaults whose packs were authored beforebrain-captureexisted needs a compatibility story for the Telegram lane; the up-front substrate couples the review and landing order of three otherwise independent secrets slices.
- Pros: one spelling of the KDF and one of the seal matches the DRY posture
- Complexity: large
- Risk: high
Variant 2: Independent slices (detect-only governance, dedicated divergence surfaces)
- Approach: Ship nine vertical slices with no module extracted first: the wrapped keyfile, the bundles and the resolver each carry their own KDF/envelope code locally with convergence deferred, and cards 7 and 9 implement sealing in place. Cards 4 and 6 are detection-only: an opt-in
frontmatter-tagshygiene detector registered throughHYGIENE_DETECTOR_IDS(src/core/brain/hygiene/types.ts:12-20) and modeled ondetectTags, plus a doctor finding for vaults whose declaredpage_typesomit the kinds the build stamps; no composer or capture writer changes. Cards 5 and 8 add new dedicated surfaces - a session-summary divergences read and a payload-parse diagnostics output - leavingbrain_session_summaryget, the CLI get and the four parse sites byte-identical. - Trade-offs:
- Pros: zero write-path break risk - topics with spaces keep landing, Telegram captures keep flowing, every existing test pin survives untouched; each slice reviews, lands and reverts independently; no read-path consumer or test churn on the current envelopes.
- Cons: three private copies of envelope/KDF code is drift in exactly the layer where a mistake costs credentials, against the wave's own DRY constraint; detection-only leaves the trust surface documented rather than hardened - the silent sorted-last read at
session-summary.ts:179stays silent on the primary surface and the agent must know to call the new one; two new surfaces cost command-manifest, help-text, census and MCP-parity work that additive keys avoid.
- Complexity: medium
- Risk: low
Variant 3: Forced sharing only, tiered enforcement, additive named keys
- Approach: Share exactly what the cards force: one
src/core/brain/secrets/envelope.tsKDF/wrapped-envelope module under cards 1 and 3 (card 3 shares the KDF with card 1 by statement), with card 2 as a separate resolver-plane slice that composesparseSecretReferencewith a read-oriented decrypt over the custody store and threads resolved literals intoEGRESS_REDACTION_OPTIONS/redactConfigMappingsoredactKnownSecretValuesfinally gains production callers; likewise onesealWithDigest/digestVerifieslift intosrc/core/integrity/digest.tsunder cards 7 and 9. Enforcement is tiered by blast radius: card 4 rejects caller-controlledextraTagsand slugify-or-rejects topic inside the composers (consuming the rule fromsrc/core/tags.ts, never a copy), while card 6 fails open on absent config per thereadSchemaPackSourcesubstitution precedent (schema-pack.ts:56) and rejects an undeclaredkindonly when a pack explicitly declarespage_types, with an opt-in hygiene detector as the companion for existing vaults; lock/unlock stays off MCP per thebrain_secretsset/get refusal (admin-tools.ts:295-299). Cards 5 and 8 extend the existing envelopes additively with named tokens -digest_count, conditionaldivergentplus an id/hash list rather than full echoes to respectMCP_PREVIEW_BUDGET, asummary-divergent-style reason token in thepayload_mismatch/coverage-divergentgrammar, and anotekey on the CLI envelope when the shared payload parser stripped a think block - and fold the pre-existing CLI serializer drift (missingproject) into the same wave. - Trade-offs:
- Pros: the only centralized code is the two substrates the cards genuinely share, so review order stays slice-sized; rejection lands where the caller controls the input (extraTags) and where the vault made a declaration (page_types), matching the write-session validator's existing polarity (fail closed on declared-but-unknown at
validate.ts:181, fail open on absent vocabulary) while detectors cover vaults that predate the declarations; additive named keys follow the conditional-key idiom, cannot trip the MCP output contract (the tool declares no outputSchema), and keep byte-identity when inactive. - Cons: three enforcement polarities in one wave (reject-always on extraTags, reject-only-when-declared on capture kinds, detect-only companion) need careful documentation so operators can predict which writes refuse; the resolver's store-lock-on-config-paths question and card 3's honest
EGRESS_SITESdeclaration (ciphertext defeats bothsharedRedactorandnoVaultContentas-is) remain open decisions inside otherwise-settled slices.
- Pros: the only centralized code is the two substrates the cards genuinely share, so review order stays slice-sized; rejection lands where the caller controls the input (extraTags) and where the vault made a declaration (page_types), matching the write-session validator's existing polarity (fail closed on declared-but-unknown at
- Complexity: medium
- Risk: medium
Recommended: Variant 3
Rationale: It centralizes only the two substrates the cards force to be shared - card 3 shares its KDF with card 1 by statement, and cards 7 and 9 both reduce to sha256Hex(canonicalJson(...)) over a canonical body - unlike Variant 1, which couples all three secrets slices up front, or Variant 2, which leaves three drifting copies of credential-critical code. Its tiered enforcement places fail-closed behavior exactly where the repo's own precedents sit (declared-vocabulary rejection with fail-open on absent config, caller-controlled-input rejection at the composers) and covers pre-existing vaults through detectors instead of breaking Telegram capture or live feedback. Additive named keys on existing envelopes are the established house grammar, preserve byte-identity when the features are inactive, and avoid Variant 2's split-surface problem where the primary single-session read stays silent.
Orchestrator decision
Picked: Variant 3 — the consultant's recommendation, accepted without override. The two substrates it centralizes are exactly the ones the cards force to be shared (the secrets envelope across cards 1 and 3; the digest seal across cards 7 and 9), its enforcement polarities sit on the repo's own precedents, and its additive named keys keep every inactive feature byte-identical. The full acceptance rationale is in design.md ("Chosen approach"); the tiered polarities are specified per write site in "Design decisions".
Provenance note. This wave ran in host mode: the external CLI consultant was replaced by an in-session subagent running against the same prompt (cli-output/prompt.md), so the reply is stored at cli-output/consultant.md rather than claude.md. The variants above are that reply, verbatim.