@contractspec/bundle.library 3.10.0 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.turbo/turbo-build.log +212 -206
  2. package/CHANGELOG.md +43 -0
  3. package/dist/components/docs/DocsIndexPage.js +2 -2
  4. package/dist/components/docs/docsManifest.js +1 -1
  5. package/dist/components/docs/guides/GuideProviderBackedKnowledgePage.d.ts +1 -0
  6. package/dist/components/docs/guides/GuideProviderBackedKnowledgePage.js +73 -0
  7. package/dist/components/docs/guides/GuidesIndexPage.js +1 -1
  8. package/dist/components/docs/guides/guides.docblocks.js +10 -1
  9. package/dist/components/docs/guides/index.d.ts +1 -0
  10. package/dist/components/docs/guides/index.js +132 -52
  11. package/dist/components/docs/index.js +414 -284
  12. package/dist/components/docs/integrations/IntegrationsGmailPage.js +3 -3
  13. package/dist/components/docs/integrations/IntegrationsGoogleCalendarPage.js +1 -1
  14. package/dist/components/docs/integrations/IntegrationsGoogleDrivePage.d.ts +1 -0
  15. package/dist/components/docs/integrations/IntegrationsGoogleDrivePage.js +22 -0
  16. package/dist/components/docs/integrations/IntegrationsOverviewPage.js +1 -1
  17. package/dist/components/docs/integrations/index.d.ts +1 -0
  18. package/dist/components/docs/integrations/index.js +65 -45
  19. package/dist/components/docs/knowledge/KnowledgeGovernancePage.d.ts +1 -0
  20. package/dist/components/docs/knowledge/KnowledgeGovernancePage.js +23 -0
  21. package/dist/components/docs/knowledge/KnowledgeOverviewPage.js +1 -1
  22. package/dist/components/docs/knowledge/KnowledgeSourcesPage.js +11 -2
  23. package/dist/components/docs/knowledge/index.d.ts +1 -0
  24. package/dist/components/docs/knowledge/index.js +49 -19
  25. package/dist/index.js +430 -300
  26. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  27. package/dist/node/components/docs/docsManifest.js +1 -1
  28. package/dist/node/components/docs/guides/GuideProviderBackedKnowledgePage.js +72 -0
  29. package/dist/node/components/docs/guides/GuidesIndexPage.js +1 -1
  30. package/dist/node/components/docs/guides/guides.docblocks.js +10 -1
  31. package/dist/node/components/docs/guides/index.js +132 -52
  32. package/dist/node/components/docs/index.js +414 -284
  33. package/dist/node/components/docs/integrations/IntegrationsGmailPage.js +3 -3
  34. package/dist/node/components/docs/integrations/IntegrationsGoogleCalendarPage.js +1 -1
  35. package/dist/node/components/docs/integrations/IntegrationsGoogleDrivePage.js +21 -0
  36. package/dist/node/components/docs/integrations/IntegrationsOverviewPage.js +1 -1
  37. package/dist/node/components/docs/integrations/index.js +65 -45
  38. package/dist/node/components/docs/knowledge/KnowledgeGovernancePage.js +22 -0
  39. package/dist/node/components/docs/knowledge/KnowledgeOverviewPage.js +1 -1
  40. package/dist/node/components/docs/knowledge/KnowledgeSourcesPage.js +11 -2
  41. package/dist/node/components/docs/knowledge/index.js +49 -19
  42. package/dist/node/index.js +430 -300
  43. package/package.json +59 -23
  44. package/src/components/docs/docsManifest.ts +62 -0
  45. package/src/components/docs/generated/docs-index._common.json +32 -0
  46. package/src/components/docs/generated/docs-index.manifest.json +2 -2
  47. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  48. package/src/components/docs/guides/GuideProviderBackedKnowledgePage.tsx +191 -0
  49. package/src/components/docs/guides/GuidesIndexPage.tsx +7 -0
  50. package/src/components/docs/guides/guides.docblocks.ts +20 -0
  51. package/src/components/docs/guides/index.ts +1 -0
  52. package/src/components/docs/integrations/IntegrationsGmailPage.tsx +23 -2
  53. package/src/components/docs/integrations/IntegrationsGoogleCalendarPage.tsx +2 -2
  54. package/src/components/docs/integrations/IntegrationsGoogleDrivePage.tsx +88 -0
  55. package/src/components/docs/integrations/IntegrationsOverviewPage.tsx +1 -0
  56. package/src/components/docs/integrations/index.ts +1 -0
  57. package/src/components/docs/knowledge/KnowledgeGovernancePage.tsx +94 -0
  58. package/src/components/docs/knowledge/KnowledgeOverviewPage.tsx +10 -0
  59. package/src/components/docs/knowledge/KnowledgeSourcesPage.tsx +45 -0
  60. package/src/components/docs/knowledge/index.ts +1 -0
@@ -0,0 +1,22 @@
1
+ var d=Object.defineProperty;var s=(t)=>t;function c(t,o){this[t]=s.bind(null,o)}var p=(t,o)=>{for(var n in o)d(t,n,{get:o[n],enumerable:!0,configurable:!0,set:c.bind(o,n)})};var m=(t,o)=>()=>(t&&(o=t(t=0)),o);import{CodeBlock as r}from"@contractspec/lib.design-system";import i from"@contractspec/lib.ui-link";import{ChevronRight as l}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function h(){return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Knowledge mutation governance"}),e("p",{className:"text-muted-foreground",children:"Provider-backed knowledge is not read-only forever. Email sends, Drive permission changes, tombstone handling, replay repairs, and source metadata updates all need explicit governance before they mutate an external system."})]}),a("div",{className:"grid gap-4 md:grid-cols-2",children:[a("div",{className:"card-subtle space-y-2 p-4",children:[e("h2",{className:"font-semibold text-lg",children:"Fail closed"}),e("p",{className:"text-muted-foreground text-sm",children:"Non-dry-run mutations require an idempotency key and audit evidence. Approval-required operations need approval refs. Outbound sends also need an approved send gate."})]}),a("div",{className:"card-subtle space-y-2 p-4",children:[e("h2",{className:"font-semibold text-lg",children:"Leave evidence"}),e("p",{className:"text-muted-foreground text-sm",children:"Every evaluation returns an audit envelope with status, missing evidence, idempotency, approval refs, and the decision timestamp."})]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Runtime gate"}),e(r,{language:"typescript",filename:"knowledge-governance.ts",code:`const result = await executeGovernedKnowledgeMutation(
2
+ {
3
+ operation: "drive.permission.update",
4
+ sourceId: "src_drive_support",
5
+ requiresApproval: true,
6
+ governance: {
7
+ idempotencyKey: "tenant:drive-permission:123",
8
+ auditEvidence: { evidenceRef: "audit://drive/permission/123" },
9
+ approvalRefs: [{ id: "approval-123" }],
10
+ },
11
+ },
12
+ () => drive.updatePermission(input),
13
+ { audit: (envelope) => auditTrail.write(envelope) },
14
+ );
15
+
16
+ if (result.status === "blocked") {
17
+ return result.auditEnvelope.requiredEvidence;
18
+ }`})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"ContractSpec surface"}),a("p",{className:"text-muted-foreground",children:["Use ",e("code",{children:"knowledge.mutation.evaluateGovernance"})," when an app or control-plane workflow needs to expose mutation decisions as a contracted action. It mirrors the runtime helper and gives Connect, ops tools, and review packets one stable contract to reference."]}),e(r,{language:"typescript",filename:"knowledge-operation.ts",code:`import {
19
+ EvaluateKnowledgeMutationGovernance,
20
+ } from "@contractspec/lib.contracts-spec/knowledge/operations";
21
+
22
+ registry.register(EvaluateKnowledgeMutationGovernance);`})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(i,{href:"/docs/knowledge/sources",className:"btn-ghost",children:"Knowledge sources"}),a(i,{href:"/docs/guides/provider-backed-knowledge",className:"btn-primary",children:["Adoption guide ",e(l,{size:16})]})]})]})}export{h as KnowledgeGovernancePage};
@@ -1 +1 @@
1
- var i=Object.defineProperty;var l=(e)=>e;function s(e,a){this[e]=l.bind(null,a)}var c=(e,a)=>{for(var n in a)i(e,n,{get:a[n],enumerable:!0,configurable:!0,set:s.bind(a,n)})};var p=(e,a)=>()=>(e&&(a=e(e=0)),a);import r from"@contractspec/lib.ui-link";import{jsx as t,jsxs as o}from"react/jsx-runtime";var d=[{title:"Categories",body:"Separate canonical truth from operational notes, external material, and ephemeral working context.",href:"/docs/knowledge/categories"},{title:"Spaces",body:"Define the storage and retrieval boundary for each knowledge domain.",href:"/docs/knowledge/spaces"},{title:"Sources",body:"Connect tenant-owned sources explicitly instead of letting context leak in through prompts alone.",href:"/docs/knowledge/sources"},{title:"Examples",body:"See how support, compliance, and product systems consume trusted knowledge at runtime.",href:"/docs/knowledge/examples"}];function g(){return o("div",{className:"space-y-10",children:[o("div",{className:"space-y-3",children:[t("p",{className:"editorial-kicker",children:"Operate"}),t("h1",{className:"font-serif text-4xl tracking-[-0.04em] md:text-5xl",children:"Knowledge is part of the runtime, not a sidecar prompt hack."}),t("p",{className:"max-w-3xl text-lg text-muted-foreground leading-8",children:"When AI-native systems depend on external context, the context needs the same discipline as the rest of the stack. ContractSpec treats knowledge as typed, bounded, and governable so teams can reason about trust, isolation, and retrieval behavior."})]}),t("section",{className:"editorial-panel space-y-5",children:o("div",{className:"space-y-2",children:[t("h2",{className:"font-serif text-3xl tracking-[-0.03em]",children:"How knowledge enters the system"}),o("ul",{className:"editorial-list",children:[o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Define the trust category and retrieval expectations first."})]}),o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Bind tenant-owned sources explicitly to those knowledge spaces."})]}),o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Consume knowledge through capabilities and workflows, not through invisible prompt assumptions."})]})]})]})}),t("div",{className:"grid gap-4 md:grid-cols-2",children:d.map((e)=>o(r,{href:e.href,className:"editorial-panel",children:[t("h2",{className:"font-semibold text-xl",children:e.title}),t("p",{className:"mt-2 text-muted-foreground text-sm leading-7",children:e.body})]},e.href))})]})}export{g as KnowledgeOverviewPage};
1
+ var i=Object.defineProperty;var r=(e)=>e;function s(e,a){this[e]=r.bind(null,a)}var c=(e,a)=>{for(var n in a)i(e,n,{get:a[n],enumerable:!0,configurable:!0,set:s.bind(a,n)})};var p=(e,a)=>()=>(e&&(a=e(e=0)),a);import l from"@contractspec/lib.ui-link";import{jsx as t,jsxs as o}from"react/jsx-runtime";var d=[{title:"Categories",body:"Separate canonical truth from operational notes, external material, and ephemeral working context.",href:"/docs/knowledge/categories"},{title:"Spaces",body:"Define the storage and retrieval boundary for each knowledge domain.",href:"/docs/knowledge/spaces"},{title:"Sources",body:"Connect tenant-owned sources explicitly instead of letting context leak in through prompts alone.",href:"/docs/knowledge/sources"},{title:"Governance",body:"Gate provider-backed mutations with dry-runs, approvals, idempotency, audit evidence, and outbound-send policy.",href:"/docs/knowledge/governance"},{title:"Provider-backed adoption",body:"Wire Gmail and Google Drive ingestion through checkpointed deltas, tombstones, watches, and Connect evidence.",href:"/docs/guides/provider-backed-knowledge"},{title:"Examples",body:"See how support, compliance, and product systems consume trusted knowledge at runtime.",href:"/docs/knowledge/examples"}];function g(){return o("div",{className:"space-y-10",children:[o("div",{className:"space-y-3",children:[t("p",{className:"editorial-kicker",children:"Operate"}),t("h1",{className:"font-serif text-4xl tracking-[-0.04em] md:text-5xl",children:"Knowledge is part of the runtime, not a sidecar prompt hack."}),t("p",{className:"max-w-3xl text-lg text-muted-foreground leading-8",children:"When AI-native systems depend on external context, the context needs the same discipline as the rest of the stack. ContractSpec treats knowledge as typed, bounded, and governable so teams can reason about trust, isolation, and retrieval behavior."})]}),t("section",{className:"editorial-panel space-y-5",children:o("div",{className:"space-y-2",children:[t("h2",{className:"font-serif text-3xl tracking-[-0.03em]",children:"How knowledge enters the system"}),o("ul",{className:"editorial-list",children:[o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Define the trust category and retrieval expectations first."})]}),o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Bind tenant-owned sources explicitly to those knowledge spaces."})]}),o("li",{children:[t("span",{className:"editorial-list-marker"}),t("span",{children:"Consume knowledge through capabilities and workflows, not through invisible prompt assumptions."})]})]})]})}),t("div",{className:"grid gap-4 md:grid-cols-2",children:d.map((e)=>o(l,{href:e.href,className:"editorial-panel",children:[t("h2",{className:"font-semibold text-xl",children:e.title}),t("p",{className:"mt-2 text-muted-foreground text-sm leading-7",children:e.body})]},e.href))})]})}export{g as KnowledgeOverviewPage};
@@ -1,4 +1,4 @@
1
- var E=Object.defineProperty;var F=(z)=>z;function G(z,A){this[z]=F.bind(null,A)}var I=(z,A)=>{for(var B in A)E(z,B,{get:A[B],enumerable:!0,configurable:!0,set:G.bind(A,B)})};var J=(z,A)=>()=>(z&&(A=z(z=0)),A);import D from"@contractspec/lib.ui-link";import{ChevronRight as H}from"lucide-react";import{jsx as q,jsxs as y}from"react/jsx-runtime";function P(){return y("div",{className:"space-y-8",children:[y("div",{className:"space-y-4",children:[q("h1",{className:"font-bold text-4xl",children:"Knowledge Sources"}),y("p",{className:"text-muted-foreground",children:["A ",q("strong",{children:"KnowledgeSourceConfig"})," connects a tenant's data sources (Notion, Gmail, uploads, databases) to knowledge spaces. Each source is synced, chunked, embedded, and indexed according to the space's configuration."]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"KnowledgeSourceConfig"}),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 KnowledgeSourceConfig = {
1
+ var E=Object.defineProperty;var F=(z)=>z;function G(z,A){this[z]=F.bind(null,A)}var I=(z,A)=>{for(var D in A)E(z,D,{get:A[D],enumerable:!0,configurable:!0,set:G.bind(A,D)})};var J=(z,A)=>()=>(z&&(A=z(z=0)),A);import B from"@contractspec/lib.ui-link";import{ChevronRight as H}from"lucide-react";import{jsx as q,jsxs as y}from"react/jsx-runtime";function P(){return y("div",{className:"space-y-8",children:[y("div",{className:"space-y-4",children:[q("h1",{className:"font-bold text-4xl",children:"Knowledge Sources"}),y("p",{className:"text-muted-foreground",children:["A ",q("strong",{children:"KnowledgeSourceConfig"})," connects a tenant's data sources (Notion, Gmail, uploads, databases) to knowledge spaces. Each source is synced, chunked, embedded, and indexed according to the space's configuration."]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"KnowledgeSourceConfig"}),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 KnowledgeSourceConfig = {
2
2
  id: string;
3
3
  tenantId: string;
4
4
  spaceId: string;
@@ -68,4 +68,13 @@ var E=Object.defineProperty;var F=(z)=>z;function G(z,A){this[z]=F.bind(null,A)}
68
68
  syncPolicy: { manual: true }
69
69
  }
70
70
  ]
71
- }`})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Processing pipeline"}),q("p",{className:"text-muted-foreground",children:"When a source is synced, ContractSpec processes it through several stages:"}),y("ol",{className:"list-inside list-decimal space-y-3 text-muted-foreground",children:[y("li",{children:[q("strong",{children:"Fetch"})," - Retrieve content from source (API, database, file)"]}),y("li",{children:[q("strong",{children:"Parse"})," - Extract text from documents (PDF, Word, HTML)"]}),y("li",{children:[q("strong",{children:"Chunk"})," - Split into semantic chunks (paragraphs, sections)"]}),y("li",{children:[q("strong",{children:"Embed"})," - Generate vector embeddings (OpenAI, Cohere)"]}),y("li",{children:[q("strong",{children:"Index"})," - Store in vector database (Qdrant) or search engine"]}),y("li",{children:[q("strong",{children:"Audit"})," - Log sync operation and results"]})]})]}),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:"Use webhooks for real-time sources (Notion, Gmail) to minimize latency"}),q("li",{children:"Set appropriate sync intervals - hourly for active docs, daily for stable content"}),q("li",{children:"Monitor sync failures and set up alerts for critical sources"}),q("li",{children:"Test sources in sandbox before enabling in production"}),q("li",{children:"Document the purpose and ownership of each source for your team"}),q("li",{children:"Use manual sync for sensitive or infrequently updated content"})]})]}),y("div",{className:"flex items-center gap-4 pt-4",children:[q(D,{href:"/docs/knowledge/spaces",className:"btn-ghost",children:"Previous: Spaces"}),y(D,{href:"/docs/knowledge/examples",className:"btn-primary",children:["Examples ",q(H,{size:16})]})]})]})}export{P as KnowledgeSourcesPage};
71
+ }`})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Processing pipeline"}),q("p",{className:"text-muted-foreground",children:"When a source is synced, ContractSpec processes it through several stages:"}),y("ol",{className:"list-inside list-decimal space-y-3 text-muted-foreground",children:[y("li",{children:[q("strong",{children:"Fetch"})," - Retrieve content from source (API, database, file)"]}),y("li",{children:[q("strong",{children:"Parse"})," - Extract text from documents (PDF, Word, HTML)"]}),y("li",{children:[q("strong",{children:"Chunk"})," - Split into semantic chunks (paragraphs, sections)"]}),y("li",{children:[q("strong",{children:"Embed"})," - Generate vector embeddings (OpenAI, Cohere)"]}),y("li",{children:[q("strong",{children:"Index"})," - Store in vector database (Qdrant) or search engine"]}),y("li",{children:[q("strong",{children:"Audit"})," - Log sync operation and results"]})]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Provider delta state"}),y("p",{className:"text-muted-foreground",children:["Runtime-backed providers should persist a"," ",q("strong",{children:"ProviderDeltaSyncState"})," per source before sync work is acknowledged. Gmail and Google Drive adapters use that checkpoint to resume cursors, renew watches, skip tombstones, dedupe webhook events, and replay from a known point after retries."]}),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 ProviderDeltaSyncState = {
72
+ lease?: { holder: string; expiresAt: string; renewalWindowMs: number };
73
+ cursor?: { cursor?: string; watermark?: string; watermarkVersion?: string };
74
+ webhookChannel?: { channelId: string; resourceId?: string; expiresAt?: string };
75
+ providerEventId?: string;
76
+ dedupeKey?: string;
77
+ idempotencyKey?: string;
78
+ replayCheckpoint?: { checkpointId: string; sequence?: string | number };
79
+ tombstone?: { deletedAt: string; reason?: string };
80
+ };`})}),y("div",{className:"flex flex-wrap gap-3",children:[q(B,{href:"/docs/integrations/gmail",className:"btn-ghost",children:"Gmail integration"}),q(B,{href:"/docs/integrations/google-drive",className:"btn-ghost",children:"Google Drive integration"}),q(B,{href:"/docs/guides/provider-backed-knowledge",className:"btn-ghost",children:"Provider-backed guide"})]})]}),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:"Use webhooks for real-time sources (Notion, Gmail) to minimize latency"}),q("li",{children:"Set appropriate sync intervals - hourly for active docs, daily for stable content"}),q("li",{children:"Monitor sync failures and set up alerts for critical sources"}),q("li",{children:"Test sources in sandbox before enabling in production"}),q("li",{children:"Document the purpose and ownership of each source for your team"}),q("li",{children:"Use manual sync for sensitive or infrequently updated content"}),y("li",{children:["Run external mutations through"," ",q(B,{href:"/docs/knowledge/governance",className:"text-primary",children:"knowledge mutation governance"})," ","before sending email, changing Drive permissions, or repairing replay state."]})]})]}),y("div",{className:"flex items-center gap-4 pt-4",children:[q(B,{href:"/docs/knowledge/spaces",className:"btn-ghost",children:"Previous: Spaces"}),y(B,{href:"/docs/knowledge/examples",className:"btn-primary",children:["Examples ",q(H,{size:16})]})]})]})}export{P as KnowledgeSourcesPage};
@@ -1,8 +1,8 @@
1
- var v=Object.defineProperty;var N=(n)=>n;function u(n,p){this[n]=N.bind(null,p)}var I=(n,p)=>{for(var c in p)v(n,c,{get:p[c],enumerable:!0,configurable:!0,set:u.bind(p,c)})};var S=(n,p)=>()=>(n&&(p=n(n=0)),p);import f from"@contractspec/lib.ui-link";import{ChevronRight as k}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function b(){return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Knowledge Categories"}),e("p",{className:"text-muted-foreground",children:"ContractSpec classifies knowledge into four categories based on trust level, source authority, and intended use. This classification determines how knowledge can be used in workflows, policy decisions, and agent responses."})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"The four categories"}),e("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:e("pre",{children:`type KnowledgeCategory =
1
+ var k=Object.defineProperty;var K=(l)=>l;function P(l,v){this[l]=K.bind(null,v)}var W=(l,v)=>{for(var f in v)k(l,f,{get:v[f],enumerable:!0,configurable:!0,set:P.bind(v,f)})};var _=(l,v)=>()=>(l&&(v=l(l=0)),v);import h from"@contractspec/lib.ui-link";import{ChevronRight as G}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function E(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Knowledge Categories"}),e("p",{className:"text-muted-foreground",children:"ContractSpec classifies knowledge into four categories based on trust level, source authority, and intended use. This classification determines how knowledge can be used in workflows, policy decisions, and agent responses."})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"The four categories"}),e("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:e("pre",{children:`type KnowledgeCategory =
2
2
  | "canonical" // Internal ground truth
3
3
  | "operational" // Internal operational docs
4
4
  | "external" // Third-party reference
5
- | "ephemeral"; // Temporary context`})})]}),a("div",{className:"space-y-6",children:[a("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"1. Canonical"}),a("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Highest - Authoritative ground truth"]}),a("div",{className:"space-y-3",children:[a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Official product specifications and schemas"}),e("li",{children:"Company policies and procedures"}),e("li",{children:"Legal terms and compliance requirements"}),e("li",{children:"Pricing rules and business logic"}),e("li",{children:"Data classification and security policies"})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[a("li",{children:[e("strong",{children:"Policy decisions"})," - Can drive PDP decisions"]}),a("li",{children:[e("strong",{children:"Validation"})," - Used to validate user inputs and operations"]}),a("li",{children:[e("strong",{children:"Code generation"})," - Source of truth for generated code"]}),a("li",{children:[e("strong",{children:"Compliance"})," - Reference for audit and regulatory checks"]})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Product Canon space
5
+ | "ephemeral"; // Temporary context`})})]}),t("div",{className:"space-y-6",children:[t("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"1. Canonical"}),t("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Highest - Authoritative ground truth"]}),t("div",{className:"space-y-3",children:[t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Official product specifications and schemas"}),e("li",{children:"Company policies and procedures"}),e("li",{children:"Legal terms and compliance requirements"}),e("li",{children:"Pricing rules and business logic"}),e("li",{children:"Data classification and security policies"})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[t("li",{children:[e("strong",{children:"Policy decisions"})," - Can drive PDP decisions"]}),t("li",{children:[e("strong",{children:"Validation"})," - Used to validate user inputs and operations"]}),t("li",{children:[e("strong",{children:"Code generation"})," - Source of truth for generated code"]}),t("li",{children:[e("strong",{children:"Compliance"})," - Reference for audit and regulatory checks"]})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Product Canon space
6
6
  {
7
7
  id: "product-canon",
8
8
  category: "canonical",
@@ -22,7 +22,7 @@ var v=Object.defineProperty;var N=(n)=>n;function u(n,p){this[n]=N.bind(null,p)}
22
22
  "access-policies.rego",
23
23
  "compliance-requirements.md"
24
24
  ]
25
- }`})})]}),e("div",{className:"card-subtle border-violet-500/30 bg-violet-500/10 p-3",children:a("p",{className:"text-sm text-violet-300",children:[e("strong",{children:"⚠️ Important:"})," Canonical knowledge is immutable once indexed. Changes require re-sync and versioning."]})})]})]}),a("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"2. Operational"}),a("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," High - Internal but not authoritative"]}),a("div",{className:"space-y-3",children:[a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Support ticket history and resolutions"}),e("li",{children:"Internal runbooks and playbooks"}),e("li",{children:"Sales materials and customer communications"}),e("li",{children:"Product management docs and roadmaps"}),e("li",{children:"Team wikis and knowledge bases"})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[a("li",{children:[e("strong",{children:"Context"})," - Provides helpful context for decisions"]}),a("li",{children:[e("strong",{children:"Suggestions"})," - Informs recommendations, not requirements"]}),a("li",{children:[e("strong",{children:"Learning"})," - Helps agents learn from past interactions"]}),a("li",{children:[e("strong",{children:"Troubleshooting"})," - Guides problem-solving workflows"]})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Support History space
25
+ }`})})]}),e("div",{className:"card-subtle border-violet-500/30 bg-violet-500/10 p-3",children:t("p",{className:"text-sm text-violet-300",children:[e("strong",{children:"⚠️ Important:"})," Canonical knowledge is immutable once indexed. Changes require re-sync and versioning."]})})]})]}),t("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"2. Operational"}),t("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," High - Internal but not authoritative"]}),t("div",{className:"space-y-3",children:[t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Support ticket history and resolutions"}),e("li",{children:"Internal runbooks and playbooks"}),e("li",{children:"Sales materials and customer communications"}),e("li",{children:"Product management docs and roadmaps"}),e("li",{children:"Team wikis and knowledge bases"})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[t("li",{children:[e("strong",{children:"Context"})," - Provides helpful context for decisions"]}),t("li",{children:[e("strong",{children:"Suggestions"})," - Informs recommendations, not requirements"]}),t("li",{children:[e("strong",{children:"Learning"})," - Helps agents learn from past interactions"]}),t("li",{children:[e("strong",{children:"Troubleshooting"})," - Guides problem-solving workflows"]})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Support History space
26
26
  {
27
27
  id: "support-history",
28
28
  category: "operational",
@@ -42,7 +42,7 @@ var v=Object.defineProperty;var N=(n)=>n;function u(n,p){this[n]=N.bind(null,p)}
42
42
  "confluence:product-docs",
43
43
  "google-drive:runbooks"
44
44
  ]
45
- }`})})]})]})]}),a("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"3. External"}),a("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Medium - Reference only"]}),a("div",{className:"space-y-3",children:[a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Third-party integration documentation (Stripe, Twilio)"}),e("li",{children:"Regulatory and compliance documents"}),e("li",{children:"Industry standards and best practices"}),e("li",{children:"Public API documentation"}),e("li",{children:"External knowledge bases"})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[a("li",{children:[e("strong",{children:"Reference"})," - Consulted but not authoritative"]}),a("li",{children:[e("strong",{children:"Integration help"})," - Guides external API usage"]}),a("li",{children:[e("strong",{children:"Compliance context"})," - Provides regulatory background"]}),a("li",{children:[e("strong",{children:"Never for policy"})," - Cannot drive policy decisions"]})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// External Provider Docs space
45
+ }`})})]})]})]}),t("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"3. External"}),t("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Medium - Reference only"]}),t("div",{className:"space-y-3",children:[t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Third-party integration documentation (Stripe, Twilio)"}),e("li",{children:"Regulatory and compliance documents"}),e("li",{children:"Industry standards and best practices"}),e("li",{children:"Public API documentation"}),e("li",{children:"External knowledge bases"})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[t("li",{children:[e("strong",{children:"Reference"})," - Consulted but not authoritative"]}),t("li",{children:[e("strong",{children:"Integration help"})," - Guides external API usage"]}),t("li",{children:[e("strong",{children:"Compliance context"})," - Provides regulatory background"]}),t("li",{children:[e("strong",{children:"Never for policy"})," - Cannot drive policy decisions"]})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// External Provider Docs space
46
46
  {
47
47
  id: "provider-docs",
48
48
  category: "external",
@@ -62,7 +62,7 @@ var v=Object.defineProperty;var N=(n)=>n;function u(n,p){this[n]=N.bind(null,p)}
62
62
  "url:https://www.hhs.gov/hipaa",
63
63
  "pdf:SOC2-requirements.pdf"
64
64
  ]
65
- }`})})]}),e("div",{className:"card-subtle border-amber-500/30 bg-amber-500/10 p-3",children:a("p",{className:"text-amber-300 text-sm",children:[e("strong",{children:"⚠️ Note:"}),` External knowledge should be clearly marked in agent responses as "according to [source]" to indicate it's not internal authority.`]})})]})]}),a("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"4. Ephemeral"}),a("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Low - Temporary context only"]}),a("div",{className:"space-y-3",children:[a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Agent conversation history and scratchpads"}),e("li",{children:"Session-specific context and state"}),e("li",{children:"Draft documents and work-in-progress"}),e("li",{children:"Temporary calculations and intermediate results"}),e("li",{children:"User-provided context for current task"})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),a("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[a("li",{children:[e("strong",{children:"Session continuity"})," - Maintains conversation context"]}),a("li",{children:[e("strong",{children:"Working memory"})," - Stores intermediate results"]}),a("li",{children:[e("strong",{children:"Never persisted long-term"})," - Auto-purged after session"]}),a("li",{children:[e("strong",{children:"Never for decisions"})," - Cannot influence policy or validation"]})]})]}),a("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Agent Scratchpad space
65
+ }`})})]}),e("div",{className:"card-subtle border-amber-500/30 bg-amber-500/10 p-3",children:t("p",{className:"text-amber-300 text-sm",children:[e("strong",{children:"⚠️ Note:"}),` External knowledge should be clearly marked in agent responses as "according to [source]" to indicate it's not internal authority.`]})})]})]}),t("div",{className:"space-y-4",children:[e("h3",{className:"font-semibold text-xl",children:"4. Ephemeral"}),t("p",{className:"text-muted-foreground",children:[e("strong",{children:"Trust level:"})," Low - Temporary context only"]}),t("div",{className:"space-y-3",children:[t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"What it contains:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[e("li",{children:"Agent conversation history and scratchpads"}),e("li",{children:"Session-specific context and state"}),e("li",{children:"Draft documents and work-in-progress"}),e("li",{children:"Temporary calculations and intermediate results"}),e("li",{children:"User-provided context for current task"})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"How it's used:"}),t("ul",{className:"ml-4 list-inside list-disc space-y-1 text-muted-foreground text-sm",children:[t("li",{children:[e("strong",{children:"Session continuity"})," - Maintains conversation context"]}),t("li",{children:[e("strong",{children:"Working memory"})," - Stores intermediate results"]}),t("li",{children:[e("strong",{children:"Never persisted long-term"})," - Auto-purged after session"]}),t("li",{children:[e("strong",{children:"Never for decisions"})," - Cannot influence policy or validation"]})]})]}),t("div",{children:[e("h4",{className:"mb-2 font-semibold text-sm",children:"Examples:"}),e("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:e("pre",{children:`// Agent Scratchpad space
66
66
  {
67
67
  id: "agent-scratchpad",
68
68
  category: "ephemeral",
@@ -82,7 +82,7 @@ var v=Object.defineProperty;var N=(n)=>n;function u(n,p){this[n]=N.bind(null,p)}
82
82
  "session:user-uploads",
83
83
  "session:form-drafts"
84
84
  ]
85
- }`})})]}),e("div",{className:"card-subtle border-red-500/30 bg-red-500/10 p-3",children:a("p",{className:"text-red-300 text-sm",children:[e("strong",{children:"⚠️ Critical:"})," Ephemeral knowledge is never used for policy decisions, compliance checks, or any authoritative purpose."]})})]})]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Category comparison"}),e("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:a("table",{className:"w-full text-left text-sm",children:[e("thead",{className:"bg-card/50",children:a("tr",{className:"border-border/50 border-b",children:[e("th",{className:"px-4 py-3 font-semibold",children:"Feature"}),e("th",{className:"px-4 py-3 font-semibold",children:"Canonical"}),e("th",{className:"px-4 py-3 font-semibold",children:"Operational"}),e("th",{className:"px-4 py-3 font-semibold",children:"External"}),e("th",{className:"px-4 py-3 font-semibold",children:"Ephemeral"})]})}),a("tbody",{className:"divide-y divide-border/50",children:[a("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Trust Level"}),e("td",{className:"px-4 py-3",children:"Highest"}),e("td",{className:"px-4 py-3",children:"High"}),e("td",{className:"px-4 py-3",children:"Medium"}),e("td",{className:"px-4 py-3",children:"Low"})]}),a("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Policy Impact"}),e("td",{className:"px-4 py-3",children:"✅ Can drive decisions"}),e("td",{className:"px-4 py-3",children:"⚠️ Can inform"}),e("td",{className:"px-4 py-3",children:"❌ Reference only"}),e("td",{className:"px-4 py-3",children:"❌ Never used"})]}),a("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Mutability"}),e("td",{className:"px-4 py-3",children:"Immutable"}),e("td",{className:"px-4 py-3",children:"Mutable"}),e("td",{className:"px-4 py-3",children:"Mutable"}),e("td",{className:"px-4 py-3",children:"Temporary"})]}),a("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Retention"}),e("td",{className:"px-4 py-3",children:"Permanent"}),e("td",{className:"px-4 py-3",children:"Long-term"}),e("td",{className:"px-4 py-3",children:"Long-term"}),e("td",{className:"px-4 py-3",children:"Short-term"})]}),a("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Audit Level"}),e("td",{className:"px-4 py-3",children:"Full audit"}),e("td",{className:"px-4 py-3",children:"Full audit"}),e("td",{className:"px-4 py-3",children:"Basic audit"}),e("td",{className:"px-4 py-3",children:"Minimal audit"})]})]})]})})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Best practices"}),a("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[e("li",{children:"Use canonical for anything that affects policy, pricing, or compliance"}),e("li",{children:"Use operational for context that helps but doesn't dictate decisions"}),e("li",{children:"Use external for reference material that's helpful but not authoritative"}),e("li",{children:"Use ephemeral for temporary working memory that shouldn't persist"}),e("li",{children:"Never mix categories in a single knowledge space - keep them separate"}),e("li",{children:"Document the category and purpose of each knowledge space clearly"})]})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(f,{href:"/docs/knowledge",className:"btn-ghost",children:"Back to Knowledge"}),a(f,{href:"/docs/knowledge/spaces",className:"btn-primary",children:["Knowledge Spaces ",e(k,{size:16})]})]})]})}import h from"@contractspec/lib.ui-link";import{jsx as d,jsxs as i}from"react/jsx-runtime";function P(){return i("div",{className:"space-y-8",children:[i("div",{className:"space-y-4",children:[d("h1",{className:"font-bold text-4xl",children:"Knowledge Examples"}),d("p",{className:"text-muted-foreground",children:"Real-world examples of how different applications use knowledge spaces to power intelligent workflows and agents."})]}),i("div",{className:"space-y-6",children:[i("div",{className:"space-y-4",children:[d("h2",{className:"font-bold text-2xl",children:"Example 1: ArtisanOS Support Agent"}),i("p",{className:"text-muted-foreground",children:[d("strong",{children:"Context:"})," ArtisanOS needs a support agent that can answer product questions using official documentation and learn from past support tickets."]}),d("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:d("pre",{children:`// Knowledge spaces
85
+ }`})})]}),e("div",{className:"card-subtle border-red-500/30 bg-red-500/10 p-3",children:t("p",{className:"text-red-300 text-sm",children:[e("strong",{children:"⚠️ Critical:"})," Ephemeral knowledge is never used for policy decisions, compliance checks, or any authoritative purpose."]})})]})]})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Category comparison"}),e("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:t("table",{className:"w-full text-left text-sm",children:[e("thead",{className:"bg-card/50",children:t("tr",{className:"border-border/50 border-b",children:[e("th",{className:"px-4 py-3 font-semibold",children:"Feature"}),e("th",{className:"px-4 py-3 font-semibold",children:"Canonical"}),e("th",{className:"px-4 py-3 font-semibold",children:"Operational"}),e("th",{className:"px-4 py-3 font-semibold",children:"External"}),e("th",{className:"px-4 py-3 font-semibold",children:"Ephemeral"})]})}),t("tbody",{className:"divide-y divide-border/50",children:[t("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Trust Level"}),e("td",{className:"px-4 py-3",children:"Highest"}),e("td",{className:"px-4 py-3",children:"High"}),e("td",{className:"px-4 py-3",children:"Medium"}),e("td",{className:"px-4 py-3",children:"Low"})]}),t("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Policy Impact"}),e("td",{className:"px-4 py-3",children:"✅ Can drive decisions"}),e("td",{className:"px-4 py-3",children:"⚠️ Can inform"}),e("td",{className:"px-4 py-3",children:"❌ Reference only"}),e("td",{className:"px-4 py-3",children:"❌ Never used"})]}),t("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Mutability"}),e("td",{className:"px-4 py-3",children:"Immutable"}),e("td",{className:"px-4 py-3",children:"Mutable"}),e("td",{className:"px-4 py-3",children:"Mutable"}),e("td",{className:"px-4 py-3",children:"Temporary"})]}),t("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Retention"}),e("td",{className:"px-4 py-3",children:"Permanent"}),e("td",{className:"px-4 py-3",children:"Long-term"}),e("td",{className:"px-4 py-3",children:"Long-term"}),e("td",{className:"px-4 py-3",children:"Short-term"})]}),t("tr",{children:[e("td",{className:"px-4 py-3 font-semibold",children:"Audit Level"}),e("td",{className:"px-4 py-3",children:"Full audit"}),e("td",{className:"px-4 py-3",children:"Full audit"}),e("td",{className:"px-4 py-3",children:"Basic audit"}),e("td",{className:"px-4 py-3",children:"Minimal audit"})]})]})]})})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Best practices"}),t("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[e("li",{children:"Use canonical for anything that affects policy, pricing, or compliance"}),e("li",{children:"Use operational for context that helps but doesn't dictate decisions"}),e("li",{children:"Use external for reference material that's helpful but not authoritative"}),e("li",{children:"Use ephemeral for temporary working memory that shouldn't persist"}),e("li",{children:"Never mix categories in a single knowledge space - keep them separate"}),e("li",{children:"Document the category and purpose of each knowledge space clearly"})]})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[e(h,{href:"/docs/knowledge",className:"btn-ghost",children:"Back to Knowledge"}),t(h,{href:"/docs/knowledge/spaces",className:"btn-primary",children:["Knowledge Spaces ",e(G,{size:16})]})]})]})}import w from"@contractspec/lib.ui-link";import{jsx as d,jsxs as i}from"react/jsx-runtime";function q(){return i("div",{className:"space-y-8",children:[i("div",{className:"space-y-4",children:[d("h1",{className:"font-bold text-4xl",children:"Knowledge Examples"}),d("p",{className:"text-muted-foreground",children:"Real-world examples of how different applications use knowledge spaces to power intelligent workflows and agents."})]}),i("div",{className:"space-y-6",children:[i("div",{className:"space-y-4",children:[d("h2",{className:"font-bold text-2xl",children:"Example 1: ArtisanOS Support Agent"}),i("p",{className:"text-muted-foreground",children:[d("strong",{children:"Context:"})," ArtisanOS needs a support agent that can answer product questions using official documentation and learn from past support tickets."]}),d("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:d("pre",{children:`// Knowledge spaces
86
86
  knowledgeSpaces: [
87
87
  {
88
88
  id: "product-canon",
@@ -250,7 +250,28 @@ steps:
250
250
  Question: \${input.question}
251
251
  Internal: \${steps.search-internal-guides.output.results}
252
252
  Stripe: \${steps.search-stripe-docs.output.results}
253
- Past: \${steps.search-past-questions.output.results}`})})]})]}),i("div",{className:"space-y-4",children:[d("h2",{className:"font-bold text-2xl",children:"Key patterns"}),i("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[i("li",{children:[d("strong",{children:"Canonical first"})," - Always search canonical spaces before operational or external"]}),i("li",{children:[d("strong",{children:"Category-aware prompts"})," - Tell the LLM which sources are authoritative vs reference"]}),i("li",{children:[d("strong",{children:"Multi-space queries"})," - Combine results from multiple spaces for richer context"]}),i("li",{children:[d("strong",{children:"Limit results"})," - Use appropriate limits (3-5) to avoid token overflow"]}),i("li",{children:[d("strong",{children:"Audit everything"})," - Log all knowledge queries for debugging and compliance"]})]})]}),i("div",{className:"flex items-center gap-4 pt-4",children:[d(h,{href:"/docs/knowledge/sources",className:"btn-ghost",children:"Previous: Sources"}),d(h,{href:"/docs/architecture/knowledge-binding",className:"btn-ghost",children:"Knowledge Binding"})]})]})}import K from"@contractspec/lib.ui-link";import{jsx as m,jsxs as g}from"react/jsx-runtime";var O=[{title:"Categories",body:"Separate canonical truth from operational notes, external material, and ephemeral working context.",href:"/docs/knowledge/categories"},{title:"Spaces",body:"Define the storage and retrieval boundary for each knowledge domain.",href:"/docs/knowledge/spaces"},{title:"Sources",body:"Connect tenant-owned sources explicitly instead of letting context leak in through prompts alone.",href:"/docs/knowledge/sources"},{title:"Examples",body:"See how support, compliance, and product systems consume trusted knowledge at runtime.",href:"/docs/knowledge/examples"}];function D(){return g("div",{className:"space-y-10",children:[g("div",{className:"space-y-3",children:[m("p",{className:"editorial-kicker",children:"Operate"}),m("h1",{className:"font-serif text-4xl tracking-[-0.04em] md:text-5xl",children:"Knowledge is part of the runtime, not a sidecar prompt hack."}),m("p",{className:"max-w-3xl text-lg text-muted-foreground leading-8",children:"When AI-native systems depend on external context, the context needs the same discipline as the rest of the stack. ContractSpec treats knowledge as typed, bounded, and governable so teams can reason about trust, isolation, and retrieval behavior."})]}),m("section",{className:"editorial-panel space-y-5",children:g("div",{className:"space-y-2",children:[m("h2",{className:"font-serif text-3xl tracking-[-0.03em]",children:"How knowledge enters the system"}),g("ul",{className:"editorial-list",children:[g("li",{children:[m("span",{className:"editorial-list-marker"}),m("span",{children:"Define the trust category and retrieval expectations first."})]}),g("li",{children:[m("span",{className:"editorial-list-marker"}),m("span",{children:"Bind tenant-owned sources explicitly to those knowledge spaces."})]}),g("li",{children:[m("span",{className:"editorial-list-marker"}),m("span",{children:"Consume knowledge through capabilities and workflows, not through invisible prompt assumptions."})]})]})]})}),m("div",{className:"grid gap-4 md:grid-cols-2",children:O.map((n)=>g(K,{href:n.href,className:"editorial-panel",children:[m("h2",{className:"font-semibold text-xl",children:n.title}),m("p",{className:"mt-2 text-muted-foreground text-sm leading-7",children:n.body})]},n.href))})]})}import w from"@contractspec/lib.ui-link";import{ChevronRight as E}from"lucide-react";import{jsx as t,jsxs as l}from"react/jsx-runtime";function A(){return l("div",{className:"space-y-8",children:[l("div",{className:"space-y-4",children:[t("h1",{className:"font-bold text-4xl",children:"Knowledge Sources"}),l("p",{className:"text-muted-foreground",children:["A ",t("strong",{children:"KnowledgeSourceConfig"})," connects a tenant's data sources (Notion, Gmail, uploads, databases) to knowledge spaces. Each source is synced, chunked, embedded, and indexed according to the space's configuration."]})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"KnowledgeSourceConfig"}),t("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:t("pre",{children:`type KnowledgeSourceConfig = {
253
+ Past: \${steps.search-past-questions.output.results}`})})]})]}),i("div",{className:"space-y-4",children:[d("h2",{className:"font-bold text-2xl",children:"Key patterns"}),i("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[i("li",{children:[d("strong",{children:"Canonical first"})," - Always search canonical spaces before operational or external"]}),i("li",{children:[d("strong",{children:"Category-aware prompts"})," - Tell the LLM which sources are authoritative vs reference"]}),i("li",{children:[d("strong",{children:"Multi-space queries"})," - Combine results from multiple spaces for richer context"]}),i("li",{children:[d("strong",{children:"Limit results"})," - Use appropriate limits (3-5) to avoid token overflow"]}),i("li",{children:[d("strong",{children:"Audit everything"})," - Log all knowledge queries for debugging and compliance"]})]})]}),i("div",{className:"flex items-center gap-4 pt-4",children:[d(w,{href:"/docs/knowledge/sources",className:"btn-ghost",children:"Previous: Sources"}),d(w,{href:"/docs/architecture/knowledge-binding",className:"btn-ghost",children:"Knowledge Binding"})]})]})}import{CodeBlock as y}from"@contractspec/lib.design-system";import N from"@contractspec/lib.ui-link";import{ChevronRight as A}from"lucide-react";import{jsx as c,jsxs as m}from"react/jsx-runtime";function D(){return m("div",{className:"space-y-8",children:[m("div",{className:"space-y-4",children:[c("h1",{className:"font-bold text-4xl",children:"Knowledge mutation governance"}),c("p",{className:"text-muted-foreground",children:"Provider-backed knowledge is not read-only forever. Email sends, Drive permission changes, tombstone handling, replay repairs, and source metadata updates all need explicit governance before they mutate an external system."})]}),m("div",{className:"grid gap-4 md:grid-cols-2",children:[m("div",{className:"card-subtle space-y-2 p-4",children:[c("h2",{className:"font-semibold text-lg",children:"Fail closed"}),c("p",{className:"text-muted-foreground text-sm",children:"Non-dry-run mutations require an idempotency key and audit evidence. Approval-required operations need approval refs. Outbound sends also need an approved send gate."})]}),m("div",{className:"card-subtle space-y-2 p-4",children:[c("h2",{className:"font-semibold text-lg",children:"Leave evidence"}),c("p",{className:"text-muted-foreground text-sm",children:"Every evaluation returns an audit envelope with status, missing evidence, idempotency, approval refs, and the decision timestamp."})]})]}),m("div",{className:"space-y-4",children:[c("h2",{className:"font-bold text-2xl",children:"Runtime gate"}),c(y,{language:"typescript",filename:"knowledge-governance.ts",code:`const result = await executeGovernedKnowledgeMutation(
254
+ {
255
+ operation: "drive.permission.update",
256
+ sourceId: "src_drive_support",
257
+ requiresApproval: true,
258
+ governance: {
259
+ idempotencyKey: "tenant:drive-permission:123",
260
+ auditEvidence: { evidenceRef: "audit://drive/permission/123" },
261
+ approvalRefs: [{ id: "approval-123" }],
262
+ },
263
+ },
264
+ () => drive.updatePermission(input),
265
+ { audit: (envelope) => auditTrail.write(envelope) },
266
+ );
267
+
268
+ if (result.status === "blocked") {
269
+ return result.auditEnvelope.requiredEvidence;
270
+ }`})]}),m("div",{className:"space-y-4",children:[c("h2",{className:"font-bold text-2xl",children:"ContractSpec surface"}),m("p",{className:"text-muted-foreground",children:["Use ",c("code",{children:"knowledge.mutation.evaluateGovernance"})," when an app or control-plane workflow needs to expose mutation decisions as a contracted action. It mirrors the runtime helper and gives Connect, ops tools, and review packets one stable contract to reference."]}),c(y,{language:"typescript",filename:"knowledge-operation.ts",code:`import {
271
+ EvaluateKnowledgeMutationGovernance,
272
+ } from "@contractspec/lib.contracts-spec/knowledge/operations";
273
+
274
+ registry.register(EvaluateKnowledgeMutationGovernance);`})]}),m("div",{className:"flex items-center gap-4 pt-4",children:[c(N,{href:"/docs/knowledge/sources",className:"btn-ghost",children:"Knowledge sources"}),m(N,{href:"/docs/guides/provider-backed-knowledge",className:"btn-primary",children:["Adoption guide ",c(A,{size:16})]})]})]})}import O from"@contractspec/lib.ui-link";import{jsx as p,jsxs as g}from"react/jsx-runtime";var C=[{title:"Categories",body:"Separate canonical truth from operational notes, external material, and ephemeral working context.",href:"/docs/knowledge/categories"},{title:"Spaces",body:"Define the storage and retrieval boundary for each knowledge domain.",href:"/docs/knowledge/spaces"},{title:"Sources",body:"Connect tenant-owned sources explicitly instead of letting context leak in through prompts alone.",href:"/docs/knowledge/sources"},{title:"Governance",body:"Gate provider-backed mutations with dry-runs, approvals, idempotency, audit evidence, and outbound-send policy.",href:"/docs/knowledge/governance"},{title:"Provider-backed adoption",body:"Wire Gmail and Google Drive ingestion through checkpointed deltas, tombstones, watches, and Connect evidence.",href:"/docs/guides/provider-backed-knowledge"},{title:"Examples",body:"See how support, compliance, and product systems consume trusted knowledge at runtime.",href:"/docs/knowledge/examples"}];function I(){return g("div",{className:"space-y-10",children:[g("div",{className:"space-y-3",children:[p("p",{className:"editorial-kicker",children:"Operate"}),p("h1",{className:"font-serif text-4xl tracking-[-0.04em] md:text-5xl",children:"Knowledge is part of the runtime, not a sidecar prompt hack."}),p("p",{className:"max-w-3xl text-lg text-muted-foreground leading-8",children:"When AI-native systems depend on external context, the context needs the same discipline as the rest of the stack. ContractSpec treats knowledge as typed, bounded, and governable so teams can reason about trust, isolation, and retrieval behavior."})]}),p("section",{className:"editorial-panel space-y-5",children:g("div",{className:"space-y-2",children:[p("h2",{className:"font-serif text-3xl tracking-[-0.03em]",children:"How knowledge enters the system"}),g("ul",{className:"editorial-list",children:[g("li",{children:[p("span",{className:"editorial-list-marker"}),p("span",{children:"Define the trust category and retrieval expectations first."})]}),g("li",{children:[p("span",{className:"editorial-list-marker"}),p("span",{children:"Bind tenant-owned sources explicitly to those knowledge spaces."})]}),g("li",{children:[p("span",{className:"editorial-list-marker"}),p("span",{children:"Consume knowledge through capabilities and workflows, not through invisible prompt assumptions."})]})]})]})}),p("div",{className:"grid gap-4 md:grid-cols-2",children:C.map((l)=>g(O,{href:l.href,className:"editorial-panel",children:[p("h2",{className:"font-semibold text-xl",children:l.title}),p("p",{className:"mt-2 text-muted-foreground text-sm leading-7",children:l.body})]},l.href))})]})}import u from"@contractspec/lib.ui-link";import{ChevronRight as M}from"lucide-react";import{jsx as a,jsxs as r}from"react/jsx-runtime";function B(){return r("div",{className:"space-y-8",children:[r("div",{className:"space-y-4",children:[a("h1",{className:"font-bold text-4xl",children:"Knowledge Sources"}),r("p",{className:"text-muted-foreground",children:["A ",a("strong",{children:"KnowledgeSourceConfig"})," connects a tenant's data sources (Notion, Gmail, uploads, databases) to knowledge spaces. Each source is synced, chunked, embedded, and indexed according to the space's configuration."]})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"KnowledgeSourceConfig"}),a("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:a("pre",{children:`type KnowledgeSourceConfig = {
254
275
  id: string;
255
276
  tenantId: string;
256
277
  spaceId: string;
@@ -277,27 +298,27 @@ steps:
277
298
  metadata?: Record<string, unknown>;
278
299
  createdAt: string;
279
300
  updatedAt: string;
280
- };`})})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Source types"}),l("div",{className:"space-y-6",children:[l("div",{className:"card-subtle p-4",children:[t("h3",{className:"mb-2 font-semibold text-lg",children:"Uploaded Documents"}),t("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:t("pre",{children:`{
301
+ };`})})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Source types"}),r("div",{className:"space-y-6",children:[r("div",{className:"card-subtle p-4",children:[a("h3",{className:"mb-2 font-semibold text-lg",children:"Uploaded Documents"}),a("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:a("pre",{children:`{
281
302
  kind: "uploaded-document",
282
303
  location: "s3://bucket/tenant-123/docs/product-spec.pdf",
283
304
  syncPolicy: { manual: true }
284
- }`})}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:"PDFs, Word docs, presentations uploaded by users"})]}),l("div",{className:"card-subtle p-4",children:[t("h3",{className:"mb-2 font-semibold text-lg",children:"Notion"}),t("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:t("pre",{children:`{
305
+ }`})}),a("p",{className:"mt-2 text-muted-foreground text-sm",children:"PDFs, Word docs, presentations uploaded by users"})]}),r("div",{className:"card-subtle p-4",children:[a("h3",{className:"mb-2 font-semibold text-lg",children:"Notion"}),a("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:a("pre",{children:`{
285
306
  kind: "notion",
286
307
  location: "https://notion.so/workspace/product-docs",
287
308
  syncPolicy: { interval: "1h", webhook: true }
288
- }`})}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:"Notion pages and databases with real-time webhook updates"})]}),l("div",{className:"card-subtle p-4",children:[t("h3",{className:"mb-2 font-semibold text-lg",children:"Gmail / Email"}),t("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:t("pre",{children:`{
309
+ }`})}),a("p",{className:"mt-2 text-muted-foreground text-sm",children:"Notion pages and databases with real-time webhook updates"})]}),r("div",{className:"card-subtle p-4",children:[a("h3",{className:"mb-2 font-semibold text-lg",children:"Gmail / Email"}),a("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:a("pre",{children:`{
289
310
  kind: "email",
290
311
  location: "support@company.com",
291
312
  syncPolicy: { webhook: true }
292
- }`})}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:"Email threads from Gmail or other providers"})]}),l("div",{className:"card-subtle p-4",children:[t("h3",{className:"mb-2 font-semibold text-lg",children:"Database Query"}),t("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:t("pre",{children:`{
313
+ }`})}),a("p",{className:"mt-2 text-muted-foreground text-sm",children:"Email threads from Gmail or other providers"})]}),r("div",{className:"card-subtle p-4",children:[a("h3",{className:"mb-2 font-semibold text-lg",children:"Database Query"}),a("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:a("pre",{children:`{
293
314
  kind: "database-query",
294
315
  location: "SELECT * FROM products WHERE active = true",
295
316
  syncPolicy: { interval: "24h" }
296
- }`})}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:"Structured data from application databases"})]}),l("div",{className:"card-subtle p-4",children:[t("h3",{className:"mb-2 font-semibold text-lg",children:"URL / Web Scraping"}),t("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:t("pre",{children:`{
317
+ }`})}),a("p",{className:"mt-2 text-muted-foreground text-sm",children:"Structured data from application databases"})]}),r("div",{className:"card-subtle p-4",children:[a("h3",{className:"mb-2 font-semibold text-lg",children:"URL / Web Scraping"}),a("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:a("pre",{children:`{
297
318
  kind: "url",
298
319
  location: "https://stripe.com/docs",
299
320
  syncPolicy: { interval: "24h" }
300
- }`})}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:"External documentation and web content"})]})]})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Sync strategies"}),t("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:l("table",{className:"w-full text-left text-sm",children:[t("thead",{className:"bg-card/50",children:l("tr",{className:"border-border/50 border-b",children:[t("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),t("th",{className:"px-4 py-3 font-semibold",children:"When to Use"}),t("th",{className:"px-4 py-3 font-semibold",children:"Latency"})]})}),l("tbody",{className:"divide-y divide-border/50",children:[l("tr",{children:[t("td",{className:"px-4 py-3 font-mono text-xs",children:"webhook"}),t("td",{className:"px-4 py-3",children:"Real-time updates (Notion, Gmail, Slack)"}),t("td",{className:"px-4 py-3",children:"Seconds"})]}),l("tr",{children:[t("td",{className:"px-4 py-3 font-mono text-xs",children:"interval"}),t("td",{className:"px-4 py-3",children:"Periodic sync (databases, URLs)"}),t("td",{className:"px-4 py-3",children:"Minutes to hours"})]}),l("tr",{children:[t("td",{className:"px-4 py-3 font-mono text-xs",children:"manual"}),t("td",{className:"px-4 py-3",children:"User-triggered (uploads, one-time imports)"}),t("td",{className:"px-4 py-3",children:"On-demand"})]})]})]})})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Example: Multi-source space"}),t("p",{className:"text-muted-foreground",children:"A single knowledge space can be fed by multiple sources:"}),t("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:t("pre",{children:`// Product Canon space with multiple sources
321
+ }`})}),a("p",{className:"mt-2 text-muted-foreground text-sm",children:"External documentation and web content"})]})]})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Sync strategies"}),a("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:r("table",{className:"w-full text-left text-sm",children:[a("thead",{className:"bg-card/50",children:r("tr",{className:"border-border/50 border-b",children:[a("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),a("th",{className:"px-4 py-3 font-semibold",children:"When to Use"}),a("th",{className:"px-4 py-3 font-semibold",children:"Latency"})]})}),r("tbody",{className:"divide-y divide-border/50",children:[r("tr",{children:[a("td",{className:"px-4 py-3 font-mono text-xs",children:"webhook"}),a("td",{className:"px-4 py-3",children:"Real-time updates (Notion, Gmail, Slack)"}),a("td",{className:"px-4 py-3",children:"Seconds"})]}),r("tr",{children:[a("td",{className:"px-4 py-3 font-mono text-xs",children:"interval"}),a("td",{className:"px-4 py-3",children:"Periodic sync (databases, URLs)"}),a("td",{className:"px-4 py-3",children:"Minutes to hours"})]}),r("tr",{children:[a("td",{className:"px-4 py-3 font-mono text-xs",children:"manual"}),a("td",{className:"px-4 py-3",children:"User-triggered (uploads, one-time imports)"}),a("td",{className:"px-4 py-3",children:"On-demand"})]})]})]})})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Example: Multi-source space"}),a("p",{className:"text-muted-foreground",children:"A single knowledge space can be fed by multiple sources:"}),a("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:a("pre",{children:`// Product Canon space with multiple sources
301
322
  {
302
323
  spaceId: "product-canon",
303
324
  sources: [
@@ -320,7 +341,16 @@ steps:
320
341
  syncPolicy: { manual: true }
321
342
  }
322
343
  ]
323
- }`})})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Processing pipeline"}),t("p",{className:"text-muted-foreground",children:"When a source is synced, ContractSpec processes it through several stages:"}),l("ol",{className:"list-inside list-decimal space-y-3 text-muted-foreground",children:[l("li",{children:[t("strong",{children:"Fetch"})," - Retrieve content from source (API, database, file)"]}),l("li",{children:[t("strong",{children:"Parse"})," - Extract text from documents (PDF, Word, HTML)"]}),l("li",{children:[t("strong",{children:"Chunk"})," - Split into semantic chunks (paragraphs, sections)"]}),l("li",{children:[t("strong",{children:"Embed"})," - Generate vector embeddings (OpenAI, Cohere)"]}),l("li",{children:[t("strong",{children:"Index"})," - Store in vector database (Qdrant) or search engine"]}),l("li",{children:[t("strong",{children:"Audit"})," - Log sync operation and results"]})]})]}),l("div",{className:"space-y-4",children:[t("h2",{className:"font-bold text-2xl",children:"Best practices"}),l("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[t("li",{children:"Use webhooks for real-time sources (Notion, Gmail) to minimize latency"}),t("li",{children:"Set appropriate sync intervals - hourly for active docs, daily for stable content"}),t("li",{children:"Monitor sync failures and set up alerts for critical sources"}),t("li",{children:"Test sources in sandbox before enabling in production"}),t("li",{children:"Document the purpose and ownership of each source for your team"}),t("li",{children:"Use manual sync for sensitive or infrequently updated content"})]})]}),l("div",{className:"flex items-center gap-4 pt-4",children:[t(w,{href:"/docs/knowledge/spaces",className:"btn-ghost",children:"Previous: Spaces"}),l(w,{href:"/docs/knowledge/examples",className:"btn-primary",children:["Examples ",t(E,{size:16})]})]})]})}import y from"@contractspec/lib.ui-link";import{ChevronRight as B}from"lucide-react";import{jsx as o,jsxs as r}from"react/jsx-runtime";function H(){return r("div",{className:"space-y-8",children:[r("div",{className:"space-y-4",children:[o("h1",{className:"font-bold text-4xl",children:"Knowledge Spaces"}),r("p",{className:"text-muted-foreground",children:["A ",o("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."]})]}),r("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"KnowledgeSpaceSpec"}),o("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:o("pre",{children:`type KnowledgeSpaceSpec = {
344
+ }`})})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Processing pipeline"}),a("p",{className:"text-muted-foreground",children:"When a source is synced, ContractSpec processes it through several stages:"}),r("ol",{className:"list-inside list-decimal space-y-3 text-muted-foreground",children:[r("li",{children:[a("strong",{children:"Fetch"})," - Retrieve content from source (API, database, file)"]}),r("li",{children:[a("strong",{children:"Parse"})," - Extract text from documents (PDF, Word, HTML)"]}),r("li",{children:[a("strong",{children:"Chunk"})," - Split into semantic chunks (paragraphs, sections)"]}),r("li",{children:[a("strong",{children:"Embed"})," - Generate vector embeddings (OpenAI, Cohere)"]}),r("li",{children:[a("strong",{children:"Index"})," - Store in vector database (Qdrant) or search engine"]}),r("li",{children:[a("strong",{children:"Audit"})," - Log sync operation and results"]})]})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Provider delta state"}),r("p",{className:"text-muted-foreground",children:["Runtime-backed providers should persist a"," ",a("strong",{children:"ProviderDeltaSyncState"})," per source before sync work is acknowledged. Gmail and Google Drive adapters use that checkpoint to resume cursors, renew watches, skip tombstones, dedupe webhook events, and replay from a known point after retries."]}),a("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:a("pre",{children:`type ProviderDeltaSyncState = {
345
+ lease?: { holder: string; expiresAt: string; renewalWindowMs: number };
346
+ cursor?: { cursor?: string; watermark?: string; watermarkVersion?: string };
347
+ webhookChannel?: { channelId: string; resourceId?: string; expiresAt?: string };
348
+ providerEventId?: string;
349
+ dedupeKey?: string;
350
+ idempotencyKey?: string;
351
+ replayCheckpoint?: { checkpointId: string; sequence?: string | number };
352
+ tombstone?: { deletedAt: string; reason?: string };
353
+ };`})}),r("div",{className:"flex flex-wrap gap-3",children:[a(u,{href:"/docs/integrations/gmail",className:"btn-ghost",children:"Gmail integration"}),a(u,{href:"/docs/integrations/google-drive",className:"btn-ghost",children:"Google Drive integration"}),a(u,{href:"/docs/guides/provider-backed-knowledge",className:"btn-ghost",children:"Provider-backed guide"})]})]}),r("div",{className:"space-y-4",children:[a("h2",{className:"font-bold text-2xl",children:"Best practices"}),r("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[a("li",{children:"Use webhooks for real-time sources (Notion, Gmail) to minimize latency"}),a("li",{children:"Set appropriate sync intervals - hourly for active docs, daily for stable content"}),a("li",{children:"Monitor sync failures and set up alerts for critical sources"}),a("li",{children:"Test sources in sandbox before enabling in production"}),a("li",{children:"Document the purpose and ownership of each source for your team"}),a("li",{children:"Use manual sync for sensitive or infrequently updated content"}),r("li",{children:["Run external mutations through"," ",a(u,{href:"/docs/knowledge/governance",className:"text-primary",children:"knowledge mutation governance"})," ","before sending email, changing Drive permissions, or repairing replay state."]})]})]}),r("div",{className:"flex items-center gap-4 pt-4",children:[a(u,{href:"/docs/knowledge/spaces",className:"btn-ghost",children:"Previous: Spaces"}),r(u,{href:"/docs/knowledge/examples",className:"btn-primary",children:["Examples ",a(M,{size:16})]})]})]})}import b from"@contractspec/lib.ui-link";import{ChevronRight as S}from"lucide-react";import{jsx as o,jsxs as n}from"react/jsx-runtime";function T(){return n("div",{className:"space-y-8",children:[n("div",{className:"space-y-4",children:[o("h1",{className:"font-bold text-4xl",children:"Knowledge Spaces"}),n("p",{className:"text-muted-foreground",children:["A ",o("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."]})]}),n("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"KnowledgeSpaceSpec"}),o("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:o("pre",{children:`type KnowledgeSpaceSpec = {
324
354
  id: string;
325
355
  label: string;
326
356
  description: string;
@@ -345,7 +375,7 @@ steps:
345
375
  owner?: string;
346
376
  createdAt: string;
347
377
  updatedAt: string;
348
- };`})})]}),r("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Common knowledge spaces"}),r("div",{className:"space-y-6",children:[r("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Product Canon"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
378
+ };`})})]}),n("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Common knowledge spaces"}),n("div",{className:"space-y-6",children:[n("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Product Canon"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
349
379
  id: "product-canon",
350
380
  label: "Product Canon",
351
381
  description: "Official product specifications and schemas",
@@ -355,7 +385,7 @@ steps:
355
385
  indexProvider: "qdrant",
356
386
  vectorDimensions: 1536,
357
387
  retentionPolicy: { versions: 10 }
358
- }`})}),r("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Invoice generation, quote creation, product recommendations, schema validation"]})]}),r("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Support History"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
388
+ }`})}),n("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Invoice generation, quote creation, product recommendations, schema validation"]})]}),n("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Support History"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
359
389
  id: "support-history",
360
390
  label: "Support History",
361
391
  description: "Past support tickets and resolutions",
@@ -365,7 +395,7 @@ steps:
365
395
  indexProvider: "qdrant",
366
396
  vectorDimensions: 1536,
367
397
  retentionPolicy: { days: 365 }
368
- }`})}),r("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Customer support, troubleshooting, similar issue detection"]})]}),r("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"External Provider Docs"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
398
+ }`})}),n("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Customer support, troubleshooting, similar issue detection"]})]}),n("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"External Provider Docs"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
369
399
  id: "provider-docs",
370
400
  label: "External Provider Docs",
371
401
  description: "Third-party integration documentation",
@@ -374,7 +404,7 @@ steps:
374
404
  storageStrategy: "search",
375
405
  indexProvider: "elasticsearch",
376
406
  retentionPolicy: { days: 90 }
377
- }`})}),r("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Integration help, API reference, troubleshooting external services"]})]}),r("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Agent Scratchpad"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
407
+ }`})}),n("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Integration help, API reference, troubleshooting external services"]})]}),n("div",{className:"card-subtle p-4",children:[o("h3",{className:"mb-2 font-semibold text-lg",children:"Agent Scratchpad"}),o("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:o("pre",{children:`{
378
408
  id: "agent-scratchpad",
379
409
  label: "Agent Scratchpad",
380
410
  description: "Temporary agent working memory",
@@ -384,4 +414,4 @@ steps:
384
414
  indexProvider: "qdrant",
385
415
  vectorDimensions: 1536,
386
416
  retentionPolicy: { days: 1 }
387
- }`})}),r("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Conversation continuity, intermediate calculations, session state"]})]})]})]}),r("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Storage strategies"}),o("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:r("table",{className:"w-full text-left text-sm",children:[o("thead",{className:"bg-card/50",children:r("tr",{className:"border-border/50 border-b",children:[o("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),o("th",{className:"px-4 py-3 font-semibold",children:"Best For"}),o("th",{className:"px-4 py-3 font-semibold",children:"Providers"})]})}),r("tbody",{className:"divide-y divide-border/50",children:[r("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"vector"}),o("td",{className:"px-4 py-3",children:"Semantic search, RAG, similarity matching"}),o("td",{className:"px-4 py-3",children:"Qdrant, Pinecone, Weaviate"})]}),r("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"search"}),o("td",{className:"px-4 py-3",children:"Keyword search, exact matching, filtering"}),o("td",{className:"px-4 py-3",children:"Elasticsearch, Algolia"})]}),r("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"hybrid"}),o("td",{className:"px-4 py-3",children:"Combined semantic + keyword search"}),o("td",{className:"px-4 py-3",children:"Qdrant + Elasticsearch"})]})]})]})})]}),r("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Best practices"}),r("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[o("li",{children:"Choose storage strategy based on query patterns - use vector for semantic, search for exact"}),o("li",{children:"Set appropriate retention policies - canonical is permanent, ephemeral is short-lived"}),o("li",{children:"Use consistent vector dimensions across spaces that will be queried together"}),o("li",{children:"Document the intended audience and use cases for each space"}),o("li",{children:"Monitor space size and query performance - add sharding if needed"})]})]}),r("div",{className:"flex items-center gap-4 pt-4",children:[o(y,{href:"/docs/knowledge/categories",className:"btn-ghost",children:"Previous: Categories"}),r(y,{href:"/docs/knowledge/sources",className:"btn-primary",children:["Knowledge Sources ",o(B,{size:16})]})]})]})}export{H as KnowledgeSpacesPage,A as KnowledgeSourcesPage,D as KnowledgeOverviewPage,P as KnowledgeExamplesPage,b as KnowledgeCategoriesPage};
417
+ }`})}),n("p",{className:"mt-2 text-muted-foreground text-sm",children:[o("strong",{children:"Use cases:"})," Conversation continuity, intermediate calculations, session state"]})]})]})]}),n("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Storage strategies"}),o("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:n("table",{className:"w-full text-left text-sm",children:[o("thead",{className:"bg-card/50",children:n("tr",{className:"border-border/50 border-b",children:[o("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),o("th",{className:"px-4 py-3 font-semibold",children:"Best For"}),o("th",{className:"px-4 py-3 font-semibold",children:"Providers"})]})}),n("tbody",{className:"divide-y divide-border/50",children:[n("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"vector"}),o("td",{className:"px-4 py-3",children:"Semantic search, RAG, similarity matching"}),o("td",{className:"px-4 py-3",children:"Qdrant, Pinecone, Weaviate"})]}),n("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"search"}),o("td",{className:"px-4 py-3",children:"Keyword search, exact matching, filtering"}),o("td",{className:"px-4 py-3",children:"Elasticsearch, Algolia"})]}),n("tr",{children:[o("td",{className:"px-4 py-3 font-mono text-xs",children:"hybrid"}),o("td",{className:"px-4 py-3",children:"Combined semantic + keyword search"}),o("td",{className:"px-4 py-3",children:"Qdrant + Elasticsearch"})]})]})]})})]}),n("div",{className:"space-y-4",children:[o("h2",{className:"font-bold text-2xl",children:"Best practices"}),n("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[o("li",{children:"Choose storage strategy based on query patterns - use vector for semantic, search for exact"}),o("li",{children:"Set appropriate retention policies - canonical is permanent, ephemeral is short-lived"}),o("li",{children:"Use consistent vector dimensions across spaces that will be queried together"}),o("li",{children:"Document the intended audience and use cases for each space"}),o("li",{children:"Monitor space size and query performance - add sharding if needed"})]})]}),n("div",{className:"flex items-center gap-4 pt-4",children:[o(b,{href:"/docs/knowledge/categories",className:"btn-ghost",children:"Previous: Categories"}),n(b,{href:"/docs/knowledge/sources",className:"btn-primary",children:["Knowledge Sources ",o(S,{size:16})]})]})]})}export{T as KnowledgeSpacesPage,B as KnowledgeSourcesPage,I as KnowledgeOverviewPage,D as KnowledgeGovernancePage,q as KnowledgeExamplesPage,E as KnowledgeCategoriesPage};