// @bun
var i=Object.defineProperty;var n=(t)=>t;function s(t,r){this[t]=n.bind(null,r)}var m=(t,r)=>{for(var o in r)i(t,o,{get:r[o],enumerable:!0,configurable:!0,set:s.bind(r,o)})};var g=(t,r)=>()=>(t&&(r=t(t=0)),r);import{CodeBlock as l,InstallCommand as d}from"@contractspec/lib.design-system";import c from"@contractspec/lib.ui-link";import{ChevronRight as p}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function u(){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(d,{package:"@contractspec/lib.progressive-delivery"})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Define a Strategy"}),e(l,{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(l,{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(c,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),a(c,{href:"/docs/libraries/resilience",className:"btn-primary",children:["Next: Resilience ",e(p,{size:16})]})]})]})}export{u as LibrariesProgressiveDeliveryPage};
