Skip to content

fix(sync-gbrain): thread GSTACK_MEMORY_INGEST_SOURCES through as --sources - #2997

Closed
harshitgavita-07 wants to merge 1 commit into
garrytan:mainfrom
harshitgavita-07:fix/sync-gbrain-memory-sources-2922
Closed

harshitgavita-07 wants to merge 1 commit into
garrytan:mainfrom
harshitgavita-07:fix/sync-gbrain-memory-sources-2922

Conversation

@harshitgavita-07

Copy link
Copy Markdown
Contributor

Fixes #2922

Problem

runMemoryIngest() in bin/gstack-gbrain-sync.ts builds the gstack-memory-ingest child argv as ["run", ingestPath, "--bulk"|"--incremental", ("--quiet")?] and never appends --sources. Since the ingest script defaults to walking every memory type (ALL_TYPES) and only narrows via that flag, a brain that also registers the curated ~/.gstack tree as a federated git-backed source gets a second copy of every design doc, eureka, learning and timeline written into the default source on every sync. Deleting the duplicates doesn't help; the next full walk recreates them.

Fix

Thread a new GSTACK_MEMORY_INGEST_SOURCES env var through as --sources:

  • resolveMemoryIngestSources() (exported, next to resolveStageTimeoutMs) parses the comma-separated value, validates tokens against the ingest types, drops unknown ones with a stderr warning, and falls back to a full walk (not a stage failure) when nothing valid remains.
  • runMemoryIngest() appends --sources <subset> to the child argv when the env names a valid subset. Unset/empty keeps today's behavior.
  • MEMORY_INGEST_TYPES mirrors the ingest script's ALL_TYPES; a test pins the two lists together so a new memory type can't silently drift.

This follows the issue's suggested minimal fix (a config key threaded through as --sources), using the repo's existing GSTACK_* env-var convention, e.g. /sync-gbrain operators can now run GSTACK_MEMORY_INGEST_SOURCES=transcript to stop re-duplicating curated pages instead of hand-invoking the ingest script.

Verification

  • New test/regression-2922-memory-ingest-sources.test.ts: 10 tests covering unset/empty, valid subsets, trimming, dedup, unknown-token filtering, all-invalid fallback, the --sources argv wiring, and the ALL_TYPES drift guard. All pass.
  • Existing suites unaffected: bun test test/gstack-gbrain-sync.test.ts test/regression-1611-gbrain-sync-resume.test.ts test/gbrain-sync-skip.test.ts — 92/92 pass.

@trunk-io

trunk-io Bot commented Sep 29, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thank you! Your --sources threading landed in v1.91.13.0 (#3013, merged as f30b7b7) with an 'all' keyword and a federated-source default, and you're credited as co-author.

@capy-ai capy-ai Bot closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runMemoryIngest() never passes --sources, so every sync re-duplicates curated pages

1 participant