@lucern/sdk 0.3.0-alpha.0 → 0.3.0-alpha.1

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 (61) hide show
  1. package/README.md +33 -21
  2. package/dist/beliefs/index.d.ts +7 -7
  3. package/dist/beliefs/index.js +100 -99
  4. package/dist/beliefs/index.js.map +1 -1
  5. package/dist/beliefsClient.d.ts +14 -29
  6. package/dist/beliefsClient.js +34 -71
  7. package/dist/beliefsClient.js.map +1 -1
  8. package/dist/{client-DAuKnDlx.d.ts → client-B6aWUUwp.d.ts} +25 -20
  9. package/dist/client.d.ts +1 -1
  10. package/dist/client.js +100 -99
  11. package/dist/client.js.map +1 -1
  12. package/dist/contracts/index.js +1 -1
  13. package/dist/contracts/index.js.map +1 -1
  14. package/dist/contracts/workflow-runtime.contract.js +1 -1
  15. package/dist/contracts/workflow-runtime.contract.js.map +1 -1
  16. package/dist/contracts/workflowRuntime.js +1 -1
  17. package/dist/contracts/workflowRuntime.js.map +1 -1
  18. package/dist/contradictions/index.d.ts +1 -1
  19. package/dist/contradictions/index.js +100 -99
  20. package/dist/contradictions/index.js.map +1 -1
  21. package/dist/decisions/index.d.ts +1 -1
  22. package/dist/decisions/index.js +100 -99
  23. package/dist/decisions/index.js.map +1 -1
  24. package/dist/edges/index.d.ts +1 -1
  25. package/dist/edges/index.js +100 -99
  26. package/dist/edges/index.js.map +1 -1
  27. package/dist/evidence/index.d.ts +2 -1
  28. package/dist/evidence/index.js +100 -99
  29. package/dist/evidence/index.js.map +1 -1
  30. package/dist/gatewayFacades.d.ts +18 -6
  31. package/dist/gatewayFacades.js +22 -41
  32. package/dist/gatewayFacades.js.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.js +103 -69
  35. package/dist/index.js.map +1 -1
  36. package/dist/lenses/index.d.ts +7 -5
  37. package/dist/lenses/index.js +100 -99
  38. package/dist/lenses/index.js.map +1 -1
  39. package/dist/nodes/index.d.ts +1 -1
  40. package/dist/nodes/index.js +100 -99
  41. package/dist/nodes/index.js.map +1 -1
  42. package/dist/ontologies/index.d.ts +1 -1
  43. package/dist/ontologies/index.js +100 -99
  44. package/dist/ontologies/index.js.map +1 -1
  45. package/dist/opinion.d.ts +2 -2
  46. package/dist/opinion.js +4 -4
  47. package/dist/opinion.js.map +1 -1
  48. package/dist/questions/index.d.ts +1 -1
  49. package/dist/questions/index.js +100 -99
  50. package/dist/questions/index.js.map +1 -1
  51. package/dist/topics/index.d.ts +1 -1
  52. package/dist/topics/index.js +100 -99
  53. package/dist/topics/index.js.map +1 -1
  54. package/dist/types.d.ts +7 -7
  55. package/dist/workflowClient.d.ts +18 -5
  56. package/dist/workflowClient.js +19 -7
  57. package/dist/workflowClient.js.map +1 -1
  58. package/dist/worktrees/index.d.ts +10 -7
  59. package/dist/worktrees/index.js +100 -99
  60. package/dist/worktrees/index.js.map +1 -1
  61. package/package.json +4 -3
package/README.md CHANGED
@@ -27,6 +27,7 @@ IA-7 closes the remaining SDK surface gaps needed for SDK-first clients:
27
27
  ```typescript
28
28
  import {
29
29
  createLucernClient,
30
+ opinionFromDogmatic,
30
31
  type PlatformBeliefRecord,
31
32
  type SdkPrincipalContext,
32
33
  type WorkflowWorktreeRecord,
@@ -87,45 +88,54 @@ const topicId = securityTopic.data.topicId;
87
88
  // A fact — verified and anchored
88
89
  const sqlFact = await lucern.beliefs.create({
89
90
  topicId,
90
- baseRate: 0.5,
91
91
  canonicalText: "Parameterized queries prevent SQL injection in all major database drivers",
92
92
  beliefType: "fact",
93
93
  });
94
+ const sqlFactEvidence = await lucern.evidence.create({
95
+ topicId,
96
+ text: "OWASP SQL Injection Prevention guidance identifies parameterized queries as the primary defense.",
97
+ sourceUrl: "https://owasp.org/www-community/attacks/SQL_Injection",
98
+ targetId: sqlFact.data.nodeId,
99
+ weight: 1,
100
+ });
94
101
  await lucern.beliefs.modulateConfidence(sqlFact.data.nodeId, {
95
- confidence: 0.95,
102
+ opinion: opinionFromDogmatic(0.95, 0.5),
96
103
  trigger: "evidence_added",
104
+ triggeringEvidenceId: sqlFactEvidence.data.nodeId,
97
105
  rationale: "OWASP verified, industry standard for 20+ years",
98
106
  });
99
107
 
100
108
  // A belief — confident from observation
101
109
  const patternBelief = await lucern.beliefs.create({
102
110
  topicId,
103
- baseRate: 0.5,
104
111
  canonicalText: "Most security vulnerabilities in our codebase come from unvalidated user input at API boundaries, not from cryptographic weaknesses",
105
112
  });
113
+ const patternEvidence = await lucern.evidence.create({
114
+ topicId,
115
+ text: "Last 6 months of security audits found 14 input validation issues and 1 cryptographic issue.",
116
+ sourceUrl: "audit://security/findings-last-6-months",
117
+ targetId: patternBelief.data.nodeId,
118
+ weight: 0.82,
119
+ });
106
120
  await lucern.beliefs.modulateConfidence(patternBelief.data.nodeId, {
107
- confidence: 0.82,
121
+ opinion: opinionFromDogmatic(0.82, 0.5),
108
122
  trigger: "evidence_added",
123
+ triggeringEvidenceId: patternEvidence.data.nodeId,
109
124
  rationale: "Last 6 months of security audits: 14 input validation issues, 1 crypto issue",
110
125
  });
111
126
 
112
127
  // A hypothesis — under active testing
113
128
  const hypothesis = await lucern.beliefs.create({
114
129
  topicId,
115
- baseRate: 0.5,
116
130
  canonicalText: "Automated static analysis catches fewer than 30% of the input validation vulnerabilities that human reviewers find",
117
131
  beliefType: "hypothesis",
118
132
  });
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
- });
133
+ // This remains at the default vacuous prior until evidence or an answered
134
+ // question records what the comparison study found.
124
135
 
125
136
  // An assumption — untested but used as a basis for decisions
126
137
  const assumption = await lucern.beliefs.create({
127
138
  topicId,
128
- baseRate: 0.5,
129
139
  canonicalText: "Our CI pipeline runs all static analysis rules on every PR",
130
140
  beliefType: "assumption",
131
141
  });
@@ -202,7 +212,7 @@ Your agent processes the results and commits evidence to the graph.
202
212
 
203
213
  ```typescript
204
214
  // Static analysis results
205
- await lucern.evidence.create({
215
+ const staticEvidence = await lucern.evidence.create({
206
216
  topicId,
207
217
  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
218
  sourceUrl: "ci://semgrep-run/batch-50pr-comparison",
@@ -211,7 +221,7 @@ await lucern.evidence.create({
211
221
  });
212
222
 
213
223
  // Human review results
214
- await lucern.evidence.create({
224
+ const humanEvidence = await lucern.evidence.create({
215
225
  topicId,
216
226
  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
227
  sourceUrl: "review://manual-audit/batch-50pr",
@@ -227,7 +237,7 @@ const comparisonQuestion = await lucern.questions.create({
227
237
  linkedBeliefId: hypothesis.data.nodeId,
228
238
  });
229
239
 
230
- await lucern.questions.answer(comparisonQuestion.data.questionId, {
240
+ const comparisonAnswer = await lucern.questions.answer(comparisonQuestion.data.questionId, {
231
241
  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
242
  confidence: "strong",
233
243
  evidenceIds: [staticEvidence.data.nodeId, humanEvidence.data.nodeId],
@@ -241,8 +251,9 @@ The original hypothesis said "less than 30%." The data shows 53% — but the sto
241
251
  ```typescript
242
252
  // Drop confidence on the original (it was too pessimistic about overall catch rate)
243
253
  await lucern.beliefs.modulateConfidence(hypothesis.data.nodeId, {
244
- confidence: 0.2,
254
+ opinion: opinionFromDogmatic(0.2, 0.5),
245
255
  trigger: "evidence_added",
256
+ triggeringEvidenceId: humanEvidence.data.nodeId,
246
257
  rationale: "Static analysis catches 53% overall, not <30%. But the category breakdown reveals something more important.",
247
258
  });
248
259
 
@@ -253,22 +264,24 @@ const evolved = await lucern.beliefs.fork(hypothesis.data.nodeId, {
253
264
  });
254
265
 
255
266
  await lucern.beliefs.modulateConfidence(evolved.data.nodeId, {
256
- confidence: 0.88,
267
+ opinion: opinionFromDogmatic(0.88, 0.5),
257
268
  trigger: "evidence_added",
269
+ triggeringEvidenceId: humanEvidence.data.nodeId,
270
+ triggeringAnswerId: comparisonAnswer.data.answerId,
258
271
  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
272
  });
260
273
 
261
274
  // This creates a new actionable belief
262
275
  const actionable = await lucern.beliefs.create({
263
276
  topicId,
264
- baseRate: 0.5,
265
277
  canonicalText: "Human code review should focus on business logic and concurrency — the categories where static analysis provides zero coverage",
266
278
  beliefType: "belief",
267
279
  });
268
280
 
269
281
  await lucern.beliefs.modulateConfidence(actionable.data.nodeId, {
270
- confidence: 0.85,
282
+ opinion: opinionFromDogmatic(0.85, 0.5),
271
283
  trigger: "worktree_outcome",
284
+ triggeringWorktreeId: investigation.data.worktreeId,
272
285
  rationale: "Direct implication of the comparison study findings",
273
286
  });
274
287
 
@@ -591,7 +604,6 @@ Record what you learned:
591
604
  // Create a belief for decisions made
592
605
  await lucern.beliefs.create({
593
606
  topicId,
594
- baseRate: 0.5,
595
607
  canonicalText: "<what you now believe to be true>",
596
608
  });
597
609
 
@@ -706,8 +718,8 @@ history.data.forEach(entry => {
706
718
  });
707
719
 
708
720
  // 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
721
+ // 2026-04-10T14:00:00Z null -> 0.50 [initial] Vacuous neutral prior
722
+ // 2026-04-11T09:30:00Z 0.50 -> 0.75 [evidence_added] Semgrep data supports
711
723
  // 2026-04-11T16:00:00Z 0.75 -> 0.20 [evidence_added] Comparison study contradicted
712
724
  ```
713
725
 
@@ -1,7 +1,7 @@
1
- import { ModulateConfidenceInput, OpinionHistoryEntry } from '../beliefsClient.js';
1
+ import { ModulateConfidenceOpinionInput, OpinionHistoryEntry } from '../beliefsClient.js';
2
2
  import { PlatformGatewaySuccess } from '../coreClient.js';
3
3
  import { JsonObject } from '../types.js';
4
- import { L as LucernClientConfig } from '../client-DAuKnDlx.js';
4
+ import { L as LucernClientConfig } from '../client-B6aWUUwp.js';
5
5
  import * as v1 from '@lucern/contracts/beliefs/v1';
6
6
  export { v1 as beliefsContracts };
7
7
  import * as toolContracts from '@lucern/contracts/tool-contracts';
@@ -47,7 +47,7 @@ declare function createBeliefsClient(config?: BeliefsClientConfig): {
47
47
  rationale?: string;
48
48
  worktreeId?: string;
49
49
  pillar?: string;
50
- baseRate: number;
50
+ baseRate?: number;
51
51
  sourceBeliefIds?: string[];
52
52
  sourceType?: string;
53
53
  beliefType?: string;
@@ -158,7 +158,7 @@ declare function createBeliefsClient(config?: BeliefsClientConfig): {
158
158
  beliefId?: string;
159
159
  nodeId?: string;
160
160
  }>;
161
- modulateBeliefConfidence: (nodeId: string, input: ModulateConfidenceInput) => Promise<PlatformGatewaySuccess<{
161
+ modulateBeliefConfidence: (nodeId: string, input: ModulateConfidenceOpinionInput) => Promise<PlatformGatewaySuccess<{
162
162
  [x: string]: unknown;
163
163
  }> & {
164
164
  [x: string]: unknown;
@@ -200,7 +200,7 @@ declare function createBeliefsClient(config?: BeliefsClientConfig): {
200
200
  rationale?: string;
201
201
  worktreeId?: string;
202
202
  pillar?: string;
203
- baseRate: number;
203
+ baseRate?: number;
204
204
  sourceBeliefIds?: string[];
205
205
  sourceType?: string;
206
206
  beliefType?: string;
@@ -249,12 +249,12 @@ declare function createBeliefsClient(config?: BeliefsClientConfig): {
249
249
  beliefId?: string;
250
250
  nodeId?: string;
251
251
  }>;
252
- updateConfidence(nodeId: string, input: ModulateConfidenceInput): Promise<PlatformGatewaySuccess<{
252
+ updateConfidence(nodeId: string, input: ModulateConfidenceOpinionInput): Promise<PlatformGatewaySuccess<{
253
253
  [x: string]: unknown;
254
254
  }> & {
255
255
  [x: string]: unknown;
256
256
  }>;
257
- modulateConfidence(nodeId: string, input: ModulateConfidenceInput): Promise<PlatformGatewaySuccess<{
257
+ modulateConfidence(nodeId: string, input: ModulateConfidenceOpinionInput): Promise<PlatformGatewaySuccess<{
258
258
  [x: string]: unknown;
259
259
  }> & {
260
260
  [x: string]: unknown;
@@ -1003,38 +1003,6 @@ function createAuditClient(config = {}) {
1003
1003
  };
1004
1004
  }
1005
1005
 
1006
- // src/opinion.ts
1007
- function clamp01(value) {
1008
- if (!Number.isFinite(value)) {
1009
- return 0;
1010
- }
1011
- return Math.max(0, Math.min(1, value));
1012
- }
1013
- function vacuous(baseRate = 0.5) {
1014
- return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
1015
- }
1016
- function dogmatic(probability, baseRate = 0.5) {
1017
- const p = clamp01(probability);
1018
- return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
1019
- }
1020
- function opinionFromBaseRate(probability) {
1021
- return vacuous(clamp01(probability));
1022
- }
1023
- function opinionFromDogmatic(probability, baseRate = 0.5) {
1024
- return dogmatic(clamp01(probability), clamp01(baseRate));
1025
- }
1026
- function opinionFromProjected(probability, uncertainty, baseRate = 0.5) {
1027
- const p = clamp01(probability);
1028
- const u = clamp01(uncertainty);
1029
- const remainingMass = 1 - u;
1030
- return {
1031
- b: p * remainingMass,
1032
- d: (1 - p) * remainingMass,
1033
- u,
1034
- a: clamp01(baseRate)
1035
- };
1036
- }
1037
-
1038
1006
  // src/beliefsClient.ts
1039
1007
  function asRecord2(value) {
1040
1008
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -1049,7 +1017,7 @@ function readString(value) {
1049
1017
  function readNumber(value) {
1050
1018
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
1051
1019
  }
1052
- function clamp012(value) {
1020
+ function clamp01(value) {
1053
1021
  return Math.max(0, Math.min(1, value));
1054
1022
  }
1055
1023
  function normalizeOpinionTuple(record) {
@@ -1058,20 +1026,16 @@ function normalizeOpinionTuple(record) {
1058
1026
  const rawDisbelief = readNumber(opinion.d) ?? readNumber(record.disbelief);
1059
1027
  const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
1060
1028
  const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
1061
- if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
1062
- const projected = clamp012(readNumber(record.confidence) ?? 0);
1063
- return {
1064
- b: projected,
1065
- d: 1 - projected,
1066
- u: 0,
1067
- a: 0.5
1068
- };
1029
+ if (rawBelief === void 0 || rawDisbelief === void 0 || rawUncertainty === void 0 || rawBaseRate === void 0) {
1030
+ throw new Error(
1031
+ "Gateway opinion history entries must include belief, disbelief, uncertainty, and baseRate."
1032
+ );
1069
1033
  }
1070
1034
  return {
1071
- b: clamp012(rawBelief ?? 0),
1072
- d: clamp012(rawDisbelief ?? 0),
1073
- u: clamp012(rawUncertainty ?? 0),
1074
- a: clamp012(rawBaseRate ?? 0.5)
1035
+ b: clamp01(rawBelief),
1036
+ d: clamp01(rawDisbelief),
1037
+ u: clamp01(rawUncertainty),
1038
+ a: clamp01(rawBaseRate)
1075
1039
  };
1076
1040
  }
1077
1041
  function mapOpinionHistoryEntriesFromGatewayData(payload) {
@@ -1079,28 +1043,28 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1079
1043
  return entries.map((value) => {
1080
1044
  const record = asRecord2(value);
1081
1045
  const tuple = normalizeOpinionTuple(record);
1082
- const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
1046
+ const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
1083
1047
  const triggeringEvidenceId = readString(record.triggeringEvidenceId);
1048
+ const triggeringQuestionId = readString(record.triggeringQuestionId);
1049
+ const triggeringAnswerId = readString(record.triggeringAnswerId);
1050
+ const triggeringContradictionId = readString(
1051
+ record.triggeringContradictionId
1052
+ );
1084
1053
  const triggeringWorktreeId = readString(record.triggeringWorktreeId);
1054
+ const triggeringRef = triggeringEvidenceId ? { kind: "evidence", id: triggeringEvidenceId } : triggeringQuestionId ? { kind: "question", id: triggeringQuestionId } : triggeringAnswerId ? { kind: "answer", id: triggeringAnswerId } : triggeringContradictionId ? { kind: "contradiction", id: triggeringContradictionId } : triggeringWorktreeId ? { kind: "worktree", id: triggeringWorktreeId } : void 0;
1055
+ const trigger = readString(record.trigger);
1056
+ if (!trigger) {
1057
+ throw new Error("Gateway opinion history entries must include trigger.");
1058
+ }
1085
1059
  return {
1086
1060
  t: readNumber(record.timestamp) ?? readNumber(record.assessedAt) ?? 0,
1087
1061
  b: tuple.b,
1088
1062
  d: tuple.d,
1089
1063
  u: tuple.u,
1090
1064
  a: tuple.a,
1091
- P: clamp012(projected),
1092
- trigger: readString(record.trigger) ?? "manual",
1093
- ...triggeringEvidenceId ? {
1094
- triggeringRef: {
1095
- kind: "evidence",
1096
- id: triggeringEvidenceId
1097
- }
1098
- } : triggeringWorktreeId ? {
1099
- triggeringRef: {
1100
- kind: "worktree",
1101
- id: triggeringWorktreeId
1102
- }
1103
- } : {},
1065
+ P: clamp01(projected),
1066
+ trigger,
1067
+ ...triggeringRef ? { triggeringRef } : {},
1104
1068
  ...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
1105
1069
  ...readString(record.userId) ? { userId: readString(record.userId) } : {},
1106
1070
  ...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
@@ -1108,11 +1072,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
1108
1072
  }).sort((left, right) => left.t - right.t);
1109
1073
  }
1110
1074
  function normalizeModulateConfidenceInput(input) {
1111
- const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
1112
- input.confidence,
1113
- input.uncertainty,
1114
- input.baseRate
1115
- );
1075
+ const opinion = input.opinion;
1116
1076
  return {
1117
1077
  belief: opinion.b,
1118
1078
  disbelief: opinion.d,
@@ -1120,20 +1080,23 @@ function normalizeModulateConfidenceInput(input) {
1120
1080
  baseRate: opinion.a,
1121
1081
  trigger: input.trigger,
1122
1082
  rationale: input.rationale,
1083
+ triggeringEvidenceId: input.triggeringEvidenceId,
1084
+ triggeringQuestionId: input.triggeringQuestionId,
1085
+ triggeringAnswerId: input.triggeringAnswerId,
1086
+ triggeringContradictionId: input.triggeringContradictionId,
1087
+ triggeringWorktreeId: input.triggeringWorktreeId,
1123
1088
  maxInlinePropagationTargets: input.maxInlinePropagationTargets
1124
1089
  };
1125
1090
  }
1126
1091
  function createBeliefsClient(config = {}) {
1127
1092
  const gateway = createGatewayRequestClient(config);
1128
- function requireBaseRate2(value) {
1093
+ function normalizeBaseRate(value) {
1129
1094
  const baseRate = readNumber(value);
1130
- if (baseRate === void 0) {
1131
- throw new Error("baseRate is required for belief creation.");
1132
- }
1133
- if (baseRate < 0 || baseRate > 1) {
1095
+ const normalized = baseRate ?? 0.5;
1096
+ if (normalized < 0 || normalized > 1) {
1134
1097
  throw new Error("baseRate must be within [0, 1].");
1135
1098
  }
1136
- return baseRate;
1099
+ return normalized;
1137
1100
  }
1138
1101
  const modulateConfidence = async (beliefId, input, idempotencyKey) => gateway.request({
1139
1102
  path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence`,
@@ -1152,7 +1115,7 @@ function createBeliefsClient(config = {}) {
1152
1115
  * Create a belief within a topic scope.
1153
1116
  */
1154
1117
  async createBelief(input, idempotencyKey) {
1155
- const baseRate = requireBaseRate2(input.baseRate);
1118
+ const baseRate = normalizeBaseRate(input.baseRate);
1156
1119
  return gateway.request({
1157
1120
  path: "/api/platform/v1/beliefs",
1158
1121
  method: "POST",
@@ -2248,11 +2211,7 @@ function createTopicsClient(config = {}) {
2248
2211
 
2249
2212
  // src/gatewayFacades.ts
2250
2213
  function normalizeBeliefConfidenceInput(input) {
2251
- const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
2252
- input.confidence,
2253
- input.uncertainty,
2254
- input.baseRate
2255
- );
2214
+ const opinion = input.opinion;
2256
2215
  return {
2257
2216
  belief: opinion.b,
2258
2217
  disbelief: opinion.d,
@@ -2260,6 +2219,11 @@ function normalizeBeliefConfidenceInput(input) {
2260
2219
  baseRate: opinion.a,
2261
2220
  trigger: input.trigger,
2262
2221
  rationale: input.rationale,
2222
+ triggeringEvidenceId: input.triggeringEvidenceId,
2223
+ triggeringQuestionId: input.triggeringQuestionId,
2224
+ triggeringAnswerId: input.triggeringAnswerId,
2225
+ triggeringContradictionId: input.triggeringContradictionId,
2226
+ triggeringWorktreeId: input.triggeringWorktreeId,
2263
2227
  maxInlinePropagationTargets: input.maxInlinePropagationTargets
2264
2228
  };
2265
2229
  }
@@ -2999,6 +2963,18 @@ function createWorktreesFacade(config = {}) {
2999
2963
  async list(query) {
3000
2964
  return gateway.request({
3001
2965
  path: `/api/platform/v1/worktrees${toQueryString({
2966
+ topicId: query.topicId,
2967
+ status: query.status,
2968
+ groupBy: query.groupBy,
2969
+ lane: query.lane,
2970
+ campaign: query.campaign,
2971
+ limit: query.limit
2972
+ })}`
2973
+ });
2974
+ },
2975
+ async listCampaigns(query = {}) {
2976
+ return gateway.request({
2977
+ path: `/api/platform/v1/worktrees/campaigns${toQueryString({
3002
2978
  topicId: query.topicId,
3003
2979
  status: query.status,
3004
2980
  limit: query.limit
@@ -3021,10 +2997,10 @@ function createWorktreesFacade(config = {}) {
3021
2997
  objective: input.objective,
3022
2998
  hypothesis: input.hypothesis,
3023
2999
  rationale: input.rationale,
3024
- track: input.track,
3025
- trackPosition: input.trackPosition,
3026
- executionBand: input.executionBand,
3027
- executionOrder: input.executionOrder,
3000
+ campaign: input.campaign,
3001
+ lane: input.lane,
3002
+ laneOrderInCampaign: input.laneOrderInCampaign,
3003
+ orderInLane: input.orderInLane,
3028
3004
  dependsOn: input.dependsOn,
3029
3005
  blocks: input.blocks,
3030
3006
  gate: input.gate,
@@ -3690,6 +3666,7 @@ var CONTRACTS = {
3690
3666
  "list_active_sessions": { method: "POST", path: "/coordination/active-sessions", kind: "query", idempotent: false, surfaceIntent: "system" },
3691
3667
  "list_all_worktrees": { method: "GET", path: "/worktrees/all", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3692
3668
  "list_beliefs": { method: "GET", path: "/beliefs", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
3669
+ "list_campaigns": { method: "GET", path: "/worktrees/campaigns", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3693
3670
  "list_evidence": { method: "GET", path: "/evidence", kind: "query", idempotent: false, surfaceIntent: "mcp_core" },
3694
3671
  "list_lenses": { method: "GET", path: "/lenses", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
3695
3672
  "list_ontologies": { method: "GET", path: "/ontologies", kind: "query", idempotent: false, surfaceIntent: "mcp_workflow" },
@@ -3980,6 +3957,9 @@ function createFunctionSurfaceClient(config = {}) {
3980
3957
  listBeliefs(input = {}, idempotencyKey) {
3981
3958
  return execute("list_beliefs", input, idempotencyKey);
3982
3959
  },
3960
+ listCampaigns(input = {}, idempotencyKey) {
3961
+ return execute("list_campaigns", input, idempotencyKey);
3962
+ },
3983
3963
  listEvidence(input = {}, idempotencyKey) {
3984
3964
  return execute("list_evidence", input, idempotencyKey);
3985
3965
  },
@@ -4791,10 +4771,11 @@ function createWorkflowClient(config = {}) {
4791
4771
  async listWorktrees(query) {
4792
4772
  const normalized = normalizeTopicQuery(query);
4793
4773
  return gateway.request({
4794
- path: `/api/platform/v1/worktrees${toQueryString({
4774
+ path: `/api/platform/v1/worktrees/all${toQueryString({
4795
4775
  ...normalized,
4796
- track: query.track,
4797
- executionBand: query.executionBand
4776
+ groupBy: query.groupBy,
4777
+ lane: query.lane,
4778
+ campaign: query.campaign
4798
4779
  })}`
4799
4780
  }).then(
4800
4781
  (response) => mapGatewayData(
@@ -4813,8 +4794,9 @@ function createWorkflowClient(config = {}) {
4813
4794
  return gateway.request({
4814
4795
  path: `/api/platform/v1/worktrees${toQueryString({
4815
4796
  status: query.status,
4816
- track: query.track,
4817
- executionBand: query.executionBand,
4797
+ groupBy: query.groupBy,
4798
+ lane: query.lane,
4799
+ campaign: query.campaign,
4818
4800
  limit: query.limit
4819
4801
  })}`
4820
4802
  }).then(
@@ -4826,12 +4808,22 @@ function createWorkflowClient(config = {}) {
4826
4808
  );
4827
4809
  return {
4828
4810
  ...list,
4829
- ...record.tracks && typeof record.tracks === "object" && !Array.isArray(record.tracks) ? { tracks: record.tracks } : {},
4830
- ...record.bands && typeof record.bands === "object" && !Array.isArray(record.bands) ? { bands: record.bands } : {}
4811
+ ...record.lanes && typeof record.lanes === "object" && !Array.isArray(record.lanes) ? { lanes: record.lanes } : {},
4812
+ ...record.campaigns && typeof record.campaigns === "object" && !Array.isArray(record.campaigns) ? { campaigns: record.campaigns } : {}
4831
4813
  };
4832
4814
  })
4833
4815
  );
4834
4816
  },
4817
+ /**
4818
+ * List compact pipeline campaigns with nested lanes.
4819
+ */
4820
+ async listCampaigns(query = {}) {
4821
+ return gateway.request({
4822
+ path: `/api/platform/v1/worktrees/campaigns${toQueryString(
4823
+ normalizeTopicQuery(query)
4824
+ )}`
4825
+ });
4826
+ },
4835
4827
  /**
4836
4828
  * Create a workflow worktree.
4837
4829
  */
@@ -5157,13 +5149,11 @@ function requireText(args) {
5157
5149
  return text;
5158
5150
  }
5159
5151
  function requireBaseRate(args) {
5160
- if (typeof args.baseRate !== "number" || !Number.isFinite(args.baseRate)) {
5161
- throw new Error("baseRate is required.");
5162
- }
5163
- if (args.baseRate < 0 || args.baseRate > 1) {
5152
+ const baseRate = typeof args.baseRate === "number" && Number.isFinite(args.baseRate) ? args.baseRate : 0.5;
5153
+ if (baseRate < 0 || baseRate > 1) {
5164
5154
  throw new Error("baseRate must be within [0, 1].");
5165
5155
  }
5166
- return args.baseRate;
5156
+ return baseRate;
5167
5157
  }
5168
5158
  function exposeGatewayData(response) {
5169
5159
  return Object.assign({}, response, response.data);
@@ -5281,9 +5271,13 @@ function createLucernClient(config = {}) {
5281
5271
  if (!text) {
5282
5272
  throw new Error("text is required");
5283
5273
  }
5274
+ const rationale = args.rationale ?? args.supports?.reasoning;
5275
+ if (!rationale) {
5276
+ throw new Error("rationale is required");
5277
+ }
5284
5278
  const metadata = {
5285
5279
  ...args.metadata ?? {},
5286
- ...args.supports?.reasoning ? { rationale: args.supports.reasoning } : {}
5280
+ rationale
5287
5281
  };
5288
5282
  return evidenceFacade.create({
5289
5283
  topicId: resolveTopicId(args),
@@ -5291,6 +5285,7 @@ function createLucernClient(config = {}) {
5291
5285
  source: args.source ?? args.sourceUrl,
5292
5286
  targetId: args.targetId ?? args.supports?.nodeId,
5293
5287
  weight: args.weight ?? args.supports?.weight,
5288
+ rationale,
5294
5289
  metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
5295
5290
  title: args.title,
5296
5291
  content: args.content,
@@ -6121,7 +6116,10 @@ function createLucernClient(config = {}) {
6121
6116
  beliefIds: input.beliefIds,
6122
6117
  autoShape: input.autoShape,
6123
6118
  domainPackId: input.domainPackId,
6124
- executionOrder: input.executionOrder,
6119
+ campaign: input.campaign,
6120
+ lane: input.lane,
6121
+ laneOrderInCampaign: input.laneOrderInCampaign,
6122
+ orderInLane: input.orderInLane,
6125
6123
  dependsOn: input.dependsOn,
6126
6124
  blocks: input.blocks,
6127
6125
  gate: input.gate,
@@ -6140,7 +6138,10 @@ function createLucernClient(config = {}) {
6140
6138
  beliefIds: input.beliefIds,
6141
6139
  autoShape: input.autoShape,
6142
6140
  domainPackId: input.domainPackId,
6143
- executionOrder: input.executionOrder,
6141
+ campaign: input.campaign,
6142
+ lane: input.lane,
6143
+ laneOrderInCampaign: input.laneOrderInCampaign,
6144
+ orderInLane: input.orderInLane,
6144
6145
  dependsOn: input.dependsOn,
6145
6146
  blocks: input.blocks,
6146
6147
  gate: input.gate,
@@ -6168,10 +6169,10 @@ function createLucernClient(config = {}) {
6168
6169
  return worktreesFacade.update({
6169
6170
  id: typeof input.worktreeId === "string" ? input.worktreeId : "",
6170
6171
  hypothesis: typeof input.hypothesis === "string" ? input.hypothesis : void 0,
6171
- track: typeof input.track === "string" ? input.track : void 0,
6172
- trackPosition: typeof input.trackPosition === "number" ? input.trackPosition : void 0,
6173
- executionBand: typeof input.executionBand === "number" ? input.executionBand : void 0,
6174
- executionOrder: typeof input.executionOrder === "number" ? input.executionOrder : void 0,
6172
+ campaign: typeof input.campaign === "number" ? input.campaign : void 0,
6173
+ lane: typeof input.lane === "string" ? input.lane : void 0,
6174
+ laneOrderInCampaign: typeof input.laneOrderInCampaign === "number" ? input.laneOrderInCampaign : void 0,
6175
+ orderInLane: typeof input.orderInLane === "number" ? input.orderInLane : void 0,
6175
6176
  dependsOn,
6176
6177
  blocks,
6177
6178
  gate: typeof input.gate === "string" ? input.gate : void 0