import z from"@contractspec/lib.ui-link";import{ChevronRight as A}from"lucide-react";import{jsx as q,jsxs as y}from"react/jsx-runtime";function E(){return y("div",{className:"space-y-8",children:[y("div",{className:"space-y-4",children:[q("h1",{className:"font-bold text-4xl",children:"Knowledge Spaces"}),y("p",{className:"text-muted-foreground",children:["A ",q("strong",{children:"KnowledgeSpaceSpec"})," defines a logical domain of knowledge with a specific category, storage strategy, and intended audience. Spaces are defined globally and populated per-tenant through knowledge sources."]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"KnowledgeSpaceSpec"}),q("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:q("pre",{children:`type KnowledgeSpaceSpec = {
  id: string;
  label: string;
  description: string;
  
  // Trust and access
  category: KnowledgeCategory;
  intendedAudience: "agents" | "humans" | "admin-only";
  
  // Storage and indexing
  storageStrategy: "vector" | "search" | "hybrid";
  indexProvider: string;  // e.g., "qdrant", "elasticsearch"
  vectorDimensions?: number;  // For vector storage
  
  // Lifecycle
  retentionPolicy: {
    days?: number;
    versions?: number;
  };
  
  // Metadata
  tags?: string[];
  owner?: string;
  createdAt: string;
  updatedAt: string;
};`})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Common knowledge spaces"}),y("div",{className:"space-y-6",children:[y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Product Canon"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  id: "product-canon",
  label: "Product Canon",
  description: "Official product specifications and schemas",
  category: "canonical",
  intendedAudience: "agents",
  storageStrategy: "hybrid",
  indexProvider: "qdrant",
  vectorDimensions: 1536,
  retentionPolicy: { versions: 10 }
}`})}),y("p",{className:"mt-2 text-muted-foreground text-sm",children:[q("strong",{children:"Use cases:"})," Invoice generation, quote creation, product recommendations, schema validation"]})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Support History"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  id: "support-history",
  label: "Support History",
  description: "Past support tickets and resolutions",
  category: "operational",
  intendedAudience: "agents",
  storageStrategy: "vector",
  indexProvider: "qdrant",
  vectorDimensions: 1536,
  retentionPolicy: { days: 365 }
}`})}),y("p",{className:"mt-2 text-muted-foreground text-sm",children:[q("strong",{children:"Use cases:"})," Customer support, troubleshooting, similar issue detection"]})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"External Provider Docs"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  id: "provider-docs",
  label: "External Provider Docs",
  description: "Third-party integration documentation",
  category: "external",
  intendedAudience: "agents",
  storageStrategy: "search",
  indexProvider: "elasticsearch",
  retentionPolicy: { days: 90 }
}`})}),y("p",{className:"mt-2 text-muted-foreground text-sm",children:[q("strong",{children:"Use cases:"})," Integration help, API reference, troubleshooting external services"]})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Agent Scratchpad"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  id: "agent-scratchpad",
  label: "Agent Scratchpad",
  description: "Temporary agent working memory",
  category: "ephemeral",
  intendedAudience: "agents",
  storageStrategy: "vector",
  indexProvider: "qdrant",
  vectorDimensions: 1536,
  retentionPolicy: { days: 1 }
}`})}),y("p",{className:"mt-2 text-muted-foreground text-sm",children:[q("strong",{children:"Use cases:"})," Conversation continuity, intermediate calculations, session state"]})]})]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Storage strategies"}),q("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:y("table",{className:"w-full text-left text-sm",children:[q("thead",{className:"bg-card/50",children:y("tr",{className:"border-border/50 border-b",children:[q("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),q("th",{className:"px-4 py-3 font-semibold",children:"Best For"}),q("th",{className:"px-4 py-3 font-semibold",children:"Providers"})]})}),y("tbody",{className:"divide-y divide-border/50",children:[y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"vector"}),q("td",{className:"px-4 py-3",children:"Semantic search, RAG, similarity matching"}),q("td",{className:"px-4 py-3",children:"Qdrant, Pinecone, Weaviate"})]}),y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"search"}),q("td",{className:"px-4 py-3",children:"Keyword search, exact matching, filtering"}),q("td",{className:"px-4 py-3",children:"Elasticsearch, Algolia"})]}),y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"hybrid"}),q("td",{className:"px-4 py-3",children:"Combined semantic + keyword search"}),q("td",{className:"px-4 py-3",children:"Qdrant + Elasticsearch"})]})]})]})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Best practices"}),y("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[q("li",{children:"Choose storage strategy based on query patterns - use vector for semantic, search for exact"}),q("li",{children:"Set appropriate retention policies - canonical is permanent, ephemeral is short-lived"}),q("li",{children:"Use consistent vector dimensions across spaces that will be queried together"}),q("li",{children:"Document the intended audience and use cases for each space"}),q("li",{children:"Monitor space size and query performance - add sharding if needed"})]})]}),y("div",{className:"flex items-center gap-4 pt-4",children:[q(z,{href:"/docs/knowledge/categories",className:"btn-ghost",children:"Previous: Categories"}),y(z,{href:"/docs/knowledge/sources",className:"btn-primary",children:["Knowledge Sources ",q(A,{size:16})]})]})]})}export{E as KnowledgeSpacesPage};
