Skip to content

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
8.5 KB
Raw Blame

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/timingSafeEqual from node:crypto, explicit N/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 the resolveSecretForExec writer side (last_used_at stamp plus custody audit). Second, lift sealManifest/manifestVerifies (src/core/state/migrate.ts:186-194) into src/core/integrity/digest.ts beside sha256Hex/canonicalJson so 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 the src/core/tags.ts rule and capture refuses an undeclared kind before allocateAndCreate - and cards 5 and 8 extend the existing response envelopes additively (digest_count/divergent on both single-session reads, a note key 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-11 already 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 ordering store.ts:119-124 already mandates.
    • Cons: hard rejection on topic shape breaks live MCP/CLI feedback and any lane that writes brain/topic/foo bar today until callers slugify; rejecting capture kinds in vaults whose packs were authored before brain-capture existed needs a compatibility story for the Telegram lane; the up-front substrate couples the review and landing order of three otherwise independent secrets slices.
  • 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-tags hygiene detector registered through HYGIENE_DETECTOR_IDS (src/core/brain/hygiene/types.ts:12-20) and modeled on detectTags, plus a doctor finding for vaults whose declared page_types omit 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 - leaving brain_session_summary get, 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:179 stays 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.ts KDF/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 composes parseSecretReference with a read-oriented decrypt over the custody store and threads resolved literals into EGRESS_REDACTION_OPTIONS/redactConfigMapping so redactKnownSecretValues finally gains production callers; likewise one sealWithDigest/digestVerifies lift into src/core/integrity/digest.ts under cards 7 and 9. Enforcement is tiered by blast radius: card 4 rejects caller-controlled extraTags and slugify-or-rejects topic inside the composers (consuming the rule from src/core/tags.ts, never a copy), while card 6 fails open on absent config per the readSchemaPackSource substitution precedent (schema-pack.ts:56) and rejects an undeclared kind only when a pack explicitly declares page_types, with an opt-in hygiene detector as the companion for existing vaults; lock/unlock stays off MCP per the brain_secrets set/get refusal (admin-tools.ts:295-299). Cards 5 and 8 extend the existing envelopes additively with named tokens - digest_count, conditional divergent plus an id/hash list rather than full echoes to respect MCP_PREVIEW_BUDGET, a summary-divergent-style reason token in the payload_mismatch/coverage-divergent grammar, and a note key on the CLI envelope when the shared payload parser stripped a think block - and fold the pre-existing CLI serializer drift (missing project) 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_SITES declaration (ciphertext defeats both sharedRedactor and noVaultContent as-is) remain open decisions inside otherwise-settled slices.
  • 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.