@lucern/sdk 0.2.0-alpha.13 → 0.2.0-alpha.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 (317) hide show
  1. package/README.md +166 -609
  2. package/dist/index.js +3539 -6269
  3. package/dist/index.js.map +1 -1
  4. package/dist/{contracts → lucern/contracts/src}/auth-session.contract.d.ts +12 -14
  5. package/dist/{contracts → lucern/contracts/src}/context-pack.contract.d.ts +58 -56
  6. package/dist/{contracts → lucern/contracts/src}/lens-filter.contract.d.ts +8 -10
  7. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +84 -0
  8. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +151 -0
  9. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +161 -0
  10. package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +119 -0
  11. package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +18 -0
  12. package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +78 -0
  13. package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +53 -0
  14. package/dist/lucern/packages/client-core/src/beliefs.d.ts +30 -0
  15. package/dist/lucern/packages/client-core/src/context.d.ts +29 -0
  16. package/dist/lucern/packages/client-core/src/contradictions.d.ts +11 -0
  17. package/dist/lucern/packages/client-core/src/edges.d.ts +11 -0
  18. package/dist/lucern/packages/client-core/src/events.d.ts +9 -0
  19. package/dist/lucern/packages/client-core/src/evidence.d.ts +21 -0
  20. package/dist/lucern/packages/client-core/src/graph.d.ts +17 -0
  21. package/dist/lucern/packages/client-core/src/identity.d.ts +7 -0
  22. package/dist/lucern/packages/client-core/src/ids.d.ts +7 -0
  23. package/dist/lucern/packages/client-core/src/ontologies.d.ts +13 -0
  24. package/dist/lucern/packages/client-core/src/questions.d.ts +39 -0
  25. package/dist/lucern/packages/client-core/src/search.d.ts +7 -0
  26. package/dist/lucern/packages/client-core/src/tasks.d.ts +13 -0
  27. package/dist/lucern/packages/client-core/src/topics.d.ts +17 -0
  28. package/dist/lucern/packages/client-core/src/webhooks.d.ts +35 -0
  29. package/dist/lucern/packages/client-core/src/worktrees.d.ts +17 -0
  30. package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +283 -0
  31. package/dist/lucern/packages/domain-beliefs/src/index.d.ts +1 -0
  32. package/dist/lucern/packages/domain-context/src/compile.d.ts +11 -0
  33. package/dist/{contextPackCompiler.d.ts → lucern/packages/domain-context/src/context-pack-compiler.d.ts} +10 -11
  34. package/dist/lucern/packages/domain-context/src/index.d.ts +4 -0
  35. package/dist/lucern/packages/domain-context/src/ports.d.ts +58 -0
  36. package/dist/lucern/packages/domain-context/src/public-types.d.ts +1 -0
  37. package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +59 -0
  38. package/dist/lucern/packages/domain-edges/src/edges.d.ts +91 -0
  39. package/dist/lucern/packages/domain-edges/src/index.d.ts +2 -0
  40. package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +115 -0
  41. package/dist/lucern/packages/domain-evidence/src/index.d.ts +1 -0
  42. package/dist/lucern/packages/domain-graph/src/graph.d.ts +150 -0
  43. package/dist/lucern/packages/domain-identity/src/index.d.ts +1 -0
  44. package/dist/lucern/packages/domain-identity/src/whoami.d.ts +13 -0
  45. package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +123 -0
  46. package/dist/lucern/packages/domain-questions/src/index.d.ts +1 -0
  47. package/dist/lucern/packages/domain-questions/src/questions.d.ts +147 -0
  48. package/dist/lucern/packages/domain-search/src/search.d.ts +97 -0
  49. package/dist/lucern/packages/domain-tasks/src/index.d.ts +1 -0
  50. package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +102 -0
  51. package/dist/lucern/packages/domain-topics/src/index.d.ts +1 -0
  52. package/dist/lucern/packages/domain-topics/src/topics.d.ts +147 -0
  53. package/dist/lucern/packages/domain-worktrees/src/index.d.ts +1 -0
  54. package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +185 -0
  55. package/dist/lucern/packages/events/src/index.d.ts +4 -0
  56. package/dist/lucern/packages/events/src/matching.d.ts +3 -0
  57. package/dist/lucern/packages/events/src/outbox.d.ts +15 -0
  58. package/dist/lucern/packages/events/src/types.d.ts +151 -0
  59. package/dist/lucern/packages/events/src/webhooks.d.ts +9 -0
  60. package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +15 -0
  61. package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +12 -0
  62. package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +7 -0
  63. package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +7 -0
  64. package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +6 -0
  65. package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +21 -0
  66. package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +10 -0
  67. package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +5 -0
  68. package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +8 -0
  69. package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +39 -0
  70. package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +5 -0
  71. package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +8 -0
  72. package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +10 -0
  73. package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +16 -0
  74. package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +10 -0
  75. package/dist/lucern/packages/sdk-typescript/src/index.d.ts +28 -0
  76. package/dist/packages/sdk/src/adminClient.d.ts +89 -0
  77. package/dist/packages/sdk/src/answersClient.d.ts +5 -0
  78. package/dist/{audiencesClient.d.ts → packages/sdk/src/audiencesClient.d.ts} +18 -30
  79. package/dist/packages/sdk/src/auditClient.d.ts +21 -0
  80. package/dist/packages/sdk/src/beliefsClient.d.ts +52 -0
  81. package/dist/packages/sdk/src/client.d.ts +1558 -0
  82. package/dist/packages/sdk/src/contextClient.d.ts +9 -0
  83. package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +58 -0
  84. package/dist/{controlObjectOwnership.d.ts → packages/sdk/src/controlObjectOwnership.d.ts} +18 -35
  85. package/dist/{coreClient.d.ts → packages/sdk/src/coreClient.d.ts} +14 -38
  86. package/dist/packages/sdk/src/customTools.d.ts +65 -0
  87. package/dist/packages/sdk/src/decisionsClient.d.ts +97 -0
  88. package/dist/packages/sdk/src/graphClient.d.ts +191 -0
  89. package/dist/{harnessClient.d.ts → packages/sdk/src/harnessClient.d.ts} +33 -127
  90. package/dist/packages/sdk/src/identityClient.d.ts +104 -0
  91. package/dist/packages/sdk/src/index.d.ts +28 -0
  92. package/dist/packages/sdk/src/learningClient.d.ts +37 -0
  93. package/dist/{mcpParityClient.d.ts → packages/sdk/src/mcpParityClient.d.ts} +5 -11
  94. package/dist/packages/sdk/src/mcpParitySurface.d.ts +8 -0
  95. package/dist/{ontologyClient.d.ts → packages/sdk/src/ontologyClient.d.ts} +22 -44
  96. package/dist/packages/sdk/src/packsClient.d.ts +101 -0
  97. package/dist/{policyClient.d.ts → packages/sdk/src/policyClient.d.ts} +18 -113
  98. package/dist/packages/sdk/src/reportsClient.d.ts +31 -0
  99. package/dist/packages/sdk/src/schemaClient.d.ts +54 -0
  100. package/dist/packages/sdk/src/sdkSurface.d.ts +55 -0
  101. package/dist/packages/sdk/src/topicsClient.d.ts +45 -0
  102. package/dist/packages/sdk/src/types.d.ts +470 -0
  103. package/dist/packages/sdk/src/version.d.ts +2 -0
  104. package/dist/packages/sdk/src/workflowClient.d.ts +252 -0
  105. package/package.json +37 -92
  106. package/CHANGELOG.md +0 -13
  107. package/dist/adminClient.d.ts +0 -409
  108. package/dist/adminClient.js +0 -755
  109. package/dist/adminClient.js.map +0 -1
  110. package/dist/answersClient.d.ts +0 -23
  111. package/dist/answersClient.js +0 -333
  112. package/dist/answersClient.js.map +0 -1
  113. package/dist/audience/index.d.ts +0 -38
  114. package/dist/audience/index.js +0 -110
  115. package/dist/audience/index.js.map +0 -1
  116. package/dist/audiencesClient.js +0 -472
  117. package/dist/audiencesClient.js.map +0 -1
  118. package/dist/auditClient.d.ts +0 -29
  119. package/dist/auditClient.js +0 -386
  120. package/dist/auditClient.js.map +0 -1
  121. package/dist/beliefs/index.d.ts +0 -465
  122. package/dist/beliefs/index.js +0 -6433
  123. package/dist/beliefs/index.js.map +0 -1
  124. package/dist/beliefs/lifecycle.d.ts +0 -24
  125. package/dist/beliefs/lifecycle.js +0 -98
  126. package/dist/beliefs/lifecycle.js.map +0 -1
  127. package/dist/beliefsClient.d.ts +0 -241
  128. package/dist/beliefsClient.js +0 -646
  129. package/dist/beliefsClient.js.map +0 -1
  130. package/dist/client.d.ts +0 -2398
  131. package/dist/client.js +0 -6411
  132. package/dist/client.js.map +0 -1
  133. package/dist/contextClient.d.ts +0 -27
  134. package/dist/contextClient.js +0 -396
  135. package/dist/contextClient.js.map +0 -1
  136. package/dist/contextFacade.d.ts +0 -2
  137. package/dist/contextFacade.js +0 -73
  138. package/dist/contextFacade.js.map +0 -1
  139. package/dist/contextPackCompiler.js +0 -1091
  140. package/dist/contextPackCompiler.js.map +0 -1
  141. package/dist/contextPackPolicy.d.ts +0 -84
  142. package/dist/contextPackPolicy.js +0 -347
  143. package/dist/contextPackPolicy.js.map +0 -1
  144. package/dist/contextPackSchema.d.ts +0 -7
  145. package/dist/contextPackSchema.js +0 -203
  146. package/dist/contextPackSchema.js.map +0 -1
  147. package/dist/contextTypes.d.ts +0 -135
  148. package/dist/contextTypes.js +0 -3
  149. package/dist/contextTypes.js.map +0 -1
  150. package/dist/contracts/api-enums.contract.d.ts +0 -81
  151. package/dist/contracts/api-enums.contract.js +0 -98
  152. package/dist/contracts/api-enums.contract.js.map +0 -1
  153. package/dist/contracts/auth-session.contract.js +0 -48
  154. package/dist/contracts/auth-session.contract.js.map +0 -1
  155. package/dist/contracts/context-pack.contract.js +0 -98
  156. package/dist/contracts/context-pack.contract.js.map +0 -1
  157. package/dist/contracts/contextPack.d.ts +0 -1
  158. package/dist/contracts/contextPack.js +0 -98
  159. package/dist/contracts/contextPack.js.map +0 -1
  160. package/dist/contracts/index.d.ts +0 -9
  161. package/dist/contracts/index.js +0 -4928
  162. package/dist/contracts/index.js.map +0 -1
  163. package/dist/contracts/lens-filter.contract.js +0 -71
  164. package/dist/contracts/lens-filter.contract.js.map +0 -1
  165. package/dist/contracts/lens-workflow.contract.d.ts +0 -87
  166. package/dist/contracts/lens-workflow.contract.js +0 -123
  167. package/dist/contracts/lens-workflow.contract.js.map +0 -1
  168. package/dist/contracts/lensFilter.d.ts +0 -1
  169. package/dist/contracts/lensFilter.js +0 -71
  170. package/dist/contracts/lensFilter.js.map +0 -1
  171. package/dist/contracts/lensWorkflow.d.ts +0 -2
  172. package/dist/contracts/lensWorkflow.js +0 -123
  173. package/dist/contracts/lensWorkflow.js.map +0 -1
  174. package/dist/contracts/mcp-tools.contract.d.ts +0 -1
  175. package/dist/contracts/mcp-tools.contract.js +0 -3016
  176. package/dist/contracts/mcp-tools.contract.js.map +0 -1
  177. package/dist/contracts/mcpTools.d.ts +0 -1
  178. package/dist/contracts/mcpTools.js +0 -3016
  179. package/dist/contracts/mcpTools.js.map +0 -1
  180. package/dist/contracts/prompt.contract.d.ts +0 -26
  181. package/dist/contracts/prompt.contract.js +0 -12
  182. package/dist/contracts/prompt.contract.js.map +0 -1
  183. package/dist/contracts/prompt.d.ts +0 -1
  184. package/dist/contracts/prompt.js +0 -12
  185. package/dist/contracts/prompt.js.map +0 -1
  186. package/dist/contracts/sdk-tools.contract.d.ts +0 -2
  187. package/dist/contracts/sdk-tools.contract.js +0 -4164
  188. package/dist/contracts/sdk-tools.contract.js.map +0 -1
  189. package/dist/contracts/sdkTools.d.ts +0 -2
  190. package/dist/contracts/sdkTools.js +0 -4164
  191. package/dist/contracts/sdkTools.js.map +0 -1
  192. package/dist/contracts/workflow-runtime.contract.d.ts +0 -163
  193. package/dist/contracts/workflow-runtime.contract.js +0 -245
  194. package/dist/contracts/workflow-runtime.contract.js.map +0 -1
  195. package/dist/contracts/workflowRuntime.d.ts +0 -1
  196. package/dist/contracts/workflowRuntime.js +0 -245
  197. package/dist/contracts/workflowRuntime.js.map +0 -1
  198. package/dist/contradictions/index.d.ts +0 -158
  199. package/dist/contradictions/index.js +0 -6427
  200. package/dist/contradictions/index.js.map +0 -1
  201. package/dist/controlObjectOwnership.js +0 -215
  202. package/dist/controlObjectOwnership.js.map +0 -1
  203. package/dist/coreClient.js +0 -339
  204. package/dist/coreClient.js.map +0 -1
  205. package/dist/customTools.d.ts +0 -88
  206. package/dist/customTools.js +0 -248
  207. package/dist/customTools.js.map +0 -1
  208. package/dist/decisions/index.d.ts +0 -68
  209. package/dist/decisions/index.js +0 -6429
  210. package/dist/decisions/index.js.map +0 -1
  211. package/dist/decisionsClient.d.ts +0 -111
  212. package/dist/decisionsClient.js +0 -522
  213. package/dist/decisionsClient.js.map +0 -1
  214. package/dist/domainContext.d.ts +0 -1
  215. package/dist/domainContext.js +0 -3
  216. package/dist/domainContext.js.map +0 -1
  217. package/dist/edges/index.d.ts +0 -204
  218. package/dist/edges/index.js +0 -6428
  219. package/dist/edges/index.js.map +0 -1
  220. package/dist/events.d.ts +0 -178
  221. package/dist/events.js +0 -251
  222. package/dist/events.js.map +0 -1
  223. package/dist/eventsCore.d.ts +0 -49
  224. package/dist/eventsCore.js +0 -429
  225. package/dist/eventsCore.js.map +0 -1
  226. package/dist/evidence/index.d.ts +0 -295
  227. package/dist/evidence/index.js +0 -6428
  228. package/dist/evidence/index.js.map +0 -1
  229. package/dist/evidenceClient.d.ts +0 -119
  230. package/dist/evidenceClient.js +0 -350
  231. package/dist/evidenceClient.js.map +0 -1
  232. package/dist/facade/context.d.ts +0 -18
  233. package/dist/facade/context.js +0 -73
  234. package/dist/facade/context.js.map +0 -1
  235. package/dist/gatewayFacades.d.ts +0 -589
  236. package/dist/gatewayFacades.js +0 -2006
  237. package/dist/gatewayFacades.js.map +0 -1
  238. package/dist/graphClient.d.ts +0 -271
  239. package/dist/graphClient.js +0 -698
  240. package/dist/graphClient.js.map +0 -1
  241. package/dist/harnessClient.js +0 -607
  242. package/dist/harnessClient.js.map +0 -1
  243. package/dist/identityClient.d.ts +0 -140
  244. package/dist/identityClient.js +0 -497
  245. package/dist/identityClient.js.map +0 -1
  246. package/dist/index.d.ts +0 -45
  247. package/dist/learningClient.d.ts +0 -46
  248. package/dist/learningClient.js +0 -409
  249. package/dist/learningClient.js.map +0 -1
  250. package/dist/lenses/index.d.ts +0 -194
  251. package/dist/lenses/index.js +0 -6427
  252. package/dist/lenses/index.js.map +0 -1
  253. package/dist/mcpParityClient.js +0 -516
  254. package/dist/mcpParityClient.js.map +0 -1
  255. package/dist/mcpParitySurface.d.ts +0 -12
  256. package/dist/mcpParitySurface.js +0 -65
  257. package/dist/mcpParitySurface.js.map +0 -1
  258. package/dist/mcpTools-DPZxowDX.d.ts +0 -254
  259. package/dist/nodes/index.d.ts +0 -62
  260. package/dist/nodes/index.js +0 -6429
  261. package/dist/nodes/index.js.map +0 -1
  262. package/dist/ontologies/index.d.ts +0 -178
  263. package/dist/ontologies/index.js +0 -6430
  264. package/dist/ontologies/index.js.map +0 -1
  265. package/dist/ontologyClient.js +0 -513
  266. package/dist/ontologyClient.js.map +0 -1
  267. package/dist/opinion.d.ts +0 -11
  268. package/dist/opinion.js +0 -35
  269. package/dist/opinion.js.map +0 -1
  270. package/dist/packRuntime.d.ts +0 -2
  271. package/dist/packRuntime.js +0 -3
  272. package/dist/packRuntime.js.map +0 -1
  273. package/dist/packsClient.d.ts +0 -131
  274. package/dist/packsClient.js +0 -525
  275. package/dist/packsClient.js.map +0 -1
  276. package/dist/policyClient.js +0 -625
  277. package/dist/policyClient.js.map +0 -1
  278. package/dist/questions/index.d.ts +0 -297
  279. package/dist/questions/index.js +0 -6430
  280. package/dist/questions/index.js.map +0 -1
  281. package/dist/realtime/index.d.ts +0 -29
  282. package/dist/realtime/index.js +0 -23
  283. package/dist/realtime/index.js.map +0 -1
  284. package/dist/realtime/refs.d.ts +0 -17
  285. package/dist/realtime/refs.js +0 -9
  286. package/dist/realtime/refs.js.map +0 -1
  287. package/dist/reportsClient.d.ts +0 -41
  288. package/dist/reportsClient.js +0 -418
  289. package/dist/reportsClient.js.map +0 -1
  290. package/dist/schemaClient.d.ts +0 -64
  291. package/dist/schemaClient.js +0 -434
  292. package/dist/schemaClient.js.map +0 -1
  293. package/dist/sdkSurface.d.ts +0 -61
  294. package/dist/sdkSurface.js +0 -112
  295. package/dist/sdkSurface.js.map +0 -1
  296. package/dist/sdkTools-CwXJDACb.d.ts +0 -150
  297. package/dist/sourcesClient.d.ts +0 -24
  298. package/dist/sourcesClient.js +0 -339
  299. package/dist/sourcesClient.js.map +0 -1
  300. package/dist/topics/index.d.ts +0 -68
  301. package/dist/topics/index.js +0 -6428
  302. package/dist/topics/index.js.map +0 -1
  303. package/dist/topicsClient.d.ts +0 -84
  304. package/dist/topicsClient.js +0 -492
  305. package/dist/topicsClient.js.map +0 -1
  306. package/dist/types.d.ts +0 -715
  307. package/dist/types.js +0 -3
  308. package/dist/types.js.map +0 -1
  309. package/dist/version.d.ts +0 -4
  310. package/dist/version.js +0 -6
  311. package/dist/version.js.map +0 -1
  312. package/dist/workflowClient.d.ts +0 -316
  313. package/dist/workflowClient.js +0 -830
  314. package/dist/workflowClient.js.map +0 -1
  315. package/dist/worktrees/index.d.ts +0 -210
  316. package/dist/worktrees/index.js +0 -6430
  317. package/dist/worktrees/index.js.map +0 -1
package/README.md CHANGED
@@ -1,53 +1,16 @@
1
1
  # @lucern/sdk
2
2
 
3
- The reasoning operating system for AI-native applications.
3
+ The TypeScript SDK for Lucern, the reasoning operating system.
4
4
 
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.
5
+ Lucern gives your application a knowledge graph that thinks. Beliefs evolve. Evidence compounds. Contradictions surface. Your software does not just store data. It reasons about it.
6
6
 
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.
7
+ ## Install
8
8
 
9
9
  ```bash
10
10
  npm install @lucern/sdk
11
11
  ```
12
12
 
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.
13
+ ## Quickstart
51
14
 
52
15
  ```typescript
53
16
  import { createLucernClient } from "@lucern/sdk";
@@ -57,667 +20,261 @@ const lucern = createLucernClient({
57
20
  baseUrl: "https://api.lucern.ai",
58
21
  });
59
22
 
60
- // Create a parent topic for your domain
61
- const codeQuality = await lucern.topics.create({
62
- name: "Code Quality Intelligence",
23
+ // 1. Create a topic (a scope for reasoning)
24
+ const topic = await lucern.topics.create({
25
+ name: "Climate Tech Market Analysis",
63
26
  type: "domain",
64
27
  });
65
28
 
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
- });
72
-
73
- const performanceTopic = await lucern.topics.create({
74
- name: "Performance Patterns",
75
- type: "theme",
76
- parentTopicId: codeQuality.data.topicId,
29
+ // 2. State a belief (what you think is true)
30
+ const belief = await lucern.beliefs.create({
31
+ topicId: topic.data.topicId,
32
+ canonicalText: "Carbon capture will reach cost parity with offsets by 2028",
77
33
  });
78
- ```
79
-
80
- ### 2. Populate the Graph With What You Know
81
-
82
- Beliefs represent understanding at different epistemic levels: facts (verified), beliefs (confident), hypotheses (testing), and assumptions (untested).
83
34
 
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,
96
- trigger: "evidence_added",
97
- rationale: "OWASP verified, industry standard for 20+ years",
35
+ // 3. Ground it in evidence
36
+ await lucern.evidence.create({
37
+ topicId: topic.data.topicId,
38
+ text: "DOE report shows capture costs fell 40% in 2025, projecting $80/ton by 2027",
39
+ sourceUrl: "https://energy.gov/reports/carbon-capture-2025",
40
+ targetId: belief.data.nodeId,
41
+ weight: 0.85,
98
42
  });
99
43
 
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,
44
+ // 4. Score your confidence
45
+ await lucern.beliefs.modulateConfidence(belief.data.nodeId, {
46
+ confidence: 0.78,
108
47
  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",
48
+ rationale: "DOE data supports the trajectory, but assumes continued policy support",
157
49
  });
158
50
 
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",
51
+ // 5. Ask what would change your mind
52
+ await lucern.questions.create({
53
+ topicId: topic.data.topicId,
54
+ text: "What happens to capture economics if the IRA tax credits expire in 2026?",
55
+ priority: "high",
56
+ linkedBeliefId: belief.data.nodeId,
167
57
  });
168
58
  ```
169
59
 
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
- ```
60
+ Five calls. A living knowledge graph with a belief grounded in evidence, scored with confidence, and tested by a question. The graph remembers everything: what you believed, when you believed it, and why.
198
61
 
199
- ### 5. Add Evidence as You Work
62
+ ## What Makes This Different
200
63
 
201
- Your agent processes the results and commits evidence to the graph.
64
+ Most knowledge tools store facts. Lucern tracks how understanding evolves.
202
65
 
203
66
  ```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
67
+ // New evidence contradicts your belief
214
68
  await lucern.evidence.create({
215
69
  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.",
70
+ text: "Shell exits direct air capture citing unfavorable unit economics at scale",
71
+ sourceUrl: "https://reuters.com/shell-dac-exit-2026",
72
+ targetId: belief.data.nodeId,
73
+ weight: -0.6,
247
74
  });
248
75
 
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,
76
+ // Your confidence changes
77
+ await lucern.beliefs.modulateConfidence(belief.data.nodeId, {
78
+ confidence: 0.55,
257
79
  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",
80
+ rationale: "Major industry exit signals real-world cost barriers beyond DOE projections",
273
81
  });
274
82
 
275
- // Link them
276
- await lucern.graph.createEdge({
83
+ // Flag the tension explicitly
84
+ await lucern.contradictions.flag({
277
85
  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,
86
+ beliefA: belief.data.nodeId,
87
+ beliefB: optimisticBelief.nodeId,
88
+ description: "DOE projections vs Shell operational exit: lab costs vs deployed costs",
89
+ severity: "high",
90
+ defeatType: "undercuts",
295
91
  });
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
92
  ```
310
93
 
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
- ---
94
+ You started at 78% confidence. New evidence dropped you to 55%. There is an unresolved contradiction between the optimistic projection and the market reality. Every step is traceable. Every change has a rationale. Nothing is silently overwritten.
314
95
 
315
96
  ## Core Concepts
316
97
 
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. |
98
+ | Concept | What It Is | Git Analogy |
99
+ |---------|-----------|-------------|
100
+ | **Topic** | A scope for reasoning about something | A repository |
101
+ | **Belief** | A statement held to be true, with confidence | A commit (immutable once scored) |
102
+ | **Evidence** | A fact that supports or contradicts a belief | A test result |
103
+ | **Question** | Something that needs investigation | An open issue |
104
+ | **Contradiction** | Two beliefs in tension | A merge conflict that may stay unresolved |
105
+ | **Worktree** | A focused investigation into specific beliefs | A feature branch |
106
+ | **Confidence** | How sure you are (0 to 1), append-only history | Build status, changes with every test |
329
107
 
330
108
  ## SDK Surface
331
109
 
332
110
  ```typescript
333
111
  const lucern = createLucernClient({ apiKey, baseUrl });
334
112
 
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
113
+ // Knowledge primitives
114
+ lucern.beliefs // Create, fork, archive, score beliefs
115
+ lucern.evidence // Add evidence, link to beliefs and questions
116
+ lucern.questions // Ask questions, answer them, track status
117
+ lucern.contradictions // Flag and manage tensions between beliefs
118
+
119
+ // Structure
120
+ lucern.topics // Scope your reasoning into domains
121
+ lucern.worktrees // Focused investigations (feature branches for knowledge)
122
+ lucern.ontologies // Define your domain vocabulary
123
+
124
+ // Intelligence
125
+ lucern.graph // Traverse, analyze, detect bias, find gaps
126
+ lucern.context // Compile context packs for AI agents
127
+ lucern.search // Semantic search across the graph
128
+
129
+ // Operations
130
+ lucern.tasks // Track execution work tied to questions
131
+ lucern.audit // Full audit trail, every mutation, every actor
132
+ lucern.identity // Manage principals, sessions, API keys
347
133
  ```
348
134
 
349
- ## Graph Intelligence
135
+ ## Build Agents That Reason
350
136
 
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}`);
427
- });
428
- ```
429
-
430
- ## LLM Integration Patterns
431
-
432
- ### Inject Reasoning Context Into Any LLM Call
137
+ Lucern is built for AI agents that need to think, not just retrieve.
433
138
 
434
139
  ```typescript
140
+ // Compile the current understanding into a context pack
435
141
  const context = await lucern.context.compile(topicId, {
436
- query: "security review priorities",
142
+ query: "What do we know about carbon capture economics?",
437
143
  ranking: "weighted_v1",
438
- tokenBudget: 3000,
439
- includeEntities: true,
144
+ tokenBudget: 2000,
440
145
  });
441
146
 
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
147
+ // Feed it to your LLM as grounded context
148
+ const response = await llm.generate({
149
+ system: `You are a research analyst. Here is your current knowledge state:
475
150
 
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
- ```
151
+ Beliefs (ranked by relevance):
152
+ ${context.data.activeBeliefs
153
+ .map((b) => `[${b.confidence}] ${b.canonicalText}`)
154
+ .join("\n ")}
506
155
 
507
- ### Search the Graph Semantically
156
+ Open Questions:
157
+ ${context.data.openQuestions.map((q) => q.text).join("\n ")}
508
158
 
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
- });
159
+ Unresolved Contradictions:
160
+ ${context.data.contradictions.map((c) => c.description).join("\n ")}
517
161
 
518
- results.data.forEach(b => {
519
- console.log(`[${b.confidence}] ${b.canonicalText}`);
162
+ Reason from this foundation. When your analysis conflicts with
163
+ existing beliefs, say so explicitly.`,
164
+ prompt: userQuery,
520
165
  });
521
166
 
522
- // Search evidence
523
- const evidence = await lucern.search.evidence({
167
+ // Write the agent findings back to the graph
168
+ await lucern.evidence.create({
524
169
  topicId,
525
- query: "token refresh timing data",
526
- limit: 5,
170
+ text: response.analysis,
171
+ sourceUrl: "agent://research-analyst/session-42",
172
+ targetId: relevantBeliefId,
173
+ weight: 0.7,
527
174
  });
528
175
  ```
529
176
 
530
- ## Agent Configuration
531
-
532
- ### CLAUDE.md / AGENTS.md Integration
533
-
534
- Add Lucern context to your coding agent's system instructions:
535
-
536
- ```markdown
537
- <!-- In your CLAUDE.md or AGENTS.md -->
538
-
539
- ## Reasoning Graph
177
+ Every time an agent reads from the graph and writes back, the graph gets smarter. This is the compound intelligence loop.
540
178
 
541
- This project uses Lucern for knowledge management. Before making
542
- architectural decisions, check the reasoning graph:
179
+ ## Evolving Understanding
543
180
 
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: "..." })`
181
+ Beliefs are immutable once scored, like git commits. When understanding evolves, you fork:
547
182
 
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>",
183
+ ```typescript
184
+ const forked = await lucern.beliefs.fork(originalBelief.nodeId, {
185
+ newFormulation:
186
+ "Carbon capture will remain 2-3x more expensive than offsets through 2030, " +
187
+ "with deployment limited to regulated industries where offsets are not accepted",
188
+ forkReason: "contradiction_response",
596
189
  });
597
190
 
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,
191
+ await lucern.beliefs.modulateConfidence(forked.data.nodeId, {
192
+ confidence: 0.82,
193
+ trigger: "evidence_added",
194
+ rationale: "Three independent operator reports confirm cost barriers persist",
605
195
  });
606
196
 
607
- // Answer questions your work resolved
608
- await lucern.questions.answer(questionId, {
609
- text: "<the answer>",
610
- confidence: "strong",
197
+ await lucern.beliefs.modulateConfidence(originalBelief.nodeId, {
198
+ confidence: 0,
199
+ trigger: "evidence_added",
200
+ rationale: "Superseded by forked belief incorporating operator data",
611
201
  });
612
- \`\`\`
613
202
  ```
614
203
 
615
- ### Custom Tool Registration for Agents
204
+ The lineage is permanent. You can trace how understanding moved from one belief to another, through what evidence, at what confidence.
205
+
206
+ ## Custom Tools
616
207
 
617
- Give your agents domain-specific capabilities that interact with the graph:
208
+ Extend the graph with domain-specific operations that any agent can invoke:
618
209
 
619
210
  ```typescript
211
+ import { z } from "zod";
212
+
620
213
  lucern.tools.register({
621
- namespace: "codebase",
622
- name: "trace_dependency",
623
- description: "Trace how a code change would affect beliefs in the reasoning graph",
214
+ namespace: "research",
215
+ name: "analyze_transcript",
216
+ description: "Extract beliefs and evidence from a meeting transcript",
624
217
  inputSchema: z.object({
625
- filePath: z.string(),
626
- changeDescription: z.string(),
218
+ transcriptUrl: z.string().url(),
627
219
  topicId: z.string(),
628
220
  }),
629
221
  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
- })),
222
+ beliefs: z.array(z.object({ text: z.string(), confidence: z.number() })),
223
+ evidence: z.array(z.object({ text: z.string(), sourceUrl: z.string() })),
636
224
  }),
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) };
225
+ handler: async ({ transcriptUrl, topicId }) => {
226
+ const transcript = await fetchTranscript(transcriptUrl);
227
+ return extractInsights(transcript, topicId);
645
228
  },
646
229
  });
647
- ```
648
-
649
- ## Worktree Patterns
650
230
 
651
- ### List and Resume Investigations
652
-
653
- ```typescript
654
- // See all active investigations
655
- const worktrees = await lucern.worktrees.list({
231
+ await lucern.extensions.research.analyze_transcript({
232
+ transcriptUrl: "https://...",
656
233
  topicId,
657
- status: "active",
658
- });
659
-
660
- worktrees.data.forEach(wt => {
661
- console.log(`${wt.title} — phase: ${wt.phase}, beliefs: ${wt.beliefCount}`);
662
234
  });
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
235
  ```
670
236
 
671
- ### Merge an Investigation
672
-
673
- When the investigation is complete, merge findings into the main graph:
237
+ ## Authentication
674
238
 
675
239
  ```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
- ],
240
+ // Service principal (server-to-server)
241
+ const lucern = createLucernClient({
242
+ apiKey: "lk_your_service_principal_key",
243
+ baseUrl: "https://api.lucern.ai",
690
244
  });
691
- ```
692
245
 
693
- ## Confidence History
246
+ // Tenant API key (application-level)
247
+ const lucern = createLucernClient({
248
+ apiKey: "luc_your_tenant_api_key",
249
+ baseUrl: "https://api.lucern.ai",
250
+ });
251
+ ```
694
252
 
695
- Every confidence change is recorded with full provenance:
253
+ ## Confidence Scale
696
254
 
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
- });
255
+ | Range | Meaning |
256
+ |-------|---------|
257
+ | 0.90-0.95 | Structural law, verified by multiple independent sources |
258
+ | 0.85-0.90 | Strong conviction, working implementation validates it |
259
+ | 0.80-0.85 | Confident, evidence supports it, not yet stress-tested |
260
+ | 0.70-0.80 | Directionally right, good signal, details still emerging |
261
+ | 0.50-0.70 | Hypothesis, plausible but needs investigation |
262
+ | Below 0.50 | Weak signal, more question than answer |
263
+ | 0 | Superseded, replaced by evolved understanding |
707
264
 
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
- ```
265
+ ## TypeScript First
713
266
 
714
- ## Authentication
267
+ Every response is fully typed. Every parameter has IntelliSense.
715
268
 
716
269
  ```typescript
717
- const lucern = createLucernClient({
718
- apiKey: "lk_your_key",
719
- baseUrl: "https://api.lucern.ai",
270
+ const belief = await lucern.beliefs.create({
271
+ topicId: "...",
272
+ canonicalText: "...",
720
273
  });
274
+
275
+ belief.data.nodeId; // string
276
+ belief.data.confidence; // number | null
277
+ belief.data.status; // "unscored" | "scored" | "archived"
721
278
  ```
722
279
 
723
280
  ## Links