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

Variants - session mining economy

Consultant output (docs/brainstorm/session-mining-economy/cli-output/claude.md) reproduced verbatim, followed by the orchestrator decision.

Variant 1: Seam extension - one ledger, one mode, one server

  • Approach: Every card becomes a strict extension of a mechanism Open Second Brain already ships. The session import ledger in src/core/brain/sessions/discover.ts gains a mining outcome per entry (a schema version bump): the same hashFile content hash that already keys the ledger keys the tombstone, so a changed session stops matching and re-mines for free, recordSessionImports' locked atomic write and vanished-path pruning carry over, the write happens only on the commitExtractedSignals path when zero items were written (keeping the deduped already-known and durability-rejected barren outcome classes apart), and planExtractSignals consults the entry before building the envelope, answering a typed suppressed verdict rather than an ExtractSignalsError so an adjudicated-barren session is not reported as a failure. The recall gate becomes a versioned off | shadow | enforce knob beside retrievalTrustGateEnabled in ResolvedRecallConfig (shadow the shipping default), realized as an edge-level adjuster inside runRelationalArm that reuses trustGateAdjuster's rank-adjust verdict vocabulary and classifies each RelationalPathStep edge deterministically - grounding band from truth/grounding.ts, query-time validity via parseValidityWindow (the same grammar closedSupersessionTip already reads), relation polarity, asserted provenance from the claim ledger - counting refusals under fixed reason tokens like RETRIEVAL_TRUST_EXCLUSION_REASON, with ungrounded claims reported into a durable extraction-refusals record following the UngroundedStatedClaim precedent in truth/stated-claims.ts. The console is new routes on buildLiveServer (live counts from discoverSessions coverage and the mining ledger, recall views over recall-telemetry.ts and report-snapshot.ts deltas, an ops route over the brain status snapshot), keeping the loopback-only, read-only, per-GET re-read invariants, and the SessionStart nudge is a throttled count over the ledger beside the existing hooks/hooks.json injection with a last-offered stamp in the derived store.
  • Trade-offs:
    • Pros: honors the reuse constraint literally (trustGateAdjuster, not a parallel gate); tombstone invalidation falls out of the content hash the ledger already computes; one state file, one lock, one serialization idiom per concern; byte-identical off paths are the existing gates' own contract, and the cache-slot already records whether the gate ran so a shadow receipt cannot be served as an enforced result.
    • Cons: a schema version bump on a shipped ledger is the wave's riskiest single edit, since readSessionLedger hard-refuses unknown schemas and every reader must move together; planExtractSignals gains a second class of non-error outcome the three existing refusal throws do not anticipate, so the suppressed verdict needs its own typed shape; mining state lives on a ledger whose discovery report is contractually read-only, so the write must stay on the commit path and nowhere else.
  • Complexity: medium
  • Risk: low

Variant 2: Receipt-persisted economy

  • Approach: Treat the wave's cross-run state as persisted receipts rather than a new ledger. The receipt vocabulary Open Second Brain already emits - retrieval_decision_trace, memory_trust_assessment, reconciliation reports, dead letters - gains durable per-run persistence in the derived store: a mining commit appends a receipt carrying its outcome counts, the shadow gate appends per-query refusal counts with reasons, and each distill proposal appends an asked-once record. planExtractSignals then consults accumulated receipts for the session's current content hash, the console becomes a viewer over the receipt store, and the SessionStart count and its throttle read receipt aggregates.
  • Trade-offs:
    • Pros: one observation channel for everything the wave surfaces, so console, counts and refusals render exactly what the flows already emit; no schema change to any shipped ledger; ask-once batching needs no separate state because a proposal is itself a receipt; the shadow mode's measure-only discipline is the receipts' native shape.
    • Cons: receipts are per-response accounting by contract, so deriving tombstone eligibility from them conflates observation with decision state; retention or compaction becomes a correctness knob, where a pruned receipt silently re-admits a barren session; the plan gate must aggregate many receipts to answer one boolean, paying a scan per plan that a single keyed entry avoids; per-query shadow counts accumulate without bound until a policy exists.
  • Complexity: medium
  • Risk: medium

Variant 3: Mining-economy journal

  • Approach: One append-only journal for the whole session-mining economy: mining commits, gate classifications, distill proposals and throttle decisions each append typed events keyed on session content hash, and derived projections answer the wave's four questions - tombstone eligibility, undistilled counts, gate enforcement state, console views. Enforce mode reads the projection at query time, the explorer renders the same projections, and a compaction policy folds event history into snapshot rows.
  • Trade-offs:
    • Pros: the strongest audit story, since every suppression and refusal is a replayable event carrying its reason; projections give the console and the SessionStart count one reader; future economy rules (per-session caps, spend accounting) become new projections over existing events rather than new stores.
    • Cons: introduces an event-sourcing substrate - append, compaction, projection rebuild - that Open Second Brain does not have, where every existing store is a locked read-modify-write snapshot; per-query gate events force a rotation policy that is itself an unresolved design question; the largest surface against the one-PR 40-60 file envelope and the hardest to hold to byte-identical off behavior.
  • Complexity: large
  • Risk: high

Recommended: Variant 1

Rationale: The validator-settled scope already names these exact seams - reuse trustGateAdjuster rather than build a parallel gate, key the tombstone on the hash the session ledger already computes, and fold the console into buildLiveServer - so Variant 1 is the settled scope rendered as code, within the one-PR envelope and with the smallest deviation from shipped behavior. Variant 2 makes a barren session's eligibility depend on receipt retention policy, and Variant 3 buys an event-store substrate this wave neither needs nor could land safely.

Orchestrator decision

Agreed: Variant 1. The recon-verified rescopes for all four cards already name Variant 1's exact seams (reuse trustGateAdjuster, content-hash keying, the console folded into buildLiveServer), so the recommendation renders the settled scope as code with the smallest deviation from shipped behavior; Variant 2 is declined because receipt retention must never decide a barren session's eligibility, and Variant 3 because the project has no event-store substrate and this wave cannot land one safely. One mechanism correction, adopted from the recon over the variant's text as written: the shared mining record is a new separate ledger keyed by the portable sessionId plus a SHA-256 over the mined turn material, not a schema version bump of session-import-ledger.json, because the import ledger's reader silently erases undeclared fields on rewrite, its keys are absolute machine paths with no join back to the mining lane, and the wave's riskiest single edit is an edit the design can simply not make. A second correction per the recon: upstream's shadow-as-shipping-default is not copied - the gate defaults off, and shadow is the default mode only when the gate is enabled without an explicit mode, keeping the repository's every-recall-knob-defaults-off discipline.