Module 6 of 6 · 61 min

Execute, Roll Back, and Close a Provider Migration

Move from offline evidence through shadow and canary stages, reconcile state and side effects during rollback, and hand off residual risk only after production observation.

Core conceptAnthropicOpenAIGoogle

By the end

You will be able to

  • Implement versioned adapters, configurable routing, compatible records, and isolated telemetry before shifting traffic.
  • Progress through offline, shadow, canary, and promotion gates with explicit stop authority.
  • Roll back safely by reconciling conversation state, tool side effects, queued work, learner records, and duplicate actions.
  • Close a migration with observed production evidence, current runbooks, lifecycle cleanup, and accepted residual risk.
01

Prepare versioned routes and records

Put source and candidate behind explicit versioned adapters and configurable routing. Keep domain records, learner progress, assessment attempts, transcripts, evidence references, and stable identifiers compatible across the change; add version fields rather than silently reinterpreting old data.

Separate telemetry by provider, surface, model, adapter, prompt, policy, evaluation set, and route. Validate credentials from environment or a secret manager, least-privilege access, timeouts, retries, budget controls, data handling, and incident ownership before enabling candidate execution.

Configurable route without embedded credentials
typescript
const route = process.env.MIGRATION_ROUTE ?? "source";
const allowedRoutes = new Set(["source", "shadow", "candidate-canary"]);
if (!allowedRoutes.has(route)) throw new Error("Unsupported migration route");

const credentialsPresent = [
  process.env.ANTHROPIC_API_KEY,
  process.env.OPENAI_API_KEY,
  process.env.GEMINI_API_KEY,
].filter(Boolean).length;
if (credentialsPresent === 0) throw new Error("No provider credential is configured");
02

Advance through controlled stages

Start with deterministic contract tests and offline replay. Use shadow execution only when duplicate processing complies with privacy, contractual, cost, and side-effect policy; block or simulate tools so a shadow cannot repeat real actions.

Move to a small cohort or use-case canary only when offline and shadow gates pass. Cap traffic, duration, cost, retries, tool permissions, and blast radius. Expand one stage at a time after the named approver reviews critical-slice evidence.

03

Enforce gates and stop authority

Evaluate output quality, factuality, safety and refusal behavior, structured data, tool trajectories, state continuity, accessibility, latency, errors, usage, cost, data controls, operator load, and incident signals by critical slice. Aggregate averages must not hide a failed safety, language, accessibility, or high-value workflow.

Automate bounded stops for clear thresholds and give an on-call human authority to pause or roll back on ambiguous high-consequence signals. Preserve the evidence, route version, decision, approver, and timestamp for every hold, expansion, or rollback.

04

Roll back and reconcile state and side effects

Route new work back to the proven source, stop or drain candidate workers, and preserve failure evidence. Identify in-flight conversations, tool calls, file or database writes, messages, purchases, queued jobs, caches, retries, learner attempts, and records that may be incomplete or duplicated.

Use idempotency keys, operation journals, versioned state, compensating actions, and manual review queues to reconcile each side effect. Verify source health, data integrity, duplicate suppression, access cleanup, and user communication before declaring rollback complete.

05

Observe, close, and hand off residual risk

After promotion, keep source routing or another tested fallback until the defined observation window passes. Confirm service, quality, safety, accessibility, cost, capacity, data, support, and incident indicators; rehearse rollback again if configuration or dependencies changed.

Close only when deprecated use is removed or accepted with an owner, records and migrations are verified, dashboards and alerts are current, runbooks and training match production, credentials and permissions are right-sized, unresolved risk is accepted by the accountable owner, and the next lifecycle review is scheduled.

Practice activity

Run a failed-canary and rollback rehearsal

  1. Create synthetic no-paid-call source and candidate traces with stable request, learner, attempt, tool-call, side-effect, and route identifiers; include one hidden critical-slice regression and one ambiguous operational signal.
  2. Move the fixture set through contract, offline, shadow, and canary gates, recording evidence, approver, exposure, cost assumption, decision, and timestamp at each stage.
  3. Trigger the failed canary, route new work to the source, stop or drain the candidate, and inventory every in-flight state item, tool side effect, queued action, retry, and learner record.
  4. Reconcile the synthetic operation journal with idempotency and compensating actions, verify source health and data integrity, and measure detection, decision, rollback, and reconciliation time.
  5. Write a closeout and residual-risk handoff that identifies production observation, lifecycle cleanup, documentation, access, owners, acceptance authority, and the next review date.

What to produce

  • A staged gate log and isolated trace set showing exact route versions, critical-slice results, approvals, exposure limits, and the rollback trigger.
  • A reconciled operation journal, recovery verification, measured rollback report, and signed closeout and residual-risk handoff.

Reflect before continuing

Which state or side effect would have remained inconsistent if rollback had only changed the traffic route?

Evidence

Sources and verification

Knowledge check

Make it stick.

Pass at 80%

Choose the strongest answer for each question. Your attempts become part of your device-local transcript.

01What must remain compatible during provider migration?
02When is shadow execution appropriate?
03Why evaluate critical slices separately?
04What completes rollback?
05When can migration close?