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.
Salience, lifecycle, and enrichment wave - one envelope spine, eight tracker units
Status: approved for implementation Author: claude-dev-agent (via feature-release-playbook) Audience: implementation
Problem statement
Eight tracker units touch the same seam from different sides: how model-delegated work enters the vault (needs-llm-step envelopes exist in three divergent shapes with no shared type), which items deserve expensive synthesis, how written memories end their life (no surface can set or change expiration_date, no delete can follow links), and how generated artifacts explain what they rest on (architect output names neither its codegraph grounding nor the decisions behind the code). Each unit alone would add one more divergent shape or one more ad-hoc validator; together they justify building the shared pieces once.
Scope
- Unit 0 (spine, new): a named
NeedsLlmStepenvelope core insrc/core/brain/llm-step.tsshared by every model-delegation lane, adopted additively - the existing diarization and rollup shapes re-declare against it without behavioral change; the durable write-session envelope is documented as the durable superset and is not rewritten. Beside it, a semantic-checker registry (src/core/brain/response-checks.ts) for payload constraints the deliberately-shallowShapeDescriptorlanguage cannot express (cardinality, cross-item rules), following the precedent of the research citation set-membership check. - Unit 1 (t_de8a0b2d): a deterministic salience gate over the rollup ladder's fold set. Scorer combines decayed salience mass (
lessons.ts), Wilson-bound confidence (confidence.ts), and observed reuse (observed-use.ts); threshold lives inBrainDreamConfig; items below threshold are excluded from rollup envelopes and reported by name in the dream summary (never silently dropped). Aretriageaction on the dream bundle verbs re-runs the gate after a threshold change and reports the delta before apply. - Unit 2 (t_1dace26d): a new batch verb
o2b brain extract-signals <session>(CLI + MCP) that reads imported session turns and emits one spine envelope; the returned payload is validated by a newShapeDescriptorplus a semantic check (per-session cap, confidence floor); accepted items are written as speculative inbox signals with new closed-vocabularysource_type: "auto_extract", subject to the durability denylist, staged throughBrain/pending/whenever write approval is enabled, and never written as confirmed preferences.import-sessionitself stays byte-identical. - Unit 3a (t_5e338af1):
--delete-linkedon note delete. Blast-radius rule adopted verbatim fromdeleteBySource: only single-purpose derived files whose references trace solely to the deleted note are deleted; every other inbound reference is reported, never repaired. Full destructive ladder: dry-run default, explicit confirm, count guard, snapshot gate,destructive-sites.tsentry. - Unit 3b (t_5e338af1): optional free-form
guidanceonWriteCaptureInput, participating in the capture id hash, rendered as a## Guidancebody section; plus the minimal ingress the field needs to exist: a CLI capture verb (o2b brain capture) exposing body, source, sender, and guidance - todaywriteCaptureNotehas exactly one caller (telegram) and no operator-facing entry. - Unit 3c (t_5e338af1): expiration, both halves of the double gap: creation-time
--expires <date>/expiresparameter on the feedback surfaces (CLI verb and MCP tool) for signals and preferences, and post-creation mutation via a dedicated lifecycle action that rewritesexpiration_date- both routed throughnormalizeExpirationDateas the single validation chokepoint. Clearing is explicit (--expires none), never an empty-string side effect. - Unit 4 (t_abaec26b): a new
mature_pagepattern kind in the existingskill-proposals.tspipeline. Maturity gate: the page-meta trio (tier, lifecycle non-stale, confidence) as the cheap filter, observed reuse rates as the evidence floor; skill-usage acts as a negative signal (do not draft what an installed skill already covers). Drafting emits one spine envelope per candidate page; the validated draft is staged as a pending proposal (inside the vault); accepting materializesSKILL.mdunder the configured skills root - the only out-of-vault write, and only on explicit accept through the existing WAL-protected path. - Unit 5 (t_3a418d07, descoped): a new
codegraphsentinel region in the architect overview stamping the graph verdict from the existing partner report:graph-presentwith node/edge counts and health, orgraph-absent, lexical-only, using the five-stateCodegraphIndexStatevocabulary. No new partner queries. - Unit 6 (t_041c571f): a deterministic Mermaid containment diagram (project to modules, file counts, dominant language;
compareStableordering) in a new architect overview region, and a key-decisions note built from repo-scoped ADR candidates (Brain/decisions/candidates/filtered byrepo_key, the join key architect already derives). Both regions are declared exceptions to the unchanged-project byte-identity guarantee, stamped from vault state that can move independently of the repo. - Unit 7 (t_c87644b4, trimmed): a one-shot
o2b brain design-note <topic>verb (CLI + MCP), diarization-shaped: read-only grounding pass over tension, decision, and truth records (topic matching reused fromdeepSynthesis), one spine envelope, payload validated to carry named alternatives with exactly onerecommended: true- the cardinality enforced by a semantic check in the new registry. The note lands beside panel outputs underBrain/decisions/. - t_916f9953 (explicit refusal, no code): the local transformer embedding provider is refused for this wave. Rationale below under Design decisions.
Out of scope
- An LLM-based salience scorer and its verdict cache. The deterministic gate serves the card's purpose (do not spend synthesis on junk) with zero added round trips and keeps the kernel model-free; if a model scorer is ever wanted it plugs into the same threshold seam.
- Rewriting the write-session kernel onto the spine type. Adoption is additive; the durable envelope keeps its superset fields.
- A partner query surface for codegraph (symbols, call edges).
CODEGRAPH_CLI's four tokens remain the entire surface; citing real symbols in architect output is a separate decision with its own risks. - Import-graph analysis in the architect scanner. The Mermaid diagram shows containment, which is what the scan truthfully knows; the design-doc exclusion in
scan.tsstands. - A transformer/ML runtime in any form, including a registered provider name without a working backend - a name that cannot embed is a stub, and stubs are forbidden here.
- Generalizing
skill-proposals.tsinto a universal speculative-artifact pipeline (consultant Variant C). The 51KB WAL-protected module is extended with one pattern kind, not refactored.
Chosen approach
Consultant Variant B, "Shared envelope spine, additive adoption", with two orchestrator amendments. First deliverable is the spine: one named envelope core plus a semantic-checker registry beside response-shape.ts, keeping ShapeDescriptor deliberately shallow. Every new model lane in the wave (auto-extraction, skill drafting, design notes) plugs into that spine; legacy shapes alias it without rewriting. Deterministic units (salience gate, delete-linked, capture guidance, expiration, codegraph verdict region, Mermaid and decisions regions) proceed independently of the spine. Amendment one: the salience gate ships deterministic-only - the consultant kept an optional LLM retriage lane, which this wave drops as unnecessary complexity. Amendment two: unit 5 in the consultant's numbering (the transformer embedder) is refused rather than shipped as a seam, because a seam without a runtime is a stub.
Design decisions
- One envelope grammar, additive adoption. Three shapes sharing field names without a shared type is the named DRY debt; this wave would otherwise raise the count to six. Aliasing rather than rewriting keeps the riskiest surface (durable write-sessions) read-only.
- Semantic checks live beside
ShapeDescriptor, not inside it. The descriptor language is shallow by recorded design ("over-constraining an extraction payload degrades recall"); cardinality rules like "exactly one Recommended" get a dedicated fail-closed checker registry, as the research citation contract already does ad hoc. - The salience gate is deterministic. All three inputs (decayed mass, Wilson-bound confidence, reuse rate) already exist as pure functions; recomputation is free, so no cache, no prompt version, no second envelope. Excluded items are always named in the summary - a gate that drops silently is the misleading fallback this project forbids.
auto_extractis a newsource_typemember, not a reuse ofextracted.extractedmeans deterministic regex extraction; a model-authored signal must be distinguishable forever, because its trust profile differs. The vocabulary is closed and fail-closed; every consumer switch is updated in the same commit.- Auto-extracted signals obey precision-beats-recall. Confidence floor and per-session cap are enforced in the semantic check (refusal names the limit); the durability denylist applies; write-approval staging applies when enabled. The inbox trial lane plus dream promotion remains the only path to a confirmed preference.
- Delete-linked adopts the solely-derived rule. The
notes/lifecycle.tsheader commitment (a delete reports inbound links, never repairs them) stands: linked notes that merely reference the target are still reported. Only single-purpose derived files tracing solely to the deleted note join the deletion set, mirroringdeleteBySource, and the whole set passes the count guard and snapshot gate as one destructive site. - Guidance joins the capture id hash. Two captures differing only in guidance are different captures; excluding the field would silently collapse them into the
-2allocator. - Expiration has one chokepoint. Both the creation flags and the mutation action call
normalizeExpirationDate; a path that bypasses it would recreate the fail-open corruption the read side deliberately tolerates only because writes were assumed validated. - Skill drafts stage inside the vault, materialize outside on accept.
skills_dirmay point outside the vault; every automatic write stays inBrain/skill-proposals/pending/, and the one out-of-vault write happens on explicit accept through the existing WAL. - Architect regions may be stamped, byte-identity exceptions declared. The codegraph verdict and decisions regions depend on vault and partner state that moves independently of the repo; each region carries the stamp that explains its provenance (counts, health, candidate set), and the generator docstring names them as declared exceptions.
- t_916f9953 is refused. A written invariant ("no new npm dependencies and NO ML runtime... the feature is redesigned in the OSB idiom, not the dependency added") stands against it; the lexical
LocalProvideralready gives key-less installs a working recall path; and the two honest alternatives - shipping a runtime, or registering a provider that cannot embed - are respectively an invariant break and a stub. The refusal, with this rationale, is the card's requested "explicit refusable choice". Revisit only if the invariant is deliberately lifted.
File changes
- New:
src/core/brain/llm-step.ts(spine type + builder),src/core/brain/response-checks.ts(semantic-checker registry),src/core/brain/salience-gate.ts,src/core/brain/extract-signals.ts,src/core/brain/skill-page-drafts.ts(mature-page mining, folded into skill-proposals surface),src/core/brain/design-note.ts,src/cli/brain/verbs/{extract-signals,capture,design-note}.ts, MCP tool modules or extensions for the three new tools, architect region renderers forcodegraph,module-map, decisions note. - Modified:
diarization.ts,rollup-ladder.ts(alias spine),dream.ts/dream-apply.ts/dream-types.ts/dream-gates.ts/dream-stage.ts/verbs/dream.ts(gate + retriage),sessionstypes (source_type),signal.ts/preference.ts(expires plumbing),verbs/feedback.ts+feedback-tools.ts(expires flags),notes/lifecycle.ts+lifecycle-file-tools.ts+verbs/note-lifecycle.ts(delete-linked, expiration action),capture/capture-note.ts(guidance),telegram-capture.ts(pass-through),skill-proposals.ts(+ pattern kind, SKILL.md materializer),architect/generate.ts(+ regions),response-shape.ts(descriptors),destructive-sites.ts,state/surfaces.ts,brain.tsdispatch,help-text.ts,command-manifest.ts,brain-tools.ts. - Docs: README section, CHANGELOG 1.51.0, this brainstorm directory.
Risks and open questions
- The wave is large (nine implementation units); mitigation is strict TDD per unit, atomic commits, and unit independence outside the spine dependency (units 2, 4, 7 of the numbered scope block on unit 0 only).
- The spine must generalize three existing shapes and three new consumers at once; a wrong generalization is expensive later. Mitigation: the spine carries only the fields all six share (
status,step,prompt,schema_hints,target_path); everything else stays on the consumer's own type. source_typewidening changes the on-disk shape of a signal; the parser already fails closed on unknown members, so older readers refuse loudly rather than misread - acceptable and documented in the CHANGELOG.- The delete-linked derived-set computation must not confuse "references the note" with "derives solely from the note"; the deleteBySource fold is the tested template and its blast-radius tests are the model.
- Whether
resolveNoteTarget's Brain-root refusal needs a scoped exception for the expiration mutation on signals/preferences - settled during implementation by routing the mutation through the feedback surface instead of the note-lifecycle surface if the refusal is load-bearing.