@lucern/sdk 0.2.0-alpha.1 → 0.2.0-alpha.10

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 (275) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +691 -61
  3. package/dist/adminClient.d.ts +409 -0
  4. package/dist/adminClient.js +755 -0
  5. package/dist/adminClient.js.map +1 -0
  6. package/dist/answersClient.d.ts +23 -0
  7. package/dist/answersClient.js +333 -0
  8. package/dist/answersClient.js.map +1 -0
  9. package/dist/{packages/sdk/src/audiencesClient.d.ts → audiencesClient.d.ts} +30 -18
  10. package/dist/audiencesClient.js +472 -0
  11. package/dist/audiencesClient.js.map +1 -0
  12. package/dist/auditClient.d.ts +29 -0
  13. package/dist/auditClient.js +386 -0
  14. package/dist/auditClient.js.map +1 -0
  15. package/dist/beliefsClient.d.ts +242 -0
  16. package/dist/beliefsClient.js +616 -0
  17. package/dist/beliefsClient.js.map +1 -0
  18. package/dist/client.d.ts +2398 -0
  19. package/dist/client.js +6378 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/contextClient.d.ts +27 -0
  22. package/dist/contextClient.js +396 -0
  23. package/dist/contextClient.js.map +1 -0
  24. package/dist/contextFacade.d.ts +2 -0
  25. package/dist/contextFacade.js +73 -0
  26. package/dist/contextFacade.js.map +1 -0
  27. package/dist/{lucern/packages/domain-context/src/context-pack-compiler.d.ts → contextPackCompiler.d.ts} +11 -10
  28. package/dist/contextPackCompiler.js +1091 -0
  29. package/dist/contextPackCompiler.js.map +1 -0
  30. package/dist/contextPackPolicy.d.ts +84 -0
  31. package/dist/contextPackPolicy.js +347 -0
  32. package/dist/contextPackPolicy.js.map +1 -0
  33. package/dist/contextPackSchema.d.ts +7 -0
  34. package/dist/contextPackSchema.js +203 -0
  35. package/dist/contextPackSchema.js.map +1 -0
  36. package/dist/contextTypes.d.ts +135 -0
  37. package/dist/contextTypes.js +3 -0
  38. package/dist/contextTypes.js.map +1 -0
  39. package/dist/contracts/api-enums.contract.d.ts +81 -0
  40. package/dist/contracts/api-enums.contract.js +98 -0
  41. package/dist/contracts/api-enums.contract.js.map +1 -0
  42. package/dist/{lucern/contracts/src → contracts}/auth-session.contract.d.ts +14 -12
  43. package/dist/contracts/auth-session.contract.js +48 -0
  44. package/dist/contracts/auth-session.contract.js.map +1 -0
  45. package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
  46. package/dist/contracts/context-pack.contract.js +98 -0
  47. package/dist/contracts/context-pack.contract.js.map +1 -0
  48. package/dist/contracts/contextPack.d.ts +1 -0
  49. package/dist/contracts/contextPack.js +98 -0
  50. package/dist/contracts/contextPack.js.map +1 -0
  51. package/dist/contracts/index.d.ts +9 -0
  52. package/dist/contracts/index.js +4928 -0
  53. package/dist/contracts/index.js.map +1 -0
  54. package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
  55. package/dist/contracts/lens-filter.contract.js +71 -0
  56. package/dist/contracts/lens-filter.contract.js.map +1 -0
  57. package/dist/contracts/lens-workflow.contract.d.ts +87 -0
  58. package/dist/contracts/lens-workflow.contract.js +123 -0
  59. package/dist/contracts/lens-workflow.contract.js.map +1 -0
  60. package/dist/contracts/lensFilter.d.ts +1 -0
  61. package/dist/contracts/lensFilter.js +71 -0
  62. package/dist/contracts/lensFilter.js.map +1 -0
  63. package/dist/contracts/lensWorkflow.d.ts +2 -0
  64. package/dist/contracts/lensWorkflow.js +123 -0
  65. package/dist/contracts/lensWorkflow.js.map +1 -0
  66. package/dist/contracts/mcp-tools.contract.d.ts +1 -0
  67. package/dist/contracts/mcp-tools.contract.js +3016 -0
  68. package/dist/contracts/mcp-tools.contract.js.map +1 -0
  69. package/dist/contracts/mcpTools.d.ts +1 -0
  70. package/dist/contracts/mcpTools.js +3016 -0
  71. package/dist/contracts/mcpTools.js.map +1 -0
  72. package/dist/contracts/prompt.contract.d.ts +26 -0
  73. package/dist/contracts/prompt.contract.js +12 -0
  74. package/dist/contracts/prompt.contract.js.map +1 -0
  75. package/dist/contracts/prompt.d.ts +1 -0
  76. package/dist/contracts/prompt.js +12 -0
  77. package/dist/contracts/prompt.js.map +1 -0
  78. package/dist/contracts/sdk-tools.contract.d.ts +2 -0
  79. package/dist/contracts/sdk-tools.contract.js +4164 -0
  80. package/dist/contracts/sdk-tools.contract.js.map +1 -0
  81. package/dist/contracts/sdkTools.d.ts +2 -0
  82. package/dist/contracts/sdkTools.js +4164 -0
  83. package/dist/contracts/sdkTools.js.map +1 -0
  84. package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
  85. package/dist/contracts/workflow-runtime.contract.js +245 -0
  86. package/dist/contracts/workflow-runtime.contract.js.map +1 -0
  87. package/dist/contracts/workflowRuntime.d.ts +1 -0
  88. package/dist/contracts/workflowRuntime.js +245 -0
  89. package/dist/contracts/workflowRuntime.js.map +1 -0
  90. package/dist/{packages/sdk/src/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +35 -18
  91. package/dist/controlObjectOwnership.js +215 -0
  92. package/dist/controlObjectOwnership.js.map +1 -0
  93. package/dist/{packages/sdk/src/coreClient.d.ts → coreClient.d.ts} +38 -14
  94. package/dist/coreClient.js +339 -0
  95. package/dist/coreClient.js.map +1 -0
  96. package/dist/customTools.d.ts +88 -0
  97. package/dist/customTools.js +248 -0
  98. package/dist/customTools.js.map +1 -0
  99. package/dist/decisionsClient.d.ts +111 -0
  100. package/dist/decisionsClient.js +522 -0
  101. package/dist/decisionsClient.js.map +1 -0
  102. package/dist/domainContext.d.ts +1 -0
  103. package/dist/domainContext.js +3 -0
  104. package/dist/domainContext.js.map +1 -0
  105. package/dist/events.d.ts +178 -0
  106. package/dist/events.js +249 -0
  107. package/dist/events.js.map +1 -0
  108. package/dist/eventsCore.d.ts +49 -0
  109. package/dist/eventsCore.js +429 -0
  110. package/dist/eventsCore.js.map +1 -0
  111. package/dist/evidenceClient.d.ts +119 -0
  112. package/dist/evidenceClient.js +350 -0
  113. package/dist/evidenceClient.js.map +1 -0
  114. package/dist/facade/context.d.ts +18 -0
  115. package/dist/facade/context.js +73 -0
  116. package/dist/facade/context.js.map +1 -0
  117. package/dist/gatewayFacades.d.ts +589 -0
  118. package/dist/gatewayFacades.js +1976 -0
  119. package/dist/gatewayFacades.js.map +1 -0
  120. package/dist/graphClient.d.ts +271 -0
  121. package/dist/graphClient.js +698 -0
  122. package/dist/graphClient.js.map +1 -0
  123. package/dist/{packages/sdk/src/harnessClient.d.ts → harnessClient.d.ts} +127 -35
  124. package/dist/harnessClient.js +607 -0
  125. package/dist/harnessClient.js.map +1 -0
  126. package/dist/identityClient.d.ts +140 -0
  127. package/dist/identityClient.js +497 -0
  128. package/dist/identityClient.js.map +1 -0
  129. package/dist/index.d.ts +45 -0
  130. package/dist/index.js +5263 -2579
  131. package/dist/index.js.map +1 -1
  132. package/dist/learningClient.d.ts +46 -0
  133. package/dist/learningClient.js +409 -0
  134. package/dist/learningClient.js.map +1 -0
  135. package/dist/{packages/sdk/src/mcpParityClient.d.ts → mcpParityClient.d.ts} +11 -5
  136. package/dist/mcpParityClient.js +516 -0
  137. package/dist/mcpParityClient.js.map +1 -0
  138. package/dist/mcpParitySurface.d.ts +12 -0
  139. package/dist/mcpParitySurface.js +65 -0
  140. package/dist/mcpParitySurface.js.map +1 -0
  141. package/dist/mcpTools-DPZxowDX.d.ts +254 -0
  142. package/dist/{packages/sdk/src/ontologyClient.d.ts → ontologyClient.d.ts} +44 -22
  143. package/dist/ontologyClient.js +513 -0
  144. package/dist/ontologyClient.js.map +1 -0
  145. package/dist/packRuntime.d.ts +2 -0
  146. package/dist/packRuntime.js +3 -0
  147. package/dist/packRuntime.js.map +1 -0
  148. package/dist/packsClient.d.ts +131 -0
  149. package/dist/packsClient.js +525 -0
  150. package/dist/packsClient.js.map +1 -0
  151. package/dist/{packages/sdk/src/policyClient.d.ts → policyClient.d.ts} +113 -18
  152. package/dist/policyClient.js +625 -0
  153. package/dist/policyClient.js.map +1 -0
  154. package/dist/realtime/index.d.ts +29 -0
  155. package/dist/realtime/index.js +23 -0
  156. package/dist/realtime/index.js.map +1 -0
  157. package/dist/realtime/refs.d.ts +17 -0
  158. package/dist/realtime/refs.js +9 -0
  159. package/dist/realtime/refs.js.map +1 -0
  160. package/dist/reportsClient.d.ts +41 -0
  161. package/dist/reportsClient.js +418 -0
  162. package/dist/reportsClient.js.map +1 -0
  163. package/dist/schemaClient.d.ts +64 -0
  164. package/dist/schemaClient.js +434 -0
  165. package/dist/schemaClient.js.map +1 -0
  166. package/dist/sdkSurface.d.ts +61 -0
  167. package/dist/sdkSurface.js +112 -0
  168. package/dist/sdkSurface.js.map +1 -0
  169. package/dist/sdkTools-CwXJDACb.d.ts +150 -0
  170. package/dist/sourcesClient.d.ts +24 -0
  171. package/dist/sourcesClient.js +339 -0
  172. package/dist/sourcesClient.js.map +1 -0
  173. package/dist/topicsClient.d.ts +84 -0
  174. package/dist/topicsClient.js +492 -0
  175. package/dist/topicsClient.js.map +1 -0
  176. package/dist/types.d.ts +715 -0
  177. package/dist/types.js +3 -0
  178. package/dist/types.js.map +1 -0
  179. package/dist/version.d.ts +4 -0
  180. package/dist/version.js +6 -0
  181. package/dist/version.js.map +1 -0
  182. package/dist/workflowClient.d.ts +316 -0
  183. package/dist/workflowClient.js +830 -0
  184. package/dist/workflowClient.js.map +1 -0
  185. package/package.json +41 -37
  186. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  187. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  188. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
  189. package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +0 -119
  190. package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +0 -18
  191. package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +0 -78
  192. package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +0 -53
  193. package/dist/lucern/packages/client-core/src/beliefs.d.ts +0 -30
  194. package/dist/lucern/packages/client-core/src/context.d.ts +0 -29
  195. package/dist/lucern/packages/client-core/src/contradictions.d.ts +0 -11
  196. package/dist/lucern/packages/client-core/src/edges.d.ts +0 -11
  197. package/dist/lucern/packages/client-core/src/events.d.ts +0 -9
  198. package/dist/lucern/packages/client-core/src/evidence.d.ts +0 -21
  199. package/dist/lucern/packages/client-core/src/graph.d.ts +0 -17
  200. package/dist/lucern/packages/client-core/src/identity.d.ts +0 -7
  201. package/dist/lucern/packages/client-core/src/ids.d.ts +0 -7
  202. package/dist/lucern/packages/client-core/src/ontologies.d.ts +0 -13
  203. package/dist/lucern/packages/client-core/src/questions.d.ts +0 -39
  204. package/dist/lucern/packages/client-core/src/search.d.ts +0 -7
  205. package/dist/lucern/packages/client-core/src/tasks.d.ts +0 -13
  206. package/dist/lucern/packages/client-core/src/topics.d.ts +0 -17
  207. package/dist/lucern/packages/client-core/src/webhooks.d.ts +0 -35
  208. package/dist/lucern/packages/client-core/src/worktrees.d.ts +0 -17
  209. package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +0 -283
  210. package/dist/lucern/packages/domain-beliefs/src/index.d.ts +0 -1
  211. package/dist/lucern/packages/domain-context/src/compile.d.ts +0 -11
  212. package/dist/lucern/packages/domain-context/src/index.d.ts +0 -4
  213. package/dist/lucern/packages/domain-context/src/ports.d.ts +0 -58
  214. package/dist/lucern/packages/domain-context/src/public-types.d.ts +0 -1
  215. package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +0 -59
  216. package/dist/lucern/packages/domain-edges/src/edges.d.ts +0 -91
  217. package/dist/lucern/packages/domain-edges/src/index.d.ts +0 -2
  218. package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +0 -115
  219. package/dist/lucern/packages/domain-evidence/src/index.d.ts +0 -1
  220. package/dist/lucern/packages/domain-graph/src/graph.d.ts +0 -150
  221. package/dist/lucern/packages/domain-identity/src/index.d.ts +0 -1
  222. package/dist/lucern/packages/domain-identity/src/whoami.d.ts +0 -13
  223. package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +0 -123
  224. package/dist/lucern/packages/domain-questions/src/index.d.ts +0 -1
  225. package/dist/lucern/packages/domain-questions/src/questions.d.ts +0 -147
  226. package/dist/lucern/packages/domain-search/src/search.d.ts +0 -97
  227. package/dist/lucern/packages/domain-tasks/src/index.d.ts +0 -1
  228. package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +0 -102
  229. package/dist/lucern/packages/domain-topics/src/index.d.ts +0 -1
  230. package/dist/lucern/packages/domain-topics/src/topics.d.ts +0 -147
  231. package/dist/lucern/packages/domain-worktrees/src/index.d.ts +0 -1
  232. package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +0 -185
  233. package/dist/lucern/packages/events/src/index.d.ts +0 -4
  234. package/dist/lucern/packages/events/src/matching.d.ts +0 -3
  235. package/dist/lucern/packages/events/src/outbox.d.ts +0 -15
  236. package/dist/lucern/packages/events/src/types.d.ts +0 -151
  237. package/dist/lucern/packages/events/src/webhooks.d.ts +0 -9
  238. package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +0 -15
  239. package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +0 -12
  240. package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +0 -7
  241. package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +0 -7
  242. package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +0 -6
  243. package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +0 -21
  244. package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +0 -10
  245. package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +0 -5
  246. package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +0 -8
  247. package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +0 -39
  248. package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +0 -5
  249. package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +0 -8
  250. package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +0 -10
  251. package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +0 -16
  252. package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +0 -10
  253. package/dist/lucern/packages/sdk-typescript/src/index.d.ts +0 -28
  254. package/dist/packages/sdk/src/adminClient.d.ts +0 -89
  255. package/dist/packages/sdk/src/answersClient.d.ts +0 -5
  256. package/dist/packages/sdk/src/auditClient.d.ts +0 -23
  257. package/dist/packages/sdk/src/beliefsClient.d.ts +0 -54
  258. package/dist/packages/sdk/src/client.d.ts +0 -1610
  259. package/dist/packages/sdk/src/contextClient.d.ts +0 -9
  260. package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +0 -58
  261. package/dist/packages/sdk/src/customTools.d.ts +0 -65
  262. package/dist/packages/sdk/src/decisionsClient.d.ts +0 -110
  263. package/dist/packages/sdk/src/graphClient.d.ts +0 -209
  264. package/dist/packages/sdk/src/identityClient.d.ts +0 -104
  265. package/dist/packages/sdk/src/index.d.ts +0 -28
  266. package/dist/packages/sdk/src/learningClient.d.ts +0 -43
  267. package/dist/packages/sdk/src/mcpParitySurface.d.ts +0 -8
  268. package/dist/packages/sdk/src/packsClient.d.ts +0 -101
  269. package/dist/packages/sdk/src/reportsClient.d.ts +0 -31
  270. package/dist/packages/sdk/src/schemaClient.d.ts +0 -54
  271. package/dist/packages/sdk/src/sdkSurface.d.ts +0 -56
  272. package/dist/packages/sdk/src/topicsClient.d.ts +0 -45
  273. package/dist/packages/sdk/src/types.d.ts +0 -489
  274. package/dist/packages/sdk/src/version.d.ts +0 -2
  275. package/dist/packages/sdk/src/workflowClient.d.ts +0 -274
package/README.md CHANGED
@@ -1,97 +1,727 @@
1
1
  # @lucern/sdk
2
2
 
3
- TypeScript SDK for the Lucern reasoning platform.
3
+ The reasoning operating system for AI-native applications.
4
4
 
5
- ## Package status
5
+ Your AI agent reads 50 documents, generates insights, and forgets everything by tomorrow. Every session starts from zero. The same questions get re-investigated. The same dead ends get explored. Nothing compounds.
6
6
 
7
- - Distribution target: private/internal registry
8
- - License: UNLICENSED
9
- - Auth model: service principal key via `LUCERN_API_KEY`
10
-
11
- ## Install
7
+ Lucern gives your agents a reasoning graph that accumulates understanding across sessions, across agents, and across time. Beliefs have confidence scores that change as evidence arrives. Contradictions are detected and tracked. Investigations are structured with hypotheses, evidence, and outcomes. Every mutation is traceable, every decision auditable.
12
8
 
13
9
  ```bash
14
- export NODE_AUTH_TOKEN="<your-package-token>"
15
- cat <<'EOF' > .npmrc
16
- @lucern:registry=https://npm.pkg.github.com
17
- //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
18
- EOF
19
-
20
10
  npm install @lucern/sdk
21
11
  ```
22
12
 
23
- ## Quickstart
13
+ ## Canonical Interface
14
+
15
+ `@lucern/sdk` is the canonical public interface for Lucern.
16
+
17
+ - Build applications, automations, and backend integrations against the SDK first.
18
+ - Treat `/api/platform/v1/*` as the transport mirror of the SDK surface.
19
+ - Treat MCP as an agent-facing client of the same surface, not as a privileged bypass around SDK or HTTP semantics.
20
+
21
+ IA-7 closes the remaining SDK surface gaps needed for SDK-first clients:
22
+
23
+ - Kernel mutations that previously only existed behind route or MCP adapters now have SDK wrappers across beliefs, evidence, questions, edges, topics, worktrees, and nodes.
24
+ - `lucern.identity.whoami()` exposes resolved principal context for service principals, tenant API keys, and interactive users.
25
+ - Public SDK types now export `SdkPrincipalContext` plus the `Platform*Record` and `Workflow*Record` families for typed client code.
26
+
27
+ ```typescript
28
+ import {
29
+ createLucernClient,
30
+ type PlatformBeliefRecord,
31
+ type SdkPrincipalContext,
32
+ type WorkflowWorktreeRecord,
33
+ } from "@lucern/sdk";
34
+
35
+ const lucern = createLucernClient({
36
+ apiKey: process.env.LUCERN_API_KEY,
37
+ baseUrl: "https://api.lucern.ai",
38
+ });
39
+
40
+ const identity = await lucern.identity.whoami();
41
+ const principal: SdkPrincipalContext = identity.data;
42
+ ```
43
+
44
+ ## The Full Developer Journey
45
+
46
+ This walkthrough mirrors what a developer building an AI-powered code review system would experience in a real coding session. Every API call is something you would actually use.
47
+
48
+ ### 1. Set Up Your Reasoning Scope
49
+
50
+ Topics are how you organize knowledge. They nest hierarchically, like folders that think.
24
51
 
25
- ```ts
52
+ ```typescript
26
53
  import { createLucernClient } from "@lucern/sdk";
27
54
 
28
55
  const lucern = createLucernClient({
29
56
  apiKey: process.env.LUCERN_API_KEY,
30
- baseUrl: process.env.LUCERN_BASE_URL ?? process.env.LUCERN_API_BASE_URL,
57
+ baseUrl: "https://api.lucern.ai",
31
58
  });
32
59
 
33
- const projectList = await lucern.context.listProjects({ includeShared: true });
34
- const project = projectList.data.projects[0];
60
+ // Create a parent topic for your domain
61
+ const codeQuality = await lucern.topics.create({
62
+ name: "Code Quality Intelligence",
63
+ type: "domain",
64
+ });
35
65
 
36
- if (!project?.projectId) {
37
- throw new Error(
38
- "No graph project is available. Bootstrap or create one before running the SDK quickstart."
39
- );
40
- }
66
+ // Create child topics for specific areas
67
+ const securityTopic = await lucern.topics.create({
68
+ name: "Security Patterns",
69
+ type: "theme",
70
+ parentTopicId: codeQuality.data.topicId,
71
+ });
41
72
 
42
- const belief = await lucern.beliefs.create({
43
- canonicalText:
44
- "AI-native reasoning infrastructure will expand rapidly over 3 years",
45
- projectId: project.projectId,
73
+ const performanceTopic = await lucern.topics.create({
74
+ name: "Performance Patterns",
75
+ type: "theme",
76
+ parentTopicId: codeQuality.data.topicId,
46
77
  });
78
+ ```
79
+
80
+ ### 2. Populate the Graph With What You Know
47
81
 
48
- await lucern.beliefs.modulateConfidence(belief.data.nodeId, {
49
- confidence: 0.72,
82
+ Beliefs represent understanding at different epistemic levels: facts (verified), beliefs (confident), hypotheses (testing), and assumptions (untested).
83
+
84
+ ```typescript
85
+ const topicId = securityTopic.data.topicId;
86
+
87
+ // A fact — verified and anchored
88
+ const sqlFact = await lucern.beliefs.create({
89
+ topicId,
90
+ baseRate: 0.5,
91
+ canonicalText: "Parameterized queries prevent SQL injection in all major database drivers",
92
+ beliefType: "fact",
93
+ });
94
+ await lucern.beliefs.modulateConfidence(sqlFact.data.nodeId, {
95
+ confidence: 0.95,
50
96
  trigger: "evidence_added",
51
- rationale: "Two independent sources confirm demand pull.",
97
+ rationale: "OWASP verified, industry standard for 20+ years",
98
+ });
99
+
100
+ // A belief — confident from observation
101
+ const patternBelief = await lucern.beliefs.create({
102
+ topicId,
103
+ baseRate: 0.5,
104
+ canonicalText: "Most security vulnerabilities in our codebase come from unvalidated user input at API boundaries, not from cryptographic weaknesses",
105
+ });
106
+ await lucern.beliefs.modulateConfidence(patternBelief.data.nodeId, {
107
+ confidence: 0.82,
108
+ trigger: "evidence_added",
109
+ rationale: "Last 6 months of security audits: 14 input validation issues, 1 crypto issue",
110
+ });
111
+
112
+ // A hypothesis — under active testing
113
+ const hypothesis = await lucern.beliefs.create({
114
+ topicId,
115
+ baseRate: 0.5,
116
+ canonicalText: "Automated static analysis catches fewer than 30% of the input validation vulnerabilities that human reviewers find",
117
+ beliefType: "hypothesis",
118
+ });
119
+ await lucern.beliefs.modulateConfidence(hypothesis.data.nodeId, {
120
+ confidence: 0.6,
121
+ trigger: "manual",
122
+ rationale: "Anecdotal — need to run a proper comparison study",
123
+ });
124
+
125
+ // An assumption — untested but used as a basis for decisions
126
+ const assumption = await lucern.beliefs.create({
127
+ topicId,
128
+ baseRate: 0.5,
129
+ canonicalText: "Our CI pipeline runs all static analysis rules on every PR",
130
+ beliefType: "assumption",
131
+ });
132
+ ```
133
+
134
+ ### 3. Connect Beliefs With Edges
135
+
136
+ Edges express the reasoning relationships between beliefs.
137
+
138
+ ```typescript
139
+ // The pattern belief depends on the SQL injection fact
140
+ await lucern.graph.createEdge({
141
+ topicId,
142
+ sourceId: patternBelief.data.nodeId,
143
+ targetId: sqlFact.data.nodeId,
144
+ edgeType: "depends_on",
145
+ reasoning: "Input validation pattern includes SQL injection as a subclass",
146
+ reasoningMethod: "deductive",
147
+ });
148
+
149
+ // The hypothesis is derived from the pattern belief
150
+ await lucern.graph.createEdge({
151
+ topicId,
152
+ sourceId: hypothesis.data.nodeId,
153
+ targetId: patternBelief.data.nodeId,
154
+ edgeType: "derived_from",
155
+ reasoning: "If most vulns are input validation, and static analysis misses them, the tooling gap is at the input boundary",
156
+ reasoningMethod: "inductive",
157
+ });
158
+
159
+ // The hypothesis depends on an untested assumption
160
+ await lucern.graph.createEdge({
161
+ topicId,
162
+ sourceId: hypothesis.data.nodeId,
163
+ targetId: assumption.data.nodeId,
164
+ edgeType: "depends_on",
165
+ reasoning: "If the CI pipeline is not running all rules, the comparison would be invalid",
166
+ reasoningMethod: "deductive",
167
+ });
168
+ ```
169
+
170
+ ### 4. Open an Investigation With a Worktree
171
+
172
+ Worktrees are focused investigations — like a feature branch for knowledge. You test beliefs, gather evidence, and merge the findings.
173
+
174
+ ```typescript
175
+ const investigation = await lucern.worktrees.create({
176
+ topicId,
177
+ title: "Static analysis vs human review comparison",
178
+ hypothesis: "Running the same 50 PRs through both static analysis and manual review will show static analysis catches less than 30% of what humans find",
179
+ beliefIds: [hypothesis.data.nodeId],
180
+ });
181
+
182
+ // Create tasks to drive the investigation
183
+ await lucern.tasks.create({
184
+ topicId,
185
+ title: "Run Semgrep + CodeQL on the last 50 merged PRs and log findings",
186
+ linkedWorktreeId: investigation.data.worktreeId,
187
+ linkedQuestionId: comparisonQuestion.data.questionId,
188
+ taskType: "data_collection",
189
+ });
190
+
191
+ await lucern.tasks.create({
192
+ topicId,
193
+ title: "Have two senior engineers independently review the same 50 PRs",
194
+ linkedWorktreeId: investigation.data.worktreeId,
195
+ taskType: "research",
196
+ });
197
+ ```
198
+
199
+ ### 5. Add Evidence as You Work
200
+
201
+ Your agent processes the results and commits evidence to the graph.
202
+
203
+ ```typescript
204
+ // Static analysis results
205
+ await lucern.evidence.create({
206
+ topicId,
207
+ text: "Semgrep + CodeQL found 23 issues across 50 PRs. 18 were true positives. Categories: 12 input validation, 4 auth bypass patterns, 2 information disclosure.",
208
+ sourceUrl: "ci://semgrep-run/batch-50pr-comparison",
209
+ targetId: hypothesis.data.nodeId,
210
+ weight: 0.6, // partially supports
211
+ });
212
+
213
+ // Human review results
214
+ await lucern.evidence.create({
215
+ topicId,
216
+ text: "Two senior engineers found 41 issues across the same 50 PRs (34 unique after dedup). Categories: 22 input validation, 7 business logic flaws, 3 auth, 2 race conditions.",
217
+ sourceUrl: "review://manual-audit/batch-50pr",
218
+ targetId: hypothesis.data.nodeId,
219
+ weight: 0.9, // strongly supports — 18/34 = 53%, even worse than hypothesized
220
+ });
221
+
222
+ // Answer the question with data
223
+ const comparisonQuestion = await lucern.questions.create({
224
+ topicId,
225
+ text: "What percentage of vulnerabilities does static analysis catch compared to human reviewers?",
226
+ priority: "high",
227
+ linkedBeliefId: hypothesis.data.nodeId,
228
+ });
229
+
230
+ await lucern.questions.answer(comparisonQuestion.data.questionId, {
231
+ text: "Static analysis caught 18 of 34 unique issues (53%). However, it missed all 7 business logic flaws and both race conditions — categories where it found 0%.",
232
+ confidence: "strong",
233
+ evidenceIds: [staticEvidence.data.nodeId, humanEvidence.data.nodeId],
234
+ });
235
+ ```
236
+
237
+ ### 6. Fork a Belief When Understanding Evolves
238
+
239
+ The original hypothesis said "less than 30%." The data shows 53% — but the story is more nuanced. Fork the belief to capture the evolved understanding.
240
+
241
+ ```typescript
242
+ // Drop confidence on the original (it was too pessimistic about overall catch rate)
243
+ await lucern.beliefs.modulateConfidence(hypothesis.data.nodeId, {
244
+ confidence: 0.2,
245
+ trigger: "evidence_added",
246
+ rationale: "Static analysis catches 53% overall, not <30%. But the category breakdown reveals something more important.",
247
+ });
248
+
249
+ // Fork into a more precise belief
250
+ const evolved = await lucern.beliefs.fork(hypothesis.data.nodeId, {
251
+ newFormulation: "Static analysis catches 53% of vulnerabilities overall, but has a complete blind spot for business logic flaws and race conditions — the hardest categories to detect",
252
+ forkReason: "refinement",
253
+ });
254
+
255
+ await lucern.beliefs.modulateConfidence(evolved.data.nodeId, {
256
+ confidence: 0.88,
257
+ trigger: "evidence_added",
258
+ rationale: "Direct comparison data: 0/7 business logic flaws caught, 0/2 race conditions caught, while input validation catch rate was 12/22 (55%)",
259
+ });
260
+
261
+ // This creates a new actionable belief
262
+ const actionable = await lucern.beliefs.create({
263
+ topicId,
264
+ baseRate: 0.5,
265
+ canonicalText: "Human code review should focus on business logic and concurrency — the categories where static analysis provides zero coverage",
266
+ beliefType: "belief",
267
+ });
268
+
269
+ await lucern.beliefs.modulateConfidence(actionable.data.nodeId, {
270
+ confidence: 0.85,
271
+ trigger: "worktree_outcome",
272
+ rationale: "Direct implication of the comparison study findings",
273
+ });
274
+
275
+ // Link them
276
+ await lucern.graph.createEdge({
277
+ topicId,
278
+ sourceId: actionable.data.nodeId,
279
+ targetId: evolved.data.nodeId,
280
+ edgeType: "derived_from",
281
+ reasoning: "The review focus recommendation follows directly from the coverage gap data",
282
+ reasoningMethod: "deductive",
283
+ });
284
+ ```
285
+
286
+ ### 7. Compile Context for Your Next Agent Session
287
+
288
+ Before your agent starts its next session, it reads the graph:
289
+
290
+ ```typescript
291
+ const context = await lucern.context.compile(topicId, {
292
+ query: "code review strategy and static analysis coverage",
293
+ ranking: "weighted_v1",
294
+ tokenBudget: 2000,
295
+ });
296
+
297
+ // context.data contains:
298
+ // - activeBeliefs: ranked by confidence and relevance
299
+ // - openQuestions: what still needs investigation
300
+ // - contradictions: tensions the agent should address
301
+ // - recentEvidence: latest findings for grounding
302
+
303
+ // Your agent starts from understanding, not from zero
304
+ console.log(`
305
+ ${context.data.summary.totalBeliefs} beliefs in scope
306
+ ${context.data.summary.openQuestions} open questions
307
+ ${context.data.summary.contradictions} unresolved contradictions
308
+ `);
309
+ ```
310
+
311
+ This is the compound intelligence loop. Every session reads the graph, reasons against it, and writes findings back. The graph gets smarter every cycle.
312
+
313
+ ---
314
+
315
+ ## Core Concepts
316
+
317
+ | Concept | What It Does |
318
+ |---------|-------------|
319
+ | **Topic** | Scopes reasoning into a domain. Topics nest hierarchically. |
320
+ | **Belief** | A statement with a confidence score. Types: fact, belief, hypothesis, assumption. |
321
+ | **Evidence** | A weighted fact linked to beliefs. Positive weight supports, negative contradicts. |
322
+ | **Question** | An open investigation. Linked to the belief it tests. |
323
+ | **Contradiction** | An explicit tension between two beliefs. May remain permanently unresolved. |
324
+ | **Worktree** | A focused investigation. Create hypotheses, gather evidence, merge findings. |
325
+ | **Edge** | A typed relationship: supports, informs, depends_on, derived_from, contains, tests. |
326
+ | **Confidence** | 0 to 1 score with append-only history. Every change has a trigger and rationale. |
327
+ | **Task** | Execution work linked to a question or worktree. |
328
+ | **Context Pack** | The graph compiled into ranked, budgeted context for LLM injection. |
329
+
330
+ ## SDK Surface
331
+
332
+ ```typescript
333
+ const lucern = createLucernClient({ apiKey, baseUrl });
334
+
335
+ lucern.beliefs // Create, fork, score, archive
336
+ lucern.evidence // Add weighted evidence, link to beliefs
337
+ lucern.questions // Ask, answer, track status
338
+ lucern.contradictions // Flag tensions between beliefs
339
+ lucern.topics // Nested topic hierarchy
340
+ lucern.worktrees // Focused investigations
341
+ lucern.graph // Edges, traversal, structural analysis
342
+ lucern.context // Compile graph into agent-ready context
343
+ lucern.ontologies // Domain vocabulary
344
+ lucern.tasks // Execution tracking
345
+ lucern.audit // Full mutation history
346
+ lucern.identity // API keys and sessions
347
+ ```
348
+
349
+ ## Graph Intelligence
350
+
351
+ The graph doesn't just store knowledge — it analyzes itself.
352
+
353
+ ### Structural Analysis
354
+
355
+ ```typescript
356
+ // Run the full analysis suite: PageRank, Louvain clustering,
357
+ // Tarjan SCC, spectral analysis, confirmation bias detection
358
+ const analysis = await lucern.graph.analyze({ topicId });
359
+
360
+ // Which beliefs are most central to your reasoning?
361
+ analysis.data.pageRank.topNodes.forEach(node => {
362
+ console.log(`${node.canonicalText} — centrality: ${node.score}`);
363
+ });
364
+
365
+ // Are there isolated belief clusters that should be connected?
366
+ analysis.data.communities.forEach(cluster => {
367
+ console.log(`Cluster "${cluster.label}": ${cluster.nodeCount} beliefs`);
368
+ });
369
+
370
+ // Any circular dependencies in your reasoning?
371
+ if (analysis.data.cycles.length > 0) {
372
+ console.warn(`Found ${analysis.data.cycles.length} circular reasoning chains`);
373
+ }
374
+ ```
375
+
376
+ ### Confirmation Bias Detection
377
+
378
+ ```typescript
379
+ // Are you only collecting evidence that supports your beliefs?
380
+ const bias = await lucern.graph.detectBias({ topicId });
381
+
382
+ bias.data.beliefs.forEach(b => {
383
+ if (b.riskLevel === "critical") {
384
+ console.warn(
385
+ `"${b.canonicalText}" has ${b.supportingEvidence} supporting ` +
386
+ `and ${b.contradictingEvidence} contradicting evidence — ` +
387
+ `one-sided evidence base`
388
+ );
389
+ }
390
+ });
391
+ ```
392
+
393
+ ### Find Gaps in Your Reasoning
394
+
395
+ ```typescript
396
+ // What beliefs have no evidence? What questions have no answers?
397
+ const gaps = await lucern.graph.findGaps({ topicId });
398
+
399
+ console.log(`Beliefs without evidence: ${gaps.data.unsupportedBeliefs.length}`);
400
+ console.log(`Beliefs without questions: ${gaps.data.untestedBeliefs.length}`);
401
+ console.log(`Orphan evidence: ${gaps.data.unlinkedEvidence.length}`);
402
+ ```
403
+
404
+ ### Falsification — What Would Disprove Your Beliefs?
405
+
406
+ ```typescript
407
+ // Generate the questions most likely to disprove your strongest beliefs
408
+ const questions = await lucern.graph.falsify({ topicId });
409
+
410
+ questions.data.forEach(q => {
411
+ console.log(`To disprove "${q.beliefText}", ask: "${q.question}"`);
412
+ });
413
+ ```
414
+
415
+ ### Traverse the Graph
416
+
417
+ ```typescript
418
+ // Walk the reasoning chain from a belief down to its evidence
419
+ const traversal = await lucern.graph.traverse({
420
+ startNodeId: belief.data.nodeId,
421
+ direction: "down", // L3 belief -> L2 evidence -> L1 sources
422
+ maxDepth: 3,
423
+ });
424
+
425
+ traversal.data.nodes.forEach(node => {
426
+ console.log(`[${node.epistemicLayer}] ${node.canonicalText}`);
52
427
  });
53
428
  ```
54
429
 
55
- ## Surface
430
+ ## LLM Integration Patterns
431
+
432
+ ### Inject Reasoning Context Into Any LLM Call
433
+
434
+ ```typescript
435
+ const context = await lucern.context.compile(topicId, {
436
+ query: "security review priorities",
437
+ ranking: "weighted_v1",
438
+ tokenBudget: 3000,
439
+ includeEntities: true,
440
+ });
441
+
442
+ // The context pack is structured for direct prompt injection
443
+ const systemPrompt = `
444
+ You are a security-focused code reviewer. Your reasoning state:
445
+
446
+ FACTS (high confidence, treat as ground truth):
447
+ ${context.data.invariants
448
+ .map(b => `- [${b.confidence}] ${b.canonicalText}`)
449
+ .join("\n")}
450
+
451
+ ACTIVE BELIEFS (current understanding, may evolve):
452
+ ${context.data.activeBeliefs
453
+ .map(b => `- [${b.confidence}] ${b.canonicalText}`)
454
+ .join("\n")}
455
+
456
+ OPEN QUESTIONS (unresolved — investigate these):
457
+ ${context.data.openQuestions
458
+ .map(q => `- [${q.priority}] ${q.text}`)
459
+ .join("\n")}
460
+
461
+ CONTRADICTIONS (tensions you must address):
462
+ ${context.data.contradictions
463
+ .map(c => `- [${c.severity}] ${c.description}`)
464
+ .join("\n")}
465
+
466
+ RULES:
467
+ - If your analysis contradicts an active belief, flag it explicitly
468
+ - If you discover evidence for an open question, answer it
469
+ - Never silently override a high-confidence belief without evidence
470
+ - When uncertain, create a new question rather than stating a conclusion
471
+ `;
472
+ ```
473
+
474
+ ### Let the LLM Write Back to the Graph
475
+
476
+ ```typescript
477
+ // After your LLM generates analysis, parse its output
478
+ // and write structured findings back to the graph
479
+
480
+ const findings = await llm.generate({
481
+ system: systemPrompt,
482
+ prompt: `Review this PR diff and identify security concerns:\n${prDiff}`,
483
+ tools: [{
484
+ name: "record_finding",
485
+ description: "Record a security finding as evidence in the reasoning graph",
486
+ parameters: {
487
+ finding: { type: "string" },
488
+ severity: { type: "string", enum: ["low", "medium", "high", "critical"] },
489
+ relatedBeliefId: { type: "string", description: "ID of the belief this relates to" },
490
+ supportsOrContradicts: { type: "number", description: "-1 to 1" },
491
+ },
492
+ }],
493
+ });
494
+
495
+ // Each tool call becomes evidence in the graph
496
+ for (const call of findings.toolCalls) {
497
+ await lucern.evidence.create({
498
+ topicId,
499
+ text: call.args.finding,
500
+ sourceUrl: `pr://review/${prNumber}`,
501
+ targetId: call.args.relatedBeliefId,
502
+ weight: call.args.supportsOrContradicts,
503
+ });
504
+ }
505
+ ```
506
+
507
+ ### Search the Graph Semantically
508
+
509
+ ```typescript
510
+ // Find beliefs related to a natural language query
511
+ const results = await lucern.search.beliefs({
512
+ topicId,
513
+ query: "race conditions in authentication",
514
+ minConfidence: 0.5,
515
+ limit: 10,
516
+ });
517
+
518
+ results.data.forEach(b => {
519
+ console.log(`[${b.confidence}] ${b.canonicalText}`);
520
+ });
521
+
522
+ // Search evidence
523
+ const evidence = await lucern.search.evidence({
524
+ topicId,
525
+ query: "token refresh timing data",
526
+ limit: 5,
527
+ });
528
+ ```
56
529
 
57
- `createLucernClient()` returns grouped clients:
530
+ ## Agent Configuration
58
531
 
59
- - `beliefs`
60
- - `evidence`
61
- - `questions`
62
- - `graph`
63
- - `judgments`
64
- - `worktrees`
65
- - `context`
66
- - `tasks`
67
- - `research`
68
- - `tools` (runtime custom tool registration/invocation)
69
- - `custom` (default custom namespace invoker)
70
- - `extensions` (dynamic namespace invokers)
71
- - `raw` (low-level endpoint clients)
532
+ ### CLAUDE.md / AGENTS.md Integration
72
533
 
73
- ## Custom tool extensions
534
+ Add Lucern context to your coding agent's system instructions:
74
535
 
75
- ```ts
76
- import { z } from "zod";
536
+ ```markdown
537
+ <!-- In your CLAUDE.md or AGENTS.md -->
77
538
 
539
+ ## Reasoning Graph
540
+
541
+ This project uses Lucern for knowledge management. Before making
542
+ architectural decisions, check the reasoning graph:
543
+
544
+ - Read current beliefs: `lucern.beliefs.list({ topicId: "..." })`
545
+ - Check for contradictions: `lucern.contradictions.list({ topicId: "..." })`
546
+ - Compile context before analysis: `lucern.context.compile(topicId, { query: "..." })`
547
+
548
+ After making decisions, write them back:
549
+ - Create beliefs for architectural decisions
550
+ - Add evidence linking to the code/PR that validates them
551
+ - Flag contradictions when new evidence conflicts with existing beliefs
552
+ - Answer open questions when your work resolves them
553
+
554
+ Confidence scale:
555
+ - 0.90+: Verified in production
556
+ - 0.80-0.90: Strong evidence, working implementation
557
+ - 0.70-0.80: Directionally right, needs validation
558
+ - Below 0.70: Hypothesis, needs investigation
559
+ ```
560
+
561
+ ### Claude Code Skill
562
+
563
+ Create a Lucern skill for your coding agents at `~/.claude/skills/lucern-sdk/SKILL.md`:
564
+
565
+ ```markdown
566
+ # Lucern SDK Skill
567
+
568
+ Use this skill when building features that read or write to the
569
+ reasoning graph, or when the user asks about beliefs, evidence,
570
+ contradictions, or knowledge state.
571
+
572
+ ## Before Starting Work
573
+
574
+ Compile the current context to understand what the graph knows:
575
+
576
+ \`\`\`typescript
577
+ const context = await lucern.context.compile(topicId, {
578
+ query: "<what you're working on>",
579
+ tokenBudget: 2000,
580
+ });
581
+ \`\`\`
582
+
583
+ Check for open questions related to your task. If one exists, your work
584
+ should aim to answer it.
585
+
586
+ ## After Completing Work
587
+
588
+ Record what you learned:
589
+
590
+ \`\`\`typescript
591
+ // Create a belief for decisions made
592
+ await lucern.beliefs.create({
593
+ topicId,
594
+ baseRate: 0.5,
595
+ canonicalText: "<what you now believe to be true>",
596
+ });
597
+
598
+ // Add evidence from your implementation
599
+ await lucern.evidence.create({
600
+ topicId,
601
+ text: "<what you observed or built>",
602
+ sourceUrl: "commit://<sha>",
603
+ targetId: beliefId,
604
+ weight: 0.8,
605
+ });
606
+
607
+ // Answer questions your work resolved
608
+ await lucern.questions.answer(questionId, {
609
+ text: "<the answer>",
610
+ confidence: "strong",
611
+ });
612
+ \`\`\`
613
+ ```
614
+
615
+ ### Custom Tool Registration for Agents
616
+
617
+ Give your agents domain-specific capabilities that interact with the graph:
618
+
619
+ ```typescript
78
620
  lucern.tools.register({
79
- namespace: "stack",
80
- name: "score_deal",
81
- description: "Stack-specific scoring extension",
82
- inputSchema: z.object({ dealId: z.string() }),
83
- outputSchema: z.object({ score: z.number() }),
84
- handler: async ({ dealId }) => ({ score: dealId.length / 10 }),
621
+ namespace: "codebase",
622
+ name: "trace_dependency",
623
+ description: "Trace how a code change would affect beliefs in the reasoning graph",
624
+ inputSchema: z.object({
625
+ filePath: z.string(),
626
+ changeDescription: z.string(),
627
+ topicId: z.string(),
628
+ }),
629
+ outputSchema: z.object({
630
+ affectedBeliefs: z.array(z.object({
631
+ beliefId: z.string(),
632
+ text: z.string(),
633
+ currentConfidence: z.number(),
634
+ impact: z.enum(["strengthens", "weakens", "invalidates"]),
635
+ })),
636
+ }),
637
+ handler: async ({ filePath, changeDescription, topicId }) => {
638
+ // Search for beliefs related to this file/area
639
+ const related = await lucern.search.beliefs({
640
+ topicId,
641
+ query: `${filePath} ${changeDescription}`,
642
+ });
643
+ // Analyze impact...
644
+ return { affectedBeliefs: analyzeImpact(related, changeDescription) };
645
+ },
85
646
  });
647
+ ```
648
+
649
+ ## Worktree Patterns
650
+
651
+ ### List and Resume Investigations
86
652
 
87
- await lucern.extensions.stack.score_deal({ dealId: "deal_001" });
653
+ ```typescript
654
+ // See all active investigations
655
+ const worktrees = await lucern.worktrees.list({
656
+ topicId,
657
+ status: "active",
658
+ });
659
+
660
+ worktrees.data.forEach(wt => {
661
+ console.log(`${wt.title} — phase: ${wt.phase}, beliefs: ${wt.beliefCount}`);
662
+ });
663
+
664
+ // Get the full state of an investigation
665
+ const investigation = await lucern.worktrees.get(worktreeId);
666
+ console.log(`Hypothesis: ${investigation.data.hypothesis}`);
667
+ console.log(`Questions: ${investigation.data.questionCount} open`);
668
+ console.log(`Evidence: ${investigation.data.evidenceCount} collected`);
669
+ ```
670
+
671
+ ### Merge an Investigation
672
+
673
+ When the investigation is complete, merge findings into the main graph:
674
+
675
+ ```typescript
676
+ await lucern.worktrees.merge(worktreeId, {
677
+ summary: "Static analysis catches 53% of vulns overall but has zero coverage for business logic flaws",
678
+ outcomes: [
679
+ {
680
+ beliefId: hypothesis.data.nodeId,
681
+ confidence: 0.2,
682
+ rationale: "Overall catch rate was 53%, not <30% — but the category breakdown is more important",
683
+ },
684
+ {
685
+ beliefId: evolved.data.nodeId,
686
+ confidence: 0.88,
687
+ rationale: "Direct comparison data confirms the coverage gap hypothesis at category level",
688
+ },
689
+ ],
690
+ });
88
691
  ```
89
692
 
90
- ## Key provisioning endpoints
693
+ ## Confidence History
694
+
695
+ Every confidence change is recorded with full provenance:
696
+
697
+ ```typescript
698
+ const history = await lucern.beliefs.confidenceHistory(beliefId);
699
+
700
+ history.data.forEach(entry => {
701
+ console.log(
702
+ `${new Date(entry.timestamp).toISOString()} ` +
703
+ `${entry.previousConfidence} -> ${entry.confidence} ` +
704
+ `[${entry.trigger}] ${entry.rationale}`
705
+ );
706
+ });
707
+
708
+ // Example output:
709
+ // 2026-04-10T14:00:00Z null -> 0.60 [manual] Anecdotal observation
710
+ // 2026-04-11T09:30:00Z 0.60 -> 0.75 [evidence_added] Semgrep data supports
711
+ // 2026-04-11T16:00:00Z 0.75 -> 0.20 [evidence_added] Comparison study contradicted
712
+ ```
713
+
714
+ ## Authentication
715
+
716
+ ```typescript
717
+ const lucern = createLucernClient({
718
+ apiKey: "lk_your_key",
719
+ baseUrl: "https://api.lucern.ai",
720
+ });
721
+ ```
91
722
 
92
- SDK key lifecycle methods map to:
723
+ ## Links
93
724
 
94
- - `GET /api/platform/v1/identity/keys`
95
- - `POST /api/platform/v1/identity/keys`
96
- - `POST /api/platform/v1/identity/keys/{keyId}/rotate`
97
- - `POST /api/platform/v1/identity/keys/{keyId}/revoke`
725
+ - [Documentation](https://docs.lucern.ai)
726
+ - [API Reference](https://docs.lucern.ai/api)
727
+ - [Examples](https://github.com/LucernAI/lucern/tree/main/examples)