Repository navigation
CXP-481 Support for Incremental Sync - #120
JavierCarnelli-ConductorOne wants to merge 25 commits into
Conversation
…n all examples All resource-level incremental_sync pagination blocks were missing the required primary_key field, which caused "primary key not found in query results" errors when detecting new or modified resources via event feed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nt feed First-run sources derive `since` from the default lookback window. The previous code unconditionally applied earliestEvent (which reflects the last processed event from another source) as a lower bound, pushing `since` forward past the lookback and permanently hiding events — including revokes — that occurred before the first cycle. sinceForSource now returns (time.Time, bool); earliestEvent is only applied when hasCommittedCursor is true. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix WordPress incremental_sync query missing ?<since> placeholder - Log debug message when event feed syncer creation fails instead of silently dropping the error - Refactor hasSince/hasID loops into queryUsesVar helper to reduce duplication - Validate IncrementalSyncConfig.default_lookback at startup - Fix event ID collisions for grants sharing the same (resource, principal, timestamp) by appending the pagination primary key - Fix SAP HANA YAML indentation: get and incremental_sync were siblings of user instead of children - Remove debug fmt.Println statements from event_feed.go Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @JavierCarnelli-ConductorOne's task in 4m 19s —— View job PR Review: Incremental Sync Support
OverviewThis PR adds incremental sync (event feed) support to baton-sql, enabling efficient change detection via timestamp-based queries instead of full re-syncs. The implementation supports three event types:
The architecture is well-designed: each "source" (resource type or grant query) maintains its own independent cursor, and a round-robin scheduler processes one page per source per What works well
Issues foundMust-fix
Should-fix
Nits / suggestions
SummaryThe core design is solid — the multi-source cursor state machine, the separation of committed vs in-flight state, and the reuse of existing query infrastructure are all well-thought-out. The main gap is test coverage: the cursor state machine and validation logic have enough complexity to warrant dedicated unit tests before merging. The |
- Add resource_id field to ResourceIncrementalSync to decouple event
feed ID extraction from list.map.id, mirroring the existing pattern
in GrantsIncrementalSync; falls back to list.map.id when not set
- Add bcel.Env.Compile for startup CEL expression validation; use it
to validate resource_id at config validation time
- Fix grantRowKey to format int64/float64 primary keys with strconv
instead of fmt.Sprintf("%v") which produces scientific notation for
large IDs
- Document why earliestEvent is intentionally ignored in ListEvents
- Document why EventFeeds re-creates syncers separately from
ResourceSyncers and why this is safe
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @JavierCarnelli-ConductorOne's task in 2m 8s —— View job PR Review: Incremental Sync Support
OverviewThis PR adds incremental sync (event feed) support to baton-sql. Instead of full re-syncs, the connector can now detect changes via timestamp-based SQL queries and emit Architecture AssessmentThe design is well-structured:
Issues1. No tests for new code (must-fix)
Key areas to test:
The validation additions in 2. Potential data loss:
|
|
Claude finished @JavierCarnelli-ConductorOne's task in 2m 59s —— View job PR Review: Incremental Sync Support
OverviewThis PR adds incremental sync (event feed) support to baton-sql. Instead of full re-syncs, the connector can now detect changes via timestamp-based SQL queries and emit Also adds ArchitectureThe design is solid:
The latest commit ( Issues1.
|
A missing or NULL cursor column now returns a FailedPrecondition error instead of silently reusing the since timestamp, which kept the cursor from advancing and changed event IDs on every poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt numeric epochs String cursor values now use the engine-specific time formats, and integer or float values are read as Unix timestamps with the same seconds-or-milliseconds rule used for numeric strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
ggreer
left a comment
There was a problem hiding this comment.
I noticed a couple of minor things, but this looks good to merge. Feel free to address them in this PR, a follow-up PR, or not at all.
| type EventFeedConfig struct { | ||
| // DefaultLookback is the maximum time window to look back when initializing a cursor for the | ||
| // first time. Accepts any Go time.Duration string (e.g., "3h", "30m", "24h"). Defaults to 3h. | ||
| DefaultLookback string `yaml:"default_lookback" json:"default_lookback"` |
There was a problem hiding this comment.
Nitpick: If this is the maximum time to look back, should it be called MaxLookback?
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without the placeholder every page returns the same rows, so the source never finishes paging and ListEvents reports HasMore forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
…wn set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
|
|
||
| var result *v2.Resource | ||
| // Get runs against the primary database only, even when multiple databases are configured. | ||
| _, err = s.iterateDBs(ctx, scopeCluster, &pagination.Token{}, func(ctx context.Context, _ string, innerToken *pagination.Token) (string, error) { |
There was a problem hiding this comment.
iterateDBs with scopeCluster calls setCurrentDB, which writes s.db and s.currentDBName on the shared syncer (L101-102). Those are the same instances ResourceSyncers() hands the full sync, and List/Grants read s.db in their own callbacks (resources.go:30, grants.go:88).
The struct comment at L34 calls that safe "because the SDK calls List/Entitlements/Grants serially per syncer" — Get is not one of those. The runner dispatches tasks concurrently, 3 slots by default (baton-sdk pkg/connectorrunner/runner.go:278), and a ResourceChangeEvent from this feed is what triggers the targeted sync that lands here. With connect.databases, a concurrent Get reroutes an in-flight List page to the primary handle while the pagination bag still names the other database, and the synthetic database column reports the wrong name.
You already drew this line for the event feed: connector.go:26 gives it its own syncer set because "syncers keep the active database as mutable state, so sharing them with full sync could race." Get runs on the full-sync set, so it has to stop mutating instead.
Suggestion — resolve the handle locally: read s.dbs[s.primaryDBName] and pass it to runQuery, and take the synthetic column (query.go:966) from s.primaryDBName on this path too.
…stent (#159) * fix: make the event feed examples runnable and keep revokes consistent Add cursor and soft-delete columns to the test databases, exclude soft-deleted rows from full-sync grants, soft-delete on revoke and revive on grant, and add an event feed smoke test to CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: match feed events regardless of protojson spacing in the smoke test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: use the baton CLI from the sync-test action in the feed smoke test The pinned standalone baton release cannot read current c1z files and replaced the CLI the sync-test action installs. The script now fails loudly when baton grants errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
| WHERE user_id = ?<user_id> AND level = ?<access_level> AND deleted_at IS NOT NULL | ||
| - | | ||
| INSERT INTO user_access (user_id, level) | ||
| VALUES (?<user_id>, ?<access_level>) | ||
|
|
||
| # Revoke Operations | ||
| # ---------------- | ||
| SELECT ?<user_id>, ?<access_level> FROM DUAL | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM user_access WHERE user_id = ?<user_id> AND level = ?<access_level> |
There was a problem hiding this comment.
🟡 Suggestion (medium confidence): The grant queries read and write a level column on user_access, but the full-sync grants query and both event-feed queries select access_level from that same table (lines 168, 192, 205). Only one of these names can match a real schema, so this reference example will fail on either grant or sync if copied as-is. Pick one column name and use it in all of these queries.
| WHERE user_id = ?<user_id> | ||
| UPDATE user_access | ||
| SET deleted_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP | ||
| WHERE user_id = ?<user_id> AND deleted_at IS NULL |
There was a problem hiding this comment.
🟡 Suggestion (medium confidence): The revoke is scoped by user_id only, but grant and the grants map scope by level = 'basic'. If a user has more than one live user_access row, this UPDATE either soft-deletes the non-basic rows too, which then show up as revokes in the event feed, or affects more than one row and fails with ErrQueryAffectedMoreThanOneRow (pkg/bsql/query.go:811). Add AND level = ?<access_level> (or the matching column) to keep revoke symmetric with grant.
Connector PR Review: CXP-481 Support for Incremental SyncBlocking Issues: 0 | Suggestions: 4 | Threads Resolved: 0 Review SummaryThe new commits touch no Go code. They change the examples, test fixtures, docs, CI and the capabilities JSON:
I checked the new provisioning queries against
Coverage gaps: none in the incremental diff (not partial, no dropped paths). The smoke script only runs in CI for Postgres; the SQL Server, MySQL and Vertica fixture changes were checked by reading only. Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agentsReviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
Description
Adds incremental sync support through the baton event feed (
ListEvents) and targeted resource sync (Get).event_feedquery emitsResourceChangeEvents, and C1 re-syncs those resources through the resource type'sgetquery.event_feed(changes_query, plus an optionalrevokes_query) emitsCreateGrantEvent/CreateRevokeEvent. Grants keepexpandableannotations.overlapwindow (default60s) so rows with tied or late-committed timestamps are not missed; re-sent events keep the same ID, so C1 skips them.paginationwithstrategy: offsetand use?<Limit>/?<Offset>. They mustORDER BY <cursor column>, <primary key>.GetreturnsUnimplementedwhen a resource type has nogetquery.See the "Event Feed" section in the README and
examples/for configuration.Breaking changes vs. earlier revisions of this PR
incremental_syncconfig keys were renamed toevent_feed.?<id>placeholder ingetqueries was renamed to?<resource_id>.pagination(offset only) and?<Limit>.Notes
Useful links:
🤖 Generated with Claude Code