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

Guarded host writes and surface sweep - consent ladders and a backup hook for host-config writes, cursor pagination for MCP list tools, a Converse decision-model route, and snooze for the trigger queue

Status: implemented Author: feature-release orchestrator (via feature-release-playbook) Audience: implementation

Problem statement

Five triaged cards ship in one wave on one branch (feat/p4-sweep-guarded-host-writes), one pull request. They form four work clusters:

  1. Host-config write guards (cards t_b6bcd984 and t_f4555087). Three Open Second Brain write lanes modify files that govern an operator's agent client - the install JSON-merge into ~/.gemini/settings.json and peers, brain protect --apply into the project .claude/settings.json, and brain doctor --repair --apply - and none of them renders a diff of the file, asks for consent, or records whether a human confirmed the write. Separately, nothing on the installed hook surface backs up or receipts agent tool writes to host settings files, so one bad agent write silently changes the client's own behavior with no record of the prior state.
  2. Cursor pagination (card t_5198f0c7). Cursor pagination exists on a minority of MCP surfaces while 23 list tools expose limit with no continuation cursor, each hand-rolling its own cap; the result is an inconsistent surface where the same operation (walking a large result set) has a first-class answer on some tools and no answer on the rest.
  3. Decision-model routing (card t_7ff0b101). The decision-model adapter union is exactly systemone | vercel-evaluate | llm-emulation; operators who reach models through a bearer-authenticated Converse-protocol (Bedrock-style) gateway cannot route decision-model calls through it and would have to stand up a separate OpenAI-compatible proxy.
  4. Trigger attention (card t_00e9de6a). Open Second Brain's trigger dismiss silences a finding for a fixed TRIGGER_COOLDOWN_DAYS window regardless of whether the underlying work changed, so a still-broken thing resurfaces on a timer and a genuinely-moved thing stays silent until the clock runs out; there is no "later, but do not lose it" state between open and dismissed.

Scope

  • t_b6bcd984: extend the existing diff-plus-fail-closed-consent patterns to the three unguarded write lanes (install JSON-merge, brain protect, doctor repair) and record the consent verdict in each lane's receipt.
  • t_f4555087: an opt-in, default-off, stdlib-only PreToolUse hook that backs up host settings files (with a receipt line) before an agent file-tool write lands, refusing the write when the backup fails.
  • t_5198f0c7: one shared offset-cursor helper in core, adopted by the 23 censused limit-only list tools per tier, with recorded decisions where a cursor is deliberately not added.
  • t_7ff0b101: a converse decision-model adapter module, preset, threshold profile, egress site and contract-suite route for bearer-authenticated Converse-protocol gateways.
  • t_00e9de6a: a snooze trigger action (bounded window or next refire, whichever comes first) and movement-gated resurrection for dismissed triggers (reopen only on changed sourceArtifacts).

Out of scope

  • The workspace-level chat slice of the upstream honcho PR. Deferred to card t_06d2ffdd (cross-scope reasoned synthesis); no chat tool is added in this wave.
  • The agent_scope gap on brain_agent_diff and brain_writes. Deferred by default: it is a different axis (scope, not pagination), and it belongs to neither lane's file ownership. It may be picked up ONLY if the pagination lane finishes its census early AND the change goes through coerceAgentScope (the one reader, src/mcp/coerce.ts:100-104) with the tests/mcp/agent-scope-matrix.test.ts classification updated in the same commit, so the census keeps it honest. The default is defer.
  • Web and CI changes beyond what the lanes need. The only CI-adjacent artifacts in this wave are the four census tests (updated in-lane) and the committed openclaw bundle (rebuilt by the integrator as the last commit); no workflow, runner or web-surface work is in scope.
  • Bash command classification in the backup hook. The hook matcher is the file-tool family (Write|Edit|MultiEdit|apply_patch); classifying Bash tool_input.command (redirections, cp, tee) is heuristic textual matching the repo elsewhere avoids (hooks/lib/detect.ts insists on structural matching). Recorded as a known gap.
  • Refactoring the existing cursor surfaces - brain_decision action=history, brain_session_expand, brain_search_expand, and the core-only paginateContinuityRecords (src/core/brain/continuity/store.ts:292-303). They are read-only pattern context; their encodings do not change (cursors are opaque to callers and may be persisted mid-walk).
  • The adjacent list ops that have neither limit nor cursor (brain_calendar list, procedure lists, entity list, brain_trigger list). Recorded as a follow-up gap; a sweep that only fixes limit-only tools does not claim to have fixed result-walking everywhere.
  • Declaring outputSchema for the 23 adopting tools. None declares one today; adding 23 output schemas multiplies review surface and trips the no-union-type vocabulary. next_cursor is added to payloads without new outputSchemas - a conscious, uniform scope decision.
  • CLI parity surfaces for the new MCP cursors (src/cli/brain/verbs/decision.ts:321 and src/cli/search/verbs/expand.ts:81 already surface next_cursor; new MCP-only cursors may draw follow-up CLI expectations). Noted for a follow-up, not built here.
  • The acted cooldown window, the brief's delivered re-surface clock (briefTriggers, store.ts:1092-1098), and suppress semantics (deliberately clockless, terminal, unsuppress is its only exit). Untouched.

Chosen approach

Variant 3 from the consultant review: cluster-honest sharing with a sequencing contract. The full variant text is in variants.md beside this document.

Machinery is shared only where several real call sites already exist inside one surface, and cross-surface agreements are pinned as contracts instead of imports:

  • Inside the trust lane (t_b6bcd984 + t_f4555087), the first commit pins the shared conventions - the consent vocabulary (confirmed, refused, headless-refused), the receipt-line schema (actor, pid, before-hash, summary plus a per-lane tail), and the timestamped backup-folder layout - and moves renderUnifiedDiff to a core leaf. The three write lanes (install JSON-merge, protect, doctor repair) consume those conventions directly; the standalone PreToolUse hook is pinned to the same receipt contract by a fixture test rather than an import, so the hook stays stdlib-only.
  • Inside the pagination lane (t_5198f0c7), the first commit extracts one pagination helper in core, standardizing on the required-next_cursor precedent, and the 23 tools adopt it per tier.
  • After those two lane-internal commits, all lanes run in parallel under one ordering rule inside the trust lane (on the shared write path: consent, then backup, then write).
  • The Converse adapter lane and the trigger lane share nothing with the others: the adapter composes the existing transport helpers beside vercel-evaluate, and the trigger lane touches only the trigger store and its CLI/MCP projections.

Design decisions

  1. The consent ladder is fail-closed on --json/non-TTY, copying the canonical pattern at src/cli/brain/verbs/upgrade.ts:119-137: without --yes, a --json or non-TTY stdin call refuses (naming --yes and the non-interactive mode); with a TTY it prompts once y/N via readSingleLine. Applied to install --apply, protect --apply and doctor --repair --apply. A consent gate sits above the write guard and never gates dry runs (src/core/brain/applier-capability.ts header; diagnostics.ts:1490-1495 convention).
  2. Consent composes with the existing drift guard, never replaces it: the _json-mcp.ts refusal of drifted config (src/core/install/adapters/_json-mcp.ts:328-349) still fires on an explicit yes, and its refusal still names its remedy. The three lanes keep their distinct no-semantics (install aborts the target, protect refuses the apply, doctor skips per fix) rather than one flattened gate.
  3. MCP brain_doctor apply: true stays machine consent: no new required argument (that would break agents mid-flight and drift the tool description quoted in host listings). The MCP path records verdict provenance caller-apply in the doctor-repair event body; CLI paths record yes-flag or interactive-yes.
  4. Receipts are per-lane and stay in each lane's existing receipt channel. Doctor repair has a Brain typed log event: its body (src/core/brain/diagnostics.ts:1542-1546, kind doc src/core/brain/types.ts:496-506) gains a consent field. Install and protect keep no event log at all: their receipts are the CLI apply JSON payloads (additive keys under INSTALL_JSON_SCHEMA_VERSION = 1) and the install sidecar manifest. The consent verdict does NOT go into the sidecar manifest - it is a schema'd sidecar with applied_at semantics (src/core/install/adapters/_json-mcp.ts:363-377); the verdict belongs in the CLI JSON receipt.
  5. The PreToolUse host-settings backup hook is opt-in with default OFF via resolveConfigFlag in src/core/config.ts (env OPEN_SECOND_BRAIN_HOST_SETTINGS_BACKUP overriding the host_settings_backup config key, beside resolveHookStrictEnabled at lines 1597-1603), and stdlib-only: the hook wrapper imports no core module, so a broken or absent core install cannot turn a failed backup into a failed hook load. Because the scripts/o2b-hook dispatcher is deliberately fail-soft (suppresses non-zero exits, always exits 0), the deny channel is stdout hookSpecificOutput.permissionDecision: "deny" (the emitPermission pattern, hooks/pretool-orient.ts:127-136), and the honest limitation - no deny at all when bun or the hook script is missing - is documented in the hook docblock and hooks/README.md.
  6. Trust-lane sequencing: conventions and the diff leaf land first, then the three write lanes, then the backup hook. On the shared write path the order is consent, then backup, then write; a refused consent must not leave a backup file.
  7. The pagination helper lives in core (src/core/brain/offset-cursor.ts) and the 23 censused limit-only tools adopt it per tier: 12 Tier-A ordered logs get full cursor walks; 9 Tier-B diagnostics get either a cursor (where the output is an ordered walk, brain_session_grep) or a recorded report-cap decision written beside the census tests; 2 Tier-C ranked retrieval (brain_search, brain_file_context) stay limit-only with the ranking-stability rationale pinned as a census entry. The canonical encoding is the receipts.ts:515-531 base64url form (the oldest, already malformed-cursor-tested); existing encodings on decisions history, session expand and continuity do not change.
  8. next_cursor is present in every adopting tool's answer, null when exhausted - the required-field treatment of brain_search_expand is the precedent, because an optional field some tools omit recreates the inconsistency this card exists to remove. Existing count fields (total, returned, total_pages) are kept; the new field is additive.
  9. The four census tests - tests/mcp/agent-scope-matrix.test.ts, tests/core/architecture/visibility-surface-census.test.ts, tests/core/brain/continuity/reader-census.test.ts, tests/mcp/maintenance-parity-census.test.ts - are updated in the SAME commits that change the surfaces they census. A census update deferred to a later commit is a broken bisect and a failed review.
  10. The openclaw bundle (openclaw/index.js, a committed build artifact that transitively embeds EGRESS_SITES) is rebuilt by the integrator as the LAST commit after any src/ edit, so the CI bundle diff passes exactly once.
  11. The trigger snooze window is a TRIGGER_SNOOZE_DAYS constant beside TRIGGER_COOLDOWN_DAYS (src/core/brain/triggers/store.ts:60-62), not a config key in this wave: Lane A owns src/core/config.ts and no other lane touches it. A config key is a recorded follow-up.
  12. Settled trigger semantics: snooze wakes at window end or next refire, whichever comes first (refire read from the existing recordRecurrence ledger as lastSeenAt > snoozedAt, which requires blockReason to keep returning a reason for snoozed twins so the ledger keeps stamping); a dismissed twin reopens only on changed sourceArtifacts (an order-insensitive set comparison following the deriveDatasetHash convention, src/core/brain/derived-artifact.ts:44 - movement is the detector firing on different artifacts, never lastSeenAt alone); suppress stays clockless; snoozed joins the terminal status partition (mirroring suppressed, so the brief allow-list excludes it with zero brief changes and the TTL expiry clock never governs the snooze wake); resurrection arrives as a new pending record through createTriggersLocked, never as a status flip of the resolved record.
  13. Lane file ownership is disjoint and listed under File changes; src/core/config.ts is owned by Lane A only.

t_b6bcd984 - diff and consent before host-config writes

Card ask. Flows that modify an operator's client configuration should print the exact planned edits one line each plus a unified diff of the file, ask once for confirmation, write nothing without an explicit yes (and nothing at all when headless without --yes), and record the consent verdict in the receipt. The card names three Open Second Brain lanes: install (JSON-merge into ~/.gemini/settings.json and peers), brain protect --apply (project .claude/settings.json), and brain doctor repair.

Premise verdicts (recon-verified against this worktree).

  • CONFIRMED - the three lanes are unguarded. parseInstallArgs (src/cli/install/install.ts:97-136) has no yes flag at all and runTarget applies at 407-419 with no gate, including under --json/non-TTY; the protect verb (src/cli/brain/verbs/protect.ts:28-45) applies with no --yes, no TTY check, no diff; the doctor verb (src/cli/brain/verbs/doctor.ts:151-165) runs --repair --apply with no gate; the MCP brain_doctor repair+apply (src/mcp/brain/health-tools.ts:96-119) writes on apply: true with nothing further.
  • CORRECTED - the card's "would fix"/"fixed" anchor (doctor.ts:283-294) is the [WARN] loop of plain doctor. The repair renderer is renderRepair at src/cli/brain/verbs/doctor.ts:386-418 (verb line 392, the validator's corrected anchor).
  • CORRECTED - the install drift guard anchors moved: the guard condition is src/core/install/adapters/_json-mcp.ts:328-340 with the InstallError (user-modified-block) thrown at 341-349; the apply write is at 353-361 (mergeMcpServers then atomicWriteFileSync), unconditional on any consent and stopped only by opts.dryRun; the plan() preview is one summary line at 296-312, no file diff.
  • CORRECTED (scope kept) - doctor repair is NOT a host-config write: applyRepair fixes vault content (WAL files and Brain page frontmatter; fixers at diagnostics.ts:1107-1156 and 1158-1262). The lane stays in scope - the consent gate and receipt verdict apply cleanly - but the "host settings diff" framing fits install and protect only.
  • REFUTED - the card's "not found: unified-diff preview or fail-closed consent" claim is overbroad. renderUnifiedDiff ships at src/cli/brain/upgrade-render.ts:65-88; fail-closed --yes ladders ship on six verbs (upgrade.ts:119-137; state.ts:165-180 and 260-271; rollback.ts:162-175; lint.ts:25-26; page-dedup.ts:107-108; import-claude-memory.ts:106-116); a second consent family (--apply --confirm "<phrase>") exists on orphan-repair, forget-source and knowledge-pack uninstall. Real scope is extending these patterns to the three named lanes.
  • CONFIRMED WITH NUANCE - "nothing distinguishes a confirmed write from an automatic one in the event log": the doctor-repair event body is {code, target, detail, agent} with no consent field (src/core/brain/diagnostics.ts:1542-1546). The nuance: install and protect keep no event log at all, so their receipts are the apply JSON payload (renderApplyJson, src/cli/install/render.ts:172-174), the protect JSON (verbs/protect.ts:30-37) and the sidecar manifest (recordEntry, _json-mcp.ts:369-377).
  • CONFIRMED - protect's own-write backup exists: ${dest}.bak.${Date.now()} written before the settings write (src/core/brain/protect.ts:503-507). It stays untouched beside the new consent convention.

Settled design. Pattern to copy end to end: src/cli/brain/verbs/upgrade.ts (flag parse 56-72, plan/dry-run split 100-103, fail-closed check 119-123, interactive y/N 124-136 via readSingleLine, src/cli/brain/rollback-prompt.ts:50-72).

  • Shared renderer: move renderUnifiedDiff (src/cli/brain/upgrade-render.ts:65-88, dependency-free, no callers outside cli/brain) to a core leaf (src/core/diff.ts) with a re-export kept at upgrade-render.ts so upgrade/rollback keep working.
  • Install lane: InstallStep gains optional diff?: string (src/core/install/types.ts:77-81, additive); _json-mcp.ts plan() (296-312) reads the on-disk raw file, computes mergeMcpServers (pure, no write) and renders a diff - compute before write, apply path (353-361) unchanged; src/cli/install/install.ts adds yes to parseInstallArgs and the gate in runTarget before adapter.apply, with the refusal exit code pinned against the documented INSTALL_EXIT 0-5 table (install.ts:16-29); src/cli/install/render.ts prints the diff in plan output and adds the consent verdict key to apply JSON, additive under INSTALL_JSON_SCHEMA_VERSION = 1 (the file's own convention, render.ts:31-63); tests/cli/install-json-shape.test.ts pins the new key set; install/*.md documents --yes.
  • Protect lane: split applyClaudeCode (src/core/brain/protect.ts:468-516) into a compute step returning {before, after, changed} and the write; same for the codex fence path (540+). Scope grew in review: unprotect (518-538) started out of scope but joined the consent lanes in the review round, mirroring applyProtect (ladder, backup, receipt). src/cli/brain/verbs/protect.ts adds --yes, the ladder before applyProtect, the diff render, and the consent key in JSON; help surfaces: src/cli/brain/help-text.ts:73 and src/cli/command-manifest.ts (protect flags, ~335).
  • Doctor repair lane: the ladder in verbs/doctor.ts (151-165; lint.ts:25-26 is the closest compact pattern); a consent option threaded through ApplyRepairOptions (diagnostics.ts:1384-1428); the event body at diagnostics.ts:1542-1546 gains the consent field (yes-flag | interactive-yes; MCP passes caller-apply), with the kind doc updated at src/core/brain/types.ts:496-506; optional Fixer.preview(vault, item): {before, after} | null on both fixers (walGap 1107, orphanedReference 1158) rendered by renderRepair under the existing dry-run path, no new flags; MCP tool description (health-tools.ts:396-397) updated, no new required args.

Feature-specific risks. The deliberate headless break: install/*.md documents o2b install --target X --apply as the copy-paste command and install --check recommends the same repair command (render.ts:93-101), so that exact command refuses under CI/non-TTY after the gate; no internal cron or self-heal caller invokes these lanes (verified against cron-recipe.ts, maintenance-cron.ts, templates, install docs), so the blast radius is user scripts - named in CHANGELOG. The exit-code contract: a consent refusal needs a code that is neither usage (2) nor a collision; pinned in tests. --yes alone, not upgrade's --yes + --approval-digest pair (upgrade.ts:145-161): the plan digest makes sense where a plan can move, and here the gate reads and applies in the same run. Diff readability: minified settings files yield one-line diffs - verify on a real-shaped fixture and consider the merged-file formatting rather than diffing raw minified bytes.

t_f4555087 - back up host settings before agent tool writes

Card ask. A fail-closed PreToolUse gate that fires on file-tool calls targeting the host client's personal settings files: it resolves tilde, relative paths and symlinks, copies the file into a timestamped backup folder, appends one receipt line (actor, pid, before-hash, summary), and only then allows the write - a failed backup refuses the call. Upstream is fail-closed and stdlib-only and never overwrites a same-second backup; the Open Second Brain version is an opt-in extra entry in hooks/hooks.json.

Premise verdicts (recon-verified).

  • CONFIRMED - deny rules cover only Brain dirs plus the brain config: buildProtectRules at src/core/brain/protect.ts:109-130 (Brain/preferences/**, Brain/retired/**, Brain/log/**, Brain/.snapshots/**, brainConfigPath(vault); allow Brain/inbox/**). Nothing outside the vault is covered.
  • CONFIRMED - the only shipped PreToolUse handler gates the first raw vault read for orientation, not writes: hooks/pretool-orient.ts:3-9, registered at hooks/hooks.json:105-117 (matcher *, command o2b-hook pretool-orient).
  • CORRECTED (detail; essence holds) - hooks/hooks.json registers nine event families (PostToolUse, SessionStart, UserPromptSubmit, PreToolUse, Stop, SubagentStart, SubagentStop, SessionEnd, PostCompact), not just the three the card lists. The load-bearing claim holds: the PreToolUse section contains exactly one entry (orientation), and the PostToolUse Write|Edit|MultiEdit|apply_patch matcher (line 16) runs only post-write-reminder and subagent-inject - no backup.
  • CONFIRMED - nothing backs up or receipts tool writes to ~/.claude/settings*.json: the only settings.json hits in src and hooks are install adapters resolving their own declared targets and protect writing the vault's own .claude/settings.json. No host_settings concept exists anywhere.
  • CONFIRMED AS FEASIBLE WITH A CAVEAT - the fail-closed shape is buildable from in-repo parts, but scripts/o2b-hook is deliberately fail-soft (suppresses non-zero hook exits, always exits 0), so the OSB hook must deny via stdout JSON (permissionDecision: "deny"), not exit codes, and cannot deny at all when bun or the hook script is missing entirely.

Settled design.

  • Pure decision core (new src/core/brain/pretool-host-backup.ts, no IO beyond realpath/stat; precedent src/core/brain/pretool-orient.ts with pure decideOrient at line 125): decideHostBackup({runtime, toolName, toolInput, home, now}) - tilde expansion, cwd-relative join, realpathSync canonicalization, and the protected-path predicate (~/.claude/settings.json, .claude/settings.local.json and peers; .codex/config.toml is deliberately excluded because protect's own fence manages it - avoid double-guarding a file Open Second Brain itself edits).
  • Fail-closed backup executor: compactRunStamp (src/core/brain/time.ts:129-137, UTC YYYY-MM-DD-HHMMSS) into a timestamped backup folder, atomicCreateFileSyncExclusive (src/core/fs-atomic.ts:467) with the collisionCandidateName bounded-attempt allocator (src/core/brain/paths.ts:980) so a same-second backup is never overwritten, atomicWriteFileSync (src/core/fs-atomic.ts:145) for the copy; the snapshot-gate.ts docblock states the semantics - if the snapshot cannot be written, the write never proceeds. Receipt: one appendAuditRecord (src/core/reliability/audit.ts:30-39, JSONL, redacted, mode 0600) at hookAuditDir(vault) (src/core/brain/paths.ts:109) carrying actor, pid, before-hash (node:crypto), summary.
  • Hook wrapper (new hooks/pretool-host-backup.ts, copied structurally from hooks/pretool-orient.ts): the opt-in flag is checked FIRST so the off path is a byte-identical no-op with no process ceiling and no payload read; then armProcessCeiling (hooks/lib/process-ceiling.ts), readHookInput/asHookPayload (hooks/lib/stdin.ts), decideHostBackup, and deny via emitPermission (hooks/pretool-orient.ts:127-136) naming the path.
  • Opt-in flag in src/core/config.ts: resolveConfigFlag("OPEN_SECOND_BRAIN_HOST_SETTINGS_BACKUP", "host_settings_backup", configPath) beside resolveHookStrictEnabled (1597-1603) over the private resolveConfigFlag (779) / isFlagOn "true"|"1" (784). Default OFF. Lane A owns this file.
  • Registration: one PreToolUse group appended after the orient group in hooks/hooks.json, matcher Write|Edit|MultiEdit|apply_patch (per the existing PostToolUse write family at line 16), standard command shape ending in o2b-hook pretool-host-backup; exit 0; the plugins/codex mirror regenerated with scripts/sync-plugin-mirrors.ts (spec at scripts/sync-plugin-mirrors.ts:167-170; codexHooksJson at 111 hard-fails on a non-conforming command). hooks/README.md gains one table row and an opt-in note. No change to the scripts/o2b-hook dispatcher (it resolves any hooks/<name>.ts by basename).
  • No-vault sessions: resolveVault() (src/core/config.ts:394) can return null and hookAuditDir needs a vault; the receipt path degrades gracefully (skip the receipt) without turning a missing vault into a deny - the orient precedent treats missing vault as fail-open allow.

Feature-specific risks. Fail-closed has a hard floor (missing runtime silently no-ops - documented, not hidden). Symlink and temp-then-rename targets can see the hook back up one path while the write lands on another - stated honestly in the README. Hook latency runs on every Edit and Write; the wrapper tests stay to four behavioral cases and the combinatorics live in the pure-layer tests, and latency is measured before install docs recommend the flag. Trust-lane coordination: the consent lanes and this hook touch the same write path, so the ordering contract (consent, then backup, then write) is enforced by lane sequencing, and both lanes' tests avoid assuming sole custody of the deny channel (Claude Code runs all matching PreToolUse hooks and any deny wins - the semantics compose).

t_5198f0c7 - cursor pagination across MCP list tools

Card ask. Extend the existing cursor-pagination pattern across the remaining list tools so an agent can walk any large result set deterministically, with a log()-style note wherever a tool still hard-caps at limit. The card's other two axes are settled: scope params are largely at parity, and workspace-level chat is tracked separately (t_06d2ffdd).

Premise verdicts (recon-verified; every card and validator anchor has drifted and the current numbers are recorded here).

  • CORRECTED - cursor pagination ships on at least three surfaces, not two: brain_decision action=history (handler now src/mcp/brain/decisions-tools.ts:242-277; next_cursor :265; core src/core/brain/decisions/receipts.ts:538-564, base64url o:<offset> encoding at receipts.ts:515-531), brain_session_expand (raw turns pass-through :1122-1124 into src/core/brain/session-recall.ts:519-527; payload mode expandPayload recall-tools.ts:1147-1205), and brain_search_expand where next_cursor is a REQUIRED output field (input schema src/mcp/search-tools.ts:1997-2001, required :2010, handler :2063/:2109; core src/core/search/cards.ts:182,199). The card's anchors (decisions-tools.ts:220, recall-tools.ts:1452, query-tools.ts:281) are all stale: recall-tools.ts:1452 today is a schema description line inside brain_context_pack_outcome; the brain_agent_query limit read is now query-tools.ts:308.
  • REFUTED - "results are silently truncated with no way to continue". Every budgeted tool that overflows returns a typed envelope - preview_truncated: true plus an artifact_id, the full character count, a head preview, and a fixed instruction naming the exact brain_artifact_get follow-up (src/mcp/preview-budget.ts:23-58) - and the server keeps structuredContent as the full object, swapping only content[0].text (src/mcp/server.ts:642-660). What a limit-only tool lacks is an ordered walk, a different and lesser problem than silent loss. Priority was re-rated accordingly (2 to 4 on 2026-10-15 for internal-actionability reasons, not urgency).
  • CONFIRMED (stale lines) - agent_scope exists on the headline tools (second_brain_query src/mcp/tools.ts:517; brain_query query-tools.ts:841; brain_agent_query query-tools.ts:885; brain_search, brain_search_expand, brain_file_context, brain_deep_synthesis knowledge-tools.ts:1345, brain_brief) via the shared AGENT_SCOPE_SCHEMA (src/mcp/coerce.ts:100-104) with ONE reader, coerceAgentScope. It is NOT on brain_agent_diff, brain_writes, brain_unlinked_mentions, brain_truth, brain_analytics, brain_write_session, brain_context_receipts, brain_event_trace, brain_maintenance or the telemetry tools - a visible tail, deferred per Out of scope.
  • CONFIRMED - no workspace or chat tool exists (workspace-tools.ts defines only brain_intention :287 and brain_trigger :318); the chat axis stays in t_06d2ffdd.
  • REFUTED - the 2026-10-15 upstream-watch comment ("cursor paging still present only on the decisions tools") repeats the refuted two-surface count.
  • CENSUS - exactly 23 limit-only tools (limit arg, no cursor): 12 Tier-A ordered logs/listings where a page-walk applies directly (second_brain_query src/mcp/tools.ts:202-272, brain_writes query-tools.ts:361/:386-387, brain_agent_query query-tools.ts:308, brain_agent_diff query-tools.ts:484, brain_unlinked_mentions query-tools.ts:632-680, brain_write_session context-tools.ts:169, brain_generation_reports generation-tools.ts:124, brain_context_receipts pack-tools.ts:509/:713, brain_event_trace pack-tools.ts:800, brain_analytics view=timeline analytics-tools.ts:66, brain_maintenance journal admin-tools.ts:390, brain_scaffold_stub lifecycle-file-tools.ts:276); 9 Tier-B diagnostics where limit caps report rows (brain_recall_telemetry recall-tools.ts:367, brain_route_metrics :463, brain_token_impact :620, brain_context_pack_outcome :884, brain_knowledge_gaps :924, brain_session_grep :972, brain_deep_synthesis knowledge-tools.ts:462, brain_brief brief-tools.ts:593, brain_truth knowledge-tools.ts:738); 2 Tier-C ranked retrieval (brain_search search-tools.ts:1009-1018, brain_file_context search-tools.ts:1931).

Settled design.

  • One core helper (src/core/brain/offset-cursor.ts) exporting encodeOffsetCursor/decodeOffsetCursor lifted from receipts.ts:515-531 (the oldest encoding, already validated by malformed-cursor tests) plus pageSlice(items, offset, limit, total) returning {items, total, next_cursor: string | null}. queryDecisionChangeHistory is re-pointed at it without changing its wire encoding. The three live cursor encodings (base64url-opaque, decimal string, offset: prefix) coexist until now; new work uses exactly one, and the core-only paginateContinuityRecords (src/core/brain/continuity/store.ts:292-303) is left alone because tests/core/brain/continuity/reader-census.test.ts:44 counts its callers.
  • Response shape convention: { ...existing fields, next_cursor: string | null }, null when exhausted (receipts.ts:511-512, cards.ts:199, session-recall.ts:527); existing count fields kept so existing consumers do not break.
  • Input schema convention: cursor: { type: "string", maxLength: 32, description: "Pagination cursor returned as next_cursor by a prior call." } (the search-tools.ts:1997-2001 form); every new property carries a description because the registry-guard audit fails on missing-description (src/mcp/registry-guard.ts) and must fit PROPERTY_DESCRIPTION_MAX.
  • Per-tool tests copy the walk-and-reassemble pattern (tests/mcp/payload-expand.test.ts:101-111: each page's next_cursor leads to the next and the pages reassemble the exact set; last page null; malformed cursor is INVALID_PARAMS) and assert on structuredContent, not only content[0].text, because the preview budget swaps content[0].text on over-budget pages.
  • Offsets over mutable newest-first logs can skip or repeat entries when records land between pages; the decisions precedent accepts this and the limitation is documented at the helper. Upstream honcho v3.3.0 chose opt-in keyset pagination - a deliberate divergence to record, not copy blindly.

Feature-specific risks. recall-tools.ts is a 1730-line file holding five census tools plus the existing session tools - the batch split keeps later batches rebasing on a stable helper. The census-style tests bite on schema and behavior changes (see decision 9). The preview-budget interplay means callers parsing content[0].text only will not see cursors on large pages - the structuredContent path is pinned in tests. Registry-guard description ceilings bound every new schema description.

t_7ff0b101 - Converse decision-model adapter

Card ask. One more adapter on the decision-model route layer: a bearer-authenticated Converse-protocol (Bedrock-style) gateway, beside the existing systemone, vercel-evaluate and llm-emulation wire formats, plus a preset so the calibrated decision flow runs inside the operator's existing gateway, authentication and cost accounting.

Premise verdicts (recon-verified).

  • CONFIRMED - DecisionModelAdapter is exactly "systemone" | "vercel-evaluate" | "llm-emulation" at src/core/decision-model/presets.ts:34, and the factory dispatch has only three arms (src/core/decision-model/provider.ts:57-81).
  • CONFIRMED - no Converse or Bedrock support anywhere in src/ or plugins/; the only case-insensitive hits are the validator-corrected drifted anchors: the vendor-list comment at plugins/hermes/_schemas.py:894 (corrected from 815) and the unrelated English word at src/core/bench/phases.ts:893 (corrected from 495).
  • CONFIRMED - shared transport helpers each adapter composes: src/core/decision-model/transport.ts:1-18 (readAttempt, fetchFailure, withOneRetry, decisionHttpError, answeringModel, finiteNonNegative, isRecord; MAX_REPLY_BYTES at :24).
  • CORRECTED (nuance) - presets.ts:126-143 is the vercel preset, which is adapter systemone pointed at a gateway base URL. The preset that actually names the gateway-route adapter is vercel-evaluate at presets.ts:182-199 (adapter vercel-evaluate, thresholdProfile JEV_PROFILE, envKey AI_GATEWAY_API_KEY) - the pattern a converse preset most resembles.
  • CONFIRMED - thresholdProfile is declared at presets.ts:71-75; enforcement holds at src/core/decision-model/config.ts:121-132 (holdToProfile) and src/core/decision-model/questions.ts:131-135 (thresholdsTunedFor): an unlisted profile runs shadow, a null profile never enforces - without a published profile the route would run unenforced.
  • CORRECTED (structure) - no JSON Schema and no Python mirror exists for the adapter union: schemas/ holds only brain review schemas, and plugins/hermes/_schemas.py is Hermes MCP tool inputSchema vendoring with no adapter enum. Registration is the TypeScript union (presets.ts:34), its use in DecisionModelPreset.adapter (presets.ts:42) and ResolvedDecisionModelConfig.adapter (src/core/decision-model/config-types.ts:8,38), plus the exhaustive switch at provider.ts:57-81 - adding a union arm without a case fails bun run typecheck, which is the enforced registration point.
  • CONFIRMED (structure the card did not state) - two adapter shapes exist: vercel-evaluate extends the systemone provider and only renames fields (src/core/decision-model/vercel-evaluate.ts:68-90), while llm-emulation is a standalone implements DecisionProvider class with its own fetch, redactForEgress and egress site id (src/core/decision-model/llm-emulation.ts:66, 284-291, 362-384). Bearer auth is set only when a key resolves (systemone.ts:182-185, llm-emulation.ts:371-374); the key is resolved at call time from the env var named by envKey, with $secret:NAME routing through the custody store (provider.ts:36-46); 401 errors name the env var's NAME, never the value (transport.ts:179-185); redirect: "error" always. A module that POSTs must be declared in EGRESS_SITES (src/core/egress/registry.ts:289-322 for the two existing decision-model sites; census rule enforced by tests/core/architecture/egress-census.test.ts).

Settled design.

  • New adapter module src/core/decision-model/converse.ts, a standalone class composing transport.ts directly (the llm-emulation pattern): a Converse gateway speaks a chat-shaped protocol (system/messages in; output.message, stopReason, camelCase usage.inputTokens/outputTokens, metrics.latencyMs out), so the systemone base-class field-rename hooks do not apply. The judgment mapping (noul/choice/score to and from the gateway's text protocol) is the core of the module; the adapter covers only the request/response subset the decision model needs and fails loud on the rest rather than half-emulating the protocol family.
  • Registration: the union arm at presets.ts:34; the case "converse" with a lazy require at provider.ts:57-81 (exhaustiveness forces it); the preset entry in DECISION_MODEL_PRESETS (presets.ts:91-268, pattern 182-199) with DECISION_MODEL_PRESET_NAMES picking it up automatically (presets.ts:270-272); the threshold profile registry entry at questions.ts:111-120, or a recorded decision to reuse jev-1.13 only if the gateway is proven to serve that family; the egress site decision-model-converse in src/core/egress/registry.ts after line 322 with R.sharedRedactor and a reason in the house style.
  • Contract suite: a fourth Route in tests/core/decision-model/contract-suite.test.ts (ROUTES) with an encode() mapping the adapter-neutral fixtures into the Converse reply shape, an errorBody canary, and requestsOn422 - every existing fixture (success, recomputed confidence, invalid probabilities, unknown keys, missing answer, non-JSON, 401 canary discipline, 422/429/529, reset, timeout, choice-limit refusal, oversized model id) then applies to the new adapter. The loopback fake (tests/helpers/fake-decision-provider.ts) is path-agnostic and fakes a Converse endpoint without changes.
  • Config surface needs no new mechanism: decision_model_provider: converse plus the existing decision_model_* keys (config.ts:362-372 error messages pick the new preset up automatically); the key value is read from the environment at call time and never stored in config.
  • Docs: docs/decision-models/providers.md (table rows plus a ### converse section like lines 53-77), skills/decision-model-setup/SKILL.md and its byte-identical mirror plugins/codex/skills/decision-model-setup/SKILL.md.

Feature-specific risks. Calibration is the real design question, not transport: if the gateway serves a judgment model, calibrated: true plus a published profile is required, and inventing a profile without shadow data overstates enforcement because holdToProfile would silently run every enforce as shadow; if the model is generative, the llm-emulation fences apply (calibrated: false, decision_model_allow_uncalibrated, fenceUntrustedContent). The thresholdProfile-before-route rule is absolute: the preset must not borrow jev-1.13 without evidence. An unknown adapter name in a stored config fails closed and names itself. Never-print discipline carries over: Converse error bodies are drained unread by readAttempt and the contract suite's canary assertions must pass unchanged. Bundle drift: forgetting the openclaw rebuild after the registry change fails the CI diff - mitigated by decision 10.

t_00e9de6a - snooze and movement-gated resurrection for triggers

Card ask. Two anti-nag primitives on the trigger lifecycle: a snooze action (defer a trigger for a bounded window OR until it fires again, whichever comes first) and movement-gated resurrection for dismissed triggers (a dismissed finding stays silent until the underlying work actually changes, not merely until a fixed time window elapses). Keep suppress semantics untouched - snooze is the time-boxed sibling it currently lacks.

Premise verdicts (recon-verified; all four validator anchors are exact on this merge base).

  • CONFIRMED - blockReason (src/core/brain/triggers/store.ts:701-716) is a pure cooldownDays window for dismissed/acted (now < resolved + cooldownDays * DAY_MS, line 715, TRIGGER_COOLDOWN_DAYS = 7 at :61); it never reads lastSeenAt, occurrences or sourceArtifacts. Module-private with exactly one caller, createTriggersLocked at store.ts:820.
  • CONFIRMED - recordRecurrence (store.ts:740-748) already stamps lastSeenAt and increments occurrences on every re-fire of a blocked twin (called at :822 and :833) - the raw movement signal exists and is persisted, but nothing ever re-opens a dismissed twin with it.
  • CONFIRMED - TriggerAction (store.ts:875) is acknowledge|dismiss|act|suppress|unsuppress, no snooze; mirror lists: ACTION_TO_STATUS store.ts:901-906, CLI VERB_TO_ACTION src/cli/brain/verbs/trigger.ts:33-39, MCP TRIGGER_TRANSITIONS src/mcp/brain/workspace-tools.ts:140-146. No snooze exists anywhere under src/ (the only repo hit is a dream-verb INVALID assertion).
  • CONFIRMED - effectiveStatus (store.ts:382-389) applies expiry to TRIGGER_OPEN_STATUSES only and is the wake point (called from parseTrigger :446 and unsuppress :1007, so every read path flows through it).
  • CORRECTED (framing) - sourceArtifacts is a ReadonlyArray<string> of wikilinks/paths (types.ts:109), not a hash: "changed sourceArtifacts" is an in-memory set comparison at scan time; no filesystem access or mtime logic is needed. Also, the cooldown knob has three consumers - dismissed/acted recreation blocking (blockReason:715), the brief's delivered re-surface window (briefTriggers, store.ts:1092-1098), and the module docstring - and only the first moves to movement gating.

Settled design.

  • Status plumbing: snoozed joins TRIGGER_STATUS/TRIGGER_STATUSES and the TERMINAL partition (src/core/brain/triggers/types.ts:20-45, 56-73) - mirroring suppressed: hidden from open list, shown in history, excluded from the brief allow-list with zero brief changes, and governed by the snooze window rather than the TTL expiry clock. The partition-cover test (trigger-store.test.ts:173) forces the explicit choice. TriggerRecord gains snoozedAt/snoozedUntil/snoozedFrom (types.ts:121-159) with TRIGGER_KEY entries snoozed_at/snoozed_until/snoozed_from (store.ts:91-106), renderer conditionals (store.ts:131-138 pattern), and refusing parsers (every field parses with refusal and raises TriggerFieldError on unreadable values, never silently defaults - the suppressedAt pattern at store.ts:463-464).
  • Snooze transition and wake: TriggerAction += snooze (:875), ACTION_TO_STATUS += snooze (:901-906), transitionTriggerLocked snooze arm legal from open states only (:931-959), window default from TRIGGER_SNOOZE_DAYS beside TRIGGER_COOLDOWN_DAYS (:60-62). effectiveStatus gains the wake arm: a snoozed record reads as its restored snoozedFrom status once now > snoozedUntil OR lastSeenAt > snoozedAt (refire via the ledger - recordRecurrence stamps on every re-fire, so "fired again since snoozing" is directly readable); the wake re-applies expiry to the restored status at the current now (the unsuppress precedent at :1007).
  • blockReason arms: a snoozed twin blocks with a new SkippedCandidate.reason value "snoozed" (:685-688) AND must keep returning non-null so the scan records the recurrence that drives the refire wake - the ledger IS the refire detector; order the arms so snoozed is checked before the open/terminal fallthrough. The dismissed arm becomes movement-gated: unblock only when the incoming candidate's sourceArtifacts differ from the twin's persisted set (order-insensitive comparison following the deriveDatasetHash convention, src/core/brain/derived-artifact.ts:44; direct set comparison preferred for surface minimality, a persisted deriveDatasetHash(sourceArtifacts) fingerprint is the convention-conformant alternative if history display or doctor diagnostics want one). acted keeps the plain cooldown window. Legacy dismissed records predate the change: a dismissed record with unchanged persisted artifacts stays blocked, and a missing fingerprint never reads as "changed" (the neutral-absence convention, src/core/content-hash.ts:66-74).
  • Surfaces: CLI VERB_TO_ACTION (:33-39), triggerJson (:55-74) with the new fields, usage line (:53); the three hand-maintained verb-list copies (src/cli/brain/help-text.ts:183 and :1361, src/cli/command-manifest.ts:607); MCP TRIGGER_TRANSITIONS (:140-146), triggerToJson (:118-137), tool description (:324, within TOOL_DESCRIPTION_MAX = 300); probe catalogue (tests/helpers/tool-probe-catalogue.ts:1068). Schema enums need no edit (they spread [...TRIGGER_OPERATIONS]/[...TRIGGER_STATUSES]). TRIGGER_TRANSITIONS is typed ReadonlyArray<TriggerAction>, so a missing arm is not a compile error - an exhaustiveness test pins it.
  • Brief surfaces need no change: briefTriggers is an allow-list of pending/delivered (store.ts:1092-1098), so snoozed is excluded by the same rule that excludes dismissed; resurrection arrives as a new pending record through the normal brief path.

Feature-specific risks. Status-vocabulary drift across the three hand-maintained surfaces surfaces as a usage error or an unhandled operation, not a build failure - the exhaustiveness test and the surface-sync task are the guard. SkippedCandidate.reason is a serialized contract consumed by CLI scan output (trigger.ts:115) and MCP scan output (workspace-tools.ts:218-223) and asserted verbatim in tests. Resurrection must create a new record, never flip the old one (immutability conventions around resolvedAt and the delivery ledger). The refire wake silently never fires if blockReason stops returning a reason for snoozed twins - covered by an explicit test.

File changes

Lane ownership is disjoint; respect it strictly.

Lane Cards Owned files
A - trust t_b6bcd984, t_f4555087 src/core/diff.ts (new), src/cli/brain/upgrade-render.ts (re-export only), src/core/install/types.ts, src/core/install/adapters/_json-mcp.ts, src/cli/install/install.ts, src/cli/install/render.ts, src/core/brain/protect.ts, src/cli/brain/verbs/protect.ts, src/cli/brain/verbs/doctor.ts, src/core/brain/diagnostics.ts, src/core/brain/types.ts, src/mcp/brain/health-tools.ts, hooks/pretool-host-backup.ts (new), src/core/brain/pretool-host-backup.ts (new), src/core/config.ts (Lane A ONLY), hooks/hooks.json, plugins/codex/hooks/hooks.json, hooks/README.md, tests/core/diff, tests/cli/install-verb, tests/cli/install-json-shape, tests/cli/brain (protect + doctor blocks), tests/core/brain/protect, tests/core/brain.diagnostics, tests/core/brain/pretool-host-backup, tests/hooks/pretool-host-backup, tests/hooks/hooks-json-shape
B - pagination t_5198f0c7 src/core/brain/offset-cursor.ts (new), src/core/brain/decisions/receipts.ts (re-point only, wire unchanged), src/mcp/tools.ts, src/mcp/brain/query-tools.ts, src/mcp/search-tools.ts, src/mcp/brain/recall-tools.ts, src/mcp/brain/context-tools.ts, src/mcp/brain/generation-tools.ts, src/mcp/brain/pack-tools.ts, src/mcp/brain/analytics-tools.ts, src/mcp/brain/admin-tools.ts, src/mcp/brain/lifecycle-file-tools.ts, src/mcp/brain/knowledge-tools.ts, and the four census tests (tests/mcp/agent-scope-matrix.test.ts, tests/core/architecture/visibility-surface-census.test.ts, tests/core/brain/continuity/reader-census.test.ts, tests/mcp/maintenance-parity-census.test.ts)
C - Converse adapter t_7ff0b101 src/core/decision-model/** (presets.ts, provider.ts, questions.ts, converse.ts new), src/core/egress/registry.ts (one new site), docs/decision-models/providers.md, skills/decision-model-setup/SKILL.md, plugins/codex/skills/decision-model-setup/SKILL.md, tests/core/decision-model/**
D - trigger snooze t_00e9de6a src/core/brain/triggers/** (types.ts, store.ts), src/cli/brain/verbs/trigger.ts, src/cli/brain/help-text.ts (trigger blocks only - coordinate, Lane A also edits other blocks), src/cli/command-manifest.ts (trigger block only - coordinate), src/mcp/brain/workspace-tools.ts, tests/helpers/tool-probe-catalogue.ts, tests/core/brain/trigger-store.test.ts, tests/cli/brain-trigger.test.ts, tests/mcp/brain-trigger-tool.test.ts

Shared, sequenced artifacts (not owned by a lane): CHANGELOG.md (each lane adds its own entry; Lane A writes the breaking-edge note), openclaw/index.js (rebuilt by the integrator as the last commit after any src/ edit).

Note on help-text.ts and command-manifest.ts: both lanes A and D add lines to these hand-maintained lists in different blocks (Lane A: install/protect usage; Lane D: trigger verb lists at help-text.ts:183 and :1361, command-manifest.ts:607). The blocks are disjoint; land Lane A's blocks first or keep the edits textually separate.

Risks and open questions

  • The headless break is deliberate and must be documented as one unambiguous flag: after the consent lanes land, doctor --repair --apply, protect --apply and install --apply refuse under CI/non-TTY without --yes, including for callers following the copy-paste commands in install/*.md. CHANGELOG and docs carry this; there is no internal cron caller to migrate.
  • Shared write path ordering: consent, then backup, then write. A refused consent must not leave a backup file, and the backup hook must not fire before the consent verdict exists on the same lane's writes. Enforced by Lane A's internal task order.
  • hooks.json and deny-channel composition: Claude Code runs all matching PreToolUse hooks and any deny wins; neither the consent work nor the hook may assume sole custody of the deny channel. Both lanes' tests assert their own entries only.
  • Census-test cadence: any commit that changes a censused surface (tool table, store read paths, maintenance surfaces, visibility vocabulary) updates the matching census in the same commit. This is the single most likely CI failure mode of the wave.
  • Bundle drift: openclaw/index.js embeds EGRESS_SITES text; the integrator rebuilds it as the last commit. If a lane forgets, the CI bundle diff catches it - after the fact.
  • Open questions carried to implementation, answered where the branch settled them: the install consent-refusal exit is 6 (INSTALL_EXIT.consentRefused, named on stderr and in the CLI reference); the dismissed-twin comparison is the direct order-insensitive set comparison over sourceArtifacts, surfaced as the new dismissed skip reason (no persisted fingerprint); unsnooze shipped, mirroring unsuppress - it restores the status the snooze interrupted verbatim and refuses a record that lost its snoozed_from rather than inventing one; and the snooze window is the TRIGGER_SNOOZE_DAYS constant alone - the per-transition snoozeDays option the first cut carried was reachable from no surface and was removed.