fix(sync): re-export edited observations by checking UpdatedAt#450
Merged
Conversation
…terNewData (#447) Observations edited via mem_update have UpdatedAt > CreatedAt but unchanged CreatedAt, so the previous cutoff check (CreatedAt only) silently dropped them from every subsequent sync. Include the observation when either CreatedAt or UpdatedAt is after the cutoff so edits are always re-exported.
There was a problem hiding this comment.
Pull request overview
Fixes issue #447 where engram sync failed to re-export observations edited in place via mem_update. The local chunk export path's filterNewData only selected observations with CreatedAt > cutoff, ignoring edited rows whose UpdatedAt was bumped but whose CreatedAt remained unchanged. The one-line fix also checks UpdatedAt, so edited observations now flow back into newly generated chunks (with content-hash dedup preventing redundant chunks on true no-ops).
Changes:
- Extend
filterNewDataobservation filter to include rows where eitherCreatedAtorUpdatedAtexceeds the cutoff. - Add
TestFilterNewDataIncludesEditedObservationscovering edited, unedited, and newly created cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/sync/sync.go | One-line change to also include observations whose UpdatedAt is past the cutoff |
| internal/sync/sync_test.go | New TDD test verifying edited observations are re-exported while never-edited stale rows remain excluded |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Closes #447 — after
mem_updateedits an observation in place,engram syncreported "Nothing new to sync" and the chunk kept the stale content. Edited observations were never re-exported.Root cause
filterNewData(internal/sync/sync.go) selected observations byCreatedAt > cutoffonly. Edited rows haveUpdatedAt > CreatedAtbut unchangedCreatedAt, so they were filtered out.Change
One-line fix: include observations where
CreatedAtorUpdatedAtis after the cutoff.UpdatedAtis already populated onstore.Observationand in the export path. Content-hash dedup (chunkcodec.ChunkID) prevents redundant chunks on no-op re-syncs.Test plan
TDD red→green. New
TestFilterNewDataIncludesEditedObservations: an observation withCreatedAtbefore cutoff andUpdatedAtafter cutoff is now included; never-edited rows stay excluded (no false inclusion).go test ./internal/sync/...andgo build ./...clean.Notes
Passed adversarial review (UpdatedAt always populated via
NOT NULL DEFAULT; no over-export risk; import round-trip upserts bysync_id).