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.
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:
- 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.jsonand peers,brain protect --applyinto the project.claude/settings.json, andbrain 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. - Cursor pagination (card t_5198f0c7). Cursor pagination exists on a minority of MCP surfaces while 23 list tools expose
limitwith 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. - 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. - Trigger attention (card t_00e9de6a). Open Second Brain's trigger
dismisssilences a finding for a fixedTRIGGER_COOLDOWN_DAYSwindow 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
conversedecision-model adapter module, preset, threshold profile, egress site and contract-suite route for bearer-authenticated Converse-protocol gateways. - t_00e9de6a: a
snoozetrigger action (bounded window or next refire, whichever comes first) and movement-gated resurrection for dismissed triggers (reopen only on changedsourceArtifacts).
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_scopegap onbrain_agent_diffandbrain_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 throughcoerceAgentScope(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 Bashtool_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_decisionaction=history,brain_session_expand,brain_search_expand, and the core-onlypaginateContinuityRecords(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
limitnor cursor (brain_calendarlist, procedure lists, entity list,brain_triggerlist). Recorded as a follow-up gap; a sweep that only fixes limit-only tools does not claim to have fixed result-walking everywhere. - Declaring
outputSchemafor the 23 adopting tools. None declares one today; adding 23 output schemas multiplies review surface and trips the no-union-type vocabulary.next_cursoris 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
actedcooldown window, the brief's delivered re-surface clock (briefTriggers, store.ts:1092-1098), andsuppresssemantics (deliberately clockless, terminal,unsuppressis 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
renderUnifiedDiffto 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_cursorprecedent, 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
- 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--jsonor non-TTY stdin call refuses (naming--yesand the non-interactive mode); with a TTY it prompts once y/N viareadSingleLine. Applied toinstall --apply,protect --applyanddoctor --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). - Consent composes with the existing drift guard, never replaces it: the
_json-mcp.tsrefusal 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. - MCP
brain_doctorapply: truestays 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 provenancecaller-applyin the doctor-repair event body; CLI paths recordyes-flagorinteractive-yes. - 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 withapplied_atsemantics (src/core/install/adapters/_json-mcp.ts:363-377); the verdict belongs in the CLI JSON receipt. - The PreToolUse host-settings backup hook is opt-in with default OFF via
resolveConfigFlagin src/core/config.ts (envOPEN_SECOND_BRAIN_HOST_SETTINGS_BACKUPoverriding thehost_settings_backupconfig key, besideresolveHookStrictEnabledat 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 thescripts/o2b-hookdispatcher is deliberately fail-soft (suppresses non-zero exits, always exits 0), the deny channel is stdouthookSpecificOutput.permissionDecision: "deny"(theemitPermissionpattern, 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. - 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.
- 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. next_cursoris present in every adopting tool's answer,nullwhen exhausted - the required-field treatment ofbrain_search_expandis 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.- 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.
- 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 anysrc/edit, so the CI bundle diff passes exactly once. - The trigger snooze window is a
TRIGGER_SNOOZE_DAYSconstant besideTRIGGER_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. - Settled trigger semantics: snooze wakes at window end or next refire, whichever comes first (refire read from the existing
recordRecurrenceledger aslastSeenAt > snoozedAt, which requiresblockReasonto keep returning a reason for snoozed twins so the ledger keeps stamping); a dismissed twin reopens only on changedsourceArtifacts(an order-insensitive set comparison following thederiveDatasetHashconvention, src/core/brain/derived-artifact.ts:44 - movement is the detector firing on different artifacts, neverlastSeenAtalone);suppressstays clockless;snoozedjoins the terminal status partition (mirroringsuppressed, 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 throughcreateTriggersLocked, never as a status flip of the resolved record. - Lane file ownership is disjoint and listed under File changes;
src/core/config.tsis 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 noyesflag at all andrunTargetapplies 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 --applywith no gate; the MCPbrain_doctorrepair+apply (src/mcp/brain/health-tools.ts:96-119) writes onapply: truewith nothing further. - CORRECTED - the card's "would fix"/"fixed" anchor (doctor.ts:283-294) is the
[WARN]loop of plain doctor. The repair renderer isrenderRepairat 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 (mergeMcpServersthenatomicWriteFileSync), unconditional on any consent and stopped only byopts.dryRun; theplan()preview is one summary line at 296-312, no file diff. - CORRECTED (scope kept) - doctor repair is NOT a host-config write:
applyRepairfixes 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.
renderUnifiedDiffships at src/cli/brain/upgrade-render.ts:65-88; fail-closed--yesladders 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:
InstallStepgains optionaldiff?: string(src/core/install/types.ts:77-81, additive);_json-mcp.tsplan()(296-312) reads the on-disk raw file, computesmergeMcpServers(pure, no write) and renders a diff - compute before write, apply path (353-361) unchanged; src/cli/install/install.ts addsyestoparseInstallArgsand the gate inrunTargetbeforeadapter.apply, with the refusal exit code pinned against the documentedINSTALL_EXIT0-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 underINSTALL_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, mirroringapplyProtect(ladder, backup, receipt). src/cli/brain/verbs/protect.ts adds--yes, the ladder beforeapplyProtect, 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 passescaller-apply), with the kind doc updated at src/core/brain/types.ts:496-506; optionalFixer.preview(vault, item): {before, after} | nullon both fixers (walGap 1107, orphanedReference 1158) rendered byrenderRepairunder 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:
buildProtectRulesat src/core/brain/protect.ts:109-130 (Brain/preferences/**,Brain/retired/**,Brain/log/**,Brain/.snapshots/**,brainConfigPath(vault); allowBrain/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
*, commando2b-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_patchmatcher (line 16) runs onlypost-write-reminderandsubagent-inject- no backup. - CONFIRMED - nothing backs up or receipts tool writes to
~/.claude/settings*.json: the onlysettings.jsonhits in src and hooks are install adapters resolving their own declared targets and protect writing the vault's own.claude/settings.json. Nohost_settingsconcept exists anywhere. - CONFIRMED AS FEASIBLE WITH A CAVEAT - the fail-closed shape is buildable from in-repo parts, but
scripts/o2b-hookis 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
decideOrientat line 125):decideHostBackup({runtime, toolName, toolInput, home, now})- tilde expansion, cwd-relative join,realpathSynccanonicalization, and the protected-path predicate (~/.claude/settings.json,.claude/settings.local.jsonand peers;.codex/config.tomlis 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, UTCYYYY-MM-DD-HHMMSS) into a timestamped backup folder,atomicCreateFileSyncExclusive(src/core/fs-atomic.ts:467) with thecollisionCandidateNamebounded-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: oneappendAuditRecord(src/core/reliability/audit.ts:30-39, JSONL, redacted, mode 0600) athookAuditDir(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 viaemitPermission(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)besideresolveHookStrictEnabled(1597-1603) over the privateresolveConfigFlag(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 ino2b-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;codexHooksJsonat 111 hard-fails on a non-conforming command). hooks/README.md gains one table row and an opt-in note. No change to thescripts/o2b-hookdispatcher (it resolves anyhooks/<name>.tsby basename). - No-vault sessions:
resolveVault()(src/core/config.ts:394) can return null andhookAuditDirneeds 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_decisionaction=history (handler now src/mcp/brain/decisions-tools.ts:242-277;next_cursor:265; core src/core/brain/decisions/receipts.ts:538-564, base64urlo:<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 modeexpandPayloadrecall-tools.ts:1147-1205), andbrain_search_expandwherenext_cursoris 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 insidebrain_context_pack_outcome; thebrain_agent_querylimit 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: trueplus anartifact_id, the full character count, a head preview, and a fixed instruction naming the exactbrain_artifact_getfollow-up (src/mcp/preview-budget.ts:23-58) - and the server keepsstructuredContentas the full object, swapping onlycontent[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_scopeexists 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 sharedAGENT_SCOPE_SCHEMA(src/mcp/coerce.ts:100-104) with ONE reader,coerceAgentScope. It is NOT onbrain_agent_diff,brain_writes,brain_unlinked_mentions,brain_truth,brain_analytics,brain_write_session,brain_context_receipts,brain_event_trace,brain_maintenanceor 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 andbrain_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/decodeOffsetCursorlifted from receipts.ts:515-531 (the oldest encoding, already validated by malformed-cursor tests) pluspageSlice(items, offset, limit, total)returning{items, total, next_cursor: string | null}.queryDecisionChangeHistoryis 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-onlypaginateContinuityRecords(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 onmissing-description(src/mcp/registry-guard.ts) and must fitPROPERTY_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 onlycontent[0].text, because the preview budget swapscontent[0].texton 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 -
DecisionModelAdapteris 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
vercelpreset, which is adaptersystemonepointed at a gateway base URL. The preset that actually names the gateway-route adapter isvercel-evaluateat presets.ts:182-199 (adaptervercel-evaluate, thresholdProfileJEV_PROFILE, envKeyAI_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) andResolvedDecisionModelConfig.adapter(src/core/decision-model/config-types.ts:8,38), plus the exhaustiveswitchat provider.ts:57-81 - adding a union arm without a case failsbun run typecheck, which is the enforced registration point. - CONFIRMED (structure the card did not state) - two adapter shapes exist:
vercel-evaluateextends the systemone provider and only renames fields (src/core/decision-model/vercel-evaluate.ts:68-90), whilellm-emulationis a standaloneimplements DecisionProviderclass with its ownfetch,redactForEgressand 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 byenvKey, with$secret:NAMErouting 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 inEGRESS_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/messagesin;output.message,stopReason, camelCaseusage.inputTokens/outputTokens,metrics.latencyMsout), 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 inDECISION_MODEL_PRESETS(presets.ts:91-268, pattern 182-199) withDECISION_MODEL_PRESET_NAMESpicking it up automatically (presets.ts:270-272); the threshold profile registry entry at questions.ts:111-120, or a recorded decision to reusejev-1.13only if the gateway is proven to serve that family; the egress sitedecision-model-conversein src/core/egress/registry.ts after line 322 withR.sharedRedactorand a reason in the house style. - Contract suite: a fourth
Routein tests/core/decision-model/contract-suite.test.ts (ROUTES) with anencode()mapping the adapter-neutral fixtures into the Converse reply shape, anerrorBodycanary, andrequestsOn422- 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: converseplus the existingdecision_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
### conversesection 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 purecooldownDayswindow for dismissed/acted (now < resolved + cooldownDays * DAY_MS, line 715,TRIGGER_COOLDOWN_DAYS = 7at :61); it never readslastSeenAt,occurrencesorsourceArtifacts. Module-private with exactly one caller,createTriggersLockedat store.ts:820. - CONFIRMED -
recordRecurrence(store.ts:740-748) already stampslastSeenAtand incrementsoccurrenceson 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) isacknowledge|dismiss|act|suppress|unsuppress, nosnooze; mirror lists:ACTION_TO_STATUSstore.ts:901-906, CLIVERB_TO_ACTIONsrc/cli/brain/verbs/trigger.ts:33-39, MCPTRIGGER_TRANSITIONSsrc/mcp/brain/workspace-tools.ts:140-146. Nosnoozeexists anywhere under src/ (the only repo hit is a dream-verb INVALID assertion). - CONFIRMED -
effectiveStatus(store.ts:382-389) applies expiry toTRIGGER_OPEN_STATUSESonly and is the wake point (called fromparseTrigger:446 andunsuppress:1007, so every read path flows through it). - CORRECTED (framing) -
sourceArtifactsis aReadonlyArray<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:
snoozedjoinsTRIGGER_STATUS/TRIGGER_STATUSESand the TERMINAL partition (src/core/brain/triggers/types.ts:20-45, 56-73) - mirroringsuppressed: hidden from openlist, shown inhistory, 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.TriggerRecordgainssnoozedAt/snoozedUntil/snoozedFrom(types.ts:121-159) withTRIGGER_KEYentriessnoozed_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 raisesTriggerFieldErroron unreadable values, never silently defaults - thesuppressedAtpattern at store.ts:463-464). - Snooze transition and wake:
TriggerAction+=snooze(:875),ACTION_TO_STATUS+=snooze(:901-906),transitionTriggerLockedsnooze arm legal from open states only (:931-959), window default fromTRIGGER_SNOOZE_DAYSbesideTRIGGER_COOLDOWN_DAYS(:60-62).effectiveStatusgains the wake arm: asnoozedrecord reads as its restoredsnoozedFromstatus oncenow > snoozedUntilORlastSeenAt > snoozedAt(refire via the ledger -recordRecurrencestamps on every re-fire, so "fired again since snoozing" is directly readable); the wake re-applies expiry to the restored status at the currentnow(theunsuppressprecedent at :1007). blockReasonarms: a snoozed twin blocks with a newSkippedCandidate.reasonvalue"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'ssourceArtifactsdiffer from the twin's persisted set (order-insensitive comparison following thederiveDatasetHashconvention, src/core/brain/derived-artifact.ts:44; direct set comparison preferred for surface minimality, a persistedderiveDatasetHash(sourceArtifacts)fingerprint is the convention-conformant alternative ifhistorydisplay or doctor diagnostics want one).actedkeeps 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); MCPTRIGGER_TRANSITIONS(:140-146),triggerToJson(:118-137), tool description (:324, withinTOOL_DESCRIPTION_MAX = 300); probe catalogue (tests/helpers/tool-probe-catalogue.ts:1068). Schema enums need no edit (they spread[...TRIGGER_OPERATIONS]/[...TRIGGER_STATUSES]).TRIGGER_TRANSITIONSis typedReadonlyArray<TriggerAction>, so a missing arm is not a compile error - an exhaustiveness test pins it. - Brief surfaces need no change:
briefTriggersis an allow-list of pending/delivered (store.ts:1092-1098), sosnoozedis 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 --applyandinstall --applyrefuse 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_SITEStext; 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 oversourceArtifacts, surfaced as the newdismissedskip reason (no persisted fingerprint);unsnoozeshipped, mirroringunsuppress- it restores the status the snooze interrupted verbatim and refuses a record that lost itssnoozed_fromrather than inventing one; and the snooze window is theTRIGGER_SNOOZE_DAYSconstant alone - the per-transitionsnoozeDaysoption the first cut carried was reachable from no surface and was removed.