Repository navigation
v1.93.29.0 fix(memory): a loopback gbrain serve --http is a local brain, not Path 4 (#3539) - #3727
Conversation
Tests from #3552. On main they fail: 21 locality/detect cases, 1 local-status case, 3 memory-ingest cases. Co-authored-by: Willy Morin <3635875+wmorin@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…h 4 (#3539) gbrain's recommended setup for local agents on a Postgres brain is one resident `gbrain serve --http` on loopback, registered as an http MCP entry. gstack classified every http entry as a remote brain, so memory ingest staged transcripts for a brain admin's pull that never comes. - lib/gbrain-mcp-locality.ts: one rule. An http/url/sse entry is local when its URL is http(s) on a loopback host and the local gbrain config has an engine and no remote_mcp marker. A URL with userinfo or ${ is never local. - gstack-memory-ingest: the loopback case takes the gbrain import path, and entries left staged/remote-http import on the next local run. - gstack-gbrain-detect: all three tiers use the rule; tier 2 classifies the whole URL token of the claude mcp list line. - gbrain-local-status: hasRemoteOnlyGbrainMcp uses the same classifier. - gstack-skill-start: the jq hot path carries a conservative subset. - USING_GBRAIN_WITH_GSTACK.md: a loopback serve over this machine's engine is not Path 4. Ported from #3552 onto current main. Co-authored-by: Willy Morin <3635875+wmorin@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
#3539) The pregate secrets stage read four userinfo URLs in the locality test as basic-auth credentials (creds.basic_auth_url). Use the PASSWORD placeholder token and split the port-lookalike URLs so the same strings reach the rule. Co-authored-by: Willy Morin <3635875+wmorin@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
test/spawnsync-timeout-tripwire.test.ts requires every sync spawn in the test trees to carry a timeout; the jq parity helper had none (remote pregate, tree 037200b). Co-authored-by: Willy Morin <3635875+wmorin@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
…ow reads local-stdio (#3539) The owned Path 4 fixture registers its fake brain at 127.0.0.1 and then runs gbrain init --pglite in the same HOME. Under the #3539 rule a loopback HTTP entry over this machine's own engine is a local brain, so detect reports local-stdio there. free-suite (7) on PR #3727 (run 41231145675) failed on the old remote-http expectation. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…in (#3539) Path 4's split-engine setup pairs a remote brain with a local PGLite for code search; through a tunnel on a loopback port, the PGLite config made the remote brain read as local, so transcripts would import into the code-search PGLite and the trust-policy step would be skipped. The loopback rule now needs a Postgres config (a database_url, engine not pglite), which is the setup gbrain recommends the resident serve for. The setup-gbrain Path 4 fixture expects remote-http again, as on main. Decided by GStack Minder (Captain), 2026-10-31. Co-authored-by: Willy Morin <3635875+wmorin@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
E2E Evals: ✅ PASS (flaky: 1 case(s) passed on their one rerun)125 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $33.65 rule/judge cost | reconcile exit: 0 Profile: pr / mode Full gate restored by:
Rule and judge shards
Fail-closed reconciliationSliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry. Flaky: failed once, passed on its one rerun (rule 16)Each failed and passed on its rerun in run 41539860218 at the attempts named above. Logged for the daily flaky-fix pass in this run's Dispatched narrow screen (gstack-ship-queue ready --screen) of merge commit |
…tor-gate Rule 19 grant (GStack Minder, GSTA-36). The only conflict was the import block of bin/gstack-gbrain-detect, next to #3727's gbrain-mcp-locality import; both imports are kept. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
What changed
A gbrain serve --http on this machine's loopback address over its own Postgres engine now reads as a local brain (local-stdio), not a remote Path 4 brain, so /sync-gbrain imports transcripts again (#3539).
Before/after as text: A gbrain serve --http on this machine's loopback address over its own Postgres engine now reads as a local brain (local-stdio), not a remote Path 4 brain, so /sync-gbrain imports transcripts again (#3539).
Proof
The tests come first in commit f371261, on top of main (c830c9b). The test files as they stand at ff81a14, run against main's code (c830c9b):
test/gstack-gbrain-detect-mcp-mode.test.ts: 9 of its 47 cases are red.test/gbrain-local-status.test.ts: 1 of its 56 cases is red.test/gstack-memory-ingest.test.ts -t 3539: 3 of its 6 cases are red.test/gbrain-mcp-locality.test.ts: the file can't load, becauselib/gbrain-mcp-locality.tsis new in this PR, so none of its 120 cases run. (The f371261 commit message counts "21 locality/detect cases"; the run above is the measured result.)At ff81a14 all four files are green: every detect case (47), every locality and local-status case (180), and every
-t 3539case (6). The before/after image above isgstack-gbrain-detecton a machine set up the waygbrain bootstrap harnesssets it up, run at main and at this branch.What users hit: the reporter's transcripts stopped importing for three weeks. Their ingest state shows 2071 sessions
ingestedup to the day before they switched to the loopback serve, then onlystaged/remote-httpafter it (#3539).Why
"Transcript ingest silently stopped importing after I followed gbrain's recommended setup for local agents on a Postgres brain" (#3539). gstack treated any HTTP gbrain MCP entry as a brain on another machine, so
/sync-gbrainstaged pages for a brain admin who doesn't exist. Now a loopback serve over this machine's own Postgres brain counts as local, transcripts go throughgbrain importagain, and pages stuck as staged are imported on the next run.Behavior changes
A loopback gbrain MCP entry is local only when this machine's gbrain config names a Postgres engine (a non-blank
database_url, engine notpglite) and has noremote_mcpmarker. PGLite configs stay remote: a loopback URL next to a local PGLite is still Path 4's split-engine setup, so a remote brain reached through an SSH tunnel or port forward on a loopback port keeps staging transcripts as before. Decided by GStack Minder (Captain), 2026-10-31 (option A2, commit ff81a14).Blast radius
The new rule in
lib/gbrain-mcp-locality.tsfeedsgstack-gbrain-detect(all three tiers),gstack-memory-ingest,gbrain-local-statusand thegstack-skill-startbanner (a jq copy that the test suite checks never says local where the TypeScript rule says remote). Only HTTP entries whose URL is http(s) onlocalhost,127.0.0.0/8or::1with no userinfo or${, on a machine whose gbrain config names a Postgres engine (database_url, not PGLite) and has noremote_mcpmarker, change classification; every other entry is classified as before (script ran: detect probes for loopback,remote_mcpmarker, userinfo, remote host and::1gave local-stdio, remote-http, remote-http, remote-http, local-stdio). One trade-off remains, documented inUSING_GBRAIN_WITH_GSTACK.md: an SSH tunnel to a remote brain on a loopback port, on a machine whose own gbrain config is a Postgresdatabase_url, counts as local. The PGLite split-engine case (Path 4) stays remote.Security read
The rule reads only local files (
~/.claude.jsonandgbrainConfigDir()/config.json) and theHOMEandGBRAIN_HOMEenvironment variables that locate them. It makes no network calls. The tests run onlyjqand local fixture scripts. There are no new dependencies and no workflow, setup or install edits. The A2 change (ff81a14) only narrows the rule: it reads the same config file and adds no inputs. The change is written on current main from #3552, and its code was read line by line before it was carried over (Co-authored-by Willy Morin).Independent text-only read of #3552's full diff and every fixture its tests run (openai/gpt-6.1-sol, a reviewer that did not write the port): no exfiltration or obfuscation. #3552's own code reads only HOME and GBRAIN_HOME (through gbrainConfigDir), writes only inside the test temp roots, and makes no network calls. The existing test harness it reuses, unchanged on main, does more: buildGbrainEnv reads DATABASE_URL, and runDetect keeps the real PATH, so a detect fallback case can start a real
claude mcp listorgbrain doctorwhen those are installed.Approvals
Source: gstack-approvals record for gsta209-loopback-gbrain-local (display only; not an approval citation).
Summary
Ported from @wmorin's #3552 onto current main, with credit kept on every commit that carries his code. #3552 will be closed as superseded once this merges. On top of the port there are three test-only changes. Four userinfo fixtures in the locality test now avoid the pregate secrets scanner's basic-auth pattern (same strings reach the rule). The jq parity helper's
execFileSyncgets a 30-second timeout, whichtest/spawnsync-timeout-tripwire.test.tsrequires.test/setup-gbrain-fixture.test.tsbriefly expectedlocal-stdiofrom its owned Path 4 fixture (4924be8). GStack Minder then decided A2 (ff81a14): only a Postgres config makes a loopback entry local, so that PGLite fixture expectsremote-httpagain, the same as on main. The changelog fragment states the measured failing-first counts and the 90-day window for old stuck pages.Test Coverage
Coverage: deterministic (each of 5 changed runtime files has a changed test naming it; no audit reader).
Tests ran: focused 357
Tests ran: typecheck count unavailable
Remote pregate (Ubicloud us-east-a2, tree 168adf1514c4 at ff81a14,
--base main, run 20261102T223417Z): 312 files, 11029 tests, 0 failed, spent $0.06, VM destroyed.Pre-Landing Review
Pre-Landing Review: 5 issues — 0 auto-fixed, 4 asked (0 fixed, 4 skipped), 0 deferred, 0 noted in the review log (one pre-existing item is listed under Review notes)
REVIEW_LOOP: passes=1 blocking_found=3 deferred=0 noted=0 fixed=0 scope=frozen unrecorded=3 dispatches=2
Gate edits: none detected (4 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
This is a re-review at the depth gstack now requires for this diff:
full(reason: risk:security, 270 runtime lines). The earlier receipt wasstandard. One pass on the whole diff (base c830c9b, tree 168adf1514c4): batched specialist (testing, security, state-machines) and Red Team found nothing. Step 11: native adversarial (4 findings, all Blocks: no) and outside voice openai/gpt-6.1-sol (1 finding, Blocks: yes). No pass 2: nothing reached the crew's blocking floor ("would fail a test, break production, or lose data or secrets"), so the code is unchanged since ff81a14.Skipped findings
These carry a blocking label under the Step 11 rules (CRITICAL or Blocks: yes) and were skipped. Each is below the crew's blocking floor:
lib/gbrain-mcp-locality.ts:90(outside voice; the same case as adversarial docs: add README and CLAUDE.md #1): an SSH tunnel to a team brain on a loopback port, on a machine whose own gbrain config has a Postgresdatabase_url, counts as local, so transcripts are imported into the local brain instead of staged. GStack Minder accepted this trade-off in A2 (ff81a14), andUSING_GBRAIN_WITH_GSTACK.mddocuments it. The pages land in the user's own brain and the transcripts stay on disk, so nothing is lost. Candidate follow-up: a one-line notice when a loopback HTTP entry is classified local.lib/gbrain-mcp-locality.ts:77(adversarial refactor: reorganize codebase into modular structure #2): the answer depends on the gbrain config at call time, so a run under a differentGBRAIN_HOME, or during a half-written config, can stage where the next run imports. Imports are idempotent by slug; the cost is duplicate staging output.lib/gbrain-mcp-locality.ts:78(adversarial Fix project-local /browse installs and harden setup #4): a Postgres brain set only throughDATABASE_URLwith nodatabase_urlin config.json stays remote. That is main's behavior, so nothing regresses; memory-ingest: a loopback gbrain serve --http is treated as a remote brain, so transcripts are staged and never imported #3539 stays open for that setup only.bin/gstack-gbrain-detect:159(core checklist): the memory-ingest: a loopback gbrain serve --http is treated as a remote brain, so transcripts are staged and never imported #3539 comment still says a loopback entry is local when the config "has an engine"; since ff81a14 only a Postgres config counts. The code calls the shared classifier, so behavior is right. Skipped to avoid a code change that would force a second full pass for a comment.Review notes
Below the blocking floor; recorded here and not fixed in this PR.
bin/gstack-skill-start:396(adversarial Project-local .claude/skills/gstack install breaks /browse and setup can report false success #3, pre-existing): skill-start reads the project-scoped gbrain entry while memory-ingest and detect tier 3 read only the top-level one, so the banner and ingest can disagree; the config file adds a third input on which they can differ.Exploratory QA
Functional surface:
lib/gbrain-mcp-locality.ts,bin/gstack-gbrain-detect,bin/gstack-memory-ingest.ts,bin/gstack-skill-startandlib/gbrain-local-status.ts. Smoke probes (parent,gstack-gbrain-detecttier 3 on a temp HOME with noclaudeon PATH, at ff81a14): a loopback entry over a Postgres config gave local-stdio; over PGLite, remote-http; with aremote_mcpmarker, remote-http; a remote host, remote-http;[::1]over Postgres, local-stdio. All five match the rule. The focused lane (357 pass) covers the rest.Design Review
No frontend files changed, so design review was skipped.
Eval Results
No prompt-related files changed, so evals were skipped.
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). The plan is autoplan-20261031175420 (approved, gate_rev=2); see Approvals.
Verification Results
No Step 8.1 obligations (no bound plan file). CI at ff81a14 is green (44 passed, 0 failed, 12 skipped). The macOS named-regressions and Windows free-shard lanes clear from that head's runs 41242806229 and 41242806251.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. No doc edits were needed; the branch's own USING_GBRAIN_WITH_GSTACK.md update is accurate.
Scope: 11 committed files (base c830c9b to head ff81a14): the loopback
gbrain serve --httplocality rule (lib/gbrain-mcp-locality.ts), plus gstack-gbrain-detect, gstack-memory-ingest, the gstack-skill-start banner, and gbrain-local-status. I checked these against the README, USING_GBRAIN_WITH_GSTACK.md, the setup-gbrain and sync-gbrain templates and sections, setup-gbrain/memory.md, and docs/gbrain-quick-tour.md.Documentation health:
README.md Current (links to the gbrain guide still valid)
USING_GBRAIN_WITH_GSTACK.md Current (the branch added the loopback paragraph under Path 4, and it matches the code)
setup-gbrain/*.tmpl, memory.md Current (mode values unchanged)
sync-gbrain/SKILL.md.tmpl Current
CHANGELOG.md Skipped (ship-owned; the entry lives in changelog.d)
TODOS.md Skipped (ship-owned)
Coverage debt: the loopback locality rule has reference and explanation coverage in USING_GBRAIN_WITH_GSTACK.md. The one-time recovery for pages stuck as staged (
gstack-memory-ingest --bulk --all-historyfor pages older than the 90-day window) appears only in the changelog fragment, with no how-to in setup-gbrain/memory.md or the guide's troubleshooting section. That is a common gap;/document-generatecould fill it later. Diagram drift: none, because no diagrams reference the changed modules.Test plan
bun test test/gbrain-mcp-locality.test.ts test/gbrain-local-status.test.ts test/gstack-gbrain-detect-mcp-mode.test.ts test/gstack-memory-ingest.test.ts test/setup-gbrain-fixture.test.ts test/spawnsync-timeout-tripwire.test.ts: 357 pass, 3 skip, 0 fail (ff81a14)bun run typecheck: cleanUBI_LOCATION=us-east-a2 UBI_OWNER=gsta209 gstack-pregate --stage tests --remote --spend-cap 2 --base main: 312 files, 11029 tests, 0 failed (tree 168adf1514c4, ff81a14)Issues
Fixes #3539
Refs #3552
Related: #3552 (@wmorin)
Credit: this ports @wmorin's #3552 (Willy Morin, Co-authored-by on the commits that carry his code). #3552 will be closed as superseded once this merges.