Skip to content

bug: named-source sync/import writes pages to default source #540

@100yenadmin

Description

@100yenadmin

Summary

gbrain sync --source <id> updates source bookkeeping for the requested source, but the import/write path can still write pages/chunks/tags under the default source.

Repro / observed behavior

From an OpenClaw Support KB install:

gbrain sync --repo ~/.gbrain/sources/openclaw-support-kb --source openclaw-support-kb

gbrain sources list --json

Observed before patch:

  • default had ~636 pages
  • openclaw-support-kb existed but had 0 pages
  • search worked only because data had accidentally landed in default

Root cause

sync --source carried sourceId into sync state/bookkeeping, but performFullSync() called runImport() without that source id. Then runImport() / importFile() / engine CRUD defaulted page writes and slug lookups to the default source.

The same source-blind slug path affected page lookup, tag reconciliation, chunk upserts/deletes, and version creation during import.

Expected behavior

Named-source sync/import should write and reconcile content under the requested sources.id, while calls that omit sourceId preserve the current default-source behavior.

Patch direction

Thread optional sourceId through:

  • sync.tsrunImport() / importFile()
  • import.tsimportFile()
  • import-file.tsgetPage, putPage, tags, chunks, versions
  • PGLite/Postgres engine page/chunk/tag/version CRUD

Default behavior should remain source_id='default' when no source id is provided.

Validation target

  • bun run typecheck
  • source-scoped sync of a multi-file repo lands pages under the named source
  • gbrain search ... --source <id> returns expected hits

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions