Skip to content

feat: connect OpenClaw to GBrain with one plugin install - #200625

Merged
obviyus merged 16 commits into
mainfrom
gbrain-plugin
Nov 17, 2026
Merged

obviyus merged 16 commits into
mainfrom
gbrain-plugin

Conversation

@obviyus

@obviyus obviyus commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Connecting OpenClaw to GBrain today takes a separate install, a hand-written mcp.servers entry, a bearer key minted by hand and a service you keep alive yourself. The gbrain-context-engine plugin GBrain ships never selects a brain on multi-agent hosts, and on ClawHub gbrain returns only unofficial skills.

User Impact

User impact: on a machine with Bun 1.4.4 or newer, install the GBrain plugin (one click in the Control UI, or openclaw plugins install) and the agent can recall from your brain about a minute later. You do not edit config, mint a key or set up a service yourself. Without Bun, the plugin shows the one command that installs it (Linux also needs unzip); OpenClaw does not install Bun. Docker users add one Compose overlay, whose GBrain image includes Bun.

Why This Change Was Made

GBrain stays the owner of its own install, brain, service and upgrades. The new external plugin extensions/gbrain only connects OpenClaw to it:

  • A Gateway service runs GBrain's own commands once: bun install -g, gbrain init --pglite, gbrain mcp expose. These install the launchd or systemd user service.
  • It mints a bearer key through GBrain's owner API and writes one static streamable-HTTP mcp.servers.gbrain entry. Static means cron, heartbeat and subagent runs see it too.
  • Every 60 s it checks the connection. A rotated or revoked key is replaced automatically. When the service is down, the plugin reports it with the next command to run. It never restarts the service: that stays with launchd, systemd or Compose.
  • It leaves alone any existing mcp.servers.gbrain that points elsewhere or uses env templates.
  • Docker: deploy/gbrain/compose.yaml runs GBrain as its own service on the project network. The brain volume is mounted read-only into the Gateway.
  • No core or Plugin SDK changes. The plugin declares no config options.

GBrain's per-turn context hook (gbrain setup openclaw) stays opt-in. MCP alone recalled without prompting in every run below.

Config budget +21 (plugin): these are the generic plugins.entries.gbrain.* keys (enabled, config, hooks.*, llm.*, subagent.*) that the baseline counter writes once for every bundled plugin id (187 × 21). GBrain adds no options of its own. Counting the shared template once is a separate change to the counter.

Evidence

Control UI (host with Bun): one click, no consent dialog, recall 58.7 s after the click. Packed candidate Gateway, plugin served from a local ClawHub fixture (not published yet), real model.

Before Installing Installed Recall
GBrain plugin page before install Install progress GBrain installed and connected Agent recalls the Sandpiper vault code from GBrain

Screencast (1 click → installed → connected 4.3 s → recall from a new session):

gbrain-one-click-install.mp4

Timeline: clicked install 0 s → mcp.servers.gbrain connected 4.3 s → question sent 4.9 s → recalled 58.7 s. Clicks: 1.

Clean hosts, live model, every step exit 0:

macOS 15 VM Ubuntu VM (systemd user) Docker (ghcr.io/openclaw/openclaw:latest + overlay)
User actions install + Bun command install + apt install unzip + Bun command -f deploy/gbrain/compose.yaml + install
Connected 60 s after Bun 54 s after Bun 0 s
Recall after Gateway restart, codeword never shown to the session ✅ 55 s ✅ 64 s ✅ 58 s
brain.pglite holders with 2 concurrent sessions 1 1 1
mcp probe gbrain 8 tools 8 tools 8 tools
Stop service / kill serve / rotate key / gbrain upgrade → recall ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Uninstall keeps service and brain, removes install record ✅ ✅ ✅
  • Docker run: in the concurrent step, turn A answered the codeword correctly after 6 code-mode bridge calls, but its receipt listed no tool names, so the harness flagged it. The receipt gap is a separate issue.
  • New live lane: pnpm test:docker:gbrain. The host driver is scripts/e2e/lib/gbrain/host-e2e.sh.
  • pnpm test extensions/gbrain (unit), Docker plan test, ocx build --dts and the packed-tarball check pass at a4c2d20. The latest commit changes only the Docker lane script, which the final Docker run used.
Bugs found by the e2e runs and fixed here
  1. Shared network namespace with the Gateway: getaddrinfo ENOTFOUND gbrain after a Gateway restart. GBrain now has its own namespace.
  2. Linux: Unit gbrain-serve.service could not be found. GBrain now gets the user session bus env (minus Gateway identity and credentials).
  3. Linux: Bun links under XDG_CACHE_HOME; the plugin asks bun pm bin -g.
  4. Docker: stable_unreadable … (offline, or no git). The sidecar image includes git.
  5. Clean Linux: Bun's installer needs unzip; the message says so.

Local review (ClawSweeper, local range origin/main...d26de1b79f): complete, "patch is correct", 0 findings. Earlier rounds' findings were all fixed, with regression tests in extensions/gbrain/src/connect.test.ts where they apply:

  • Key refresh kept only URL, transport and bearer; it now keeps the user's other entry settings (enabled, toolFilter, other headers).
  • An expose --port move is followed instead of being reported as an external entry.
  • Ownership comes from the config file as authored, not the env-expanded runtime config, so Bearer ${GBRAIN_MCP_TOKEN} entries stay the user's; entries supplied or changed by an $include, and any non-canonical authorization header, also stay the user's.
  • Both e2e drivers carry the macOS Bash 5.3 heredoc guard and are registered in portableScripts.
  • Both e2e drivers fail when the GBrain downgrade or upgrade fails or leaves the version unchanged.

The plugin icon is GBrain's own 512×512 app icon from gbrain.io (assets/icon.png); the screenshots above predate it and show the generic letter placeholder.

Maintainer decision on the remaining finding: the review flags the one-time bun install -g github:garrytan/gbrain#stable in the plugin's Gateway service against extensions/AGENTS.md ("Runtime never installs deps"). Kept on purpose: that rule covers the plugin's own package dependencies. GBrain is a separate tool with its own installer, its install runs only after the user explicitly installs this plugin, it happens once, and after a failure it retries at most every 10 minutes. Moving it to Doctor would add a step to the one-click setup this PR exists for.

Known gaps (not in this PR):

  • GBrain upstream: no CLI to mint a key against a running server (the plugin uses the dashboard API), mcp expose has no --bind, no official container image. Headless Linux needs loginctl enable-linger to keep the user service after logout (not tested).
  • OpenClaw: MCP startup backoff does not reset when GBrain recovers. mcp.servers.gbrain stays after uninstall (openclaw mcp unset gbrain).
  • Bun is a prerequisite on macOS and Linux. Follow-up: install GBrain from its standalone release binaries (gbrain-darwin-arm64, gbrain-linux-x64) so neither Bun nor unzip is needed; first check that gbrain upgrade and mcp expose work without Bun and that releases publish checksums.
  • Distribution: @openclaw/gbrain is an external plugin like Discord and Codex (publishToClawHub/publishToNpm, npm default install, excluded from the core openclaw package). It publishes with the next release; until then the Control UI proof used a local ClawHub fixture. The unscoped ClawHub name gbrain belongs to an unofficial upload; this package is scoped.

- New external plugin `gbrain`: a Gateway service runs GBrain's own commands once (install with Bun, `gbrain init`, `gbrain mcp expose`), mints a bearer through GBrain's owner API, and writes one static streamable-HTTP `mcp.servers.gbrain` entry.
- Only reports when GBrain's supervised service is down; never restarts it.
- Docker overlay `deploy/gbrain/compose.yaml` runs GBrain next to the Gateway container.
- Docs page and a host e2e driver.
- Config budget +21: the generic per-plugin `plugins.entries.gbrain.*` keys every plugin gets; the plugin declares no options of its own.
…lobal bin

- Docker: GBrain runs as the `gbrain` Compose service on the project network (a shared network namespace broke on every Gateway container restart); the plugin looks for it at 127.0.0.1, then `gbrain`. The sidecar image adds git so `gbrain upgrade` works.
- GBrain commands keep the user's session env (XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESS) so `gbrain mcp expose` installs its systemd user unit; Gateway identity and credential vars stay out.
- Find the installed `gbrain` through `bun pm bin -g` (Bun honors XDG_CACHE_HOME and BUN_INSTALL_BIN).
- Bun message names unzip on Linux.
- Live Docker lane `test:docker:gbrain` and host e2e driver; ClawHub prepublish fixture serves the package detail page.
- `mcp probe` is offline-only and refuses a copied state from another PID namespace; stop the Gateway container, probe from a one-off CLI container on the project network, start it again.
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts docker Docker and sandbox tooling size: XL labels Nov 17, 2026
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Raw e2e step logs

Every step of the three clean-host runs (live model). One JSON line per step: step, exit, seconds, last output line. Produced by scripts/e2e/lib/gbrain/host-e2e.sh (macOS, Linux) and pnpm test:docker:gbrain (Docker).

macOS 15 VM: 36 steps
{"step":"node","exit":0,"seconds":2,"last":""}
{"step":"install-openclaw","exit":0,"seconds":43,"last":"npm warn install-scripts Run `npm install -g --allow-scripts=@google/genai,esbuild,protobufjs,openclaw` to allow these scripts once, or `npm config set allow-scripts=@google/genai,esbuild,protobufjs,openclaw --location=user` to allow them for all global installs."}
{"step":"onboard","exit":0,"seconds":4,"last":"Tip: run `openclaw configure --section web` to store your Brave API key for web_search. Docs: https://docs.openclaw.ai/tools/web"}
{"step":"model-secret","exit":0,"seconds":2,"last":"Updated secrets.providers.oaikey. No gateway restart needed."}
{"step":"model-provider","exit":0,"seconds":2,"last":"Updated models.providers.openai. Change will apply without restarting the gateway."}
{"step":"model-default","exit":0,"seconds":4,"last":"Updated agents.defaults.model. Change will apply without restarting the gateway."}
{"step":"gateway-start","exit":0,"seconds":7,"last":""}
{"step":"plugin-install","exit":0,"seconds":5,"last":"attempt=1"}
{"step":"bun-missing-message","exit":0,"seconds":0,"last":"2026-11-17T13:38:31.299+00:00 [plugins] GBrain needs Bun 1.4.4 or newer. Install it with: curl -fsSL https://bun.sh/install | bash (on Linux, Bun's installer also needs unzip). OpenClaw finishes the GBrain setup within a minute."}
{"step":"bun-install","exit":0,"seconds":3,"last":"Run 'bun --help' to get started"}
{"step":"connect","exit":0,"seconds":60,"last":""}
{"step":"inspect-runtime","exit":0,"seconds":2,"last":"{\"status\":\"loaded\",\"imported\":true,\"activated\":true}"}
{"step":"seed","exit":0,"seconds":1,"last":"}"}
{"step":"gateway-stop","exit":0,"seconds":1,"last":""}
{"step":"mcp-probe","exit":0,"seconds":2,"last":"- gbrain: 8 tools, resources, Codex approval auto"}
{"step":"gateway-restart","exit":0,"seconds":6,"last":""}
{"step":"recall","exit":0,"seconds":55,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"concurrent-holders","exit":0,"seconds":0,"last":"max_holders=1 parA=0 parB=0"}
{"step":"gbrain-doctor","exit":0,"seconds":1,"last":"Overall health score: 90/100. All checks OK (some warnings)."}
{"step":"fault-stop-service","exit":0,"seconds":0,"last":""}
{"step":"fault-stop-reported","exit":0,"seconds":0,"last":"2026-11-17T13:42:56.820+00:00 [plugins] GBrain's service is not answering on http://127.0.0.1:3131. Check it with: gbrain mcp expose --status"}
{"step":"fault-start-service","exit":0,"seconds":0,"last":""}
{"step":"fault-stop-recovered","exit":0,"seconds":42,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"gbrain__recall\"]}"}
{"step":"fault-kill-serve","exit":0,"seconds":0,"last":""}
{"step":"fault-kill-supervisor-restart","exit":0,"seconds":0,"last":""}
{"step":"fault-kill-recovered","exit":0,"seconds":43,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"fault-rotate-token","exit":0,"seconds":0,"last":"{\"id\":\"62ef933f-3ff1-48e3-88a7-0ee36cbc94fd\",\"revoked\":true}"}
{"step":"fault-rotate-reminted","exit":0,"seconds":0,"last":""}
{"step":"fault-rotate-recovered","exit":0,"seconds":88,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"upgrade-downgrade","exit":0,"seconds":10,"last":"gbrain 0.60.732.0"}
{"step":"upgrade-run","exit":0,"seconds":23,"last":"gbrain 0.60.734.0"}
{"step":"upgrade-recall","exit":0,"seconds":14,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"gbrain__recall\"]}"}
{"step":"uninstall","exit":0,"seconds":3,"last":"Uninstalled plugin \"gbrain\". Removed: plugin settings, install record, directory."}
{"step":"uninstall-no-record","exit":0,"seconds":0,"last":"{\"present\":false}"}
{"step":"uninstall-service-kept","exit":0,"seconds":0,"last":""}
{"step":"uninstall-brain-kept","exit":0,"seconds":0,"last":""}
Ubuntu VM, systemd user service: 37 steps
{"step":"node","exit":0,"seconds":2,"last":""}
{"step":"install-openclaw","exit":0,"seconds":43,"last":"npm warn install-scripts Run `npm install -g --allow-scripts=@google/genai,esbuild,protobufjs,openclaw` to allow these scripts once, or `npm config set allow-scripts=@google/genai,esbuild,protobufjs,openclaw --location=user` to allow them for all global installs."}
{"step":"onboard","exit":0,"seconds":3,"last":"Tip: run `openclaw configure --section web` to store your Brave API key for web_search. Docs: https://docs.openclaw.ai/tools/web"}
{"step":"model-secret","exit":0,"seconds":3,"last":"Updated secrets.providers.oaikey. No gateway restart needed."}
{"step":"model-provider","exit":0,"seconds":2,"last":"Updated models.providers.openai. Change will apply without restarting the gateway."}
{"step":"model-default","exit":0,"seconds":3,"last":"Updated agents.defaults.model. Change will apply without restarting the gateway."}
{"step":"gateway-start","exit":0,"seconds":7,"last":""}
{"step":"plugin-install","exit":0,"seconds":4,"last":"attempt=1"}
{"step":"bun-missing-message","exit":0,"seconds":0,"last":"2026-11-17T13:48:59.226+00:00 [plugins] GBrain needs Bun 1.4.4 or newer. Install it with: curl -fsSL https://bun.sh/install | bash (on Linux, Bun's installer also needs unzip). OpenClaw finishes the GBrain setup within a minute."}
{"step":"unzip-install","exit":0,"seconds":7,"last":"No VM guests are running outdated hypervisor (qemu) binaries on this host."}
{"step":"bun-install","exit":0,"seconds":4,"last":"Run 'bun --help' to get started"}
{"step":"connect","exit":0,"seconds":54,"last":""}
{"step":"inspect-runtime","exit":0,"seconds":3,"last":"{\"status\":\"loaded\",\"imported\":true,\"activated\":true}"}
{"step":"seed","exit":0,"seconds":0,"last":"}"}
{"step":"gateway-stop","exit":0,"seconds":1,"last":""}
{"step":"mcp-probe","exit":0,"seconds":3,"last":"- gbrain: 8 tools, resources, Codex approval auto"}
{"step":"gateway-restart","exit":0,"seconds":6,"last":""}
{"step":"recall","exit":0,"seconds":64,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"concurrent-holders","exit":0,"seconds":1,"last":"max_holders=1 parA=0 parB=0"}
{"step":"gbrain-doctor","exit":0,"seconds":0,"last":"Overall health score: 90/100. All checks OK (some warnings)."}
{"step":"fault-stop-service","exit":0,"seconds":0,"last":""}
{"step":"fault-stop-reported","exit":0,"seconds":0,"last":"2026-11-17T13:53:26.616+00:00 [plugins] GBrain's service is not answering on http://127.0.0.1:3131. Check it with: gbrain mcp expose --status"}
{"step":"fault-start-service","exit":0,"seconds":0,"last":""}
{"step":"fault-stop-recovered","exit":0,"seconds":53,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"gbrain__recall\"]}"}
{"step":"fault-kill-serve","exit":0,"seconds":0,"last":""}
{"step":"fault-kill-supervisor-restart","exit":0,"seconds":0,"last":""}
{"step":"fault-kill-recovered","exit":0,"seconds":38,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"fault-rotate-token","exit":0,"seconds":0,"last":"{\"id\":\"79606808-d7d2-4e6a-ad91-3f2f115ed36a\",\"revoked\":true}"}
{"step":"fault-rotate-reminted","exit":0,"seconds":0,"last":""}
{"step":"fault-rotate-recovered","exit":0,"seconds":27,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"upgrade-downgrade","exit":0,"seconds":4,"last":"gbrain 0.60.732.0"}
{"step":"upgrade-run","exit":0,"seconds":11,"last":"gbrain 0.60.734.0"}
{"step":"upgrade-recall","exit":0,"seconds":44,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"uninstall","exit":0,"seconds":3,"last":"Uninstalled plugin \"gbrain\". Removed: plugin settings, install record, directory."}
{"step":"uninstall-no-record","exit":0,"seconds":0,"last":"{\"present\":false}"}
{"step":"uninstall-service-kept","exit":0,"seconds":0,"last":""}
{"step":"uninstall-brain-kept","exit":0,"seconds":0,"last":""}
Docker, released `ghcr.io/openclaw/openclaw:latest` + `deploy/gbrain/compose.yaml`: 35 steps
{"step":"pull","exit":0,"seconds":2,"last":"ghcr.io/openclaw/openclaw:latest"}
{"step":"onboard","exit":0,"seconds":4,"last":"Tip: run `openclaw configure --section web` to store your Brave API key for web_search. Docs: https://docs.openclaw.ai/tools/web"}
{"step":"model","exit":0,"seconds":6,"last":"Updated agents.defaults.model. Change will apply without restarting the gateway."}
{"step":"compose-up","exit":0,"seconds":1,"last":" Container gbrain-e2e-89039-openclaw-gateway-1 Started "}
{"step":"gateway-ready","exit":0,"seconds":28,"last":""}
{"step":"gbrain-healthy","exit":0,"seconds":0,"last":""}
{"step":"plugin-install","exit":0,"seconds":3,"last":"attempt=1"}
{"step":"connect","exit":0,"seconds":0,"last":""}
{"step":"inspect-runtime","exit":0,"seconds":2,"last":"{\"status\":\"loaded\",\"imported\":true,\"activated\":true}"}
{"step":"mcp-probe","exit":0,"seconds":28,"last":"- gbrain: 8 tools, resources, Codex approval auto"}
{"step":"seed","exit":0,"seconds":1,"last":"}"}
{"step":"gateway-restart","exit":0,"seconds":0,"last":" Container gbrain-e2e-89039-openclaw-gateway-1 Started "}
{"step":"gateway-ready-2","exit":0,"seconds":25,"last":""}
{"step":"gbrain-after-gateway-restart","exit":0,"seconds":0,"last":""}
{"step":"recall","exit":0,"seconds":58,"last":"{\"codeword\":true,\"tools\":[\"exec\",\"memory_search\",\"sessions_search\",\"gbrain__recall\"]}"}
{"step":"concurrent-holders","exit":1,"seconds":0,"last":"max_holders=1 parA=1 parB=0"}
{"step":"gbrain-doctor","exit":0,"seconds":1,"last":"Overall health score: 90/100. All checks OK (some warnings)."}
{"step":"fault-stop-gbrain","exit":0,"seconds":0,"last":" Container gbrain-e2e-89039-gbrain-1 Stopped "}
{"step":"fault-stop-reported","exit":0,"seconds":0,"last":"openclaw-gateway-1  | \u001b[90m2026-11-17T13:51:05.490+00:00\u001b[39m \u001b[35m[plugins]\u001b[39m \u001b[33mGBrain's service is not answering on http://127.0.0.1:3131. Check it with: gbrain mcp expose --status\u001b[39m"}
{"step":"fault-start-gbrain","exit":0,"seconds":0,"last":" Container gbrain-e2e-89039-gbrain-1 Started "}
{"step":"fault-stop-recovered","exit":0,"seconds":56,"last":"{\"codeword\":true,\"tools\":[\"skills_read\",\"exec\",\"gbrain__recall\"]}"}
{"step":"fault-kill-serve","exit":0,"seconds":0,"last":"killed 6 "}
{"step":"fault-kill-compose-restart","exit":0,"seconds":0,"last":""}
{"step":"fault-kill-recovered","exit":0,"seconds":78,"last":"{\"codeword\":true,\"tools\":[\"skills_read\",\"exec\",\"memory_search\",\"gbrain__recall\"]}"}
{"step":"fault-rotate-token","exit":0,"seconds":0,"last":"revoked 7c84f083-e694-4296-9d5c-5c9e8b742497 200"}
{"step":"fault-rotate-reminted","exit":0,"seconds":0,"last":""}
{"step":"fault-rotate-recovered","exit":0,"seconds":80,"last":"{\"codeword\":true,\"tools\":[\"skills_read\",\"exec\",\"memory_search\",\"gbrain__recall\"]}"}
{"step":"upgrade-downgrade","exit":0,"seconds":6,"last":"gbrain 0.60.732.0"}
{"step":"upgrade-run","exit":0,"seconds":13,"last":"gbrain 0.60.734.0"}
{"step":"upgrade-restart","exit":0,"seconds":1,"last":" Container gbrain-e2e-89039-gbrain-1 Started "}
{"step":"upgrade-recall","exit":0,"seconds":51,"last":"{\"codeword\":true,\"tools\":[\"skills_read\",\"exec\",\"gbrain__recall\"]}"}
{"step":"uninstall","exit":0,"seconds":3,"last":"Uninstalled plugin \"gbrain\". Removed: plugin settings, install record, directory."}
{"step":"uninstall-no-record","exit":0,"seconds":1,"last":"{\"present\":false}"}
{"step":"uninstall-gbrain-kept","exit":0,"seconds":0,"last":""}
{"step":"uninstall-brain-kept","exit":0,"seconds":0,"last":""}

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Dependency graph changes

This PR changes the dependency graph.

This comment is informational because the PR author is a repository admin or an active member of @openclaw/openclaw-secops.

  • Current SHA: d26de1b79f8a3d2ebbd3393306a0c7f6740efce2
  • Approver: @obviyus
  • Repository role: admin

These dependency graph changes were made:

  • pnpm-lock.yaml
  • extensions/gbrain/package.json

Carefully review these changes before merging.

- A key refresh updated the whole `mcp.servers.gbrain` entry and dropped `enabled`, `toolFilter` and other headers; it now updates only the URL, transport and `Authorization`.
- An entry on a GBrain host with another port is still the plugin's, so `gbrain mcp expose --port` moves are followed instead of reported as external.
- The runtime config expands `${GBRAIN_MCP_TOKEN}`, so a template-backed entry looked like a literal GBrain key and could be overwritten on refresh. Ownership and the bearer now come from the config file as written; an entry from an `$include` is the user's.
… heredoc deadlock

- Both drivers use here-strings; add the shared re-exec guard and register them in `portableScripts`.
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR adds a GBrain plugin that sets up its service, creates an MCP connection, and supports Docker deployment.

Example: Ask “What is our Sandpiper vault code?” after installing the plugin.

  • Before: Connecting the brain requires a manual service installation, bearer key, and MCP configuration.
  • After: The supplied live example recalls JUNIPER-COBALT-8335 through GBrain tools.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful live evidence supports the feature, but existing-configuration defects and confirmed integration failures prevent a merge-ready verdict.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 5 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Connecting an existing OpenClaw installation to GBrain requires several manual installation, service, credential, and configuration steps.
Reason: The maintainer-authored direction removes substantial setup work through an optional plugin, and supplied live evidence demonstrates useful recall.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep this PR open: the integration has clear value and live evidence, but configuration-preservation defects and incomplete package integration block merging.

Priority: P2
Reviewed head: 0a99f73451b9057a5565bac80ed80b6888ced68a

Before merge

  • [P1] Preserve MCP entries inherited through ancestor includes (P1) - For a root config containing $include: './shared.json5' and mcp: {sessionIdleTtlMs: 60000}, where shared.json5 defines mcp.servers.gbrain, traversal descends into the local mcp object and returns undefined because it lacks servers. It forgets the root include, although the config owner deep-merges that included server into the effective configuration. connectGbrain then treats the connection as absent and writeServer replaces its URL and bearer with the local brain’s connection. Resolve authored ownership using the existing include provenance so this supported configuration remains untouched.
  • [P1] Handle authorization header names case-insensitively (P1) - A valid existing entry with headers: {authorization: 'Bearer ${GBRAIN_MCP_TOKEN}'} passes isManaged because only the capitalized Authorization property is examined. The plugin then mints a key and adds Authorization while retaining authorization. This violates the promised template preservation and supplies competing values for the same HTTP header; the MCP transport constructs case-insensitive Headers from this configuration. Inspect authorization names case-insensitively and preserve foreign/template-backed credentials.
  • [P2] Route GBrain requests through the supported HTTP helper (P2) - The four new raw fetch calls fall under the existing extensions runtime guard and have no allowlist entries. Exact-head CI identifies lint:tmp:no-raw-channel-fetch as failing, and scripts/check-no-raw-channel-fetch.mts independently confirms these calls are rejected. Use the existing Plugin SDK guarded HTTP path with the intended local-service policy and response cleanup for health, initialize, login, and key creation.
  • [P2] Include the required package-local plugin artwork (P2) - Adding this top-level plugin manifest enrolls GBrain in the existing artwork contract, but the package contains neither assets/icon.png nor assets/activity.svg. Exact-head CI fails opening the missing identity icon. Add the required 512px identity PNG and activity SVG rather than weakening the shared contract.
  • [P2] Regenerate the plugin inventory and reference pages (P2) - The new manifest changes the generator’s authoritative plugin set, but the PR updates neither docs/plugins/plugin-inventory.md nor the generated reference index and GBrain page. The generator checks every top-level manifest, including unpublished plugins, and exact-head CI reports plugin-inventory failure. Run pnpm plugins:inventory:gen and commit its generated outputs, with distribution metadata matching the intended source-only state.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] [P1] Preserve MCP entries inherited through ancestor includes — extensions/gbrain/index.ts:100-106
  • [P1] [P1] Handle authorization header names case-insensitively — extensions/gbrain/src/connect.ts:105-106
  • [P2] [P2] Route GBrain requests through the supported HTTP helper — extensions/gbrain/src/gbrain-http.ts:10

Tests

  • Missing end-to-end proof: Show an OpenClaw v2026.11.5-to-candidate upgrade and plugin installation preserving existing include-owned and template-backed MCP connections, using redacted terminal output or logs.
Agent review details

How this fits together

A Gateway plugin service invokes GBrain’s setup commands, reads its service receipt, obtains a bearer key through its owner API, and persists a static MCP connection for agent runs.

flowchart LR
  A[Plugin installation] --> B[Gateway plugin service]
  B --> C[GBrain setup commands]
  C --> D[GBrain supervised service]
  B --> E[OpenClaw MCP configuration]
  E --> F[Agent MCP tools]
  F --> D
Loading

Technical review

Best possible solution:

Keep the plugin-local connector, preserve authored MCP ownership through the existing config owner, and complete its package assets and generated documentation.

Do we have a high-confidence way to reproduce the issue?

The configuration defects follow directly from the authored-config traversal and case-sensitive header lookup; no target code was executed during this read-only review.

Is this the best way to solve the issue?

A plugin using GBrain’s own service and the existing static MCP configuration is an appropriate boundary, but its ownership checks must cover supported authored configurations.

Full review comments:

  • [P1] [P1] Preserve MCP entries inherited through ancestor includes — extensions/gbrain/index.ts:100-106
    For a root config containing $include: './shared.json5' and mcp: {sessionIdleTtlMs: 60000}, where shared.json5 defines mcp.servers.gbrain, traversal descends into the local mcp object and returns undefined because it lacks servers. It forgets the root include, although the config owner deep-merges that included server into the effective configuration. connectGbrain then treats the connection as absent and writeServer replaces its URL and bearer with the local brain’s connection. Resolve authored ownership using the existing include provenance so this supported configuration remains untouched.
    Confidence: 0.99
  • [P1] [P1] Handle authorization header names case-insensitively — extensions/gbrain/src/connect.ts:105-106
    A valid existing entry with headers: {authorization: 'Bearer ${GBRAIN_MCP_TOKEN}'} passes isManaged because only the capitalized Authorization property is examined. The plugin then mints a key and adds Authorization while retaining authorization. This violates the promised template preservation and supplies competing values for the same HTTP header; the MCP transport constructs case-insensitive Headers from this configuration. Inspect authorization names case-insensitively and preserve foreign/template-backed credentials.
    Confidence: 0.99
  • [P2] [P2] Route GBrain requests through the supported HTTP helper — extensions/gbrain/src/gbrain-http.ts:10
    The four new raw fetch calls fall under the existing extensions runtime guard and have no allowlist entries. Exact-head CI identifies lint:tmp:no-raw-channel-fetch as failing, and scripts/check-no-raw-channel-fetch.mts independently confirms these calls are rejected. Use the existing Plugin SDK guarded HTTP path with the intended local-service policy and response cleanup for health, initialize, login, and key creation.
    Confidence: 1
  • [P2] [P2] Include the required package-local plugin artwork — extensions/gbrain/openclaw.plugin.json:2-4
    Adding this top-level plugin manifest enrolls GBrain in the existing artwork contract, but the package contains neither assets/icon.png nor assets/activity.svg. Exact-head CI fails opening the missing identity icon. Add the required 512px identity PNG and activity SVG rather than weakening the shared contract.
    Confidence: 1
  • [P2] [P2] Regenerate the plugin inventory and reference pages — extensions/gbrain/openclaw.plugin.json:2
    The new manifest changes the generator’s authoritative plugin set, but the PR updates neither docs/plugins/plugin-inventory.md nor the generated reference index and GBrain page. The generator checks every top-level manifest, including unpublished plugins, and exact-head CI reports plugin-inventory failure. Run pnpm plugins:inventory:gen and commit its generated outputs, with distribution metadata matching the intended source-only state.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1f75f9cec0ee.

Provenance checked

  • Generated configuration baseline keeps the original intent (3a3eed8: The existing generated baseline records the configuration surface; the increase matches one plugin’s shared template.)
  • Prepublish ClawHub fixture keeps the original intent (b40f846: The fixture keeps plugin installation hermetic; the new detail response remains derived from its verified packed artifacts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/gbrain
  • pnpm test src/plugins/bundled-plugin-icons.test.ts
  • pnpm lint:tmp:no-raw-channel-fetch
  • pnpm plugins:inventory:check
  • pnpm check:extension-package-boundary

What I checked:

PR surface

Source +607, Tests +255, Docs +90, Config +34, Generated 0, Other +694. Total +1680 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 607 0 +607
Tests 2 255 0 +255
Docs 2 90 0 +90
Config 3 34 0 +34
Generated 2 3 3 0
Other 7 694 0 +694
Total 20 1683 3 +1680

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Configuration surface 0 plugin-schema properties; +21 generic plugin baseline keys The baseline increase comes from the shared plugin template; the Compose deployment separately exposes GBRAIN_INSTALL_SPEC.

Labels

Label changes:

  • add P2: This is a useful optional integration with focused repairs, without evidence of an urgent released regression.
  • add merge-risk: 🚨 compatibility: Installing the plugin can replace an existing include-owned connection or alter a template-backed authorization header.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a useful optional integration with focused repairs, without evidence of an urgent released regression.
  • merge-risk: 🚨 compatibility: Installing the plugin can replace an existing include-owned connection or alter a template-backed authorization header.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 17, 2026, 9:44 AM ET / 14:44 UTC.

… user

- Ownership tracks every `$include` on the `mcp.servers.gbrain` path and compares the root entry with the include-resolved one, so an entry an include supplies or changes is never rewritten.
- Any Authorization header spelled other than `Authorization` marks the entry as the user's, so the plugin never adds a second auth header.
… match

- One rule replaces the include walk: an `$include` at any depth (headers included) or an `${ENV}` value makes the written entry differ from the resolved one, so the entry stays the user's.
… fails

- `gbrain upgrade; gbrain --version` hid upgrade failures and neither step called `fail`; the upgrade step now needs a zero exit and a version other than the downgraded one.
- `assets/icon.png` is gbrain.io's 512x512 app icon (`/icons/icon-512.png`), unchanged.
- OpenClaw does not install Bun; on a host without Bun the plugin shows the installer command, and Linux also needs unzip.
- CI `no-raw-channel-fetch`: every GBrain request now goes through `fetchWithSsrFGuard`, allowing only GBrain's exact origin, with no redirects and no capture (requests carry owner and API keys).
…rnal plugin

- Same shape as Discord and Codex: publishToClawHub/publishToNpm, install specs with npm as the default, minimum host 2026.11.4, and `!dist/extensions/gbrain/**` so the core openclaw package does not carry it.
- Fixes CI `No packaged surface for extension boundary: gbrain`; adds the package README the npm release requires and regenerates the plugin inventory.
- Replace unchecked JSON type assertions with one `asRecord` reader (two remaining assertions carry SAFETY comments); update the entry in place instead of a single-use generic.
- Add the required monochrome `assets/activity.svg`: the G from GBrain's MIT wordmark.
- Drop the ClawHub fixture detail route: only the UI recording used it, and it broke the fixture's 404 contract.
- CI `coercion-helpers` bans local record coercion helpers in bundled plugins; use `asOptionalRecord` from `openclaw/plugin-sdk/string-coerce-runtime`.
- The previous commit left out the formatter-moved import line.
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: landing d26de1b79f8a3d2ebbd3393306a0c7f6740efce2 past one failing CI job this PR does not cause.

  • Failing job: checks-node-changed-4 (run 44142063615, job 134248753916). openclaw/ci-gate only aggregates it.
  • Failure: test/e2e/qa-lab/runtime/channel-progress-presentation.e2e.test.ts > retains ambiguous Discord announcement custody after an unidentified send — timed out waiting for ambiguous announcement settlement.
  • Same failure on an unrelated PR: fix/queued-input-end-cause, job 134209259308, identical error.
  • This PR changes no Discord, channel, qa-lab or announcement code (git diff --name-only origin/main...HEAD has none); it adds the external extensions/gbrain plugin, its docs and its e2e lanes.
  • Every other required check is green on this head, and the local ClawSweeper review of this exact head is complete with no findings.

@obviyus
obviyus merged commit 2718a07 into main Nov 17, 2026
238 of 241 checks passed
@obviyus
obviyus deleted the gbrain-plugin branch November 17, 2026 18:25
@obviyus

obviyus commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 2718a07.

  • Problem: connecting OpenClaw to GBrain took a separate install, a hand-written mcp.servers entry, a hand-minted key and a service you kept alive yourself.
  • Fix: the new external @openclaw/gbrain plugin runs GBrain's own setup once, mints a key through GBrain's owner API and writes one streamable-HTTP mcp.servers.gbrain entry. GBrain keeps owning its install, brain, service and upgrades; the plugin never restarts the service and leaves user-authored entries alone. Docker users add deploy/gbrain/compose.yaml. Bun 1.4.4+ is a stated prerequisite on macOS and Linux.
  • Proof: live-model e2e on clean macOS and Ubuntu VMs and in Docker (recall after Gateway restart, one PGLite holder, service stop/kill, key rotation, gbrain upgrade, uninstall), the one-click Control UI recording above, plugin unit tests and a clean local ClawSweeper review of the merged head. The one failing CI job, a Discord channel-progress timeout, is unrelated (override comment above).
  • Ships: to ClawHub and npm with the next release.
  • Follow-up: install GBrain from its standalone release binaries so Apple Silicon Macs and x86-64 Linux need no Bun.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…0625)

## What Problem This Solves

Connecting OpenClaw to [GBrain](https://github.com/garrytan/gbrain) today takes a separate install, a hand-written `mcp.servers` entry, a bearer key minted by hand and a service you keep alive yourself. The `gbrain-context-engine` plugin GBrain ships never selects a brain on multi-agent hosts, and on ClawHub `gbrain` returns only unofficial skills.

## User Impact

User impact: on a machine with Bun 1.4.4 or newer, install the GBrain plugin (one click in the Control UI, or `openclaw plugins install`) and the agent can recall from your brain about a minute later. You do not edit config, mint a key or set up a service yourself. Without Bun, the plugin shows the one command that installs it (Linux also needs `unzip`); OpenClaw does not install Bun. Docker users add one Compose overlay, whose GBrain image includes Bun.

## Why This Change Was Made

GBrain stays the owner of its own install, brain, service and upgrades. The new external plugin `extensions/gbrain` only connects OpenClaw to it:

- A Gateway service runs GBrain's own commands once: `bun install -g`, `gbrain init --pglite`, `gbrain mcp expose`. These install the launchd or systemd user service.
- It mints a bearer key through GBrain's owner API and writes one static streamable-HTTP `mcp.servers.gbrain` entry. Static means cron, heartbeat and subagent runs see it too.
- Every 60 s it checks the connection. A rotated or revoked key is replaced automatically. When the service is down, the plugin reports it with the next command to run. It never restarts the service: that stays with launchd, systemd or Compose.
- It leaves alone any existing `mcp.servers.gbrain` that points elsewhere or uses env templates.
- Docker: `deploy/gbrain/compose.yaml` runs GBrain as its own service on the project network. The brain volume is mounted read-only into the Gateway.
- No core or Plugin SDK changes. The plugin declares no config options.

GBrain's per-turn context hook (`gbrain setup openclaw`) stays opt-in. MCP alone recalled without prompting in every run below.

**Config budget +21 (`plugin`):** these are the generic `plugins.entries.gbrain.*` keys (`enabled`, `config`, `hooks.*`, `llm.*`, `subagent.*`) that the baseline counter writes once for every bundled plugin id (187 × 21). GBrain adds no options of its own. Counting the shared template once is a separate change to the counter.

## Evidence

**Control UI (host with Bun): one click, no consent dialog, recall 58.7 s after the click.** Packed candidate Gateway, plugin served from a local ClawHub fixture (not published yet), real model.

| Before | Installing | Installed | Recall |
|---|---|---|---|
| ![GBrain plugin page before install](https://github.com/user-attachments/assets/45dfbbd0-7f37-415d-bcc8-74333c7788a2) | ![Install progress](https://github.com/user-attachments/assets/132917e4-a007-4a7f-8e5e-5fdc36d65600) | ![GBrain installed and connected](https://github.com/user-attachments/assets/28084efc-0430-44e5-a9df-a1bbb2bb872e) | ![Agent recalls the Sandpiper vault code from GBrain](https://github.com/user-attachments/assets/5285b917-b213-4101-ba24-b1d574f8d699) |

Screencast (1 click → installed → connected 4.3 s → recall from a new session):

https://github.com/user-attachments/assets/0d5dc907-4fb1-4265-b84c-0b497d0f4e53

Timeline: clicked install 0 s → `mcp.servers.gbrain` connected 4.3 s → question sent 4.9 s → recalled 58.7 s. Clicks: 1.

**Clean hosts, live model, every step exit 0:**

| | macOS 15 VM | Ubuntu VM (systemd user) | Docker (`ghcr.io/openclaw/openclaw:latest` + overlay) |
|---|---|---|---|
| User actions | install + Bun command | install + `apt install unzip` + Bun command | `-f deploy/gbrain/compose.yaml` + install |
| Connected | 60 s after Bun | 54 s after Bun | 0 s |
| Recall after Gateway restart, codeword never shown to the session | ✅ 55 s | ✅ 64 s | ✅ 58 s |
| `brain.pglite` holders with 2 concurrent sessions | 1 | 1 | 1 |
| `mcp probe gbrain` | 8 tools | 8 tools | 8 tools |
| Stop service / kill serve / rotate key / `gbrain upgrade` → recall | ✅ ✅ ✅ ✅ | ✅ ✅ ✅ ✅ | ✅ ✅ ✅ ✅ |
| Uninstall keeps service and brain, removes install record | ✅ | ✅ | ✅ |

- Docker run: in the concurrent step, turn A answered the codeword correctly after 6 code-mode bridge calls, but its receipt listed no tool names, so the harness flagged it. The receipt gap is a separate issue.
- New live lane: `pnpm test:docker:gbrain`. The host driver is `scripts/e2e/lib/gbrain/host-e2e.sh`.
- `pnpm test extensions/gbrain` (unit), Docker plan test, `ocx build --dts` and the packed-tarball check pass at `a4c2d20`. The latest commit changes only the Docker lane script, which the final Docker run used.

<details><summary>Bugs found by the e2e runs and fixed here</summary>

1. Shared network namespace with the Gateway: `getaddrinfo ENOTFOUND gbrain` after a Gateway restart. GBrain now has its own namespace.
2. Linux: `Unit gbrain-serve.service could not be found.` GBrain now gets the user session bus env (minus Gateway identity and credentials).
3. Linux: Bun links under `XDG_CACHE_HOME`; the plugin asks `bun pm bin -g`.
4. Docker: `stable_unreadable … (offline, or no git)`. The sidecar image includes git.
5. Clean Linux: Bun's installer needs `unzip`; the message says so.
</details>

**Local review (ClawSweeper, local range `origin/main...d26de1b`):** complete, "patch is correct", 0 findings. Earlier rounds' findings were all fixed, with regression tests in `extensions/gbrain/src/connect.test.ts` where they apply:
- Key refresh kept only URL, transport and bearer; it now keeps the user's other entry settings (`enabled`, `toolFilter`, other headers).
- An `expose --port` move is followed instead of being reported as an external entry.
- Ownership comes from the config file as authored, not the env-expanded runtime config, so `Bearer ${GBRAIN_MCP_TOKEN}` entries stay the user's; entries supplied or changed by an `$include`, and any non-canonical `authorization` header, also stay the user's.
- Both e2e drivers carry the macOS Bash 5.3 heredoc guard and are registered in `portableScripts`.
- Both e2e drivers fail when the GBrain downgrade or upgrade fails or leaves the version unchanged.

The plugin icon is GBrain's own 512×512 app icon from gbrain.io (`assets/icon.png`); the screenshots above predate it and show the generic letter placeholder.

**Maintainer decision on the remaining finding:** the review flags the one-time `bun install -g github:garrytan/gbrain#stable` in the plugin's Gateway service against `extensions/AGENTS.md` ("Runtime never installs deps"). Kept on purpose: that rule covers the plugin's own package dependencies. GBrain is a separate tool with its own installer, its install runs only after the user explicitly installs this plugin, it happens once, and after a failure it retries at most every 10 minutes. Moving it to Doctor would add a step to the one-click setup this PR exists for.

**Known gaps (not in this PR):**
- GBrain upstream: no CLI to mint a key against a running server (the plugin uses the dashboard API), `mcp expose` has no `--bind`, no official container image. Headless Linux needs `loginctl enable-linger` to keep the user service after logout (not tested).
- OpenClaw: MCP startup backoff does not reset when GBrain recovers. `mcp.servers.gbrain` stays after uninstall (`openclaw mcp unset gbrain`).
- Bun is a prerequisite on macOS and Linux. Follow-up: install GBrain from its standalone release binaries (`gbrain-darwin-arm64`, `gbrain-linux-x64`) so neither Bun nor `unzip` is needed; first check that `gbrain upgrade` and `mcp expose` work without Bun and that releases publish checksums.
- Distribution: `@openclaw/gbrain` is an external plugin like Discord and Codex (`publishToClawHub`/`publishToNpm`, npm default install, excluded from the core `openclaw` package). It publishes with the next release; until then the Control UI proof used a local ClawHub fixture. The unscoped ClawHub name `gbrain` belongs to an unofficial upload; this package is scoped.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 18, 2026
…ux (#200987)

## What Problem This Solves

The GBrain plugin (#200625) needs Bun to install GBrain. On a clean Mac or Linux machine that meant a terminal step after the one-click install: run Bun's installer, and on Linux install `unzip` first.

## User Impact

User impact: on Apple Silicon macOS and x86-64 Linux without Bun, installing the GBrain plugin is now the only step. The plugin installs GBrain's own release binary and connects; on a clean macOS VM it was connected 14 seconds after the install request. Existing Bun users keep the same Bun install. Intel macOS and ARM Linux, where GBrain publishes no binary, still show the Bun command.

## Why This Change Was Made

When `gbrain` is missing and Bun is not installed, the plugin:

1. Reads GBrain's stable version from its documented `stable/VERSION` file.
2. Downloads that release's asset (`gbrain-darwin-arm64` or `gbrain-linux-x64`) to `~/.gbrain/bin/gbrain`.
3. Accepts it only when GitHub's build-provenance attestation for its SHA-256 names that asset and GBrain's release workflow on `master`. This is the same check GBrain's own binary self-update uses (`src/core/binary-self-update.ts`). Nothing is made executable or moved into place before the check passes.

GBrain then owns the binary as it does any install: `gbrain mcp expose` supervises the service, and `gbrain upgrade` self-updates the binary in place. When Bun is present the plugin keeps using Bun, so existing installs and the GitHub API limit (see below) cannot block a host that can already install.

The release download uses GitHub's fixed download URL; only the attestation lookup uses GitHub's API (one unauthenticated request per install). The plugin logs where it installed GBrain and that `~/.gbrain/bin` must be on `PATH` to run `gbrain` in a terminal. It does not edit shell files.

## Evidence

**Clean hosts, packed candidate, live model:**

| | macOS 15 VM, Apple Silicon (binary path) | Ubuntu VM, ARM (Bun fallback) |
|---|---|---|
| Bun on host before install | none | none |
| User steps | install only | install + `apt install unzip` + Bun command |
| Connected after install | 14 s | 64 s after Bun |
| `~/.gbrain/bin/gbrain --version` | 0.60.734.0 | (Bun install) |
| Recall after Gateway restart | ✅ | ✅ |
| One `brain.pglite` holder, 2 concurrent sessions | ✅ | ✅ |
| Stop / kill / key rotation → recall | ✅ ✅ ✅ | ✅ ✅ ✅ |
| `gbrain upgrade` (from 0.60.733.0) → recall | ✅ | ✅ |
| Uninstall keeps service and brain | ✅ | ✅ |

- Earlier runs of the same flow each failed one step: macOS run 2 and ARM Linux run 1. The failing steps were the service-restart recall, where the Gateway's MCP client tried GBrain moments before its restarted service answered, and one of two concurrent recall turns. Both were green on the next run. This is the known MCP retry gap from #200625.
- One macOS run hit GitHub's unauthenticated API limit (HTTP 403, 60 requests an hour per network). That led to dropping the releases API call and to a clear "limit used up, resets within an hour" status. The plugin retries within 10 minutes.
- x86-64 Linux (privileged Ubuntu container under Rosetta): the binary runs, `gbrain init` and `gbrain serve` work with health `ok`, with no Bun, git or unzip on the host.
- Unit tests cover the binary install, a failed download, Bun-first ordering, and the attestation check rejecting a fork, another workflow, another branch, the wrong asset or the wrong digest.

- Local ClawSweeper review (local range `origin/main...90ad0c3`): complete, "patch is correct", 0 findings. Earlier rounds found that an existing Bun install could be skipped, that a GitHub API limit could block a Bun host, and that the Bun-free e2e assertion could pass with Bun present; all fixed.

**Known gaps:**
- No full x86-64 Linux e2e. GBrain installs no service inside containers, and no x86 Linux VM was available.
- GBrain upstream: after an upgrade, `gbrain upgrade` checks the new version through `PATH`, not the binary it replaced. Without `~/.gbrain/bin` on `PATH` it swaps the binary, fails, and skips the service restart.
- GBrain upstream: `gbrain upgrade` reads the stable channel with `git ls-remote`, so a binary install on Linux needs `git` to upgrade (Bun installs had the same need).
- GBrain upstream: no binary for Intel macOS or ARM Linux.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…ux (openclaw#200987)

## What Problem This Solves

The GBrain plugin (openclaw#200625) needs Bun to install GBrain. On a clean Mac or Linux machine that meant a terminal step after the one-click install: run Bun's installer, and on Linux install `unzip` first.

## User Impact

User impact: on Apple Silicon macOS and x86-64 Linux without Bun, installing the GBrain plugin is now the only step. The plugin installs GBrain's own release binary and connects; on a clean macOS VM it was connected 14 seconds after the install request. Existing Bun users keep the same Bun install. Intel macOS and ARM Linux, where GBrain publishes no binary, still show the Bun command.

## Why This Change Was Made

When `gbrain` is missing and Bun is not installed, the plugin:

1. Reads GBrain's stable version from its documented `stable/VERSION` file.
2. Downloads that release's asset (`gbrain-darwin-arm64` or `gbrain-linux-x64`) to `~/.gbrain/bin/gbrain`.
3. Accepts it only when GitHub's build-provenance attestation for its SHA-256 names that asset and GBrain's release workflow on `master`. This is the same check GBrain's own binary self-update uses (`src/core/binary-self-update.ts`). Nothing is made executable or moved into place before the check passes.

GBrain then owns the binary as it does any install: `gbrain mcp expose` supervises the service, and `gbrain upgrade` self-updates the binary in place. When Bun is present the plugin keeps using Bun, so existing installs and the GitHub API limit (see below) cannot block a host that can already install.

The release download uses GitHub's fixed download URL; only the attestation lookup uses GitHub's API (one unauthenticated request per install). The plugin logs where it installed GBrain and that `~/.gbrain/bin` must be on `PATH` to run `gbrain` in a terminal. It does not edit shell files.

## Evidence

**Clean hosts, packed candidate, live model:**

| | macOS 15 VM, Apple Silicon (binary path) | Ubuntu VM, ARM (Bun fallback) |
|---|---|---|
| Bun on host before install | none | none |
| User steps | install only | install + `apt install unzip` + Bun command |
| Connected after install | 14 s | 64 s after Bun |
| `~/.gbrain/bin/gbrain --version` | 0.60.734.0 | (Bun install) |
| Recall after Gateway restart | ✅ | ✅ |
| One `brain.pglite` holder, 2 concurrent sessions | ✅ | ✅ |
| Stop / kill / key rotation → recall | ✅ ✅ ✅ | ✅ ✅ ✅ |
| `gbrain upgrade` (from 0.60.733.0) → recall | ✅ | ✅ |
| Uninstall keeps service and brain | ✅ | ✅ |

- Earlier runs of the same flow each failed one step: macOS run 2 and ARM Linux run 1. The failing steps were the service-restart recall, where the Gateway's MCP client tried GBrain moments before its restarted service answered, and one of two concurrent recall turns. Both were green on the next run. This is the known MCP retry gap from openclaw#200625.
- One macOS run hit GitHub's unauthenticated API limit (HTTP 403, 60 requests an hour per network). That led to dropping the releases API call and to a clear "limit used up, resets within an hour" status. The plugin retries within 10 minutes.
- x86-64 Linux (privileged Ubuntu container under Rosetta): the binary runs, `gbrain init` and `gbrain serve` work with health `ok`, with no Bun, git or unzip on the host.
- Unit tests cover the binary install, a failed download, Bun-first ordering, and the attestation check rejecting a fork, another workflow, another branch, the wrong asset or the wrong digest.

- Local ClawSweeper review (local range `origin/main...90ad0c3`): complete, "patch is correct", 0 findings. Earlier rounds found that an existing Bun install could be skipped, that a GitHub API limit could block a Bun host, and that the Bun-free e2e assertion could pass with Bun present; all fixed.

**Known gaps:**
- No full x86-64 Linux e2e. GBrain installs no service inside containers, and no x86 Linux VM was available.
- GBrain upstream: after an upgrade, `gbrain upgrade` checks the new version through `PATH`, not the binary it replaced. Without `~/.gbrain/bin` on `PATH` it swaps the binary, fails, and skips the service restart.
- GBrain upstream: `gbrain upgrade` reads the stable channel with `git ls-remote`, so a binary install on Linux needs `git` to upgrade (Bun installs had the same need).
- GBrain upstream: no binary for Intel macOS or ARM Linux.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files docker Docker and sandbox tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant