Skip to content

refactor(gitlab): make credential migration stateless#4649

Merged
eshurakov merged 1 commit into
mainfrom
confusion-gardenia
Jul 21, 2026
Merged

refactor(gitlab): make credential migration stateless#4649
eshurakov merged 1 commit into
mainfrom
confusion-gardenia

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

Replaces the stateful DB-job design for the GitLab credential migration (introduced in #4625) with a stateless, cursor-paged design:

  • Drops the gitlab_credential_migration_jobs table (migration 0191), along with the job repository, lease fencing, phase state machine, and CLI script.
  • The admin router now exposes backfillNextBatch, verifyDecryptability, and scrubNextBatch procedures. Each processes one keyset page and returns nextCursor; the operator walks the table until it returns null.
  • Migration state lives in the data itself — a migrated row stops matching the selection query — so every step is idempotent and resumable without lease recovery.
  • Scrub remains gated by the exact confirmation string and now re-checks the public/private keypair match on every call; full decrypt coverage is verified via verifyDecryptability beforehand.
  • New modules: credential-migration-selection.ts (keyset selection queries) and credential-migration-verify.ts (decryptability and key-match checks).

Operator flow: audit via SQL → backfillNextBatch to completion → verifyDecryptability across all pages → scrubNextBatch to completion → re-audit.

Verification

  • No manual verification; admin-only migration tooling that runs against production data during the operator run. Behavior is covered by targeted automated tests (GitLab credential migration + admin router suites) run against the local test Postgres.

Visual Changes

N/A

Reviewer Notes

  • Focus on credential-migration.ts (per-integration backfill/scrub guards), credential-migration-selection.ts (keyset queries), and credential-migration-verify.ts (decryptability checks).
  • Migration 0191 drops the jobs table, which was only ever used by the admin tooling from feat(gitlab): add admin job runner for credential migration #4625.

…tch procedures

Drop the gitlab_credential_migration_jobs table, lease fencing, phase state
machine, and CLI script. The admin router now exposes backfillNextBatch,
verifyDecryptability, and scrubNextBatch procedures that walk keyset pages;
migration state lives in the data itself, so a migrated row simply stops
matching the selection query. Scrub remains gated by an exact confirmation
string plus a keypair-match guard on every call.
@kilo-code-bot

kilo-code-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the stateless, cursor-paged rewrite of GitLab credential migration (backfill/verify/scrub logic, keyset selection queries, admin router, and the associated table-drop migration); no high-confidence CRITICAL/WARNING/SUGGESTION issues were found in changed code, and no dangling references to the deleted job/job-repository modules remain.

Files Reviewed (17 files)
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration.test.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-selection.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-verify.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-audit.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-backfill.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-legacy.ts
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-job.ts (deleted)
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-job-repository.ts (deleted)
  • apps/web/src/lib/integrations/platforms/gitlab/credential-migration-job-repository.test.ts (deleted)
  • apps/web/src/routers/admin-gitlab-credential-migration-router.ts
  • apps/web/src/routers/admin-gitlab-credential-migration-router.test.ts
  • apps/web/src/scripts/db/gitlab-credential-migration.ts (deleted)
  • packages/db/src/schema.ts
  • packages/db/src/migrations/0191_drop_gitlab_credential_migration_jobs.sql
  • packages/db/src/migrations/meta/0191_snapshot.json (generated, skipped per review rules)
  • packages/db/src/migrations/meta/_journal.json (generated, skipped per review rules)

Reviewed by claude-sonnet-5 · Input: 24 · Output: 10.2K · Cached: 502.1K

Review guidance: REVIEW.md from base branch main

@eshurakov
eshurakov merged commit d569adf into main Jul 21, 2026
63 checks passed
@eshurakov
eshurakov deleted the confusion-gardenia branch July 21, 2026 10:00
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