fix: sync all registered sources in autopilot cycle instead of single brainDir#1079
Open
samvilian wants to merge 1 commit into
Open
fix: sync all registered sources in autopilot cycle instead of single brainDir#1079samvilian wants to merge 1 commit into
samvilian wants to merge 1 commit into
Conversation
In multi-source brains, autopilot/dream passes --repo with a parent
directory that may not match any source's local_path. This causes
resolveSourceForDir() to return undefined, making importFile() fall back
to the schema DEFAULT ('default') for source_id. Since no row with
id='default' exists in the sources table, every INSERT violates the
pages_source_id_fkey foreign key constraint.
Fix: enumerate all registered sources from DB and sync each one
individually with its correct source_id. Preserves the legacy fallback
for brains with no registered sources.
Fixes garrytan#1078
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1078
In multi-source brains,
runPhaseSync()resolves the source ID by matchingbrainDiragainstsources.local_path. When--repopoints to a parent directory that doesn't match any source (e.g./home/ubuntu/brainvs/home/ubuntu/brain/wiki/),sourceIdresolves toundefined, causingimportFile()to fall back to the schema DEFAULT'default'forsource_id. Since no row withid='default'exists insources, every INSERT violatespages_source_id_fkey.Changes
src/core/cycle.ts:runPhaseSync()now enumerates all registered sources from the database and syncs each one individually with its correctsource_idandlocal_pathSyncPhaseResultdetails.sourcesSyncedfor observabilityBefore
After
Test
Verified locally with 4 registered sources (logseq, wiki, obsidian, books) — all FK constraint errors resolved, sync completes successfully across all git-initialized sources.