// @bun
import{CodeBlock as t,InstallCommand as o}from"@contractspec/lib.design-system";import r from"@contractspec/lib.ui-link";import{ChevronRight as l}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function s(){return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Progressive Delivery Library"}),a("p",{className:"text-lg text-muted-foreground",children:["The ",e("code",{children:"@contractspec/lib.progressive-delivery"})," package helps you ship new specs with confidence: canary + blue-green strategies, metric guardrails, and rollback hooks in one place."]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(o,{package:"@contractspec/lib.progressive-delivery"})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Define a Strategy"}),e(t,{language:"typescript",code:`import { DeploymentCoordinator, createDefaultCanaryController, TrafficShifter, RollbackManager } from '@contractspec/lib.progressive-delivery';

const strategy = {
  target: { name: 'billing.createInvoice', version: 7 },
  mode: 'canary',
  thresholds: {
    errorRate: 0.01,
    latencyP99: 500,
    latencyP95: 250,
  },
};`})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Run the Coordinator"}),e(t,{language:"typescript",code:`const eventBus = new DeploymentEventBus();
const controller = createDefaultCanaryController(strategy, fetchMetrics, eventBus);
const coordinator = new DeploymentCoordinator({
  strategy,
  controller,
  trafficShifter: new TrafficShifter(strategy.mode),
  rollbackManager: new RollbackManager({ rollback: revertSpec }),
  applyTrafficSplit: updateFeatureFlag,
  eventBus,
});

const result = await coordinator.run();`}),a("p",{className:"text-muted-foreground text-sm",children:["The coordinator emits ",e("code",{children:"stage_started"}),","," ",e("code",{children:"stage_failed"}),", and ",e("code",{children:"rolled_back"})," events, making it easy to power dashboards or alerting workflows."]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Blue-Green Swap"}),a("p",{className:"text-muted-foreground text-sm",children:["Switch to ",e("code",{children:"mode: 'blue-green'"})," to warm up the new stack in parallel and cut over once smoke tests pass. The same guardrails apply before the final swap."]})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(r,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),a(r,{href:"/docs/libraries/resilience",className:"btn-primary",children:["Next: Resilience ",e(l,{size:16})]})]})]})}export{s as LibrariesProgressiveDeliveryPage};
