fix: import dedup checks remote DB when LORE_REMOTE_URL is set#338
Merged
Conversation
The import command's idempotency check (isImported) was querying the local SQLite DB, but import records were written to the remote gateway. This caused duplicate imports on every run in remote mode. Fix: - Fetch import history from remote gateway via GET /api/v1/import/history and check against it during session filtering - Skip ensureProject() in remote mode to avoid creating phantom local project records - Also record imports locally after remote record succeeds (belt-and- suspenders: remote is source of truth, local prevents re-detection if user later runs without LORE_REMOTE_URL)
BYK
added a commit
that referenced
this pull request
May 15, 2026
## Summary Self-review follow-up for PR #338. Hardens error handling in the remote import path and cleans up code duplication. ## Fixes **Critical:** - **C2**: Only swallow 400/404 on remote history fetch (project not yet known to remote). Server errors (500), auth failures (401), and network errors now propagate instead of silently skipping dedup — which could cause duplicate imports - **C3**: Wrap `remotePost` for `/api/v1/import/record` in try/catch. Previously a single record failure would abort the entire import, losing all progress for remaining agents/sessions - **M5**: Wrap `remotePost` for `/api/v1/import/extract` in try/catch. On extraction failure, logs error and continues to next agent instead of crashing **Cleanup:** - **M3**: Replace hand-rolled git remote resolution with `projectQueryParams()` from `remote.ts` (eliminates code duplication) - Remove redundant dynamic `import("@loreai/core")` for `exportLoreFile` — already statically imported - Clarify `ensureProject` skip comment: local project creation from belt-and-suspenders `recordImport()` is intentional, not a bug ## Files Changed | File | Change | |---|---| | `packages/gateway/src/cli/import.ts` | Error handling, code cleanup |
This was referenced May 15, 2026
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
lore importwithLORE_REMOTE_URLchecked the local DB for dedup but wrote import records to the remote DB, causing duplicate imports on every runensureProject()in remote mode to avoid creating phantom local project recordsProblem
When
LORE_REMOTE_URLis set:isImported()queries the localimport_historytable → always emptyremotePost("/api/v1/import/record")writes to the remote DBThis means every
lore importin remote mode re-imports everything, wasting LLM calls and creating duplicate knowledge entries.Fix
GET /api/v1/import/history?git_remote=...from the remote gateway and check against it instead of the local DBensureProject(): In remote mode, don't create a phantom project record in the local DB (detection/readChunks don't need it)recordImport()as belt-and-suspenders — if the user later runs withoutLORE_REMOTE_URL, the local DB already has the recordsFiles Changed
packages/gateway/src/cli/import.tscommandImport()to fetch remote history for dedup; skip localensureProject()in remote mode; record imports locally after remote