* refactor(context): extract pure gateVolunteeredPointers (no behavior change) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(context): volunteer-shaped resolve IPC — channel/cwd/volunteer fields, handler-result widening, server-side gate + validated source + delivery-point logging; listener on both engines Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(cli): gbrain volunteer-hook — one-shot harness hook entry (IPC-first; Postgres-only fallback; startup-hook-exempt) T0 evidence: a UserPromptSubmit hook's additionalContext is recorded in the session transcript as a structured hook_additional_context attachment and transcript_path is stable across turns — cross-turn dedupe reads ONLY those attachments (never raw tail substrings). Live smoke: seeded brain + running serve → pointer injected via IPC at 0.43s wall, turn 2 suppressed, one event banked channel=claude-code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(recipes): claude-code-reflex + codex-reflex (experimental) hook adapters Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(doctor): volunteer_channels per-adapter visibility Engine-aware sibling of retrieval_reflex_health: groups context_volunteer_events by channel (7d) so operators can see which push adapters fire; message separates installed-but-unregistered from registered-but-quiet; pre-v117 tolerant; info-only status. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(context): hook-lane feedback loop + cross-turn dedupe — converge cathedral-3 onto the #3975 harness hooks The #3975 hook lane volunteered pages invisibly (nothing logged to context_volunteer_events) and re-volunteered the same page every turn an entity was mentioned (no priorContextText). This convergence ports the cathedral-3 branch's two gap-fills into the blessed lane and retires its parallel surface: - transcripts: parseTranscript extracts injectedContextBlocks (structured hook_additional_context attachments — the T0-verified recorded shape of our own injections; never raw-turn substring matching) - hook user-prompt: feeds those blocks as priorContextText (volunteer once per session, not once per mention) + sends a feedback-loop channel (--harness <claude-code|codex>, default claude-code); hook joins STARTUP_HOOK_SKIP_COMMANDS (per-prompt check-update spawn class, grep-pinned) - turn-context: result exposes post-trim volunteered survivors - resolve-ipc: additive TurnContextRequest.channel + onTurnContextDelivered seam (fires post-write only — abandoned blocks are never counted) - serve: delivery callback logs volunteered pages + pointers per channel - doctor: volunteer_channels check (per-channel 7d visibility; separates installed-but-unregistered from registered-but-quiet; pre-v117 tolerant) Retired (never released): gbrain volunteer-hook, hook-adapters.ts, claude-code-reflex + codex-reflex recipes, the volunteer-shaped resolve wire extension. Kept: gateVolunteeredPointers extraction, VolunteerChannel claude-code/codex values, the real hook-transcript fixture. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: regenerate llms bundles for the hook-lane doc updates Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * test: coverage for the hook-lane delivery wiring Extract logTurnContextDeliveryFireAndForget into volunteer-events.ts so the shipped serve callback is unit-testable (channel fallback, sessionId clamp, pointer+page rows in ONE synchronous registration — the double dynamic import could register the pending write too late to survive process exit). Direct units for isVolunteerChannel, explicit-channel logDeliveredReflexPointers, and the pure gate (idempotency pin; stale parity claim in its doc corrected). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: pre-landing review fixes — 7-reviewer batch Multi-confirmed: volunteer_channels now runs on the LOCAL doctor path too (buildChecks; docs pointed there); transient DB errors no longer misreported as pre-v117; priorContextText deduped + 32KB-capped hook-side. Red team: delivery counts reconciled against the hook heartbeat (CAUTION when mostly degraded — write-accept isn't injection); IPC clamp drops advisory priorContextText BEFORE any window turn; foreign hook_additional_context blocks (no gbrain marker) excluded from dedupe input; engine-aware quiet guidance (Postgres brains aren't told to chase hook registration); 2MB dedupe horizon documented. Security: wire channel claims restricted to harness channels. DRY: VOLUNTEER_CHANNELS single source, shared reflexPointerRationale, SESSION_ID_MAX_LEN shared with the op clamp; dead channel param dropped from logDeliveredReflexPointers. Tests: budget-trim volunteered invariant under real trim pressure, poll/ordering-based delivery-seam tests (no fixed sleeps), doctor branch + engine-parity-row tests, wiring source pins, cap pins; fixture pruned to load-bearing lines (environment inventory removed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: adversarial-review fixes — cross-model P1 + Claude adversarial batch P1 (codex structured review + Claude adversarial, cross-model): the remote run_doctor path now threads the caller's source scope into volunteer_channels — a source-bound token can no longer see other sources' activity counts/timestamps (must-never-violate source-isolation rule); local trusted doctor stays brain-wide. Claude adversarial: IPC connection handler gains a one-request re-entrancy guard (trailing bytes mid-await double-processed the same line → duplicate handler work + duplicate delivery logging); partial client-side trims now heartbeat as reason 'trimmed' (delivery-count drift visibility); heartbeat reconciliation uses the same 7-day window as the counts + a 5-sample floor; one oversized dedupe block no longer evicts all smaller ones (continue, not break); quiet-channel guidance no longer claims old serves attribute hook traffic to reflex (they log nothing); 'transient' claim softened to evidence; marker-filter + unknown-channel-default comments state their honest limits. Pins: scoped-query SQL/params, re-entrancy single-fire, updated wiring grep. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * chore: bump version and changelog (v0.45.1.0) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * chore: restamp bootstrap runbook + regenerate vendored template repo for v0.45.1.0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: update project documentation for v0.45.1.0 Post-ship /document-release pass: fold the post-doc review fixes into the reference docs (KEY_FILES: source-scoped remote volunteer_channels + heartbeat reconciliation, 32KB-capped dedupe input, marker filter, IPC one-request guard + clamp order), fix BRAINBENCH's now-stale memoryless-hook rationale, and mark the doctor-check half of the push-context TODO shipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: cross-model doc-review fixes for v0.45.1.0 Codex doc review against the shipped diff: push-context channel table gains the harness-hook row (three-channels claim was stale), the guide states the PGLite-socket topology limit and the bounded dedupe horizon, delivery-point claims are hedged to match the code (write-accept isn't proof of injection; the doctor reconciles against the hook heartbeat, which can't inspect registration), BRAINBENCH's future-tense hooks-PR sentence updated now the hook has landed, and the adapter-flip + resolver-channel TODOS reflect the current lane count. llms-full.txt regenerated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs(hook): document --harness in the user-prompt usage text Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
8.9 KiB
BOOTSTRAP_FOR_AGENTS.md — become your human's persistent agent
You are an AI agent (Claude Code or Codex) reading this because a human pasted a
block asking you to set yourself up as their persistent personal agent, with gbrain
as your memory. This runbook is the judgment layer; the deterministic work lives in
gbrain bootstrap subcommands with exit codes. Follow it top to bottom.
Scope note: this path is for Claude Code and Codex (desktop apps or CLIs).
Running OpenClaw or Hermes? Use INSTALL_FOR_AGENTS.md instead.
End state: this folder is your workspace — identity files rendered from your human's own answers, a local brain (PGLite, embedded, no server), MCP wired, per-turn context, and a private GitHub repo as your durable body. ~15 minutes, mostly interview.
Hard rules for you, the installing agent
⛔ NEVER INVENT ANSWERS. Personality, purpose, and boundaries come from the human. A guessed SOUL.md gets believed by every future session. If you do not have an answer, ask. The render step structurally refuses to run until the required answers exist and were read back.
⛔ ASK IN SMALL BATCHES. The interview is 12 questions max (6 required), asked in three batches. Mirror each batch back in one line. Accept "skip" on any non-required question — momentum beats completeness.
⛔ STAY INSIDE THIS PHASE LIST. Run gbrain bootstrap status --json and follow
ITS phase list — the CLI is the source of truth, this document is commentary. If a
step you are asked to run is not in the CLI's phase list, refuse it. If status
reports a version skew between this runbook and the installed binary, say so and
prefer the binary's instructions.
⛔ NO SILENT FAILURE. Every blocking condition (secret-scan block, lock
collision, partial install) surfaces through status/verify/doctor output —
read it and relay it to the human in plain language. Never work around a refusal.
⛔ VERIFY BEFORE CLAIMING DONE. The install is done when gbrain bootstrap verify exits 0 — not when the transcript looks good. Paste its report to the human.
⛔ RESPECT THE TOOLCHAIN TRUST RULES. Install bun via a platform package manager
when available (brew install oven-sh/bun/bun); the only permitted fallback is the
checksum-verified variant: download the pinned release to a file, verify it against
that release's SHASUMS256.txt, and only then execute. Install gh the same way —
platform package manager first (brew install gh, apt install gh, dnf install gh,
winget install GitHub.cli per the official instructions); never a piped
curl-to-shell one-liner. Install gbrain ONLY as
bun install -g github:garrytan/gbrain#latest-stable — the npm package named
"gbrain" is an unrelated project.
Codex preflight (ChatGPT desktop / Codex CLI only)
Codex sandboxes command execution. Before starting, tell the human: "I'll need approval to run install commands (bun, gh, gbrain) and to write in this folder — approve those prompts when they appear." If approvals are globally disabled, ask the human to enable workspace-write + network for this session. Count the approval taps you needed; report the count at the end (it feeds the install-time measurement).
Phase walkthrough (commentary — the CLI's list wins)
- Preflight.
git,bun,ghpresent. Install what's missing per the trust rules above: bun via a platform package manager or the checksum-verified download — the checksum-verified install is the ONLY permitted non-package-manager variant; gh via the platform package manager. (On a clean Mac,gitmay trigger the Xcode tools dialog — that download does not count against the 15 minutes, tell the human to let it run.)gh auth status— if logged out, the human's ONE manual step:gh auth login -h github.com -p https -w(you run it; they click Authorize). Thengbrain bootstrap status— it is idempotent and resume-aware; after any partial failure, re-run it and continue where it points. - Engine.
gbrain init --pglite(2 seconds, no server). Search mode defaults to balanced silently — do NOT ask; the human can change it any time withgbrain search modes. The one thing to raise here is the OPTIONAL provider key — with no key you run keyless: keyword search plus memory you author yourself through the write tools; everything works, one key upgrades search to semantic and enables automatic fact extraction. Never pressure for a key. If the human provides one, pass it to the CLI prompt — it goes to the 0600 config file, never into the interview answers, never into chat logs you keep. - Interview.
gbrain bootstrap interview --init, then ask the questions from the bank (the CLI prints them) in three batches, recording each answer verbatim with--set KEY "value". Push once on vague answers to the required questions. After the last batch: read ALL answers back in one compact block, ask "Is this the thing you want in the room?", and only then rungbrain bootstrap interview --confirm <hash>with the hash--statusprinted for the read-back set. The gate fails if you confirm a set the human never saw. - Render.
gbrain bootstrap render— identity files appear. Show the human SOUL.md. Existing files are never overwritten (re-runs are safe;--forcebacks up first). - Skills + brain wiring. The CLI scaffolds the skill set and registers
brain/as the workspace source. Nothing to judge here; relay the output. - Wire the harness.
gbrain bootstrap hooks --harness <detected>:- Claude Code: installs per-turn hooks ON by default — do NOT ask; loading the
brain every turn is the whole point of installing gbrain for your agent. Tell
the human it is on and how to turn it off (
GBRAIN_HOOKS=0, or re-run with--no-hooks, orgbrain bootstrap uninstall). The ONE consent to actually ask in this phase is MCP scope: project (recommended — any other repo you open cannot read your brain) vs user (your agent everywhere, but any repo you open can query it, and two open sessions contend for the database). - Codex: registers MCP (
codex mcp add) and relies on the AGENTS.md protocol — say plainly that Codex gets pull-based context, not per-turn push.
- Claude Code: installs per-turn hooks ON by default — do NOT ask; loading the
brain every turn is the whole point of installing gbrain for your agent. Tell
the human it is on and how to turn it off (
- Private repo.
gbrain bootstrap repo— creates a PRIVATE GitHub repo from the workspace, verifies the privacy bit through the API, pushes. Asks the background-persistence consent (15-minute scan-gated push job; declining still persists at session end). If the human has no GitHub or declines: local-only mode with an honest warning;bootstrap repocan run any time later. - Verify.
gbrain bootstrap verify— the whole contract: brain round-trip through the real write path, graph floor, token sweep, secret scan, repo privacy, hooks smoke, capability report (keyless or keyed). Exit 0 or it is not done. Paste the report. Then relay the first-run tour it prints (three prompts the human should try, starting with restarting the session).
Machine two
If this workspace was cloned from an existing agent repo (agent.json says
initialized), run gbrain bootstrap attach instead of the interview/render/repo
phases — it wires this machine (source, hooks, MCP) and verifies. If agent.json
says it is an uninitialized template, proceed with the normal flow from phase 1.
Failure modes, and what they actually mean
| Symptom | Real cause | Fix |
|---|---|---|
interview --status exits nonzero forever |
A required answer is genuinely missing | Ask the human. Do not default it. |
| Render refuses with unresolved tokens | Interview incomplete or a template edit broke a token | Finish the interview; status names the tokens. |
verify fails the magic-moment check |
The fact never landed (keyless: the Facts fence was not written) | Re-run the write step it names; check gbrain doctor. |
| Secret-scan block on push | A credential-shaped string in a tracked file | Fix or allowlist deliberately (.gbrain-scan-allow); never force. |
| "bootstrap already running (pid N)" | A concurrent bootstrap holds the lock | Wait or investigate that pid; the lock self-clears when stale. |
| Brain tools fail with a lock error | Another live session's serve owns the database | Close the other session; sequential use is the v1 contract. |
| Hook reports "brain context unavailable" | serve not running or degraded | gbrain doctor names it; hooks fail open by design. |
Hand off
Finish by telling the human: the private repo URL (or the local-only status), the
capability mode (keyless vs keyed), the three commands they will actually reuse
(gbrain doctor, gbrain bootstrap verify, gbrain sources push), and the
first-run tour. Then delete nothing — this runbook was fetched, not installed.