SR-030 — Admin UI: Tenant Catalog Migration Console Spec
Metadata
| Field | Value |
|---|---|
| System Name | ui-admin-application — features/migration/ |
| Document ID | SR-2026-MIG-002 |
| Author | Engineering Team |
| Status | Implemented (gaps noted inline) |
Traces back to BRD-029 — Admin UI: Tenant Catalog Migration Console.
Functional Requirements
Ingest & Upload (pages/ingest/IngestPage.tsx, MigrationController.ts)
FR-01 (Presigned GCS upload, BR-01): startUpload requests presigned upload URLs through features/media/MediaService and uploads the selected .zip directly to GCS, tagged with transactionName: 'migration_bundle' (MIGRATION_BUNDLE_TRANSACTION_NAME) — the same fixed transaction name media-access-service/content-processor route on, and the one firebase-function’s storage_migration_upload_event.js filters for (see SR-029 FR-01). The console is the sole producer of this upload shape.
FR-02 (Client-minted batch identifier, BR-01): the console generates its own batchId (`batch_${Date.now()}`) before the upload starts and sends it as the upload’s transactionId — this value becomes the Pub/Sub envelope’s transaction_id, which tenant-migration’s MigrationBatchCreatedReceiver uses directly as the server-side batchId (SR-029 FR-02) — the console and the backend agree on one identifier from the first moment, with no separate “create batch, then upload” round trip. (See TD-00024 for a gap in how this identifier is generated.)
FR-03 (Bounded post-upload materialization wait, BR-01): after upload, pollForBatch polls GET-equivalent fetchBatch(batchId) every 1.5s (BATCH_POLL_INTERVAL_MS) for up to 40 attempts (BATCH_POLL_MAX_ATTEMPTS, a 60-second ceiling) waiting for the asynchronously-created migration_batches document to appear; exceeding the ceiling surfaces a visible error ("[Migration] pollForBatch — timed out") rather than leaving the UI spinning indefinitely.
Verify gate (pages/ingest/IngestPage.tsx, MigrationService.ts)
FR-04 (Verify gated to UPLOADED, BR-02): isVerifyReady enables “Verify & Push to Queue” only when the batch’s status is exactly UPLOADED — a batch in any other state cannot be re-submitted for verification from the console.
FR-05 (Three-step verify progress, BR-02): verification renders three named steps — Extract Bundle, Schema & Directory Audit, Compile Records (verificationStepLabel mapping EXTRACT/SCHEMA/COMPILE) — each with its own PENDING/RUNNING/PASSED/FAILED chip, polled via pollForVerification on the same 1.5s/40-attempt schedule as FR-03 until the batch reaches VERIFIED or VERIFICATION_FAILED; exceeding the poll ceiling surfaces "Verification is taking longer than expected." rather than hanging silently.
FR-06 (Execute gated to VERIFIED, BR-02): isExecuteReady enables “Execute Migration” only when the batch’s status is exactly VERIFIED — an unverified or VERIFICATION_FAILED bundle can never be executed from the console, matching BRD-029 BR-02 exactly.
Execute & live monitor (pages/monitor/MonitorPage.tsx, MigrationController.ts)
FR-07 (Dual execute entry points, BR-01, BR-03): startExecute executes the in-memory currentBatchId from the Ingest tab’s own flow; runExecute takes an explicit batchId argument and is used from the History tab’s play-arrow action instead, because currentBatch/currentBatchId live only in React state and are lost on a page refresh — a batch verified in an earlier session has no other path back to Execute except through the persisted History list. See ADR-00046.
FR-08 (SSE live execution stream, BR-03): once execution starts, the console opens a Server-Sent Events stream (openMigrationStream, wrapping core/http/sseClient’s openEventStream) scoped to the running batch; a streamCloserRef guards against opening a second stream for the same batch and guarantees the stream is closed on unmount or tab change. See ADR-00046 for why execution monitoring uses push (SSE) while upload/verify waiting (FR-03, FR-05) uses polling.
FR-09 (Four-stage, per-entity-type progress, BR-03): the Live Execution Monitor renders all four pipeline stages (stage1Foundational → stage4Finalize) with one row per entity type inside each stage, showing queued/processed/failed counts and, where applicable, which other entity type(s) it is still blocked on — a direct visualization of the backend’s wave-barrier execute stages (SR-029 FR-11, FR-12).
Historical audits & corrective actions (pages/history/HistoryPage.tsx, pages/history/AuditDrawer.tsx, MigrationService.ts)
FR-10 (Full batch history list, BR-04): the Historical Audits tab lists every batch for the current tenant — filename, batch id, created timestamp, and a StatusChip — sourced from fetchBatches, with no cross-tenant visibility (the repository call is tenant-scoped like every other call in this feature).
FR-11 (Per-batch action set matches backend-allowed transitions, BR-05): each history row exposes only the actions the backend pipeline would actually accept for that batch’s current status: View (always), Watch live progress (!isTerminalStatus(batch) || canRetryBatch(batch)), Execute (isExecuteReady(batch)), Cancel (!isTerminalStatus(batch)), Retry (canRetryBatch(batch)), Delete (canDeleteBatch(batch)) — the console never offers an action the pipeline would reject.
FR-12 (Status-specific retry semantics, BR-05): retry is offered for VERIFICATION_FAILED (re-enqueues the verify pipeline from scratch), EXECUTION_FAILED (re-enqueues the execute pipeline from scratch), and COMPLETED_WITH_ERRORS (re-publishes only the failed records, read from already-processed GCS output) — matching SR-029 FR-19’s dead-letter retry exactly; the console never offers a blanket “retry everything” action.
FR-13 (Status-specific delete eligibility, BR-05): delete is offered only for UPLOADED (nothing of value was ever processed), VERIFICATION_FAILED (verification itself failed, nothing of value was processed), and CANCELLED (the operator already chose to discard it) — any other status must be retained for audit and has no delete action available.
FR-14 (Confirmation required before any destructive action, BR-06): retry, delete, and cancel each route through requestHistoryAction → a ConfirmDeleteDialog with action-specific copy (CONFIRM_COPY) → confirmPendingHistoryAction/cancelPendingHistoryAction — no destructive action fires directly off a single click.
FR-15 (Per-batch audit drawer, BR-04): AuditDrawer opens as a right-side panel for any selected batch, showing its verification steps (including a RUNNING state not shown on the History row itself) and an “Entity Summaries” section — one card per entity type with validation status, total/valid/invalid counts, queued/processed/failed stage counts, the list of files that contributed records, and the specific validation checks that ran.
FR-16 (Errors panel shown even with zero stage failures, BR-06): the shared MigrationErrorsPanel (used by both the Monitor tab and the Audit drawer) is shown whenever getTotalFailed(batch) > 0 or batch.status === 'VERIFICATION_FAILED' — a verification-stage failure never touches any stage’s failed counter (the pipeline aborts before a single record is queued), so status is checked explicitly rather than inferring “nothing to show” from a zero count.
FR-17 (Paginated execution errors, unpaginated verification errors, BR-04): MigrationErrorsPanel renders unpaginated verification-stage errors (keyed by step/entity type — always a small, fixed set) separately from paginated execution-stage errors (keyed by migration type/original record id, via fetchBatchErrors(batchId, page, pageSize) and MUI TablePagination) — a batch with thousands of failed records never renders them all into the DOM at once.
Cross-cutting
FR-18 (Tabs, not a wizard, BR-01): the feature’s three top-level views — Ingest & Validate, Live Execution Monitor, Historical Audits — are MUI Tabs/Tab, freely switchable in any order with no forced sequence and no final combined submit step, per ui-admin-application/CLAUDE.md’s explicit rule that a feature with independent, any-order sections stays on Tabs rather than a Wizard. See ADR-00046.
FR-19 (TenantID sourced from authStore only, BR-06): tenantId is read once in MigrationController (useAuthStore((s) => s.tenantId)) and passed explicitly into every service/repository call; MigrationRepository.ts never reads authStore itself — its own code comment states the SSE stream’s auth token is “passed as an argument… never read from authStore here, per the Repository-never-reads-authStore rule” — matching ui-admin-application/CLAUDE.md’s TenantID flow rule and 00-global-microservice-rules’ multi-tenancy mandate.
Non-Functional Requirements
NFR-01 (Repository is the sole HTTP/SSE boundary): MigrationRepository.ts is the only file in the feature importing apiClient or opening the SSE connection — MigrationController.ts and every page component reach the network exclusively through it, per the Feature Triad.
NFR-02 (Structured, prefixed logging): every controller action logs via loglevel (log.debug/log.warn/log.error) with a consistent "[Migration] <action> — <detail>" message prefix, making a single operator action traceable across its async steps (upload → poll → verify → poll → execute → stream) in the browser console.
NFR-03 (Bounded waits, visible timeouts): both status-polling loops (FR-03, FR-05) are bounded at 40 attempts / 60 seconds and surface a user-visible error on timeout rather than polling forever or failing silently (NFR-05 mirrors SR-029’s own NFR-05 on the backend’s wave-barrier wait).
NFR-04 (No action offered that the backend would reject): every action-visibility rule in FR-11 through FR-13 is derived from the same MigrationBatchStatus the backend pipeline itself transitions through — the console’s eligibility logic (isVerifyReady, isExecuteReady, isTerminalStatus, canRetryBatch, canDeleteBatch) is a client-side mirror of the backend’s own allowed transitions, not an independently invented rule set.
NFR-05 (No DEV mock fallback): (Gap — ui-admin-application/CLAUDE.md requires every new feature’s repository to include a DEV_MOCK_* fallback so the UI works without a running backend; MigrationRepository.ts has none, see TD-00024.)
Related Documents
- BRD-029 — Admin UI: Tenant Catalog Migration Console
- BRD-028 — Tenant Catalog Bulk Data Migration
- SR-029 — Tenant Catalog Bulk Data Migration Spec
- ADR-00046 — Tabs and Dual-Channel Status Strategy for the Tenant Migration Console
- Architecture-00025 — Admin UI: Tenant Catalog Migration Console Component Topology and Data Flow
- TD-00024 — Admin UI: Tenant Catalog Migration Console Gaps
- Tenant Data Migration Admin UI — Walkthrough Overview
- tenant-migration
- tenant-migration-orchestrator