// @bun
// src/components/docs/architecture/ArchitectureAppConfigPage.tsx
import { CodeBlock } from "@contractspec/lib.design-system";
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
function ArchitectureAppConfigPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: "App Configuration"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground",
            children: "ContractSpec uses a three-tier configuration model that separates global app definitions from tenant-specific settings and runtime resolution."
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "AppBlueprintSpec"
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground",
            children: [
              "The ",
              /* @__PURE__ */ jsx("strong", {
                children: "AppBlueprintSpec"
              }),
              " is the global, versioned definition of your application. It contains no tenant-specific information and is stored in version control."
            ]
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `type AppBlueprintSpec = {
  id: string;
  version: string;
  name: string;
  description: string;
  
  // Core specs
  capabilities: CapabilitySpec[];
  dataViews: DataViewSpec[];
  workflows: WorkflowSpec[];
  policies: PolicySpec[];
  
  // Required integrations
  requiredIntegrations: {
    integrationId: string;
    category: IntegrationCategory;
    purpose: string;
    optional?: boolean;
  }[];
  
  // Expected knowledge spaces
  knowledgeSpaces: {
    spaceId: string;
    category: KnowledgeCategory;
    required: boolean;
    purpose: string;
  }[];
  
  // UI/UX
  theme: ThemeSpec;
  overlays: OverlaySpec[];
  
  // Observability
  telemetry: TelemetrySpec;
  
  // Schema evolution
  migrations: MigrationSpec[];
};`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "TenantAppConfig"
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground",
            children: [
              "The ",
              /* @__PURE__ */ jsx("strong", {
                children: "TenantAppConfig"
              }),
              " is the per-tenant, per-environment configuration that customizes how a specific tenant uses the app."
            ]
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `type TenantAppConfig = {
  tenantId: string;
  blueprintId: string;
  blueprintVersion: string;
  environment: "sandbox" | "staging" | "production";
  status: "draft" | "preview" | "published" | "archived" | "superseded";
  
  // Integration bindings
  integrationBindings: AppIntegrationBinding[];
  
  // Knowledge bindings
  knowledgeBindings: AppKnowledgeBinding[];
  
  // Tenant-specific overrides
  featureFlags: Record<string, boolean>;
  limits: {
    maxUsers?: number;
    maxStorage?: number;
    rateLimit?: number;
  };
  
  // Tenant customization
  branding: {
    logo?: string;
    colors?: Record<string, string>;
    domain?: string;
  };
  
  metadata: Record<string, unknown>;
  createdAt: string;
  updatedAt: string;
};`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "AppIntegrationBinding"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground",
            children: "Defines how a tenant connects specific integration instances to satisfy capabilities and workflows."
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `type AppIntegrationBinding = {
  slotId: string;          // References AppIntegrationSlot.slotId
  connectionId: string;    // References IntegrationConnection.meta.id
  scope?: {
    workflows?: string[];
    operations?: string[];
    features?: string[];
  };
  priority?: number;       // Lower number = higher priority
};

// Example:
{
  slotId: "payments.primary",
  connectionId: "conn_stripe_acme_prod",
  scope: {
    workflows: ["checkout", "subscription-renewal"],
    operations: ["payments.stripe.*"]
  },
  priority: 1
}`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "AppKnowledgeBinding"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground",
            children: "Defines which knowledge spaces a tenant's app can access and how."
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `type AppKnowledgeBinding = {
  spaceId: string;
  enabled: boolean;
  
  // Which workflows/agents can read this space
  allowedConsumers: {
    workflowIds?: string[];
    agentIds?: string[];
    roles?: string[];
  };
  
  // Category-based access control
  allowedCategories: KnowledgeCategory[];
  
  // Sources feeding this space for this tenant
  sources: string[];  // References KnowledgeSourceConfig IDs
  
  metadata?: Record<string, unknown>;
};

// Example:
{
  spaceId: "product-canon",
  enabled: true,
  allowedConsumers: {
    workflowIds: ["invoice-generation", "quote-creation"],
    agentIds: ["support-agent"]
  },
  allowedCategories: ["canonical", "operational"],
  sources: ["src_notion_product_docs", "src_database_schema"]
}`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "ResolvedAppConfig"
          }),
          /* @__PURE__ */ jsxs("p", {
            className: "text-muted-foreground",
            children: [
              "The ",
              /* @__PURE__ */ jsx("strong", {
                children: "ResolvedAppConfig"
              }),
              " is the runtime result of merging AppBlueprintSpec with TenantAppConfig. It's computed on-demand and never persisted."
            ]
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `type ResolvedAppConfig = {
  appId: string;
  tenantId: string;
  blueprintName: string;
  blueprintVersion: number;
  environment?: string;
  configVersion: number;

  capabilities: { enabled: CapabilityRef[]; disabled: CapabilityRef[] };
  features: { include: FeatureRef[]; exclude: FeatureRef[] };
  dataViews: Record<string, SpecPointer>;
  workflows: Record<string, SpecPointer>;
  policies: PolicyRef[];
  theme?: AppThemeBinding;
  telemetry?: TelemetryBinding;
  experiments: {
    catalog: ExperimentRef[];
    active: ExperimentRef[];
    paused: ExperimentRef[];
  };
  featureFlags: FeatureFlagState[];
  routes: AppRouteConfig[];

  integrations: ResolvedIntegration[]; // [{ slot, binding, connection, spec }]
  knowledge: ResolvedKnowledge[];       // [{ binding, space, sources }]
  branding: ResolvedBranding;           // { appName, assets, colors, domain }
  notes?: string;
};`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Configuration flow"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground",
            children: "Here's how configuration flows from definition to runtime:"
          }),
          /* @__PURE__ */ jsxs("ol", {
            className: "text-muted-foreground list-inside list-decimal space-y-3",
            children: [
              /* @__PURE__ */ jsxs("li", {
                children: [
                  /* @__PURE__ */ jsx("strong", {
                    children: "Development"
                  }),
                  " - Define AppBlueprintSpec with required integrations and knowledge spaces"
                ]
              }),
              /* @__PURE__ */ jsxs("li", {
                children: [
                  /* @__PURE__ */ jsx("strong", {
                    children: "Deployment"
                  }),
                  " - Deploy blueprint to environment (sandbox, staging, production)"
                ]
              }),
              /* @__PURE__ */ jsxs("li", {
                children: [
                  /* @__PURE__ */ jsx("strong", {
                    children: "Tenant Setup"
                  }),
                  " - Create TenantAppConfig with specific integration connections and knowledge sources"
                ]
              }),
              /* @__PURE__ */ jsxs("li", {
                children: [
                  /* @__PURE__ */ jsx("strong", {
                    children: "Runtime"
                  }),
                  " - Resolve configuration on-demand when tenant accesses the app"
                ]
              }),
              /* @__PURE__ */ jsxs("li", {
                children: [
                  /* @__PURE__ */ jsx("strong", {
                    children: "Execution"
                  }),
                  " - Use ResolvedAppConfig to execute capabilities, workflows, and enforce policies"
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Best practices"
          }),
          /* @__PURE__ */ jsxs("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsx("li", {
                children: "Keep AppBlueprintSpec environment-agnostic - no secrets or tenant-specific data"
              }),
              /* @__PURE__ */ jsx("li", {
                children: "Use TenantAppConfig for all tenant-specific settings and connections"
              }),
              /* @__PURE__ */ jsx("li", {
                children: "Cache ResolvedAppConfig per request to avoid repeated resolution"
              }),
              /* @__PURE__ */ jsx("li", {
                children: "Version blueprints carefully - migrations affect all tenants"
              }),
              /* @__PURE__ */ jsx("li", {
                children: "Test blueprint changes in sandbox before promoting to production"
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/architecture",
            className: "btn-ghost",
            children: "Back to Architecture"
          }),
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/architecture/integration-binding",
            className: "btn-primary",
            children: [
              "Integration Binding ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}

// src/components/docs/architecture/ArchitectureControlPlanePage.tsx
import { CodeBlock as CodeBlock2 } from "@contractspec/lib.design-system";
import Link2 from "@contractspec/lib.ui-link";
import { ChevronRight as ChevronRight2 } from "lucide-react";
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
function ArchitectureControlPlanePage() {
  return /* @__PURE__ */ jsxs2("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h1", {
            className: "text-4xl font-bold",
            children: "Control Plane Runtime"
          }),
          /* @__PURE__ */ jsx2("p", {
            className: "text-muted-foreground",
            children: "The control plane is the governance layer for agentic execution. It turns incoming intent into deterministic plans, enforces risk policy before side effects, and records replayable traces for audits."
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "Canonical execution loop"
          }),
          /* @__PURE__ */ jsxs2("ol", {
            className: "text-muted-foreground list-inside list-decimal space-y-2",
            children: [
              /* @__PURE__ */ jsx2("li", {
                children: "Accept intent and create execution identity + trace context."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Compile intent into a typed, deterministic plan DAG."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Verify plan against policy and risk rules."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Route into autonomous or assist mode based on verdict."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Execute steps with idempotent keys and explicit stage events."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Persist outcomes for replay, audits, and operator visibility."
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "Contract surfaces (v1 baseline)"
          }),
          /* @__PURE__ */ jsxs2("p", {
            className: "text-muted-foreground",
            children: [
              "The runtime is contract-first. Commands, queries, events, and capabilities are explicit and versioned under",
              /* @__PURE__ */ jsx2("code", {
                children: " @contractspec/lib.contracts-spec"
              }),
              "."
            ]
          }),
          /* @__PURE__ */ jsx2(CodeBlock2, {
            language: "text",
            code: `Commands
- controlPlane.intent.submit
- controlPlane.plan.compile
- controlPlane.plan.verify
- controlPlane.execution.start
- controlPlane.execution.approve
- controlPlane.execution.reject
- controlPlane.execution.cancel
- controlPlane.skill.install
- controlPlane.skill.disable

Queries
- controlPlane.execution.get
- controlPlane.execution.list
- controlPlane.trace.get
- controlPlane.policy.explain
- controlPlane.skill.list
- controlPlane.skill.verify

Events
- controlPlane.intent.received
- controlPlane.plan.compiled
- controlPlane.plan.rejected
- controlPlane.execution.step.started
- controlPlane.execution.step.blocked
- controlPlane.execution.step.completed
- controlPlane.execution.completed
- controlPlane.execution.failed
- controlPlane.skill.installed
- controlPlane.skill.rejected

Capabilities
- control-plane.core
- control-plane.approval
- control-plane.audit
- control-plane.skill-registry
- control-plane.channel-runtime`
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "Policy and safety posture"
          }),
          /* @__PURE__ */ jsxs2("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsx2("li", {
                children: "No side-effect action executes unless it comes from a compiled plan."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "High-risk actions are blocked from autonomous mode in v1."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Approval commands provide explicit human-in-the-loop transitions."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Skill installation is modeled as governance-controlled operations."
              }),
              /* @__PURE__ */ jsx2("li", {
                children: "Trace queries expose policy rationale and step outcomes for replay."
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "Implementation map"
          }),
          /* @__PURE__ */ jsx2(CodeBlock2, {
            language: "text",
            code: `packages/libs/contracts-spec/src/control-plane/
  commands/
  queries/
  events/
  capabilities/
  contracts.ts
  contracts.test.ts

packages/apps/web-landing/src/app/docs/architecture/control-plane/page.tsx
implementation_plan_controle_plane.md`
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx2("h2", {
            className: "text-2xl font-bold",
            children: "What comes next"
          }),
          /* @__PURE__ */ jsx2("p", {
            className: "text-muted-foreground",
            children: "WS1 delivers the contract fabric. Next increments add planner/executor split, policy escalation, capability-bound authorization, signed skill compatibility checks, and full replay tooling."
          })
        ]
      }),
      /* @__PURE__ */ jsxs2("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx2(Link2, {
            href: "/docs/architecture/integration-binding",
            className: "btn-ghost",
            children: "Previous: Integration Binding"
          }),
          /* @__PURE__ */ jsxs2(Link2, {
            href: "/docs/safety/auditing",
            className: "btn-primary",
            children: [
              "Audit Logs ",
              /* @__PURE__ */ jsx2(ChevronRight2, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}

// src/components/docs/architecture/ArchitectureIntegrationBindingPage.tsx
import { CodeBlock as CodeBlock3 } from "@contractspec/lib.design-system";
import Link3 from "@contractspec/lib.ui-link";
import { ChevronRight as ChevronRight3 } from "lucide-react";
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
function ArchitectureIntegrationBindingPage() {
  return /* @__PURE__ */ jsxs3("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h1", {
            className: "text-4xl font-bold",
            children: "Integration Binding"
          }),
          /* @__PURE__ */ jsx3("p", {
            className: "text-muted-foreground",
            children: "Integration binding connects your app's capabilities to external service providers. Each tenant can configure their own integration connections while sharing the same app blueprint."
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "How it works"
          }),
          /* @__PURE__ */ jsx3("p", {
            className: "text-muted-foreground",
            children: "Integration binding follows a three-layer model:"
          }),
          /* @__PURE__ */ jsxs3("ol", {
            className: "text-muted-foreground list-inside list-decimal space-y-3",
            children: [
              /* @__PURE__ */ jsxs3("li", {
                children: [
                  /* @__PURE__ */ jsx3("strong", {
                    children: "IntegrationSpec"
                  }),
                  " (global) - Defines what an integration provides"
                ]
              }),
              /* @__PURE__ */ jsxs3("li", {
                children: [
                  /* @__PURE__ */ jsx3("strong", {
                    children: "IntegrationConnection"
                  }),
                  " (per-tenant) - A tenant's configured connection"
                ]
              }),
              /* @__PURE__ */ jsxs3("li", {
                children: [
                  /* @__PURE__ */ jsx3("strong", {
                    children: "AppIntegrationBinding"
                  }),
                  " (per-app) - Maps named slots to concrete tenant connections"
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "Example: Payment processing"
          }),
          /* @__PURE__ */ jsx3("p", {
            className: "text-muted-foreground",
            children: "Let's walk through a complete example of binding Stripe for payments."
          }),
          /* @__PURE__ */ jsxs3("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx3("h3", {
                className: "text-lg font-semibold",
                children: "Step 1: Blueprint declares requirement"
              }),
              /* @__PURE__ */ jsx3(CodeBlock3, {
                language: "typescript",
                code: `// AppBlueprintSpec
{
  meta: { name: "invoice-app", version: '1.0.0', appId: "invoice" },
  integrationSlots: [
    {
      slotId: "payments.primary",
      requiredCategory: "payments",
      allowedModes: ["managed", "byok"],
      requiredCapabilities: [
        { key: "payments.createPaymentIntent", version: '1.0.0' },
        { key: "payments.createRefund", version: '1.0.0' }
      ],
      required: true,
      description: "Primary PSP used for Checkout and Subscription flows"
    }
  ],
  workflows: {
    checkout: { name: "invoice.checkout", version: '1.0.0' }
  },
  branding: {
    appNameKey: "invoice.appName",
    assets: [{ type: "logo", url: "https://cdn.acme.dev/logo.png" }],
    colorTokens: { primary: "colors.brand.primary" }
  }
}`
              })
            ]
          }),
          /* @__PURE__ */ jsxs3("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx3("h3", {
                className: "text-lg font-semibold",
                children: "Step 2: Tenant creates connection"
              }),
              /* @__PURE__ */ jsx3(CodeBlock3, {
                language: "typescript",
                code: `// IntegrationConnection
{
  meta: {
    id: "conn_stripe_acme_prod",
    tenantId: "acme-corp",
    integrationKey: "payments.stripe",
    integrationVersion: 1,
    label: "Stripe Production",
    environment: "production",
    createdAt: "2025-01-15T09:00:00Z",
    updatedAt: "2025-01-15T10:30:00Z"
  },
  ownershipMode: "byok",
  externalAccountId: "acct_123",
  config: {
    accountId: "acct_123",
    webhookUrl: "https://acme.app/webhooks/stripe"
  },
  secretRef: "vault://integrations/acme/conn_stripe_acme_prod",
  status: "active"
}`
              })
            ]
          }),
          /* @__PURE__ */ jsxs3("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx3("h3", {
                className: "text-lg font-semibold",
                children: "Step 3: TenantAppConfig binds connection"
              }),
              /* @__PURE__ */ jsx3(CodeBlock3, {
                language: "typescript",
                code: `// TenantAppConfig
{
  meta: {
    tenantId: "acme-corp",
    blueprintName: "invoice-app",
    blueprintVersion: 1,
    environment: "production",
    version: 4,
    status: "published"
  },
  integrations: [
    {
      slotId: "payments.primary",
      connectionId: "conn_stripe_acme_prod",
      scope: {
        workflows: ["checkout", "subscription-renewal", "refund-process"],
        operations: ["payments.stripe.*"]
      },
      priority: 1
    }
  ],
  branding: {
    appName: { en: "Acme Billing Portal" },
    customDomain: "billing.acme.com",
    assets: [{ type: "logo", url: "https://assets.acme.com/logo.svg" }]
  }
}`
              })
            ]
          }),
          /* @__PURE__ */ jsxs3("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx3("h3", {
                className: "text-lg font-semibold",
                children: "Step 4: Runtime resolves and executes"
              }),
              /* @__PURE__ */ jsx3(CodeBlock3, {
                language: "typescript",
                code: `// ResolvedAppConfig (runtime)
{
  integrations: {
    "payments.createPaymentIntent": {
      provider: { /* IntegrationSpec for Stripe */ },
      connection: { /* IntegrationConnection */ },
      config: { /* Merged configuration */ }
    }
  }
}

// When workflow executes:
const result = await executeCapability(
  "payments.createPaymentIntent",
  { amount: 5000, currency: "usd" },
  resolvedConfig
);
// \u2192 Uses Stripe connection automatically`
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "Multi-integration scenarios"
          }),
          /* @__PURE__ */ jsx3("p", {
            className: "text-muted-foreground",
            children: "A single app can use multiple integrations across different categories:"
          }),
          /* @__PURE__ */ jsx3(CodeBlock3, {
            language: "typescript",
            code: `integrations: [
  {
    slotId: "payments.primary",
    connectionId: "conn_stripe_prod",
    scope: {
      workflows: ["checkout", "subscription-*"]
    }
  },
  {
    slotId: "email.outbound",
    connectionId: "conn_postmark_prod"
  },
  {
    slotId: "email.inbound",
    connectionId: "conn_gmail_support",
    scope: {
      workflows: ["support-ticket-creation"]
    }
  },
  {
    slotId: "knowledge.vector-store",
    connectionId: "conn_qdrant_prod",
    scope: {
      workflows: ["semantic-search", "rag-query"]
    }
  }
]`
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "Sandbox vs Production"
          }),
          /* @__PURE__ */ jsx3("p", {
            className: "text-muted-foreground",
            children: "Tenants typically maintain separate connections for sandbox and production environments:"
          }),
          /* @__PURE__ */ jsx3(CodeBlock3, {
            language: "typescript",
            code: `// Sandbox environment
{
  meta: { environment: "sandbox", status: "preview" },
  integrations: [
    {
      slotId: "payments.primary",
      connectionId: "conn_stripe_acme_test"
    }
  ]
}

// Production environment
{
  meta: { environment: "production", status: "published" },
  integrations: [
    {
      slotId: "payments.primary",
      connectionId: "conn_stripe_acme_prod"
    }
  ]
}`
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "Security & validation"
          }),
          /* @__PURE__ */ jsxs3("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsx3("li", {
                children: "Integration connections are validated before binding - health checks ensure connectivity"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Secrets are never stored in TenantAppConfig - only references to encrypted secrets"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Policy Decision Point (PDP) enforces which workflows can use which integrations"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "All integration calls are audited with full request/response logging"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Rate limiting and quotas are enforced per connection"
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx3("h2", {
            className: "text-2xl font-bold",
            children: "Best practices"
          }),
          /* @__PURE__ */ jsxs3("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsxs3("li", {
                children: [
                  "Use wildcard patterns sparingly in ",
                  /* @__PURE__ */ jsx3("code", {
                    children: "allowedWorkflows"
                  }),
                  " - be explicit about access"
                ]
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Always maintain separate sandbox and production connections"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Monitor integration health checks and set up alerts for failures"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Document the purpose of each integration binding for your team"
              }),
              /* @__PURE__ */ jsx3("li", {
                children: "Test integration changes in sandbox before promoting to production"
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs3("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx3(Link3, {
            href: "/docs/architecture/app-config",
            className: "btn-ghost",
            children: "Previous: App Configuration"
          }),
          /* @__PURE__ */ jsxs3(Link3, {
            href: "/docs/architecture/knowledge-binding",
            className: "btn-primary",
            children: [
              "Knowledge Binding ",
              /* @__PURE__ */ jsx3(ChevronRight3, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}

// src/components/docs/architecture/ArchitectureKnowledgeBindingPage.tsx
import { CodeBlock as CodeBlock4 } from "@contractspec/lib.design-system";
import Link4 from "@contractspec/lib.ui-link";
import { ChevronRight as ChevronRight4 } from "lucide-react";
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
function ArchitectureKnowledgeBindingPage() {
  return /* @__PURE__ */ jsxs4("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h1", {
            className: "text-4xl font-bold",
            children: "Knowledge Binding"
          }),
          /* @__PURE__ */ jsx4("p", {
            className: "text-muted-foreground",
            children: "Knowledge binding connects your app's workflows and agents to structured knowledge spaces. This enables semantic search, RAG (Retrieval-Augmented Generation), and context-aware decision-making."
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "How it works"
          }),
          /* @__PURE__ */ jsx4("p", {
            className: "text-muted-foreground",
            children: "Knowledge binding follows a three-layer model:"
          }),
          /* @__PURE__ */ jsxs4("ol", {
            className: "text-muted-foreground list-inside list-decimal space-y-3",
            children: [
              /* @__PURE__ */ jsxs4("li", {
                children: [
                  /* @__PURE__ */ jsx4("strong", {
                    children: "KnowledgeSpaceSpec"
                  }),
                  " (global) - Defines a logical knowledge domain"
                ]
              }),
              /* @__PURE__ */ jsxs4("li", {
                children: [
                  /* @__PURE__ */ jsx4("strong", {
                    children: "KnowledgeSourceConfig"
                  }),
                  " (per-tenant) - Tenant's data sources feeding spaces"
                ]
              }),
              /* @__PURE__ */ jsxs4("li", {
                children: [
                  /* @__PURE__ */ jsx4("strong", {
                    children: "AppKnowledgeBinding"
                  }),
                  " (per-app) - Maps spaces to workflows/agents"
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "Example: Support agent with RAG"
          }),
          /* @__PURE__ */ jsx4("p", {
            className: "text-muted-foreground",
            children: "Let's build a support agent that uses canonical product documentation and operational support history."
          }),
          /* @__PURE__ */ jsxs4("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx4("h3", {
                className: "text-lg font-semibold",
                children: "Step 1: Blueprint declares knowledge needs"
              }),
              /* @__PURE__ */ jsx4(CodeBlock4, {
                language: "typescript",
                code: `// AppBlueprintSpec
{
  id: "support-app",
  version: "1.0.0",
  knowledgeSpaces: [
    {
      spaceId: "product-canon",
      category: "canonical",
      required: true,
      purpose: "Official product documentation and specs"
    },
    {
      spaceId: "support-history",
      category: "operational",
      required: true,
      purpose: "Past support tickets and resolutions"
    },
    {
      spaceId: "external-docs",
      category: "external",
      required: false,
      purpose: "Third-party integration documentation"
    }
  ]
}`
              })
            ]
          }),
          /* @__PURE__ */ jsxs4("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx4("h3", {
                className: "text-lg font-semibold",
                children: "Step 2: Tenant configures sources"
              }),
              /* @__PURE__ */ jsx4(CodeBlock4, {
                language: "typescript",
                code: `// KnowledgeSourceConfig (per-tenant)
[
  {
    id: "src_notion_product_docs",
    tenantId: "acme-corp",
    spaceId: "product-canon",
    kind: "notion",
    location: "https://notion.so/acme/product-docs",
    syncPolicy: { interval: "1h" },
    lastSyncedAt: "2025-01-15T10:00:00Z"
  },
  {
    id: "src_gmail_support_threads",
    tenantId: "acme-corp",
    spaceId: "support-history",
    kind: "gmail",
    location: "support@acme.com",
    syncPolicy: { webhook: true },
    lastSyncedAt: "2025-01-15T10:30:00Z"
  },
  {
    id: "src_stripe_docs",
    tenantId: "acme-corp",
    spaceId: "external-docs",
    kind: "url",
    location: "https://stripe.com/docs",
    syncPolicy: { interval: "24h" },
    lastSyncedAt: "2025-01-15T00:00:00Z"
  }
]`
              })
            ]
          }),
          /* @__PURE__ */ jsxs4("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx4("h3", {
                className: "text-lg font-semibold",
                children: "Step 3: TenantAppConfig binds spaces"
              }),
              /* @__PURE__ */ jsx4(CodeBlock4, {
                language: "typescript",
                code: `// TenantAppConfig
{
  tenantId: "acme-corp",
  blueprintId: "support-app",
  blueprintVersion: "1.0.0",
  knowledgeBindings: [
    {
      spaceId: "product-canon",
      enabled: true,
      allowedConsumers: {
        workflowIds: ["answer-question", "generate-docs"],
        agentIds: ["support-agent", "docs-agent"]
      },
      allowedCategories: ["canonical"],
      sources: ["src_notion_product_docs"]
    },
    {
      spaceId: "support-history",
      enabled: true,
      allowedConsumers: {
        workflowIds: ["answer-question", "escalate-ticket"],
        agentIds: ["support-agent"]
      },
      allowedCategories: ["operational"],
      sources: ["src_gmail_support_threads"]
    },
    {
      spaceId: "external-docs",
      enabled: true,
      allowedConsumers: {
        agentIds: ["support-agent"]
      },
      allowedCategories: ["external"],
      sources: ["src_stripe_docs"]
    }
  ]
}`
              })
            ]
          }),
          /* @__PURE__ */ jsxs4("div", {
            className: "space-y-3",
            children: [
              /* @__PURE__ */ jsx4("h3", {
                className: "text-lg font-semibold",
                children: "Step 4: Workflow uses knowledge"
              }),
              /* @__PURE__ */ jsx4(CodeBlock4, {
                language: "yaml",
                code: `// WorkflowSpec
workflowId: answer-question
version: '1.0.0'.0.0

steps:
  - id: generate-embedding
    capability: openai-embeddings
    inputs:
      text: \${input.question}
  
  - id: search-canonical
    capability: vector.search
    inputs:
      collection: "product-canon"
      vector: \${steps.generate-embedding.output.embedding}
      limit: 5
  
  - id: search-support-history
    capability: vector.search
    inputs:
      collection: "support-history"
      vector: \${steps.generate-embedding.output.embedding}
      limit: 3
  
  - id: generate-answer
    capability: openai-chat
    inputs:
      messages:
        - role: "system"
          content: |
            You are a support agent. Answer based on:
            1. Canonical docs (authoritative)
            2. Support history (helpful context)
            Only use external docs for integration questions.
        - role: "user"
          content: |
            Question: \${input.question}
            
            Canonical docs:
            \${steps.search-canonical.output.results}
            
            Support history:
            \${steps.search-support-history.output.results}`
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "Category-based access control"
          }),
          /* @__PURE__ */ jsx4("p", {
            className: "text-muted-foreground",
            children: "Different knowledge categories have different trust levels and access patterns:"
          }),
          /* @__PURE__ */ jsx4("div", {
            className: "border-border/50 overflow-x-auto rounded-lg border",
            children: /* @__PURE__ */ jsxs4("table", {
              className: "w-full text-left text-sm",
              children: [
                /* @__PURE__ */ jsx4("thead", {
                  className: "bg-card/50",
                  children: /* @__PURE__ */ jsxs4("tr", {
                    className: "border-border/50 border-b",
                    children: [
                      /* @__PURE__ */ jsx4("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Category"
                      }),
                      /* @__PURE__ */ jsx4("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Trust Level"
                      }),
                      /* @__PURE__ */ jsx4("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Use Cases"
                      }),
                      /* @__PURE__ */ jsx4("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Policy Impact"
                      })
                    ]
                  })
                }),
                /* @__PURE__ */ jsxs4("tbody", {
                  className: "divide-border/50 divide-y",
                  children: [
                    /* @__PURE__ */ jsxs4("tr", {
                      children: [
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3 font-mono text-xs",
                          children: "canonical"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Highest"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Product specs, schemas, official policies"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Can drive policy decisions"
                        })
                      ]
                    }),
                    /* @__PURE__ */ jsxs4("tr", {
                      children: [
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3 font-mono text-xs",
                          children: "operational"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "High"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Support tickets, sales docs, internal runbooks"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Can inform decisions"
                        })
                      ]
                    }),
                    /* @__PURE__ */ jsxs4("tr", {
                      children: [
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3 font-mono text-xs",
                          children: "external"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Medium"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Third-party docs, regulations, PSP guides"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Reference only, not authoritative"
                        })
                      ]
                    }),
                    /* @__PURE__ */ jsxs4("tr", {
                      children: [
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3 font-mono text-xs",
                          children: "ephemeral"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Low"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Agent scratchpads, session context, drafts"
                        }),
                        /* @__PURE__ */ jsx4("td", {
                          className: "px-4 py-3",
                          children: "Never used for decisions"
                        })
                      ]
                    })
                  ]
                })
              ]
            })
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "Multi-space workflows"
          }),
          /* @__PURE__ */ jsx4("p", {
            className: "text-muted-foreground",
            children: "Workflows can query multiple knowledge spaces and combine results:"
          }),
          /* @__PURE__ */ jsx4(CodeBlock4, {
            language: "typescript",
            code: `knowledgeBindings: [
  {
    spaceId: "product-canon",
    enabled: true,
    allowedConsumers: {
      workflowIds: ["invoice-generation", "quote-creation"]
    },
    allowedCategories: ["canonical"],
    sources: ["src_database_schema", "src_product_catalog"]
  },
  {
    spaceId: "pricing-rules",
    enabled: true,
    allowedConsumers: {
      workflowIds: ["invoice-generation", "quote-creation"]
    },
    allowedCategories: ["canonical", "operational"],
    sources: ["src_pricing_database", "src_discount_policies"]
  },
  {
    spaceId: "customer-history",
    enabled: true,
    allowedConsumers: {
      workflowIds: ["quote-creation"]
    },
    allowedCategories: ["operational"],
    sources: ["src_crm_data", "src_past_invoices"]
  }
]`
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "Security & validation"
          }),
          /* @__PURE__ */ jsxs4("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsx4("li", {
                children: "Knowledge sources are validated before sync - credentials and permissions checked"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "PDP enforces which workflows/agents can access which spaces"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "All knowledge queries are audited with search terms and results"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Canonical knowledge is immutable once indexed - changes require re-sync"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Ephemeral knowledge is automatically purged based on retention policies"
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx4("h2", {
            className: "text-2xl font-bold",
            children: "Best practices"
          }),
          /* @__PURE__ */ jsxs4("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsx4("li", {
                children: "Use canonical spaces for policy-critical decisions, operational for suggestions"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Never allow workflows to write to canonical spaces - maintain read-only access"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Set up monitoring for sync failures and stale knowledge sources"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Document the purpose and trust level of each knowledge space"
              }),
              /* @__PURE__ */ jsx4("li", {
                children: "Test knowledge queries in sandbox before promoting to production"
              }),
              /* @__PURE__ */ jsxs4("li", {
                children: [
                  "Use explicit ",
                  /* @__PURE__ */ jsx4("code", {
                    children: "allowedConsumers"
                  }),
                  " - avoid wildcard access"
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs4("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx4(Link4, {
            href: "/docs/architecture/integration-binding",
            className: "btn-ghost",
            children: "Previous: Integration Binding"
          }),
          /* @__PURE__ */ jsxs4(Link4, {
            href: "/docs/knowledge",
            className: "btn-primary",
            children: [
              "Knowledge & Context ",
              /* @__PURE__ */ jsx4(ChevronRight4, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}

// src/components/docs/architecture/ArchitectureMultiTenancyPage.tsx
import { CodeBlock as CodeBlock5 } from "@contractspec/lib.design-system";
import Link5 from "@contractspec/lib.ui-link";
import { ChevronRight as ChevronRight5 } from "lucide-react";
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
function ArchitectureMultiTenancyPage() {
  return /* @__PURE__ */ jsxs5("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs5("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx5("h1", {
            className: "text-4xl font-bold",
            children: "Multi-Tenancy"
          }),
          /* @__PURE__ */ jsx5("p", {
            className: "text-muted-foreground",
            children: "ContractSpec is designed from the ground up for multi-tenancy. Apps built with ContractSpec can serve multiple organizations (tenants) from a single deployment, while ensuring strict data isolation and configuration separation."
          })
        ]
      }),
      /* @__PURE__ */ jsxs5("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx5("h2", {
            className: "text-2xl font-bold",
            children: "Core Concepts"
          }),
          /* @__PURE__ */ jsxs5("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  /* @__PURE__ */ jsx5("strong", {
                    children: "Tenant"
                  }),
                  ": An organization or customer that uses your app. Each tenant has a unique ",
                  /* @__PURE__ */ jsx5("code", {
                    children: "tenantId"
                  }),
                  "."
                ]
              }),
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  /* @__PURE__ */ jsx5("strong", {
                    children: "Tenant Isolation"
                  }),
                  ": Data and configuration for one tenant is never accessible to another tenant unless explicitly shared."
                ]
              }),
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  /* @__PURE__ */ jsx5("strong", {
                    children: "Tenant Context"
                  }),
                  ": Every request and operation runs within the context of a specific tenant."
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs5("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx5("h2", {
            className: "text-2xl font-bold",
            children: "Tenant Resolution"
          }),
          /* @__PURE__ */ jsx5("p", {
            className: "text-muted-foreground",
            children: "The runtime automatically resolves the tenant context for every request based on:"
          }),
          /* @__PURE__ */ jsxs5("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  "Subdomain (e.g., ",
                  /* @__PURE__ */ jsx5("code", {
                    children: "acme.app.com"
                  }),
                  ")"
                ]
              }),
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  "Custom Domain (e.g., ",
                  /* @__PURE__ */ jsx5("code", {
                    children: "portal.acme.com"
                  }),
                  ")"
                ]
              }),
              /* @__PURE__ */ jsxs5("li", {
                children: [
                  "Header (e.g., ",
                  /* @__PURE__ */ jsx5("code", {
                    children: "x-tenant-id: acme-corp"
                  }),
                  ")"
                ]
              }),
              /* @__PURE__ */ jsx5("li", {
                children: "Authentication Token (embedded tenant claim)"
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs5("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx5("h2", {
            className: "text-2xl font-bold",
            children: "Configuration Isolation"
          }),
          /* @__PURE__ */ jsxs5("p", {
            className: "text-muted-foreground",
            children: [
              "Each tenant has its own ",
              /* @__PURE__ */ jsx5("code", {
                children: "TenantAppConfig"
              }),
              " which defines:"
            ]
          }),
          /* @__PURE__ */ jsx5(CodeBlock5, {
            language: "typescript",
            code: `type TenantAppConfig = {
  tenantId: string;
  blueprintId: string;
  // ...
  integrationBindings: AppIntegrationBinding[];
  knowledgeBindings: AppKnowledgeBinding[];
  featureFlags: Record<string, boolean>;
};`
          }),
          /* @__PURE__ */ jsx5("p", {
            className: "text-muted-foreground mt-2",
            children: "This allows you to customize feature flags, integration connections, and knowledge sources per tenant without changing the application code."
          })
        ]
      }),
      /* @__PURE__ */ jsxs5("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx5(Link5, {
            href: "/docs/architecture",
            className: "btn-ghost",
            children: "Back to Architecture"
          }),
          /* @__PURE__ */ jsxs5(Link5, {
            href: "/docs/libraries/multi-tenancy",
            className: "btn-primary",
            children: [
              "Multi-Tenancy Library ",
              /* @__PURE__ */ jsx5(ChevronRight5, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}

// src/components/docs/architecture/ArchitectureOverviewPage.tsx
import Link6 from "@contractspec/lib.ui-link";
import { ChevronRight as ChevronRight6 } from "lucide-react";
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
function ArchitectureOverviewPage() {
  return /* @__PURE__ */ jsxs6("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs6("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx6("h1", {
            className: "text-4xl font-bold",
            children: "Architecture"
          }),
          /* @__PURE__ */ jsx6("p", {
            className: "text-muted-foreground",
            children: "ContractSpec's architecture is built on a foundation of typed specifications served by runtime adapters. This section covers the core architectural concepts: app configuration, integration binding, control-plane governance, and knowledge management."
          })
        ]
      }),
      /* @__PURE__ */ jsxs6("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx6("h2", {
            className: "text-2xl font-bold",
            children: "Core layers"
          }),
          /* @__PURE__ */ jsxs6("div", {
            className: "space-y-6",
            children: [
              /* @__PURE__ */ jsxs6("div", {
                className: "space-y-3",
                children: [
                  /* @__PURE__ */ jsx6("h3", {
                    className: "text-xl font-semibold",
                    children: "1. Specification Layer"
                  }),
                  /* @__PURE__ */ jsx6("p", {
                    className: "text-muted-foreground",
                    children: "The foundation of ContractSpec. Typed specifications define what your application can do:"
                  }),
                  /* @__PURE__ */ jsxs6("ul", {
                    className: "text-muted-foreground ml-4 list-inside list-disc space-y-2",
                    children: [
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/specs/capabilities",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "CapabilitySpec"
                          }),
                          " ",
                          "- Operations and their inputs/outputs"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/specs/dataviews",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "DataViewSpec"
                          }),
                          " ",
                          "- Data queries and presentation"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/specs/workflows",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "WorkflowSpec"
                          }),
                          " ",
                          "- Multi-step processes"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/specs/policy",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "PolicySpec"
                          }),
                          " ",
                          "- Access control and data protection"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/integrations/spec-model",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "IntegrationSpec"
                          }),
                          " ",
                          "- External service providers"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/knowledge/spaces",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "KnowledgeSpaceSpec"
                          }),
                          " ",
                          "- Knowledge and context management"
                        ]
                      })
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs6("div", {
                className: "space-y-3",
                children: [
                  /* @__PURE__ */ jsx6("h3", {
                    className: "text-xl font-semibold",
                    children: "2. Configuration Layer"
                  }),
                  /* @__PURE__ */ jsx6("p", {
                    className: "text-muted-foreground",
                    children: "How applications are configured and customized:"
                  }),
                  /* @__PURE__ */ jsxs6("ul", {
                    className: "text-muted-foreground ml-4 list-inside list-disc space-y-2",
                    children: [
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/architecture/app-config",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "AppBlueprintSpec"
                          }),
                          " ",
                          "- Global, versioned app definition"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/architecture/app-config",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "TenantAppConfig"
                          }),
                          " ",
                          "- Per-tenant, per-environment configuration"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/architecture/integration-binding",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "AppIntegrationBinding"
                          }),
                          " ",
                          "- How apps use integrations"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/architecture/knowledge-binding",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "AppKnowledgeBinding"
                          }),
                          " ",
                          "- How apps access knowledge"
                        ]
                      })
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs6("div", {
                className: "space-y-3",
                children: [
                  /* @__PURE__ */ jsx6("h3", {
                    className: "text-xl font-semibold",
                    children: "3. Runtime Layer"
                  }),
                  /* @__PURE__ */ jsx6("p", {
                    className: "text-muted-foreground",
                    children: "How specifications are executed at runtime:"
                  }),
                  /* @__PURE__ */ jsxs6("ul", {
                    className: "text-muted-foreground ml-4 list-inside list-disc space-y-2",
                    children: [
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6("strong", {
                            children: "ResolvedAppConfig"
                          }),
                          " - Merged blueprint + tenant config"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6("strong", {
                            children: "Policy Decision Point (PDP)"
                          }),
                          " - Enforces policies on every operation"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6(Link6, {
                            href: "/docs/architecture/control-plane",
                            className: "text-violet-400 hover:text-violet-300",
                            children: "Control Plane Runtime"
                          }),
                          " ",
                          "- Deterministic intent to plan to policy to execution loop"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6("strong", {
                            children: "Presentation Runtime"
                          }),
                          " - React and React Native renderers"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6("strong", {
                            children: "Integration Connectors"
                          }),
                          " - Execute external API calls"
                        ]
                      }),
                      /* @__PURE__ */ jsxs6("li", {
                        children: [
                          /* @__PURE__ */ jsx6("strong", {
                            children: "Knowledge Retrieval"
                          }),
                          " - Query vector databases and knowledge sources"
                        ]
                      })
                    ]
                  })
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs6("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx6("h2", {
            className: "text-2xl font-bold",
            children: "Configuration model"
          }),
          /* @__PURE__ */ jsx6("p", {
            className: "text-muted-foreground",
            children: "ContractSpec uses a three-tier configuration model:"
          }),
          /* @__PURE__ */ jsx6("div", {
            className: "border-border/50 overflow-x-auto rounded-lg border",
            children: /* @__PURE__ */ jsxs6("table", {
              className: "w-full text-left text-sm",
              children: [
                /* @__PURE__ */ jsx6("thead", {
                  className: "bg-card/50",
                  children: /* @__PURE__ */ jsxs6("tr", {
                    className: "border-border/50 border-b",
                    children: [
                      /* @__PURE__ */ jsx6("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Layer"
                      }),
                      /* @__PURE__ */ jsx6("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Type"
                      }),
                      /* @__PURE__ */ jsx6("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Scope"
                      }),
                      /* @__PURE__ */ jsx6("th", {
                        className: "px-4 py-3 font-semibold",
                        children: "Storage"
                      })
                    ]
                  })
                }),
                /* @__PURE__ */ jsxs6("tbody", {
                  className: "divide-border/50 divide-y",
                  children: [
                    /* @__PURE__ */ jsxs6("tr", {
                      children: [
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: /* @__PURE__ */ jsx6("strong", {
                            children: "Blueprint"
                          })
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top font-mono text-xs",
                          children: "AppBlueprintSpec"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "Global, versioned, no tenant info"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "Version control, immutable"
                        })
                      ]
                    }),
                    /* @__PURE__ */ jsxs6("tr", {
                      children: [
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: /* @__PURE__ */ jsx6("strong", {
                            children: "Tenant Config"
                          })
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top font-mono text-xs",
                          children: "TenantAppConfig"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "Per-tenant, per-environment"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "Database, mutable"
                        })
                      ]
                    }),
                    /* @__PURE__ */ jsxs6("tr", {
                      children: [
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: /* @__PURE__ */ jsx6("strong", {
                            children: "Resolved Config"
                          })
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top font-mono text-xs",
                          children: "ResolvedAppConfig"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "Runtime, ephemeral"
                        }),
                        /* @__PURE__ */ jsx6("td", {
                          className: "px-4 py-3 align-top",
                          children: "In-memory, not persisted"
                        })
                      ]
                    })
                  ]
                })
              ]
            })
          })
        ]
      }),
      /* @__PURE__ */ jsxs6("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx6("h2", {
            className: "text-2xl font-bold",
            children: "Key architectural principles"
          }),
          /* @__PURE__ */ jsxs6("ul", {
            className: "text-muted-foreground list-inside list-disc space-y-2",
            children: [
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Spec-first"
                  }),
                  " - Everything is defined declaratively before code generation"
                ]
              }),
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Type-safe"
                  }),
                  " - All specifications are strongly typed and validated at compile time"
                ]
              }),
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Policy-enforced"
                  }),
                  " - Every operation passes through the PDP"
                ]
              }),
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Multi-tenant by default"
                  }),
                  " - Tenant isolation is built-in, not bolted on"
                ]
              }),
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Environment-aware"
                  }),
                  " - Separate configurations for sandbox, staging, production"
                ]
              }),
              /* @__PURE__ */ jsxs6("li", {
                children: [
                  /* @__PURE__ */ jsx6("strong", {
                    children: "Auditable"
                  }),
                  " - All operations are logged for compliance and debugging"
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs6("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsxs6(Link6, {
            href: "/docs/architecture/app-config",
            className: "btn-primary",
            children: [
              "App Configuration ",
              /* @__PURE__ */ jsx6(ChevronRight6, {
                size: 16
              })
            ]
          }),
          /* @__PURE__ */ jsx6(Link6, {
            href: "/docs/architecture/control-plane",
            className: "btn-ghost",
            children: "Control Plane Runtime"
          }),
          /* @__PURE__ */ jsx6(Link6, {
            href: "/docs/integrations",
            className: "btn-ghost",
            children: "Integrations"
          }),
          /* @__PURE__ */ jsx6(Link6, {
            href: "/docs/knowledge",
            className: "btn-ghost",
            children: "Knowledge & Context"
          })
        ]
      })
    ]
  });
}
export {
  ArchitectureOverviewPage,
  ArchitectureMultiTenancyPage,
  ArchitectureKnowledgeBindingPage,
  ArchitectureIntegrationBindingPage,
  ArchitectureControlPlanePage,
  ArchitectureAppConfigPage
};
