Repository navigation
Description
Summary
gstack-memory-ingest ingests coding-agent transcripts with no source isolation, no repo/workspace scope, and no trust enforcement — contrary to what setup-gbrain documents. The practical result: transcript pages land in the default source (often federated) or in the current repo's code source, and gbrain's dream/extract cycle then mines every one of them as if it were curated knowledge. On a real corpus this smears unrelated context across the brain and produced a ~21M-token blowup the first time dream ran over the ingested transcripts (had to delete everything afterward).
Versions: gstack 1.58.5.0, gbrain 0.42.42.0.
What the docs promise
setup-gbrain/SKILL.md:1456-1470— transcript ingest default scope is "current repo only, last 90 days", and "Per-repo trust policies still apply."setup-gbrain/SKILL.md:1330—read-onlyrepos are skipped (but "enforced by the future auto-import hook … not here").setup-gbrain/memory.md:35-37— "Repos under adenytrust policy … are skipped — neither code nor transcripts from those repos ingest."
What the code actually does
- Global walk, no repo/workspace filter.
walkClaudeCodeProjects/walkCodexSessions(bin/gstack-memory-ingest.ts:362-423) enumerate all of~/.claude/projects/*and~/.codex/sessions/*.preparePages(:1130-1191) filters only on mtime-dedup, optional secret-scan, and "unattributed" (nocwd/git_remote). There is no current-repo scope and no date floor beyond the 90-day window (--all-historyremoves even that). - No trust enforcement. The binary never reads
~/.gstack/gbrain-repo-policy.json.gstack-gbrain-repo-policy's own header says the tier is "enforced at the caller level; this binary just stores the decision." Nothing ingstack-memory-ingestorgstack-gbrain-syncconsults it, sodeny/read-onlyrepos are not skipped for transcripts. - No source isolation. Ingest calls
gbrain import <stagingDir> --no-embed --json(bin/gstack-memory-ingest.ts:1419) with no--source-id. gbrain's resolver only auto-adopts a source when exactly one non-default source exists (src/commands/import.ts:131-146,sole_non_defaulttier). With multiple registered sources, transcripts route todefault(which is commonly federated) — or, whenGBRAIN_SOURCE/.gbrain-sourceis active, to the current code source. Never to a dedicated, isolated transcript source. - The cycle then mines them.
dream/extractrun per-source and do a full walk with notypefilter (src/core/cycle/extract-facts.ts:184→engine.getAllSlugs(); sourceId scoping at:98). Everytype: transcriptpage is treated as fact/take source material → one LLM call per page/chunk → the token blowup, plus low-quality facts smeared into the brain.
Note: gstack-config set transcript_ingest_mode off does not stop this at sync time — transcript_ingest_mode is referenced only in the setup-gbrain skill files, never read by bin/gstack-gbrain-sync.ts or bin/gstack-memory-ingest.ts. The only effective off-switch is gstack-gbrain-sync --no-memory / --code-only.
Repro (no writes)
# 1. Brain has >1 registered non-default source (typical multi-project setup).
gbrain sources list
# 2. A bare sync runs the global transcript walk and imports with no --source-id:
gstack-gbrain-sync --incremental # -> runMemoryIngest -> gbrain import <dir> (no --source-id)
# 3. Resulting transcript pages carry source_id = 'default' (or the CWD code source),
# not an isolated transcript source. dream/extract over that source then mine them.Suggested fixes
- Route transcripts to a dedicated
--source-id(default a non-federated source, e.g.transcripts-<workspace>), neverdefault/the code source. - Enforce repo-trust + an actual scope before the walk: honor
gbrain-repo-policy.json(skipdeny/read-only), default to current-repo, and support a hard date floor — matching whatsetup-gbrainalready promises. - Let the cycle exclude
type: transcript(or make transcript ingest opt-in to mining), sodream/extractdon't burn tokens treating raw transcripts as curated knowledge. - Make
transcript_ingest_mode=offactually gate the sync memory stage (today it's docs-only).
Related
Pairs with #2104 (staging inside GSTACK_HOME's gitignore=* repo → git-aware import sees 0 files). Together: when the staging bug is fixed, transcripts will flow — and without this issue's scoping/isolation they'll flow into the wrong source and get mined.
Activity
xg-gh-25 commentedon Jul 1, 2026
This is the "trust-enforcement gap" pattern — the tool documents a boundary ("per-repo trust policies apply") but the code path skips the check entirely, so the boundary doesn't actually exist at runtime. SwarmAI hit an adjacent variant when our early memory-ingest honored
CONTEXT.mdexclusions for files but not for git submodules, so adeny-policy submodule's commit messages would still land in the brain. The symptom was identical: documented promise ("submodules under deny are skipped") vs actual behavior (submodule content skipped, but metadata ingested).Your § What the code actually does (point 2) is the smoking gun —
gstack-memory-ingestnever readsgbrain-repo-policy.json, so there's no enforcement layer even when the policy file is correct. The policy is "enforced at the caller level" per the binary's own header, but the caller (gstack-gbrain-sync→runMemoryIngest) doesn't do the check either. So the boundary collapses to a no-op.Why your Suggested Fix #2 is the right one: Threading the trust policy into the walk (before it touches the filesystem) is the only safe order. If you filter after the walk, there's a TOCTOU window where a transcript from a
denyrepo gets staged, and a concurrentdreamrun might mine it before the filter removes it. If you filter at import time, gbrain has already paid the I/O cost to read the file. Filtering at walk time (skip~/.claude/projects/XifX's remote is underdeny) is the cheapest correct boundary — no I/O wasted, no race.Two follow-on notes that may save time:
Your § Related pairs this with memory-ingest stages inside GSTACK_HOME (gitignore=* repo) → gbrain git-aware import sees 0 files → silent false-success #2104 (staging inside gitignore). There's a third bug in the cluster that you didn't mention but is implied by your Repro step 3: when
GBRAIN_SOURCE/.gbrain-sourceis active (the current code source), transcripts from other repos land in the current repo's code source. That's a cross-contamination bug on top of the no-isolation bug. The fix for Project-local .claude/skills/gstack install breaks /browse and setup can report false success #3 (dedicated transcript source) would also resolve this — transcripts never touch a code source, soGBRAIN_SOURCEcan't redirect them.Suggested Fix Fix project-local /browse installs and harden setup #4 (make
transcript_ingest_mode=offactually gate sync) is the fastest kill-switch for users who hit this bug before the code fix lands. Today the only working off-switch is--no-memory(which also disables file-based memory, not just transcripts), so a user who wants file-based memory but no transcript mining has no option. Readinggstack-config get transcript_ingest_modeinrunMemoryIngest(default:on) and skipping the transcript walk whenoffwould unblock them immediately.The 21M-token blowup you hit (§ Summary) is the production lesson here: when a trust boundary is documented but not enforced, the cost of the false-positive is unbounded — the user believes they're protected, so they don't monitor for leakage, and by the time they notice (token bill / quality degradation) the damage is done. For any memory/context tool, unenforced trust is worse than no trust promise at all.
Traced similar trust-gap in SwarmAI early memory-ingest (submodule metadata leak). Discussion: T-MEM
time-attack commentedon Jul 15, 2026
@exGeni Transcript discovery still lacks repository trust enforcement and a dedicated non-federated source, allowing transcripts to enter default or code sources and later be mined.
garrytan commentedon Aug 15, 2026
Partial progress: v1.65.0.0 (#2577) enforces the per-repo trust policy at the gbrain-sync code-import chokepoint — deny refuses, read-only skips code ingest, unreadable store fails closed, and the egress receipt names the decision (
bin/gstack-gbrain-sync.tsvialib/gbrain-repo-policy-client.ts, pinned bytest/gbrain-repo-policy.test.ts). The ingest-path source-isolation ask in this issue remains open.v1.65.0.0 feat: fork port wave 2 — feature fixes, session persistence…
chris-conte commentedon Sep 1, 2026
Point 3 (no source isolation) still reproduces at current HEAD (
e76f65a8). The spawn site has moved since this was filed —bin/gstack-memory-ingest.ts:1419is now:1778-1787— and still passes no source:grep -- '--source-id\|--source"' bin/gstack-memory-ingest.tsreturns nothing. The staged frontmatter (:765-779) carriesagent:,session_id:,cwd:,git_remote:,source_path:— no gbrain source either, so there is nothing downstream to recover the routing from.Four things I can add to the report.
1. The sibling write paths already do this correctly
Suggested fix 1 isn't a new pattern for this repo — it's the one the other two gbrain-writing paths already follow:
The wireup even documents this exact hazard class in the comment directly above (
:335-337, the #2662 note): an unsourced call "resolves against the brain's DEFAULT source" and can silently misroute. Memory ingest is the same class on the import path, without the probe.2. It is silent twice over
The pass summary (
printBulkResult,bin/gstack-memory-ingest.ts:2382-2402) reports written / skipped / failed counts but never a destination. So the misroute is invisible at write time and unattributable afterward — once the pages are indefaultthere is no source id by which to exclude the transcript corpus or query it on its own, anddefaultis federated, so it participates in every unscoped search.Worth fixing even if routing stays as-is: printing the destination source in the summary would have made this self-reporting.
3. The auto-adopt tier's boundary is unchanged at current gbrain
The
sole_non_defaulttier you cite is still the only rescue path at current gbrain HEAD (6bf8db90, 0.47.9.0), and its boundary is the same —src/core/source-resolver.ts:313,if (rows.length !== 1) return null. So it fires only on a brain with exactly one non-default source; with zero, or with two or more (any real multi-project setup), it cannot fire and the import seedsdefault.One thing that has changed since your report makes it narrower still: the #3070 emptiness guard (
:314-319) disables the tier oncedefaultholds any active page. So on a brain where the transcript ingest has already run a single time, the tier is permanently off from then on — the first unsourced import seedsdefault, and that seeding is itself what disqualifies the only mechanism that would have rescued the next one.4. Self-contained repro
Scratch brain, nothing touched outside
$HOME(progress lines elided):The page landed in
default, neither registered source moved, and nothing in the output mentions a source.Field data
Matching your ~21M-token
dreamblowup from the other end: on one multi-source install this accumulated roughly 900 transcript pages indefaultover about two months, close to half of them near-empty session stubs. Retrieval there was pinned to--source default, so searches kept surfacing months-old transcripts as top hits — including descriptions of components that had since been deleted, which agents then had to recognize and discard in their own logs. Cleanup required manual page deletion, not a config change.Smallest version of suggested fix 1
If the dedicated-source design in fix 1 is more than you want to take at once, the routing half is one argument plus the existing probe:
guarded by
gbrain import --help | grep -q -- '--source-id', mirroringbin/gstack-gbrain-source-wireup:343-344, so older gbrains degrade to today's behavior. Note import's flag is--source-id, notsync's--source.Happy to open a PR for the routing + summary-destination part if that's useful — I'd leave the trust-enforcement and cycle-exclusion points (2 and 4) to you, since they're larger design calls.
capy-ai commentedon Oct 4, 2026
Memory ingest now imports each transcript into a machine-local, non-federated gbrain source for its own repository, and transcripts with no attributable repository stay local instead of landing in the default source. Fixed in v1.91.19.0 (#3025).
To upgrade: run
/gstack-upgradein Claude Code, then start a new session.If you still see this, please reopen with
./setup --statusoutput.