Skip to content

Fix knowledge connector sync follow-up - #6927

Open
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
fix/kb-connector-sync-followup
Open

Fix knowledge connector sync follow-up#6927
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
fix/kb-connector-sync-followup

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Queue synchronization when runnable connector source configuration changes, while preserving paused state and rejecting active-sync races
  • Move manual sync to sim knowledge connectors sync and fix nested connector document commands
  • Support Linear personal API keys and OAuth tokens with the correct authorization format
  • Update the generated OpenAPI and CLI documentation without adding or changing HTTP endpoints

Type of Change

  • Bug fix

Testing

  • Passed focused Sim tests: 106 tests
  • Passed Sim CLI tests: 450 tests, 1 skipped
  • Passed Sim and CLI type checks
  • Passed lint and all 32 repository audits

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 21, 2026 6:08pm

Request Review

@cursor

cursor Bot commented Aug 21, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Touches connector sync locking, queue idempotency, and billing attribution on source-change syncs—incorrect CAS or attribution could skip, double-run, or mis-bill syncs.

Overview
Updating a runnable knowledge connector’s sourceConfig now queues an immediate billed sync. Paused/disabled connectors keep the new source without syncing; mid-sync and other races return 409. Updates CAS on status/nextSyncAt, preserve an already-due source-sync marker when the schedule is disabled, and fail closed if billing attribution cannot be resolved.

Automatic dispatch is idempotent on the expected due time, skips stale or non-runnable connectors, and the lock only starts from active/error when requireRunnable is set. The worker uses the locked row as the source snapshot so a concurrent source change cannot be processed with stale config.

CLI: sim knowledge connectors sync replaces knowledge sync create, nested document commands nest correctly, and path args are named knowledgeBaseId. Linear connector auth now uses linearAuthorizationHeader so personal API keys are not sent as Bearer tokens.

Reviewed by Cursor Bugbot for commit 5d0ac9c. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/sim/lib/knowledge/orchestration/connectors.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes runnable connector source changes queue an immediate synchronization while preserving paused state and preventing active-sync races.

  • Persists due markers and adds optimistic status/time checks so rejected or concurrent handoffs remain recoverable.
  • Locks synchronization to an authoritative connector snapshot and carries runnable-state requirements through queued jobs.
  • Corrects Linear authorization handling for personal API keys and OAuth tokens.
  • Reorganizes connector CLI commands and updates generated API and CLI documentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/knowledge/orchestration/connectors.ts Source updates now persist durable sync intent, use optimistic concurrency checks, and await the immediate handoff.
apps/sim/lib/knowledge/connectors/queue.ts Automatic dispatch now validates runnable state and expected due time and uses due-time-based idempotency.
apps/sim/lib/knowledge/connectors/sync-engine.ts Synchronization acquires an authoritative connector snapshot under the lock and guards automatic work and terminal writes.
apps/sim/lib/knowledge/application/connectors.ts Connector updates now resolve billing attribution required for source-change synchronization.
apps/sim/connectors/linear/linear.ts Linear requests now use the shared authorization formatter for personal API keys and OAuth tokens.
packages/sim-cli/src/contract/commands.ts Knowledge connector commands are reorganized under the corrected nested CLI hierarchy.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant Update as Connector update
  participant DB
  participant Queue
  participant Worker
  Caller->>Update: Replace sourceConfig
  Update->>DB: CAS update sourceConfig + due marker
  DB-->>Update: Updated connector
  Update->>Queue: Dispatch with expected due time
  Queue->>DB: Verify due marker and runnable status
  Queue->>Worker: Enqueue idempotent sync
  Worker->>DB: Acquire sync lock and return current row
  Worker->>Worker: Sync using locked sourceConfig snapshot
  Worker->>DB: Write terminal state if lock still owned
  Update-->>Caller: Updated connector or dispatch failure
Loading

Reviews (6): Last reviewed commit: "Merge origin/staging into fix/kb-connect..." | Re-trigger Greptile

Comment thread apps/sim/lib/knowledge/orchestration/connectors.ts Outdated
Comment thread apps/sim/lib/knowledge/connectors/sync-engine.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/knowledge/orchestration/connectors.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 335c015. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/knowledge/orchestration/connectors.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/knowledge/connectors/queue.ts
Comment thread apps/sim/lib/knowledge/connectors/queue.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

Comment thread apps/sim/lib/knowledge/connectors/queue.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ea8b877. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5d0ac9c. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant