A4: import transcripts into per-repository, non-federated gbrain sources

`gbrain import` ran without --source-id, so transcripts from every project
landed in the shared (often federated) default source.

- Each transcript partition imports with --source-id into its originating
  repository's own source (gstack-transcripts-<repo>, built with
  constrainSourceId, now exported from lib/gbrain-sources.ts). The source
  is registered machine-local and --no-federated before its first import,
  and the registration is cached in state. Partitions import one after
  another (PGLite is a single writer); a failing source no longer blocks
  the others, except a timeout, whose checkpoint must survive.
- If gbrain cannot register the source, that partition stays local and
  unstamped, and the run says why (even under --quiet).
- --include-unattributed sends repo-less transcripts only to the
  machine-local gstack-transcripts-unattributed source, keeps them on the
  machine when the brain is remote (Postgres, Supabase or remote-HTTP),
  and never writes them to the publishable ~/.gstack/transcripts staging.
- A page's recorded source is sticky: pages stamped before this release
  ("default") keep importing there, so no source gains a duplicate.
- The staging dir name carries -src-<id> so a resumed import keeps its
  source.

Test fakes that recorded only the last import now record every import of
one run, and answer `gbrain sources`; remote-http scan tests use an
attributed transcript, since unattributed ones no longer stage there.

Co-authored-by: Sinabina <sinabina@Sinabinas-MacBook-Pro-4.local>
This commit is contained in:
garrytanandSinabina committed 2026-10-03 21:17:54 +00:00
1 parent 97d4e58dcc
commit d02c8effb7
7 files changed
+400 -62

No files matched your search

+34
View File
@@ -374,6 +374,40 @@ gbrain skips unchanged content.
---
## `[memory-ingest] kept N unattributed transcript(s) on this machine: the brain is remote (Postgres or HTTP), ...`
**Problem.** `--include-unattributed` transcripts (sessions with no git
remote) were not imported.
**Cause.** Transcripts that cannot be attributed to a repository go only to
the machine-local, never-federated source `gstack-transcripts-unattributed`.
Your brain is remote (a Postgres or Supabase `database_url`, or a remote-HTTP
MCP brain), so sending them would take them off this machine. They are not
marked ingested and are not written to the publishable `~/.gstack/transcripts/`
staging either.
**Fix.** Nothing to do if that is what you want. To include such a session,
run it from a git repository with an `origin` remote so it is attributed.
---
## `[memory-ingest] kept N transcript page(s) for <repo> on this machine: could not register gbrain source <id> (...)`
**Problem.** Transcripts from one repository were not imported.
**Cause.** gstack imports each repository's transcripts into that
repository's own gbrain source (`gstack-transcripts-...`, machine-local and
not federated) and registers it before the first import. The installed gbrain
refused `gbrain sources add`, so the pages stay local and unstamped.
**Fix.**
```bash
gstack-gbrain-install # upgrade gbrain
/sync-gbrain # the pages import on the next run
```
---
## Nothing is syncing but I expect it to
**Not an error, but a common gotcha.** Check in order: