@lucern/events 0.3.0-alpha.1 → 0.3.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -26,6 +26,487 @@ function matchesAnyEventPattern(eventType, patterns) {
26
26
  return patterns.some((pattern) => matchesEventPattern(eventType, pattern));
27
27
  }
28
28
 
29
+ // ../contracts/src/graph-intelligence.contract.ts
30
+ var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
31
+ core: [
32
+ "get_graph_structure_analysis",
33
+ "get_topic_coverage",
34
+ "get_graph_gaps",
35
+ "list_beliefs",
36
+ "list_questions",
37
+ "search_evidence"
38
+ ],
39
+ bias: [
40
+ "get_graph_structure_analysis",
41
+ "detect_confirmation_bias",
42
+ "find_contradictions",
43
+ "search_evidence",
44
+ "list_beliefs"
45
+ ],
46
+ stress: [
47
+ "get_graph_structure_analysis",
48
+ "get_graph_gaps",
49
+ "find_contradictions",
50
+ "get_falsification_questions",
51
+ "list_beliefs",
52
+ "list_questions"
53
+ ],
54
+ operational: [
55
+ "get_topic_coverage",
56
+ "get_graph_gaps",
57
+ "list_beliefs",
58
+ "list_questions",
59
+ "search_evidence"
60
+ ],
61
+ alpha: [
62
+ "get_graph_structure_analysis",
63
+ "detect_confirmation_bias",
64
+ "find_contradictions",
65
+ "search_beliefs",
66
+ "search_evidence"
67
+ ],
68
+ semantic: [
69
+ "get_graph_structure_analysis",
70
+ "search_beliefs",
71
+ "search_evidence",
72
+ "traverse_graph",
73
+ "query_lineage",
74
+ "get_graph_neighborhood"
75
+ ],
76
+ evidence: [
77
+ "get_graph_structure_analysis",
78
+ "get_topic_coverage",
79
+ "search_evidence",
80
+ "get_falsification_questions",
81
+ "find_contradictions"
82
+ ]
83
+ };
84
+ var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
85
+ var GRAPH_INTELLIGENCE_QUERIES = [
86
+ {
87
+ id: "confirmation-bias",
88
+ categoryId: "problems",
89
+ mode: "bias",
90
+ name: "Find Confirmation Bias",
91
+ description: "Find beliefs supported mainly by confirming evidence.",
92
+ prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
93
+ highlightStrategy: "bias-risk",
94
+ riskLevel: "high"
95
+ },
96
+ {
97
+ id: "contradiction-map",
98
+ categoryId: "problems",
99
+ mode: "stress",
100
+ name: "Map Contradictions",
101
+ description: "Surface direct and indirect contradiction clusters.",
102
+ prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
103
+ highlightStrategy: "contradictions",
104
+ riskLevel: "high"
105
+ },
106
+ {
107
+ id: "weak-evidence",
108
+ categoryId: "problems",
109
+ mode: "stress",
110
+ name: "Weak Evidence Chains",
111
+ description: "Find important claims with thin or indirect evidence.",
112
+ prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
113
+ highlightStrategy: "weak-support",
114
+ riskLevel: "medium"
115
+ },
116
+ {
117
+ id: "single-source",
118
+ categoryId: "problems",
119
+ mode: "bias",
120
+ name: "Single-Source Risk",
121
+ description: "Find claims overly dependent on one source or source type.",
122
+ prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
123
+ highlightStrategy: "source-concentration",
124
+ riskLevel: "medium"
125
+ },
126
+ {
127
+ id: "untested-assumptions",
128
+ categoryId: "problems",
129
+ mode: "stress",
130
+ name: "Untested Assumptions",
131
+ description: "Find load-bearing assumptions without falsification paths.",
132
+ prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
133
+ highlightStrategy: "untested",
134
+ riskLevel: "high"
135
+ },
136
+ {
137
+ id: "load-bearing-beliefs",
138
+ categoryId: "problems",
139
+ mode: "stress",
140
+ name: "Load-Bearing Beliefs",
141
+ description: "Find central beliefs whose failure would affect many claims.",
142
+ prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
143
+ highlightStrategy: "load-bearing",
144
+ riskLevel: "high"
145
+ },
146
+ {
147
+ id: "cascade-analysis",
148
+ categoryId: "problems",
149
+ mode: "stress",
150
+ name: "Cascade Analysis",
151
+ description: "Trace what changes if a belief is weakened or invalidated.",
152
+ prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
153
+ highlightStrategy: "cascade",
154
+ riskLevel: "high"
155
+ },
156
+ {
157
+ id: "unanswered-questions",
158
+ categoryId: "gaps",
159
+ mode: "operational",
160
+ name: "Unanswered Questions",
161
+ description: "Find important open questions that block confidence.",
162
+ prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
163
+ highlightStrategy: "open-questions"
164
+ },
165
+ {
166
+ id: "thin-themes",
167
+ categoryId: "gaps",
168
+ mode: "operational",
169
+ name: "Thin Themes",
170
+ description: "Find topics with shallow belief or evidence coverage.",
171
+ prompt: "Find themes that look underdeveloped relative to their role in the graph.",
172
+ highlightStrategy: "thin-themes"
173
+ },
174
+ {
175
+ id: "missing-evidence",
176
+ categoryId: "gaps",
177
+ mode: "stress",
178
+ name: "Missing Evidence",
179
+ description: "Find beliefs that need specific missing evidence.",
180
+ prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
181
+ highlightStrategy: "missing-evidence"
182
+ },
183
+ {
184
+ id: "isolated-clusters",
185
+ categoryId: "gaps",
186
+ mode: "operational",
187
+ name: "Isolated Clusters",
188
+ description: "Find clusters not connected to the broader graph.",
189
+ prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
190
+ highlightStrategy: "isolated-clusters"
191
+ },
192
+ {
193
+ id: "source-contribution",
194
+ categoryId: "gaps",
195
+ mode: "evidence",
196
+ name: "Source Contribution",
197
+ description: "Assess how source mix shapes the graph.",
198
+ prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
199
+ highlightStrategy: "source-mix"
200
+ },
201
+ {
202
+ id: "stale-beliefs",
203
+ categoryId: "gaps",
204
+ mode: "operational",
205
+ name: "Stale Beliefs",
206
+ description: "Find beliefs that need review because they are old or stale.",
207
+ prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
208
+ highlightStrategy: "staleness"
209
+ },
210
+ {
211
+ id: "assumption-pyramid",
212
+ categoryId: "reasoning",
213
+ mode: "operational",
214
+ name: "Assumption Pyramid",
215
+ description: "Show which conclusions rest on which assumptions.",
216
+ prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
217
+ highlightStrategy: "assumptions"
218
+ },
219
+ {
220
+ id: "converging-evidence",
221
+ categoryId: "reasoning",
222
+ mode: "evidence",
223
+ name: "Converging Evidence",
224
+ description: "Find claims supported by independent evidence streams.",
225
+ prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
226
+ highlightStrategy: "convergence"
227
+ },
228
+ {
229
+ id: "weakest-links",
230
+ categoryId: "reasoning",
231
+ mode: "stress",
232
+ name: "Weakest Links",
233
+ description: "Find the weakest links in important reasoning chains.",
234
+ prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
235
+ highlightStrategy: "weak-links",
236
+ riskLevel: "medium"
237
+ },
238
+ {
239
+ id: "challenged-beliefs",
240
+ categoryId: "reasoning",
241
+ mode: "stress",
242
+ name: "Challenged Beliefs",
243
+ description: "Find beliefs with active challenges or defeaters.",
244
+ prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
245
+ highlightStrategy: "challenged"
246
+ },
247
+ {
248
+ id: "contrarian-map",
249
+ categoryId: "strategic",
250
+ mode: "alpha",
251
+ name: "Contrarian Map",
252
+ description: "Find non-consensus beliefs and where they are grounded.",
253
+ prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
254
+ highlightStrategy: "contrarian"
255
+ },
256
+ {
257
+ id: "irreversibility-audit",
258
+ categoryId: "strategic",
259
+ mode: "stress",
260
+ name: "Irreversibility Audit",
261
+ description: "Find irreversible bets and assumptions behind them.",
262
+ prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
263
+ highlightStrategy: "irreversible",
264
+ riskLevel: "high"
265
+ },
266
+ {
267
+ id: "pre-mortem",
268
+ categoryId: "strategic",
269
+ mode: "stress",
270
+ name: "Pre-Mortem",
271
+ description: "Explain how the graph could be wrong.",
272
+ prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
273
+ highlightStrategy: "failure-paths",
274
+ riskLevel: "high"
275
+ },
276
+ {
277
+ id: "devils-advocate",
278
+ categoryId: "strategic",
279
+ mode: "stress",
280
+ name: "Devil's Advocate",
281
+ description: "Generate the strongest critique of the graph.",
282
+ prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
283
+ highlightStrategy: "critique"
284
+ },
285
+ {
286
+ id: "falsification-map",
287
+ categoryId: "strategic",
288
+ mode: "stress",
289
+ name: "Falsification Map",
290
+ description: "Find the cheapest tests that would disprove key beliefs.",
291
+ prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
292
+ highlightStrategy: "falsification",
293
+ riskLevel: "high"
294
+ },
295
+ {
296
+ id: "prediction-tracker",
297
+ categoryId: "strategic",
298
+ mode: "evidence",
299
+ name: "Prediction Tracker",
300
+ description: "Find beliefs that imply measurable predictions.",
301
+ prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
302
+ highlightStrategy: "predictions"
303
+ },
304
+ {
305
+ id: "belief-pagerank",
306
+ categoryId: "deep",
307
+ mode: "semantic",
308
+ name: "Belief PageRank",
309
+ description: "Identify structurally central beliefs.",
310
+ prompt: "Use graph centrality to identify the most structurally important beliefs.",
311
+ highlightStrategy: "centrality"
312
+ },
313
+ {
314
+ id: "underdetermination",
315
+ categoryId: "deep",
316
+ mode: "semantic",
317
+ name: "Underdetermination",
318
+ description: "Find places where evidence supports multiple explanations.",
319
+ prompt: "Find places where the same evidence could support multiple incompatible explanations.",
320
+ highlightStrategy: "underdetermination"
321
+ },
322
+ {
323
+ id: "confidence-propagation",
324
+ categoryId: "deep",
325
+ mode: "semantic",
326
+ name: "Confidence Propagation",
327
+ description: "Assess how uncertainty moves through the graph.",
328
+ prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
329
+ highlightStrategy: "confidence-flow"
330
+ },
331
+ {
332
+ id: "argument-depth",
333
+ categoryId: "deep",
334
+ mode: "evidence",
335
+ name: "Argument Depth",
336
+ description: "Assess reasoning depth and chain quality.",
337
+ prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
338
+ highlightStrategy: "depth"
339
+ },
340
+ {
341
+ id: "information-edge",
342
+ categoryId: "deep",
343
+ mode: "alpha",
344
+ name: "Information Edge",
345
+ description: "Find differentiated evidence or signals.",
346
+ prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
347
+ highlightStrategy: "information-edge"
348
+ },
349
+ {
350
+ id: "thesis-summary",
351
+ categoryId: "browse",
352
+ mode: "semantic",
353
+ name: "Thesis Summary",
354
+ description: "Summarize the graph's core thesis and support.",
355
+ prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
356
+ highlightStrategy: "summary"
357
+ },
358
+ {
359
+ id: "theme-deep-dive",
360
+ categoryId: "browse",
361
+ mode: "semantic",
362
+ name: "Theme Deep Dive",
363
+ description: "Deep dive into a named theme.",
364
+ prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
365
+ inputType: "theme",
366
+ highlightStrategy: "theme"
367
+ },
368
+ {
369
+ id: "belief-detail",
370
+ categoryId: "browse",
371
+ mode: "semantic",
372
+ name: "Belief Detail",
373
+ description: "Explain one belief and its graph neighborhood.",
374
+ prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
375
+ inputType: "belief",
376
+ highlightStrategy: "belief"
377
+ },
378
+ {
379
+ id: "strongest-beliefs",
380
+ categoryId: "browse",
381
+ mode: "operational",
382
+ name: "Strongest Beliefs",
383
+ description: "Find the graph's strongest current beliefs.",
384
+ prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
385
+ highlightStrategy: "strongest"
386
+ },
387
+ {
388
+ id: "cross-theme-connection",
389
+ categoryId: "browse",
390
+ mode: "semantic",
391
+ name: "Cross-Theme Connections",
392
+ description: "Find bridges between themes.",
393
+ prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
394
+ highlightStrategy: "bridges"
395
+ },
396
+ {
397
+ id: "research-velocity",
398
+ categoryId: "browse",
399
+ mode: "operational",
400
+ name: "Research Velocity",
401
+ description: "Summarize recent graph movement and momentum.",
402
+ prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
403
+ highlightStrategy: "velocity"
404
+ },
405
+ {
406
+ id: "search",
407
+ categoryId: "browse",
408
+ mode: "semantic",
409
+ name: "Graph Search",
410
+ description: "Search the graph with semantic context.",
411
+ prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
412
+ inputType: "search",
413
+ highlightStrategy: "search"
414
+ },
415
+ {
416
+ id: "expert-coverage",
417
+ categoryId: "browse",
418
+ mode: "semantic",
419
+ name: "Expert Coverage",
420
+ description: "Assess coverage from expert/source perspectives.",
421
+ prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
422
+ highlightStrategy: "expert-coverage"
423
+ },
424
+ {
425
+ id: "value-chain-map",
426
+ categoryId: "browse",
427
+ mode: "semantic",
428
+ name: "Value Chain Map",
429
+ description: "Map entities, dependencies, and value-chain logic.",
430
+ prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
431
+ highlightStrategy: "value-chain"
432
+ },
433
+ {
434
+ id: "meeting-brief",
435
+ categoryId: "prep",
436
+ mode: "semantic",
437
+ name: "Meeting Brief",
438
+ description: "Prepare a meeting brief from graph context.",
439
+ prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
440
+ highlightStrategy: "brief"
441
+ },
442
+ {
443
+ id: "open-questions-entity",
444
+ categoryId: "prep",
445
+ mode: "semantic",
446
+ name: "Entity Open Questions",
447
+ description: "Find open questions about a specific entity.",
448
+ prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
449
+ inputType: "entity",
450
+ highlightStrategy: "entity-questions"
451
+ },
452
+ {
453
+ id: "company-context",
454
+ categoryId: "prep",
455
+ mode: "semantic",
456
+ name: "Company Context",
457
+ description: "Summarize graph context about a company.",
458
+ prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
459
+ inputType: "company",
460
+ highlightStrategy: "company"
461
+ },
462
+ {
463
+ id: "company-theme-fit",
464
+ categoryId: "prep",
465
+ mode: "semantic",
466
+ name: "Company Theme Fit",
467
+ description: "Assess how a company fits graph themes.",
468
+ prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
469
+ inputType: "company",
470
+ highlightStrategy: "fit"
471
+ },
472
+ {
473
+ id: "company-comparison",
474
+ categoryId: "prep",
475
+ mode: "semantic",
476
+ name: "Company Comparison",
477
+ description: "Compare companies through graph context.",
478
+ prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
479
+ inputType: "company-list",
480
+ highlightStrategy: "comparison"
481
+ },
482
+ {
483
+ id: "questions-to-ask",
484
+ categoryId: "prep",
485
+ mode: "operational",
486
+ name: "Questions to Ask",
487
+ description: "Generate high-signal questions from graph gaps.",
488
+ prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
489
+ highlightStrategy: "questions"
490
+ },
491
+ {
492
+ id: "beliefs-to-test",
493
+ categoryId: "prep",
494
+ mode: "stress",
495
+ name: "Beliefs to Test",
496
+ description: "Prioritize beliefs that should be tested next.",
497
+ prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
498
+ highlightStrategy: "tests",
499
+ riskLevel: "medium"
500
+ }
501
+ ];
502
+ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
503
+ const definition = query;
504
+ return {
505
+ ...definition,
506
+ tools: definition.tools ?? byMode(definition.mode)
507
+ };
508
+ });
509
+
29
510
  // ../contracts/src/events.contract.ts
30
511
  var DOMAIN_EVENT_VERSION = "1.0";
31
512
  var EVENT_RETENTION_DEFAULT_DAYS = 30;
@@ -176,7 +657,10 @@ function idOf(table) {
176
657
  return schema;
177
658
  }
178
659
  var NODE_TYPE = z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
179
- var EDGE_TYPE = z.enum(["supports", "informs", "depends_on", "extracted_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"]);
660
+ var EDGE_TYPE_VALUES = ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"];
661
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
662
+ z.enum(EDGE_TYPE_VALUES);
663
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
180
664
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
181
665
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
182
666
  defineTable({
@@ -1661,7 +2145,7 @@ defineTable({
1661
2145
  "toNodeId": z.string().optional(),
1662
2146
  "sourceGlobalId": z.string().optional(),
1663
2147
  "targetGlobalId": z.string().optional(),
1664
- "edgeType": EDGE_TYPE,
2148
+ "edgeType": STORAGE_EDGE_TYPE,
1665
2149
  "edgeTier": z.string().optional(),
1666
2150
  "domainNamespace": z.string().optional(),
1667
2151
  "constraint": z.string().optional(),
@@ -2004,6 +2488,40 @@ defineTable({
2004
2488
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
2005
2489
  ]
2006
2490
  });
2491
+ defineTable({
2492
+ name: "oauthDeviceCodes",
2493
+ component: "mc",
2494
+ category: "identity",
2495
+ shape: z.object({
2496
+ "deviceCodeHash": z.string(),
2497
+ "userCode": z.string(),
2498
+ "clientId": z.string(),
2499
+ "scope": z.string(),
2500
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
2501
+ "expiresAt": z.number(),
2502
+ "intervalSeconds": z.number(),
2503
+ "lastPolledAt": z.number().optional(),
2504
+ "slowDownCount": z.number().optional(),
2505
+ "clerkUserId": z.string().optional(),
2506
+ "tenantId": idOf("tenants").optional(),
2507
+ "workspaceId": z.string().optional(),
2508
+ "principalId": z.string().optional(),
2509
+ "role": z.string().optional(),
2510
+ "scopes": z.array(z.string()).optional(),
2511
+ "sessionId": z.string().optional(),
2512
+ "approvedAt": z.number().optional(),
2513
+ "deniedAt": z.number().optional(),
2514
+ "consumedAt": z.number().optional(),
2515
+ "createdAt": z.number(),
2516
+ "updatedAt": z.number()
2517
+ }),
2518
+ indices: [
2519
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
2520
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
2521
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
2522
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
2523
+ ]
2524
+ });
2007
2525
  defineTable({
2008
2526
  name: "servicePrincipalKeys",
2009
2527
  component: "mc",
@@ -3836,6 +4354,7 @@ defineTable({
3836
4354
  "updatedAt": z.number()
3837
4355
  }),
3838
4356
  indices: [
4357
+ { kind: "index", name: "by_globalId", columns: ["globalId"] },
3839
4358
  { kind: "index", name: "by_parent", columns: ["parentTopicId"] },
3840
4359
  { kind: "index", name: "by_type", columns: ["type"] },
3841
4360
  { kind: "index", name: "by_graph_scope_project", columns: ["graphScopeProjectId"] },
@@ -3960,7 +4479,9 @@ defineTable({
3960
4479
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3961
4480
  "deployments": z.record(z.object({
3962
4481
  "url": z.string(),
3963
- "encryptedDeployKey": z.string()
4482
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4483
+ "encryptedDeployKey": z.string().optional(),
4484
+ "credentialRef": z.string().optional()
3964
4485
  })).optional(),
3965
4486
  "metadata": z.record(z.any()).optional(),
3966
4487
  "createdBy": z.string().optional(),
@@ -4310,17 +4831,44 @@ z.object({
4310
4831
  message: "SL invariant b+d+u=1 violated at API boundary"
4311
4832
  }
4312
4833
  );
4313
- var EpistemicNodeTypeSchema = z.enum([
4834
+
4835
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
4836
+ var NODE_TYPES = [
4837
+ "decision",
4314
4838
  "belief",
4315
- "evidence",
4316
4839
  "question",
4317
- "answer",
4840
+ "theme",
4841
+ "deal",
4318
4842
  "topic",
4843
+ "claim",
4844
+ "evidence",
4845
+ "synthesis",
4846
+ "answer",
4847
+ "atomic_fact",
4848
+ "excerpt",
4849
+ "source",
4850
+ "company",
4851
+ "person",
4852
+ "investor",
4853
+ "function",
4854
+ "value_chain"
4855
+ ];
4856
+ new Set(NODE_TYPES);
4857
+
4858
+ // ../contracts/src/types/graph-ref.ts
4859
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4319
4860
  "edge",
4320
4861
  "ontology",
4321
4862
  "lens",
4322
4863
  "contradiction"
4323
- ]);
4864
+ ];
4865
+ var GRAPH_REF_NODE_TYPES = [
4866
+ ...NODE_TYPES,
4867
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4868
+ ];
4869
+ var EpistemicNodeTypeSchema = z.enum(
4870
+ GRAPH_REF_NODE_TYPES
4871
+ );
4324
4872
  var GraphRefSchema = z.discriminatedUnion("kind", [
4325
4873
  z.object({
4326
4874
  kind: z.literal("epistemic_node"),
@@ -4368,34 +4916,142 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4368
4916
  }
4369
4917
 
4370
4918
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
4919
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
4920
+ edgeType,
4921
+ fromKinds: ["epistemic_node"],
4922
+ toKinds: ["epistemic_node"],
4923
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
4924
+ });
4371
4925
  var edgePolicyManifest = {
4372
- policies: [
4373
- {
4374
- edgeType: "evidence_derived_from_evidence",
4375
- fromKinds: ["epistemic_node"],
4376
- fromNodeTypes: ["evidence"],
4377
- toKinds: ["epistemic_node"],
4378
- toNodeTypes: ["evidence"],
4379
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4380
- },
4381
- {
4382
- edgeType: "evidence_supports_belief",
4383
- fromKinds: ["epistemic_node"],
4384
- fromNodeTypes: ["evidence"],
4385
- toKinds: ["epistemic_node"],
4386
- toNodeTypes: ["belief"],
4387
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4388
- },
4389
- {
4390
- edgeType: "evidence_supports_question",
4391
- fromKinds: ["epistemic_node"],
4392
- fromNodeTypes: ["evidence"],
4393
- toKinds: ["epistemic_node"],
4394
- toNodeTypes: ["question"],
4395
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4396
- }
4397
- ]
4926
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
4398
4927
  };
4928
+
4929
+ // ../contracts/src/tenant-client.contract.ts
4930
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4931
+ {
4932
+ packageName: "@lucern/access-control",
4933
+ role: "runtime_entrypoint",
4934
+ directTenantImport: true
4935
+ },
4936
+ {
4937
+ packageName: "@lucern/agent",
4938
+ role: "platform_runtime",
4939
+ directTenantImport: false
4940
+ },
4941
+ {
4942
+ packageName: "@lucern/auth",
4943
+ role: "sdk_dependency",
4944
+ directTenantImport: false
4945
+ },
4946
+ {
4947
+ packageName: "@lucern/cli",
4948
+ role: "developer_tool",
4949
+ directTenantImport: false
4950
+ },
4951
+ {
4952
+ packageName: "@lucern/client-core",
4953
+ role: "sdk_dependency",
4954
+ directTenantImport: false
4955
+ },
4956
+ {
4957
+ packageName: "@lucern/confidence",
4958
+ role: "sdk_dependency",
4959
+ directTenantImport: false
4960
+ },
4961
+ {
4962
+ packageName: "@lucern/config",
4963
+ role: "configuration",
4964
+ directTenantImport: false
4965
+ },
4966
+ {
4967
+ packageName: "@lucern/contracts",
4968
+ role: "contract_entrypoint",
4969
+ directTenantImport: true
4970
+ },
4971
+ {
4972
+ packageName: "@lucern/control-plane",
4973
+ role: "platform_runtime",
4974
+ directTenantImport: false
4975
+ },
4976
+ {
4977
+ packageName: "@lucern/developer-kit",
4978
+ role: "developer_tool",
4979
+ directTenantImport: false
4980
+ },
4981
+ {
4982
+ packageName: "@lucern/events",
4983
+ role: "sdk_dependency",
4984
+ directTenantImport: false
4985
+ },
4986
+ {
4987
+ packageName: "@lucern/graph-primitives",
4988
+ role: "sdk_dependency",
4989
+ directTenantImport: false
4990
+ },
4991
+ {
4992
+ packageName: "@lucern/graph-sync",
4993
+ role: "host_addon_runtime",
4994
+ directTenantImport: true
4995
+ },
4996
+ {
4997
+ packageName: "@lucern/identity",
4998
+ role: "component_runtime",
4999
+ directTenantImport: false
5000
+ },
5001
+ {
5002
+ packageName: "@lucern/mcp",
5003
+ role: "runtime_entrypoint",
5004
+ directTenantImport: true
5005
+ },
5006
+ {
5007
+ packageName: "@lucern/pack-host",
5008
+ role: "platform_runtime",
5009
+ directTenantImport: false
5010
+ },
5011
+ {
5012
+ packageName: "@lucern/pack-installer",
5013
+ role: "developer_tool",
5014
+ directTenantImport: false
5015
+ },
5016
+ {
5017
+ packageName: "@lucern/proof-compiler",
5018
+ role: "developer_tool",
5019
+ directTenantImport: false
5020
+ },
5021
+ {
5022
+ packageName: "@lucern/react",
5023
+ role: "runtime_entrypoint",
5024
+ directTenantImport: true
5025
+ },
5026
+ {
5027
+ packageName: "@lucern/reasoning-kernel",
5028
+ role: "component_runtime",
5029
+ directTenantImport: false
5030
+ },
5031
+ {
5032
+ packageName: "@lucern/sdk",
5033
+ role: "runtime_entrypoint",
5034
+ directTenantImport: true
5035
+ },
5036
+ {
5037
+ packageName: "@lucern/server-core",
5038
+ role: "platform_runtime",
5039
+ directTenantImport: false
5040
+ },
5041
+ {
5042
+ packageName: "@lucern/testing",
5043
+ role: "test_support",
5044
+ directTenantImport: false
5045
+ },
5046
+ {
5047
+ packageName: "@lucern/types",
5048
+ role: "contract_entrypoint",
5049
+ directTenantImport: true
5050
+ }
5051
+ ];
5052
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
5053
+ (entry) => entry.packageName
5054
+ );
4399
5055
  z.object({
4400
5056
  manifestVersion: z.literal("1.0.0"),
4401
5057
  rules: z.array(
@@ -4456,8 +5112,11 @@ function compactRecord(input) {
4456
5112
  Object.entries(input).filter(([, value]) => value !== void 0)
4457
5113
  );
4458
5114
  }
5115
+ function isRecord(value) {
5116
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5117
+ }
4459
5118
  function recordValue(value) {
4460
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
5119
+ return isRecord(value) ? value : {};
4461
5120
  }
4462
5121
  var createEvidenceProjection = defineProjection({
4463
5122
  contractName: "create_evidence",
@@ -5157,7 +5816,22 @@ var ADD_WORKTREE = {
5157
5816
  description: "Check out a branch into an active worktree for investigation. Like `git worktree add <branch>` \u2014 creates independent working state on a thematic branch. Beliefs committed within the worktree can be freely amended (draft code on a feature branch). When investigation is complete, `merge` integrates findings into main.",
5158
5817
  parameters: {
5159
5818
  title: { type: "string", description: "Worktree name/objective" },
5160
- topicId: { type: "string", description: "Optional topic scope hint" },
5819
+ name: {
5820
+ type: "string",
5821
+ description: "Optional storage-name alias for callers that already use backend naming"
5822
+ },
5823
+ projectId: {
5824
+ type: "string",
5825
+ description: "Legacy topicId alias or resolver hint"
5826
+ },
5827
+ topicId: {
5828
+ type: "string",
5829
+ description: "Optional topic scope hint for resolver validation"
5830
+ },
5831
+ topicHint: {
5832
+ type: "string",
5833
+ description: "Natural-language topic hint for automatic topic resolution"
5834
+ },
5161
5835
  branchId: {
5162
5836
  type: "string",
5163
5837
  description: "The branch this worktree investigates"
@@ -5170,18 +5844,107 @@ var ADD_WORKTREE = {
5170
5844
  type: "string",
5171
5845
  description: "The testable claim this worktree investigates"
5172
5846
  },
5847
+ rationale: {
5848
+ type: "string",
5849
+ description: "Why this worktree exists and why it belongs in the campaign"
5850
+ },
5851
+ worktreeType: {
5852
+ type: "string",
5853
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5854
+ },
5855
+ gate: {
5856
+ type: "string",
5857
+ description: "Exit gate name for this worktree"
5858
+ },
5859
+ startDate: {
5860
+ type: "number",
5861
+ description: "Planned start timestamp in milliseconds since epoch"
5862
+ },
5863
+ endDate: {
5864
+ type: "number",
5865
+ description: "Planned end timestamp in milliseconds since epoch"
5866
+ },
5867
+ durationWeeks: {
5868
+ type: "number",
5869
+ description: "Planned duration in weeks"
5870
+ },
5871
+ confidenceImpact: {
5872
+ type: "string",
5873
+ description: "Expected confidence impact if the worktree succeeds",
5874
+ enum: ["high", "medium", "low"]
5875
+ },
5876
+ beliefFocus: {
5877
+ type: "string",
5878
+ description: "Natural-language focus spanning the target belief neighborhood"
5879
+ },
5173
5880
  beliefIds: {
5174
5881
  type: "array",
5175
- description: "Beliefs to test in this worktree"
5882
+ description: "Legacy alias for targetBeliefIds"
5883
+ },
5884
+ beliefs: {
5885
+ type: "array",
5886
+ description: "Legacy alias for targetBeliefIds"
5887
+ },
5888
+ targetBeliefIds: {
5889
+ type: "array",
5890
+ description: "Belief node IDs this worktree is expected to test or update"
5891
+ },
5892
+ targetQuestionIds: {
5893
+ type: "array",
5894
+ description: "Question node IDs this worktree is expected to answer"
5895
+ },
5896
+ keyQuestions: {
5897
+ type: "array",
5898
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5899
+ },
5900
+ evidenceSignals: {
5901
+ type: "array",
5902
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5903
+ },
5904
+ decisionGate: {
5905
+ type: "object",
5906
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5907
+ },
5908
+ goCriteria: {
5909
+ type: "array",
5910
+ description: "Shorthand go criteria used to build decisionGate"
5911
+ },
5912
+ noGoSignals: {
5913
+ type: "array",
5914
+ description: "Shorthand no-go signals used to build decisionGate"
5915
+ },
5916
+ proofArtifacts: {
5917
+ type: "array",
5918
+ description: "Expected proof artifacts required to close the worktree"
5176
5919
  },
5177
5920
  autoShape: {
5178
5921
  type: "boolean",
5179
5922
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5180
5923
  },
5924
+ autoFixPolicy: {
5925
+ type: "object",
5926
+ description: "Policy for permitted automatic remediation inside the worktree"
5927
+ },
5181
5928
  domainPackId: {
5182
5929
  type: "string",
5183
5930
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5184
5931
  },
5932
+ tags: {
5933
+ type: "array",
5934
+ description: "Additional topic-resolution tags for the worktree"
5935
+ },
5936
+ touchedPaths: {
5937
+ type: "array",
5938
+ description: "File paths used as topic-resolution signals"
5939
+ },
5940
+ sourceRef: {
5941
+ type: "string",
5942
+ description: "Source reference used as a topic-resolution signal"
5943
+ },
5944
+ sourceKind: {
5945
+ type: "string",
5946
+ description: "Source kind used as a topic-resolution signal"
5947
+ },
5185
5948
  campaign: {
5186
5949
  type: "number",
5187
5950
  description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
@@ -5206,13 +5969,21 @@ var ADD_WORKTREE = {
5206
5969
  type: "array",
5207
5970
  description: "Worktree IDs blocked by this worktree"
5208
5971
  },
5209
- gate: {
5972
+ staffingHint: {
5210
5973
  type: "string",
5211
- description: "Exit gate name for this worktree"
5212
- }
5213
- },
5214
- required: ["title", "topicId"],
5215
- response: {
5974
+ description: "Suggested staffing or agent allocation note"
5975
+ },
5976
+ lensId: {
5977
+ type: "string",
5978
+ description: "Lens that scopes this worktree when applicable"
5979
+ },
5980
+ lastReconciledAt: {
5981
+ type: "number",
5982
+ description: "Timestamp when worktree metadata was last reconciled"
5983
+ }
5984
+ },
5985
+ required: ["title"],
5986
+ response: {
5216
5987
  description: "The created worktree",
5217
5988
  fields: {
5218
5989
  worktreeId: "string",
@@ -5238,7 +6009,7 @@ var MERGE = {
5238
6009
  worktreeId: { type: "string", description: "The worktree to merge" },
5239
6010
  outcomes: {
5240
6011
  type: "array",
5241
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
6012
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5242
6013
  },
5243
6014
  summary: { type: "string", description: "Overall findings summary" }
5244
6015
  },
@@ -5456,19 +6227,23 @@ var FIND_CONTRADICTIONS = {
5456
6227
  };
5457
6228
  var CREATE_EDGE = {
5458
6229
  name: "create_edge",
5459
- description: "Commit a typed relationship between two nodes in the reasoning graph. Like `git commit` \u2014 an atomic write that declares a dependency between nodes. The engine enforces layer transition rules \u2014 for example, L1 \u2192 L3 direct edges are forbidden (must go through L2).",
6230
+ description: "Commit a typed relationship between two nodes in the reasoning graph. Like `git commit` \u2014 an atomic write that declares a dependency between nodes. Accepts any public epistemic edge type between public graph node refs so agents can author the full spine.",
5460
6231
  parameters: {
5461
- sourceId: {
5462
- type: "string",
5463
- description: "Source node of the relationship"
6232
+ from: {
6233
+ type: "object",
6234
+ description: "Source graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'topic' }"
5464
6235
  },
5465
- targetId: {
5466
- type: "string",
5467
- description: "Target node of the relationship"
6236
+ to: {
6237
+ type: "object",
6238
+ description: "Target graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'belief' }"
5468
6239
  },
5469
6240
  edgeType: {
5470
6241
  type: "string",
5471
- description: "Relationship type (informs, tests, depends_on, supersedes, etc.)"
6242
+ description: "Relationship type from the public epistemic edge enum."
6243
+ },
6244
+ globalId: {
6245
+ type: "string",
6246
+ description: "Optional idempotent edge global ID."
5472
6247
  },
5473
6248
  weight: {
5474
6249
  type: "number",
@@ -5479,9 +6254,13 @@ var CREATE_EDGE = {
5479
6254
  type: "string",
5480
6255
  description: "How this was determined",
5481
6256
  enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
6257
+ },
6258
+ metadata: {
6259
+ type: "object",
6260
+ description: "Optional edge metadata."
5482
6261
  }
5483
6262
  },
5484
- required: ["sourceId", "targetId", "edgeType"],
6263
+ required: ["from", "to", "edgeType"],
5485
6264
  response: {
5486
6265
  description: "The created edge",
5487
6266
  fields: {
@@ -5495,6 +6274,240 @@ var CREATE_EDGE = {
5495
6274
  ontologyPrimitive: "edge",
5496
6275
  tier: "showcase"
5497
6276
  };
6277
+ var UPDATE_EDGE = {
6278
+ name: "update_edge",
6279
+ description: "Amend metadata on an existing graph edge. Like `git commit --amend` \u2014 changes the edge annotation without recreating the relationship.",
6280
+ parameters: {
6281
+ edgeId: { type: "string", description: "Edge ID or global ID to update" },
6282
+ weight: { type: "number", description: "Updated edge weight" },
6283
+ confidence: { type: "number", description: "Updated confidence" },
6284
+ context: { type: "string", description: "Updated human-readable context" },
6285
+ derivationType: { type: "string", description: "Updated derivation type" },
6286
+ metadata: { type: "object", description: "Updated metadata" }
6287
+ },
6288
+ required: ["edgeId"],
6289
+ response: {
6290
+ description: "Edge update result",
6291
+ fields: { success: "boolean" }
6292
+ },
6293
+ ownerModule: "graph-primitives",
6294
+ ontologyPrimitive: "edge",
6295
+ tier: "workhorse"
6296
+ };
6297
+ var REMOVE_EDGE = {
6298
+ name: "remove_edge",
6299
+ description: "Remove one graph edge by ID. Like `git rm` \u2014 deletes a single explicit relationship from the spine.",
6300
+ parameters: {
6301
+ edgeId: { type: "string", description: "Edge ID or global ID to remove" }
6302
+ },
6303
+ required: ["edgeId"],
6304
+ response: {
6305
+ description: "Edge removal result",
6306
+ fields: { success: "boolean" }
6307
+ },
6308
+ ownerModule: "graph-primitives",
6309
+ ontologyPrimitive: "edge",
6310
+ tier: "workhorse"
6311
+ };
6312
+ var REMOVE_EDGES_BETWEEN = {
6313
+ name: "remove_edges_between",
6314
+ description: "Remove graph edges between two nodes. Like `git rm <pathspec>` \u2014 deletes relationships matching a source, target, and optional type.",
6315
+ parameters: {
6316
+ fromNodeId: { type: "string", description: "Source node ID or global ID" },
6317
+ toNodeId: { type: "string", description: "Target node ID or global ID" },
6318
+ edgeType: { type: "string", description: "Optional edge type filter" }
6319
+ },
6320
+ required: ["fromNodeId", "toNodeId"],
6321
+ response: {
6322
+ description: "Matched edge removal result",
6323
+ fields: { deleted: "number" }
6324
+ },
6325
+ ownerModule: "graph-primitives",
6326
+ ontologyPrimitive: "edge",
6327
+ tier: "workhorse"
6328
+ };
6329
+ var BATCH_CREATE_EDGES = {
6330
+ name: "batch_create_edges",
6331
+ description: "Commit multiple typed graph edges. Like `git commit` with many staged paths \u2014 writes a batch of explicit relationships atomically per edge.",
6332
+ parameters: {
6333
+ edges: {
6334
+ type: "array",
6335
+ description: "Edges to create, each with from, to, edgeType, and optional weight/confidence/context."
6336
+ },
6337
+ skipLayerValidation: {
6338
+ type: "boolean",
6339
+ description: "Skip kernel layer validation for trusted materialization flows."
6340
+ }
6341
+ },
6342
+ required: ["edges"],
6343
+ response: {
6344
+ description: "Batch edge creation result",
6345
+ fields: {
6346
+ created: "number",
6347
+ results: "array",
6348
+ errors: "array"
6349
+ }
6350
+ },
6351
+ ownerModule: "graph-primitives",
6352
+ ontologyPrimitive: "edge",
6353
+ tier: "workhorse"
6354
+ };
6355
+ var CREATE_EPISTEMIC_NODE = {
6356
+ name: "create_epistemic_node",
6357
+ description: "Commit a generic epistemic graph node. Like `git commit` \u2014 creates a canonical node in the public spine for topics, beliefs, evidence, questions, answers, sources, and entities.",
6358
+ parameters: {
6359
+ globalId: { type: "string", description: "Optional idempotent node global ID" },
6360
+ nodeType: { type: "string", description: "Public epistemic node type" },
6361
+ canonicalText: { type: "string", description: "Canonical node text" },
6362
+ text: { type: "string", description: "Alias for canonicalText" },
6363
+ contentHash: { type: "string", description: "Optional idempotency content hash" },
6364
+ sourceType: { type: "string", description: "Source type for provenance" },
6365
+ topicId: { type: "string", description: "Optional topic scope" },
6366
+ content: { type: "string", description: "Extended content" },
6367
+ title: { type: "string", description: "Display title" },
6368
+ metadata: { type: "object", description: "Optional node metadata" }
6369
+ },
6370
+ required: ["nodeType"],
6371
+ response: {
6372
+ description: "Created node result",
6373
+ fields: {
6374
+ nodeId: "string",
6375
+ nodeGlobalId: "string",
6376
+ isDuplicate: "boolean"
6377
+ }
6378
+ },
6379
+ ownerModule: "reasoning-kernel",
6380
+ ontologyPrimitive: "graph",
6381
+ tier: "showcase"
6382
+ };
6383
+ var GET_EPISTEMIC_NODE = {
6384
+ name: "get_epistemic_node",
6385
+ description: "Read one epistemic graph node. Like `git show` \u2014 resolves a canonical spine node by ID or global ID.",
6386
+ parameters: {
6387
+ nodeId: { type: "string", description: "Node ID or global ID" }
6388
+ },
6389
+ required: ["nodeId"],
6390
+ response: {
6391
+ description: "The resolved node",
6392
+ fields: { node: "object" }
6393
+ },
6394
+ ownerModule: "reasoning-kernel",
6395
+ ontologyPrimitive: "graph",
6396
+ tier: "workhorse"
6397
+ };
6398
+ var LIST_EPISTEMIC_NODES = {
6399
+ name: "list_epistemic_nodes",
6400
+ description: "List epistemic graph nodes. Like `git ls-tree` \u2014 lists canonical spine nodes by topic, type, status, or search query.",
6401
+ parameters: {
6402
+ topicId: { type: "string", description: "Optional topic scope" },
6403
+ nodeType: { type: "string", description: "Optional node type filter" },
6404
+ status: { type: "string", description: "Optional lifecycle status" },
6405
+ searchQuery: { type: "string", description: "Optional text search query" },
6406
+ limit: { type: "number", description: "Maximum nodes to return" }
6407
+ },
6408
+ required: [],
6409
+ response: {
6410
+ description: "Matching nodes",
6411
+ fields: { nodes: "array" }
6412
+ },
6413
+ ownerModule: "reasoning-kernel",
6414
+ ontologyPrimitive: "graph",
6415
+ tier: "workhorse"
6416
+ };
6417
+ var UPDATE_EPISTEMIC_NODE = {
6418
+ name: "update_epistemic_node",
6419
+ description: "Amend an epistemic graph node. Like `git commit --amend` \u2014 updates mutable node metadata, text, status, or verification fields.",
6420
+ parameters: {
6421
+ nodeId: { type: "string", description: "Node ID or global ID" },
6422
+ canonicalText: { type: "string", description: "Updated canonical text" },
6423
+ text: { type: "string", description: "Alias for canonicalText" },
6424
+ contentHash: { type: "string", description: "Updated content hash" },
6425
+ content: { type: "string", description: "Updated content" },
6426
+ title: { type: "string", description: "Updated display title" },
6427
+ metadata: { type: "object", description: "Updated metadata" },
6428
+ confidence: { type: "number", description: "Updated confidence" },
6429
+ verificationStatus: { type: "string", description: "Updated verification status" },
6430
+ status: { type: "string", description: "Updated lifecycle status" }
6431
+ },
6432
+ required: ["nodeId"],
6433
+ response: {
6434
+ description: "Node update result",
6435
+ fields: { success: "boolean" }
6436
+ },
6437
+ ownerModule: "reasoning-kernel",
6438
+ ontologyPrimitive: "graph",
6439
+ tier: "workhorse"
6440
+ };
6441
+ var ARCHIVE_EPISTEMIC_NODE = {
6442
+ name: "archive_epistemic_node",
6443
+ description: "Archive an epistemic graph node. Like `git rm --cached` \u2014 removes a node from active traversal without hard-deleting it.",
6444
+ parameters: {
6445
+ nodeId: { type: "string", description: "Node ID or global ID" }
6446
+ },
6447
+ required: ["nodeId"],
6448
+ response: {
6449
+ description: "Archive result",
6450
+ fields: { success: "boolean", effectiveStatus: "string" }
6451
+ },
6452
+ ownerModule: "reasoning-kernel",
6453
+ ontologyPrimitive: "graph",
6454
+ tier: "workhorse"
6455
+ };
6456
+ var VERIFY_EPISTEMIC_NODE = {
6457
+ name: "verify_epistemic_node",
6458
+ description: "Record verification state on an epistemic graph node. Like `git tag` \u2014 marks the node with a reviewed verification state.",
6459
+ parameters: {
6460
+ nodeId: { type: "string", description: "Node ID or global ID" },
6461
+ verificationStatus: { type: "string", description: "Verification status" },
6462
+ confidence: { type: "number", description: "Optional confidence update" }
6463
+ },
6464
+ required: ["nodeId", "verificationStatus"],
6465
+ response: {
6466
+ description: "Verification result",
6467
+ fields: { success: "boolean" }
6468
+ },
6469
+ ownerModule: "reasoning-kernel",
6470
+ ontologyPrimitive: "graph",
6471
+ tier: "workhorse"
6472
+ };
6473
+ var SUPERSEDE_EPISTEMIC_NODE = {
6474
+ name: "supersede_epistemic_node",
6475
+ description: "Supersede an epistemic graph node with a new version. Like `git commit --amend` on an immutable history branch \u2014 creates the replacement and marks the old node superseded.",
6476
+ parameters: {
6477
+ oldNodeId: { type: "string", description: "Node ID or global ID to supersede" },
6478
+ newGlobalId: { type: "string", description: "Optional replacement global ID" },
6479
+ newCanonicalText: { type: "string", description: "Replacement canonical text" },
6480
+ text: { type: "string", description: "Alias for newCanonicalText" },
6481
+ newContentHash: { type: "string", description: "Optional replacement content hash" },
6482
+ reason: { type: "string", description: "Reason for superseding" }
6483
+ },
6484
+ required: ["oldNodeId"],
6485
+ response: {
6486
+ description: "Supersede result",
6487
+ fields: { oldNodeId: "string", newNodeId: "string" }
6488
+ },
6489
+ ownerModule: "reasoning-kernel",
6490
+ ontologyPrimitive: "graph",
6491
+ tier: "workhorse"
6492
+ };
6493
+ var BATCH_CREATE_EPISTEMIC_NODES = {
6494
+ name: "batch_create_epistemic_nodes",
6495
+ description: "Commit multiple epistemic graph nodes. Like `git commit` with many staged files \u2014 writes a batch of canonical spine nodes.",
6496
+ parameters: {
6497
+ nodes: {
6498
+ type: "array",
6499
+ description: "Nodes to create with nodeType, canonicalText/text, and optional metadata."
6500
+ }
6501
+ },
6502
+ required: ["nodes"],
6503
+ response: {
6504
+ description: "Batch node creation result",
6505
+ fields: { created: "number", results: "array" }
6506
+ },
6507
+ ownerModule: "reasoning-kernel",
6508
+ ontologyPrimitive: "graph",
6509
+ tier: "workhorse"
6510
+ };
5498
6511
  var RECORD_JUDGMENT = {
5499
6512
  name: "record_judgment",
5500
6513
  description: "Record a judgment \u2014 an irreversible commitment based on the current epistemic state. Like a `git tag` marking a release. A judgment synthesizes beliefs, evidence, and uncertainties into a determination. Once issued, a judgment is evaluated against the epistemic state that existed when it was made (knowledge horizon evaluation, Invariant #10).",
@@ -5792,6 +6805,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5792
6805
  ontologyPrimitive: "graph",
5793
6806
  tier: "showcase"
5794
6807
  };
6808
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6809
+ name: "list_graph_intelligence_queries",
6810
+ description: "List the Graph Intelligence query catalog that powers structural graph analysis experiences. Returns categories, query IDs, prompt templates, modes, and the public tool plan each query can use.",
6811
+ parameters: {
6812
+ categoryId: {
6813
+ type: "string",
6814
+ description: "Optional category filter, such as problems or strategic"
6815
+ },
6816
+ mode: {
6817
+ type: "string",
6818
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6819
+ }
6820
+ },
6821
+ required: [],
6822
+ response: {
6823
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6824
+ fields: {
6825
+ categories: "array \u2014 query categories",
6826
+ queries: "array \u2014 query definitions with prompt templates and tools",
6827
+ quickQueries: "array \u2014 recommended one-click query presets",
6828
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6829
+ }
6830
+ },
6831
+ ownerModule: "graph-intelligence",
6832
+ ontologyPrimitive: "graph",
6833
+ tier: "showcase"
6834
+ };
6835
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6836
+ name: "run_graph_intelligence_query",
6837
+ description: "Run a named Graph Intelligence query against a tenant topic graph. Returns the selected query, prompt, deterministic graph-analysis bundle, graph context, and public tool plan for model synthesis.",
6838
+ parameters: {
6839
+ topicId: { type: "string", description: "Topic to analyze" },
6840
+ queryId: {
6841
+ type: "string",
6842
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6843
+ },
6844
+ prompt: {
6845
+ type: "string",
6846
+ description: "Optional custom prompt for custom analysis runs"
6847
+ },
6848
+ input: {
6849
+ type: "string",
6850
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6851
+ },
6852
+ mode: {
6853
+ type: "string",
6854
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6855
+ },
6856
+ limit: {
6857
+ type: "number",
6858
+ description: "Maximum graph context rows to return"
6859
+ }
6860
+ },
6861
+ required: ["topicId"],
6862
+ response: {
6863
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6864
+ fields: {
6865
+ query: "object \u2014 selected query definition",
6866
+ prompt: "string \u2014 resolved prompt template",
6867
+ toolPlan: "array \u2014 public tools and args the model can call next",
6868
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6869
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6870
+ }
6871
+ },
6872
+ ownerModule: "graph-intelligence",
6873
+ ontologyPrimitive: "graph",
6874
+ tier: "showcase"
6875
+ };
5795
6876
  var GET_FALSIFICATION_QUESTIONS = {
5796
6877
  name: "get_falsification_questions",
5797
6878
  description: "Generate Popperian falsification questions for beliefs. Like `git test` \u2014 identifies the questions most likely to disprove current beliefs. Karl Popper as a tool: surfaces what would need to be true to invalidate each belief.",
@@ -6640,15 +7721,15 @@ var IDENTITY_WHOAMI = {
6640
7721
  };
6641
7722
  var COMPILE_CONTEXT = {
6642
7723
  name: "compile_context",
6643
- description: "Compile a focused reasoning context for a topic. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
7724
+ description: "Compile a focused reasoning context. If topicId is omitted, Lucern resolves the best topic from the query. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
6644
7725
  parameters: {
6645
7726
  topicId: {
6646
7727
  type: "string",
6647
- description: "Topic scope ID to compile"
7728
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
6648
7729
  },
6649
7730
  query: {
6650
7731
  type: "string",
6651
- description: "Optional focus query used to rank context items"
7732
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
6652
7733
  },
6653
7734
  budget: {
6654
7735
  type: "number",
@@ -6672,7 +7753,7 @@ var COMPILE_CONTEXT = {
6672
7753
  description: "Include related ontological entities in the compiled result"
6673
7754
  }
6674
7755
  },
6675
- required: ["topicId"],
7756
+ required: [],
6676
7757
  response: {
6677
7758
  description: "Compiled context pack for the requested topic",
6678
7759
  fields: {
@@ -6846,18 +7927,60 @@ var CREATE_TASK = {
6846
7927
  name: "create_task",
6847
7928
  description: "Create an execution task tied to the reasoning state. Like `git task` \u2014 tracks concrete work items (calls to make, data to gather, analyses to run) linked to questions, beliefs, or worktrees.",
6848
7929
  parameters: {
6849
- title: { type: "string", description: "Task description" },
7930
+ title: { type: "string", description: "Task title" },
6850
7931
  topicId: { type: "string", description: "Topic scope" },
7932
+ description: {
7933
+ type: "string",
7934
+ description: "Long-form task description"
7935
+ },
6851
7936
  taskType: {
6852
7937
  type: "string",
6853
- description: "Type: research, interview, analysis, data_collection",
6854
- enum: ["research", "interview", "analysis", "data_collection"]
7938
+ description: "Task taxonomy",
7939
+ enum: [
7940
+ "general",
7941
+ "find_evidence",
7942
+ "verify_claim",
7943
+ "research",
7944
+ "review",
7945
+ "interview",
7946
+ "analysis",
7947
+ "track_metrics"
7948
+ ]
7949
+ },
7950
+ priority: {
7951
+ type: "string",
7952
+ description: "Priority",
7953
+ enum: ["urgent", "high", "medium", "low"]
7954
+ },
7955
+ status: {
7956
+ type: "string",
7957
+ description: "Initial status (defaults to todo)",
7958
+ enum: ["todo", "in_progress", "blocked", "done"]
7959
+ },
7960
+ linkedWorktreeId: {
7961
+ type: "string",
7962
+ description: "Worktree this task belongs to"
7963
+ },
7964
+ linkedBeliefId: {
7965
+ type: "string",
7966
+ description: "Belief this task supports"
6855
7967
  },
6856
7968
  linkedQuestionId: {
6857
7969
  type: "string",
6858
7970
  description: "Question this task addresses"
6859
7971
  },
6860
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
7972
+ assigneeId: {
7973
+ type: "string",
7974
+ description: "Principal assigned to the task"
7975
+ },
7976
+ dueDate: {
7977
+ type: "number",
7978
+ description: "Due date as epoch milliseconds"
7979
+ },
7980
+ tags: {
7981
+ type: "array",
7982
+ description: "Free-form string tags"
7983
+ }
6861
7984
  },
6862
7985
  required: ["title"],
6863
7986
  response: {
@@ -6977,6 +8100,10 @@ var CREATE_TOPIC = {
6977
8100
  name: "create_topic",
6978
8101
  description: "Create a new topic container for scoping knowledge. Like `git init` \u2014 initializes a new repository for a knowledge domain. Topics are hierarchical: a deal topic can nest under a theme topic. Types: domain, theme, deal, strategy, constitution, project, portfolio.",
6979
8102
  parameters: {
8103
+ globalId: {
8104
+ type: "string",
8105
+ description: "Optional idempotent topic global ID"
8106
+ },
6980
8107
  name: { type: "string", description: "Topic name" },
6981
8108
  type: {
6982
8109
  type: "string",
@@ -6987,6 +8114,18 @@ var CREATE_TOPIC = {
6987
8114
  type: "string",
6988
8115
  description: "Optional parent topic for nesting"
6989
8116
  },
8117
+ parentTopicGlobalId: {
8118
+ type: "string",
8119
+ description: "Optional parent topic global ID for nesting"
8120
+ },
8121
+ tenantId: { type: "string", description: "Optional tenant scope" },
8122
+ workspaceId: { type: "string", description: "Optional workspace scope" },
8123
+ visibility: {
8124
+ type: "string",
8125
+ description: "Topic visibility",
8126
+ enum: ["private", "team", "firm", "external", "public"]
8127
+ },
8128
+ metadata: { type: "object", description: "Optional topic metadata" },
6990
8129
  createdBy: { type: "string", description: "Who created this topic" }
6991
8130
  },
6992
8131
  required: ["name", "type"],
@@ -6995,6 +8134,9 @@ var CREATE_TOPIC = {
6995
8134
  fields: {
6996
8135
  id: "string \u2014 topic ID",
6997
8136
  globalId: "string \u2014 globally unique ID",
8137
+ topicGlobalId: "string \u2014 topic global ID",
8138
+ epistemicNodeId: "string \u2014 materialized topic node ID",
8139
+ epistemicNodeGlobalId: "string \u2014 materialized topic node global ID",
6998
8140
  depth: "number \u2014 nesting depth"
6999
8141
  }
7000
8142
  },
@@ -7125,6 +8267,65 @@ var GET_TOPIC_TREE = {
7125
8267
  ontologyPrimitive: "graph",
7126
8268
  tier: "workhorse"
7127
8269
  };
8270
+ var MATERIALIZE_TOPIC_GRAPH = {
8271
+ name: "materialize_topic_graph",
8272
+ description: "Backfill the topic graph spine. Like `git fsck --connectivity-only` with repair enabled \u2014 creates missing topic nodes and parent-child edges idempotently.",
8273
+ parameters: {
8274
+ rootTopicId: {
8275
+ type: "string",
8276
+ description: "Optional root topic for a bounded materialization pass"
8277
+ },
8278
+ dryRun: {
8279
+ type: "boolean",
8280
+ description: "When true, report missing rows without writing them"
8281
+ }
8282
+ },
8283
+ required: [],
8284
+ response: {
8285
+ description: "Topic graph materialization counts",
8286
+ fields: {
8287
+ topicsSeen: "number",
8288
+ nodesCreated: "number",
8289
+ nodesExisting: "number",
8290
+ edgesCreated: "number",
8291
+ edgesExisting: "number",
8292
+ errors: "array"
8293
+ }
8294
+ },
8295
+ ownerModule: "reasoning-kernel",
8296
+ ontologyPrimitive: "graph",
8297
+ tier: "workhorse"
8298
+ };
8299
+ var GET_TOPIC_GRAPH_SPINE = {
8300
+ name: "get_topic_graph_spine",
8301
+ description: "Verify the topic graph spine. Like `git fsck` \u2014 reads topics, materialized topic nodes, parent-child edges, and missing spine rows.",
8302
+ parameters: {
8303
+ rootTopicId: {
8304
+ type: "string",
8305
+ description: "Optional root topic for a bounded verifier pass"
8306
+ },
8307
+ includeTopicBeliefEdges: {
8308
+ type: "boolean",
8309
+ description: "Include topic -> belief edges in the verifier payload"
8310
+ }
8311
+ },
8312
+ required: [],
8313
+ response: {
8314
+ description: "Topic graph spine verification payload",
8315
+ fields: {
8316
+ ok: "boolean",
8317
+ counts: "object",
8318
+ topics: "array",
8319
+ topicNodes: "array",
8320
+ parentEdges: "array",
8321
+ missingTopicNodes: "array",
8322
+ missingParentEdges: "array"
8323
+ }
8324
+ },
8325
+ ownerModule: "reasoning-kernel",
8326
+ ontologyPrimitive: "graph",
8327
+ tier: "workhorse"
8328
+ };
7128
8329
  var GET_CODE_CONTEXT = {
7129
8330
  name: "get_code_context",
7130
8331
  description: "Returns code-grounded beliefs, contracts, migration states, and failed attempts anchored to a specific file or function path. Like `git log -- <path>` \u2014 filters the knowledge graph to nodes anchored to a file path via metadata.codeAnchors. Results are separated by coding belief type: decisions, contracts, migrations, patterns, deprecations, and failures.",
@@ -8257,27 +9458,90 @@ var GENERATE_SESSION_HANDOFF = {
8257
9458
  tier: "showcase",
8258
9459
  internal: true
8259
9460
  };
8260
- var MCP_TOOL_CONTRACTS = {
8261
- // Belief lifecycle (commit, amend, fork, archive)
8262
- create_belief: CREATE_BELIEF,
8263
- get_belief: GET_BELIEF,
8264
- refine_belief: REFINE_BELIEF,
8265
- modulate_confidence: MODULATE_CONFIDENCE,
8266
- fork_belief: FORK_BELIEF,
8267
- archive_belief: ARCHIVE_BELIEF,
8268
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8269
- evaluate_contract: EVALUATE_CONTRACT,
8270
- get_contract_status: GET_CONTRACT_STATUS,
8271
- // Evidence (commit)
8272
- create_evidence: CREATE_EVIDENCE,
8273
- get_evidence: GET_EVIDENCE,
8274
- list_evidence: LIST_EVIDENCE,
8275
- link_evidence: LINK_EVIDENCE,
8276
- add_evidence: ADD_EVIDENCE,
8277
- // Contradictions (merge conflict)
8278
- flag_contradiction: FLAG_CONTRADICTION,
8279
- // Lens lifecycle (workspace-scoped operational frames)
8280
- create_lens: CREATE_LENS,
9461
+ var BEGIN_BUILD_SESSION = {
9462
+ name: "begin_build_session",
9463
+ description: "Bootstrap a coding build session for a Lucern worktree. Like `git worktree add` plus `git status` \u2014 returns the compact context packet an agent needs before editing.",
9464
+ parameters: {
9465
+ worktreeId: {
9466
+ type: "string",
9467
+ description: "The Lucern worktree ID to bootstrap."
9468
+ },
9469
+ branch: {
9470
+ type: "string",
9471
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
9472
+ },
9473
+ branchBase: {
9474
+ type: "string",
9475
+ description: 'Base branch for the feature branch. Default: "staging".'
9476
+ },
9477
+ prBase: {
9478
+ type: "string",
9479
+ description: 'Target branch for the PR. Default: "staging".'
9480
+ },
9481
+ sessionMode: {
9482
+ type: "string",
9483
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
9484
+ enum: ["async", "interactive"]
9485
+ },
9486
+ activateIfPlanning: {
9487
+ type: "boolean",
9488
+ description: "When true, automatically activate a planning worktree during bootstrap."
9489
+ }
9490
+ },
9491
+ required: ["worktreeId"],
9492
+ response: {
9493
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
9494
+ fields: {
9495
+ topicId: "string \u2014 canonical topic scope",
9496
+ topicName: "string \u2014 human-readable topic name",
9497
+ worktreeId: "string \u2014 worktree ID",
9498
+ worktreeName: "string \u2014 human-readable worktree name",
9499
+ branch: "string \u2014 git branch name",
9500
+ branchBase: "string \u2014 base branch",
9501
+ prBase: "string \u2014 PR target branch",
9502
+ campaign: "number | null \u2014 top-level pipeline campaign",
9503
+ lane: "string \u2014 campaign lane",
9504
+ gate: "string \u2014 exit gate",
9505
+ hypothesis: "string \u2014 worktree hypothesis",
9506
+ focus: "string \u2014 session focus",
9507
+ status: "string \u2014 worktree status after optional activation",
9508
+ sessionMode: "string \u2014 async | interactive",
9509
+ targetBeliefIds: "array \u2014 scoped belief IDs",
9510
+ targetQuestionIds: "array \u2014 scoped question IDs",
9511
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
9512
+ openQuestions: "array \u2014 open scoped questions",
9513
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
9514
+ dependencies: "array \u2014 upstream worktrees",
9515
+ unblocks: "array \u2014 downstream worktrees",
9516
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
9517
+ }
9518
+ },
9519
+ ownerModule: "bootstrap",
9520
+ ontologyPrimitive: "worktree",
9521
+ tier: "showcase",
9522
+ internal: true
9523
+ };
9524
+ var MCP_TOOL_CONTRACTS = {
9525
+ // Belief lifecycle (commit, amend, fork, archive)
9526
+ create_belief: CREATE_BELIEF,
9527
+ get_belief: GET_BELIEF,
9528
+ refine_belief: REFINE_BELIEF,
9529
+ modulate_confidence: MODULATE_CONFIDENCE,
9530
+ fork_belief: FORK_BELIEF,
9531
+ archive_belief: ARCHIVE_BELIEF,
9532
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
9533
+ evaluate_contract: EVALUATE_CONTRACT,
9534
+ get_contract_status: GET_CONTRACT_STATUS,
9535
+ // Evidence (commit)
9536
+ create_evidence: CREATE_EVIDENCE,
9537
+ get_evidence: GET_EVIDENCE,
9538
+ list_evidence: LIST_EVIDENCE,
9539
+ link_evidence: LINK_EVIDENCE,
9540
+ add_evidence: ADD_EVIDENCE,
9541
+ // Contradictions (merge conflict)
9542
+ flag_contradiction: FLAG_CONTRADICTION,
9543
+ // Lens lifecycle (workspace-scoped operational frames)
9544
+ create_lens: CREATE_LENS,
8281
9545
  list_lenses: LIST_LENSES,
8282
9546
  apply_lens_to_topic: APPLY_LENS_TO_TOPIC,
8283
9547
  remove_lens_from_topic: REMOVE_LENS_FROM_TOPIC,
@@ -8299,11 +9563,26 @@ var MCP_TOOL_CONTRACTS = {
8299
9563
  bisect_confidence: BISECT_CONFIDENCE,
8300
9564
  // Edges (commit)
8301
9565
  create_edge: CREATE_EDGE,
9566
+ update_edge: UPDATE_EDGE,
9567
+ remove_edge: REMOVE_EDGE,
9568
+ remove_edges_between: REMOVE_EDGES_BETWEEN,
9569
+ batch_create_edges: BATCH_CREATE_EDGES,
9570
+ // Epistemic node spine (commit/amend/show)
9571
+ create_epistemic_node: CREATE_EPISTEMIC_NODE,
9572
+ get_epistemic_node: GET_EPISTEMIC_NODE,
9573
+ list_epistemic_nodes: LIST_EPISTEMIC_NODES,
9574
+ update_epistemic_node: UPDATE_EPISTEMIC_NODE,
9575
+ archive_epistemic_node: ARCHIVE_EPISTEMIC_NODE,
9576
+ verify_epistemic_node: VERIFY_EPISTEMIC_NODE,
9577
+ supersede_epistemic_node: SUPERSEDE_EPISTEMIC_NODE,
9578
+ batch_create_epistemic_nodes: BATCH_CREATE_EPISTEMIC_NODES,
8302
9579
  // Judgments (tag)
8303
9580
  record_judgment: RECORD_JUDGMENT,
8304
9581
  // Graph intelligence (showcase)
8305
9582
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8306
9583
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9584
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9585
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8307
9586
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8308
9587
  // Evidence operations (workhorse)
8309
9588
  search_evidence: SEARCH_EVIDENCE,
@@ -8350,6 +9629,7 @@ var MCP_TOOL_CONTRACTS = {
8350
9629
  get_agent_inbox: GET_AGENT_INBOX,
8351
9630
  claim_files: CLAIM_FILES,
8352
9631
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9632
+ begin_build_session: BEGIN_BUILD_SESSION,
8353
9633
  // Policy / ACL (workhorse)
8354
9634
  check_permission: CHECK_PERMISSION,
8355
9635
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8369,6 +9649,8 @@ var MCP_TOOL_CONTRACTS = {
8369
9649
  get_topic: GET_TOPIC,
8370
9650
  update_topic: UPDATE_TOPIC,
8371
9651
  get_topic_tree: GET_TOPIC_TREE,
9652
+ materialize_topic_graph: MATERIALIZE_TOPIC_GRAPH,
9653
+ get_topic_graph_spine: GET_TOPIC_GRAPH_SPINE,
8372
9654
  // Coding intelligence (code-grounded knowledge)
8373
9655
  get_code_context: GET_CODE_CONTEXT,
8374
9656
  get_change_history: GET_CHANGE_HISTORY,
@@ -8473,18 +9755,34 @@ var MCP_CORE_OPERATION_NAMES = [
8473
9755
  "find_missing_questions",
8474
9756
  "get_high_priority_questions",
8475
9757
  "get_falsification_questions",
9758
+ "create_epistemic_node",
9759
+ "get_epistemic_node",
9760
+ "list_epistemic_nodes",
9761
+ "update_epistemic_node",
9762
+ "archive_epistemic_node",
9763
+ "verify_epistemic_node",
9764
+ "supersede_epistemic_node",
9765
+ "batch_create_epistemic_nodes",
8476
9766
  "create_topic",
8477
9767
  "get_topic",
8478
9768
  "list_topics",
8479
9769
  "update_topic",
8480
- "get_topic_tree"
9770
+ "get_topic_tree",
9771
+ "materialize_topic_graph",
9772
+ "get_topic_graph_spine"
8481
9773
  ];
8482
9774
  var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8483
9775
  "create_edge",
9776
+ "update_edge",
9777
+ "remove_edge",
9778
+ "remove_edges_between",
9779
+ "batch_create_edges",
8484
9780
  "query_lineage",
8485
9781
  "traverse_graph",
8486
9782
  "get_graph_neighborhood",
8487
9783
  "get_graph_structure_analysis",
9784
+ "list_graph_intelligence_queries",
9785
+ "run_graph_intelligence_query",
8488
9786
  "find_contradictions",
8489
9787
  "flag_contradiction",
8490
9788
  "detect_confirmation_bias",
@@ -8563,6 +9861,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8563
9861
  "get_change_history",
8564
9862
  "get_failure_log",
8565
9863
  "record_attempt",
9864
+ "begin_build_session",
8566
9865
  "push",
8567
9866
  "open_pull_request",
8568
9867
  "record_judgment",
@@ -8617,7 +9916,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8617
9916
  "find_semantic_orphans"
8618
9917
  ];
8619
9918
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8620
- "begin_build_session",
8621
9919
  "evaluate_engineering_contract",
8622
9920
  "evaluate_research_contract"
8623
9921
  ];
@@ -8872,9 +10170,7 @@ function mcpContractFromArgsSchema(base, args, contractName) {
8872
10170
  required: converted.filter(([, field]) => field.required).map(([fieldName]) => fieldName)
8873
10171
  };
8874
10172
  }
8875
- function defineFunctionContract(contract) {
8876
- return contract;
8877
- }
10173
+ var defineFunctionContract = (contract) => contract;
8878
10174
  function authUserId(context) {
8879
10175
  return context.userId ?? context.principalId ?? "lucern-agent";
8880
10176
  }
@@ -9003,8 +10299,34 @@ function assertSurfaceCoverage(contracts) {
9003
10299
  }
9004
10300
  }
9005
10301
  }
9006
-
9007
- // ../contracts/src/function-registry/context.ts
10302
+ var jsonRecordSchema2 = z.record(z.unknown());
10303
+ var observationArgs = z.object({
10304
+ topicId: z.string().optional().describe("Topic scope for the observation."),
10305
+ summary: z.string().describe("Short observation summary."),
10306
+ text: z.string().optional().describe("Canonical observation text alias."),
10307
+ title: z.string().optional().describe("Optional observation title."),
10308
+ content: z.string().optional().describe("Optional rich observation content."),
10309
+ contentType: z.string().optional().describe("Observation content type."),
10310
+ kind: z.string().optional().describe("Evidence kind to store."),
10311
+ observationType: z.string().optional().describe("Observation type."),
10312
+ tags: z.array(z.string()).optional().describe("Observation tags."),
10313
+ source: z.string().optional().describe("Observation source label."),
10314
+ sourceType: z.string().optional().describe("Evidence source type."),
10315
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
10316
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10317
+ confidence: z.number().optional().describe("Observation confidence."),
10318
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
10319
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
10320
+ });
10321
+ var observationContextArgs = z.object({
10322
+ topicId: z.string().describe("Topic scope."),
10323
+ query: z.string().optional().describe("Optional context query."),
10324
+ limit: z.number().optional().describe("Maximum observations to return."),
10325
+ status: z.string().optional().describe("Observation status filter.")
10326
+ });
10327
+ function isRecord2(value) {
10328
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10329
+ }
9008
10330
  var observationInput = (input, context) => withUserId(
9009
10331
  compactRecord4({
9010
10332
  projectId: input.projectId,
@@ -9037,7 +10359,7 @@ var contextContracts = [
9037
10359
  path: "/context/compile",
9038
10360
  sdkNamespace: "context",
9039
10361
  sdkMethod: "compileContext",
9040
- summary: "Compile a focused reasoning context for a topic.",
10362
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
9041
10363
  convex: {
9042
10364
  module: "contextCompiler",
9043
10365
  functionName: "compile",
@@ -9059,11 +10381,12 @@ var contextContracts = [
9059
10381
  kind: "mutation",
9060
10382
  inputProjection: observationInput,
9061
10383
  outputProjection: (output, input) => ({
9062
- ...output && typeof output === "object" ? output : {},
9063
- observationId: output && typeof output === "object" ? output.nodeId : void 0,
10384
+ ...isRecord2(output) ? output : {},
10385
+ observationId: isRecord2(output) ? output.nodeId : void 0,
9064
10386
  observationType: input.observationType
9065
10387
  })
9066
- }
10388
+ },
10389
+ args: observationArgs
9067
10390
  }),
9068
10391
  surfaceContract({
9069
10392
  name: "get_observation_context",
@@ -9084,7 +10407,8 @@ var contextContracts = [
9084
10407
  status: input.status,
9085
10408
  userId: input.userId
9086
10409
  })
9087
- }
10410
+ },
10411
+ args: observationContextArgs
9088
10412
  })
9089
10413
  ];
9090
10414
 
@@ -9147,8 +10471,45 @@ var identityContracts = [
9147
10471
  }
9148
10472
  })
9149
10473
  ];
9150
-
9151
- // ../contracts/src/function-registry/beliefs.ts
10474
+ var jsonRecordSchema3 = z.record(z.unknown());
10475
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
10476
+ var reversibilitySchema = z.enum([
10477
+ "irreversible",
10478
+ "hard_to_reverse",
10479
+ "reversible",
10480
+ "trivial"
10481
+ ]);
10482
+ var predictionMetaSchema = z.object({
10483
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
10484
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
10485
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
10486
+ });
10487
+ var createBeliefArgs = z.object({
10488
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
10489
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
10490
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
10491
+ beliefType: z.string().optional().describe("Schema belief type."),
10492
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
10493
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
10494
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
10495
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
10496
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
10497
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
10498
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
10499
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
10500
+ });
10501
+ var forkBeliefArgs = z.object({
10502
+ nodeId: z.string().describe("The scored belief to fork from."),
10503
+ newFormulation: z.string().describe("The evolved belief statement."),
10504
+ forkReason: z.enum([
10505
+ "refinement",
10506
+ "contradiction_response",
10507
+ "scope_change",
10508
+ "confidence_collapse",
10509
+ "manual"
10510
+ ]).describe("Why this fork was created."),
10511
+ rationale: z.string().optional().describe("Why the fork is warranted.")
10512
+ });
9152
10513
  var beliefLookupInput = (input) => compactRecord4({
9153
10514
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9154
10515
  beliefId: input.beliefId
@@ -9223,7 +10584,8 @@ var beliefsContracts = [
9223
10584
  functionName: "create",
9224
10585
  kind: "mutation",
9225
10586
  inputProjection: createBeliefInput
9226
- }
10587
+ },
10588
+ args: createBeliefArgs
9227
10589
  }),
9228
10590
  surfaceContract({
9229
10591
  name: "get_belief",
@@ -9314,7 +10676,8 @@ var beliefsContracts = [
9314
10676
  functionName: "forkBelief",
9315
10677
  kind: "mutation",
9316
10678
  inputProjection: forkBeliefInput
9317
- }
10679
+ },
10680
+ args: forkBeliefArgs
9318
10681
  }),
9319
10682
  surfaceContract({
9320
10683
  name: "archive_belief",
@@ -9395,8 +10758,46 @@ var beliefsContracts = [
9395
10758
  }
9396
10759
  })
9397
10760
  ];
9398
-
9399
- // ../contracts/src/function-registry/evidence.ts
10761
+ var jsonRecordSchema4 = z.record(z.unknown());
10762
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10763
+ var createEvidenceArgs = z.object({
10764
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10765
+ text: z.string().describe("Canonical evidence text."),
10766
+ source: z.string().optional().describe("Source URL or source label."),
10767
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10768
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10769
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10770
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10771
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10772
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10773
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10774
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10775
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10776
+ title: z.string().optional().describe("Optional short title."),
10777
+ content: z.string().optional().describe("Optional long-form content."),
10778
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10779
+ kind: z.string().optional().describe("Evidence kind."),
10780
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10781
+ sourceType: z.string().optional().describe("Evidence source type."),
10782
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10783
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10784
+ methodology: z.string().optional().describe("Collection methodology."),
10785
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10786
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10787
+ });
10788
+ var addEvidenceArgs = z.object({
10789
+ canonicalText: z.string().describe("The evidence statement."),
10790
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10791
+ topicId: z.string().optional().describe("Topic scope hint."),
10792
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10793
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10794
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10795
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10796
+ title: z.string().optional().describe("Optional short title."),
10797
+ content: z.string().optional().describe("Optional long-form evidence content."),
10798
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10799
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10800
+ });
9400
10801
  var evidenceIdInput = (input) => compactRecord4({
9401
10802
  evidenceId: input.evidenceId,
9402
10803
  insightId: input.insightId,
@@ -9424,12 +10825,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
9424
10825
  compactRecord4({
9425
10826
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9426
10827
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
9427
- edgeType: "evidence_supports_belief",
10828
+ edgeType: "informs",
9428
10829
  globalId: input.globalId ?? `edge:${String(
9429
10830
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9430
10831
  )}:${String(
9431
10832
  input.beliefNodeId ?? input.beliefId ?? input.targetId
9432
- )}:evidence_supports_belief`,
10833
+ )}:informs`,
9433
10834
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
9434
10835
  context: input.rationale ?? input.context,
9435
10836
  skipLayerValidation: true,
@@ -9442,12 +10843,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
9442
10843
  compactRecord4({
9443
10844
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9444
10845
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
9445
- edgeType: "evidence_supports_question",
10846
+ edgeType: "responds_to",
9446
10847
  globalId: input.globalId ?? `edge:${String(
9447
10848
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9448
10849
  )}:${String(
9449
10850
  input.questionId ?? input.questionNodeId ?? input.targetId
9450
- )}:evidence_supports_question`,
10851
+ )}:responds_to`,
9451
10852
  weight: input.impactScore ?? input.weight,
9452
10853
  context: input.rationale ?? input.context,
9453
10854
  skipLayerValidation: true,
@@ -9471,7 +10872,8 @@ var evidenceContracts = [
9471
10872
  functionName: "create",
9472
10873
  kind: "mutation",
9473
10874
  inputProjection: createEvidenceInput
9474
- }
10875
+ },
10876
+ args: createEvidenceArgs
9475
10877
  }),
9476
10878
  surfaceContract({
9477
10879
  name: "add_evidence",
@@ -9507,7 +10909,8 @@ var evidenceContracts = [
9507
10909
  context
9508
10910
  );
9509
10911
  }
9510
- }
10912
+ },
10913
+ args: addEvidenceArgs
9511
10914
  }),
9512
10915
  surfaceContract({
9513
10916
  name: "get_evidence",
@@ -9614,8 +11017,91 @@ var evidenceContracts = [
9614
11017
  }
9615
11018
  })
9616
11019
  ];
9617
-
9618
- // ../contracts/src/function-registry/questions.ts
11020
+ var jsonRecordSchema5 = z.record(z.unknown());
11021
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
11022
+ var kernelQuestionPrioritySchema = z.enum([
11023
+ "critical",
11024
+ "high",
11025
+ "medium",
11026
+ "low"
11027
+ ]);
11028
+ var questionTypeSchema = z.enum([
11029
+ "validation",
11030
+ "falsification",
11031
+ "assumption_probe",
11032
+ "prediction_test",
11033
+ "counterfactual",
11034
+ "discovery",
11035
+ "clarification",
11036
+ "comparison",
11037
+ "causal",
11038
+ "mechanism",
11039
+ "general"
11040
+ ]);
11041
+ var createQuestionArgs = z.object({
11042
+ text: z.string().describe("The question text."),
11043
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
11044
+ topicId: z.string().optional().describe("Topic scope hint."),
11045
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
11046
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
11047
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
11048
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
11049
+ category: z.string().optional().describe("Question category."),
11050
+ source: z.string().optional().describe("Question source."),
11051
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
11052
+ importance: z.number().optional().describe("Numeric importance score."),
11053
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
11054
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
11055
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
11056
+ questionType: questionTypeSchema.optional().describe("Question type."),
11057
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
11058
+ });
11059
+ var refineQuestionArgs = z.object({
11060
+ id: z.string().describe("The question to refine."),
11061
+ text: z.string().describe("Updated question text."),
11062
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
11063
+ rationale: z.string().optional().describe("Why the question is refined."),
11064
+ category: z.string().optional().describe("Updated question category."),
11065
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
11066
+ });
11067
+ var createAnswerArgs = z.object({
11068
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
11069
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
11070
+ answerText: z.string().describe("The answer content."),
11071
+ topicId: z.string().optional().describe("Topic scope for the answer."),
11072
+ confidence: z.string().optional().describe("Answer confidence."),
11073
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
11074
+ answerSource: z.string().optional().describe("How the answer was produced."),
11075
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
11076
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
11077
+ });
11078
+ var answerQuestionArgs = z.object({
11079
+ id: z.string().describe("Canonical question ID."),
11080
+ topicId: z.string().describe("Topic scope for the answer."),
11081
+ text: z.string().describe("Answer text."),
11082
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
11083
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
11084
+ rationale: z.string().optional().describe("Why this answer is credible."),
11085
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
11086
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
11087
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
11088
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
11089
+ answerSource: z.string().optional().describe("How the answer was produced."),
11090
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
11091
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
11092
+ });
11093
+ var missingQuestionsArgs = z.object({
11094
+ topicId: z.string().describe("Topic scope."),
11095
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
11096
+ status: z.string().optional().describe("Question status filter."),
11097
+ limit: z.number().optional().describe("Maximum questions to inspect.")
11098
+ });
11099
+ var falsificationQuestionsArgs = z.object({
11100
+ topicId: z.string().describe("Topic scope."),
11101
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
11102
+ status: z.string().optional().describe("Question status filter."),
11103
+ limit: z.number().optional().describe("Maximum questions to inspect.")
11104
+ });
9619
11105
  var questionNodeInput = (input) => compactRecord4({
9620
11106
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9621
11107
  questionId: input.questionId
@@ -9662,7 +11148,8 @@ var questionsContracts = [
9662
11148
  functionName: "create",
9663
11149
  kind: "mutation",
9664
11150
  inputProjection: createQuestionInput
9665
- }
11151
+ },
11152
+ args: createQuestionArgs
9666
11153
  }),
9667
11154
  surfaceContract({
9668
11155
  name: "get_question",
@@ -9718,7 +11205,8 @@ var questionsContracts = [
9718
11205
  category: input.category,
9719
11206
  priority: input.priority
9720
11207
  })
9721
- }
11208
+ },
11209
+ args: refineQuestionArgs
9722
11210
  }),
9723
11211
  surfaceContract({
9724
11212
  name: "update_question_status",
@@ -9794,7 +11282,8 @@ var questionsContracts = [
9794
11282
  }),
9795
11283
  context
9796
11284
  )
9797
- }
11285
+ },
11286
+ args: createAnswerArgs
9798
11287
  }),
9799
11288
  surfaceContract({
9800
11289
  name: "answer_question",
@@ -9823,7 +11312,8 @@ var questionsContracts = [
9823
11312
  }),
9824
11313
  context
9825
11314
  )
9826
- }
11315
+ },
11316
+ args: answerQuestionArgs
9827
11317
  }),
9828
11318
  surfaceContract({
9829
11319
  name: "get_answer",
@@ -9855,7 +11345,8 @@ var questionsContracts = [
9855
11345
  functionName: "getByTopic",
9856
11346
  kind: "query",
9857
11347
  inputProjection: questionTopicInput
9858
- }
11348
+ },
11349
+ args: missingQuestionsArgs
9859
11350
  }),
9860
11351
  surfaceContract({
9861
11352
  name: "get_high_priority_questions",
@@ -9890,11 +11381,54 @@ var questionsContracts = [
9890
11381
  functionName: "getByTopic",
9891
11382
  kind: "query",
9892
11383
  inputProjection: questionTopicInput
9893
- }
11384
+ },
11385
+ args: falsificationQuestionsArgs
9894
11386
  })
9895
11387
  ];
9896
-
9897
- // ../contracts/src/function-registry/topics.ts
11388
+ var topicVisibilitySchema = z.enum([
11389
+ "private",
11390
+ "team",
11391
+ "firm",
11392
+ "external",
11393
+ "public"
11394
+ ]);
11395
+ var topicStatusSchema = z.enum(["active", "archived", "watching"]);
11396
+ var createTopicArgs = z.object({
11397
+ globalId: z.string().optional().describe("Optional idempotent topic global ID."),
11398
+ name: z.string().describe("Topic name."),
11399
+ description: z.string().optional().describe("Topic description."),
11400
+ type: z.string().describe("Topic type."),
11401
+ parentTopicId: z.string().optional().describe("Optional parent topic ID."),
11402
+ parentTopicGlobalId: z.string().optional().describe("Optional parent topic global ID."),
11403
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11404
+ tenantId: z.string().optional().describe("Optional tenant scope."),
11405
+ workspaceId: z.string().optional().describe("Optional workspace scope."),
11406
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11407
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata."),
11408
+ graphScopeProjectId: z.string().optional(),
11409
+ createdBy: z.string().optional()
11410
+ });
11411
+ var updateTopicArgs = z.object({
11412
+ id: z.string().describe("Topic ID."),
11413
+ topicId: z.string().optional().describe("Topic ID alias."),
11414
+ name: z.string().optional().describe("Topic name."),
11415
+ description: z.string().optional().describe("Topic description."),
11416
+ type: z.string().optional().describe("Topic type."),
11417
+ status: topicStatusSchema.optional().describe("Topic status."),
11418
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11419
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11420
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
11421
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
11422
+ });
11423
+ var materializeTopicGraphArgs = z.object({
11424
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11425
+ dryRun: z.boolean().optional().describe("Report missing rows without writing."),
11426
+ createdBy: z.string().optional()
11427
+ });
11428
+ var getTopicGraphSpineArgs = z.object({
11429
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11430
+ includeTopicBeliefEdges: z.boolean().optional()
11431
+ });
9898
11432
  var topicIdInput = (input) => compactRecord4({
9899
11433
  id: input.id ?? input.topicId
9900
11434
  });
@@ -9925,7 +11459,8 @@ var topicsContracts = [
9925
11459
  functionName: "create",
9926
11460
  kind: "mutation",
9927
11461
  inputProjection: withCreatedBy
9928
- }
11462
+ },
11463
+ args: createTopicArgs
9929
11464
  }),
9930
11465
  surfaceContract({
9931
11466
  name: "get_topic",
@@ -9975,7 +11510,8 @@ var topicsContracts = [
9975
11510
  functionName: "update",
9976
11511
  kind: "mutation",
9977
11512
  inputProjection: updateTopicInput
9978
- }
11513
+ },
11514
+ args: updateTopicArgs
9979
11515
  }),
9980
11516
  surfaceContract({
9981
11517
  name: "get_topic_tree",
@@ -9992,92 +11528,512 @@ var topicsContracts = [
9992
11528
  functionName: "getTree",
9993
11529
  kind: "query"
9994
11530
  }
11531
+ }),
11532
+ surfaceContract({
11533
+ name: "materialize_topic_graph",
11534
+ kind: "mutation",
11535
+ domain: "topics",
11536
+ surfaceClass: "platform_public",
11537
+ path: "/topics/materialize-graph",
11538
+ sdkNamespace: "topics",
11539
+ sdkMethod: "materializeTopicGraph",
11540
+ summary: "Materialize topic nodes and parent-child graph edges.",
11541
+ convex: {
11542
+ module: "topics",
11543
+ functionName: "materializeTopicGraph",
11544
+ kind: "mutation",
11545
+ inputProjection: withCreatedBy
11546
+ },
11547
+ args: materializeTopicGraphArgs
11548
+ }),
11549
+ surfaceContract({
11550
+ name: "get_topic_graph_spine",
11551
+ kind: "query",
11552
+ domain: "topics",
11553
+ surfaceClass: "platform_public",
11554
+ method: "GET",
11555
+ path: "/topics/graph-spine",
11556
+ sdkNamespace: "topics",
11557
+ sdkMethod: "getTopicGraphSpine",
11558
+ summary: "Verify topic nodes and parent-child graph edges.",
11559
+ convex: {
11560
+ module: "topics",
11561
+ functionName: "getTopicGraphSpine",
11562
+ kind: "query"
11563
+ },
11564
+ args: getTopicGraphSpineArgs
9995
11565
  })
9996
11566
  ];
9997
-
9998
- // ../contracts/src/function-registry/lenses.ts
9999
- var createLensInput = (input, context) => compactRecord4({
10000
- name: input.name,
10001
- description: input.description,
10002
- workspaceId: input.workspaceId,
10003
- topicId: input.topicId,
10004
- perspectiveType: input.perspectiveType,
10005
- promptTemplates: input.promptTemplates,
10006
- workflowTemplates: input.workflowTemplates,
10007
- taskTemplates: input.taskTemplates,
10008
- questionTemplates: input.questionTemplates,
10009
- filterCriteria: input.filterCriteria,
10010
- metadata: input.metadata,
10011
- createdBy: authUserId(context)
11567
+ var sourceTypeSchema2 = z.enum([
11568
+ "human",
11569
+ "ai_extracted",
11570
+ "ai_generated",
11571
+ "imported",
11572
+ "system",
11573
+ "verified",
11574
+ "proprietary"
11575
+ ]);
11576
+ var verificationStatusSchema = z.enum([
11577
+ "unverified",
11578
+ "human_verified",
11579
+ "ai_verified",
11580
+ "contradicted",
11581
+ "outdated"
11582
+ ]);
11583
+ var nodeStatusSchema = z.enum([
11584
+ "active",
11585
+ "superseded",
11586
+ "archived",
11587
+ "deleted"
11588
+ ]);
11589
+ var externalIdsArgs = z.object({
11590
+ crunchbase: z.string().optional(),
11591
+ linkedin: z.string().optional(),
11592
+ pitchbook: z.string().optional(),
11593
+ twitter: z.string().optional(),
11594
+ website: z.string().optional()
11595
+ }).optional();
11596
+ var createEpistemicNodeItemArgs = z.object({
11597
+ globalId: z.string().optional().describe("Optional idempotent node global ID."),
11598
+ nodeType: NODE_TYPE.describe("Public epistemic node type."),
11599
+ subtype: z.string().optional(),
11600
+ canonicalText: z.string().optional().describe("Canonical node text."),
11601
+ text: z.string().optional().describe("Alias for canonicalText."),
11602
+ contentHash: z.string().optional().describe("Optional idempotency content hash."),
11603
+ content: z.string().optional(),
11604
+ contentType: z.string().optional(),
11605
+ title: z.string().optional(),
11606
+ tags: z.array(z.string()).optional(),
11607
+ domain: z.string().optional(),
11608
+ metadata: z.record(z.unknown()).optional(),
11609
+ externalIds: externalIdsArgs,
11610
+ sourceType: sourceTypeSchema2.optional(),
11611
+ aiProvider: z.string().optional(),
11612
+ extractedFromNodeId: z.string().optional(),
11613
+ confidence: z.number().optional(),
11614
+ verificationStatus: verificationStatusSchema.optional(),
11615
+ topicId: z.string().optional(),
11616
+ projectId: z.string().optional(),
11617
+ createdBy: z.string().optional(),
11618
+ trustedBypassAccessCheck: z.boolean().optional()
10012
11619
  });
10013
- var lensListInput = (input, context) => compactRecord4({
10014
- actorId: input.actorId ?? authUserId(context),
10015
- workspaceId: input.workspaceId,
11620
+ var createEpistemicNodeArgs = createEpistemicNodeItemArgs;
11621
+ var batchCreateEpistemicNodesArgs = z.object({
11622
+ nodes: z.array(createEpistemicNodeItemArgs)
11623
+ });
11624
+ var getEpistemicNodeArgs = z.object({
11625
+ nodeId: z.string().describe("Node ID or global ID."),
11626
+ globalId: z.string().optional().describe("Node global ID alias.")
11627
+ });
11628
+ var listEpistemicNodesArgs = z.object({
11629
+ topicId: z.string().optional(),
11630
+ projectId: z.string().optional(),
11631
+ nodeType: NODE_TYPE.optional(),
11632
+ status: nodeStatusSchema.optional(),
11633
+ searchQuery: z.string().optional(),
11634
+ query: z.string().optional(),
11635
+ limit: z.number().optional()
11636
+ });
11637
+ var updateEpistemicNodeArgs = z.object({
11638
+ nodeId: z.string().describe("Node ID or global ID."),
11639
+ id: z.string().optional().describe("Node ID alias."),
11640
+ subtype: z.string().optional(),
11641
+ canonicalText: z.string().optional(),
11642
+ text: z.string().optional(),
11643
+ contentHash: z.string().optional(),
11644
+ content: z.string().optional(),
11645
+ contentType: z.string().optional(),
11646
+ title: z.string().optional(),
11647
+ tags: z.array(z.string()).optional(),
11648
+ domain: z.string().optional(),
11649
+ metadata: z.record(z.unknown()).optional(),
11650
+ externalIds: externalIdsArgs,
11651
+ confidence: z.number().optional(),
11652
+ verificationStatus: verificationStatusSchema.optional(),
11653
+ status: nodeStatusSchema.optional(),
11654
+ userId: z.string().optional(),
11655
+ trustedBypassAccessCheck: z.boolean().optional()
11656
+ });
11657
+ var archiveEpistemicNodeArgs = z.object({
11658
+ nodeId: z.string().describe("Node ID or global ID."),
11659
+ id: z.string().optional().describe("Node ID alias."),
11660
+ userId: z.string().optional(),
11661
+ trustedBypassAccessCheck: z.boolean().optional()
11662
+ });
11663
+ var verifyEpistemicNodeArgs = z.object({
11664
+ nodeId: z.string().describe("Node ID or global ID."),
11665
+ id: z.string().optional().describe("Node ID alias."),
11666
+ verificationStatus: verificationStatusSchema,
11667
+ confidence: z.number().optional(),
11668
+ userId: z.string().optional()
11669
+ });
11670
+ var supersedeEpistemicNodeArgs = z.object({
11671
+ oldNodeId: z.string().describe("Node ID or global ID to supersede."),
11672
+ nodeId: z.string().optional().describe("Old node ID alias."),
11673
+ newGlobalId: z.string().optional(),
11674
+ newCanonicalText: z.string().optional(),
11675
+ text: z.string().optional(),
11676
+ canonicalText: z.string().optional(),
11677
+ newContentHash: z.string().optional(),
11678
+ reason: z.string().optional(),
11679
+ createdBy: z.string().optional(),
11680
+ trustedBypassAccessCheck: z.boolean().optional()
11681
+ });
11682
+ function generatedGlobalId(prefix) {
11683
+ return `${prefix}:${crypto.randomUUID()}`;
11684
+ }
11685
+ function resolveCanonicalText(input) {
11686
+ const text = input.canonicalText ?? input.text ?? input.title ?? input.content;
11687
+ if (typeof text !== "string" || text.trim().length === 0) {
11688
+ throw new Error("canonicalText or text is required.");
11689
+ }
11690
+ return text;
11691
+ }
11692
+ function createNodeInput(input, context) {
11693
+ const canonicalText = resolveCanonicalText(input);
11694
+ const nodeType = String(input.nodeType);
11695
+ return withCreatedBy(
11696
+ compactRecord4({
11697
+ globalId: typeof input.globalId === "string" && input.globalId.trim() ? input.globalId : generatedGlobalId(nodeType),
11698
+ nodeType,
11699
+ subtype: input.subtype,
11700
+ canonicalText,
11701
+ contentHash: typeof input.contentHash === "string" && input.contentHash.trim() ? input.contentHash : `${nodeType}:${canonicalText}`,
11702
+ content: input.content,
11703
+ contentType: input.contentType,
11704
+ title: input.title,
11705
+ tags: input.tags,
11706
+ domain: input.domain,
11707
+ metadata: input.metadata,
11708
+ externalIds: input.externalIds,
11709
+ sourceType: typeof input.sourceType === "string" && input.sourceType.trim() ? input.sourceType : "human",
11710
+ aiProvider: input.aiProvider,
11711
+ extractedFromNodeId: input.extractedFromNodeId,
11712
+ confidence: input.confidence,
11713
+ verificationStatus: input.verificationStatus,
11714
+ topicId: input.topicId,
11715
+ projectId: input.projectId
11716
+ }),
11717
+ context
11718
+ );
11719
+ }
11720
+ var getNodeInput = (input) => compactRecord4({
11721
+ nodeId: input.nodeId ?? input.globalId
11722
+ });
11723
+ var listNodesInput = (input) => compactRecord4({
10016
11724
  topicId: input.topicId,
11725
+ projectId: input.projectId,
11726
+ nodeType: input.nodeType,
10017
11727
  status: input.status,
10018
- perspectiveType: input.perspectiveType
11728
+ searchQuery: input.searchQuery ?? input.query,
11729
+ limit: input.limit
10019
11730
  });
10020
- var lensesContracts = [
11731
+ var updateNodeInput = (input, context) => withUserId(
11732
+ compactRecord4({
11733
+ nodeId: input.nodeId ?? input.id,
11734
+ subtype: input.subtype,
11735
+ canonicalText: input.canonicalText ?? input.text,
11736
+ contentHash: input.contentHash,
11737
+ content: input.content,
11738
+ contentType: input.contentType,
11739
+ title: input.title,
11740
+ tags: input.tags,
11741
+ domain: input.domain,
11742
+ metadata: input.metadata,
11743
+ externalIds: input.externalIds,
11744
+ confidence: input.confidence,
11745
+ verificationStatus: input.verificationStatus,
11746
+ status: input.status,
11747
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11748
+ }),
11749
+ context
11750
+ );
11751
+ var archiveNodeInput = (input, context) => withUserId(
11752
+ compactRecord4({
11753
+ nodeId: input.nodeId ?? input.id,
11754
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11755
+ }),
11756
+ context
11757
+ );
11758
+ var verifyNodeInput = (input, context) => withUserId(
11759
+ compactRecord4({
11760
+ nodeId: input.nodeId ?? input.id,
11761
+ verificationStatus: input.verificationStatus,
11762
+ confidence: input.confidence
11763
+ }),
11764
+ context
11765
+ );
11766
+ var supersedeNodeInput = (input, context) => {
11767
+ const newCanonicalText = input.newCanonicalText ?? input.canonicalText ?? input.text;
11768
+ if (typeof newCanonicalText !== "string" || newCanonicalText.trim().length === 0) {
11769
+ throw new Error("newCanonicalText or text is required.");
11770
+ }
11771
+ return {
11772
+ oldNodeId: input.oldNodeId ?? input.nodeId,
11773
+ newGlobalId: typeof input.newGlobalId === "string" && input.newGlobalId.trim() ? input.newGlobalId : generatedGlobalId("node"),
11774
+ newCanonicalText,
11775
+ newContentHash: typeof input.newContentHash === "string" && input.newContentHash.trim() ? input.newContentHash : `superseded:${newCanonicalText}`,
11776
+ createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context),
11777
+ reason: input.reason,
11778
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11779
+ };
11780
+ };
11781
+ var batchCreateNodesInput = (input, context) => {
11782
+ const nodes = Array.isArray(input.nodes) ? input.nodes : [];
11783
+ return {
11784
+ nodes: nodes.map(
11785
+ (node) => createNodeInput(
11786
+ node && typeof node === "object" ? node : {},
11787
+ context
11788
+ )
11789
+ )
11790
+ };
11791
+ };
11792
+ var nodesContracts = [
10021
11793
  surfaceContract({
10022
- name: "create_lens",
11794
+ name: "create_epistemic_node",
10023
11795
  kind: "mutation",
10024
- domain: "lenses",
11796
+ domain: "nodes",
10025
11797
  surfaceClass: "platform_public",
10026
- path: "/lenses",
10027
- sdkNamespace: "lenses",
10028
- sdkMethod: "createLens",
10029
- summary: "Create a lens.",
11798
+ path: "/nodes",
11799
+ sdkNamespace: "nodes",
11800
+ sdkMethod: "createEpistemicNode",
11801
+ summary: "Create a generic epistemic graph node.",
10030
11802
  convex: {
10031
- module: "lenses",
11803
+ module: "nodes",
10032
11804
  functionName: "create",
10033
11805
  kind: "mutation",
10034
- inputProjection: createLensInput
10035
- }
11806
+ inputProjection: createNodeInput
11807
+ },
11808
+ args: createEpistemicNodeArgs
10036
11809
  }),
10037
11810
  surfaceContract({
10038
- name: "list_lenses",
11811
+ name: "get_epistemic_node",
10039
11812
  kind: "query",
10040
- domain: "lenses",
11813
+ domain: "nodes",
10041
11814
  surfaceClass: "platform_public",
10042
11815
  method: "GET",
10043
- path: "/lenses",
10044
- sdkNamespace: "lenses",
10045
- sdkMethod: "listLenses",
10046
- summary: "List lenses.",
11816
+ path: "/nodes/get",
11817
+ sdkNamespace: "nodes",
11818
+ sdkMethod: "getEpistemicNode",
11819
+ summary: "Get a generic epistemic graph node.",
10047
11820
  convex: {
10048
- module: "lenses",
10049
- functionName: "list",
11821
+ module: "nodes",
11822
+ functionName: "get",
10050
11823
  kind: "query",
10051
- inputProjection: lensListInput
10052
- }
11824
+ inputProjection: getNodeInput
11825
+ },
11826
+ args: getEpistemicNodeArgs
10053
11827
  }),
10054
11828
  surfaceContract({
10055
- name: "apply_lens_to_topic",
10056
- kind: "mutation",
10057
- domain: "lenses",
11829
+ name: "list_epistemic_nodes",
11830
+ kind: "query",
11831
+ domain: "nodes",
10058
11832
  surfaceClass: "platform_public",
10059
- path: "/lenses/apply",
10060
- sdkNamespace: "lenses",
10061
- sdkMethod: "applyLensToTopic",
10062
- summary: "Apply a lens to a topic.",
11833
+ method: "GET",
11834
+ path: "/nodes",
11835
+ sdkNamespace: "nodes",
11836
+ sdkMethod: "listEpistemicNodes",
11837
+ summary: "List generic epistemic graph nodes.",
10063
11838
  convex: {
10064
- module: "lenses",
10065
- functionName: "applyToTopic",
10066
- kind: "mutation",
10067
- inputProjection: (input, context) => compactRecord4({
10068
- lensId: input.lensId,
10069
- topicId: input.topicId,
10070
- metadata: input.metadata,
10071
- appliedBy: authUserId(context)
10072
- })
10073
- }
11839
+ module: "nodes",
11840
+ functionName: "list",
11841
+ kind: "query",
11842
+ inputProjection: listNodesInput
11843
+ },
11844
+ args: listEpistemicNodesArgs
10074
11845
  }),
10075
11846
  surfaceContract({
10076
- name: "remove_lens_from_topic",
11847
+ name: "update_epistemic_node",
10077
11848
  kind: "mutation",
10078
- domain: "lenses",
11849
+ domain: "nodes",
10079
11850
  surfaceClass: "platform_public",
10080
- method: "DELETE",
11851
+ method: "PATCH",
11852
+ path: "/nodes",
11853
+ sdkNamespace: "nodes",
11854
+ sdkMethod: "updateEpistemicNode",
11855
+ summary: "Update a generic epistemic graph node.",
11856
+ convex: {
11857
+ module: "nodes",
11858
+ functionName: "update",
11859
+ kind: "mutation",
11860
+ inputProjection: updateNodeInput
11861
+ },
11862
+ args: updateEpistemicNodeArgs
11863
+ }),
11864
+ surfaceContract({
11865
+ name: "archive_epistemic_node",
11866
+ kind: "mutation",
11867
+ domain: "nodes",
11868
+ surfaceClass: "platform_public",
11869
+ path: "/nodes/archive",
11870
+ sdkNamespace: "nodes",
11871
+ sdkMethod: "archiveEpistemicNode",
11872
+ summary: "Archive a generic epistemic graph node.",
11873
+ convex: {
11874
+ module: "nodes",
11875
+ functionName: "archive",
11876
+ kind: "mutation",
11877
+ inputProjection: archiveNodeInput
11878
+ },
11879
+ args: archiveEpistemicNodeArgs
11880
+ }),
11881
+ surfaceContract({
11882
+ name: "verify_epistemic_node",
11883
+ kind: "mutation",
11884
+ domain: "nodes",
11885
+ surfaceClass: "platform_public",
11886
+ path: "/nodes/verify",
11887
+ sdkNamespace: "nodes",
11888
+ sdkMethod: "verifyEpistemicNode",
11889
+ summary: "Verify a generic epistemic graph node.",
11890
+ convex: {
11891
+ module: "nodes",
11892
+ functionName: "verify",
11893
+ kind: "mutation",
11894
+ inputProjection: verifyNodeInput
11895
+ },
11896
+ args: verifyEpistemicNodeArgs
11897
+ }),
11898
+ surfaceContract({
11899
+ name: "supersede_epistemic_node",
11900
+ kind: "mutation",
11901
+ domain: "nodes",
11902
+ surfaceClass: "platform_public",
11903
+ path: "/nodes/supersede",
11904
+ sdkNamespace: "nodes",
11905
+ sdkMethod: "supersedeEpistemicNode",
11906
+ summary: "Supersede a generic epistemic graph node.",
11907
+ convex: {
11908
+ module: "nodes",
11909
+ functionName: "supersede",
11910
+ kind: "mutation",
11911
+ inputProjection: supersedeNodeInput
11912
+ },
11913
+ args: supersedeEpistemicNodeArgs
11914
+ }),
11915
+ surfaceContract({
11916
+ name: "batch_create_epistemic_nodes",
11917
+ kind: "mutation",
11918
+ domain: "nodes",
11919
+ surfaceClass: "platform_public",
11920
+ path: "/nodes/batch",
11921
+ sdkNamespace: "nodes",
11922
+ sdkMethod: "batchCreateEpistemicNodes",
11923
+ summary: "Batch create generic epistemic graph nodes.",
11924
+ convex: {
11925
+ module: "nodes",
11926
+ functionName: "batchCreate",
11927
+ kind: "mutation",
11928
+ inputProjection: batchCreateNodesInput
11929
+ },
11930
+ args: batchCreateEpistemicNodesArgs
11931
+ })
11932
+ ];
11933
+ var lensPerspectiveSchema = z.enum([
11934
+ "investigation",
11935
+ "monitoring",
11936
+ "analysis",
11937
+ "comparison",
11938
+ "taxonomy"
11939
+ ]);
11940
+ var jsonRecordSchema6 = z.record(z.unknown());
11941
+ var createLensArgs = z.object({
11942
+ name: z.string().describe("Lens name."),
11943
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
11944
+ topicId: z.string().optional().describe("Originating topic scope."),
11945
+ description: z.string().optional().describe("What this lens investigates or monitors."),
11946
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
11947
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
11948
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
11949
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
11950
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
11951
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
11952
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
11953
+ });
11954
+ var createLensInput = (input, context) => compactRecord4({
11955
+ name: input.name,
11956
+ description: input.description,
11957
+ workspaceId: input.workspaceId,
11958
+ topicId: input.topicId,
11959
+ perspectiveType: input.perspectiveType,
11960
+ promptTemplates: input.promptTemplates,
11961
+ workflowTemplates: input.workflowTemplates,
11962
+ taskTemplates: input.taskTemplates,
11963
+ questionTemplates: input.questionTemplates,
11964
+ filterCriteria: input.filterCriteria,
11965
+ metadata: input.metadata,
11966
+ createdBy: authUserId(context)
11967
+ });
11968
+ var lensListInput = (input, context) => compactRecord4({
11969
+ actorId: input.actorId ?? authUserId(context),
11970
+ workspaceId: input.workspaceId,
11971
+ topicId: input.topicId,
11972
+ status: input.status,
11973
+ perspectiveType: input.perspectiveType
11974
+ });
11975
+ var lensesContracts = [
11976
+ surfaceContract({
11977
+ name: "create_lens",
11978
+ kind: "mutation",
11979
+ domain: "lenses",
11980
+ surfaceClass: "platform_public",
11981
+ path: "/lenses",
11982
+ sdkNamespace: "lenses",
11983
+ sdkMethod: "createLens",
11984
+ summary: "Create a lens.",
11985
+ convex: {
11986
+ module: "lenses",
11987
+ functionName: "create",
11988
+ kind: "mutation",
11989
+ inputProjection: createLensInput
11990
+ },
11991
+ args: createLensArgs
11992
+ }),
11993
+ surfaceContract({
11994
+ name: "list_lenses",
11995
+ kind: "query",
11996
+ domain: "lenses",
11997
+ surfaceClass: "platform_public",
11998
+ method: "GET",
11999
+ path: "/lenses",
12000
+ sdkNamespace: "lenses",
12001
+ sdkMethod: "listLenses",
12002
+ summary: "List lenses.",
12003
+ convex: {
12004
+ module: "lenses",
12005
+ functionName: "list",
12006
+ kind: "query",
12007
+ inputProjection: lensListInput
12008
+ }
12009
+ }),
12010
+ surfaceContract({
12011
+ name: "apply_lens_to_topic",
12012
+ kind: "mutation",
12013
+ domain: "lenses",
12014
+ surfaceClass: "platform_public",
12015
+ path: "/lenses/apply",
12016
+ sdkNamespace: "lenses",
12017
+ sdkMethod: "applyLensToTopic",
12018
+ summary: "Apply a lens to a topic.",
12019
+ convex: {
12020
+ module: "lenses",
12021
+ functionName: "applyToTopic",
12022
+ kind: "mutation",
12023
+ inputProjection: (input, context) => compactRecord4({
12024
+ lensId: input.lensId,
12025
+ topicId: input.topicId,
12026
+ metadata: input.metadata,
12027
+ appliedBy: authUserId(context)
12028
+ })
12029
+ }
12030
+ }),
12031
+ surfaceContract({
12032
+ name: "remove_lens_from_topic",
12033
+ kind: "mutation",
12034
+ domain: "lenses",
12035
+ surfaceClass: "platform_public",
12036
+ method: "DELETE",
10081
12037
  path: "/lenses/apply",
10082
12038
  sdkNamespace: "lenses",
10083
12039
  sdkMethod: "removeLensFromTopic",
@@ -10094,8 +12050,18 @@ var lensesContracts = [
10094
12050
  }
10095
12051
  })
10096
12052
  ];
10097
-
10098
- // ../contracts/src/function-registry/ontologies.ts
12053
+ var updateOntologyArgs = z.object({
12054
+ id: z.string().describe("Ontology definition ID."),
12055
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
12056
+ name: z.string().optional().describe("Ontology display name."),
12057
+ description: z.string().optional().describe("Ontology description."),
12058
+ status: z.string().optional().describe("Ontology lifecycle status.")
12059
+ });
12060
+ var ontologyVersionLifecycleArgs = z.object({
12061
+ id: z.string().describe("Ontology version ID."),
12062
+ versionId: z.string().optional().describe("Ontology version ID alias."),
12063
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
12064
+ });
10099
12065
  var ontologyIdInput = (input) => compactRecord4({
10100
12066
  id: input.id ?? input.ontologyId
10101
12067
  });
@@ -10174,11 +12140,11 @@ var ontologiesContracts = [
10174
12140
  id: input.id ?? input.ontologyId,
10175
12141
  name: input.name,
10176
12142
  description: input.description,
10177
- parentOntologyId: input.parentOntologyId,
10178
12143
  status: input.status,
10179
12144
  actorId: input.actorId
10180
12145
  })
10181
- }
12146
+ },
12147
+ args: updateOntologyArgs
10182
12148
  }),
10183
12149
  surfaceContract({
10184
12150
  name: "archive_ontology",
@@ -10261,7 +12227,8 @@ var ontologiesContracts = [
10261
12227
  functionName: "publishOntologyVersion",
10262
12228
  kind: "mutation",
10263
12229
  inputProjection: ontologyVersionIdInput
10264
- }
12230
+ },
12231
+ args: ontologyVersionLifecycleArgs
10265
12232
  }),
10266
12233
  surfaceContract({
10267
12234
  name: "deprecate_ontology_version",
@@ -10277,7 +12244,8 @@ var ontologiesContracts = [
10277
12244
  functionName: "deprecateOntologyVersion",
10278
12245
  kind: "mutation",
10279
12246
  inputProjection: ontologyVersionIdInput
10280
- }
12247
+ },
12248
+ args: ontologyVersionLifecycleArgs
10281
12249
  }),
10282
12250
  surfaceContract({
10283
12251
  name: "resolve_effective_ontology",
@@ -10296,8 +12264,81 @@ var ontologiesContracts = [
10296
12264
  }
10297
12265
  })
10298
12266
  ];
10299
-
10300
- // ../contracts/src/function-registry/worktrees.ts
12267
+ var autoFixPolicyInputSchema = z.object({
12268
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
12269
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
12270
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
12271
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
12272
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
12273
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
12274
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
12275
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
12276
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
12277
+ var worktreeKeyQuestionInputSchema = z.object({
12278
+ question: z.string().describe("Question the worktree must resolve."),
12279
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
12280
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
12281
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
12282
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
12283
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
12284
+ var worktreeEvidenceSignalInputSchema = z.object({
12285
+ signal: z.string().describe("Evidence signal the worktree should collect."),
12286
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
12287
+ progress: z.string().optional().describe("Collection progress note for the signal."),
12288
+ notes: z.string().optional().describe("Additional evidence collection notes.")
12289
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
12290
+ var worktreeDecisionGateInputSchema = z.object({
12291
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
12292
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
12293
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
12294
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
12295
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
12296
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
12297
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
12298
+ var addWorktreeArgs = z.object({
12299
+ title: z.string().describe("Human-readable worktree name or objective."),
12300
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
12301
+ topicId: z.string().optional().describe("Optional primary topic scope hint for resolver validation."),
12302
+ projectId: z.string().optional().describe("Legacy topicId alias/hint."),
12303
+ topicHint: z.string().optional().describe("Natural-language topic hint for automatic topic resolution."),
12304
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
12305
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
12306
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12307
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
12308
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
12309
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12310
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
12311
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
12312
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
12313
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
12314
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
12315
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12316
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12317
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
12318
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
12319
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
12320
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
12321
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
12322
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
12323
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
12324
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
12325
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
12326
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12327
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
12328
+ tags: z.array(z.string()).optional().describe("Additional topic-resolution tags for the worktree."),
12329
+ touchedPaths: z.array(z.string()).optional().describe("File paths used as topic-resolution signals."),
12330
+ sourceRef: z.string().optional().describe("Source reference used as a topic-resolution signal."),
12331
+ sourceKind: z.string().optional().describe("Source kind used as a topic-resolution signal."),
12332
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
12333
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
12334
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12335
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12336
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
12337
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12338
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12339
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
12340
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
12341
+ });
10301
12342
  var worktreeIdInput = (input) => compactRecord4({
10302
12343
  worktreeId: input.worktreeId ?? input.id
10303
12344
  });
@@ -10330,6 +12371,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10330
12371
  autoFixPolicy: input.autoFixPolicy,
10331
12372
  lastReconciledAt: input.lastReconciledAt
10332
12373
  });
12374
+ var worktreeMetadataArgs = z.object({
12375
+ worktreeId: z.string().describe("The worktree to update."),
12376
+ id: z.string().optional().describe("Worktree ID alias."),
12377
+ topicId: z.string().optional().describe("Primary topic scope."),
12378
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
12379
+ status: z.string().optional().describe("Worktree lifecycle status."),
12380
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
12381
+ lane: z.string().optional().describe("Campaign lane."),
12382
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12383
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12384
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12385
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12386
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
12387
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
12388
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
12389
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12390
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12391
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
12392
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
12393
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12394
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
12395
+ });
12396
+ var pushArgs = worktreeMetadataArgs.extend({
12397
+ targetContext: z.string().describe("Where to push merged findings."),
12398
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
12399
+ });
12400
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
12401
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
12402
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
12403
+ });
12404
+ var mergeKeyFindingsInput = (input) => {
12405
+ if (Array.isArray(input.keyFindings)) {
12406
+ return input.keyFindings;
12407
+ }
12408
+ if (Array.isArray(input.outcomes)) {
12409
+ const findings = input.outcomes.filter(
12410
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
12411
+ );
12412
+ if (findings.length > 0) {
12413
+ return findings;
12414
+ }
12415
+ }
12416
+ return [input.summary ?? "Merged worktree"];
12417
+ };
10333
12418
  var listAllWorktreesInput = (input) => compactRecord4({
10334
12419
  status: input.status,
10335
12420
  lane: input.lane,
@@ -10337,6 +12422,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10337
12422
  limit: input.limit
10338
12423
  });
10339
12424
  var worktreesContracts = [
12425
+ surfaceContract({
12426
+ name: "begin_build_session",
12427
+ kind: "mutation",
12428
+ domain: "worktrees",
12429
+ surfaceClass: "platform_internal",
12430
+ path: "/mcp/build-session/begin",
12431
+ sdkNamespace: "worktrees",
12432
+ sdkMethod: "beginBuildSession",
12433
+ summary: "Begin a coding build session for a worktree."
12434
+ }),
10340
12435
  surfaceContract({
10341
12436
  name: "add_worktree",
10342
12437
  kind: "mutation",
@@ -10353,13 +12448,12 @@ var worktreesContracts = [
10353
12448
  inputProjection: (input, context) => withCreatedBy(
10354
12449
  compactRecord4({
10355
12450
  name: input.name ?? input.title,
10356
- topicId: input.topicId,
12451
+ topicId: input.topicId ?? input.projectId,
10357
12452
  worktreeType: input.worktreeType,
10358
12453
  objective: input.objective,
10359
12454
  gate: input.gate,
10360
12455
  hypothesis: input.hypothesis,
10361
12456
  rationale: input.rationale,
10362
- signal: input.signal,
10363
12457
  startDate: input.startDate,
10364
12458
  endDate: input.endDate,
10365
12459
  durationWeeks: input.durationWeeks,
@@ -10385,12 +12479,12 @@ var worktreesContracts = [
10385
12479
  staffingHint: input.staffingHint,
10386
12480
  domainPackId: input.domainPackId,
10387
12481
  lensId: input.lensId,
10388
- linkedQuestionId: input.linkedQuestionId,
10389
12482
  lastReconciledAt: input.lastReconciledAt
10390
12483
  }),
10391
12484
  context
10392
12485
  )
10393
- }
12486
+ },
12487
+ args: addWorktreeArgs
10394
12488
  }),
10395
12489
  surfaceContract({
10396
12490
  name: "activate_worktree",
@@ -10502,7 +12596,8 @@ var worktreesContracts = [
10502
12596
  functionName: "updateMetadata",
10503
12597
  kind: "mutation",
10504
12598
  inputProjection: worktreeMetadataInput
10505
- }
12599
+ },
12600
+ args: worktreeMetadataArgs
10506
12601
  }),
10507
12602
  surfaceContract({
10508
12603
  name: "merge",
@@ -10520,9 +12615,7 @@ var worktreesContracts = [
10520
12615
  inputProjection: (input, context) => withUserId(
10521
12616
  {
10522
12617
  ...worktreeIdInput(input),
10523
- keyFindings: input.keyFindings ?? [
10524
- input.summary ?? "Merged worktree"
10525
- ],
12618
+ keyFindings: mergeKeyFindingsInput(input),
10526
12619
  decisionsReached: input.decisionsReached ?? [],
10527
12620
  nextSteps: input.nextSteps ?? []
10528
12621
  },
@@ -10544,7 +12637,8 @@ var worktreesContracts = [
10544
12637
  functionName: "updateMetadata",
10545
12638
  kind: "mutation",
10546
12639
  inputProjection: worktreeMetadataInput
10547
- }
12640
+ },
12641
+ args: pushArgs
10548
12642
  }),
10549
12643
  surfaceContract({
10550
12644
  name: "open_pull_request",
@@ -10560,11 +12654,50 @@ var worktreesContracts = [
10560
12654
  functionName: "updateMetadata",
10561
12655
  kind: "mutation",
10562
12656
  inputProjection: worktreeMetadataInput
10563
- }
12657
+ },
12658
+ args: openPullRequestArgs
10564
12659
  })
10565
12660
  ];
10566
-
10567
- // ../contracts/src/function-registry/tasks.ts
12661
+ var taskPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
12662
+ var taskStatusSchema2 = z.enum(["todo", "in_progress", "blocked", "done"]);
12663
+ var taskTypeSchema = z.enum([
12664
+ "general",
12665
+ "find_evidence",
12666
+ "verify_claim",
12667
+ "research",
12668
+ "review",
12669
+ "interview",
12670
+ "analysis",
12671
+ "track_metrics"
12672
+ ]);
12673
+ var createTaskArgs = z.object({
12674
+ title: z.string().describe("Task title."),
12675
+ topicId: z.string().optional().describe("Topic scope."),
12676
+ description: z.string().optional().describe("Long-form task description."),
12677
+ taskType: taskTypeSchema.optional().describe("Task taxonomy."),
12678
+ priority: taskPrioritySchema.optional().describe("Priority. Defaults to medium when omitted by the server."),
12679
+ status: taskStatusSchema2.optional().describe("Initial status. Defaults to todo."),
12680
+ linkedWorktreeId: z.string().optional().describe("Worktree this task belongs to."),
12681
+ linkedBeliefId: z.string().optional().describe("Belief this task supports."),
12682
+ linkedQuestionId: z.string().optional().describe("Question this task addresses."),
12683
+ assigneeId: z.string().optional().describe("Principal assigned to the task."),
12684
+ dueDate: z.number().optional().describe("Due date as epoch milliseconds."),
12685
+ tags: z.array(z.string()).optional().describe("Free-form tags.")
12686
+ });
12687
+ var createTaskInput = (input) => compactRecord4({
12688
+ title: input.title,
12689
+ topicId: input.topicId,
12690
+ description: input.description,
12691
+ taskType: input.taskType,
12692
+ priority: input.priority ?? "medium",
12693
+ status: input.status ?? "todo",
12694
+ linkedWorktreeId: input.linkedWorktreeId,
12695
+ linkedBeliefId: input.linkedBeliefId,
12696
+ linkedQuestionId: input.linkedQuestionId,
12697
+ assigneeId: input.assigneeId,
12698
+ dueDate: input.dueDate,
12699
+ tags: input.tags
12700
+ });
10568
12701
  var taskInput = (input) => compactRecord4({
10569
12702
  ...input,
10570
12703
  taskId: input.taskId ?? input.id
@@ -10596,8 +12729,10 @@ var tasksContracts = [
10596
12729
  convex: {
10597
12730
  module: "tasks",
10598
12731
  functionName: "create",
10599
- kind: "mutation"
10600
- }
12732
+ kind: "mutation",
12733
+ inputProjection: createTaskInput
12734
+ },
12735
+ args: createTaskArgs
10601
12736
  }),
10602
12737
  surfaceContract({
10603
12738
  name: "list_tasks",
@@ -10651,19 +12786,57 @@ var tasksContracts = [
10651
12786
  }
10652
12787
  })
10653
12788
  ];
12789
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12790
+ (policy) => policy.edgeType
12791
+ );
10654
12792
  var createEdgeArgs = z.object({
10655
12793
  from: GraphRefSchema,
10656
12794
  to: GraphRefSchema,
10657
- edgeType: z.string(),
12795
+ edgeType: z.enum(CREATE_EDGE_TYPES),
10658
12796
  globalId: z.string().optional(),
10659
12797
  weight: z.number().optional(),
10660
12798
  confidence: z.number().optional(),
10661
12799
  context: z.string().optional(),
10662
12800
  reasoning: z.string().optional(),
10663
12801
  derivationType: z.string().optional(),
12802
+ metadata: z.record(z.unknown()).optional(),
10664
12803
  topicId: z.string().optional(),
10665
12804
  trustedBypassAccessCheck: z.boolean().optional()
10666
12805
  });
12806
+ var updateEdgeArgs = z.object({
12807
+ edgeId: z.string().describe("Edge ID or global ID."),
12808
+ weight: z.number().optional(),
12809
+ confidence: z.number().optional(),
12810
+ context: z.string().optional(),
12811
+ reasoning: z.string().optional(),
12812
+ derivationType: z.string().optional(),
12813
+ metadata: z.record(z.unknown()).optional(),
12814
+ userId: z.string().optional()
12815
+ });
12816
+ var removeEdgeArgs = z.object({
12817
+ edgeId: z.string().describe("Edge ID or global ID."),
12818
+ userId: z.string().optional()
12819
+ });
12820
+ var removeEdgesBetweenArgs = z.object({
12821
+ from: GraphRefSchema.optional(),
12822
+ to: GraphRefSchema.optional(),
12823
+ fromNodeId: z.string().optional(),
12824
+ toNodeId: z.string().optional(),
12825
+ edgeType: z.enum(CREATE_EDGE_TYPES).optional()
12826
+ });
12827
+ var batchCreateEdgesArgs = z.object({
12828
+ edges: z.array(createEdgeArgs),
12829
+ skipLayerValidation: z.boolean().optional()
12830
+ });
12831
+ var queryLineageArgs = z.object({
12832
+ nodeId: z.string().describe("Starting node to trace from."),
12833
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
12834
+ depth: z.number().optional().describe("Traversal depth alias."),
12835
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12836
+ mode: z.string().optional().describe("Traversal mode."),
12837
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12838
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12839
+ });
10667
12840
  function graphRefNodeId(ref) {
10668
12841
  if (ref.kind === "epistemic_node") {
10669
12842
  return ref.nodeId;
@@ -10704,6 +12877,7 @@ var edgesContracts = [
10704
12877
  confidence: parsed.confidence,
10705
12878
  context: parsed.context ?? parsed.reasoning,
10706
12879
  derivationType: parsed.derivationType,
12880
+ metadata: parsed.metadata,
10707
12881
  skipLayerValidation: true,
10708
12882
  topicId: parsed.topicId,
10709
12883
  trustedBypassAccessCheck: parsed.trustedBypassAccessCheck
@@ -10714,6 +12888,130 @@ var edgesContracts = [
10714
12888
  },
10715
12889
  args: createEdgeArgs
10716
12890
  }),
12891
+ surfaceContract({
12892
+ name: "update_edge",
12893
+ kind: "mutation",
12894
+ domain: "edges",
12895
+ surfaceClass: "platform_public",
12896
+ method: "PATCH",
12897
+ path: "/edges",
12898
+ sdkNamespace: "edges",
12899
+ sdkMethod: "updateEdge",
12900
+ summary: "Update an epistemic edge.",
12901
+ convex: {
12902
+ module: "edges",
12903
+ functionName: "update",
12904
+ kind: "mutation",
12905
+ inputProjection: (input, context) => compactRecord4({
12906
+ edgeId: input.edgeId,
12907
+ weight: input.weight,
12908
+ confidence: input.confidence,
12909
+ context: input.context ?? input.reasoning,
12910
+ derivationType: input.derivationType,
12911
+ metadata: input.metadata,
12912
+ userId: input.userId ?? context.userId ?? context.principalId
12913
+ })
12914
+ },
12915
+ args: updateEdgeArgs
12916
+ }),
12917
+ surfaceContract({
12918
+ name: "remove_edge",
12919
+ kind: "mutation",
12920
+ domain: "edges",
12921
+ surfaceClass: "platform_public",
12922
+ method: "DELETE",
12923
+ path: "/edges",
12924
+ sdkNamespace: "edges",
12925
+ sdkMethod: "removeEdge",
12926
+ summary: "Remove an epistemic edge.",
12927
+ convex: {
12928
+ module: "edges",
12929
+ functionName: "remove",
12930
+ kind: "mutation",
12931
+ inputProjection: (input, context) => compactRecord4({
12932
+ edgeId: input.edgeId,
12933
+ userId: input.userId ?? context.userId ?? context.principalId
12934
+ })
12935
+ },
12936
+ args: removeEdgeArgs
12937
+ }),
12938
+ surfaceContract({
12939
+ name: "remove_edges_between",
12940
+ kind: "mutation",
12941
+ domain: "edges",
12942
+ surfaceClass: "platform_public",
12943
+ method: "DELETE",
12944
+ path: "/edges/between",
12945
+ sdkNamespace: "edges",
12946
+ sdkMethod: "removeEdgesBetween",
12947
+ summary: "Remove epistemic edges between two nodes.",
12948
+ convex: {
12949
+ module: "edges",
12950
+ functionName: "removeBetween",
12951
+ kind: "mutation",
12952
+ inputProjection: (input) => {
12953
+ const parsed = removeEdgesBetweenArgs.parse(input);
12954
+ const fromNodeId = parsed.from ? graphRefNodeId(parsed.from) : parsed.fromNodeId;
12955
+ const toNodeId = parsed.to ? graphRefNodeId(parsed.to) : parsed.toNodeId;
12956
+ if (!fromNodeId || !toNodeId) {
12957
+ throw new Error("from/to or fromNodeId/toNodeId are required.");
12958
+ }
12959
+ return compactRecord4({
12960
+ fromNodeId,
12961
+ toNodeId,
12962
+ edgeType: parsed.edgeType
12963
+ });
12964
+ }
12965
+ },
12966
+ args: removeEdgesBetweenArgs
12967
+ }),
12968
+ surfaceContract({
12969
+ name: "batch_create_edges",
12970
+ kind: "mutation",
12971
+ domain: "edges",
12972
+ surfaceClass: "platform_public",
12973
+ path: "/edges/batch",
12974
+ sdkNamespace: "edges",
12975
+ sdkMethod: "batchCreateEdges",
12976
+ summary: "Batch create epistemic edges.",
12977
+ convex: {
12978
+ module: "edges",
12979
+ functionName: "batchCreate",
12980
+ kind: "mutation",
12981
+ inputProjection: (input, context) => {
12982
+ const parsed = batchCreateEdgesArgs.parse(input);
12983
+ return {
12984
+ skipLayerValidation: parsed.skipLayerValidation ?? true,
12985
+ edges: parsed.edges.map((edge) => {
12986
+ assertEdgePolicyAllowed(
12987
+ edgePolicyManifest,
12988
+ edge.edgeType,
12989
+ edge.from,
12990
+ edge.to
12991
+ );
12992
+ const fromNodeId = graphRefNodeId(edge.from);
12993
+ const toNodeId = graphRefNodeId(edge.to);
12994
+ return withCreatedBy(
12995
+ compactRecord4({
12996
+ fromNodeId,
12997
+ toNodeId,
12998
+ edgeType: edge.edgeType,
12999
+ globalId: edge.globalId ?? `edge:${fromNodeId}:${toNodeId}:${edge.edgeType}`,
13000
+ weight: edge.weight,
13001
+ confidence: edge.confidence,
13002
+ context: edge.context ?? edge.reasoning,
13003
+ derivationType: edge.derivationType,
13004
+ metadata: edge.metadata,
13005
+ topicId: edge.topicId
13006
+ }),
13007
+ context
13008
+ );
13009
+ })
13010
+ };
13011
+ }
13012
+ },
13013
+ args: batchCreateEdgesArgs
13014
+ }),
10717
13015
  surfaceContract({
10718
13016
  name: "query_lineage",
10719
13017
  kind: "query",
@@ -10734,11 +13032,84 @@ var edgesContracts = [
10734
13032
  minLayer: input.minLayer,
10735
13033
  maxLayer: input.maxLayer
10736
13034
  })
10737
- }
13035
+ },
13036
+ args: queryLineageArgs
10738
13037
  })
10739
13038
  ];
10740
-
10741
- // ../contracts/src/function-registry/graph.ts
13039
+ var graphIntelligenceQueryModes = [
13040
+ "core",
13041
+ "bias",
13042
+ "stress",
13043
+ "operational",
13044
+ "alpha",
13045
+ "semantic",
13046
+ "evidence"
13047
+ ];
13048
+ var traversalLayerSchema = z.enum([
13049
+ "L4",
13050
+ "L3",
13051
+ "L2",
13052
+ "L1",
13053
+ "ontological",
13054
+ "organizational"
13055
+ ]);
13056
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
13057
+ var lineageAliasArgs = z.object({
13058
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
13059
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
13060
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
13061
+ depth: z.number().optional().describe("Traversal depth alias."),
13062
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
13063
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
13064
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
13065
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
13066
+ });
13067
+ var lineageArgs = lineageAliasArgs.extend({
13068
+ nodeId: z.string().describe("Starting node to traverse from.")
13069
+ });
13070
+ var traverseGraphArgs = lineageAliasArgs.extend({
13071
+ startNode: z.string().describe("Node to start traversal from."),
13072
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
13073
+ });
13074
+ var graphNeighborhoodArgs = z.object({
13075
+ globalId: z.string().optional().describe("Single root global ID."),
13076
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
13077
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
13078
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
13079
+ limit: z.number().optional().describe("Maximum edges to return.")
13080
+ });
13081
+ var graphIntelligenceModeSchema = z.enum([
13082
+ graphIntelligenceQueryModes[0],
13083
+ ...graphIntelligenceQueryModes.slice(1)
13084
+ ]);
13085
+ var graphIntelligenceCatalogArgs = z.object({
13086
+ categoryId: z.string().optional().describe("Optional query category filter."),
13087
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
13088
+ });
13089
+ var graphIntelligenceRunArgs = z.object({
13090
+ topicId: z.string().describe("Topic to analyze."),
13091
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
13092
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
13093
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
13094
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
13095
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
13096
+ });
13097
+ var flagContradictionArgs = z.object({
13098
+ beliefA: z.string().describe("First belief in tension."),
13099
+ beliefB: z.string().describe("Second belief in tension."),
13100
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
13101
+ description: z.string().optional().describe("Human-readable contradiction."),
13102
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
13103
+ defeatType: z.string().optional().describe("Defeat type annotation."),
13104
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
13105
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
13106
+ });
13107
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
13108
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
13109
+ topicId: z.string().optional().describe("Topic scope override."),
13110
+ minScore: z.number().optional().describe("Minimum match score."),
13111
+ limit: z.number().optional().describe("Maximum candidates to return.")
13112
+ });
10742
13113
  var contradictionSeverity = (value) => {
10743
13114
  switch (value) {
10744
13115
  case "critical":
@@ -10793,7 +13164,8 @@ var graphContracts = [
10793
13164
  functionName: "getLineage",
10794
13165
  kind: "query",
10795
13166
  inputProjection: lineageInput
10796
- }
13167
+ },
13168
+ args: traverseGraphArgs
10797
13169
  }),
10798
13170
  surfaceContract({
10799
13171
  name: "get_graph_neighborhood",
@@ -10809,7 +13181,8 @@ var graphContracts = [
10809
13181
  functionName: "getByTopic",
10810
13182
  kind: "query",
10811
13183
  inputProjection: topicEdgesInput
10812
- }
13184
+ },
13185
+ args: graphNeighborhoodArgs
10813
13186
  }),
10814
13187
  surfaceContract({
10815
13188
  name: "get_graph_structure_analysis",
@@ -10826,6 +13199,38 @@ var graphContracts = [
10826
13199
  kind: "query"
10827
13200
  }
10828
13201
  }),
13202
+ surfaceContract({
13203
+ name: "list_graph_intelligence_queries",
13204
+ kind: "query",
13205
+ domain: "graph",
13206
+ surfaceClass: "platform_public",
13207
+ path: "/graph-intelligence/queries",
13208
+ sdkNamespace: "graphAnalysis",
13209
+ sdkMethod: "listGraphIntelligenceQueries",
13210
+ summary: "List Graph Intelligence query catalog entries.",
13211
+ convex: {
13212
+ module: "contextCompiler",
13213
+ functionName: "listGraphIntelligenceQueries",
13214
+ kind: "query"
13215
+ },
13216
+ args: graphIntelligenceCatalogArgs
13217
+ }),
13218
+ surfaceContract({
13219
+ name: "run_graph_intelligence_query",
13220
+ kind: "query",
13221
+ domain: "graph",
13222
+ surfaceClass: "platform_public",
13223
+ path: "/graph-intelligence/run",
13224
+ sdkNamespace: "graphAnalysis",
13225
+ sdkMethod: "runGraphIntelligenceQuery",
13226
+ summary: "Run a Graph Intelligence query against a topic graph.",
13227
+ convex: {
13228
+ module: "contextCompiler",
13229
+ functionName: "runGraphIntelligenceQuery",
13230
+ kind: "query"
13231
+ },
13232
+ args: graphIntelligenceRunArgs
13233
+ }),
10829
13234
  surfaceContract({
10830
13235
  name: "find_contradictions",
10831
13236
  kind: "query",
@@ -10858,7 +13263,8 @@ var graphContracts = [
10858
13263
  functionName: "create",
10859
13264
  kind: "mutation",
10860
13265
  inputProjection: flagContradictionInput
10861
- }
13266
+ },
13267
+ args: flagContradictionArgs
10862
13268
  }),
10863
13269
  surfaceContract({
10864
13270
  name: "detect_confirmation_bias",
@@ -10949,7 +13355,8 @@ var graphContracts = [
10949
13355
  functionName: "getLineage",
10950
13356
  kind: "query",
10951
13357
  inputProjection: lineageInput
10952
- }
13358
+ },
13359
+ args: discoverEntityConnectionsArgs
10953
13360
  }),
10954
13361
  surfaceContract({
10955
13362
  name: "trigger_belief_review",
@@ -10980,7 +13387,8 @@ var graphContracts = [
10980
13387
  functionName: "getLineage",
10981
13388
  kind: "query",
10982
13389
  inputProjection: lineageInput
10983
- }
13390
+ },
13391
+ args: lineageArgs
10984
13392
  })
10985
13393
  ];
10986
13394
 
@@ -11032,8 +13440,16 @@ var contractsContracts = [
11032
13440
  }
11033
13441
  })
11034
13442
  ];
11035
-
11036
- // ../contracts/src/function-registry/judgments.ts
13443
+ var auditTrailArgs = z.object({
13444
+ nodeId: z.string().describe("The node to audit."),
13445
+ id: z.string().optional().describe("Node ID alias."),
13446
+ limit: z.number().optional().describe("Maximum entries to return."),
13447
+ depth: z.number().optional().describe("Traversal depth alias."),
13448
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
13449
+ mode: z.string().optional().describe("Traversal mode."),
13450
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
13451
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
13452
+ });
11037
13453
  var judgmentsContracts = [
11038
13454
  surfaceContract({
11039
13455
  name: "record_judgment",
@@ -11088,7 +13504,8 @@ var judgmentsContracts = [
11088
13504
  minLayer: input.minLayer,
11089
13505
  maxLayer: input.maxLayer
11090
13506
  })
11091
- }
13507
+ },
13508
+ args: auditTrailArgs
11092
13509
  })
11093
13510
  ];
11094
13511
 
@@ -11256,8 +13673,13 @@ var coordinationContracts = [
11256
13673
  }
11257
13674
  })
11258
13675
  ];
11259
-
11260
- // ../contracts/src/function-registry/pipeline.ts
13676
+ var pipelineSnapshotArgs = z.object({
13677
+ topicId: z.string().describe("Topic scope ID."),
13678
+ status: z.string().optional().describe("Worktree status filter."),
13679
+ lane: z.string().optional().describe("Campaign lane filter."),
13680
+ campaign: z.number().optional().describe("Campaign number filter."),
13681
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
13682
+ });
11261
13683
  var pipelineContracts = [
11262
13684
  surfaceContract({
11263
13685
  name: "pipeline_snapshot",
@@ -11278,7 +13700,8 @@ var pipelineContracts = [
11278
13700
  campaign: input.campaign,
11279
13701
  limit: input.limit
11280
13702
  })
11281
- }
13703
+ },
13704
+ args: pipelineSnapshotArgs
11282
13705
  }),
11283
13706
  surfaceContract({
11284
13707
  name: "seed_belief_lattice",
@@ -11330,7 +13753,31 @@ var recordScopeLearningArgs = z.object({
11330
13753
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11331
13754
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11332
13755
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11333
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
13756
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
13757
+ text: z.string().optional().describe("Canonical learning text alias."),
13758
+ content: z.string().optional().describe("Canonical learning content alias."),
13759
+ kind: z.string().optional().describe("Evidence kind to store."),
13760
+ sourceType: z.string().optional().describe("Evidence source type."),
13761
+ externalSourceType: z.string().optional().describe("External source type alias."),
13762
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
13763
+ });
13764
+ var codeContextArgs = z.object({
13765
+ topicId: z.string().optional().describe("Topic scope."),
13766
+ filePath: z.string().optional().describe("File path anchor."),
13767
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
13768
+ limit: z.number().optional().describe("Maximum records to return."),
13769
+ status: z.string().optional().describe("Evidence status filter.")
13770
+ });
13771
+ var recordAttemptArgs = z.object({
13772
+ topicId: z.string().optional().describe("Topic scope."),
13773
+ description: z.string().describe("Attempt description."),
13774
+ errorMessage: z.string().optional().describe("Failure or error message."),
13775
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
13776
+ filePath: z.string().optional().describe("Single file path alias."),
13777
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
13778
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
13779
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
13780
+ title: z.string().optional().describe("Attempt evidence title.")
11334
13781
  });
11335
13782
  var learningInput = (input, context) => {
11336
13783
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11447,7 +13894,8 @@ var codingContracts = [
11447
13894
  status: input.status,
11448
13895
  userId: input.userId
11449
13896
  })
11450
- }
13897
+ },
13898
+ args: codeContextArgs
11451
13899
  }),
11452
13900
  surfaceContract({
11453
13901
  name: "get_change_history",
@@ -11484,7 +13932,8 @@ var codingContracts = [
11484
13932
  functionName: "create",
11485
13933
  kind: "mutation",
11486
13934
  inputProjection: attemptInput
11487
- }
13935
+ },
13936
+ args: recordAttemptArgs
11488
13937
  }),
11489
13938
  surfaceContract({
11490
13939
  name: "get_failure_log",
@@ -11541,6 +13990,7 @@ var ALL_FUNCTION_CONTRACTS = [
11541
13990
  ...evidenceContracts,
11542
13991
  ...questionsContracts,
11543
13992
  ...topicsContracts,
13993
+ ...nodesContracts,
11544
13994
  ...lensesContracts,
11545
13995
  ...ontologiesContracts,
11546
13996
  ...worktreesContracts,
@@ -11555,17 +14005,623 @@ var ALL_FUNCTION_CONTRACTS = [
11555
14005
  ...legacyContracts
11556
14006
  ];
11557
14007
  assertSurfaceCoverage(ALL_FUNCTION_CONTRACTS);
11558
- new Map(
14008
+ var FUNCTION_CONTRACTS_BY_NAME = new Map(
11559
14009
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11560
14010
  );
14011
+ FUNCTION_CONTRACTS_BY_NAME.get.bind(
14012
+ FUNCTION_CONTRACTS_BY_NAME
14013
+ );
14014
+
14015
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
14016
+ function isCopyableSeedRequirement(entry) {
14017
+ return (entry.copyMode === "template_global" || entry.copyMode === "template_tenant_rewrite" || entry.copyMode === "template_reference_remap") && Boolean(entry.scope) && Array.isArray(entry.uniqueKey) && entry.uniqueKey.length > 0;
14018
+ }
14019
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
14020
+ {
14021
+ component: "kernel",
14022
+ table: "agentMessages",
14023
+ prepopulation: "runtime_data",
14024
+ copyMode: "none",
14025
+ description: "Agent coordination messages are session data, not template data."
14026
+ },
14027
+ {
14028
+ component: "kernel",
14029
+ table: "agentSessions",
14030
+ prepopulation: "runtime_data",
14031
+ copyMode: "none",
14032
+ description: "Agent coordination sessions are created by active clients."
14033
+ },
14034
+ {
14035
+ component: "kernel",
14036
+ table: "autofixJobs",
14037
+ prepopulation: "runtime_queue",
14038
+ copyMode: "none",
14039
+ description: "Autofix work items are runtime queue rows."
14040
+ },
14041
+ {
14042
+ component: "kernel",
14043
+ table: "backgroundJobRuns",
14044
+ prepopulation: "runtime_log",
14045
+ copyMode: "none",
14046
+ description: "Background job executions are runtime logs."
14047
+ },
14048
+ {
14049
+ component: "kernel",
14050
+ table: "backgroundJobSettings",
14051
+ prepopulation: "required_template",
14052
+ copyMode: "template_global",
14053
+ scope: "global",
14054
+ uniqueKey: ["jobKey"],
14055
+ description: "Default job enablement settings must come from the K template."
14056
+ },
14057
+ {
14058
+ component: "kernel",
14059
+ table: "beliefConfidence",
14060
+ prepopulation: "runtime_data",
14061
+ copyMode: "none",
14062
+ description: "Belief confidence rows are created with tenant graph facts."
14063
+ },
14064
+ {
14065
+ component: "kernel",
14066
+ table: "beliefEvidenceLinks",
14067
+ prepopulation: "runtime_data",
14068
+ copyMode: "none",
14069
+ description: "Belief-to-evidence links are tenant graph data."
14070
+ },
14071
+ {
14072
+ component: "kernel",
14073
+ table: "beliefHistory",
14074
+ prepopulation: "runtime_data",
14075
+ copyMode: "none",
14076
+ description: "Belief history is append-only tenant graph data."
14077
+ },
14078
+ {
14079
+ component: "kernel",
14080
+ table: "beliefScenarios",
14081
+ prepopulation: "runtime_data",
14082
+ copyMode: "none",
14083
+ description: "Scenario rows are tenant-authored reasoning data."
14084
+ },
14085
+ {
14086
+ component: "kernel",
14087
+ table: "beliefVotes",
14088
+ prepopulation: "runtime_data",
14089
+ copyMode: "none",
14090
+ description: "Decision belief votes are tenant-authored data."
14091
+ },
14092
+ {
14093
+ component: "kernel",
14094
+ table: "calibrationScores",
14095
+ prepopulation: "runtime_derived",
14096
+ copyMode: "none",
14097
+ description: "Calibration scores are computed from tenant outcomes."
14098
+ },
14099
+ {
14100
+ component: "kernel",
14101
+ table: "contractEvaluations",
14102
+ prepopulation: "runtime_log",
14103
+ copyMode: "none",
14104
+ description: "Contract evaluation rows are runtime computation logs."
14105
+ },
14106
+ {
14107
+ component: "kernel",
14108
+ table: "contradictions",
14109
+ prepopulation: "runtime_data",
14110
+ copyMode: "none",
14111
+ description: "Contradictions are tenant graph facts."
14112
+ },
14113
+ {
14114
+ component: "kernel",
14115
+ table: "crossProjectConnections",
14116
+ prepopulation: "runtime_data",
14117
+ copyMode: "none",
14118
+ description: "Cross-topic connections are tenant graph facts."
14119
+ },
14120
+ {
14121
+ component: "kernel",
14122
+ table: "decisionComputedSummaries",
14123
+ prepopulation: "runtime_derived",
14124
+ copyMode: "none",
14125
+ description: "Decision summaries are derived tenant outputs."
14126
+ },
14127
+ {
14128
+ component: "kernel",
14129
+ table: "decisionEvents",
14130
+ prepopulation: "runtime_data",
14131
+ copyMode: "none",
14132
+ description: "Decision events are lifecycle data."
14133
+ },
14134
+ {
14135
+ component: "kernel",
14136
+ table: "decisionParticipants",
14137
+ prepopulation: "runtime_data",
14138
+ copyMode: "none",
14139
+ description: "Decision participants are tenant-selected actors."
14140
+ },
14141
+ {
14142
+ component: "kernel",
14143
+ table: "decisionRiskLedger",
14144
+ prepopulation: "runtime_data",
14145
+ copyMode: "none",
14146
+ description: "Decision risk rows are tenant decision data."
14147
+ },
14148
+ {
14149
+ component: "kernel",
14150
+ table: "decisionSnapshots",
14151
+ prepopulation: "runtime_derived",
14152
+ copyMode: "none",
14153
+ description: "Decision snapshots are derived from tenant state."
14154
+ },
14155
+ {
14156
+ component: "kernel",
14157
+ table: "deliberationContributions",
14158
+ prepopulation: "runtime_data",
14159
+ copyMode: "none",
14160
+ description: "Deliberation contributions are tenant-authored data."
14161
+ },
14162
+ {
14163
+ component: "kernel",
14164
+ table: "deliberationSessions",
14165
+ prepopulation: "runtime_data",
14166
+ copyMode: "none",
14167
+ description: "Deliberation sessions are created by tenant workflows."
14168
+ },
14169
+ {
14170
+ component: "kernel",
14171
+ table: "epistemicAudit",
14172
+ prepopulation: "runtime_log",
14173
+ copyMode: "none",
14174
+ description: "Epistemic audit rows are append-only runtime audit data."
14175
+ },
14176
+ {
14177
+ component: "kernel",
14178
+ table: "epistemicContracts",
14179
+ prepopulation: "runtime_data",
14180
+ copyMode: "none",
14181
+ description: "Epistemic contracts are tenant-authored governance data."
14182
+ },
14183
+ {
14184
+ component: "kernel",
14185
+ table: "epistemicEdges",
14186
+ prepopulation: "runtime_data",
14187
+ copyMode: "none",
14188
+ description: "Edges are tenant reasoning graph data."
14189
+ },
14190
+ {
14191
+ component: "kernel",
14192
+ table: "epistemicNodeEmbeddings",
14193
+ prepopulation: "runtime_derived",
14194
+ copyMode: "none",
14195
+ description: "Embeddings are derived from tenant graph nodes."
14196
+ },
14197
+ {
14198
+ component: "kernel",
14199
+ table: "epistemicNodes",
14200
+ prepopulation: "runtime_data",
14201
+ copyMode: "none",
14202
+ description: "Nodes are tenant reasoning graph data."
14203
+ },
14204
+ {
14205
+ component: "kernel",
14206
+ table: "graphAnalysisCache",
14207
+ prepopulation: "runtime_derived",
14208
+ copyMode: "none",
14209
+ description: "Graph analysis cache rows are derived from tenant graph state."
14210
+ },
14211
+ {
14212
+ component: "kernel",
14213
+ table: "graphAnalysisResults",
14214
+ prepopulation: "runtime_derived",
14215
+ copyMode: "none",
14216
+ description: "Graph analysis result rows are derived tenant outputs."
14217
+ },
14218
+ {
14219
+ component: "kernel",
14220
+ table: "graphSuggestions",
14221
+ prepopulation: "runtime_derived",
14222
+ copyMode: "none",
14223
+ description: "Graph suggestions are derived recommendations."
14224
+ },
14225
+ {
14226
+ component: "kernel",
14227
+ table: "harnessReplays",
14228
+ prepopulation: "runtime_log",
14229
+ copyMode: "none",
14230
+ description: "Harness replay rows are runtime verification logs."
14231
+ },
14232
+ {
14233
+ component: "kernel",
14234
+ table: "harnessRuns",
14235
+ prepopulation: "runtime_log",
14236
+ copyMode: "none",
14237
+ description: "Harness run rows are runtime verification logs."
14238
+ },
14239
+ {
14240
+ component: "kernel",
14241
+ table: "idempotencyTokens",
14242
+ prepopulation: "runtime_log",
14243
+ copyMode: "none",
14244
+ description: "Idempotency tokens are request-scoped runtime guards."
14245
+ },
14246
+ {
14247
+ component: "kernel",
14248
+ table: "lenses",
14249
+ prepopulation: "optional_template",
14250
+ copyMode: "none",
14251
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
14252
+ },
14253
+ {
14254
+ component: "kernel",
14255
+ table: "lensTopicBindings",
14256
+ prepopulation: "runtime_data",
14257
+ copyMode: "none",
14258
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
14259
+ },
14260
+ {
14261
+ component: "kernel",
14262
+ table: "neo4jSyncQueue",
14263
+ prepopulation: "runtime_queue",
14264
+ copyMode: "none",
14265
+ description: "Neo4j sync queue rows are runtime work items."
14266
+ },
14267
+ {
14268
+ component: "kernel",
14269
+ table: "ontologyDefinitions",
14270
+ prepopulation: "required_template",
14271
+ copyMode: "template_global",
14272
+ scope: "global",
14273
+ uniqueKey: ["ontologyKey"],
14274
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
14275
+ },
14276
+ {
14277
+ component: "kernel",
14278
+ table: "ontologyVersions",
14279
+ prepopulation: "required_template",
14280
+ copyMode: "template_reference_remap",
14281
+ scope: "global",
14282
+ uniqueKey: ["ontologyKey", "version"],
14283
+ dependsOn: ["ontologyDefinitions"],
14284
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
14285
+ },
14286
+ {
14287
+ component: "kernel",
14288
+ table: "platformAgentRunPolicyDecisions",
14289
+ prepopulation: "runtime_log",
14290
+ copyMode: "none",
14291
+ description: "Agent-run policy decisions are audit logs."
14292
+ },
14293
+ {
14294
+ component: "kernel",
14295
+ table: "platformAgentRunPromptResolutions",
14296
+ prepopulation: "runtime_log",
14297
+ copyMode: "none",
14298
+ description: "Agent-run prompt resolution rows are runtime logs."
14299
+ },
14300
+ {
14301
+ component: "kernel",
14302
+ table: "platformAgentRuns",
14303
+ prepopulation: "runtime_log",
14304
+ copyMode: "none",
14305
+ description: "Agent runs are runtime execution records."
14306
+ },
14307
+ {
14308
+ component: "kernel",
14309
+ table: "platformAgentRunToolCalls",
14310
+ prepopulation: "runtime_log",
14311
+ copyMode: "none",
14312
+ description: "Agent-run tool calls are runtime execution records."
14313
+ },
14314
+ {
14315
+ component: "kernel",
14316
+ table: "platformHarnessShadowAudit",
14317
+ prepopulation: "runtime_log",
14318
+ copyMode: "none",
14319
+ description: "Harness shadow audit rows are runtime audit records."
14320
+ },
14321
+ {
14322
+ component: "kernel",
14323
+ table: "publicationRules",
14324
+ prepopulation: "required_template",
14325
+ copyMode: "template_tenant_rewrite",
14326
+ scope: "tenant",
14327
+ uniqueKey: ["tenantId", "workspaceId", "name"],
14328
+ description: "Default publication policy rules are rewritten into each tenant."
14329
+ },
14330
+ {
14331
+ component: "kernel",
14332
+ table: "questionEvidenceLinks",
14333
+ prepopulation: "runtime_data",
14334
+ copyMode: "none",
14335
+ description: "Question-to-evidence links are tenant graph data."
14336
+ },
14337
+ {
14338
+ component: "kernel",
14339
+ table: "researchJobs",
14340
+ prepopulation: "runtime_queue",
14341
+ copyMode: "none",
14342
+ description: "Research job rows are runtime queue items."
14343
+ },
14344
+ {
14345
+ component: "kernel",
14346
+ table: "schemaEnumConfig",
14347
+ prepopulation: "required_template",
14348
+ copyMode: "template_global",
14349
+ scope: "global",
14350
+ uniqueKey: ["category", "value"],
14351
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
14352
+ },
14353
+ {
14354
+ component: "kernel",
14355
+ table: "stakeholderGroups",
14356
+ prepopulation: "runtime_data",
14357
+ copyMode: "none",
14358
+ description: "Stakeholder groups are tenant decision data."
14359
+ },
14360
+ {
14361
+ component: "kernel",
14362
+ table: "systemLogs",
14363
+ prepopulation: "runtime_log",
14364
+ copyMode: "none",
14365
+ description: "System logs are runtime telemetry."
14366
+ },
14367
+ {
14368
+ component: "kernel",
14369
+ table: "tasks",
14370
+ prepopulation: "runtime_data",
14371
+ copyMode: "none",
14372
+ description: "Tasks are tenant-authored work items."
14373
+ },
14374
+ {
14375
+ component: "kernel",
14376
+ table: "topics",
14377
+ prepopulation: "runtime_bootstrap",
14378
+ copyMode: "none",
14379
+ description: "Default topics are created by tenant provisioning, not copied from templates."
14380
+ },
14381
+ {
14382
+ component: "kernel",
14383
+ table: "workflowDefinitions",
14384
+ prepopulation: "optional_template",
14385
+ copyMode: "none",
14386
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
14387
+ },
14388
+ {
14389
+ component: "kernel",
14390
+ table: "workflowPullRequests",
14391
+ prepopulation: "runtime_data",
14392
+ copyMode: "none",
14393
+ description: "Workflow pull requests are tenant workflow data."
14394
+ },
14395
+ {
14396
+ component: "kernel",
14397
+ table: "workflowStages",
14398
+ prepopulation: "optional_template",
14399
+ copyMode: "none",
14400
+ dependsOn: ["workflowDefinitions"],
14401
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
14402
+ },
14403
+ {
14404
+ component: "kernel",
14405
+ table: "worktreeBeliefCluster",
14406
+ prepopulation: "runtime_data",
14407
+ copyMode: "none",
14408
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
14409
+ },
14410
+ {
14411
+ component: "kernel",
14412
+ table: "worktrees",
14413
+ prepopulation: "runtime_data",
14414
+ copyMode: "none",
14415
+ description: "Worktrees are tenant/runtime planning data."
14416
+ },
14417
+ {
14418
+ component: "identity",
14419
+ table: "agents",
14420
+ prepopulation: "runtime_bootstrap",
14421
+ copyMode: "none",
14422
+ description: "Service agents are provisioned per tenant or service, not copied."
14423
+ },
14424
+ {
14425
+ component: "identity",
14426
+ table: "mcpWritePolicy",
14427
+ prepopulation: "required_template",
14428
+ copyMode: "template_global",
14429
+ scope: "global",
14430
+ uniqueKey: ["topicId", "role", "toolCategory"],
14431
+ description: "Global write policy defaults govern service and interactive MCP writes."
14432
+ },
14433
+ {
14434
+ component: "identity",
14435
+ table: "modelCallLogs",
14436
+ prepopulation: "runtime_log",
14437
+ copyMode: "none",
14438
+ description: "Model call logs are runtime telemetry."
14439
+ },
14440
+ {
14441
+ component: "identity",
14442
+ table: "modelFunctionSlots",
14443
+ prepopulation: "required_template",
14444
+ copyMode: "template_global",
14445
+ scope: "global",
14446
+ uniqueKey: ["slot"],
14447
+ description: "Function-to-model slots are required by model runtime resolution."
14448
+ },
14449
+ {
14450
+ component: "identity",
14451
+ table: "modelRegistry",
14452
+ prepopulation: "required_template",
14453
+ copyMode: "template_global",
14454
+ scope: "global",
14455
+ uniqueKey: ["key"],
14456
+ description: "Model catalog defaults are required by model runtime clients."
14457
+ },
14458
+ {
14459
+ component: "identity",
14460
+ table: "modelSlotConfigs",
14461
+ prepopulation: "required_template",
14462
+ copyMode: "template_global",
14463
+ scope: "global",
14464
+ uniqueKey: ["slot"],
14465
+ description: "Slot-level defaults are required before tenant overrides exist."
14466
+ },
14467
+ {
14468
+ component: "identity",
14469
+ table: "platformAudienceGrants",
14470
+ prepopulation: "runtime_data",
14471
+ copyMode: "none",
14472
+ description: "Audience grants are principal/group-specific access rows."
14473
+ },
14474
+ {
14475
+ component: "identity",
14476
+ table: "platformAudiences",
14477
+ prepopulation: "required_template",
14478
+ copyMode: "template_tenant_rewrite",
14479
+ scope: "tenant",
14480
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
14481
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
14482
+ },
14483
+ {
14484
+ component: "identity",
14485
+ table: "platformPolicyDecisionLogs",
14486
+ prepopulation: "runtime_log",
14487
+ copyMode: "none",
14488
+ description: "Policy decisions are runtime audit logs."
14489
+ },
14490
+ {
14491
+ component: "identity",
14492
+ table: "projectGrants",
14493
+ prepopulation: "runtime_data",
14494
+ copyMode: "none",
14495
+ description: "Project/topic grants are principal or group-specific access rows."
14496
+ },
14497
+ {
14498
+ component: "identity",
14499
+ table: "reasoningPermissions",
14500
+ prepopulation: "runtime_data",
14501
+ copyMode: "none",
14502
+ description: "Reasoning permissions are principal-specific policy rows."
14503
+ },
14504
+ {
14505
+ component: "identity",
14506
+ table: "tenantApiKeys",
14507
+ prepopulation: "runtime_secret",
14508
+ copyMode: "none",
14509
+ description: "API keys are tenant credentials and must never be copied."
14510
+ },
14511
+ {
14512
+ component: "identity",
14513
+ table: "tenantConfig",
14514
+ prepopulation: "required_template",
14515
+ copyMode: "template_tenant_rewrite",
14516
+ scope: "tenant",
14517
+ uniqueKey: ["tenantId"],
14518
+ description: "Tenant-local config defaults are rewritten during bootstrap."
14519
+ },
14520
+ {
14521
+ component: "identity",
14522
+ table: "tenantIntegrations",
14523
+ prepopulation: "required_template",
14524
+ copyMode: "template_tenant_rewrite",
14525
+ scope: "tenant",
14526
+ uniqueKey: ["tenantId", "integrationKey"],
14527
+ description: "Non-secret integration descriptors are rewritten into each tenant."
14528
+ },
14529
+ {
14530
+ component: "identity",
14531
+ table: "tenantModelSlotBindings",
14532
+ prepopulation: "runtime_secret",
14533
+ copyMode: "none",
14534
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
14535
+ },
14536
+ {
14537
+ component: "identity",
14538
+ table: "tenantPolicies",
14539
+ prepopulation: "required_template",
14540
+ copyMode: "template_tenant_rewrite",
14541
+ scope: "tenant",
14542
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
14543
+ description: "Default tenant policy roles are rewritten during bootstrap."
14544
+ },
14545
+ {
14546
+ component: "identity",
14547
+ table: "tenantProviderSecrets",
14548
+ prepopulation: "runtime_secret",
14549
+ copyMode: "none",
14550
+ description: "Provider secrets are credentials and must never be copied."
14551
+ },
14552
+ {
14553
+ component: "identity",
14554
+ table: "tenantProxyGatewayUsage",
14555
+ prepopulation: "runtime_log",
14556
+ copyMode: "none",
14557
+ description: "Proxy gateway usage rows are runtime telemetry."
14558
+ },
14559
+ {
14560
+ component: "identity",
14561
+ table: "tenantProxyTokenMints",
14562
+ prepopulation: "runtime_secret",
14563
+ copyMode: "none",
14564
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
14565
+ },
14566
+ {
14567
+ component: "identity",
14568
+ table: "tenantSandboxAuditEvents",
14569
+ prepopulation: "runtime_log",
14570
+ copyMode: "none",
14571
+ description: "Sandbox audit rows are runtime security logs."
14572
+ },
14573
+ {
14574
+ component: "identity",
14575
+ table: "tenantSecrets",
14576
+ prepopulation: "runtime_secret",
14577
+ copyMode: "none",
14578
+ description: "Tenant secrets are credentials and must never be copied."
14579
+ },
14580
+ {
14581
+ component: "identity",
14582
+ table: "toolAcls",
14583
+ prepopulation: "required_template",
14584
+ copyMode: "template_global",
14585
+ scope: "global",
14586
+ uniqueKey: ["role", "toolName"],
14587
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
14588
+ },
14589
+ {
14590
+ component: "identity",
14591
+ table: "toolRegistry",
14592
+ prepopulation: "required_template",
14593
+ copyMode: "template_global",
14594
+ scope: "global",
14595
+ uniqueKey: ["toolName"],
14596
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
14597
+ },
14598
+ {
14599
+ component: "identity",
14600
+ table: "users",
14601
+ prepopulation: "runtime_bootstrap",
14602
+ copyMode: "none",
14603
+ description: "Users are created from Clerk/MC principal resolution, not copied."
14604
+ }
14605
+ ];
14606
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14607
+ isCopyableSeedRequirement
14608
+ );
14609
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14610
+ (entry) => !isCopyableSeedRequirement(entry)
14611
+ ).map((entry) => entry.table);
11561
14612
 
11562
14613
  // src/webhooks.ts
11563
14614
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
14615
+ function invalidWebhookUrlError(error) {
14616
+ return new Error("Webhook URL must be a valid absolute URL.", {
14617
+ cause: error
14618
+ });
14619
+ }
11564
14620
  function normalizeUrl(url) {
11565
14621
  try {
11566
14622
  return new URL(url.trim());
11567
- } catch {
11568
- throw new Error("Webhook URL must be a valid absolute URL.");
14623
+ } catch (error) {
14624
+ throw invalidWebhookUrlError(error);
11569
14625
  }
11570
14626
  }
11571
14627
  function assertValidWebhookUrl(url) {