Skip to content

Expose a typed Sync Service API#77

Open
AntonNiklasson wants to merge 1 commit into
mainfrom
codex/sync-service-api
Open

Expose a typed Sync Service API#77
AntonNiklasson wants to merge 1 commit into
mainfrom
codex/sync-service-api

Conversation

@AntonNiklasson

Copy link
Copy Markdown
Owner

Summary

  • replace the sync package’s low-level public constructors with a typed SyncService application boundary
  • expose normalized pull-request and notification read models, explicit/requested sync operations, and lifecycle methods
  • keep SQLite, repositories, providers, engine construction, and cache diagnostics internal
  • migrate the sync CLI’s execution paths onto the service contract
  • contain fire-and-forget failures and make terminal close wait for outstanding work and release storage
  • document the contract and build the sync artifact from the root build

This intentionally does not integrate the API server. It establishes the boundary that a later integration can consume through dependency injection.

Validation

  • pnpm typecheck
  • pnpm test (203 tests)
  • pnpm lint
  • pnpm fmt:check
  • pnpm build
  • pnpm --filter sync cli --help

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

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 reshapes the packages/sync package into a small, typed application boundary (SyncService) intended for dependency injection by future consumers (e.g., the dashboard server), while keeping storage/engine composition details internal.

Changes:

  • Introduces a SyncService API with normalized read models, explicit sync operations, and lifecycle management (start/stop/close).
  • Centralizes domain model types (PullRequest, Notification, etc.) and reuses them in GitHub normalization.
  • Migrates the sync CLI to consume the service contract and updates root build to include the sync package.

Reviewed changes

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

Show a summary per file
File Description
packages/sync/src/service.ts Adds the new SyncService boundary, request tracking, and lifecycle semantics.
packages/sync/src/service.test.ts Adds focused tests for read-model normalization, lifecycle delegation, and background error containment.
packages/sync/src/providers/github/normalize.ts Aligns normalization types with shared models and aliases NormalizedPr to the public PullRequest.
packages/sync/src/models.ts Introduces shared, normalized domain model types for PRs and notifications.
packages/sync/src/index.ts Narrows the public surface to the service boundary + exported model/engine types.
packages/sync/src/index.test.ts Updates public surface tests to validate only the service constructor is exported at runtime.
packages/sync/src/cli.ts Migrates CLI commands from direct engine composition to the SyncService API.
packages/sync/README.md Documents the new service contract and usage expectations for consumers.
package.json Ensures the sync package is built as part of the root build.

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

Comment on lines +94 to +98
async function stop(): Promise<void> {
if (closed) return;
await engine.stop();
await waitForPending();
}
Comment on lines +87 to +88
const engineOptions = (request: SyncRequest | undefined) =>
request ? { instance: request.instanceId, kind: request.kind } : undefined;
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