Skip to content

OUT-4041: L1.4 — resync sweep flow tests - #128

Open
SandipBajracharya wants to merge 3 commits into
mainfrom
OUT-4041
Open

OUT-4041: L1.4 — resync sweep flow tests#128
SandipBajracharya wants to merge 3 commits into
mainfrom
OUT-4041

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What & why

L1.4 — the last of the L1 flow spine. Integration tests for the resync sweep: retrying and reconciling failed fileFolderSync rows (rows carrying a pendingAction tombstone that errored). Driven in-process via the L1.0 Trigger double against Testcontainers Postgres, Dropbox + Copilot faked via MSW.

Changes (all test/**, zero production change)

  • test/msw/write.ts (+ harness test) — new mockCopilotRetrieveFile (GET /v1/files/:id); mockDropboxUpload's default now returns a distinct id per path (avoids partial-unique collisions); delete_v2 mock comment clarified.
  • test/flows/resync-sweep.integration.test.ts — 12 scenarios.
  • DRY refactor: removed 4 duplicated uniqueDbxUpload copies across the existing flow tests → they use the new default.

What it proves (12 scenarios)

  • Backoff selection (findFailedSyncs): past-backoff + null-last-attempt picked; too-recent, attempts=10, and deleted rows skipped — SQL NOW() boundary driven by minutesAgo() seeds.
  • Retry create/delete: Dropbox delete (exact path), Assembly delete (exact id), Dropbox create (re-upload → tombstone cleared).
  • Reconcile: completed → markUpdated + count++; recently-stuck (<12h) → markFailure, untouched; abandoned (≥12h) → stale file deleted + recreated with a fresh id.
  • Per-row isolation: one throwing row → markFailure, batch continues.
  • Per-channel resync gating (resyncFailedFilesForChannel): 404 unknown / 409 already-resyncing / reset-only (stubbed orchestration) / full end-to-end (reset → retry → clears resyncingAt).

Both clock domains handled: SQL NOW() via minutesAgo seeds, JS Date.now() (12h) via createdAt: hoursAgo(n).

Reviewed by the fullstack reviewer (SHIP). This completes the L1 flow spine (L1.0–L1.4).

Testing

  • pnpm typecheck ✅ · pnpm lint
  • pnpm test:integration — 88/88 ✅ (13 files)

🤖 Generated with Claude Code

SandipBajracharya and others added 3 commits August 13, 2026 20:38
…d ids

mockCopilotRetrieveFile (GET /v1/files/:id, 404 for unknown), proven by a
harness test. mockDropboxUpload's default now yields a distinct id per path
so multiple uploads in one test don't collide on the partial unique index.
Clarify the delete_v2 mock comment (returns file/folder metadata).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Removed 3 identical uniqueDbxUpload helpers + 1 inline copy; call sites now
use mockDropboxUpload()'s distinct-per-path default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Backoff selection, retry create/delete, per-row error isolation, reconcile
(completed / recently-stuck / abandoned-past-12h), and per-channel resync
gating (404 / 409 / reset + run). Driven via ResyncService /
retryFailedSyncsForPortal against Postgres with Dropbox + Copilot MSW.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 13, 2026

Copy link
Copy Markdown

OUT-4041

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview Aug 13, 2026 2:55pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown

Greptile Summary

The PR expands integration coverage for failed-sync retry, reconciliation, and manual resync orchestration while consolidating Dropbox upload mock behavior.

  • Adds resync sweep scenarios for backoff selection, create/delete retries, reconciliation states, row-level failure isolation, and channel resync gating.
  • Adds a Copilot retrieve-file MSW helper and harness coverage for successful and missing-file responses.
  • Makes default Dropbox upload metadata IDs distinct by path and removes duplicated test-local resolvers.

Confidence Score: 5/5

The PR appears safe to merge, with its changes confined to coherent integration tests and test harness helpers.

The new scenarios map to the intended retry, reconciliation, and orchestration branches, while the shared mock changes preserve existing test behavior without introducing a concrete failure.

Important Files Changed

Filename Overview
test/flows/resync-sweep.integration.test.ts Adds focused integration coverage for sweep eligibility, retry and reconciliation branches, per-row isolation, and manual resync lifecycle behavior.
test/msw/write.ts Adds a retrieve-file Copilot handler and makes default Dropbox upload IDs distinct across paths.
test/msw/write.integration.test.ts Verifies that the new retrieve-file handler returns mapped files and reports unknown IDs as 404.
test/flows/assembly-to-dropbox.initial-sync.integration.test.ts Replaces a local unique-upload resolver with the equivalent shared default mock behavior.
test/flows/assembly-webhook-controller.integration.test.ts Removes duplicated path-derived Dropbox upload metadata setup in favor of the shared helper default.
test/flows/assembly-webhook.integration.test.ts Uses the consolidated upload mock default without changing the exercised webhook behavior.

Sequence Diagram

sequenceDiagram
    participant User
    participant Service as ResyncService
    participant DB
    participant Trigger as Inline Trigger
    participant Retry as Retry Worker
    participant APIs as Dropbox/Copilot Mocks
    User->>Service: resyncFailedFilesForChannel
    Service->>DB: Validate channel and set resyncingAt
    Service->>DB: Reset pending attempts and backoff
    Service->>Trigger: Start resync orchestration
    Trigger->>Retry: Retry pending rows
    loop Each failed row
        Retry->>APIs: Delete, retrieve, or recreate
        Retry->>DB: Mark updated, deleted, or failed
    end
    Trigger->>DB: Run master-sync reconciliation
    Trigger->>DB: Clear resyncingAt in finally
    Service-->>User: Return pendingCount
Loading

Reviews (1): Last reviewed commit: "test(OUT-4041): add resync sweep flow te..." | Re-trigger Greptile

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