Summary
gbrain dream --phase synthesize --dir <brain-dir> writes the synthesized
reflection/idea pages to the default source, even when <brain-dir> is a
registered source (its .gbrain-source dotfile names the source id). Result:
persistent multi_source_drift warnings in doctor, and the named source's
last_sync never advances ("stale" forever).
Root cause
In src/core/cycle/synthesize.ts, collectChildPutPageSlugs() (~L870)
hardcodes source_id: 'default' for all subagent-written pages. The comment at
L849-854 acknowledges this is a known gap:
Subagent put_page tool schema doesn't expose source_id (subagents are scoped
to a single source); default to 'default' for the current dream-cycle product
behavior. Threading the source_id through reverseWriteRefs guarantees getPage
targets the correct (source, slug) row...
So the brain_put_page write path never honors the resolved source from the
6-tier resolveSourceId chain (--source / GBRAIN_SOURCE / .gbrain-source
/ path-match / brain-default / 'default').
Impact
doctor → multi_source_drift: pages live at default but their intended
source is the named brain source.
doctor → sync_freshness: the named source is flagged stale forever,
because dream writes land in default and never advance the source's sync.
- Workaround forces operators to
git commit && gbrain sync --source <id> to
re-home the pages, which leaves duplicate copies (one in default, one in the
named source). Search dedupes by slug so retrieval is unaffected, but
page_count / chunk_count inflate.
Repro
gbrain sources add mybrain --path ~/mybrain (so ~/mybrain/.gbrain-source
= mybrain)
gbrain dream --phase synthesize --dir ~/mybrain
gbrain doctor → multi_source_drift lists the new reflection/idea pages as
intended=mybrain but present at default.
Suggested fix
Thread the resolved sourceId into the subagent put_page write path and through
collectChildPutPageSlugs / reverseWriteRefs, so synthesized pages are
attributed to the correct source at write time instead of the hardcoded
'default'.
Env
gbrain 0.35.8.0, postgres engine, multi-source setup (multiple federated
sources).
Summary
gbrain dream --phase synthesize --dir <brain-dir>writes the synthesizedreflection/idea pages to the
defaultsource, even when<brain-dir>is aregistered source (its
.gbrain-sourcedotfile names the source id). Result:persistent
multi_source_driftwarnings indoctor, and the named source'slast_syncnever advances ("stale" forever).Root cause
In
src/core/cycle/synthesize.ts,collectChildPutPageSlugs()(~L870)hardcodes
source_id: 'default'for all subagent-written pages. The comment atL849-854 acknowledges this is a known gap:
So the
brain_put_pagewrite path never honors the resolved source from the6-tier
resolveSourceIdchain (--source/GBRAIN_SOURCE/.gbrain-source/ path-match / brain-default / 'default').
Impact
doctor→multi_source_drift: pages live atdefaultbut their intendedsource is the named brain source.
doctor→sync_freshness: the named source is flagged stale forever,because dream writes land in
defaultand never advance the source's sync.git commit && gbrain sync --source <id>tore-home the pages, which leaves duplicate copies (one in
default, one in thenamed source). Search dedupes by slug so retrieval is unaffected, but
page_count/chunk_countinflate.Repro
gbrain sources add mybrain --path ~/mybrain(so~/mybrain/.gbrain-source=
mybrain)gbrain dream --phase synthesize --dir ~/mybraingbrain doctor→multi_source_driftlists the new reflection/idea pages asintended=
mybrainbut present atdefault.Suggested fix
Thread the resolved sourceId into the subagent put_page write path and through
collectChildPutPageSlugs/reverseWriteRefs, so synthesized pages areattributed to the correct source at write time instead of the hardcoded
'default'.Env
gbrain 0.35.8.0, postgres engine, multi-source setup (multiple federated
sources).