fix(store): prevent duplicate observations on import#616
Merged
Alan-TheGentleman merged 1 commit intoJul 20, 2026
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughObservation imports now derive normalized sync IDs, skip existing observations, count only inserted rows, and return contextual insertion errors. A regression test verifies repeated imports preserve the original three observations. ChangesObservation import deduplication
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Linked Issue
Closes #531
PR Type
type:bug- Bug fixtype:feature- New featuretype:docs- Documentation onlytype:refactor- Code refactoring (no behavior change)type:chore- Maintenance, dependencies, toolingtype:breaking-change- Breaking changeSummary
sync_id.ObservationsImported.3 -> 6 -> 9scenario.Changes
internal/store/store.gosync_iddoes not already exist in the import transaction.internal/store/store_test.goTest Plan
go test ./...go test -tags e2e ./internal/server/...Focused verification:
go test ./internal/store -run TestImportSkipsObservationWithExistingSyncID -count=1go vet ./internal/storeThe full Windows unit suite currently has unrelated baseline failures in
cmd/engram,internal/setup,internal/store, andinternal/sync. The failinginternal/store,internal/setup, andinternal/synccases were reproduced unchanged from a cleanorigin/mainworktree atbe4b613.Automated Checks
Closes #N/Fixes #N/Resolves #Nstatus:approvedlabeltype:*labelgo test ./...passesgo test -tags e2e ./internal/server/...passesContributor Checklist
Closes #531)type:*label to this PR (pending maintainer permission)go test ./...(ran; pre-existing Windows failures remain)go test -tags e2e ./internal/server/...Co-Authored-Bytrailers in commitsNotes for Reviewers
This stays within the scope approved in #531: dedupe observations during import. It does not repair historical duplicates, change prompt import behavior, or implement the LWW redesign discussed in #244.
The schema currently has a non-unique index on
observations.sync_id. The implementation therefore uses an atomicINSERT ... SELECT ... WHERE NOT EXISTSinside the existing import transaction rather than adding a unique constraint that could fail migration for databases already containing duplicates.Summary by CodeRabbit