Skip to content

perf(notifications): add opt-in concurrent history backfill - #445

Merged
imshashank merged 1 commit into
mainfrom
codex/notification-backfill-throughput
Sep 8, 2026
Merged

imshashank merged 1 commit into
mainfrom
codex/notification-backfill-throughput

Conversation

@imshashank

@imshashank imshashank commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add --source-concurrency=1..8 to the notification history backfill, defaulting to serial execution. Resolve and classify independent source groups in bounded windows. Drain started work before reporting failure, preserve cursor ordering and complete equivalence groups, and reject overlapping groups before classification. Other phases remain sequential. Document the restart and rollout procedure.

Evidence

The production rollout was spending roughly half a second per database round trip. The serial source phase was the main bottleneck.

  • Regression demonstrated maximum concurrency 1 before the fix and 3 after it.
  • Failure regression confirms started work settles before a failed checkpoint, then the same run resumes to zero drift.
  • Services suite: 846 passed, 5 optional storage tests skipped, no failures.
  • CLI safeguards: 10 passed.
  • Private pre-migration production backup restored locally, all 9 pending migrations applied, eight-worker backfill completed for all 10 organizations, and every verifier drift counter is zero.
  • Full local verification is being rerun after restoring local database and Redis prerequisites. CI is required before merge.

Rollout

PR #443 is already merged and deployed. The authorized production backfill has resumed from its saved checkpoint using the rehearsed eight-worker Node bundle. Provider delivery and grouped reads remain paused until production verification returns zero drift. No schema migration is introduced by this PR.

Greptile Summary

The PR adds opt-in bounded concurrency to notification source resolution and classification while preserving serial execution by default.

  • Adds and validates sourceConcurrency from the service API through the CLI.
  • Resolves and applies independent source groups in bounded windows, draining started promises before propagating failures.
  • Rejects overlapping equivalence groups before concurrent application.
  • Adds concurrency, failure-recovery, and CLI validation coverage.
  • Documents operational safeguards, restart behavior, verification, and rollout sequencing.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security defects identified in the changed paths.

The bounded-window implementation validates concurrency, preserves seed-order cursor advancement, prevents overlapping groups from being applied concurrently, drains started operations on failure, and retains resumable checkpoint behavior.

Important Files Changed

Filename Overview
packages/services/src/notifications/conversation-backfill.ts Adds validated bounded concurrency for source resolution and transactional group application while preserving ordered planning, overlap rejection, and checkpoint semantics.
packages/services/tests/notifications/conversation-backfill.test.ts Adds integration coverage for maximum concurrency, draining work after failure, resumability, verification, and invalid concurrency values.
scripts/notification-conversation-backfill.ts Exposes the source-concurrency option through the backfill CLI and delegates upper-bound validation to the service.
tests/notification-conversation-cli.test.ts Verifies that zero, excessive, fractional, and nonnumeric concurrency arguments fail before useful execution.
docs/database-releases.md Documents safe backfill rollout, concurrency limits, restart behavior, feature flags, and required drift verification.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read ordered source seeds] --> B[Split into bounded windows]
  B --> C[Resolve every seed in window concurrently]
  C --> D{Any resolution failed?}
  D -- Yes --> E[Drain window and report failure]
  D -- No --> F[Build complete source groups in seed order]
  F --> G{Next group exceeds batch bound?}
  G -- Yes --> H[Defer group without advancing past it]
  G -- No --> I[Add or merge group and advance cursor]
  I --> F
  H --> J[Reject overlapping notification IDs]
  F --> J
  J --> K[Apply independent groups concurrently]
  K --> L{Every started transaction succeeded?}
  L -- No --> M[Drain work and preserve prior checkpoint]
  L -- Yes --> N[Persist ordered cursor and processed count]
Loading

Reviews (1): Last reviewed commit: "perf(notifications): bound concurrent hi..." | Re-trigger Greptile

@imshashank
imshashank requested a review from pulkitxm as a code owner September 8, 2026 12:21
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a1abc5a7-db20-4671-a5c6-17e795c1366f

📥 Commits

Reviewing files that changed from the base of the PR and between 7ca1234 and caef103.

📒 Files selected for processing (5)
  • docs/database-releases.md
  • packages/services/src/notifications/conversation-backfill.ts
  • packages/services/tests/notifications/conversation-backfill.test.ts
  • scripts/notification-conversation-backfill.ts
  • tests/notification-conversation-cli.test.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure ci Workflows, tooling and repo automation labels Sep 8, 2026
@vercel

vercel Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
orbit Ready Ready Preview Sep 8, 2026 12:35pm UTC

Request Review

@imshashank

Copy link
Copy Markdown
Contributor Author

Final review: current main is already included, no unresolved review threads, and all CI checks plus the Vercel preview and Greptile review passed. Reviewed bounded concurrency, disjoint source groups, draining failed work before checkpointing, deterministic ordering, and resumability. Production source classification is complete; conversation materialization is still running with providers paused. The private production-data rehearsal completed with zero verifier drift across all 10 organizations. Local full verification reached the analytics line-plot suite and hit a Bun SIGTRAP; a subsequent isolated attempt was blocked by the local Postgres service stopping. CI unit/integration and both E2E suites passed. CodeRabbit rate limiting is not a gate per the requested review policy.

@imshashank
imshashank merged commit f9d33cf into main Sep 8, 2026
19 checks passed
@imshashank
imshashank deleted the codex/notification-backfill-throughput branch September 8, 2026 12:36
@imshashank

Copy link
Copy Markdown
Contributor Author

Merged and deployed to production at https://orbit.noveum.ai (deployment dpl_4u2cDqdrKWhcV1T5AiiwH6mShaBH, READY). Fixed a rollout configuration gap by adding the existing Slack app ID to Vercel production and preview. Live Slack channel lookup succeeds and member synchronization succeeds, currently matching 8 of 10 members. Historical source classification is complete; conversation materialization remains in progress. Grouped reads remain disabled and providers remain paused until backfill completion and a zero-drift production verifier result. Historical unresolved delivery destinations have not been reset for resend.

This branch was successfully deployed

1 active deployment
Preview — caef1038 Deployed Sep 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Workflows, tooling and repo automation documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant