@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/webhooks.js CHANGED
@@ -1,6 +1,487 @@
1
1
  import { z } from 'zod';
2
2
  import { v } from 'convex/values';
3
3
 
4
+ // ../contracts/src/graph-intelligence.contract.ts
5
+ var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
6
+ core: [
7
+ "get_graph_structure_analysis",
8
+ "get_topic_coverage",
9
+ "get_graph_gaps",
10
+ "list_beliefs",
11
+ "list_questions",
12
+ "search_evidence"
13
+ ],
14
+ bias: [
15
+ "get_graph_structure_analysis",
16
+ "detect_confirmation_bias",
17
+ "find_contradictions",
18
+ "search_evidence",
19
+ "list_beliefs"
20
+ ],
21
+ stress: [
22
+ "get_graph_structure_analysis",
23
+ "get_graph_gaps",
24
+ "find_contradictions",
25
+ "get_falsification_questions",
26
+ "list_beliefs",
27
+ "list_questions"
28
+ ],
29
+ operational: [
30
+ "get_topic_coverage",
31
+ "get_graph_gaps",
32
+ "list_beliefs",
33
+ "list_questions",
34
+ "search_evidence"
35
+ ],
36
+ alpha: [
37
+ "get_graph_structure_analysis",
38
+ "detect_confirmation_bias",
39
+ "find_contradictions",
40
+ "search_beliefs",
41
+ "search_evidence"
42
+ ],
43
+ semantic: [
44
+ "get_graph_structure_analysis",
45
+ "search_beliefs",
46
+ "search_evidence",
47
+ "traverse_graph",
48
+ "query_lineage",
49
+ "get_graph_neighborhood"
50
+ ],
51
+ evidence: [
52
+ "get_graph_structure_analysis",
53
+ "get_topic_coverage",
54
+ "search_evidence",
55
+ "get_falsification_questions",
56
+ "find_contradictions"
57
+ ]
58
+ };
59
+ var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
60
+ var GRAPH_INTELLIGENCE_QUERIES = [
61
+ {
62
+ id: "confirmation-bias",
63
+ categoryId: "problems",
64
+ mode: "bias",
65
+ name: "Find Confirmation Bias",
66
+ description: "Find beliefs supported mainly by confirming evidence.",
67
+ prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
68
+ highlightStrategy: "bias-risk",
69
+ riskLevel: "high"
70
+ },
71
+ {
72
+ id: "contradiction-map",
73
+ categoryId: "problems",
74
+ mode: "stress",
75
+ name: "Map Contradictions",
76
+ description: "Surface direct and indirect contradiction clusters.",
77
+ prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
78
+ highlightStrategy: "contradictions",
79
+ riskLevel: "high"
80
+ },
81
+ {
82
+ id: "weak-evidence",
83
+ categoryId: "problems",
84
+ mode: "stress",
85
+ name: "Weak Evidence Chains",
86
+ description: "Find important claims with thin or indirect evidence.",
87
+ prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
88
+ highlightStrategy: "weak-support",
89
+ riskLevel: "medium"
90
+ },
91
+ {
92
+ id: "single-source",
93
+ categoryId: "problems",
94
+ mode: "bias",
95
+ name: "Single-Source Risk",
96
+ description: "Find claims overly dependent on one source or source type.",
97
+ prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
98
+ highlightStrategy: "source-concentration",
99
+ riskLevel: "medium"
100
+ },
101
+ {
102
+ id: "untested-assumptions",
103
+ categoryId: "problems",
104
+ mode: "stress",
105
+ name: "Untested Assumptions",
106
+ description: "Find load-bearing assumptions without falsification paths.",
107
+ prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
108
+ highlightStrategy: "untested",
109
+ riskLevel: "high"
110
+ },
111
+ {
112
+ id: "load-bearing-beliefs",
113
+ categoryId: "problems",
114
+ mode: "stress",
115
+ name: "Load-Bearing Beliefs",
116
+ description: "Find central beliefs whose failure would affect many claims.",
117
+ prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
118
+ highlightStrategy: "load-bearing",
119
+ riskLevel: "high"
120
+ },
121
+ {
122
+ id: "cascade-analysis",
123
+ categoryId: "problems",
124
+ mode: "stress",
125
+ name: "Cascade Analysis",
126
+ description: "Trace what changes if a belief is weakened or invalidated.",
127
+ prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
128
+ highlightStrategy: "cascade",
129
+ riskLevel: "high"
130
+ },
131
+ {
132
+ id: "unanswered-questions",
133
+ categoryId: "gaps",
134
+ mode: "operational",
135
+ name: "Unanswered Questions",
136
+ description: "Find important open questions that block confidence.",
137
+ prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
138
+ highlightStrategy: "open-questions"
139
+ },
140
+ {
141
+ id: "thin-themes",
142
+ categoryId: "gaps",
143
+ mode: "operational",
144
+ name: "Thin Themes",
145
+ description: "Find topics with shallow belief or evidence coverage.",
146
+ prompt: "Find themes that look underdeveloped relative to their role in the graph.",
147
+ highlightStrategy: "thin-themes"
148
+ },
149
+ {
150
+ id: "missing-evidence",
151
+ categoryId: "gaps",
152
+ mode: "stress",
153
+ name: "Missing Evidence",
154
+ description: "Find beliefs that need specific missing evidence.",
155
+ prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
156
+ highlightStrategy: "missing-evidence"
157
+ },
158
+ {
159
+ id: "isolated-clusters",
160
+ categoryId: "gaps",
161
+ mode: "operational",
162
+ name: "Isolated Clusters",
163
+ description: "Find clusters not connected to the broader graph.",
164
+ prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
165
+ highlightStrategy: "isolated-clusters"
166
+ },
167
+ {
168
+ id: "source-contribution",
169
+ categoryId: "gaps",
170
+ mode: "evidence",
171
+ name: "Source Contribution",
172
+ description: "Assess how source mix shapes the graph.",
173
+ prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
174
+ highlightStrategy: "source-mix"
175
+ },
176
+ {
177
+ id: "stale-beliefs",
178
+ categoryId: "gaps",
179
+ mode: "operational",
180
+ name: "Stale Beliefs",
181
+ description: "Find beliefs that need review because they are old or stale.",
182
+ prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
183
+ highlightStrategy: "staleness"
184
+ },
185
+ {
186
+ id: "assumption-pyramid",
187
+ categoryId: "reasoning",
188
+ mode: "operational",
189
+ name: "Assumption Pyramid",
190
+ description: "Show which conclusions rest on which assumptions.",
191
+ prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
192
+ highlightStrategy: "assumptions"
193
+ },
194
+ {
195
+ id: "converging-evidence",
196
+ categoryId: "reasoning",
197
+ mode: "evidence",
198
+ name: "Converging Evidence",
199
+ description: "Find claims supported by independent evidence streams.",
200
+ prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
201
+ highlightStrategy: "convergence"
202
+ },
203
+ {
204
+ id: "weakest-links",
205
+ categoryId: "reasoning",
206
+ mode: "stress",
207
+ name: "Weakest Links",
208
+ description: "Find the weakest links in important reasoning chains.",
209
+ prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
210
+ highlightStrategy: "weak-links",
211
+ riskLevel: "medium"
212
+ },
213
+ {
214
+ id: "challenged-beliefs",
215
+ categoryId: "reasoning",
216
+ mode: "stress",
217
+ name: "Challenged Beliefs",
218
+ description: "Find beliefs with active challenges or defeaters.",
219
+ prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
220
+ highlightStrategy: "challenged"
221
+ },
222
+ {
223
+ id: "contrarian-map",
224
+ categoryId: "strategic",
225
+ mode: "alpha",
226
+ name: "Contrarian Map",
227
+ description: "Find non-consensus beliefs and where they are grounded.",
228
+ prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
229
+ highlightStrategy: "contrarian"
230
+ },
231
+ {
232
+ id: "irreversibility-audit",
233
+ categoryId: "strategic",
234
+ mode: "stress",
235
+ name: "Irreversibility Audit",
236
+ description: "Find irreversible bets and assumptions behind them.",
237
+ prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
238
+ highlightStrategy: "irreversible",
239
+ riskLevel: "high"
240
+ },
241
+ {
242
+ id: "pre-mortem",
243
+ categoryId: "strategic",
244
+ mode: "stress",
245
+ name: "Pre-Mortem",
246
+ description: "Explain how the graph could be wrong.",
247
+ prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
248
+ highlightStrategy: "failure-paths",
249
+ riskLevel: "high"
250
+ },
251
+ {
252
+ id: "devils-advocate",
253
+ categoryId: "strategic",
254
+ mode: "stress",
255
+ name: "Devil's Advocate",
256
+ description: "Generate the strongest critique of the graph.",
257
+ prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
258
+ highlightStrategy: "critique"
259
+ },
260
+ {
261
+ id: "falsification-map",
262
+ categoryId: "strategic",
263
+ mode: "stress",
264
+ name: "Falsification Map",
265
+ description: "Find the cheapest tests that would disprove key beliefs.",
266
+ prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
267
+ highlightStrategy: "falsification",
268
+ riskLevel: "high"
269
+ },
270
+ {
271
+ id: "prediction-tracker",
272
+ categoryId: "strategic",
273
+ mode: "evidence",
274
+ name: "Prediction Tracker",
275
+ description: "Find beliefs that imply measurable predictions.",
276
+ prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
277
+ highlightStrategy: "predictions"
278
+ },
279
+ {
280
+ id: "belief-pagerank",
281
+ categoryId: "deep",
282
+ mode: "semantic",
283
+ name: "Belief PageRank",
284
+ description: "Identify structurally central beliefs.",
285
+ prompt: "Use graph centrality to identify the most structurally important beliefs.",
286
+ highlightStrategy: "centrality"
287
+ },
288
+ {
289
+ id: "underdetermination",
290
+ categoryId: "deep",
291
+ mode: "semantic",
292
+ name: "Underdetermination",
293
+ description: "Find places where evidence supports multiple explanations.",
294
+ prompt: "Find places where the same evidence could support multiple incompatible explanations.",
295
+ highlightStrategy: "underdetermination"
296
+ },
297
+ {
298
+ id: "confidence-propagation",
299
+ categoryId: "deep",
300
+ mode: "semantic",
301
+ name: "Confidence Propagation",
302
+ description: "Assess how uncertainty moves through the graph.",
303
+ prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
304
+ highlightStrategy: "confidence-flow"
305
+ },
306
+ {
307
+ id: "argument-depth",
308
+ categoryId: "deep",
309
+ mode: "evidence",
310
+ name: "Argument Depth",
311
+ description: "Assess reasoning depth and chain quality.",
312
+ prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
313
+ highlightStrategy: "depth"
314
+ },
315
+ {
316
+ id: "information-edge",
317
+ categoryId: "deep",
318
+ mode: "alpha",
319
+ name: "Information Edge",
320
+ description: "Find differentiated evidence or signals.",
321
+ prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
322
+ highlightStrategy: "information-edge"
323
+ },
324
+ {
325
+ id: "thesis-summary",
326
+ categoryId: "browse",
327
+ mode: "semantic",
328
+ name: "Thesis Summary",
329
+ description: "Summarize the graph's core thesis and support.",
330
+ prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
331
+ highlightStrategy: "summary"
332
+ },
333
+ {
334
+ id: "theme-deep-dive",
335
+ categoryId: "browse",
336
+ mode: "semantic",
337
+ name: "Theme Deep Dive",
338
+ description: "Deep dive into a named theme.",
339
+ prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
340
+ inputType: "theme",
341
+ highlightStrategy: "theme"
342
+ },
343
+ {
344
+ id: "belief-detail",
345
+ categoryId: "browse",
346
+ mode: "semantic",
347
+ name: "Belief Detail",
348
+ description: "Explain one belief and its graph neighborhood.",
349
+ prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
350
+ inputType: "belief",
351
+ highlightStrategy: "belief"
352
+ },
353
+ {
354
+ id: "strongest-beliefs",
355
+ categoryId: "browse",
356
+ mode: "operational",
357
+ name: "Strongest Beliefs",
358
+ description: "Find the graph's strongest current beliefs.",
359
+ prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
360
+ highlightStrategy: "strongest"
361
+ },
362
+ {
363
+ id: "cross-theme-connection",
364
+ categoryId: "browse",
365
+ mode: "semantic",
366
+ name: "Cross-Theme Connections",
367
+ description: "Find bridges between themes.",
368
+ prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
369
+ highlightStrategy: "bridges"
370
+ },
371
+ {
372
+ id: "research-velocity",
373
+ categoryId: "browse",
374
+ mode: "operational",
375
+ name: "Research Velocity",
376
+ description: "Summarize recent graph movement and momentum.",
377
+ prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
378
+ highlightStrategy: "velocity"
379
+ },
380
+ {
381
+ id: "search",
382
+ categoryId: "browse",
383
+ mode: "semantic",
384
+ name: "Graph Search",
385
+ description: "Search the graph with semantic context.",
386
+ prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
387
+ inputType: "search",
388
+ highlightStrategy: "search"
389
+ },
390
+ {
391
+ id: "expert-coverage",
392
+ categoryId: "browse",
393
+ mode: "semantic",
394
+ name: "Expert Coverage",
395
+ description: "Assess coverage from expert/source perspectives.",
396
+ prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
397
+ highlightStrategy: "expert-coverage"
398
+ },
399
+ {
400
+ id: "value-chain-map",
401
+ categoryId: "browse",
402
+ mode: "semantic",
403
+ name: "Value Chain Map",
404
+ description: "Map entities, dependencies, and value-chain logic.",
405
+ prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
406
+ highlightStrategy: "value-chain"
407
+ },
408
+ {
409
+ id: "meeting-brief",
410
+ categoryId: "prep",
411
+ mode: "semantic",
412
+ name: "Meeting Brief",
413
+ description: "Prepare a meeting brief from graph context.",
414
+ prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
415
+ highlightStrategy: "brief"
416
+ },
417
+ {
418
+ id: "open-questions-entity",
419
+ categoryId: "prep",
420
+ mode: "semantic",
421
+ name: "Entity Open Questions",
422
+ description: "Find open questions about a specific entity.",
423
+ prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
424
+ inputType: "entity",
425
+ highlightStrategy: "entity-questions"
426
+ },
427
+ {
428
+ id: "company-context",
429
+ categoryId: "prep",
430
+ mode: "semantic",
431
+ name: "Company Context",
432
+ description: "Summarize graph context about a company.",
433
+ prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
434
+ inputType: "company",
435
+ highlightStrategy: "company"
436
+ },
437
+ {
438
+ id: "company-theme-fit",
439
+ categoryId: "prep",
440
+ mode: "semantic",
441
+ name: "Company Theme Fit",
442
+ description: "Assess how a company fits graph themes.",
443
+ prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
444
+ inputType: "company",
445
+ highlightStrategy: "fit"
446
+ },
447
+ {
448
+ id: "company-comparison",
449
+ categoryId: "prep",
450
+ mode: "semantic",
451
+ name: "Company Comparison",
452
+ description: "Compare companies through graph context.",
453
+ prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
454
+ inputType: "company-list",
455
+ highlightStrategy: "comparison"
456
+ },
457
+ {
458
+ id: "questions-to-ask",
459
+ categoryId: "prep",
460
+ mode: "operational",
461
+ name: "Questions to Ask",
462
+ description: "Generate high-signal questions from graph gaps.",
463
+ prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
464
+ highlightStrategy: "questions"
465
+ },
466
+ {
467
+ id: "beliefs-to-test",
468
+ categoryId: "prep",
469
+ mode: "stress",
470
+ name: "Beliefs to Test",
471
+ description: "Prioritize beliefs that should be tested next.",
472
+ prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
473
+ highlightStrategy: "tests",
474
+ riskLevel: "medium"
475
+ }
476
+ ];
477
+ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
478
+ const definition = query;
479
+ return {
480
+ ...definition,
481
+ tools: definition.tools ?? byMode(definition.mode)
482
+ };
483
+ });
484
+
4
485
  // ../contracts/src/events.contract.ts
5
486
  var WEBHOOK_MAX_ATTEMPTS = 5;
6
487
  var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
@@ -21,7 +502,10 @@ function idOf(table) {
21
502
  return schema;
22
503
  }
23
504
  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"]);
24
- 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"]);
505
+ 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"];
506
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
507
+ z.enum(EDGE_TYPE_VALUES);
508
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
25
509
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
26
510
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
27
511
  defineTable({
@@ -1506,7 +1990,7 @@ defineTable({
1506
1990
  "toNodeId": z.string().optional(),
1507
1991
  "sourceGlobalId": z.string().optional(),
1508
1992
  "targetGlobalId": z.string().optional(),
1509
- "edgeType": EDGE_TYPE,
1993
+ "edgeType": STORAGE_EDGE_TYPE,
1510
1994
  "edgeTier": z.string().optional(),
1511
1995
  "domainNamespace": z.string().optional(),
1512
1996
  "constraint": z.string().optional(),
@@ -1849,6 +2333,40 @@ defineTable({
1849
2333
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
1850
2334
  ]
1851
2335
  });
2336
+ defineTable({
2337
+ name: "oauthDeviceCodes",
2338
+ component: "mc",
2339
+ category: "identity",
2340
+ shape: z.object({
2341
+ "deviceCodeHash": z.string(),
2342
+ "userCode": z.string(),
2343
+ "clientId": z.string(),
2344
+ "scope": z.string(),
2345
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
2346
+ "expiresAt": z.number(),
2347
+ "intervalSeconds": z.number(),
2348
+ "lastPolledAt": z.number().optional(),
2349
+ "slowDownCount": z.number().optional(),
2350
+ "clerkUserId": z.string().optional(),
2351
+ "tenantId": idOf("tenants").optional(),
2352
+ "workspaceId": z.string().optional(),
2353
+ "principalId": z.string().optional(),
2354
+ "role": z.string().optional(),
2355
+ "scopes": z.array(z.string()).optional(),
2356
+ "sessionId": z.string().optional(),
2357
+ "approvedAt": z.number().optional(),
2358
+ "deniedAt": z.number().optional(),
2359
+ "consumedAt": z.number().optional(),
2360
+ "createdAt": z.number(),
2361
+ "updatedAt": z.number()
2362
+ }),
2363
+ indices: [
2364
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
2365
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
2366
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
2367
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
2368
+ ]
2369
+ });
1852
2370
  defineTable({
1853
2371
  name: "servicePrincipalKeys",
1854
2372
  component: "mc",
@@ -3681,6 +4199,7 @@ defineTable({
3681
4199
  "updatedAt": z.number()
3682
4200
  }),
3683
4201
  indices: [
4202
+ { kind: "index", name: "by_globalId", columns: ["globalId"] },
3684
4203
  { kind: "index", name: "by_parent", columns: ["parentTopicId"] },
3685
4204
  { kind: "index", name: "by_type", columns: ["type"] },
3686
4205
  { kind: "index", name: "by_graph_scope_project", columns: ["graphScopeProjectId"] },
@@ -3805,7 +4324,9 @@ defineTable({
3805
4324
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3806
4325
  "deployments": z.record(z.object({
3807
4326
  "url": z.string(),
3808
- "encryptedDeployKey": z.string()
4327
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4328
+ "encryptedDeployKey": z.string().optional(),
4329
+ "credentialRef": z.string().optional()
3809
4330
  })).optional(),
3810
4331
  "metadata": z.record(z.any()).optional(),
3811
4332
  "createdBy": z.string().optional(),
@@ -4155,17 +4676,44 @@ z.object({
4155
4676
  message: "SL invariant b+d+u=1 violated at API boundary"
4156
4677
  }
4157
4678
  );
4158
- var EpistemicNodeTypeSchema = z.enum([
4679
+
4680
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
4681
+ var NODE_TYPES = [
4682
+ "decision",
4159
4683
  "belief",
4160
- "evidence",
4161
4684
  "question",
4162
- "answer",
4685
+ "theme",
4686
+ "deal",
4163
4687
  "topic",
4688
+ "claim",
4689
+ "evidence",
4690
+ "synthesis",
4691
+ "answer",
4692
+ "atomic_fact",
4693
+ "excerpt",
4694
+ "source",
4695
+ "company",
4696
+ "person",
4697
+ "investor",
4698
+ "function",
4699
+ "value_chain"
4700
+ ];
4701
+ new Set(NODE_TYPES);
4702
+
4703
+ // ../contracts/src/types/graph-ref.ts
4704
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4164
4705
  "edge",
4165
4706
  "ontology",
4166
4707
  "lens",
4167
4708
  "contradiction"
4168
- ]);
4709
+ ];
4710
+ var GRAPH_REF_NODE_TYPES = [
4711
+ ...NODE_TYPES,
4712
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4713
+ ];
4714
+ var EpistemicNodeTypeSchema = z.enum(
4715
+ GRAPH_REF_NODE_TYPES
4716
+ );
4169
4717
  var GraphRefSchema = z.discriminatedUnion("kind", [
4170
4718
  z.object({
4171
4719
  kind: z.literal("epistemic_node"),
@@ -4213,34 +4761,142 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4213
4761
  }
4214
4762
 
4215
4763
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
4764
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
4765
+ edgeType,
4766
+ fromKinds: ["epistemic_node"],
4767
+ toKinds: ["epistemic_node"],
4768
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
4769
+ });
4216
4770
  var edgePolicyManifest = {
4217
- policies: [
4218
- {
4219
- edgeType: "evidence_derived_from_evidence",
4220
- fromKinds: ["epistemic_node"],
4221
- fromNodeTypes: ["evidence"],
4222
- toKinds: ["epistemic_node"],
4223
- toNodeTypes: ["evidence"],
4224
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4225
- },
4226
- {
4227
- edgeType: "evidence_supports_belief",
4228
- fromKinds: ["epistemic_node"],
4229
- fromNodeTypes: ["evidence"],
4230
- toKinds: ["epistemic_node"],
4231
- toNodeTypes: ["belief"],
4232
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4233
- },
4234
- {
4235
- edgeType: "evidence_supports_question",
4236
- fromKinds: ["epistemic_node"],
4237
- fromNodeTypes: ["evidence"],
4238
- toKinds: ["epistemic_node"],
4239
- toNodeTypes: ["question"],
4240
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4241
- }
4242
- ]
4771
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
4243
4772
  };
4773
+
4774
+ // ../contracts/src/tenant-client.contract.ts
4775
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4776
+ {
4777
+ packageName: "@lucern/access-control",
4778
+ role: "runtime_entrypoint",
4779
+ directTenantImport: true
4780
+ },
4781
+ {
4782
+ packageName: "@lucern/agent",
4783
+ role: "platform_runtime",
4784
+ directTenantImport: false
4785
+ },
4786
+ {
4787
+ packageName: "@lucern/auth",
4788
+ role: "sdk_dependency",
4789
+ directTenantImport: false
4790
+ },
4791
+ {
4792
+ packageName: "@lucern/cli",
4793
+ role: "developer_tool",
4794
+ directTenantImport: false
4795
+ },
4796
+ {
4797
+ packageName: "@lucern/client-core",
4798
+ role: "sdk_dependency",
4799
+ directTenantImport: false
4800
+ },
4801
+ {
4802
+ packageName: "@lucern/confidence",
4803
+ role: "sdk_dependency",
4804
+ directTenantImport: false
4805
+ },
4806
+ {
4807
+ packageName: "@lucern/config",
4808
+ role: "configuration",
4809
+ directTenantImport: false
4810
+ },
4811
+ {
4812
+ packageName: "@lucern/contracts",
4813
+ role: "contract_entrypoint",
4814
+ directTenantImport: true
4815
+ },
4816
+ {
4817
+ packageName: "@lucern/control-plane",
4818
+ role: "platform_runtime",
4819
+ directTenantImport: false
4820
+ },
4821
+ {
4822
+ packageName: "@lucern/developer-kit",
4823
+ role: "developer_tool",
4824
+ directTenantImport: false
4825
+ },
4826
+ {
4827
+ packageName: "@lucern/events",
4828
+ role: "sdk_dependency",
4829
+ directTenantImport: false
4830
+ },
4831
+ {
4832
+ packageName: "@lucern/graph-primitives",
4833
+ role: "sdk_dependency",
4834
+ directTenantImport: false
4835
+ },
4836
+ {
4837
+ packageName: "@lucern/graph-sync",
4838
+ role: "host_addon_runtime",
4839
+ directTenantImport: true
4840
+ },
4841
+ {
4842
+ packageName: "@lucern/identity",
4843
+ role: "component_runtime",
4844
+ directTenantImport: false
4845
+ },
4846
+ {
4847
+ packageName: "@lucern/mcp",
4848
+ role: "runtime_entrypoint",
4849
+ directTenantImport: true
4850
+ },
4851
+ {
4852
+ packageName: "@lucern/pack-host",
4853
+ role: "platform_runtime",
4854
+ directTenantImport: false
4855
+ },
4856
+ {
4857
+ packageName: "@lucern/pack-installer",
4858
+ role: "developer_tool",
4859
+ directTenantImport: false
4860
+ },
4861
+ {
4862
+ packageName: "@lucern/proof-compiler",
4863
+ role: "developer_tool",
4864
+ directTenantImport: false
4865
+ },
4866
+ {
4867
+ packageName: "@lucern/react",
4868
+ role: "runtime_entrypoint",
4869
+ directTenantImport: true
4870
+ },
4871
+ {
4872
+ packageName: "@lucern/reasoning-kernel",
4873
+ role: "component_runtime",
4874
+ directTenantImport: false
4875
+ },
4876
+ {
4877
+ packageName: "@lucern/sdk",
4878
+ role: "runtime_entrypoint",
4879
+ directTenantImport: true
4880
+ },
4881
+ {
4882
+ packageName: "@lucern/server-core",
4883
+ role: "platform_runtime",
4884
+ directTenantImport: false
4885
+ },
4886
+ {
4887
+ packageName: "@lucern/testing",
4888
+ role: "test_support",
4889
+ directTenantImport: false
4890
+ },
4891
+ {
4892
+ packageName: "@lucern/types",
4893
+ role: "contract_entrypoint",
4894
+ directTenantImport: true
4895
+ }
4896
+ ];
4897
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
4898
+ (entry) => entry.packageName
4899
+ );
4244
4900
  z.object({
4245
4901
  manifestVersion: z.literal("1.0.0"),
4246
4902
  rules: z.array(
@@ -4301,8 +4957,11 @@ function compactRecord(input) {
4301
4957
  Object.entries(input).filter(([, value]) => value !== void 0)
4302
4958
  );
4303
4959
  }
4960
+ function isRecord(value) {
4961
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4962
+ }
4304
4963
  function recordValue(value) {
4305
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
4964
+ return isRecord(value) ? value : {};
4306
4965
  }
4307
4966
  var createEvidenceProjection = defineProjection({
4308
4967
  contractName: "create_evidence",
@@ -5002,7 +5661,22 @@ var ADD_WORKTREE = {
5002
5661
  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.",
5003
5662
  parameters: {
5004
5663
  title: { type: "string", description: "Worktree name/objective" },
5005
- topicId: { type: "string", description: "Optional topic scope hint" },
5664
+ name: {
5665
+ type: "string",
5666
+ description: "Optional storage-name alias for callers that already use backend naming"
5667
+ },
5668
+ projectId: {
5669
+ type: "string",
5670
+ description: "Legacy topicId alias or resolver hint"
5671
+ },
5672
+ topicId: {
5673
+ type: "string",
5674
+ description: "Optional topic scope hint for resolver validation"
5675
+ },
5676
+ topicHint: {
5677
+ type: "string",
5678
+ description: "Natural-language topic hint for automatic topic resolution"
5679
+ },
5006
5680
  branchId: {
5007
5681
  type: "string",
5008
5682
  description: "The branch this worktree investigates"
@@ -5015,18 +5689,107 @@ var ADD_WORKTREE = {
5015
5689
  type: "string",
5016
5690
  description: "The testable claim this worktree investigates"
5017
5691
  },
5692
+ rationale: {
5693
+ type: "string",
5694
+ description: "Why this worktree exists and why it belongs in the campaign"
5695
+ },
5696
+ worktreeType: {
5697
+ type: "string",
5698
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5699
+ },
5700
+ gate: {
5701
+ type: "string",
5702
+ description: "Exit gate name for this worktree"
5703
+ },
5704
+ startDate: {
5705
+ type: "number",
5706
+ description: "Planned start timestamp in milliseconds since epoch"
5707
+ },
5708
+ endDate: {
5709
+ type: "number",
5710
+ description: "Planned end timestamp in milliseconds since epoch"
5711
+ },
5712
+ durationWeeks: {
5713
+ type: "number",
5714
+ description: "Planned duration in weeks"
5715
+ },
5716
+ confidenceImpact: {
5717
+ type: "string",
5718
+ description: "Expected confidence impact if the worktree succeeds",
5719
+ enum: ["high", "medium", "low"]
5720
+ },
5721
+ beliefFocus: {
5722
+ type: "string",
5723
+ description: "Natural-language focus spanning the target belief neighborhood"
5724
+ },
5018
5725
  beliefIds: {
5019
5726
  type: "array",
5020
- description: "Beliefs to test in this worktree"
5727
+ description: "Legacy alias for targetBeliefIds"
5728
+ },
5729
+ beliefs: {
5730
+ type: "array",
5731
+ description: "Legacy alias for targetBeliefIds"
5732
+ },
5733
+ targetBeliefIds: {
5734
+ type: "array",
5735
+ description: "Belief node IDs this worktree is expected to test or update"
5736
+ },
5737
+ targetQuestionIds: {
5738
+ type: "array",
5739
+ description: "Question node IDs this worktree is expected to answer"
5740
+ },
5741
+ keyQuestions: {
5742
+ type: "array",
5743
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5744
+ },
5745
+ evidenceSignals: {
5746
+ type: "array",
5747
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5748
+ },
5749
+ decisionGate: {
5750
+ type: "object",
5751
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5752
+ },
5753
+ goCriteria: {
5754
+ type: "array",
5755
+ description: "Shorthand go criteria used to build decisionGate"
5756
+ },
5757
+ noGoSignals: {
5758
+ type: "array",
5759
+ description: "Shorthand no-go signals used to build decisionGate"
5760
+ },
5761
+ proofArtifacts: {
5762
+ type: "array",
5763
+ description: "Expected proof artifacts required to close the worktree"
5021
5764
  },
5022
5765
  autoShape: {
5023
5766
  type: "boolean",
5024
5767
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5025
5768
  },
5769
+ autoFixPolicy: {
5770
+ type: "object",
5771
+ description: "Policy for permitted automatic remediation inside the worktree"
5772
+ },
5026
5773
  domainPackId: {
5027
5774
  type: "string",
5028
5775
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5029
5776
  },
5777
+ tags: {
5778
+ type: "array",
5779
+ description: "Additional topic-resolution tags for the worktree"
5780
+ },
5781
+ touchedPaths: {
5782
+ type: "array",
5783
+ description: "File paths used as topic-resolution signals"
5784
+ },
5785
+ sourceRef: {
5786
+ type: "string",
5787
+ description: "Source reference used as a topic-resolution signal"
5788
+ },
5789
+ sourceKind: {
5790
+ type: "string",
5791
+ description: "Source kind used as a topic-resolution signal"
5792
+ },
5030
5793
  campaign: {
5031
5794
  type: "number",
5032
5795
  description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
@@ -5051,13 +5814,21 @@ var ADD_WORKTREE = {
5051
5814
  type: "array",
5052
5815
  description: "Worktree IDs blocked by this worktree"
5053
5816
  },
5054
- gate: {
5817
+ staffingHint: {
5055
5818
  type: "string",
5056
- description: "Exit gate name for this worktree"
5057
- }
5058
- },
5059
- required: ["title", "topicId"],
5060
- response: {
5819
+ description: "Suggested staffing or agent allocation note"
5820
+ },
5821
+ lensId: {
5822
+ type: "string",
5823
+ description: "Lens that scopes this worktree when applicable"
5824
+ },
5825
+ lastReconciledAt: {
5826
+ type: "number",
5827
+ description: "Timestamp when worktree metadata was last reconciled"
5828
+ }
5829
+ },
5830
+ required: ["title"],
5831
+ response: {
5061
5832
  description: "The created worktree",
5062
5833
  fields: {
5063
5834
  worktreeId: "string",
@@ -5083,7 +5854,7 @@ var MERGE = {
5083
5854
  worktreeId: { type: "string", description: "The worktree to merge" },
5084
5855
  outcomes: {
5085
5856
  type: "array",
5086
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5857
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5087
5858
  },
5088
5859
  summary: { type: "string", description: "Overall findings summary" }
5089
5860
  },
@@ -5301,19 +6072,23 @@ var FIND_CONTRADICTIONS = {
5301
6072
  };
5302
6073
  var CREATE_EDGE = {
5303
6074
  name: "create_edge",
5304
- 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).",
6075
+ 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.",
5305
6076
  parameters: {
5306
- sourceId: {
5307
- type: "string",
5308
- description: "Source node of the relationship"
6077
+ from: {
6078
+ type: "object",
6079
+ description: "Source graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'topic' }"
5309
6080
  },
5310
- targetId: {
5311
- type: "string",
5312
- description: "Target node of the relationship"
6081
+ to: {
6082
+ type: "object",
6083
+ description: "Target graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'belief' }"
5313
6084
  },
5314
6085
  edgeType: {
5315
6086
  type: "string",
5316
- description: "Relationship type (informs, tests, depends_on, supersedes, etc.)"
6087
+ description: "Relationship type from the public epistemic edge enum."
6088
+ },
6089
+ globalId: {
6090
+ type: "string",
6091
+ description: "Optional idempotent edge global ID."
5317
6092
  },
5318
6093
  weight: {
5319
6094
  type: "number",
@@ -5324,9 +6099,13 @@ var CREATE_EDGE = {
5324
6099
  type: "string",
5325
6100
  description: "How this was determined",
5326
6101
  enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
6102
+ },
6103
+ metadata: {
6104
+ type: "object",
6105
+ description: "Optional edge metadata."
5327
6106
  }
5328
6107
  },
5329
- required: ["sourceId", "targetId", "edgeType"],
6108
+ required: ["from", "to", "edgeType"],
5330
6109
  response: {
5331
6110
  description: "The created edge",
5332
6111
  fields: {
@@ -5340,6 +6119,240 @@ var CREATE_EDGE = {
5340
6119
  ontologyPrimitive: "edge",
5341
6120
  tier: "showcase"
5342
6121
  };
6122
+ var UPDATE_EDGE = {
6123
+ name: "update_edge",
6124
+ description: "Amend metadata on an existing graph edge. Like `git commit --amend` \u2014 changes the edge annotation without recreating the relationship.",
6125
+ parameters: {
6126
+ edgeId: { type: "string", description: "Edge ID or global ID to update" },
6127
+ weight: { type: "number", description: "Updated edge weight" },
6128
+ confidence: { type: "number", description: "Updated confidence" },
6129
+ context: { type: "string", description: "Updated human-readable context" },
6130
+ derivationType: { type: "string", description: "Updated derivation type" },
6131
+ metadata: { type: "object", description: "Updated metadata" }
6132
+ },
6133
+ required: ["edgeId"],
6134
+ response: {
6135
+ description: "Edge update result",
6136
+ fields: { success: "boolean" }
6137
+ },
6138
+ ownerModule: "graph-primitives",
6139
+ ontologyPrimitive: "edge",
6140
+ tier: "workhorse"
6141
+ };
6142
+ var REMOVE_EDGE = {
6143
+ name: "remove_edge",
6144
+ description: "Remove one graph edge by ID. Like `git rm` \u2014 deletes a single explicit relationship from the spine.",
6145
+ parameters: {
6146
+ edgeId: { type: "string", description: "Edge ID or global ID to remove" }
6147
+ },
6148
+ required: ["edgeId"],
6149
+ response: {
6150
+ description: "Edge removal result",
6151
+ fields: { success: "boolean" }
6152
+ },
6153
+ ownerModule: "graph-primitives",
6154
+ ontologyPrimitive: "edge",
6155
+ tier: "workhorse"
6156
+ };
6157
+ var REMOVE_EDGES_BETWEEN = {
6158
+ name: "remove_edges_between",
6159
+ description: "Remove graph edges between two nodes. Like `git rm <pathspec>` \u2014 deletes relationships matching a source, target, and optional type.",
6160
+ parameters: {
6161
+ fromNodeId: { type: "string", description: "Source node ID or global ID" },
6162
+ toNodeId: { type: "string", description: "Target node ID or global ID" },
6163
+ edgeType: { type: "string", description: "Optional edge type filter" }
6164
+ },
6165
+ required: ["fromNodeId", "toNodeId"],
6166
+ response: {
6167
+ description: "Matched edge removal result",
6168
+ fields: { deleted: "number" }
6169
+ },
6170
+ ownerModule: "graph-primitives",
6171
+ ontologyPrimitive: "edge",
6172
+ tier: "workhorse"
6173
+ };
6174
+ var BATCH_CREATE_EDGES = {
6175
+ name: "batch_create_edges",
6176
+ description: "Commit multiple typed graph edges. Like `git commit` with many staged paths \u2014 writes a batch of explicit relationships atomically per edge.",
6177
+ parameters: {
6178
+ edges: {
6179
+ type: "array",
6180
+ description: "Edges to create, each with from, to, edgeType, and optional weight/confidence/context."
6181
+ },
6182
+ skipLayerValidation: {
6183
+ type: "boolean",
6184
+ description: "Skip kernel layer validation for trusted materialization flows."
6185
+ }
6186
+ },
6187
+ required: ["edges"],
6188
+ response: {
6189
+ description: "Batch edge creation result",
6190
+ fields: {
6191
+ created: "number",
6192
+ results: "array",
6193
+ errors: "array"
6194
+ }
6195
+ },
6196
+ ownerModule: "graph-primitives",
6197
+ ontologyPrimitive: "edge",
6198
+ tier: "workhorse"
6199
+ };
6200
+ var CREATE_EPISTEMIC_NODE = {
6201
+ name: "create_epistemic_node",
6202
+ 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.",
6203
+ parameters: {
6204
+ globalId: { type: "string", description: "Optional idempotent node global ID" },
6205
+ nodeType: { type: "string", description: "Public epistemic node type" },
6206
+ canonicalText: { type: "string", description: "Canonical node text" },
6207
+ text: { type: "string", description: "Alias for canonicalText" },
6208
+ contentHash: { type: "string", description: "Optional idempotency content hash" },
6209
+ sourceType: { type: "string", description: "Source type for provenance" },
6210
+ topicId: { type: "string", description: "Optional topic scope" },
6211
+ content: { type: "string", description: "Extended content" },
6212
+ title: { type: "string", description: "Display title" },
6213
+ metadata: { type: "object", description: "Optional node metadata" }
6214
+ },
6215
+ required: ["nodeType"],
6216
+ response: {
6217
+ description: "Created node result",
6218
+ fields: {
6219
+ nodeId: "string",
6220
+ nodeGlobalId: "string",
6221
+ isDuplicate: "boolean"
6222
+ }
6223
+ },
6224
+ ownerModule: "reasoning-kernel",
6225
+ ontologyPrimitive: "graph",
6226
+ tier: "showcase"
6227
+ };
6228
+ var GET_EPISTEMIC_NODE = {
6229
+ name: "get_epistemic_node",
6230
+ description: "Read one epistemic graph node. Like `git show` \u2014 resolves a canonical spine node by ID or global ID.",
6231
+ parameters: {
6232
+ nodeId: { type: "string", description: "Node ID or global ID" }
6233
+ },
6234
+ required: ["nodeId"],
6235
+ response: {
6236
+ description: "The resolved node",
6237
+ fields: { node: "object" }
6238
+ },
6239
+ ownerModule: "reasoning-kernel",
6240
+ ontologyPrimitive: "graph",
6241
+ tier: "workhorse"
6242
+ };
6243
+ var LIST_EPISTEMIC_NODES = {
6244
+ name: "list_epistemic_nodes",
6245
+ description: "List epistemic graph nodes. Like `git ls-tree` \u2014 lists canonical spine nodes by topic, type, status, or search query.",
6246
+ parameters: {
6247
+ topicId: { type: "string", description: "Optional topic scope" },
6248
+ nodeType: { type: "string", description: "Optional node type filter" },
6249
+ status: { type: "string", description: "Optional lifecycle status" },
6250
+ searchQuery: { type: "string", description: "Optional text search query" },
6251
+ limit: { type: "number", description: "Maximum nodes to return" }
6252
+ },
6253
+ required: [],
6254
+ response: {
6255
+ description: "Matching nodes",
6256
+ fields: { nodes: "array" }
6257
+ },
6258
+ ownerModule: "reasoning-kernel",
6259
+ ontologyPrimitive: "graph",
6260
+ tier: "workhorse"
6261
+ };
6262
+ var UPDATE_EPISTEMIC_NODE = {
6263
+ name: "update_epistemic_node",
6264
+ description: "Amend an epistemic graph node. Like `git commit --amend` \u2014 updates mutable node metadata, text, status, or verification fields.",
6265
+ parameters: {
6266
+ nodeId: { type: "string", description: "Node ID or global ID" },
6267
+ canonicalText: { type: "string", description: "Updated canonical text" },
6268
+ text: { type: "string", description: "Alias for canonicalText" },
6269
+ contentHash: { type: "string", description: "Updated content hash" },
6270
+ content: { type: "string", description: "Updated content" },
6271
+ title: { type: "string", description: "Updated display title" },
6272
+ metadata: { type: "object", description: "Updated metadata" },
6273
+ confidence: { type: "number", description: "Updated confidence" },
6274
+ verificationStatus: { type: "string", description: "Updated verification status" },
6275
+ status: { type: "string", description: "Updated lifecycle status" }
6276
+ },
6277
+ required: ["nodeId"],
6278
+ response: {
6279
+ description: "Node update result",
6280
+ fields: { success: "boolean" }
6281
+ },
6282
+ ownerModule: "reasoning-kernel",
6283
+ ontologyPrimitive: "graph",
6284
+ tier: "workhorse"
6285
+ };
6286
+ var ARCHIVE_EPISTEMIC_NODE = {
6287
+ name: "archive_epistemic_node",
6288
+ description: "Archive an epistemic graph node. Like `git rm --cached` \u2014 removes a node from active traversal without hard-deleting it.",
6289
+ parameters: {
6290
+ nodeId: { type: "string", description: "Node ID or global ID" }
6291
+ },
6292
+ required: ["nodeId"],
6293
+ response: {
6294
+ description: "Archive result",
6295
+ fields: { success: "boolean", effectiveStatus: "string" }
6296
+ },
6297
+ ownerModule: "reasoning-kernel",
6298
+ ontologyPrimitive: "graph",
6299
+ tier: "workhorse"
6300
+ };
6301
+ var VERIFY_EPISTEMIC_NODE = {
6302
+ name: "verify_epistemic_node",
6303
+ description: "Record verification state on an epistemic graph node. Like `git tag` \u2014 marks the node with a reviewed verification state.",
6304
+ parameters: {
6305
+ nodeId: { type: "string", description: "Node ID or global ID" },
6306
+ verificationStatus: { type: "string", description: "Verification status" },
6307
+ confidence: { type: "number", description: "Optional confidence update" }
6308
+ },
6309
+ required: ["nodeId", "verificationStatus"],
6310
+ response: {
6311
+ description: "Verification result",
6312
+ fields: { success: "boolean" }
6313
+ },
6314
+ ownerModule: "reasoning-kernel",
6315
+ ontologyPrimitive: "graph",
6316
+ tier: "workhorse"
6317
+ };
6318
+ var SUPERSEDE_EPISTEMIC_NODE = {
6319
+ name: "supersede_epistemic_node",
6320
+ 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.",
6321
+ parameters: {
6322
+ oldNodeId: { type: "string", description: "Node ID or global ID to supersede" },
6323
+ newGlobalId: { type: "string", description: "Optional replacement global ID" },
6324
+ newCanonicalText: { type: "string", description: "Replacement canonical text" },
6325
+ text: { type: "string", description: "Alias for newCanonicalText" },
6326
+ newContentHash: { type: "string", description: "Optional replacement content hash" },
6327
+ reason: { type: "string", description: "Reason for superseding" }
6328
+ },
6329
+ required: ["oldNodeId"],
6330
+ response: {
6331
+ description: "Supersede result",
6332
+ fields: { oldNodeId: "string", newNodeId: "string" }
6333
+ },
6334
+ ownerModule: "reasoning-kernel",
6335
+ ontologyPrimitive: "graph",
6336
+ tier: "workhorse"
6337
+ };
6338
+ var BATCH_CREATE_EPISTEMIC_NODES = {
6339
+ name: "batch_create_epistemic_nodes",
6340
+ description: "Commit multiple epistemic graph nodes. Like `git commit` with many staged files \u2014 writes a batch of canonical spine nodes.",
6341
+ parameters: {
6342
+ nodes: {
6343
+ type: "array",
6344
+ description: "Nodes to create with nodeType, canonicalText/text, and optional metadata."
6345
+ }
6346
+ },
6347
+ required: ["nodes"],
6348
+ response: {
6349
+ description: "Batch node creation result",
6350
+ fields: { created: "number", results: "array" }
6351
+ },
6352
+ ownerModule: "reasoning-kernel",
6353
+ ontologyPrimitive: "graph",
6354
+ tier: "workhorse"
6355
+ };
5343
6356
  var RECORD_JUDGMENT = {
5344
6357
  name: "record_judgment",
5345
6358
  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).",
@@ -5637,6 +6650,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5637
6650
  ontologyPrimitive: "graph",
5638
6651
  tier: "showcase"
5639
6652
  };
6653
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6654
+ name: "list_graph_intelligence_queries",
6655
+ 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.",
6656
+ parameters: {
6657
+ categoryId: {
6658
+ type: "string",
6659
+ description: "Optional category filter, such as problems or strategic"
6660
+ },
6661
+ mode: {
6662
+ type: "string",
6663
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6664
+ }
6665
+ },
6666
+ required: [],
6667
+ response: {
6668
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6669
+ fields: {
6670
+ categories: "array \u2014 query categories",
6671
+ queries: "array \u2014 query definitions with prompt templates and tools",
6672
+ quickQueries: "array \u2014 recommended one-click query presets",
6673
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6674
+ }
6675
+ },
6676
+ ownerModule: "graph-intelligence",
6677
+ ontologyPrimitive: "graph",
6678
+ tier: "showcase"
6679
+ };
6680
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6681
+ name: "run_graph_intelligence_query",
6682
+ 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.",
6683
+ parameters: {
6684
+ topicId: { type: "string", description: "Topic to analyze" },
6685
+ queryId: {
6686
+ type: "string",
6687
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6688
+ },
6689
+ prompt: {
6690
+ type: "string",
6691
+ description: "Optional custom prompt for custom analysis runs"
6692
+ },
6693
+ input: {
6694
+ type: "string",
6695
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6696
+ },
6697
+ mode: {
6698
+ type: "string",
6699
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6700
+ },
6701
+ limit: {
6702
+ type: "number",
6703
+ description: "Maximum graph context rows to return"
6704
+ }
6705
+ },
6706
+ required: ["topicId"],
6707
+ response: {
6708
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6709
+ fields: {
6710
+ query: "object \u2014 selected query definition",
6711
+ prompt: "string \u2014 resolved prompt template",
6712
+ toolPlan: "array \u2014 public tools and args the model can call next",
6713
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6714
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6715
+ }
6716
+ },
6717
+ ownerModule: "graph-intelligence",
6718
+ ontologyPrimitive: "graph",
6719
+ tier: "showcase"
6720
+ };
5640
6721
  var GET_FALSIFICATION_QUESTIONS = {
5641
6722
  name: "get_falsification_questions",
5642
6723
  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.",
@@ -6485,15 +7566,15 @@ var IDENTITY_WHOAMI = {
6485
7566
  };
6486
7567
  var COMPILE_CONTEXT = {
6487
7568
  name: "compile_context",
6488
- 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.",
7569
+ 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.",
6489
7570
  parameters: {
6490
7571
  topicId: {
6491
7572
  type: "string",
6492
- description: "Topic scope ID to compile"
7573
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
6493
7574
  },
6494
7575
  query: {
6495
7576
  type: "string",
6496
- description: "Optional focus query used to rank context items"
7577
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
6497
7578
  },
6498
7579
  budget: {
6499
7580
  type: "number",
@@ -6517,7 +7598,7 @@ var COMPILE_CONTEXT = {
6517
7598
  description: "Include related ontological entities in the compiled result"
6518
7599
  }
6519
7600
  },
6520
- required: ["topicId"],
7601
+ required: [],
6521
7602
  response: {
6522
7603
  description: "Compiled context pack for the requested topic",
6523
7604
  fields: {
@@ -6691,18 +7772,60 @@ var CREATE_TASK = {
6691
7772
  name: "create_task",
6692
7773
  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.",
6693
7774
  parameters: {
6694
- title: { type: "string", description: "Task description" },
7775
+ title: { type: "string", description: "Task title" },
6695
7776
  topicId: { type: "string", description: "Topic scope" },
7777
+ description: {
7778
+ type: "string",
7779
+ description: "Long-form task description"
7780
+ },
6696
7781
  taskType: {
6697
7782
  type: "string",
6698
- description: "Type: research, interview, analysis, data_collection",
6699
- enum: ["research", "interview", "analysis", "data_collection"]
7783
+ description: "Task taxonomy",
7784
+ enum: [
7785
+ "general",
7786
+ "find_evidence",
7787
+ "verify_claim",
7788
+ "research",
7789
+ "review",
7790
+ "interview",
7791
+ "analysis",
7792
+ "track_metrics"
7793
+ ]
7794
+ },
7795
+ priority: {
7796
+ type: "string",
7797
+ description: "Priority",
7798
+ enum: ["urgent", "high", "medium", "low"]
7799
+ },
7800
+ status: {
7801
+ type: "string",
7802
+ description: "Initial status (defaults to todo)",
7803
+ enum: ["todo", "in_progress", "blocked", "done"]
7804
+ },
7805
+ linkedWorktreeId: {
7806
+ type: "string",
7807
+ description: "Worktree this task belongs to"
7808
+ },
7809
+ linkedBeliefId: {
7810
+ type: "string",
7811
+ description: "Belief this task supports"
6700
7812
  },
6701
7813
  linkedQuestionId: {
6702
7814
  type: "string",
6703
7815
  description: "Question this task addresses"
6704
7816
  },
6705
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
7817
+ assigneeId: {
7818
+ type: "string",
7819
+ description: "Principal assigned to the task"
7820
+ },
7821
+ dueDate: {
7822
+ type: "number",
7823
+ description: "Due date as epoch milliseconds"
7824
+ },
7825
+ tags: {
7826
+ type: "array",
7827
+ description: "Free-form string tags"
7828
+ }
6706
7829
  },
6707
7830
  required: ["title"],
6708
7831
  response: {
@@ -6822,6 +7945,10 @@ var CREATE_TOPIC = {
6822
7945
  name: "create_topic",
6823
7946
  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.",
6824
7947
  parameters: {
7948
+ globalId: {
7949
+ type: "string",
7950
+ description: "Optional idempotent topic global ID"
7951
+ },
6825
7952
  name: { type: "string", description: "Topic name" },
6826
7953
  type: {
6827
7954
  type: "string",
@@ -6832,6 +7959,18 @@ var CREATE_TOPIC = {
6832
7959
  type: "string",
6833
7960
  description: "Optional parent topic for nesting"
6834
7961
  },
7962
+ parentTopicGlobalId: {
7963
+ type: "string",
7964
+ description: "Optional parent topic global ID for nesting"
7965
+ },
7966
+ tenantId: { type: "string", description: "Optional tenant scope" },
7967
+ workspaceId: { type: "string", description: "Optional workspace scope" },
7968
+ visibility: {
7969
+ type: "string",
7970
+ description: "Topic visibility",
7971
+ enum: ["private", "team", "firm", "external", "public"]
7972
+ },
7973
+ metadata: { type: "object", description: "Optional topic metadata" },
6835
7974
  createdBy: { type: "string", description: "Who created this topic" }
6836
7975
  },
6837
7976
  required: ["name", "type"],
@@ -6840,6 +7979,9 @@ var CREATE_TOPIC = {
6840
7979
  fields: {
6841
7980
  id: "string \u2014 topic ID",
6842
7981
  globalId: "string \u2014 globally unique ID",
7982
+ topicGlobalId: "string \u2014 topic global ID",
7983
+ epistemicNodeId: "string \u2014 materialized topic node ID",
7984
+ epistemicNodeGlobalId: "string \u2014 materialized topic node global ID",
6843
7985
  depth: "number \u2014 nesting depth"
6844
7986
  }
6845
7987
  },
@@ -6970,6 +8112,65 @@ var GET_TOPIC_TREE = {
6970
8112
  ontologyPrimitive: "graph",
6971
8113
  tier: "workhorse"
6972
8114
  };
8115
+ var MATERIALIZE_TOPIC_GRAPH = {
8116
+ name: "materialize_topic_graph",
8117
+ description: "Backfill the topic graph spine. Like `git fsck --connectivity-only` with repair enabled \u2014 creates missing topic nodes and parent-child edges idempotently.",
8118
+ parameters: {
8119
+ rootTopicId: {
8120
+ type: "string",
8121
+ description: "Optional root topic for a bounded materialization pass"
8122
+ },
8123
+ dryRun: {
8124
+ type: "boolean",
8125
+ description: "When true, report missing rows without writing them"
8126
+ }
8127
+ },
8128
+ required: [],
8129
+ response: {
8130
+ description: "Topic graph materialization counts",
8131
+ fields: {
8132
+ topicsSeen: "number",
8133
+ nodesCreated: "number",
8134
+ nodesExisting: "number",
8135
+ edgesCreated: "number",
8136
+ edgesExisting: "number",
8137
+ errors: "array"
8138
+ }
8139
+ },
8140
+ ownerModule: "reasoning-kernel",
8141
+ ontologyPrimitive: "graph",
8142
+ tier: "workhorse"
8143
+ };
8144
+ var GET_TOPIC_GRAPH_SPINE = {
8145
+ name: "get_topic_graph_spine",
8146
+ description: "Verify the topic graph spine. Like `git fsck` \u2014 reads topics, materialized topic nodes, parent-child edges, and missing spine rows.",
8147
+ parameters: {
8148
+ rootTopicId: {
8149
+ type: "string",
8150
+ description: "Optional root topic for a bounded verifier pass"
8151
+ },
8152
+ includeTopicBeliefEdges: {
8153
+ type: "boolean",
8154
+ description: "Include topic -> belief edges in the verifier payload"
8155
+ }
8156
+ },
8157
+ required: [],
8158
+ response: {
8159
+ description: "Topic graph spine verification payload",
8160
+ fields: {
8161
+ ok: "boolean",
8162
+ counts: "object",
8163
+ topics: "array",
8164
+ topicNodes: "array",
8165
+ parentEdges: "array",
8166
+ missingTopicNodes: "array",
8167
+ missingParentEdges: "array"
8168
+ }
8169
+ },
8170
+ ownerModule: "reasoning-kernel",
8171
+ ontologyPrimitive: "graph",
8172
+ tier: "workhorse"
8173
+ };
6973
8174
  var GET_CODE_CONTEXT = {
6974
8175
  name: "get_code_context",
6975
8176
  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.",
@@ -8102,27 +9303,90 @@ var GENERATE_SESSION_HANDOFF = {
8102
9303
  tier: "showcase",
8103
9304
  internal: true
8104
9305
  };
8105
- var MCP_TOOL_CONTRACTS = {
8106
- // Belief lifecycle (commit, amend, fork, archive)
8107
- create_belief: CREATE_BELIEF,
8108
- get_belief: GET_BELIEF,
8109
- refine_belief: REFINE_BELIEF,
8110
- modulate_confidence: MODULATE_CONFIDENCE,
8111
- fork_belief: FORK_BELIEF,
8112
- archive_belief: ARCHIVE_BELIEF,
8113
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8114
- evaluate_contract: EVALUATE_CONTRACT,
8115
- get_contract_status: GET_CONTRACT_STATUS,
8116
- // Evidence (commit)
8117
- create_evidence: CREATE_EVIDENCE,
8118
- get_evidence: GET_EVIDENCE,
8119
- list_evidence: LIST_EVIDENCE,
8120
- link_evidence: LINK_EVIDENCE,
8121
- add_evidence: ADD_EVIDENCE,
8122
- // Contradictions (merge conflict)
8123
- flag_contradiction: FLAG_CONTRADICTION,
8124
- // Lens lifecycle (workspace-scoped operational frames)
8125
- create_lens: CREATE_LENS,
9306
+ var BEGIN_BUILD_SESSION = {
9307
+ name: "begin_build_session",
9308
+ 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.",
9309
+ parameters: {
9310
+ worktreeId: {
9311
+ type: "string",
9312
+ description: "The Lucern worktree ID to bootstrap."
9313
+ },
9314
+ branch: {
9315
+ type: "string",
9316
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
9317
+ },
9318
+ branchBase: {
9319
+ type: "string",
9320
+ description: 'Base branch for the feature branch. Default: "staging".'
9321
+ },
9322
+ prBase: {
9323
+ type: "string",
9324
+ description: 'Target branch for the PR. Default: "staging".'
9325
+ },
9326
+ sessionMode: {
9327
+ type: "string",
9328
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
9329
+ enum: ["async", "interactive"]
9330
+ },
9331
+ activateIfPlanning: {
9332
+ type: "boolean",
9333
+ description: "When true, automatically activate a planning worktree during bootstrap."
9334
+ }
9335
+ },
9336
+ required: ["worktreeId"],
9337
+ response: {
9338
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
9339
+ fields: {
9340
+ topicId: "string \u2014 canonical topic scope",
9341
+ topicName: "string \u2014 human-readable topic name",
9342
+ worktreeId: "string \u2014 worktree ID",
9343
+ worktreeName: "string \u2014 human-readable worktree name",
9344
+ branch: "string \u2014 git branch name",
9345
+ branchBase: "string \u2014 base branch",
9346
+ prBase: "string \u2014 PR target branch",
9347
+ campaign: "number | null \u2014 top-level pipeline campaign",
9348
+ lane: "string \u2014 campaign lane",
9349
+ gate: "string \u2014 exit gate",
9350
+ hypothesis: "string \u2014 worktree hypothesis",
9351
+ focus: "string \u2014 session focus",
9352
+ status: "string \u2014 worktree status after optional activation",
9353
+ sessionMode: "string \u2014 async | interactive",
9354
+ targetBeliefIds: "array \u2014 scoped belief IDs",
9355
+ targetQuestionIds: "array \u2014 scoped question IDs",
9356
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
9357
+ openQuestions: "array \u2014 open scoped questions",
9358
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
9359
+ dependencies: "array \u2014 upstream worktrees",
9360
+ unblocks: "array \u2014 downstream worktrees",
9361
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
9362
+ }
9363
+ },
9364
+ ownerModule: "bootstrap",
9365
+ ontologyPrimitive: "worktree",
9366
+ tier: "showcase",
9367
+ internal: true
9368
+ };
9369
+ var MCP_TOOL_CONTRACTS = {
9370
+ // Belief lifecycle (commit, amend, fork, archive)
9371
+ create_belief: CREATE_BELIEF,
9372
+ get_belief: GET_BELIEF,
9373
+ refine_belief: REFINE_BELIEF,
9374
+ modulate_confidence: MODULATE_CONFIDENCE,
9375
+ fork_belief: FORK_BELIEF,
9376
+ archive_belief: ARCHIVE_BELIEF,
9377
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
9378
+ evaluate_contract: EVALUATE_CONTRACT,
9379
+ get_contract_status: GET_CONTRACT_STATUS,
9380
+ // Evidence (commit)
9381
+ create_evidence: CREATE_EVIDENCE,
9382
+ get_evidence: GET_EVIDENCE,
9383
+ list_evidence: LIST_EVIDENCE,
9384
+ link_evidence: LINK_EVIDENCE,
9385
+ add_evidence: ADD_EVIDENCE,
9386
+ // Contradictions (merge conflict)
9387
+ flag_contradiction: FLAG_CONTRADICTION,
9388
+ // Lens lifecycle (workspace-scoped operational frames)
9389
+ create_lens: CREATE_LENS,
8126
9390
  list_lenses: LIST_LENSES,
8127
9391
  apply_lens_to_topic: APPLY_LENS_TO_TOPIC,
8128
9392
  remove_lens_from_topic: REMOVE_LENS_FROM_TOPIC,
@@ -8144,11 +9408,26 @@ var MCP_TOOL_CONTRACTS = {
8144
9408
  bisect_confidence: BISECT_CONFIDENCE,
8145
9409
  // Edges (commit)
8146
9410
  create_edge: CREATE_EDGE,
9411
+ update_edge: UPDATE_EDGE,
9412
+ remove_edge: REMOVE_EDGE,
9413
+ remove_edges_between: REMOVE_EDGES_BETWEEN,
9414
+ batch_create_edges: BATCH_CREATE_EDGES,
9415
+ // Epistemic node spine (commit/amend/show)
9416
+ create_epistemic_node: CREATE_EPISTEMIC_NODE,
9417
+ get_epistemic_node: GET_EPISTEMIC_NODE,
9418
+ list_epistemic_nodes: LIST_EPISTEMIC_NODES,
9419
+ update_epistemic_node: UPDATE_EPISTEMIC_NODE,
9420
+ archive_epistemic_node: ARCHIVE_EPISTEMIC_NODE,
9421
+ verify_epistemic_node: VERIFY_EPISTEMIC_NODE,
9422
+ supersede_epistemic_node: SUPERSEDE_EPISTEMIC_NODE,
9423
+ batch_create_epistemic_nodes: BATCH_CREATE_EPISTEMIC_NODES,
8147
9424
  // Judgments (tag)
8148
9425
  record_judgment: RECORD_JUDGMENT,
8149
9426
  // Graph intelligence (showcase)
8150
9427
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8151
9428
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9429
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9430
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8152
9431
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8153
9432
  // Evidence operations (workhorse)
8154
9433
  search_evidence: SEARCH_EVIDENCE,
@@ -8195,6 +9474,7 @@ var MCP_TOOL_CONTRACTS = {
8195
9474
  get_agent_inbox: GET_AGENT_INBOX,
8196
9475
  claim_files: CLAIM_FILES,
8197
9476
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9477
+ begin_build_session: BEGIN_BUILD_SESSION,
8198
9478
  // Policy / ACL (workhorse)
8199
9479
  check_permission: CHECK_PERMISSION,
8200
9480
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8214,6 +9494,8 @@ var MCP_TOOL_CONTRACTS = {
8214
9494
  get_topic: GET_TOPIC,
8215
9495
  update_topic: UPDATE_TOPIC,
8216
9496
  get_topic_tree: GET_TOPIC_TREE,
9497
+ materialize_topic_graph: MATERIALIZE_TOPIC_GRAPH,
9498
+ get_topic_graph_spine: GET_TOPIC_GRAPH_SPINE,
8217
9499
  // Coding intelligence (code-grounded knowledge)
8218
9500
  get_code_context: GET_CODE_CONTEXT,
8219
9501
  get_change_history: GET_CHANGE_HISTORY,
@@ -8318,18 +9600,34 @@ var MCP_CORE_OPERATION_NAMES = [
8318
9600
  "find_missing_questions",
8319
9601
  "get_high_priority_questions",
8320
9602
  "get_falsification_questions",
9603
+ "create_epistemic_node",
9604
+ "get_epistemic_node",
9605
+ "list_epistemic_nodes",
9606
+ "update_epistemic_node",
9607
+ "archive_epistemic_node",
9608
+ "verify_epistemic_node",
9609
+ "supersede_epistemic_node",
9610
+ "batch_create_epistemic_nodes",
8321
9611
  "create_topic",
8322
9612
  "get_topic",
8323
9613
  "list_topics",
8324
9614
  "update_topic",
8325
- "get_topic_tree"
9615
+ "get_topic_tree",
9616
+ "materialize_topic_graph",
9617
+ "get_topic_graph_spine"
8326
9618
  ];
8327
9619
  var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8328
9620
  "create_edge",
9621
+ "update_edge",
9622
+ "remove_edge",
9623
+ "remove_edges_between",
9624
+ "batch_create_edges",
8329
9625
  "query_lineage",
8330
9626
  "traverse_graph",
8331
9627
  "get_graph_neighborhood",
8332
9628
  "get_graph_structure_analysis",
9629
+ "list_graph_intelligence_queries",
9630
+ "run_graph_intelligence_query",
8333
9631
  "find_contradictions",
8334
9632
  "flag_contradiction",
8335
9633
  "detect_confirmation_bias",
@@ -8408,6 +9706,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8408
9706
  "get_change_history",
8409
9707
  "get_failure_log",
8410
9708
  "record_attempt",
9709
+ "begin_build_session",
8411
9710
  "push",
8412
9711
  "open_pull_request",
8413
9712
  "record_judgment",
@@ -8462,7 +9761,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8462
9761
  "find_semantic_orphans"
8463
9762
  ];
8464
9763
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8465
- "begin_build_session",
8466
9764
  "evaluate_engineering_contract",
8467
9765
  "evaluate_research_contract"
8468
9766
  ];
@@ -8717,9 +10015,7 @@ function mcpContractFromArgsSchema(base, args, contractName) {
8717
10015
  required: converted.filter(([, field]) => field.required).map(([fieldName]) => fieldName)
8718
10016
  };
8719
10017
  }
8720
- function defineFunctionContract(contract) {
8721
- return contract;
8722
- }
10018
+ var defineFunctionContract = (contract) => contract;
8723
10019
  function authUserId(context) {
8724
10020
  return context.userId ?? context.principalId ?? "lucern-agent";
8725
10021
  }
@@ -8848,8 +10144,34 @@ function assertSurfaceCoverage(contracts) {
8848
10144
  }
8849
10145
  }
8850
10146
  }
8851
-
8852
- // ../contracts/src/function-registry/context.ts
10147
+ var jsonRecordSchema2 = z.record(z.unknown());
10148
+ var observationArgs = z.object({
10149
+ topicId: z.string().optional().describe("Topic scope for the observation."),
10150
+ summary: z.string().describe("Short observation summary."),
10151
+ text: z.string().optional().describe("Canonical observation text alias."),
10152
+ title: z.string().optional().describe("Optional observation title."),
10153
+ content: z.string().optional().describe("Optional rich observation content."),
10154
+ contentType: z.string().optional().describe("Observation content type."),
10155
+ kind: z.string().optional().describe("Evidence kind to store."),
10156
+ observationType: z.string().optional().describe("Observation type."),
10157
+ tags: z.array(z.string()).optional().describe("Observation tags."),
10158
+ source: z.string().optional().describe("Observation source label."),
10159
+ sourceType: z.string().optional().describe("Evidence source type."),
10160
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
10161
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10162
+ confidence: z.number().optional().describe("Observation confidence."),
10163
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
10164
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
10165
+ });
10166
+ var observationContextArgs = z.object({
10167
+ topicId: z.string().describe("Topic scope."),
10168
+ query: z.string().optional().describe("Optional context query."),
10169
+ limit: z.number().optional().describe("Maximum observations to return."),
10170
+ status: z.string().optional().describe("Observation status filter.")
10171
+ });
10172
+ function isRecord2(value) {
10173
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10174
+ }
8853
10175
  var observationInput = (input, context) => withUserId(
8854
10176
  compactRecord4({
8855
10177
  projectId: input.projectId,
@@ -8882,7 +10204,7 @@ var contextContracts = [
8882
10204
  path: "/context/compile",
8883
10205
  sdkNamespace: "context",
8884
10206
  sdkMethod: "compileContext",
8885
- summary: "Compile a focused reasoning context for a topic.",
10207
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
8886
10208
  convex: {
8887
10209
  module: "contextCompiler",
8888
10210
  functionName: "compile",
@@ -8904,11 +10226,12 @@ var contextContracts = [
8904
10226
  kind: "mutation",
8905
10227
  inputProjection: observationInput,
8906
10228
  outputProjection: (output, input) => ({
8907
- ...output && typeof output === "object" ? output : {},
8908
- observationId: output && typeof output === "object" ? output.nodeId : void 0,
10229
+ ...isRecord2(output) ? output : {},
10230
+ observationId: isRecord2(output) ? output.nodeId : void 0,
8909
10231
  observationType: input.observationType
8910
10232
  })
8911
- }
10233
+ },
10234
+ args: observationArgs
8912
10235
  }),
8913
10236
  surfaceContract({
8914
10237
  name: "get_observation_context",
@@ -8929,7 +10252,8 @@ var contextContracts = [
8929
10252
  status: input.status,
8930
10253
  userId: input.userId
8931
10254
  })
8932
- }
10255
+ },
10256
+ args: observationContextArgs
8933
10257
  })
8934
10258
  ];
8935
10259
 
@@ -8992,8 +10316,45 @@ var identityContracts = [
8992
10316
  }
8993
10317
  })
8994
10318
  ];
8995
-
8996
- // ../contracts/src/function-registry/beliefs.ts
10319
+ var jsonRecordSchema3 = z.record(z.unknown());
10320
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
10321
+ var reversibilitySchema = z.enum([
10322
+ "irreversible",
10323
+ "hard_to_reverse",
10324
+ "reversible",
10325
+ "trivial"
10326
+ ]);
10327
+ var predictionMetaSchema = z.object({
10328
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
10329
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
10330
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
10331
+ });
10332
+ var createBeliefArgs = z.object({
10333
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
10334
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
10335
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
10336
+ beliefType: z.string().optional().describe("Schema belief type."),
10337
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
10338
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
10339
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
10340
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
10341
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
10342
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
10343
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
10344
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
10345
+ });
10346
+ var forkBeliefArgs = z.object({
10347
+ nodeId: z.string().describe("The scored belief to fork from."),
10348
+ newFormulation: z.string().describe("The evolved belief statement."),
10349
+ forkReason: z.enum([
10350
+ "refinement",
10351
+ "contradiction_response",
10352
+ "scope_change",
10353
+ "confidence_collapse",
10354
+ "manual"
10355
+ ]).describe("Why this fork was created."),
10356
+ rationale: z.string().optional().describe("Why the fork is warranted.")
10357
+ });
8997
10358
  var beliefLookupInput = (input) => compactRecord4({
8998
10359
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
8999
10360
  beliefId: input.beliefId
@@ -9068,7 +10429,8 @@ var beliefsContracts = [
9068
10429
  functionName: "create",
9069
10430
  kind: "mutation",
9070
10431
  inputProjection: createBeliefInput
9071
- }
10432
+ },
10433
+ args: createBeliefArgs
9072
10434
  }),
9073
10435
  surfaceContract({
9074
10436
  name: "get_belief",
@@ -9159,7 +10521,8 @@ var beliefsContracts = [
9159
10521
  functionName: "forkBelief",
9160
10522
  kind: "mutation",
9161
10523
  inputProjection: forkBeliefInput
9162
- }
10524
+ },
10525
+ args: forkBeliefArgs
9163
10526
  }),
9164
10527
  surfaceContract({
9165
10528
  name: "archive_belief",
@@ -9240,8 +10603,46 @@ var beliefsContracts = [
9240
10603
  }
9241
10604
  })
9242
10605
  ];
9243
-
9244
- // ../contracts/src/function-registry/evidence.ts
10606
+ var jsonRecordSchema4 = z.record(z.unknown());
10607
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10608
+ var createEvidenceArgs = z.object({
10609
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10610
+ text: z.string().describe("Canonical evidence text."),
10611
+ source: z.string().optional().describe("Source URL or source label."),
10612
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10613
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10614
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10615
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10616
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10617
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10618
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10619
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10620
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10621
+ title: z.string().optional().describe("Optional short title."),
10622
+ content: z.string().optional().describe("Optional long-form content."),
10623
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10624
+ kind: z.string().optional().describe("Evidence kind."),
10625
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10626
+ sourceType: z.string().optional().describe("Evidence source type."),
10627
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10628
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10629
+ methodology: z.string().optional().describe("Collection methodology."),
10630
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10631
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10632
+ });
10633
+ var addEvidenceArgs = z.object({
10634
+ canonicalText: z.string().describe("The evidence statement."),
10635
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10636
+ topicId: z.string().optional().describe("Topic scope hint."),
10637
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10638
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10639
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10640
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10641
+ title: z.string().optional().describe("Optional short title."),
10642
+ content: z.string().optional().describe("Optional long-form evidence content."),
10643
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10644
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10645
+ });
9245
10646
  var evidenceIdInput = (input) => compactRecord4({
9246
10647
  evidenceId: input.evidenceId,
9247
10648
  insightId: input.insightId,
@@ -9269,12 +10670,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
9269
10670
  compactRecord4({
9270
10671
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9271
10672
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
9272
- edgeType: "evidence_supports_belief",
10673
+ edgeType: "informs",
9273
10674
  globalId: input.globalId ?? `edge:${String(
9274
10675
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9275
10676
  )}:${String(
9276
10677
  input.beliefNodeId ?? input.beliefId ?? input.targetId
9277
- )}:evidence_supports_belief`,
10678
+ )}:informs`,
9278
10679
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
9279
10680
  context: input.rationale ?? input.context,
9280
10681
  skipLayerValidation: true,
@@ -9287,12 +10688,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
9287
10688
  compactRecord4({
9288
10689
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9289
10690
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
9290
- edgeType: "evidence_supports_question",
10691
+ edgeType: "responds_to",
9291
10692
  globalId: input.globalId ?? `edge:${String(
9292
10693
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9293
10694
  )}:${String(
9294
10695
  input.questionId ?? input.questionNodeId ?? input.targetId
9295
- )}:evidence_supports_question`,
10696
+ )}:responds_to`,
9296
10697
  weight: input.impactScore ?? input.weight,
9297
10698
  context: input.rationale ?? input.context,
9298
10699
  skipLayerValidation: true,
@@ -9316,7 +10717,8 @@ var evidenceContracts = [
9316
10717
  functionName: "create",
9317
10718
  kind: "mutation",
9318
10719
  inputProjection: createEvidenceInput
9319
- }
10720
+ },
10721
+ args: createEvidenceArgs
9320
10722
  }),
9321
10723
  surfaceContract({
9322
10724
  name: "add_evidence",
@@ -9352,7 +10754,8 @@ var evidenceContracts = [
9352
10754
  context
9353
10755
  );
9354
10756
  }
9355
- }
10757
+ },
10758
+ args: addEvidenceArgs
9356
10759
  }),
9357
10760
  surfaceContract({
9358
10761
  name: "get_evidence",
@@ -9459,8 +10862,91 @@ var evidenceContracts = [
9459
10862
  }
9460
10863
  })
9461
10864
  ];
9462
-
9463
- // ../contracts/src/function-registry/questions.ts
10865
+ var jsonRecordSchema5 = z.record(z.unknown());
10866
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
10867
+ var kernelQuestionPrioritySchema = z.enum([
10868
+ "critical",
10869
+ "high",
10870
+ "medium",
10871
+ "low"
10872
+ ]);
10873
+ var questionTypeSchema = z.enum([
10874
+ "validation",
10875
+ "falsification",
10876
+ "assumption_probe",
10877
+ "prediction_test",
10878
+ "counterfactual",
10879
+ "discovery",
10880
+ "clarification",
10881
+ "comparison",
10882
+ "causal",
10883
+ "mechanism",
10884
+ "general"
10885
+ ]);
10886
+ var createQuestionArgs = z.object({
10887
+ text: z.string().describe("The question text."),
10888
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10889
+ topicId: z.string().optional().describe("Topic scope hint."),
10890
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
10891
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
10892
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
10893
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
10894
+ category: z.string().optional().describe("Question category."),
10895
+ source: z.string().optional().describe("Question source."),
10896
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
10897
+ importance: z.number().optional().describe("Numeric importance score."),
10898
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
10899
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
10900
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
10901
+ questionType: questionTypeSchema.optional().describe("Question type."),
10902
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
10903
+ });
10904
+ var refineQuestionArgs = z.object({
10905
+ id: z.string().describe("The question to refine."),
10906
+ text: z.string().describe("Updated question text."),
10907
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10908
+ rationale: z.string().optional().describe("Why the question is refined."),
10909
+ category: z.string().optional().describe("Updated question category."),
10910
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
10911
+ });
10912
+ var createAnswerArgs = z.object({
10913
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
10914
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10915
+ answerText: z.string().describe("The answer content."),
10916
+ topicId: z.string().optional().describe("Topic scope for the answer."),
10917
+ confidence: z.string().optional().describe("Answer confidence."),
10918
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
10919
+ answerSource: z.string().optional().describe("How the answer was produced."),
10920
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10921
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10922
+ });
10923
+ var answerQuestionArgs = z.object({
10924
+ id: z.string().describe("Canonical question ID."),
10925
+ topicId: z.string().describe("Topic scope for the answer."),
10926
+ text: z.string().describe("Answer text."),
10927
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
10928
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
10929
+ rationale: z.string().optional().describe("Why this answer is credible."),
10930
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10931
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
10932
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
10933
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
10934
+ answerSource: z.string().optional().describe("How the answer was produced."),
10935
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10936
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10937
+ });
10938
+ var missingQuestionsArgs = z.object({
10939
+ topicId: z.string().describe("Topic scope."),
10940
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
10941
+ status: z.string().optional().describe("Question status filter."),
10942
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10943
+ });
10944
+ var falsificationQuestionsArgs = z.object({
10945
+ topicId: z.string().describe("Topic scope."),
10946
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
10947
+ status: z.string().optional().describe("Question status filter."),
10948
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10949
+ });
9464
10950
  var questionNodeInput = (input) => compactRecord4({
9465
10951
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9466
10952
  questionId: input.questionId
@@ -9507,7 +10993,8 @@ var questionsContracts = [
9507
10993
  functionName: "create",
9508
10994
  kind: "mutation",
9509
10995
  inputProjection: createQuestionInput
9510
- }
10996
+ },
10997
+ args: createQuestionArgs
9511
10998
  }),
9512
10999
  surfaceContract({
9513
11000
  name: "get_question",
@@ -9563,7 +11050,8 @@ var questionsContracts = [
9563
11050
  category: input.category,
9564
11051
  priority: input.priority
9565
11052
  })
9566
- }
11053
+ },
11054
+ args: refineQuestionArgs
9567
11055
  }),
9568
11056
  surfaceContract({
9569
11057
  name: "update_question_status",
@@ -9639,7 +11127,8 @@ var questionsContracts = [
9639
11127
  }),
9640
11128
  context
9641
11129
  )
9642
- }
11130
+ },
11131
+ args: createAnswerArgs
9643
11132
  }),
9644
11133
  surfaceContract({
9645
11134
  name: "answer_question",
@@ -9668,7 +11157,8 @@ var questionsContracts = [
9668
11157
  }),
9669
11158
  context
9670
11159
  )
9671
- }
11160
+ },
11161
+ args: answerQuestionArgs
9672
11162
  }),
9673
11163
  surfaceContract({
9674
11164
  name: "get_answer",
@@ -9700,7 +11190,8 @@ var questionsContracts = [
9700
11190
  functionName: "getByTopic",
9701
11191
  kind: "query",
9702
11192
  inputProjection: questionTopicInput
9703
- }
11193
+ },
11194
+ args: missingQuestionsArgs
9704
11195
  }),
9705
11196
  surfaceContract({
9706
11197
  name: "get_high_priority_questions",
@@ -9735,11 +11226,54 @@ var questionsContracts = [
9735
11226
  functionName: "getByTopic",
9736
11227
  kind: "query",
9737
11228
  inputProjection: questionTopicInput
9738
- }
11229
+ },
11230
+ args: falsificationQuestionsArgs
9739
11231
  })
9740
11232
  ];
9741
-
9742
- // ../contracts/src/function-registry/topics.ts
11233
+ var topicVisibilitySchema = z.enum([
11234
+ "private",
11235
+ "team",
11236
+ "firm",
11237
+ "external",
11238
+ "public"
11239
+ ]);
11240
+ var topicStatusSchema = z.enum(["active", "archived", "watching"]);
11241
+ var createTopicArgs = z.object({
11242
+ globalId: z.string().optional().describe("Optional idempotent topic global ID."),
11243
+ name: z.string().describe("Topic name."),
11244
+ description: z.string().optional().describe("Topic description."),
11245
+ type: z.string().describe("Topic type."),
11246
+ parentTopicId: z.string().optional().describe("Optional parent topic ID."),
11247
+ parentTopicGlobalId: z.string().optional().describe("Optional parent topic global ID."),
11248
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11249
+ tenantId: z.string().optional().describe("Optional tenant scope."),
11250
+ workspaceId: z.string().optional().describe("Optional workspace scope."),
11251
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11252
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata."),
11253
+ graphScopeProjectId: z.string().optional(),
11254
+ createdBy: z.string().optional()
11255
+ });
11256
+ var updateTopicArgs = z.object({
11257
+ id: z.string().describe("Topic ID."),
11258
+ topicId: z.string().optional().describe("Topic ID alias."),
11259
+ name: z.string().optional().describe("Topic name."),
11260
+ description: z.string().optional().describe("Topic description."),
11261
+ type: z.string().optional().describe("Topic type."),
11262
+ status: topicStatusSchema.optional().describe("Topic status."),
11263
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11264
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11265
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
11266
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
11267
+ });
11268
+ var materializeTopicGraphArgs = z.object({
11269
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11270
+ dryRun: z.boolean().optional().describe("Report missing rows without writing."),
11271
+ createdBy: z.string().optional()
11272
+ });
11273
+ var getTopicGraphSpineArgs = z.object({
11274
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11275
+ includeTopicBeliefEdges: z.boolean().optional()
11276
+ });
9743
11277
  var topicIdInput = (input) => compactRecord4({
9744
11278
  id: input.id ?? input.topicId
9745
11279
  });
@@ -9770,7 +11304,8 @@ var topicsContracts = [
9770
11304
  functionName: "create",
9771
11305
  kind: "mutation",
9772
11306
  inputProjection: withCreatedBy
9773
- }
11307
+ },
11308
+ args: createTopicArgs
9774
11309
  }),
9775
11310
  surfaceContract({
9776
11311
  name: "get_topic",
@@ -9820,7 +11355,8 @@ var topicsContracts = [
9820
11355
  functionName: "update",
9821
11356
  kind: "mutation",
9822
11357
  inputProjection: updateTopicInput
9823
- }
11358
+ },
11359
+ args: updateTopicArgs
9824
11360
  }),
9825
11361
  surfaceContract({
9826
11362
  name: "get_topic_tree",
@@ -9837,92 +11373,512 @@ var topicsContracts = [
9837
11373
  functionName: "getTree",
9838
11374
  kind: "query"
9839
11375
  }
11376
+ }),
11377
+ surfaceContract({
11378
+ name: "materialize_topic_graph",
11379
+ kind: "mutation",
11380
+ domain: "topics",
11381
+ surfaceClass: "platform_public",
11382
+ path: "/topics/materialize-graph",
11383
+ sdkNamespace: "topics",
11384
+ sdkMethod: "materializeTopicGraph",
11385
+ summary: "Materialize topic nodes and parent-child graph edges.",
11386
+ convex: {
11387
+ module: "topics",
11388
+ functionName: "materializeTopicGraph",
11389
+ kind: "mutation",
11390
+ inputProjection: withCreatedBy
11391
+ },
11392
+ args: materializeTopicGraphArgs
11393
+ }),
11394
+ surfaceContract({
11395
+ name: "get_topic_graph_spine",
11396
+ kind: "query",
11397
+ domain: "topics",
11398
+ surfaceClass: "platform_public",
11399
+ method: "GET",
11400
+ path: "/topics/graph-spine",
11401
+ sdkNamespace: "topics",
11402
+ sdkMethod: "getTopicGraphSpine",
11403
+ summary: "Verify topic nodes and parent-child graph edges.",
11404
+ convex: {
11405
+ module: "topics",
11406
+ functionName: "getTopicGraphSpine",
11407
+ kind: "query"
11408
+ },
11409
+ args: getTopicGraphSpineArgs
9840
11410
  })
9841
11411
  ];
9842
-
9843
- // ../contracts/src/function-registry/lenses.ts
9844
- var createLensInput = (input, context) => compactRecord4({
9845
- name: input.name,
9846
- description: input.description,
9847
- workspaceId: input.workspaceId,
9848
- topicId: input.topicId,
9849
- perspectiveType: input.perspectiveType,
9850
- promptTemplates: input.promptTemplates,
9851
- workflowTemplates: input.workflowTemplates,
9852
- taskTemplates: input.taskTemplates,
9853
- questionTemplates: input.questionTemplates,
9854
- filterCriteria: input.filterCriteria,
9855
- metadata: input.metadata,
9856
- createdBy: authUserId(context)
11412
+ var sourceTypeSchema2 = z.enum([
11413
+ "human",
11414
+ "ai_extracted",
11415
+ "ai_generated",
11416
+ "imported",
11417
+ "system",
11418
+ "verified",
11419
+ "proprietary"
11420
+ ]);
11421
+ var verificationStatusSchema = z.enum([
11422
+ "unverified",
11423
+ "human_verified",
11424
+ "ai_verified",
11425
+ "contradicted",
11426
+ "outdated"
11427
+ ]);
11428
+ var nodeStatusSchema = z.enum([
11429
+ "active",
11430
+ "superseded",
11431
+ "archived",
11432
+ "deleted"
11433
+ ]);
11434
+ var externalIdsArgs = z.object({
11435
+ crunchbase: z.string().optional(),
11436
+ linkedin: z.string().optional(),
11437
+ pitchbook: z.string().optional(),
11438
+ twitter: z.string().optional(),
11439
+ website: z.string().optional()
11440
+ }).optional();
11441
+ var createEpistemicNodeItemArgs = z.object({
11442
+ globalId: z.string().optional().describe("Optional idempotent node global ID."),
11443
+ nodeType: NODE_TYPE.describe("Public epistemic node type."),
11444
+ subtype: z.string().optional(),
11445
+ canonicalText: z.string().optional().describe("Canonical node text."),
11446
+ text: z.string().optional().describe("Alias for canonicalText."),
11447
+ contentHash: z.string().optional().describe("Optional idempotency content hash."),
11448
+ content: z.string().optional(),
11449
+ contentType: z.string().optional(),
11450
+ title: z.string().optional(),
11451
+ tags: z.array(z.string()).optional(),
11452
+ domain: z.string().optional(),
11453
+ metadata: z.record(z.unknown()).optional(),
11454
+ externalIds: externalIdsArgs,
11455
+ sourceType: sourceTypeSchema2.optional(),
11456
+ aiProvider: z.string().optional(),
11457
+ extractedFromNodeId: z.string().optional(),
11458
+ confidence: z.number().optional(),
11459
+ verificationStatus: verificationStatusSchema.optional(),
11460
+ topicId: z.string().optional(),
11461
+ projectId: z.string().optional(),
11462
+ createdBy: z.string().optional(),
11463
+ trustedBypassAccessCheck: z.boolean().optional()
9857
11464
  });
9858
- var lensListInput = (input, context) => compactRecord4({
9859
- actorId: input.actorId ?? authUserId(context),
9860
- workspaceId: input.workspaceId,
11465
+ var createEpistemicNodeArgs = createEpistemicNodeItemArgs;
11466
+ var batchCreateEpistemicNodesArgs = z.object({
11467
+ nodes: z.array(createEpistemicNodeItemArgs)
11468
+ });
11469
+ var getEpistemicNodeArgs = z.object({
11470
+ nodeId: z.string().describe("Node ID or global ID."),
11471
+ globalId: z.string().optional().describe("Node global ID alias.")
11472
+ });
11473
+ var listEpistemicNodesArgs = z.object({
11474
+ topicId: z.string().optional(),
11475
+ projectId: z.string().optional(),
11476
+ nodeType: NODE_TYPE.optional(),
11477
+ status: nodeStatusSchema.optional(),
11478
+ searchQuery: z.string().optional(),
11479
+ query: z.string().optional(),
11480
+ limit: z.number().optional()
11481
+ });
11482
+ var updateEpistemicNodeArgs = z.object({
11483
+ nodeId: z.string().describe("Node ID or global ID."),
11484
+ id: z.string().optional().describe("Node ID alias."),
11485
+ subtype: z.string().optional(),
11486
+ canonicalText: z.string().optional(),
11487
+ text: z.string().optional(),
11488
+ contentHash: z.string().optional(),
11489
+ content: z.string().optional(),
11490
+ contentType: z.string().optional(),
11491
+ title: z.string().optional(),
11492
+ tags: z.array(z.string()).optional(),
11493
+ domain: z.string().optional(),
11494
+ metadata: z.record(z.unknown()).optional(),
11495
+ externalIds: externalIdsArgs,
11496
+ confidence: z.number().optional(),
11497
+ verificationStatus: verificationStatusSchema.optional(),
11498
+ status: nodeStatusSchema.optional(),
11499
+ userId: z.string().optional(),
11500
+ trustedBypassAccessCheck: z.boolean().optional()
11501
+ });
11502
+ var archiveEpistemicNodeArgs = z.object({
11503
+ nodeId: z.string().describe("Node ID or global ID."),
11504
+ id: z.string().optional().describe("Node ID alias."),
11505
+ userId: z.string().optional(),
11506
+ trustedBypassAccessCheck: z.boolean().optional()
11507
+ });
11508
+ var verifyEpistemicNodeArgs = z.object({
11509
+ nodeId: z.string().describe("Node ID or global ID."),
11510
+ id: z.string().optional().describe("Node ID alias."),
11511
+ verificationStatus: verificationStatusSchema,
11512
+ confidence: z.number().optional(),
11513
+ userId: z.string().optional()
11514
+ });
11515
+ var supersedeEpistemicNodeArgs = z.object({
11516
+ oldNodeId: z.string().describe("Node ID or global ID to supersede."),
11517
+ nodeId: z.string().optional().describe("Old node ID alias."),
11518
+ newGlobalId: z.string().optional(),
11519
+ newCanonicalText: z.string().optional(),
11520
+ text: z.string().optional(),
11521
+ canonicalText: z.string().optional(),
11522
+ newContentHash: z.string().optional(),
11523
+ reason: z.string().optional(),
11524
+ createdBy: z.string().optional(),
11525
+ trustedBypassAccessCheck: z.boolean().optional()
11526
+ });
11527
+ function generatedGlobalId(prefix) {
11528
+ return `${prefix}:${crypto.randomUUID()}`;
11529
+ }
11530
+ function resolveCanonicalText(input) {
11531
+ const text = input.canonicalText ?? input.text ?? input.title ?? input.content;
11532
+ if (typeof text !== "string" || text.trim().length === 0) {
11533
+ throw new Error("canonicalText or text is required.");
11534
+ }
11535
+ return text;
11536
+ }
11537
+ function createNodeInput(input, context) {
11538
+ const canonicalText = resolveCanonicalText(input);
11539
+ const nodeType = String(input.nodeType);
11540
+ return withCreatedBy(
11541
+ compactRecord4({
11542
+ globalId: typeof input.globalId === "string" && input.globalId.trim() ? input.globalId : generatedGlobalId(nodeType),
11543
+ nodeType,
11544
+ subtype: input.subtype,
11545
+ canonicalText,
11546
+ contentHash: typeof input.contentHash === "string" && input.contentHash.trim() ? input.contentHash : `${nodeType}:${canonicalText}`,
11547
+ content: input.content,
11548
+ contentType: input.contentType,
11549
+ title: input.title,
11550
+ tags: input.tags,
11551
+ domain: input.domain,
11552
+ metadata: input.metadata,
11553
+ externalIds: input.externalIds,
11554
+ sourceType: typeof input.sourceType === "string" && input.sourceType.trim() ? input.sourceType : "human",
11555
+ aiProvider: input.aiProvider,
11556
+ extractedFromNodeId: input.extractedFromNodeId,
11557
+ confidence: input.confidence,
11558
+ verificationStatus: input.verificationStatus,
11559
+ topicId: input.topicId,
11560
+ projectId: input.projectId
11561
+ }),
11562
+ context
11563
+ );
11564
+ }
11565
+ var getNodeInput = (input) => compactRecord4({
11566
+ nodeId: input.nodeId ?? input.globalId
11567
+ });
11568
+ var listNodesInput = (input) => compactRecord4({
9861
11569
  topicId: input.topicId,
11570
+ projectId: input.projectId,
11571
+ nodeType: input.nodeType,
9862
11572
  status: input.status,
9863
- perspectiveType: input.perspectiveType
11573
+ searchQuery: input.searchQuery ?? input.query,
11574
+ limit: input.limit
9864
11575
  });
9865
- var lensesContracts = [
11576
+ var updateNodeInput = (input, context) => withUserId(
11577
+ compactRecord4({
11578
+ nodeId: input.nodeId ?? input.id,
11579
+ subtype: input.subtype,
11580
+ canonicalText: input.canonicalText ?? input.text,
11581
+ contentHash: input.contentHash,
11582
+ content: input.content,
11583
+ contentType: input.contentType,
11584
+ title: input.title,
11585
+ tags: input.tags,
11586
+ domain: input.domain,
11587
+ metadata: input.metadata,
11588
+ externalIds: input.externalIds,
11589
+ confidence: input.confidence,
11590
+ verificationStatus: input.verificationStatus,
11591
+ status: input.status,
11592
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11593
+ }),
11594
+ context
11595
+ );
11596
+ var archiveNodeInput = (input, context) => withUserId(
11597
+ compactRecord4({
11598
+ nodeId: input.nodeId ?? input.id,
11599
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11600
+ }),
11601
+ context
11602
+ );
11603
+ var verifyNodeInput = (input, context) => withUserId(
11604
+ compactRecord4({
11605
+ nodeId: input.nodeId ?? input.id,
11606
+ verificationStatus: input.verificationStatus,
11607
+ confidence: input.confidence
11608
+ }),
11609
+ context
11610
+ );
11611
+ var supersedeNodeInput = (input, context) => {
11612
+ const newCanonicalText = input.newCanonicalText ?? input.canonicalText ?? input.text;
11613
+ if (typeof newCanonicalText !== "string" || newCanonicalText.trim().length === 0) {
11614
+ throw new Error("newCanonicalText or text is required.");
11615
+ }
11616
+ return {
11617
+ oldNodeId: input.oldNodeId ?? input.nodeId,
11618
+ newGlobalId: typeof input.newGlobalId === "string" && input.newGlobalId.trim() ? input.newGlobalId : generatedGlobalId("node"),
11619
+ newCanonicalText,
11620
+ newContentHash: typeof input.newContentHash === "string" && input.newContentHash.trim() ? input.newContentHash : `superseded:${newCanonicalText}`,
11621
+ createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context),
11622
+ reason: input.reason,
11623
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11624
+ };
11625
+ };
11626
+ var batchCreateNodesInput = (input, context) => {
11627
+ const nodes = Array.isArray(input.nodes) ? input.nodes : [];
11628
+ return {
11629
+ nodes: nodes.map(
11630
+ (node) => createNodeInput(
11631
+ node && typeof node === "object" ? node : {},
11632
+ context
11633
+ )
11634
+ )
11635
+ };
11636
+ };
11637
+ var nodesContracts = [
9866
11638
  surfaceContract({
9867
- name: "create_lens",
11639
+ name: "create_epistemic_node",
9868
11640
  kind: "mutation",
9869
- domain: "lenses",
11641
+ domain: "nodes",
9870
11642
  surfaceClass: "platform_public",
9871
- path: "/lenses",
9872
- sdkNamespace: "lenses",
9873
- sdkMethod: "createLens",
9874
- summary: "Create a lens.",
11643
+ path: "/nodes",
11644
+ sdkNamespace: "nodes",
11645
+ sdkMethod: "createEpistemicNode",
11646
+ summary: "Create a generic epistemic graph node.",
9875
11647
  convex: {
9876
- module: "lenses",
11648
+ module: "nodes",
9877
11649
  functionName: "create",
9878
11650
  kind: "mutation",
9879
- inputProjection: createLensInput
9880
- }
11651
+ inputProjection: createNodeInput
11652
+ },
11653
+ args: createEpistemicNodeArgs
9881
11654
  }),
9882
11655
  surfaceContract({
9883
- name: "list_lenses",
11656
+ name: "get_epistemic_node",
9884
11657
  kind: "query",
9885
- domain: "lenses",
11658
+ domain: "nodes",
9886
11659
  surfaceClass: "platform_public",
9887
11660
  method: "GET",
9888
- path: "/lenses",
9889
- sdkNamespace: "lenses",
9890
- sdkMethod: "listLenses",
9891
- summary: "List lenses.",
11661
+ path: "/nodes/get",
11662
+ sdkNamespace: "nodes",
11663
+ sdkMethod: "getEpistemicNode",
11664
+ summary: "Get a generic epistemic graph node.",
9892
11665
  convex: {
9893
- module: "lenses",
9894
- functionName: "list",
11666
+ module: "nodes",
11667
+ functionName: "get",
9895
11668
  kind: "query",
9896
- inputProjection: lensListInput
9897
- }
11669
+ inputProjection: getNodeInput
11670
+ },
11671
+ args: getEpistemicNodeArgs
9898
11672
  }),
9899
11673
  surfaceContract({
9900
- name: "apply_lens_to_topic",
9901
- kind: "mutation",
9902
- domain: "lenses",
11674
+ name: "list_epistemic_nodes",
11675
+ kind: "query",
11676
+ domain: "nodes",
9903
11677
  surfaceClass: "platform_public",
9904
- path: "/lenses/apply",
9905
- sdkNamespace: "lenses",
9906
- sdkMethod: "applyLensToTopic",
9907
- summary: "Apply a lens to a topic.",
11678
+ method: "GET",
11679
+ path: "/nodes",
11680
+ sdkNamespace: "nodes",
11681
+ sdkMethod: "listEpistemicNodes",
11682
+ summary: "List generic epistemic graph nodes.",
9908
11683
  convex: {
9909
- module: "lenses",
9910
- functionName: "applyToTopic",
9911
- kind: "mutation",
9912
- inputProjection: (input, context) => compactRecord4({
9913
- lensId: input.lensId,
9914
- topicId: input.topicId,
9915
- metadata: input.metadata,
9916
- appliedBy: authUserId(context)
9917
- })
9918
- }
11684
+ module: "nodes",
11685
+ functionName: "list",
11686
+ kind: "query",
11687
+ inputProjection: listNodesInput
11688
+ },
11689
+ args: listEpistemicNodesArgs
9919
11690
  }),
9920
11691
  surfaceContract({
9921
- name: "remove_lens_from_topic",
11692
+ name: "update_epistemic_node",
9922
11693
  kind: "mutation",
9923
- domain: "lenses",
11694
+ domain: "nodes",
11695
+ surfaceClass: "platform_public",
11696
+ method: "PATCH",
11697
+ path: "/nodes",
11698
+ sdkNamespace: "nodes",
11699
+ sdkMethod: "updateEpistemicNode",
11700
+ summary: "Update a generic epistemic graph node.",
11701
+ convex: {
11702
+ module: "nodes",
11703
+ functionName: "update",
11704
+ kind: "mutation",
11705
+ inputProjection: updateNodeInput
11706
+ },
11707
+ args: updateEpistemicNodeArgs
11708
+ }),
11709
+ surfaceContract({
11710
+ name: "archive_epistemic_node",
11711
+ kind: "mutation",
11712
+ domain: "nodes",
11713
+ surfaceClass: "platform_public",
11714
+ path: "/nodes/archive",
11715
+ sdkNamespace: "nodes",
11716
+ sdkMethod: "archiveEpistemicNode",
11717
+ summary: "Archive a generic epistemic graph node.",
11718
+ convex: {
11719
+ module: "nodes",
11720
+ functionName: "archive",
11721
+ kind: "mutation",
11722
+ inputProjection: archiveNodeInput
11723
+ },
11724
+ args: archiveEpistemicNodeArgs
11725
+ }),
11726
+ surfaceContract({
11727
+ name: "verify_epistemic_node",
11728
+ kind: "mutation",
11729
+ domain: "nodes",
11730
+ surfaceClass: "platform_public",
11731
+ path: "/nodes/verify",
11732
+ sdkNamespace: "nodes",
11733
+ sdkMethod: "verifyEpistemicNode",
11734
+ summary: "Verify a generic epistemic graph node.",
11735
+ convex: {
11736
+ module: "nodes",
11737
+ functionName: "verify",
11738
+ kind: "mutation",
11739
+ inputProjection: verifyNodeInput
11740
+ },
11741
+ args: verifyEpistemicNodeArgs
11742
+ }),
11743
+ surfaceContract({
11744
+ name: "supersede_epistemic_node",
11745
+ kind: "mutation",
11746
+ domain: "nodes",
11747
+ surfaceClass: "platform_public",
11748
+ path: "/nodes/supersede",
11749
+ sdkNamespace: "nodes",
11750
+ sdkMethod: "supersedeEpistemicNode",
11751
+ summary: "Supersede a generic epistemic graph node.",
11752
+ convex: {
11753
+ module: "nodes",
11754
+ functionName: "supersede",
11755
+ kind: "mutation",
11756
+ inputProjection: supersedeNodeInput
11757
+ },
11758
+ args: supersedeEpistemicNodeArgs
11759
+ }),
11760
+ surfaceContract({
11761
+ name: "batch_create_epistemic_nodes",
11762
+ kind: "mutation",
11763
+ domain: "nodes",
11764
+ surfaceClass: "platform_public",
11765
+ path: "/nodes/batch",
11766
+ sdkNamespace: "nodes",
11767
+ sdkMethod: "batchCreateEpistemicNodes",
11768
+ summary: "Batch create generic epistemic graph nodes.",
11769
+ convex: {
11770
+ module: "nodes",
11771
+ functionName: "batchCreate",
11772
+ kind: "mutation",
11773
+ inputProjection: batchCreateNodesInput
11774
+ },
11775
+ args: batchCreateEpistemicNodesArgs
11776
+ })
11777
+ ];
11778
+ var lensPerspectiveSchema = z.enum([
11779
+ "investigation",
11780
+ "monitoring",
11781
+ "analysis",
11782
+ "comparison",
11783
+ "taxonomy"
11784
+ ]);
11785
+ var jsonRecordSchema6 = z.record(z.unknown());
11786
+ var createLensArgs = z.object({
11787
+ name: z.string().describe("Lens name."),
11788
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
11789
+ topicId: z.string().optional().describe("Originating topic scope."),
11790
+ description: z.string().optional().describe("What this lens investigates or monitors."),
11791
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
11792
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
11793
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
11794
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
11795
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
11796
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
11797
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
11798
+ });
11799
+ var createLensInput = (input, context) => compactRecord4({
11800
+ name: input.name,
11801
+ description: input.description,
11802
+ workspaceId: input.workspaceId,
11803
+ topicId: input.topicId,
11804
+ perspectiveType: input.perspectiveType,
11805
+ promptTemplates: input.promptTemplates,
11806
+ workflowTemplates: input.workflowTemplates,
11807
+ taskTemplates: input.taskTemplates,
11808
+ questionTemplates: input.questionTemplates,
11809
+ filterCriteria: input.filterCriteria,
11810
+ metadata: input.metadata,
11811
+ createdBy: authUserId(context)
11812
+ });
11813
+ var lensListInput = (input, context) => compactRecord4({
11814
+ actorId: input.actorId ?? authUserId(context),
11815
+ workspaceId: input.workspaceId,
11816
+ topicId: input.topicId,
11817
+ status: input.status,
11818
+ perspectiveType: input.perspectiveType
11819
+ });
11820
+ var lensesContracts = [
11821
+ surfaceContract({
11822
+ name: "create_lens",
11823
+ kind: "mutation",
11824
+ domain: "lenses",
11825
+ surfaceClass: "platform_public",
11826
+ path: "/lenses",
11827
+ sdkNamespace: "lenses",
11828
+ sdkMethod: "createLens",
11829
+ summary: "Create a lens.",
11830
+ convex: {
11831
+ module: "lenses",
11832
+ functionName: "create",
11833
+ kind: "mutation",
11834
+ inputProjection: createLensInput
11835
+ },
11836
+ args: createLensArgs
11837
+ }),
11838
+ surfaceContract({
11839
+ name: "list_lenses",
11840
+ kind: "query",
11841
+ domain: "lenses",
11842
+ surfaceClass: "platform_public",
11843
+ method: "GET",
11844
+ path: "/lenses",
11845
+ sdkNamespace: "lenses",
11846
+ sdkMethod: "listLenses",
11847
+ summary: "List lenses.",
11848
+ convex: {
11849
+ module: "lenses",
11850
+ functionName: "list",
11851
+ kind: "query",
11852
+ inputProjection: lensListInput
11853
+ }
11854
+ }),
11855
+ surfaceContract({
11856
+ name: "apply_lens_to_topic",
11857
+ kind: "mutation",
11858
+ domain: "lenses",
9924
11859
  surfaceClass: "platform_public",
9925
- method: "DELETE",
11860
+ path: "/lenses/apply",
11861
+ sdkNamespace: "lenses",
11862
+ sdkMethod: "applyLensToTopic",
11863
+ summary: "Apply a lens to a topic.",
11864
+ convex: {
11865
+ module: "lenses",
11866
+ functionName: "applyToTopic",
11867
+ kind: "mutation",
11868
+ inputProjection: (input, context) => compactRecord4({
11869
+ lensId: input.lensId,
11870
+ topicId: input.topicId,
11871
+ metadata: input.metadata,
11872
+ appliedBy: authUserId(context)
11873
+ })
11874
+ }
11875
+ }),
11876
+ surfaceContract({
11877
+ name: "remove_lens_from_topic",
11878
+ kind: "mutation",
11879
+ domain: "lenses",
11880
+ surfaceClass: "platform_public",
11881
+ method: "DELETE",
9926
11882
  path: "/lenses/apply",
9927
11883
  sdkNamespace: "lenses",
9928
11884
  sdkMethod: "removeLensFromTopic",
@@ -9939,8 +11895,18 @@ var lensesContracts = [
9939
11895
  }
9940
11896
  })
9941
11897
  ];
9942
-
9943
- // ../contracts/src/function-registry/ontologies.ts
11898
+ var updateOntologyArgs = z.object({
11899
+ id: z.string().describe("Ontology definition ID."),
11900
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
11901
+ name: z.string().optional().describe("Ontology display name."),
11902
+ description: z.string().optional().describe("Ontology description."),
11903
+ status: z.string().optional().describe("Ontology lifecycle status.")
11904
+ });
11905
+ var ontologyVersionLifecycleArgs = z.object({
11906
+ id: z.string().describe("Ontology version ID."),
11907
+ versionId: z.string().optional().describe("Ontology version ID alias."),
11908
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
11909
+ });
9944
11910
  var ontologyIdInput = (input) => compactRecord4({
9945
11911
  id: input.id ?? input.ontologyId
9946
11912
  });
@@ -10019,11 +11985,11 @@ var ontologiesContracts = [
10019
11985
  id: input.id ?? input.ontologyId,
10020
11986
  name: input.name,
10021
11987
  description: input.description,
10022
- parentOntologyId: input.parentOntologyId,
10023
11988
  status: input.status,
10024
11989
  actorId: input.actorId
10025
11990
  })
10026
- }
11991
+ },
11992
+ args: updateOntologyArgs
10027
11993
  }),
10028
11994
  surfaceContract({
10029
11995
  name: "archive_ontology",
@@ -10106,7 +12072,8 @@ var ontologiesContracts = [
10106
12072
  functionName: "publishOntologyVersion",
10107
12073
  kind: "mutation",
10108
12074
  inputProjection: ontologyVersionIdInput
10109
- }
12075
+ },
12076
+ args: ontologyVersionLifecycleArgs
10110
12077
  }),
10111
12078
  surfaceContract({
10112
12079
  name: "deprecate_ontology_version",
@@ -10122,7 +12089,8 @@ var ontologiesContracts = [
10122
12089
  functionName: "deprecateOntologyVersion",
10123
12090
  kind: "mutation",
10124
12091
  inputProjection: ontologyVersionIdInput
10125
- }
12092
+ },
12093
+ args: ontologyVersionLifecycleArgs
10126
12094
  }),
10127
12095
  surfaceContract({
10128
12096
  name: "resolve_effective_ontology",
@@ -10141,8 +12109,81 @@ var ontologiesContracts = [
10141
12109
  }
10142
12110
  })
10143
12111
  ];
10144
-
10145
- // ../contracts/src/function-registry/worktrees.ts
12112
+ var autoFixPolicyInputSchema = z.object({
12113
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
12114
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
12115
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
12116
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
12117
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
12118
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
12119
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
12120
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
12121
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
12122
+ var worktreeKeyQuestionInputSchema = z.object({
12123
+ question: z.string().describe("Question the worktree must resolve."),
12124
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
12125
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
12126
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
12127
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
12128
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
12129
+ var worktreeEvidenceSignalInputSchema = z.object({
12130
+ signal: z.string().describe("Evidence signal the worktree should collect."),
12131
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
12132
+ progress: z.string().optional().describe("Collection progress note for the signal."),
12133
+ notes: z.string().optional().describe("Additional evidence collection notes.")
12134
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
12135
+ var worktreeDecisionGateInputSchema = z.object({
12136
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
12137
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
12138
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
12139
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
12140
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
12141
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
12142
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
12143
+ var addWorktreeArgs = z.object({
12144
+ title: z.string().describe("Human-readable worktree name or objective."),
12145
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
12146
+ topicId: z.string().optional().describe("Optional primary topic scope hint for resolver validation."),
12147
+ projectId: z.string().optional().describe("Legacy topicId alias/hint."),
12148
+ topicHint: z.string().optional().describe("Natural-language topic hint for automatic topic resolution."),
12149
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
12150
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
12151
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12152
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
12153
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
12154
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12155
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
12156
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
12157
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
12158
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
12159
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
12160
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12161
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12162
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
12163
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
12164
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
12165
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
12166
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
12167
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
12168
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
12169
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
12170
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
12171
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12172
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
12173
+ tags: z.array(z.string()).optional().describe("Additional topic-resolution tags for the worktree."),
12174
+ touchedPaths: z.array(z.string()).optional().describe("File paths used as topic-resolution signals."),
12175
+ sourceRef: z.string().optional().describe("Source reference used as a topic-resolution signal."),
12176
+ sourceKind: z.string().optional().describe("Source kind used as a topic-resolution signal."),
12177
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
12178
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
12179
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12180
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12181
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
12182
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12183
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12184
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
12185
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
12186
+ });
10146
12187
  var worktreeIdInput = (input) => compactRecord4({
10147
12188
  worktreeId: input.worktreeId ?? input.id
10148
12189
  });
@@ -10175,6 +12216,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10175
12216
  autoFixPolicy: input.autoFixPolicy,
10176
12217
  lastReconciledAt: input.lastReconciledAt
10177
12218
  });
12219
+ var worktreeMetadataArgs = z.object({
12220
+ worktreeId: z.string().describe("The worktree to update."),
12221
+ id: z.string().optional().describe("Worktree ID alias."),
12222
+ topicId: z.string().optional().describe("Primary topic scope."),
12223
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
12224
+ status: z.string().optional().describe("Worktree lifecycle status."),
12225
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
12226
+ lane: z.string().optional().describe("Campaign lane."),
12227
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12228
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12229
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12230
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12231
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
12232
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
12233
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
12234
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12235
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12236
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
12237
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
12238
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12239
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
12240
+ });
12241
+ var pushArgs = worktreeMetadataArgs.extend({
12242
+ targetContext: z.string().describe("Where to push merged findings."),
12243
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
12244
+ });
12245
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
12246
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
12247
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
12248
+ });
12249
+ var mergeKeyFindingsInput = (input) => {
12250
+ if (Array.isArray(input.keyFindings)) {
12251
+ return input.keyFindings;
12252
+ }
12253
+ if (Array.isArray(input.outcomes)) {
12254
+ const findings = input.outcomes.filter(
12255
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
12256
+ );
12257
+ if (findings.length > 0) {
12258
+ return findings;
12259
+ }
12260
+ }
12261
+ return [input.summary ?? "Merged worktree"];
12262
+ };
10178
12263
  var listAllWorktreesInput = (input) => compactRecord4({
10179
12264
  status: input.status,
10180
12265
  lane: input.lane,
@@ -10182,6 +12267,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10182
12267
  limit: input.limit
10183
12268
  });
10184
12269
  var worktreesContracts = [
12270
+ surfaceContract({
12271
+ name: "begin_build_session",
12272
+ kind: "mutation",
12273
+ domain: "worktrees",
12274
+ surfaceClass: "platform_internal",
12275
+ path: "/mcp/build-session/begin",
12276
+ sdkNamespace: "worktrees",
12277
+ sdkMethod: "beginBuildSession",
12278
+ summary: "Begin a coding build session for a worktree."
12279
+ }),
10185
12280
  surfaceContract({
10186
12281
  name: "add_worktree",
10187
12282
  kind: "mutation",
@@ -10198,13 +12293,12 @@ var worktreesContracts = [
10198
12293
  inputProjection: (input, context) => withCreatedBy(
10199
12294
  compactRecord4({
10200
12295
  name: input.name ?? input.title,
10201
- topicId: input.topicId,
12296
+ topicId: input.topicId ?? input.projectId,
10202
12297
  worktreeType: input.worktreeType,
10203
12298
  objective: input.objective,
10204
12299
  gate: input.gate,
10205
12300
  hypothesis: input.hypothesis,
10206
12301
  rationale: input.rationale,
10207
- signal: input.signal,
10208
12302
  startDate: input.startDate,
10209
12303
  endDate: input.endDate,
10210
12304
  durationWeeks: input.durationWeeks,
@@ -10230,12 +12324,12 @@ var worktreesContracts = [
10230
12324
  staffingHint: input.staffingHint,
10231
12325
  domainPackId: input.domainPackId,
10232
12326
  lensId: input.lensId,
10233
- linkedQuestionId: input.linkedQuestionId,
10234
12327
  lastReconciledAt: input.lastReconciledAt
10235
12328
  }),
10236
12329
  context
10237
12330
  )
10238
- }
12331
+ },
12332
+ args: addWorktreeArgs
10239
12333
  }),
10240
12334
  surfaceContract({
10241
12335
  name: "activate_worktree",
@@ -10347,7 +12441,8 @@ var worktreesContracts = [
10347
12441
  functionName: "updateMetadata",
10348
12442
  kind: "mutation",
10349
12443
  inputProjection: worktreeMetadataInput
10350
- }
12444
+ },
12445
+ args: worktreeMetadataArgs
10351
12446
  }),
10352
12447
  surfaceContract({
10353
12448
  name: "merge",
@@ -10365,9 +12460,7 @@ var worktreesContracts = [
10365
12460
  inputProjection: (input, context) => withUserId(
10366
12461
  {
10367
12462
  ...worktreeIdInput(input),
10368
- keyFindings: input.keyFindings ?? [
10369
- input.summary ?? "Merged worktree"
10370
- ],
12463
+ keyFindings: mergeKeyFindingsInput(input),
10371
12464
  decisionsReached: input.decisionsReached ?? [],
10372
12465
  nextSteps: input.nextSteps ?? []
10373
12466
  },
@@ -10389,7 +12482,8 @@ var worktreesContracts = [
10389
12482
  functionName: "updateMetadata",
10390
12483
  kind: "mutation",
10391
12484
  inputProjection: worktreeMetadataInput
10392
- }
12485
+ },
12486
+ args: pushArgs
10393
12487
  }),
10394
12488
  surfaceContract({
10395
12489
  name: "open_pull_request",
@@ -10405,11 +12499,50 @@ var worktreesContracts = [
10405
12499
  functionName: "updateMetadata",
10406
12500
  kind: "mutation",
10407
12501
  inputProjection: worktreeMetadataInput
10408
- }
12502
+ },
12503
+ args: openPullRequestArgs
10409
12504
  })
10410
12505
  ];
10411
-
10412
- // ../contracts/src/function-registry/tasks.ts
12506
+ var taskPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
12507
+ var taskStatusSchema2 = z.enum(["todo", "in_progress", "blocked", "done"]);
12508
+ var taskTypeSchema = z.enum([
12509
+ "general",
12510
+ "find_evidence",
12511
+ "verify_claim",
12512
+ "research",
12513
+ "review",
12514
+ "interview",
12515
+ "analysis",
12516
+ "track_metrics"
12517
+ ]);
12518
+ var createTaskArgs = z.object({
12519
+ title: z.string().describe("Task title."),
12520
+ topicId: z.string().optional().describe("Topic scope."),
12521
+ description: z.string().optional().describe("Long-form task description."),
12522
+ taskType: taskTypeSchema.optional().describe("Task taxonomy."),
12523
+ priority: taskPrioritySchema.optional().describe("Priority. Defaults to medium when omitted by the server."),
12524
+ status: taskStatusSchema2.optional().describe("Initial status. Defaults to todo."),
12525
+ linkedWorktreeId: z.string().optional().describe("Worktree this task belongs to."),
12526
+ linkedBeliefId: z.string().optional().describe("Belief this task supports."),
12527
+ linkedQuestionId: z.string().optional().describe("Question this task addresses."),
12528
+ assigneeId: z.string().optional().describe("Principal assigned to the task."),
12529
+ dueDate: z.number().optional().describe("Due date as epoch milliseconds."),
12530
+ tags: z.array(z.string()).optional().describe("Free-form tags.")
12531
+ });
12532
+ var createTaskInput = (input) => compactRecord4({
12533
+ title: input.title,
12534
+ topicId: input.topicId,
12535
+ description: input.description,
12536
+ taskType: input.taskType,
12537
+ priority: input.priority ?? "medium",
12538
+ status: input.status ?? "todo",
12539
+ linkedWorktreeId: input.linkedWorktreeId,
12540
+ linkedBeliefId: input.linkedBeliefId,
12541
+ linkedQuestionId: input.linkedQuestionId,
12542
+ assigneeId: input.assigneeId,
12543
+ dueDate: input.dueDate,
12544
+ tags: input.tags
12545
+ });
10413
12546
  var taskInput = (input) => compactRecord4({
10414
12547
  ...input,
10415
12548
  taskId: input.taskId ?? input.id
@@ -10441,8 +12574,10 @@ var tasksContracts = [
10441
12574
  convex: {
10442
12575
  module: "tasks",
10443
12576
  functionName: "create",
10444
- kind: "mutation"
10445
- }
12577
+ kind: "mutation",
12578
+ inputProjection: createTaskInput
12579
+ },
12580
+ args: createTaskArgs
10446
12581
  }),
10447
12582
  surfaceContract({
10448
12583
  name: "list_tasks",
@@ -10496,19 +12631,57 @@ var tasksContracts = [
10496
12631
  }
10497
12632
  })
10498
12633
  ];
12634
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12635
+ (policy) => policy.edgeType
12636
+ );
10499
12637
  var createEdgeArgs = z.object({
10500
12638
  from: GraphRefSchema,
10501
12639
  to: GraphRefSchema,
10502
- edgeType: z.string(),
12640
+ edgeType: z.enum(CREATE_EDGE_TYPES),
10503
12641
  globalId: z.string().optional(),
10504
12642
  weight: z.number().optional(),
10505
12643
  confidence: z.number().optional(),
10506
12644
  context: z.string().optional(),
10507
12645
  reasoning: z.string().optional(),
10508
12646
  derivationType: z.string().optional(),
12647
+ metadata: z.record(z.unknown()).optional(),
10509
12648
  topicId: z.string().optional(),
10510
12649
  trustedBypassAccessCheck: z.boolean().optional()
10511
12650
  });
12651
+ var updateEdgeArgs = z.object({
12652
+ edgeId: z.string().describe("Edge ID or global ID."),
12653
+ weight: z.number().optional(),
12654
+ confidence: z.number().optional(),
12655
+ context: z.string().optional(),
12656
+ reasoning: z.string().optional(),
12657
+ derivationType: z.string().optional(),
12658
+ metadata: z.record(z.unknown()).optional(),
12659
+ userId: z.string().optional()
12660
+ });
12661
+ var removeEdgeArgs = z.object({
12662
+ edgeId: z.string().describe("Edge ID or global ID."),
12663
+ userId: z.string().optional()
12664
+ });
12665
+ var removeEdgesBetweenArgs = z.object({
12666
+ from: GraphRefSchema.optional(),
12667
+ to: GraphRefSchema.optional(),
12668
+ fromNodeId: z.string().optional(),
12669
+ toNodeId: z.string().optional(),
12670
+ edgeType: z.enum(CREATE_EDGE_TYPES).optional()
12671
+ });
12672
+ var batchCreateEdgesArgs = z.object({
12673
+ edges: z.array(createEdgeArgs),
12674
+ skipLayerValidation: z.boolean().optional()
12675
+ });
12676
+ var queryLineageArgs = z.object({
12677
+ nodeId: z.string().describe("Starting node to trace from."),
12678
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
12679
+ depth: z.number().optional().describe("Traversal depth alias."),
12680
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12681
+ mode: z.string().optional().describe("Traversal mode."),
12682
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12683
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12684
+ });
10512
12685
  function graphRefNodeId(ref) {
10513
12686
  if (ref.kind === "epistemic_node") {
10514
12687
  return ref.nodeId;
@@ -10549,6 +12722,7 @@ var edgesContracts = [
10549
12722
  confidence: parsed.confidence,
10550
12723
  context: parsed.context ?? parsed.reasoning,
10551
12724
  derivationType: parsed.derivationType,
12725
+ metadata: parsed.metadata,
10552
12726
  skipLayerValidation: true,
10553
12727
  topicId: parsed.topicId,
10554
12728
  trustedBypassAccessCheck: parsed.trustedBypassAccessCheck
@@ -10559,6 +12733,130 @@ var edgesContracts = [
10559
12733
  },
10560
12734
  args: createEdgeArgs
10561
12735
  }),
12736
+ surfaceContract({
12737
+ name: "update_edge",
12738
+ kind: "mutation",
12739
+ domain: "edges",
12740
+ surfaceClass: "platform_public",
12741
+ method: "PATCH",
12742
+ path: "/edges",
12743
+ sdkNamespace: "edges",
12744
+ sdkMethod: "updateEdge",
12745
+ summary: "Update an epistemic edge.",
12746
+ convex: {
12747
+ module: "edges",
12748
+ functionName: "update",
12749
+ kind: "mutation",
12750
+ inputProjection: (input, context) => compactRecord4({
12751
+ edgeId: input.edgeId,
12752
+ weight: input.weight,
12753
+ confidence: input.confidence,
12754
+ context: input.context ?? input.reasoning,
12755
+ derivationType: input.derivationType,
12756
+ metadata: input.metadata,
12757
+ userId: input.userId ?? context.userId ?? context.principalId
12758
+ })
12759
+ },
12760
+ args: updateEdgeArgs
12761
+ }),
12762
+ surfaceContract({
12763
+ name: "remove_edge",
12764
+ kind: "mutation",
12765
+ domain: "edges",
12766
+ surfaceClass: "platform_public",
12767
+ method: "DELETE",
12768
+ path: "/edges",
12769
+ sdkNamespace: "edges",
12770
+ sdkMethod: "removeEdge",
12771
+ summary: "Remove an epistemic edge.",
12772
+ convex: {
12773
+ module: "edges",
12774
+ functionName: "remove",
12775
+ kind: "mutation",
12776
+ inputProjection: (input, context) => compactRecord4({
12777
+ edgeId: input.edgeId,
12778
+ userId: input.userId ?? context.userId ?? context.principalId
12779
+ })
12780
+ },
12781
+ args: removeEdgeArgs
12782
+ }),
12783
+ surfaceContract({
12784
+ name: "remove_edges_between",
12785
+ kind: "mutation",
12786
+ domain: "edges",
12787
+ surfaceClass: "platform_public",
12788
+ method: "DELETE",
12789
+ path: "/edges/between",
12790
+ sdkNamespace: "edges",
12791
+ sdkMethod: "removeEdgesBetween",
12792
+ summary: "Remove epistemic edges between two nodes.",
12793
+ convex: {
12794
+ module: "edges",
12795
+ functionName: "removeBetween",
12796
+ kind: "mutation",
12797
+ inputProjection: (input) => {
12798
+ const parsed = removeEdgesBetweenArgs.parse(input);
12799
+ const fromNodeId = parsed.from ? graphRefNodeId(parsed.from) : parsed.fromNodeId;
12800
+ const toNodeId = parsed.to ? graphRefNodeId(parsed.to) : parsed.toNodeId;
12801
+ if (!fromNodeId || !toNodeId) {
12802
+ throw new Error("from/to or fromNodeId/toNodeId are required.");
12803
+ }
12804
+ return compactRecord4({
12805
+ fromNodeId,
12806
+ toNodeId,
12807
+ edgeType: parsed.edgeType
12808
+ });
12809
+ }
12810
+ },
12811
+ args: removeEdgesBetweenArgs
12812
+ }),
12813
+ surfaceContract({
12814
+ name: "batch_create_edges",
12815
+ kind: "mutation",
12816
+ domain: "edges",
12817
+ surfaceClass: "platform_public",
12818
+ path: "/edges/batch",
12819
+ sdkNamespace: "edges",
12820
+ sdkMethod: "batchCreateEdges",
12821
+ summary: "Batch create epistemic edges.",
12822
+ convex: {
12823
+ module: "edges",
12824
+ functionName: "batchCreate",
12825
+ kind: "mutation",
12826
+ inputProjection: (input, context) => {
12827
+ const parsed = batchCreateEdgesArgs.parse(input);
12828
+ return {
12829
+ skipLayerValidation: parsed.skipLayerValidation ?? true,
12830
+ edges: parsed.edges.map((edge) => {
12831
+ assertEdgePolicyAllowed(
12832
+ edgePolicyManifest,
12833
+ edge.edgeType,
12834
+ edge.from,
12835
+ edge.to
12836
+ );
12837
+ const fromNodeId = graphRefNodeId(edge.from);
12838
+ const toNodeId = graphRefNodeId(edge.to);
12839
+ return withCreatedBy(
12840
+ compactRecord4({
12841
+ fromNodeId,
12842
+ toNodeId,
12843
+ edgeType: edge.edgeType,
12844
+ globalId: edge.globalId ?? `edge:${fromNodeId}:${toNodeId}:${edge.edgeType}`,
12845
+ weight: edge.weight,
12846
+ confidence: edge.confidence,
12847
+ context: edge.context ?? edge.reasoning,
12848
+ derivationType: edge.derivationType,
12849
+ metadata: edge.metadata,
12850
+ topicId: edge.topicId
12851
+ }),
12852
+ context
12853
+ );
12854
+ })
12855
+ };
12856
+ }
12857
+ },
12858
+ args: batchCreateEdgesArgs
12859
+ }),
10562
12860
  surfaceContract({
10563
12861
  name: "query_lineage",
10564
12862
  kind: "query",
@@ -10579,11 +12877,84 @@ var edgesContracts = [
10579
12877
  minLayer: input.minLayer,
10580
12878
  maxLayer: input.maxLayer
10581
12879
  })
10582
- }
12880
+ },
12881
+ args: queryLineageArgs
10583
12882
  })
10584
12883
  ];
10585
-
10586
- // ../contracts/src/function-registry/graph.ts
12884
+ var graphIntelligenceQueryModes = [
12885
+ "core",
12886
+ "bias",
12887
+ "stress",
12888
+ "operational",
12889
+ "alpha",
12890
+ "semantic",
12891
+ "evidence"
12892
+ ];
12893
+ var traversalLayerSchema = z.enum([
12894
+ "L4",
12895
+ "L3",
12896
+ "L2",
12897
+ "L1",
12898
+ "ontological",
12899
+ "organizational"
12900
+ ]);
12901
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
12902
+ var lineageAliasArgs = z.object({
12903
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
12904
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
12905
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
12906
+ depth: z.number().optional().describe("Traversal depth alias."),
12907
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12908
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
12909
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
12910
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
12911
+ });
12912
+ var lineageArgs = lineageAliasArgs.extend({
12913
+ nodeId: z.string().describe("Starting node to traverse from.")
12914
+ });
12915
+ var traverseGraphArgs = lineageAliasArgs.extend({
12916
+ startNode: z.string().describe("Node to start traversal from."),
12917
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
12918
+ });
12919
+ var graphNeighborhoodArgs = z.object({
12920
+ globalId: z.string().optional().describe("Single root global ID."),
12921
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
12922
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12923
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
12924
+ limit: z.number().optional().describe("Maximum edges to return.")
12925
+ });
12926
+ var graphIntelligenceModeSchema = z.enum([
12927
+ graphIntelligenceQueryModes[0],
12928
+ ...graphIntelligenceQueryModes.slice(1)
12929
+ ]);
12930
+ var graphIntelligenceCatalogArgs = z.object({
12931
+ categoryId: z.string().optional().describe("Optional query category filter."),
12932
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
12933
+ });
12934
+ var graphIntelligenceRunArgs = z.object({
12935
+ topicId: z.string().describe("Topic to analyze."),
12936
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
12937
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
12938
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
12939
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
12940
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
12941
+ });
12942
+ var flagContradictionArgs = z.object({
12943
+ beliefA: z.string().describe("First belief in tension."),
12944
+ beliefB: z.string().describe("Second belief in tension."),
12945
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
12946
+ description: z.string().optional().describe("Human-readable contradiction."),
12947
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
12948
+ defeatType: z.string().optional().describe("Defeat type annotation."),
12949
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
12950
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
12951
+ });
12952
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
12953
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
12954
+ topicId: z.string().optional().describe("Topic scope override."),
12955
+ minScore: z.number().optional().describe("Minimum match score."),
12956
+ limit: z.number().optional().describe("Maximum candidates to return.")
12957
+ });
10587
12958
  var contradictionSeverity = (value) => {
10588
12959
  switch (value) {
10589
12960
  case "critical":
@@ -10638,7 +13009,8 @@ var graphContracts = [
10638
13009
  functionName: "getLineage",
10639
13010
  kind: "query",
10640
13011
  inputProjection: lineageInput
10641
- }
13012
+ },
13013
+ args: traverseGraphArgs
10642
13014
  }),
10643
13015
  surfaceContract({
10644
13016
  name: "get_graph_neighborhood",
@@ -10654,7 +13026,8 @@ var graphContracts = [
10654
13026
  functionName: "getByTopic",
10655
13027
  kind: "query",
10656
13028
  inputProjection: topicEdgesInput
10657
- }
13029
+ },
13030
+ args: graphNeighborhoodArgs
10658
13031
  }),
10659
13032
  surfaceContract({
10660
13033
  name: "get_graph_structure_analysis",
@@ -10671,6 +13044,38 @@ var graphContracts = [
10671
13044
  kind: "query"
10672
13045
  }
10673
13046
  }),
13047
+ surfaceContract({
13048
+ name: "list_graph_intelligence_queries",
13049
+ kind: "query",
13050
+ domain: "graph",
13051
+ surfaceClass: "platform_public",
13052
+ path: "/graph-intelligence/queries",
13053
+ sdkNamespace: "graphAnalysis",
13054
+ sdkMethod: "listGraphIntelligenceQueries",
13055
+ summary: "List Graph Intelligence query catalog entries.",
13056
+ convex: {
13057
+ module: "contextCompiler",
13058
+ functionName: "listGraphIntelligenceQueries",
13059
+ kind: "query"
13060
+ },
13061
+ args: graphIntelligenceCatalogArgs
13062
+ }),
13063
+ surfaceContract({
13064
+ name: "run_graph_intelligence_query",
13065
+ kind: "query",
13066
+ domain: "graph",
13067
+ surfaceClass: "platform_public",
13068
+ path: "/graph-intelligence/run",
13069
+ sdkNamespace: "graphAnalysis",
13070
+ sdkMethod: "runGraphIntelligenceQuery",
13071
+ summary: "Run a Graph Intelligence query against a topic graph.",
13072
+ convex: {
13073
+ module: "contextCompiler",
13074
+ functionName: "runGraphIntelligenceQuery",
13075
+ kind: "query"
13076
+ },
13077
+ args: graphIntelligenceRunArgs
13078
+ }),
10674
13079
  surfaceContract({
10675
13080
  name: "find_contradictions",
10676
13081
  kind: "query",
@@ -10703,7 +13108,8 @@ var graphContracts = [
10703
13108
  functionName: "create",
10704
13109
  kind: "mutation",
10705
13110
  inputProjection: flagContradictionInput
10706
- }
13111
+ },
13112
+ args: flagContradictionArgs
10707
13113
  }),
10708
13114
  surfaceContract({
10709
13115
  name: "detect_confirmation_bias",
@@ -10794,7 +13200,8 @@ var graphContracts = [
10794
13200
  functionName: "getLineage",
10795
13201
  kind: "query",
10796
13202
  inputProjection: lineageInput
10797
- }
13203
+ },
13204
+ args: discoverEntityConnectionsArgs
10798
13205
  }),
10799
13206
  surfaceContract({
10800
13207
  name: "trigger_belief_review",
@@ -10825,7 +13232,8 @@ var graphContracts = [
10825
13232
  functionName: "getLineage",
10826
13233
  kind: "query",
10827
13234
  inputProjection: lineageInput
10828
- }
13235
+ },
13236
+ args: lineageArgs
10829
13237
  })
10830
13238
  ];
10831
13239
 
@@ -10877,8 +13285,16 @@ var contractsContracts = [
10877
13285
  }
10878
13286
  })
10879
13287
  ];
10880
-
10881
- // ../contracts/src/function-registry/judgments.ts
13288
+ var auditTrailArgs = z.object({
13289
+ nodeId: z.string().describe("The node to audit."),
13290
+ id: z.string().optional().describe("Node ID alias."),
13291
+ limit: z.number().optional().describe("Maximum entries to return."),
13292
+ depth: z.number().optional().describe("Traversal depth alias."),
13293
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
13294
+ mode: z.string().optional().describe("Traversal mode."),
13295
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
13296
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
13297
+ });
10882
13298
  var judgmentsContracts = [
10883
13299
  surfaceContract({
10884
13300
  name: "record_judgment",
@@ -10933,7 +13349,8 @@ var judgmentsContracts = [
10933
13349
  minLayer: input.minLayer,
10934
13350
  maxLayer: input.maxLayer
10935
13351
  })
10936
- }
13352
+ },
13353
+ args: auditTrailArgs
10937
13354
  })
10938
13355
  ];
10939
13356
 
@@ -11101,8 +13518,13 @@ var coordinationContracts = [
11101
13518
  }
11102
13519
  })
11103
13520
  ];
11104
-
11105
- // ../contracts/src/function-registry/pipeline.ts
13521
+ var pipelineSnapshotArgs = z.object({
13522
+ topicId: z.string().describe("Topic scope ID."),
13523
+ status: z.string().optional().describe("Worktree status filter."),
13524
+ lane: z.string().optional().describe("Campaign lane filter."),
13525
+ campaign: z.number().optional().describe("Campaign number filter."),
13526
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
13527
+ });
11106
13528
  var pipelineContracts = [
11107
13529
  surfaceContract({
11108
13530
  name: "pipeline_snapshot",
@@ -11123,7 +13545,8 @@ var pipelineContracts = [
11123
13545
  campaign: input.campaign,
11124
13546
  limit: input.limit
11125
13547
  })
11126
- }
13548
+ },
13549
+ args: pipelineSnapshotArgs
11127
13550
  }),
11128
13551
  surfaceContract({
11129
13552
  name: "seed_belief_lattice",
@@ -11175,7 +13598,31 @@ var recordScopeLearningArgs = z.object({
11175
13598
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11176
13599
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11177
13600
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11178
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
13601
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
13602
+ text: z.string().optional().describe("Canonical learning text alias."),
13603
+ content: z.string().optional().describe("Canonical learning content alias."),
13604
+ kind: z.string().optional().describe("Evidence kind to store."),
13605
+ sourceType: z.string().optional().describe("Evidence source type."),
13606
+ externalSourceType: z.string().optional().describe("External source type alias."),
13607
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
13608
+ });
13609
+ var codeContextArgs = z.object({
13610
+ topicId: z.string().optional().describe("Topic scope."),
13611
+ filePath: z.string().optional().describe("File path anchor."),
13612
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
13613
+ limit: z.number().optional().describe("Maximum records to return."),
13614
+ status: z.string().optional().describe("Evidence status filter.")
13615
+ });
13616
+ var recordAttemptArgs = z.object({
13617
+ topicId: z.string().optional().describe("Topic scope."),
13618
+ description: z.string().describe("Attempt description."),
13619
+ errorMessage: z.string().optional().describe("Failure or error message."),
13620
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
13621
+ filePath: z.string().optional().describe("Single file path alias."),
13622
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
13623
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
13624
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
13625
+ title: z.string().optional().describe("Attempt evidence title.")
11179
13626
  });
11180
13627
  var learningInput = (input, context) => {
11181
13628
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11292,7 +13739,8 @@ var codingContracts = [
11292
13739
  status: input.status,
11293
13740
  userId: input.userId
11294
13741
  })
11295
- }
13742
+ },
13743
+ args: codeContextArgs
11296
13744
  }),
11297
13745
  surfaceContract({
11298
13746
  name: "get_change_history",
@@ -11329,7 +13777,8 @@ var codingContracts = [
11329
13777
  functionName: "create",
11330
13778
  kind: "mutation",
11331
13779
  inputProjection: attemptInput
11332
- }
13780
+ },
13781
+ args: recordAttemptArgs
11333
13782
  }),
11334
13783
  surfaceContract({
11335
13784
  name: "get_failure_log",
@@ -11386,6 +13835,7 @@ var ALL_FUNCTION_CONTRACTS = [
11386
13835
  ...evidenceContracts,
11387
13836
  ...questionsContracts,
11388
13837
  ...topicsContracts,
13838
+ ...nodesContracts,
11389
13839
  ...lensesContracts,
11390
13840
  ...ontologiesContracts,
11391
13841
  ...worktreesContracts,
@@ -11400,17 +13850,623 @@ var ALL_FUNCTION_CONTRACTS = [
11400
13850
  ...legacyContracts
11401
13851
  ];
11402
13852
  assertSurfaceCoverage(ALL_FUNCTION_CONTRACTS);
11403
- new Map(
13853
+ var FUNCTION_CONTRACTS_BY_NAME = new Map(
11404
13854
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11405
13855
  );
13856
+ FUNCTION_CONTRACTS_BY_NAME.get.bind(
13857
+ FUNCTION_CONTRACTS_BY_NAME
13858
+ );
13859
+
13860
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
13861
+ function isCopyableSeedRequirement(entry) {
13862
+ 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;
13863
+ }
13864
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
13865
+ {
13866
+ component: "kernel",
13867
+ table: "agentMessages",
13868
+ prepopulation: "runtime_data",
13869
+ copyMode: "none",
13870
+ description: "Agent coordination messages are session data, not template data."
13871
+ },
13872
+ {
13873
+ component: "kernel",
13874
+ table: "agentSessions",
13875
+ prepopulation: "runtime_data",
13876
+ copyMode: "none",
13877
+ description: "Agent coordination sessions are created by active clients."
13878
+ },
13879
+ {
13880
+ component: "kernel",
13881
+ table: "autofixJobs",
13882
+ prepopulation: "runtime_queue",
13883
+ copyMode: "none",
13884
+ description: "Autofix work items are runtime queue rows."
13885
+ },
13886
+ {
13887
+ component: "kernel",
13888
+ table: "backgroundJobRuns",
13889
+ prepopulation: "runtime_log",
13890
+ copyMode: "none",
13891
+ description: "Background job executions are runtime logs."
13892
+ },
13893
+ {
13894
+ component: "kernel",
13895
+ table: "backgroundJobSettings",
13896
+ prepopulation: "required_template",
13897
+ copyMode: "template_global",
13898
+ scope: "global",
13899
+ uniqueKey: ["jobKey"],
13900
+ description: "Default job enablement settings must come from the K template."
13901
+ },
13902
+ {
13903
+ component: "kernel",
13904
+ table: "beliefConfidence",
13905
+ prepopulation: "runtime_data",
13906
+ copyMode: "none",
13907
+ description: "Belief confidence rows are created with tenant graph facts."
13908
+ },
13909
+ {
13910
+ component: "kernel",
13911
+ table: "beliefEvidenceLinks",
13912
+ prepopulation: "runtime_data",
13913
+ copyMode: "none",
13914
+ description: "Belief-to-evidence links are tenant graph data."
13915
+ },
13916
+ {
13917
+ component: "kernel",
13918
+ table: "beliefHistory",
13919
+ prepopulation: "runtime_data",
13920
+ copyMode: "none",
13921
+ description: "Belief history is append-only tenant graph data."
13922
+ },
13923
+ {
13924
+ component: "kernel",
13925
+ table: "beliefScenarios",
13926
+ prepopulation: "runtime_data",
13927
+ copyMode: "none",
13928
+ description: "Scenario rows are tenant-authored reasoning data."
13929
+ },
13930
+ {
13931
+ component: "kernel",
13932
+ table: "beliefVotes",
13933
+ prepopulation: "runtime_data",
13934
+ copyMode: "none",
13935
+ description: "Decision belief votes are tenant-authored data."
13936
+ },
13937
+ {
13938
+ component: "kernel",
13939
+ table: "calibrationScores",
13940
+ prepopulation: "runtime_derived",
13941
+ copyMode: "none",
13942
+ description: "Calibration scores are computed from tenant outcomes."
13943
+ },
13944
+ {
13945
+ component: "kernel",
13946
+ table: "contractEvaluations",
13947
+ prepopulation: "runtime_log",
13948
+ copyMode: "none",
13949
+ description: "Contract evaluation rows are runtime computation logs."
13950
+ },
13951
+ {
13952
+ component: "kernel",
13953
+ table: "contradictions",
13954
+ prepopulation: "runtime_data",
13955
+ copyMode: "none",
13956
+ description: "Contradictions are tenant graph facts."
13957
+ },
13958
+ {
13959
+ component: "kernel",
13960
+ table: "crossProjectConnections",
13961
+ prepopulation: "runtime_data",
13962
+ copyMode: "none",
13963
+ description: "Cross-topic connections are tenant graph facts."
13964
+ },
13965
+ {
13966
+ component: "kernel",
13967
+ table: "decisionComputedSummaries",
13968
+ prepopulation: "runtime_derived",
13969
+ copyMode: "none",
13970
+ description: "Decision summaries are derived tenant outputs."
13971
+ },
13972
+ {
13973
+ component: "kernel",
13974
+ table: "decisionEvents",
13975
+ prepopulation: "runtime_data",
13976
+ copyMode: "none",
13977
+ description: "Decision events are lifecycle data."
13978
+ },
13979
+ {
13980
+ component: "kernel",
13981
+ table: "decisionParticipants",
13982
+ prepopulation: "runtime_data",
13983
+ copyMode: "none",
13984
+ description: "Decision participants are tenant-selected actors."
13985
+ },
13986
+ {
13987
+ component: "kernel",
13988
+ table: "decisionRiskLedger",
13989
+ prepopulation: "runtime_data",
13990
+ copyMode: "none",
13991
+ description: "Decision risk rows are tenant decision data."
13992
+ },
13993
+ {
13994
+ component: "kernel",
13995
+ table: "decisionSnapshots",
13996
+ prepopulation: "runtime_derived",
13997
+ copyMode: "none",
13998
+ description: "Decision snapshots are derived from tenant state."
13999
+ },
14000
+ {
14001
+ component: "kernel",
14002
+ table: "deliberationContributions",
14003
+ prepopulation: "runtime_data",
14004
+ copyMode: "none",
14005
+ description: "Deliberation contributions are tenant-authored data."
14006
+ },
14007
+ {
14008
+ component: "kernel",
14009
+ table: "deliberationSessions",
14010
+ prepopulation: "runtime_data",
14011
+ copyMode: "none",
14012
+ description: "Deliberation sessions are created by tenant workflows."
14013
+ },
14014
+ {
14015
+ component: "kernel",
14016
+ table: "epistemicAudit",
14017
+ prepopulation: "runtime_log",
14018
+ copyMode: "none",
14019
+ description: "Epistemic audit rows are append-only runtime audit data."
14020
+ },
14021
+ {
14022
+ component: "kernel",
14023
+ table: "epistemicContracts",
14024
+ prepopulation: "runtime_data",
14025
+ copyMode: "none",
14026
+ description: "Epistemic contracts are tenant-authored governance data."
14027
+ },
14028
+ {
14029
+ component: "kernel",
14030
+ table: "epistemicEdges",
14031
+ prepopulation: "runtime_data",
14032
+ copyMode: "none",
14033
+ description: "Edges are tenant reasoning graph data."
14034
+ },
14035
+ {
14036
+ component: "kernel",
14037
+ table: "epistemicNodeEmbeddings",
14038
+ prepopulation: "runtime_derived",
14039
+ copyMode: "none",
14040
+ description: "Embeddings are derived from tenant graph nodes."
14041
+ },
14042
+ {
14043
+ component: "kernel",
14044
+ table: "epistemicNodes",
14045
+ prepopulation: "runtime_data",
14046
+ copyMode: "none",
14047
+ description: "Nodes are tenant reasoning graph data."
14048
+ },
14049
+ {
14050
+ component: "kernel",
14051
+ table: "graphAnalysisCache",
14052
+ prepopulation: "runtime_derived",
14053
+ copyMode: "none",
14054
+ description: "Graph analysis cache rows are derived from tenant graph state."
14055
+ },
14056
+ {
14057
+ component: "kernel",
14058
+ table: "graphAnalysisResults",
14059
+ prepopulation: "runtime_derived",
14060
+ copyMode: "none",
14061
+ description: "Graph analysis result rows are derived tenant outputs."
14062
+ },
14063
+ {
14064
+ component: "kernel",
14065
+ table: "graphSuggestions",
14066
+ prepopulation: "runtime_derived",
14067
+ copyMode: "none",
14068
+ description: "Graph suggestions are derived recommendations."
14069
+ },
14070
+ {
14071
+ component: "kernel",
14072
+ table: "harnessReplays",
14073
+ prepopulation: "runtime_log",
14074
+ copyMode: "none",
14075
+ description: "Harness replay rows are runtime verification logs."
14076
+ },
14077
+ {
14078
+ component: "kernel",
14079
+ table: "harnessRuns",
14080
+ prepopulation: "runtime_log",
14081
+ copyMode: "none",
14082
+ description: "Harness run rows are runtime verification logs."
14083
+ },
14084
+ {
14085
+ component: "kernel",
14086
+ table: "idempotencyTokens",
14087
+ prepopulation: "runtime_log",
14088
+ copyMode: "none",
14089
+ description: "Idempotency tokens are request-scoped runtime guards."
14090
+ },
14091
+ {
14092
+ component: "kernel",
14093
+ table: "lenses",
14094
+ prepopulation: "optional_template",
14095
+ copyMode: "none",
14096
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
14097
+ },
14098
+ {
14099
+ component: "kernel",
14100
+ table: "lensTopicBindings",
14101
+ prepopulation: "runtime_data",
14102
+ copyMode: "none",
14103
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
14104
+ },
14105
+ {
14106
+ component: "kernel",
14107
+ table: "neo4jSyncQueue",
14108
+ prepopulation: "runtime_queue",
14109
+ copyMode: "none",
14110
+ description: "Neo4j sync queue rows are runtime work items."
14111
+ },
14112
+ {
14113
+ component: "kernel",
14114
+ table: "ontologyDefinitions",
14115
+ prepopulation: "required_template",
14116
+ copyMode: "template_global",
14117
+ scope: "global",
14118
+ uniqueKey: ["ontologyKey"],
14119
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
14120
+ },
14121
+ {
14122
+ component: "kernel",
14123
+ table: "ontologyVersions",
14124
+ prepopulation: "required_template",
14125
+ copyMode: "template_reference_remap",
14126
+ scope: "global",
14127
+ uniqueKey: ["ontologyKey", "version"],
14128
+ dependsOn: ["ontologyDefinitions"],
14129
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
14130
+ },
14131
+ {
14132
+ component: "kernel",
14133
+ table: "platformAgentRunPolicyDecisions",
14134
+ prepopulation: "runtime_log",
14135
+ copyMode: "none",
14136
+ description: "Agent-run policy decisions are audit logs."
14137
+ },
14138
+ {
14139
+ component: "kernel",
14140
+ table: "platformAgentRunPromptResolutions",
14141
+ prepopulation: "runtime_log",
14142
+ copyMode: "none",
14143
+ description: "Agent-run prompt resolution rows are runtime logs."
14144
+ },
14145
+ {
14146
+ component: "kernel",
14147
+ table: "platformAgentRuns",
14148
+ prepopulation: "runtime_log",
14149
+ copyMode: "none",
14150
+ description: "Agent runs are runtime execution records."
14151
+ },
14152
+ {
14153
+ component: "kernel",
14154
+ table: "platformAgentRunToolCalls",
14155
+ prepopulation: "runtime_log",
14156
+ copyMode: "none",
14157
+ description: "Agent-run tool calls are runtime execution records."
14158
+ },
14159
+ {
14160
+ component: "kernel",
14161
+ table: "platformHarnessShadowAudit",
14162
+ prepopulation: "runtime_log",
14163
+ copyMode: "none",
14164
+ description: "Harness shadow audit rows are runtime audit records."
14165
+ },
14166
+ {
14167
+ component: "kernel",
14168
+ table: "publicationRules",
14169
+ prepopulation: "required_template",
14170
+ copyMode: "template_tenant_rewrite",
14171
+ scope: "tenant",
14172
+ uniqueKey: ["tenantId", "workspaceId", "name"],
14173
+ description: "Default publication policy rules are rewritten into each tenant."
14174
+ },
14175
+ {
14176
+ component: "kernel",
14177
+ table: "questionEvidenceLinks",
14178
+ prepopulation: "runtime_data",
14179
+ copyMode: "none",
14180
+ description: "Question-to-evidence links are tenant graph data."
14181
+ },
14182
+ {
14183
+ component: "kernel",
14184
+ table: "researchJobs",
14185
+ prepopulation: "runtime_queue",
14186
+ copyMode: "none",
14187
+ description: "Research job rows are runtime queue items."
14188
+ },
14189
+ {
14190
+ component: "kernel",
14191
+ table: "schemaEnumConfig",
14192
+ prepopulation: "required_template",
14193
+ copyMode: "template_global",
14194
+ scope: "global",
14195
+ uniqueKey: ["category", "value"],
14196
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
14197
+ },
14198
+ {
14199
+ component: "kernel",
14200
+ table: "stakeholderGroups",
14201
+ prepopulation: "runtime_data",
14202
+ copyMode: "none",
14203
+ description: "Stakeholder groups are tenant decision data."
14204
+ },
14205
+ {
14206
+ component: "kernel",
14207
+ table: "systemLogs",
14208
+ prepopulation: "runtime_log",
14209
+ copyMode: "none",
14210
+ description: "System logs are runtime telemetry."
14211
+ },
14212
+ {
14213
+ component: "kernel",
14214
+ table: "tasks",
14215
+ prepopulation: "runtime_data",
14216
+ copyMode: "none",
14217
+ description: "Tasks are tenant-authored work items."
14218
+ },
14219
+ {
14220
+ component: "kernel",
14221
+ table: "topics",
14222
+ prepopulation: "runtime_bootstrap",
14223
+ copyMode: "none",
14224
+ description: "Default topics are created by tenant provisioning, not copied from templates."
14225
+ },
14226
+ {
14227
+ component: "kernel",
14228
+ table: "workflowDefinitions",
14229
+ prepopulation: "optional_template",
14230
+ copyMode: "none",
14231
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
14232
+ },
14233
+ {
14234
+ component: "kernel",
14235
+ table: "workflowPullRequests",
14236
+ prepopulation: "runtime_data",
14237
+ copyMode: "none",
14238
+ description: "Workflow pull requests are tenant workflow data."
14239
+ },
14240
+ {
14241
+ component: "kernel",
14242
+ table: "workflowStages",
14243
+ prepopulation: "optional_template",
14244
+ copyMode: "none",
14245
+ dependsOn: ["workflowDefinitions"],
14246
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
14247
+ },
14248
+ {
14249
+ component: "kernel",
14250
+ table: "worktreeBeliefCluster",
14251
+ prepopulation: "runtime_data",
14252
+ copyMode: "none",
14253
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
14254
+ },
14255
+ {
14256
+ component: "kernel",
14257
+ table: "worktrees",
14258
+ prepopulation: "runtime_data",
14259
+ copyMode: "none",
14260
+ description: "Worktrees are tenant/runtime planning data."
14261
+ },
14262
+ {
14263
+ component: "identity",
14264
+ table: "agents",
14265
+ prepopulation: "runtime_bootstrap",
14266
+ copyMode: "none",
14267
+ description: "Service agents are provisioned per tenant or service, not copied."
14268
+ },
14269
+ {
14270
+ component: "identity",
14271
+ table: "mcpWritePolicy",
14272
+ prepopulation: "required_template",
14273
+ copyMode: "template_global",
14274
+ scope: "global",
14275
+ uniqueKey: ["topicId", "role", "toolCategory"],
14276
+ description: "Global write policy defaults govern service and interactive MCP writes."
14277
+ },
14278
+ {
14279
+ component: "identity",
14280
+ table: "modelCallLogs",
14281
+ prepopulation: "runtime_log",
14282
+ copyMode: "none",
14283
+ description: "Model call logs are runtime telemetry."
14284
+ },
14285
+ {
14286
+ component: "identity",
14287
+ table: "modelFunctionSlots",
14288
+ prepopulation: "required_template",
14289
+ copyMode: "template_global",
14290
+ scope: "global",
14291
+ uniqueKey: ["slot"],
14292
+ description: "Function-to-model slots are required by model runtime resolution."
14293
+ },
14294
+ {
14295
+ component: "identity",
14296
+ table: "modelRegistry",
14297
+ prepopulation: "required_template",
14298
+ copyMode: "template_global",
14299
+ scope: "global",
14300
+ uniqueKey: ["key"],
14301
+ description: "Model catalog defaults are required by model runtime clients."
14302
+ },
14303
+ {
14304
+ component: "identity",
14305
+ table: "modelSlotConfigs",
14306
+ prepopulation: "required_template",
14307
+ copyMode: "template_global",
14308
+ scope: "global",
14309
+ uniqueKey: ["slot"],
14310
+ description: "Slot-level defaults are required before tenant overrides exist."
14311
+ },
14312
+ {
14313
+ component: "identity",
14314
+ table: "platformAudienceGrants",
14315
+ prepopulation: "runtime_data",
14316
+ copyMode: "none",
14317
+ description: "Audience grants are principal/group-specific access rows."
14318
+ },
14319
+ {
14320
+ component: "identity",
14321
+ table: "platformAudiences",
14322
+ prepopulation: "required_template",
14323
+ copyMode: "template_tenant_rewrite",
14324
+ scope: "tenant",
14325
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
14326
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
14327
+ },
14328
+ {
14329
+ component: "identity",
14330
+ table: "platformPolicyDecisionLogs",
14331
+ prepopulation: "runtime_log",
14332
+ copyMode: "none",
14333
+ description: "Policy decisions are runtime audit logs."
14334
+ },
14335
+ {
14336
+ component: "identity",
14337
+ table: "projectGrants",
14338
+ prepopulation: "runtime_data",
14339
+ copyMode: "none",
14340
+ description: "Project/topic grants are principal or group-specific access rows."
14341
+ },
14342
+ {
14343
+ component: "identity",
14344
+ table: "reasoningPermissions",
14345
+ prepopulation: "runtime_data",
14346
+ copyMode: "none",
14347
+ description: "Reasoning permissions are principal-specific policy rows."
14348
+ },
14349
+ {
14350
+ component: "identity",
14351
+ table: "tenantApiKeys",
14352
+ prepopulation: "runtime_secret",
14353
+ copyMode: "none",
14354
+ description: "API keys are tenant credentials and must never be copied."
14355
+ },
14356
+ {
14357
+ component: "identity",
14358
+ table: "tenantConfig",
14359
+ prepopulation: "required_template",
14360
+ copyMode: "template_tenant_rewrite",
14361
+ scope: "tenant",
14362
+ uniqueKey: ["tenantId"],
14363
+ description: "Tenant-local config defaults are rewritten during bootstrap."
14364
+ },
14365
+ {
14366
+ component: "identity",
14367
+ table: "tenantIntegrations",
14368
+ prepopulation: "required_template",
14369
+ copyMode: "template_tenant_rewrite",
14370
+ scope: "tenant",
14371
+ uniqueKey: ["tenantId", "integrationKey"],
14372
+ description: "Non-secret integration descriptors are rewritten into each tenant."
14373
+ },
14374
+ {
14375
+ component: "identity",
14376
+ table: "tenantModelSlotBindings",
14377
+ prepopulation: "runtime_secret",
14378
+ copyMode: "none",
14379
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
14380
+ },
14381
+ {
14382
+ component: "identity",
14383
+ table: "tenantPolicies",
14384
+ prepopulation: "required_template",
14385
+ copyMode: "template_tenant_rewrite",
14386
+ scope: "tenant",
14387
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
14388
+ description: "Default tenant policy roles are rewritten during bootstrap."
14389
+ },
14390
+ {
14391
+ component: "identity",
14392
+ table: "tenantProviderSecrets",
14393
+ prepopulation: "runtime_secret",
14394
+ copyMode: "none",
14395
+ description: "Provider secrets are credentials and must never be copied."
14396
+ },
14397
+ {
14398
+ component: "identity",
14399
+ table: "tenantProxyGatewayUsage",
14400
+ prepopulation: "runtime_log",
14401
+ copyMode: "none",
14402
+ description: "Proxy gateway usage rows are runtime telemetry."
14403
+ },
14404
+ {
14405
+ component: "identity",
14406
+ table: "tenantProxyTokenMints",
14407
+ prepopulation: "runtime_secret",
14408
+ copyMode: "none",
14409
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
14410
+ },
14411
+ {
14412
+ component: "identity",
14413
+ table: "tenantSandboxAuditEvents",
14414
+ prepopulation: "runtime_log",
14415
+ copyMode: "none",
14416
+ description: "Sandbox audit rows are runtime security logs."
14417
+ },
14418
+ {
14419
+ component: "identity",
14420
+ table: "tenantSecrets",
14421
+ prepopulation: "runtime_secret",
14422
+ copyMode: "none",
14423
+ description: "Tenant secrets are credentials and must never be copied."
14424
+ },
14425
+ {
14426
+ component: "identity",
14427
+ table: "toolAcls",
14428
+ prepopulation: "required_template",
14429
+ copyMode: "template_global",
14430
+ scope: "global",
14431
+ uniqueKey: ["role", "toolName"],
14432
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
14433
+ },
14434
+ {
14435
+ component: "identity",
14436
+ table: "toolRegistry",
14437
+ prepopulation: "required_template",
14438
+ copyMode: "template_global",
14439
+ scope: "global",
14440
+ uniqueKey: ["toolName"],
14441
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
14442
+ },
14443
+ {
14444
+ component: "identity",
14445
+ table: "users",
14446
+ prepopulation: "runtime_bootstrap",
14447
+ copyMode: "none",
14448
+ description: "Users are created from Clerk/MC principal resolution, not copied."
14449
+ }
14450
+ ];
14451
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14452
+ isCopyableSeedRequirement
14453
+ );
14454
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14455
+ (entry) => !isCopyableSeedRequirement(entry)
14456
+ ).map((entry) => entry.table);
11406
14457
 
11407
14458
  // src/webhooks.ts
11408
14459
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
14460
+ function invalidWebhookUrlError(error) {
14461
+ return new Error("Webhook URL must be a valid absolute URL.", {
14462
+ cause: error
14463
+ });
14464
+ }
11409
14465
  function normalizeUrl(url) {
11410
14466
  try {
11411
14467
  return new URL(url.trim());
11412
- } catch {
11413
- throw new Error("Webhook URL must be a valid absolute URL.");
14468
+ } catch (error) {
14469
+ throw invalidWebhookUrlError(error);
11414
14470
  }
11415
14471
  }
11416
14472
  function assertValidWebhookUrl(url) {