@lucern/sdk 0.2.0-alpha.12 → 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.
- package/README.md +166 -609
- package/dist/index.js +3539 -6269
- package/dist/index.js.map +1 -1
- package/dist/{contracts → lucern/contracts/src}/auth-session.contract.d.ts +12 -14
- package/dist/{contracts → lucern/contracts/src}/context-pack.contract.d.ts +58 -56
- package/dist/{contracts → lucern/contracts/src}/lens-filter.contract.d.ts +8 -10
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +84 -0
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +151 -0
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +161 -0
- package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +119 -0
- package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +18 -0
- package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +78 -0
- package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +53 -0
- package/dist/lucern/packages/client-core/src/beliefs.d.ts +30 -0
- package/dist/lucern/packages/client-core/src/context.d.ts +29 -0
- package/dist/lucern/packages/client-core/src/contradictions.d.ts +11 -0
- package/dist/lucern/packages/client-core/src/edges.d.ts +11 -0
- package/dist/lucern/packages/client-core/src/events.d.ts +9 -0
- package/dist/lucern/packages/client-core/src/evidence.d.ts +21 -0
- package/dist/lucern/packages/client-core/src/graph.d.ts +17 -0
- package/dist/lucern/packages/client-core/src/identity.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/ids.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/ontologies.d.ts +13 -0
- package/dist/lucern/packages/client-core/src/questions.d.ts +39 -0
- package/dist/lucern/packages/client-core/src/search.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/tasks.d.ts +13 -0
- package/dist/lucern/packages/client-core/src/topics.d.ts +17 -0
- package/dist/lucern/packages/client-core/src/webhooks.d.ts +35 -0
- package/dist/lucern/packages/client-core/src/worktrees.d.ts +17 -0
- package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +283 -0
- package/dist/lucern/packages/domain-beliefs/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-context/src/compile.d.ts +11 -0
- package/dist/{contextPackCompiler.d.ts → lucern/packages/domain-context/src/context-pack-compiler.d.ts} +10 -11
- package/dist/lucern/packages/domain-context/src/index.d.ts +4 -0
- package/dist/lucern/packages/domain-context/src/ports.d.ts +58 -0
- package/dist/lucern/packages/domain-context/src/public-types.d.ts +1 -0
- package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +59 -0
- package/dist/lucern/packages/domain-edges/src/edges.d.ts +91 -0
- package/dist/lucern/packages/domain-edges/src/index.d.ts +2 -0
- package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +115 -0
- package/dist/lucern/packages/domain-evidence/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-graph/src/graph.d.ts +150 -0
- package/dist/lucern/packages/domain-identity/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-identity/src/whoami.d.ts +13 -0
- package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +123 -0
- package/dist/lucern/packages/domain-questions/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-questions/src/questions.d.ts +147 -0
- package/dist/lucern/packages/domain-search/src/search.d.ts +97 -0
- package/dist/lucern/packages/domain-tasks/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +102 -0
- package/dist/lucern/packages/domain-topics/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-topics/src/topics.d.ts +147 -0
- package/dist/lucern/packages/domain-worktrees/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +185 -0
- package/dist/lucern/packages/events/src/index.d.ts +4 -0
- package/dist/lucern/packages/events/src/matching.d.ts +3 -0
- package/dist/lucern/packages/events/src/outbox.d.ts +15 -0
- package/dist/lucern/packages/events/src/types.d.ts +151 -0
- package/dist/lucern/packages/events/src/webhooks.d.ts +9 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +15 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +12 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +7 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +7 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +6 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +21 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +5 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +8 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +39 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +5 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +8 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +16 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/index.d.ts +28 -0
- package/dist/packages/sdk/src/adminClient.d.ts +89 -0
- package/dist/packages/sdk/src/answersClient.d.ts +5 -0
- package/dist/{audiencesClient.d.ts → packages/sdk/src/audiencesClient.d.ts} +18 -30
- package/dist/packages/sdk/src/auditClient.d.ts +21 -0
- package/dist/packages/sdk/src/beliefsClient.d.ts +52 -0
- package/dist/packages/sdk/src/client.d.ts +1558 -0
- package/dist/packages/sdk/src/contextClient.d.ts +9 -0
- package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +58 -0
- package/dist/{controlObjectOwnership.d.ts → packages/sdk/src/controlObjectOwnership.d.ts} +18 -35
- package/dist/{coreClient.d.ts → packages/sdk/src/coreClient.d.ts} +14 -38
- package/dist/packages/sdk/src/customTools.d.ts +65 -0
- package/dist/packages/sdk/src/decisionsClient.d.ts +97 -0
- package/dist/packages/sdk/src/graphClient.d.ts +191 -0
- package/dist/{harnessClient.d.ts → packages/sdk/src/harnessClient.d.ts} +33 -127
- package/dist/packages/sdk/src/identityClient.d.ts +104 -0
- package/dist/packages/sdk/src/index.d.ts +28 -0
- package/dist/packages/sdk/src/learningClient.d.ts +37 -0
- package/dist/{mcpParityClient.d.ts → packages/sdk/src/mcpParityClient.d.ts} +5 -11
- package/dist/packages/sdk/src/mcpParitySurface.d.ts +8 -0
- package/dist/{ontologyClient.d.ts → packages/sdk/src/ontologyClient.d.ts} +22 -44
- package/dist/packages/sdk/src/packsClient.d.ts +101 -0
- package/dist/{policyClient.d.ts → packages/sdk/src/policyClient.d.ts} +18 -113
- package/dist/packages/sdk/src/reportsClient.d.ts +31 -0
- package/dist/packages/sdk/src/schemaClient.d.ts +54 -0
- package/dist/packages/sdk/src/sdkSurface.d.ts +55 -0
- package/dist/packages/sdk/src/topicsClient.d.ts +45 -0
- package/dist/packages/sdk/src/types.d.ts +470 -0
- package/dist/packages/sdk/src/version.d.ts +2 -0
- package/dist/packages/sdk/src/workflowClient.d.ts +252 -0
- package/package.json +37 -92
- package/CHANGELOG.md +0 -13
- package/dist/adminClient.d.ts +0 -409
- package/dist/adminClient.js +0 -755
- package/dist/adminClient.js.map +0 -1
- package/dist/answersClient.d.ts +0 -23
- package/dist/answersClient.js +0 -333
- package/dist/answersClient.js.map +0 -1
- package/dist/audience/index.d.ts +0 -38
- package/dist/audience/index.js +0 -110
- package/dist/audience/index.js.map +0 -1
- package/dist/audiencesClient.js +0 -472
- package/dist/audiencesClient.js.map +0 -1
- package/dist/auditClient.d.ts +0 -29
- package/dist/auditClient.js +0 -386
- package/dist/auditClient.js.map +0 -1
- package/dist/beliefs/index.d.ts +0 -465
- package/dist/beliefs/index.js +0 -6433
- package/dist/beliefs/index.js.map +0 -1
- package/dist/beliefs/lifecycle.d.ts +0 -24
- package/dist/beliefs/lifecycle.js +0 -98
- package/dist/beliefs/lifecycle.js.map +0 -1
- package/dist/beliefsClient.d.ts +0 -241
- package/dist/beliefsClient.js +0 -646
- package/dist/beliefsClient.js.map +0 -1
- package/dist/client.d.ts +0 -2398
- package/dist/client.js +0 -6411
- package/dist/client.js.map +0 -1
- package/dist/contextClient.d.ts +0 -27
- package/dist/contextClient.js +0 -396
- package/dist/contextClient.js.map +0 -1
- package/dist/contextFacade.d.ts +0 -2
- package/dist/contextFacade.js +0 -73
- package/dist/contextFacade.js.map +0 -1
- package/dist/contextPackCompiler.js +0 -1091
- package/dist/contextPackCompiler.js.map +0 -1
- package/dist/contextPackPolicy.d.ts +0 -84
- package/dist/contextPackPolicy.js +0 -347
- package/dist/contextPackPolicy.js.map +0 -1
- package/dist/contextPackSchema.d.ts +0 -7
- package/dist/contextPackSchema.js +0 -203
- package/dist/contextPackSchema.js.map +0 -1
- package/dist/contextTypes.d.ts +0 -135
- package/dist/contextTypes.js +0 -3
- package/dist/contextTypes.js.map +0 -1
- package/dist/contracts/api-enums.contract.d.ts +0 -81
- package/dist/contracts/api-enums.contract.js +0 -98
- package/dist/contracts/api-enums.contract.js.map +0 -1
- package/dist/contracts/auth-session.contract.js +0 -48
- package/dist/contracts/auth-session.contract.js.map +0 -1
- package/dist/contracts/context-pack.contract.js +0 -98
- package/dist/contracts/context-pack.contract.js.map +0 -1
- package/dist/contracts/contextPack.d.ts +0 -1
- package/dist/contracts/contextPack.js +0 -98
- package/dist/contracts/contextPack.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -9
- package/dist/contracts/index.js +0 -4928
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lens-filter.contract.js +0 -71
- package/dist/contracts/lens-filter.contract.js.map +0 -1
- package/dist/contracts/lens-workflow.contract.d.ts +0 -87
- package/dist/contracts/lens-workflow.contract.js +0 -123
- package/dist/contracts/lens-workflow.contract.js.map +0 -1
- package/dist/contracts/lensFilter.d.ts +0 -1
- package/dist/contracts/lensFilter.js +0 -71
- package/dist/contracts/lensFilter.js.map +0 -1
- package/dist/contracts/lensWorkflow.d.ts +0 -2
- package/dist/contracts/lensWorkflow.js +0 -123
- package/dist/contracts/lensWorkflow.js.map +0 -1
- package/dist/contracts/mcp-tools.contract.d.ts +0 -1
- package/dist/contracts/mcp-tools.contract.js +0 -3016
- package/dist/contracts/mcp-tools.contract.js.map +0 -1
- package/dist/contracts/mcpTools.d.ts +0 -1
- package/dist/contracts/mcpTools.js +0 -3016
- package/dist/contracts/mcpTools.js.map +0 -1
- package/dist/contracts/prompt.contract.d.ts +0 -26
- package/dist/contracts/prompt.contract.js +0 -12
- package/dist/contracts/prompt.contract.js.map +0 -1
- package/dist/contracts/prompt.d.ts +0 -1
- package/dist/contracts/prompt.js +0 -12
- package/dist/contracts/prompt.js.map +0 -1
- package/dist/contracts/sdk-tools.contract.d.ts +0 -2
- package/dist/contracts/sdk-tools.contract.js +0 -4164
- package/dist/contracts/sdk-tools.contract.js.map +0 -1
- package/dist/contracts/sdkTools.d.ts +0 -2
- package/dist/contracts/sdkTools.js +0 -4164
- package/dist/contracts/sdkTools.js.map +0 -1
- package/dist/contracts/workflow-runtime.contract.d.ts +0 -163
- package/dist/contracts/workflow-runtime.contract.js +0 -245
- package/dist/contracts/workflow-runtime.contract.js.map +0 -1
- package/dist/contracts/workflowRuntime.d.ts +0 -1
- package/dist/contracts/workflowRuntime.js +0 -245
- package/dist/contracts/workflowRuntime.js.map +0 -1
- package/dist/contradictions/index.d.ts +0 -158
- package/dist/contradictions/index.js +0 -6427
- package/dist/contradictions/index.js.map +0 -1
- package/dist/controlObjectOwnership.js +0 -215
- package/dist/controlObjectOwnership.js.map +0 -1
- package/dist/coreClient.js +0 -339
- package/dist/coreClient.js.map +0 -1
- package/dist/customTools.d.ts +0 -88
- package/dist/customTools.js +0 -248
- package/dist/customTools.js.map +0 -1
- package/dist/decisions/index.d.ts +0 -68
- package/dist/decisions/index.js +0 -6429
- package/dist/decisions/index.js.map +0 -1
- package/dist/decisionsClient.d.ts +0 -111
- package/dist/decisionsClient.js +0 -522
- package/dist/decisionsClient.js.map +0 -1
- package/dist/domainContext.d.ts +0 -1
- package/dist/domainContext.js +0 -3
- package/dist/domainContext.js.map +0 -1
- package/dist/edges/index.d.ts +0 -204
- package/dist/edges/index.js +0 -6428
- package/dist/edges/index.js.map +0 -1
- package/dist/events.d.ts +0 -178
- package/dist/events.js +0 -251
- package/dist/events.js.map +0 -1
- package/dist/eventsCore.d.ts +0 -49
- package/dist/eventsCore.js +0 -429
- package/dist/eventsCore.js.map +0 -1
- package/dist/evidence/index.d.ts +0 -295
- package/dist/evidence/index.js +0 -6428
- package/dist/evidence/index.js.map +0 -1
- package/dist/evidenceClient.d.ts +0 -119
- package/dist/evidenceClient.js +0 -350
- package/dist/evidenceClient.js.map +0 -1
- package/dist/facade/context.d.ts +0 -18
- package/dist/facade/context.js +0 -73
- package/dist/facade/context.js.map +0 -1
- package/dist/gatewayFacades.d.ts +0 -589
- package/dist/gatewayFacades.js +0 -2006
- package/dist/gatewayFacades.js.map +0 -1
- package/dist/graphClient.d.ts +0 -271
- package/dist/graphClient.js +0 -698
- package/dist/graphClient.js.map +0 -1
- package/dist/harnessClient.js +0 -607
- package/dist/harnessClient.js.map +0 -1
- package/dist/identityClient.d.ts +0 -140
- package/dist/identityClient.js +0 -497
- package/dist/identityClient.js.map +0 -1
- package/dist/index.d.ts +0 -45
- package/dist/learningClient.d.ts +0 -46
- package/dist/learningClient.js +0 -409
- package/dist/learningClient.js.map +0 -1
- package/dist/lenses/index.d.ts +0 -194
- package/dist/lenses/index.js +0 -6427
- package/dist/lenses/index.js.map +0 -1
- package/dist/mcpParityClient.js +0 -516
- package/dist/mcpParityClient.js.map +0 -1
- package/dist/mcpParitySurface.d.ts +0 -12
- package/dist/mcpParitySurface.js +0 -65
- package/dist/mcpParitySurface.js.map +0 -1
- package/dist/mcpTools-DPZxowDX.d.ts +0 -254
- package/dist/nodes/index.d.ts +0 -62
- package/dist/nodes/index.js +0 -6429
- package/dist/nodes/index.js.map +0 -1
- package/dist/ontologies/index.d.ts +0 -178
- package/dist/ontologies/index.js +0 -6430
- package/dist/ontologies/index.js.map +0 -1
- package/dist/ontologyClient.js +0 -513
- package/dist/ontologyClient.js.map +0 -1
- package/dist/opinion.d.ts +0 -11
- package/dist/opinion.js +0 -35
- package/dist/opinion.js.map +0 -1
- package/dist/packRuntime.d.ts +0 -2
- package/dist/packRuntime.js +0 -3
- package/dist/packRuntime.js.map +0 -1
- package/dist/packsClient.d.ts +0 -131
- package/dist/packsClient.js +0 -525
- package/dist/packsClient.js.map +0 -1
- package/dist/policyClient.js +0 -625
- package/dist/policyClient.js.map +0 -1
- package/dist/questions/index.d.ts +0 -297
- package/dist/questions/index.js +0 -6430
- package/dist/questions/index.js.map +0 -1
- package/dist/realtime/index.d.ts +0 -29
- package/dist/realtime/index.js +0 -23
- package/dist/realtime/index.js.map +0 -1
- package/dist/realtime/refs.d.ts +0 -17
- package/dist/realtime/refs.js +0 -9
- package/dist/realtime/refs.js.map +0 -1
- package/dist/reportsClient.d.ts +0 -41
- package/dist/reportsClient.js +0 -418
- package/dist/reportsClient.js.map +0 -1
- package/dist/schemaClient.d.ts +0 -64
- package/dist/schemaClient.js +0 -434
- package/dist/schemaClient.js.map +0 -1
- package/dist/sdkSurface.d.ts +0 -61
- package/dist/sdkSurface.js +0 -112
- package/dist/sdkSurface.js.map +0 -1
- package/dist/sdkTools-CwXJDACb.d.ts +0 -150
- package/dist/sourcesClient.d.ts +0 -24
- package/dist/sourcesClient.js +0 -339
- package/dist/sourcesClient.js.map +0 -1
- package/dist/topics/index.d.ts +0 -68
- package/dist/topics/index.js +0 -6428
- package/dist/topics/index.js.map +0 -1
- package/dist/topicsClient.d.ts +0 -84
- package/dist/topicsClient.js +0 -492
- package/dist/topicsClient.js.map +0 -1
- package/dist/types.d.ts +0 -715
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/version.d.ts +0 -4
- package/dist/version.js +0 -6
- package/dist/version.js.map +0 -1
- package/dist/workflowClient.d.ts +0 -316
- package/dist/workflowClient.js +0 -830
- package/dist/workflowClient.js.map +0 -1
- package/dist/worktrees/index.d.ts +0 -210
- package/dist/worktrees/index.js +0 -6430
- 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
|
|
3
|
+
The TypeScript SDK for Lucern, the reasoning operating system.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @lucern/sdk
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
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
|
|
61
|
-
const
|
|
62
|
-
name: "
|
|
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
|
-
//
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
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: "
|
|
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
|
-
//
|
|
160
|
-
await lucern.
|
|
161
|
-
topicId,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
## What Makes This Different
|
|
200
63
|
|
|
201
|
-
|
|
64
|
+
Most knowledge tools store facts. Lucern tracks how understanding evolves.
|
|
202
65
|
|
|
203
66
|
```typescript
|
|
204
|
-
//
|
|
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: "
|
|
217
|
-
sourceUrl: "
|
|
218
|
-
targetId:
|
|
219
|
-
weight: 0.
|
|
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
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
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: "
|
|
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
|
-
//
|
|
276
|
-
await lucern.
|
|
83
|
+
// Flag the tension explicitly
|
|
84
|
+
await lucern.contradictions.flag({
|
|
277
85
|
topicId,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
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
|
|
318
|
-
|
|
319
|
-
| **Topic** |
|
|
320
|
-
| **Belief** | A statement with
|
|
321
|
-
| **Evidence** | A
|
|
322
|
-
| **Question** |
|
|
323
|
-
| **Contradiction** |
|
|
324
|
-
| **Worktree** | A focused investigation
|
|
325
|
-
| **
|
|
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
|
-
|
|
336
|
-
lucern.
|
|
337
|
-
lucern.
|
|
338
|
-
lucern.
|
|
339
|
-
lucern.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
lucern.
|
|
343
|
-
lucern.
|
|
344
|
-
lucern.
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
##
|
|
135
|
+
## Build Agents That Reason
|
|
350
136
|
|
|
351
|
-
|
|
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: "
|
|
142
|
+
query: "What do we know about carbon capture economics?",
|
|
437
143
|
ranking: "weighted_v1",
|
|
438
|
-
tokenBudget:
|
|
439
|
-
includeEntities: true,
|
|
144
|
+
tokenBudget: 2000,
|
|
440
145
|
});
|
|
441
146
|
|
|
442
|
-
//
|
|
443
|
-
const
|
|
444
|
-
You are a
|
|
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
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
-
|
|
156
|
+
Open Questions:
|
|
157
|
+
${context.data.openQuestions.map((q) => q.text).join("\n ")}
|
|
508
158
|
|
|
509
|
-
|
|
510
|
-
|
|
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
|
-
|
|
519
|
-
|
|
162
|
+
Reason from this foundation. When your analysis conflicts with
|
|
163
|
+
existing beliefs, say so explicitly.`,
|
|
164
|
+
prompt: userQuery,
|
|
520
165
|
});
|
|
521
166
|
|
|
522
|
-
//
|
|
523
|
-
|
|
167
|
+
// Write the agent findings back to the graph
|
|
168
|
+
await lucern.evidence.create({
|
|
524
169
|
topicId,
|
|
525
|
-
|
|
526
|
-
|
|
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
|
-
|
|
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
|
-
|
|
542
|
-
architectural decisions, check the reasoning graph:
|
|
179
|
+
## Evolving Understanding
|
|
543
180
|
|
|
544
|
-
|
|
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
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
-
|
|
552
|
-
|
|
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
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: "
|
|
622
|
-
name: "
|
|
623
|
-
description: "
|
|
214
|
+
namespace: "research",
|
|
215
|
+
name: "analyze_transcript",
|
|
216
|
+
description: "Extract beliefs and evidence from a meeting transcript",
|
|
624
217
|
inputSchema: z.object({
|
|
625
|
-
|
|
626
|
-
changeDescription: z.string(),
|
|
218
|
+
transcriptUrl: z.string().url(),
|
|
627
219
|
topicId: z.string(),
|
|
628
220
|
}),
|
|
629
221
|
outputSchema: z.object({
|
|
630
|
-
|
|
631
|
-
|
|
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 ({
|
|
638
|
-
|
|
639
|
-
|
|
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
|
-
|
|
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
|
-
|
|
672
|
-
|
|
673
|
-
When the investigation is complete, merge findings into the main graph:
|
|
237
|
+
## Authentication
|
|
674
238
|
|
|
675
239
|
```typescript
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
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
|
-
|
|
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
|
-
|
|
253
|
+
## Confidence Scale
|
|
696
254
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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
|
-
|
|
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
|
-
|
|
267
|
+
Every response is fully typed. Every parameter has IntelliSense.
|
|
715
268
|
|
|
716
269
|
```typescript
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
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
|