Skip to content

Integrate the sync engine into the backend - #76

Closed
AntonNiklasson wants to merge 1 commit into
mainfrom
codex/integrate-sync-engine
Closed

Integrate the sync engine into the backend#76
AntonNiklasson wants to merge 1 commit into
mainfrom
codex/integrate-sync-engine

Conversation

@AntonNiklasson

Copy link
Copy Markdown
Owner

Summary

  • replace the server’s legacy PR/review/notification cache loop with the shared SQLite sync engine
  • serve dashboard reads from the sync repository and support targeted fresh=1 cycles
  • preserve optimistic mutation behavior and guard against stale GitHub search results
  • reconcile instances after config reloads and stop the engine cleanly during shutdown
  • build the sync workspace before server development, tests, and production builds

Validation

  • pnpm typecheck
  • pnpm test (198 tests)
  • pnpm lint
  • pnpm fmt:check
  • pnpm build

Copilot AI review requested due to automatic review settings July 10, 2026 21:20

Copilot AI 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.

Pull request overview

This PR integrates the shared packages/sync SQLite-backed sync engine into the packages/server backend, replacing the server’s legacy in-memory cache loop and switching API reads to come from the sync repository (with optional targeted ?fresh=1 syncs).

Changes:

  • Wire the server to the sync engine + SQLite repository; add clean engine startup/shutdown hooks.
  • Update API routes to read PRs/notifications from the sync repository and run targeted fresh=1 sync cycles.
  • Ensure the sync workspace is built before server dev/test and root builds.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds sync workspace link to the lockfile importers.
packages/sync/src/cache/store.ts Extends the repository contract with targeted PR/notification mutation helpers.
packages/sync/package.json Adjusts package export typing to point at source types for workspace consumption.
packages/server/src/sync.ts Replaces legacy interval cache loop with the shared sync engine + SQLite repo, and adds mutation guarding.
packages/server/src/routes.ts Switches routes to read from sync repo; supports fresh=1 targeted sync; keeps optimistic removals/draft toggles.
packages/server/src/routes.test.ts Updates route tests to mock the new sync interface and new initial-empty behavior.
packages/server/src/index.ts Stops the sync engine during shutdown (after closing the HTTP server).
packages/server/package.json Builds sync before server dev/test to ensure runtime artifacts exist.
package.json Builds sync before server/web in the root build pipeline.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +123 to 127
const promise = resyncInstance(instanceId, keys).finally(() => {
pending.delete(promise);
});
pending.add(p);
pending.add(promise);
}
Comment on lines +129 to 134
export function scheduleFullResync(): void {
const promise = engine.runOnce().finally(() => {
pending.delete(promise);
});
pending.add(promise);
}
Comment on lines +68 to +71
server.close(async () => {
await stopSync();
process.exit(0);
});
Comment on lines 343 to 346
const res = await call("/config/reload", { method: "POST" });
expect(res.status).toBe(200);
expect(configStub.invalidateConfigStatus).toHaveBeenCalled();
expect(cacheStore.get("github:prs")).toBeNull();
expect(cacheStore.get("github:reviews")).toBeNull();
expect(cacheStore.get("github:notifications")).toBeNull();
const body = await res.json();
);
pending.add(promise);
},
scheduleFullResync: () => {},
@AntonNiklasson

Copy link
Copy Markdown
Owner Author

Closing this integration attempt so we can first establish a clean, independently testable Sync Service API. The server integration can be reproduced on top of that foundation.

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.

2 participants