Skip to content

gbrain memory lookups find the artifacts source, product pages and newest timeline rows - #4685

Merged
capy-ai[bot] merged 4 commits into
mainfrom
gbrain-memory-lookups-find-their-pages
Nov 22, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
gbrain-memory-lookups-find-their-pages

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

/sync-gbrain and gstack-decision-search --semantic now find a brain host's artifacts source through GSTACK_BRAIN_SOURCE_ID, planning skills read their product and brand digests from current gbrain, and the brain gets each sync's newest artifacts and timeline rows.
Why: five outside reports (#4443, #4327, #4265, #4179, #4362), each reproduced on main by a test that fails before this change and passes after it.
Nothing to do unless your artifacts source lives outside ~/.gstack-brain-worktree; then set GSTACK_BRAIN_SOURCE_ID to its id.

What changed, item by item
Report Before After Test
#4443 (rebuilt from #4656 by @Barack-zero-to-one) /sync-gbrain's guard found the federated artifacts source only at the worktree path or state root, so a brain host whose source is a gbrain clone re-imported every plan and design doc into the default source federatedCuratedSourceId takes the id GSTACK_BRAIN_SOURCE_ID names (still required to be federated, with no fallback to the path match), as brainSyncIndexVerdict and the wireup already did test/regression-2922-memory-ingest-sources.test.ts
#4327 (rebuilt from #4328 by @exGeni) --semantic found the memory source only by a path ending in .gstack-brain-worktree the named source wins when registered; an unregistered name gives the file results only, never the worktree or an unscoped search test/gstack-decision-semantic.test.ts
#4265 (narrowed from #4316 by @atharva081106, reported by @stevotcp) gstack-brain-cache read page.body, which current gbrain's get --json uses for the read-mode name, and asked for the mixed-case slug gbrain never stores, so every product, brand and persona digest missed reads compiled_truth (content for a streamed page) under the lowercased slug test/brain-cache-page-read.test.ts
#4179 (rebuilt from the PR by @extremenelson) the drain advanced the brain worktree at its start, before its own commit, and at most once a day, so gbrain served artifacts up to a day old the advance runs in the drain's exit trap after the commit, on every drain; a failed or refused advance holds retries for 24h; INT/TERM skip it test/gbrain-source-worktree-advance.test.ts (its old test pinned the daily window and is replaced)
#4362 (rebuilt narrower from the PR by @DanCanadian) an artifact over 200,000 characters kept its first 200,000, so a long timeline, learnings or eureka log lost its newest rows and ended mid-row an oversized .jsonl log keeps its newest complete rows; markdown keeps its start as before; the cap is unchanged test/memory-artifact-body.test.ts

Left out on purpose: #4316's not-found versus unreachable message and markdown fallback for gbrain 0.46; #4179's glab auth status move; #4362's 24 MiB ceiling, --project scoped repair and readback changes.

Security read

No CI, install script, dependency, auth or new network path changes. gstack-brain-sync's advance calls the same gstack-gbrain-source-wireup --advance-only as before (no force-remove, refuses dirty or foreign worktrees) from the exit trap while the drain lock is still held; INT/TERM disarm it. GSTACK_BRAIN_SOURCE_ID only selects among sources gbrain sources list already reports and scopes reads to it; it never widens a search.

Issues

Fixes #4179
Fixes #4265
Fixes #4327
Fixes #4362
Fixes #4443

Documentation

Status: current. The docs already match this branch's changes, so nothing was edited.

Scope: committed changes from c2b4f0d2 to HEAD on gbrain-memory-lookups-find-their-pages (nothing staged, unstaged or untracked). That covers the GSTACK_BRAIN_SOURCE_ID source selection, the brain worktree advance on every sync, the gbrain page-text fix and the newest-rows rule for jsonl logs.

Documentation health

  • docs/gbrain-sync.md: current. It documents GSTACK_BRAIN_SOURCE_ID and the advance on every sync with a 24-hour wait after a failure.
  • USING_GBRAIN_WITH_GSTACK.md: current. The --advance-only flag row is unchanged and still accurate.
  • changelog.d/gbrain-memory-lookups-find-their-pages.md: current. It matches the code.

Coverage debt: none. Diagram drift: none.

Agent notes

Outside items triaged under GSTA-799 and rebuilt on main per R45; no outside branch was checked out or run. Co-authored-by trailers credit the PR authors whose approach was carried over.

Approvals

Approved: yes (record r-740f1a3afd22). The full approval record stays private.
Plan: exempt: bug fix (--kind fix), failing-first tests in the PR
Plan check: exempt bug fix

Ruled note: test/gbrain-source-worktree-advance.test.ts:152:adversarial at b46aaa0 ruled by Captain GStack Minder (GSTA-36) (relayed from GSTA-804:2026-11-22T06:30Z) at 2026-11-22T06:46:59.431Z: refuted: test-setup.ts clears GSTACK_STATE_ROOT; a sentinel rerun stayed empty (approval a-a45b9967ca4f)
Ruled note: lib/memory-artifact-body.ts:15:outside at b46aaa0 ruled by Captain GStack Minder (GSTA-36) (relayed from GSTA-804:2026-11-22T06:30Z) at 2026-11-22T06:46:59.532Z: needs one row over 200K characters; the source log is untouched; below the floor (approval a-9bde07958502)
Review-loop exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-22 via relayed from GSTA-804:2026-11-22T06:30Z: one scoped fix round for outside-voice #2 at the round cap; #1 and #3 closed as ruled notes (fix-check at 8d51fe1, 1 finding)

Open in Capy

{
  "schema_version": 1,
  "pr": 4685,
  "head": "8d51fe17d5e5f3849f7b6aa2614bb96f225d1dbf",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 181,
      "fail": 0,
      "skip": 0
    }
  },
  "calls": 44,
  "session_kind": "unattended",
  "run": "ship-4685",
  "head_tree": "34a6dfba1a48c9fd39b6ae58f41b435ed54bb23c",
  "product_patch_id": "b552c0d09641aac7bd13474b04d00cb9e7a212a0",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 127,
    "rules": "630fd3101899e28e",
    "base": "7c0659a69fd731e20a9dd3833eb0a6a8aa165bdf",
    "registry": "7c0659a69fd731e20a9dd3833eb0a6a8aa165bdf",
    "gate_scan": {
      "tagged": 0,
      "head": "8d51fe17d5e5f3849f7b6aa2614bb96f225d1dbf"
    },
    "reasons": [
      "runtime=127"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @34a6dfba1a48 (8 checks, current for 8d51fe17d5e5)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44997281692/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=34a6dfba1a48 tests=38829 skipped=67 runs=44997281692/1 profiles=ci-reuse/free-tests heads=8d51fe17d5e5 verified=2026-11-22T07:38:36.231Z"
  ],
  "issues": {
    "fixes": [
      4179,
      4265,
      4327,
      4362,
      4443
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md against the branch diff c2b4f0d2..HEAD (gbrain-sync docs, changelog fragment)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 6,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 1,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "review_loop_exception": {
    "accepted_by": "Captain GStack Minder (GSTA-36)",
    "date": "2026-11-22",
    "via": "relayed from GSTA-804:2026-11-22T06:30Z",
    "reason": "one scoped fix round for outside-voice #2 at the round cap; #1 and #3 closed as ruled notes",
    "fix_check": {
      "head": "8d51fe17d5e5f3849f7b6aa2614bb96f225d1dbf",
      "findings": 1
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "b46aaa0177c0b98fbb7e0d41d4b3169d146091f4",
      "pr": 4685,
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "one scoped fix round for outside-voice #2: disarm the worktree advance on the drain's consent and letter-case refusal exits",
      "at": "2026-11-22T06:46:59.275Z",
      "approval": "a-6d3a4d23d3d0",
      "stop_run": "ship-4685",
      "findings": [
        "p1v/outside-voice#2"
      ]
    }
  ],
  "ruled_notes": [
    {
      "finding": "test/gbrain-source-worktree-advance.test.ts:152:adversarial",
      "head": "b46aaa0177c0b98fbb7e0d41d4b3169d146091f4",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "refuted: test-setup.ts clears GSTACK_STATE_ROOT; a sentinel rerun stayed empty",
      "at": "2026-11-22T06:46:59.431Z",
      "approval": "a-a45b9967ca4f",
      "relayed": "GSTA-804:2026-11-22T06:30Z"
    },
    {
      "finding": "lib/memory-artifact-body.ts:15:outside",
      "head": "b46aaa0177c0b98fbb7e0d41d4b3169d146091f4",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "needs one row over 200K characters; the source log is untouched; below the floor",
      "at": "2026-11-22T06:46:59.532Z",
      "approval": "a-9bde07958502",
      "relayed": "GSTA-804:2026-11-22T06:30Z"
    }
  ],
  "gate_dispositions": []
}
{"head":"b46aaa0177c0b98fbb7e0d41d4b3169d146091f4","run":"ship-4685","mark":"stop","tree":"03430c395d86b98efab21b6f753f24d51f3a485a"}
{"head":"b46aaa0177c0b98fbb7e0d41d4b3169d146091f4","run":"ship-4685","mark":"grant","grant":"a-6d3a4d23d3d0"}

…west timeline rows

GSTACK_BRAIN_SOURCE_ID now names the artifacts source for /sync-gbrain's
duplicate-import guard (#4443) and for gstack-decision-search --semantic
(#4327). Brain-cache page digests read compiled_truth under the lowercase
slug gbrain stores (#4265). Each artifacts sync advances the brain worktree
after its own commit (#4179). Oversized .jsonl logs keep their newest
complete rows in the brain (#4362).

Co-authored-by: Barack-zero-to-one <[email protected]>
Co-authored-by: exGeni <[email protected]>
Co-authored-by: atharva081106 <[email protected]>
Co-authored-by: extremenelson <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 22, 2026 06:04
An oversized .jsonl whose last row alone passes the cap now keeps a non-empty body instead of an empty page.

Review-Finding: p1/specialist-batched#1 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… passes

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… commit

A drain whose push the transcript consent or the letter-case check refuses no longer advances gbrain's worktree to that local commit.

Review-Finding: p1v/outside-voice#2 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment