@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/types.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 DOMAIN_EVENT_VERSION = "1.0";
6
487
  var EVENT_RETENTION_DEFAULT_DAYS = 30;
@@ -60,7 +541,10 @@ function idOf(table) {
60
541
  return schema;
61
542
  }
62
543
  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"]);
63
- 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"]);
544
+ 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"];
545
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
546
+ z.enum(EDGE_TYPE_VALUES);
547
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
64
548
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
65
549
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
66
550
  defineTable({
@@ -1545,7 +2029,7 @@ defineTable({
1545
2029
  "toNodeId": z.string().optional(),
1546
2030
  "sourceGlobalId": z.string().optional(),
1547
2031
  "targetGlobalId": z.string().optional(),
1548
- "edgeType": EDGE_TYPE,
2032
+ "edgeType": STORAGE_EDGE_TYPE,
1549
2033
  "edgeTier": z.string().optional(),
1550
2034
  "domainNamespace": z.string().optional(),
1551
2035
  "constraint": z.string().optional(),
@@ -1888,6 +2372,40 @@ defineTable({
1888
2372
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
1889
2373
  ]
1890
2374
  });
2375
+ defineTable({
2376
+ name: "oauthDeviceCodes",
2377
+ component: "mc",
2378
+ category: "identity",
2379
+ shape: z.object({
2380
+ "deviceCodeHash": z.string(),
2381
+ "userCode": z.string(),
2382
+ "clientId": z.string(),
2383
+ "scope": z.string(),
2384
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
2385
+ "expiresAt": z.number(),
2386
+ "intervalSeconds": z.number(),
2387
+ "lastPolledAt": z.number().optional(),
2388
+ "slowDownCount": z.number().optional(),
2389
+ "clerkUserId": z.string().optional(),
2390
+ "tenantId": idOf("tenants").optional(),
2391
+ "workspaceId": z.string().optional(),
2392
+ "principalId": z.string().optional(),
2393
+ "role": z.string().optional(),
2394
+ "scopes": z.array(z.string()).optional(),
2395
+ "sessionId": z.string().optional(),
2396
+ "approvedAt": z.number().optional(),
2397
+ "deniedAt": z.number().optional(),
2398
+ "consumedAt": z.number().optional(),
2399
+ "createdAt": z.number(),
2400
+ "updatedAt": z.number()
2401
+ }),
2402
+ indices: [
2403
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
2404
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
2405
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
2406
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
2407
+ ]
2408
+ });
1891
2409
  defineTable({
1892
2410
  name: "servicePrincipalKeys",
1893
2411
  component: "mc",
@@ -3720,6 +4238,7 @@ defineTable({
3720
4238
  "updatedAt": z.number()
3721
4239
  }),
3722
4240
  indices: [
4241
+ { kind: "index", name: "by_globalId", columns: ["globalId"] },
3723
4242
  { kind: "index", name: "by_parent", columns: ["parentTopicId"] },
3724
4243
  { kind: "index", name: "by_type", columns: ["type"] },
3725
4244
  { kind: "index", name: "by_graph_scope_project", columns: ["graphScopeProjectId"] },
@@ -3844,7 +4363,9 @@ defineTable({
3844
4363
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3845
4364
  "deployments": z.record(z.object({
3846
4365
  "url": z.string(),
3847
- "encryptedDeployKey": z.string()
4366
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4367
+ "encryptedDeployKey": z.string().optional(),
4368
+ "credentialRef": z.string().optional()
3848
4369
  })).optional(),
3849
4370
  "metadata": z.record(z.any()).optional(),
3850
4371
  "createdBy": z.string().optional(),
@@ -4194,17 +4715,44 @@ z.object({
4194
4715
  message: "SL invariant b+d+u=1 violated at API boundary"
4195
4716
  }
4196
4717
  );
4197
- var EpistemicNodeTypeSchema = z.enum([
4718
+
4719
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
4720
+ var NODE_TYPES = [
4721
+ "decision",
4198
4722
  "belief",
4199
- "evidence",
4200
4723
  "question",
4201
- "answer",
4724
+ "theme",
4725
+ "deal",
4202
4726
  "topic",
4727
+ "claim",
4728
+ "evidence",
4729
+ "synthesis",
4730
+ "answer",
4731
+ "atomic_fact",
4732
+ "excerpt",
4733
+ "source",
4734
+ "company",
4735
+ "person",
4736
+ "investor",
4737
+ "function",
4738
+ "value_chain"
4739
+ ];
4740
+ new Set(NODE_TYPES);
4741
+
4742
+ // ../contracts/src/types/graph-ref.ts
4743
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4203
4744
  "edge",
4204
4745
  "ontology",
4205
4746
  "lens",
4206
4747
  "contradiction"
4207
- ]);
4748
+ ];
4749
+ var GRAPH_REF_NODE_TYPES = [
4750
+ ...NODE_TYPES,
4751
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4752
+ ];
4753
+ var EpistemicNodeTypeSchema = z.enum(
4754
+ GRAPH_REF_NODE_TYPES
4755
+ );
4208
4756
  var GraphRefSchema = z.discriminatedUnion("kind", [
4209
4757
  z.object({
4210
4758
  kind: z.literal("epistemic_node"),
@@ -4252,34 +4800,142 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4252
4800
  }
4253
4801
 
4254
4802
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
4803
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
4804
+ edgeType,
4805
+ fromKinds: ["epistemic_node"],
4806
+ toKinds: ["epistemic_node"],
4807
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
4808
+ });
4255
4809
  var edgePolicyManifest = {
4256
- policies: [
4257
- {
4258
- edgeType: "evidence_derived_from_evidence",
4259
- fromKinds: ["epistemic_node"],
4260
- fromNodeTypes: ["evidence"],
4261
- toKinds: ["epistemic_node"],
4262
- toNodeTypes: ["evidence"],
4263
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4264
- },
4265
- {
4266
- edgeType: "evidence_supports_belief",
4267
- fromKinds: ["epistemic_node"],
4268
- fromNodeTypes: ["evidence"],
4269
- toKinds: ["epistemic_node"],
4270
- toNodeTypes: ["belief"],
4271
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4272
- },
4273
- {
4274
- edgeType: "evidence_supports_question",
4275
- fromKinds: ["epistemic_node"],
4276
- fromNodeTypes: ["evidence"],
4277
- toKinds: ["epistemic_node"],
4278
- toNodeTypes: ["question"],
4279
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4280
- }
4281
- ]
4810
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
4282
4811
  };
4812
+
4813
+ // ../contracts/src/tenant-client.contract.ts
4814
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4815
+ {
4816
+ packageName: "@lucern/access-control",
4817
+ role: "runtime_entrypoint",
4818
+ directTenantImport: true
4819
+ },
4820
+ {
4821
+ packageName: "@lucern/agent",
4822
+ role: "platform_runtime",
4823
+ directTenantImport: false
4824
+ },
4825
+ {
4826
+ packageName: "@lucern/auth",
4827
+ role: "sdk_dependency",
4828
+ directTenantImport: false
4829
+ },
4830
+ {
4831
+ packageName: "@lucern/cli",
4832
+ role: "developer_tool",
4833
+ directTenantImport: false
4834
+ },
4835
+ {
4836
+ packageName: "@lucern/client-core",
4837
+ role: "sdk_dependency",
4838
+ directTenantImport: false
4839
+ },
4840
+ {
4841
+ packageName: "@lucern/confidence",
4842
+ role: "sdk_dependency",
4843
+ directTenantImport: false
4844
+ },
4845
+ {
4846
+ packageName: "@lucern/config",
4847
+ role: "configuration",
4848
+ directTenantImport: false
4849
+ },
4850
+ {
4851
+ packageName: "@lucern/contracts",
4852
+ role: "contract_entrypoint",
4853
+ directTenantImport: true
4854
+ },
4855
+ {
4856
+ packageName: "@lucern/control-plane",
4857
+ role: "platform_runtime",
4858
+ directTenantImport: false
4859
+ },
4860
+ {
4861
+ packageName: "@lucern/developer-kit",
4862
+ role: "developer_tool",
4863
+ directTenantImport: false
4864
+ },
4865
+ {
4866
+ packageName: "@lucern/events",
4867
+ role: "sdk_dependency",
4868
+ directTenantImport: false
4869
+ },
4870
+ {
4871
+ packageName: "@lucern/graph-primitives",
4872
+ role: "sdk_dependency",
4873
+ directTenantImport: false
4874
+ },
4875
+ {
4876
+ packageName: "@lucern/graph-sync",
4877
+ role: "host_addon_runtime",
4878
+ directTenantImport: true
4879
+ },
4880
+ {
4881
+ packageName: "@lucern/identity",
4882
+ role: "component_runtime",
4883
+ directTenantImport: false
4884
+ },
4885
+ {
4886
+ packageName: "@lucern/mcp",
4887
+ role: "runtime_entrypoint",
4888
+ directTenantImport: true
4889
+ },
4890
+ {
4891
+ packageName: "@lucern/pack-host",
4892
+ role: "platform_runtime",
4893
+ directTenantImport: false
4894
+ },
4895
+ {
4896
+ packageName: "@lucern/pack-installer",
4897
+ role: "developer_tool",
4898
+ directTenantImport: false
4899
+ },
4900
+ {
4901
+ packageName: "@lucern/proof-compiler",
4902
+ role: "developer_tool",
4903
+ directTenantImport: false
4904
+ },
4905
+ {
4906
+ packageName: "@lucern/react",
4907
+ role: "runtime_entrypoint",
4908
+ directTenantImport: true
4909
+ },
4910
+ {
4911
+ packageName: "@lucern/reasoning-kernel",
4912
+ role: "component_runtime",
4913
+ directTenantImport: false
4914
+ },
4915
+ {
4916
+ packageName: "@lucern/sdk",
4917
+ role: "runtime_entrypoint",
4918
+ directTenantImport: true
4919
+ },
4920
+ {
4921
+ packageName: "@lucern/server-core",
4922
+ role: "platform_runtime",
4923
+ directTenantImport: false
4924
+ },
4925
+ {
4926
+ packageName: "@lucern/testing",
4927
+ role: "test_support",
4928
+ directTenantImport: false
4929
+ },
4930
+ {
4931
+ packageName: "@lucern/types",
4932
+ role: "contract_entrypoint",
4933
+ directTenantImport: true
4934
+ }
4935
+ ];
4936
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
4937
+ (entry) => entry.packageName
4938
+ );
4283
4939
  z.object({
4284
4940
  manifestVersion: z.literal("1.0.0"),
4285
4941
  rules: z.array(
@@ -4340,8 +4996,11 @@ function compactRecord(input) {
4340
4996
  Object.entries(input).filter(([, value]) => value !== void 0)
4341
4997
  );
4342
4998
  }
4999
+ function isRecord(value) {
5000
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5001
+ }
4343
5002
  function recordValue(value) {
4344
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
5003
+ return isRecord(value) ? value : {};
4345
5004
  }
4346
5005
  var createEvidenceProjection = defineProjection({
4347
5006
  contractName: "create_evidence",
@@ -5041,7 +5700,22 @@ var ADD_WORKTREE = {
5041
5700
  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.",
5042
5701
  parameters: {
5043
5702
  title: { type: "string", description: "Worktree name/objective" },
5044
- topicId: { type: "string", description: "Optional topic scope hint" },
5703
+ name: {
5704
+ type: "string",
5705
+ description: "Optional storage-name alias for callers that already use backend naming"
5706
+ },
5707
+ projectId: {
5708
+ type: "string",
5709
+ description: "Legacy topicId alias or resolver hint"
5710
+ },
5711
+ topicId: {
5712
+ type: "string",
5713
+ description: "Optional topic scope hint for resolver validation"
5714
+ },
5715
+ topicHint: {
5716
+ type: "string",
5717
+ description: "Natural-language topic hint for automatic topic resolution"
5718
+ },
5045
5719
  branchId: {
5046
5720
  type: "string",
5047
5721
  description: "The branch this worktree investigates"
@@ -5054,18 +5728,107 @@ var ADD_WORKTREE = {
5054
5728
  type: "string",
5055
5729
  description: "The testable claim this worktree investigates"
5056
5730
  },
5731
+ rationale: {
5732
+ type: "string",
5733
+ description: "Why this worktree exists and why it belongs in the campaign"
5734
+ },
5735
+ worktreeType: {
5736
+ type: "string",
5737
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5738
+ },
5739
+ gate: {
5740
+ type: "string",
5741
+ description: "Exit gate name for this worktree"
5742
+ },
5743
+ startDate: {
5744
+ type: "number",
5745
+ description: "Planned start timestamp in milliseconds since epoch"
5746
+ },
5747
+ endDate: {
5748
+ type: "number",
5749
+ description: "Planned end timestamp in milliseconds since epoch"
5750
+ },
5751
+ durationWeeks: {
5752
+ type: "number",
5753
+ description: "Planned duration in weeks"
5754
+ },
5755
+ confidenceImpact: {
5756
+ type: "string",
5757
+ description: "Expected confidence impact if the worktree succeeds",
5758
+ enum: ["high", "medium", "low"]
5759
+ },
5760
+ beliefFocus: {
5761
+ type: "string",
5762
+ description: "Natural-language focus spanning the target belief neighborhood"
5763
+ },
5057
5764
  beliefIds: {
5058
5765
  type: "array",
5059
- description: "Beliefs to test in this worktree"
5766
+ description: "Legacy alias for targetBeliefIds"
5767
+ },
5768
+ beliefs: {
5769
+ type: "array",
5770
+ description: "Legacy alias for targetBeliefIds"
5771
+ },
5772
+ targetBeliefIds: {
5773
+ type: "array",
5774
+ description: "Belief node IDs this worktree is expected to test or update"
5775
+ },
5776
+ targetQuestionIds: {
5777
+ type: "array",
5778
+ description: "Question node IDs this worktree is expected to answer"
5779
+ },
5780
+ keyQuestions: {
5781
+ type: "array",
5782
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5783
+ },
5784
+ evidenceSignals: {
5785
+ type: "array",
5786
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5787
+ },
5788
+ decisionGate: {
5789
+ type: "object",
5790
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5791
+ },
5792
+ goCriteria: {
5793
+ type: "array",
5794
+ description: "Shorthand go criteria used to build decisionGate"
5795
+ },
5796
+ noGoSignals: {
5797
+ type: "array",
5798
+ description: "Shorthand no-go signals used to build decisionGate"
5799
+ },
5800
+ proofArtifacts: {
5801
+ type: "array",
5802
+ description: "Expected proof artifacts required to close the worktree"
5060
5803
  },
5061
5804
  autoShape: {
5062
5805
  type: "boolean",
5063
5806
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5064
5807
  },
5808
+ autoFixPolicy: {
5809
+ type: "object",
5810
+ description: "Policy for permitted automatic remediation inside the worktree"
5811
+ },
5065
5812
  domainPackId: {
5066
5813
  type: "string",
5067
5814
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5068
5815
  },
5816
+ tags: {
5817
+ type: "array",
5818
+ description: "Additional topic-resolution tags for the worktree"
5819
+ },
5820
+ touchedPaths: {
5821
+ type: "array",
5822
+ description: "File paths used as topic-resolution signals"
5823
+ },
5824
+ sourceRef: {
5825
+ type: "string",
5826
+ description: "Source reference used as a topic-resolution signal"
5827
+ },
5828
+ sourceKind: {
5829
+ type: "string",
5830
+ description: "Source kind used as a topic-resolution signal"
5831
+ },
5069
5832
  campaign: {
5070
5833
  type: "number",
5071
5834
  description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
@@ -5090,13 +5853,21 @@ var ADD_WORKTREE = {
5090
5853
  type: "array",
5091
5854
  description: "Worktree IDs blocked by this worktree"
5092
5855
  },
5093
- gate: {
5856
+ staffingHint: {
5094
5857
  type: "string",
5095
- description: "Exit gate name for this worktree"
5096
- }
5097
- },
5098
- required: ["title", "topicId"],
5099
- response: {
5858
+ description: "Suggested staffing or agent allocation note"
5859
+ },
5860
+ lensId: {
5861
+ type: "string",
5862
+ description: "Lens that scopes this worktree when applicable"
5863
+ },
5864
+ lastReconciledAt: {
5865
+ type: "number",
5866
+ description: "Timestamp when worktree metadata was last reconciled"
5867
+ }
5868
+ },
5869
+ required: ["title"],
5870
+ response: {
5100
5871
  description: "The created worktree",
5101
5872
  fields: {
5102
5873
  worktreeId: "string",
@@ -5122,7 +5893,7 @@ var MERGE = {
5122
5893
  worktreeId: { type: "string", description: "The worktree to merge" },
5123
5894
  outcomes: {
5124
5895
  type: "array",
5125
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5896
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5126
5897
  },
5127
5898
  summary: { type: "string", description: "Overall findings summary" }
5128
5899
  },
@@ -5340,19 +6111,23 @@ var FIND_CONTRADICTIONS = {
5340
6111
  };
5341
6112
  var CREATE_EDGE = {
5342
6113
  name: "create_edge",
5343
- 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).",
6114
+ 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.",
5344
6115
  parameters: {
5345
- sourceId: {
5346
- type: "string",
5347
- description: "Source node of the relationship"
6116
+ from: {
6117
+ type: "object",
6118
+ description: "Source graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'topic' }"
5348
6119
  },
5349
- targetId: {
5350
- type: "string",
5351
- description: "Target node of the relationship"
6120
+ to: {
6121
+ type: "object",
6122
+ description: "Target graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'belief' }"
5352
6123
  },
5353
6124
  edgeType: {
5354
6125
  type: "string",
5355
- description: "Relationship type (informs, tests, depends_on, supersedes, etc.)"
6126
+ description: "Relationship type from the public epistemic edge enum."
6127
+ },
6128
+ globalId: {
6129
+ type: "string",
6130
+ description: "Optional idempotent edge global ID."
5356
6131
  },
5357
6132
  weight: {
5358
6133
  type: "number",
@@ -5363,9 +6138,13 @@ var CREATE_EDGE = {
5363
6138
  type: "string",
5364
6139
  description: "How this was determined",
5365
6140
  enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
6141
+ },
6142
+ metadata: {
6143
+ type: "object",
6144
+ description: "Optional edge metadata."
5366
6145
  }
5367
6146
  },
5368
- required: ["sourceId", "targetId", "edgeType"],
6147
+ required: ["from", "to", "edgeType"],
5369
6148
  response: {
5370
6149
  description: "The created edge",
5371
6150
  fields: {
@@ -5379,6 +6158,240 @@ var CREATE_EDGE = {
5379
6158
  ontologyPrimitive: "edge",
5380
6159
  tier: "showcase"
5381
6160
  };
6161
+ var UPDATE_EDGE = {
6162
+ name: "update_edge",
6163
+ description: "Amend metadata on an existing graph edge. Like `git commit --amend` \u2014 changes the edge annotation without recreating the relationship.",
6164
+ parameters: {
6165
+ edgeId: { type: "string", description: "Edge ID or global ID to update" },
6166
+ weight: { type: "number", description: "Updated edge weight" },
6167
+ confidence: { type: "number", description: "Updated confidence" },
6168
+ context: { type: "string", description: "Updated human-readable context" },
6169
+ derivationType: { type: "string", description: "Updated derivation type" },
6170
+ metadata: { type: "object", description: "Updated metadata" }
6171
+ },
6172
+ required: ["edgeId"],
6173
+ response: {
6174
+ description: "Edge update result",
6175
+ fields: { success: "boolean" }
6176
+ },
6177
+ ownerModule: "graph-primitives",
6178
+ ontologyPrimitive: "edge",
6179
+ tier: "workhorse"
6180
+ };
6181
+ var REMOVE_EDGE = {
6182
+ name: "remove_edge",
6183
+ description: "Remove one graph edge by ID. Like `git rm` \u2014 deletes a single explicit relationship from the spine.",
6184
+ parameters: {
6185
+ edgeId: { type: "string", description: "Edge ID or global ID to remove" }
6186
+ },
6187
+ required: ["edgeId"],
6188
+ response: {
6189
+ description: "Edge removal result",
6190
+ fields: { success: "boolean" }
6191
+ },
6192
+ ownerModule: "graph-primitives",
6193
+ ontologyPrimitive: "edge",
6194
+ tier: "workhorse"
6195
+ };
6196
+ var REMOVE_EDGES_BETWEEN = {
6197
+ name: "remove_edges_between",
6198
+ description: "Remove graph edges between two nodes. Like `git rm <pathspec>` \u2014 deletes relationships matching a source, target, and optional type.",
6199
+ parameters: {
6200
+ fromNodeId: { type: "string", description: "Source node ID or global ID" },
6201
+ toNodeId: { type: "string", description: "Target node ID or global ID" },
6202
+ edgeType: { type: "string", description: "Optional edge type filter" }
6203
+ },
6204
+ required: ["fromNodeId", "toNodeId"],
6205
+ response: {
6206
+ description: "Matched edge removal result",
6207
+ fields: { deleted: "number" }
6208
+ },
6209
+ ownerModule: "graph-primitives",
6210
+ ontologyPrimitive: "edge",
6211
+ tier: "workhorse"
6212
+ };
6213
+ var BATCH_CREATE_EDGES = {
6214
+ name: "batch_create_edges",
6215
+ description: "Commit multiple typed graph edges. Like `git commit` with many staged paths \u2014 writes a batch of explicit relationships atomically per edge.",
6216
+ parameters: {
6217
+ edges: {
6218
+ type: "array",
6219
+ description: "Edges to create, each with from, to, edgeType, and optional weight/confidence/context."
6220
+ },
6221
+ skipLayerValidation: {
6222
+ type: "boolean",
6223
+ description: "Skip kernel layer validation for trusted materialization flows."
6224
+ }
6225
+ },
6226
+ required: ["edges"],
6227
+ response: {
6228
+ description: "Batch edge creation result",
6229
+ fields: {
6230
+ created: "number",
6231
+ results: "array",
6232
+ errors: "array"
6233
+ }
6234
+ },
6235
+ ownerModule: "graph-primitives",
6236
+ ontologyPrimitive: "edge",
6237
+ tier: "workhorse"
6238
+ };
6239
+ var CREATE_EPISTEMIC_NODE = {
6240
+ name: "create_epistemic_node",
6241
+ 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.",
6242
+ parameters: {
6243
+ globalId: { type: "string", description: "Optional idempotent node global ID" },
6244
+ nodeType: { type: "string", description: "Public epistemic node type" },
6245
+ canonicalText: { type: "string", description: "Canonical node text" },
6246
+ text: { type: "string", description: "Alias for canonicalText" },
6247
+ contentHash: { type: "string", description: "Optional idempotency content hash" },
6248
+ sourceType: { type: "string", description: "Source type for provenance" },
6249
+ topicId: { type: "string", description: "Optional topic scope" },
6250
+ content: { type: "string", description: "Extended content" },
6251
+ title: { type: "string", description: "Display title" },
6252
+ metadata: { type: "object", description: "Optional node metadata" }
6253
+ },
6254
+ required: ["nodeType"],
6255
+ response: {
6256
+ description: "Created node result",
6257
+ fields: {
6258
+ nodeId: "string",
6259
+ nodeGlobalId: "string",
6260
+ isDuplicate: "boolean"
6261
+ }
6262
+ },
6263
+ ownerModule: "reasoning-kernel",
6264
+ ontologyPrimitive: "graph",
6265
+ tier: "showcase"
6266
+ };
6267
+ var GET_EPISTEMIC_NODE = {
6268
+ name: "get_epistemic_node",
6269
+ description: "Read one epistemic graph node. Like `git show` \u2014 resolves a canonical spine node by ID or global ID.",
6270
+ parameters: {
6271
+ nodeId: { type: "string", description: "Node ID or global ID" }
6272
+ },
6273
+ required: ["nodeId"],
6274
+ response: {
6275
+ description: "The resolved node",
6276
+ fields: { node: "object" }
6277
+ },
6278
+ ownerModule: "reasoning-kernel",
6279
+ ontologyPrimitive: "graph",
6280
+ tier: "workhorse"
6281
+ };
6282
+ var LIST_EPISTEMIC_NODES = {
6283
+ name: "list_epistemic_nodes",
6284
+ description: "List epistemic graph nodes. Like `git ls-tree` \u2014 lists canonical spine nodes by topic, type, status, or search query.",
6285
+ parameters: {
6286
+ topicId: { type: "string", description: "Optional topic scope" },
6287
+ nodeType: { type: "string", description: "Optional node type filter" },
6288
+ status: { type: "string", description: "Optional lifecycle status" },
6289
+ searchQuery: { type: "string", description: "Optional text search query" },
6290
+ limit: { type: "number", description: "Maximum nodes to return" }
6291
+ },
6292
+ required: [],
6293
+ response: {
6294
+ description: "Matching nodes",
6295
+ fields: { nodes: "array" }
6296
+ },
6297
+ ownerModule: "reasoning-kernel",
6298
+ ontologyPrimitive: "graph",
6299
+ tier: "workhorse"
6300
+ };
6301
+ var UPDATE_EPISTEMIC_NODE = {
6302
+ name: "update_epistemic_node",
6303
+ description: "Amend an epistemic graph node. Like `git commit --amend` \u2014 updates mutable node metadata, text, status, or verification fields.",
6304
+ parameters: {
6305
+ nodeId: { type: "string", description: "Node ID or global ID" },
6306
+ canonicalText: { type: "string", description: "Updated canonical text" },
6307
+ text: { type: "string", description: "Alias for canonicalText" },
6308
+ contentHash: { type: "string", description: "Updated content hash" },
6309
+ content: { type: "string", description: "Updated content" },
6310
+ title: { type: "string", description: "Updated display title" },
6311
+ metadata: { type: "object", description: "Updated metadata" },
6312
+ confidence: { type: "number", description: "Updated confidence" },
6313
+ verificationStatus: { type: "string", description: "Updated verification status" },
6314
+ status: { type: "string", description: "Updated lifecycle status" }
6315
+ },
6316
+ required: ["nodeId"],
6317
+ response: {
6318
+ description: "Node update result",
6319
+ fields: { success: "boolean" }
6320
+ },
6321
+ ownerModule: "reasoning-kernel",
6322
+ ontologyPrimitive: "graph",
6323
+ tier: "workhorse"
6324
+ };
6325
+ var ARCHIVE_EPISTEMIC_NODE = {
6326
+ name: "archive_epistemic_node",
6327
+ description: "Archive an epistemic graph node. Like `git rm --cached` \u2014 removes a node from active traversal without hard-deleting it.",
6328
+ parameters: {
6329
+ nodeId: { type: "string", description: "Node ID or global ID" }
6330
+ },
6331
+ required: ["nodeId"],
6332
+ response: {
6333
+ description: "Archive result",
6334
+ fields: { success: "boolean", effectiveStatus: "string" }
6335
+ },
6336
+ ownerModule: "reasoning-kernel",
6337
+ ontologyPrimitive: "graph",
6338
+ tier: "workhorse"
6339
+ };
6340
+ var VERIFY_EPISTEMIC_NODE = {
6341
+ name: "verify_epistemic_node",
6342
+ description: "Record verification state on an epistemic graph node. Like `git tag` \u2014 marks the node with a reviewed verification state.",
6343
+ parameters: {
6344
+ nodeId: { type: "string", description: "Node ID or global ID" },
6345
+ verificationStatus: { type: "string", description: "Verification status" },
6346
+ confidence: { type: "number", description: "Optional confidence update" }
6347
+ },
6348
+ required: ["nodeId", "verificationStatus"],
6349
+ response: {
6350
+ description: "Verification result",
6351
+ fields: { success: "boolean" }
6352
+ },
6353
+ ownerModule: "reasoning-kernel",
6354
+ ontologyPrimitive: "graph",
6355
+ tier: "workhorse"
6356
+ };
6357
+ var SUPERSEDE_EPISTEMIC_NODE = {
6358
+ name: "supersede_epistemic_node",
6359
+ 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.",
6360
+ parameters: {
6361
+ oldNodeId: { type: "string", description: "Node ID or global ID to supersede" },
6362
+ newGlobalId: { type: "string", description: "Optional replacement global ID" },
6363
+ newCanonicalText: { type: "string", description: "Replacement canonical text" },
6364
+ text: { type: "string", description: "Alias for newCanonicalText" },
6365
+ newContentHash: { type: "string", description: "Optional replacement content hash" },
6366
+ reason: { type: "string", description: "Reason for superseding" }
6367
+ },
6368
+ required: ["oldNodeId"],
6369
+ response: {
6370
+ description: "Supersede result",
6371
+ fields: { oldNodeId: "string", newNodeId: "string" }
6372
+ },
6373
+ ownerModule: "reasoning-kernel",
6374
+ ontologyPrimitive: "graph",
6375
+ tier: "workhorse"
6376
+ };
6377
+ var BATCH_CREATE_EPISTEMIC_NODES = {
6378
+ name: "batch_create_epistemic_nodes",
6379
+ description: "Commit multiple epistemic graph nodes. Like `git commit` with many staged files \u2014 writes a batch of canonical spine nodes.",
6380
+ parameters: {
6381
+ nodes: {
6382
+ type: "array",
6383
+ description: "Nodes to create with nodeType, canonicalText/text, and optional metadata."
6384
+ }
6385
+ },
6386
+ required: ["nodes"],
6387
+ response: {
6388
+ description: "Batch node creation result",
6389
+ fields: { created: "number", results: "array" }
6390
+ },
6391
+ ownerModule: "reasoning-kernel",
6392
+ ontologyPrimitive: "graph",
6393
+ tier: "workhorse"
6394
+ };
5382
6395
  var RECORD_JUDGMENT = {
5383
6396
  name: "record_judgment",
5384
6397
  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).",
@@ -5676,6 +6689,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5676
6689
  ontologyPrimitive: "graph",
5677
6690
  tier: "showcase"
5678
6691
  };
6692
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6693
+ name: "list_graph_intelligence_queries",
6694
+ 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.",
6695
+ parameters: {
6696
+ categoryId: {
6697
+ type: "string",
6698
+ description: "Optional category filter, such as problems or strategic"
6699
+ },
6700
+ mode: {
6701
+ type: "string",
6702
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6703
+ }
6704
+ },
6705
+ required: [],
6706
+ response: {
6707
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6708
+ fields: {
6709
+ categories: "array \u2014 query categories",
6710
+ queries: "array \u2014 query definitions with prompt templates and tools",
6711
+ quickQueries: "array \u2014 recommended one-click query presets",
6712
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6713
+ }
6714
+ },
6715
+ ownerModule: "graph-intelligence",
6716
+ ontologyPrimitive: "graph",
6717
+ tier: "showcase"
6718
+ };
6719
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6720
+ name: "run_graph_intelligence_query",
6721
+ 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.",
6722
+ parameters: {
6723
+ topicId: { type: "string", description: "Topic to analyze" },
6724
+ queryId: {
6725
+ type: "string",
6726
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6727
+ },
6728
+ prompt: {
6729
+ type: "string",
6730
+ description: "Optional custom prompt for custom analysis runs"
6731
+ },
6732
+ input: {
6733
+ type: "string",
6734
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6735
+ },
6736
+ mode: {
6737
+ type: "string",
6738
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6739
+ },
6740
+ limit: {
6741
+ type: "number",
6742
+ description: "Maximum graph context rows to return"
6743
+ }
6744
+ },
6745
+ required: ["topicId"],
6746
+ response: {
6747
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6748
+ fields: {
6749
+ query: "object \u2014 selected query definition",
6750
+ prompt: "string \u2014 resolved prompt template",
6751
+ toolPlan: "array \u2014 public tools and args the model can call next",
6752
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6753
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6754
+ }
6755
+ },
6756
+ ownerModule: "graph-intelligence",
6757
+ ontologyPrimitive: "graph",
6758
+ tier: "showcase"
6759
+ };
5679
6760
  var GET_FALSIFICATION_QUESTIONS = {
5680
6761
  name: "get_falsification_questions",
5681
6762
  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.",
@@ -6524,15 +7605,15 @@ var IDENTITY_WHOAMI = {
6524
7605
  };
6525
7606
  var COMPILE_CONTEXT = {
6526
7607
  name: "compile_context",
6527
- 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.",
7608
+ 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.",
6528
7609
  parameters: {
6529
7610
  topicId: {
6530
7611
  type: "string",
6531
- description: "Topic scope ID to compile"
7612
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
6532
7613
  },
6533
7614
  query: {
6534
7615
  type: "string",
6535
- description: "Optional focus query used to rank context items"
7616
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
6536
7617
  },
6537
7618
  budget: {
6538
7619
  type: "number",
@@ -6556,7 +7637,7 @@ var COMPILE_CONTEXT = {
6556
7637
  description: "Include related ontological entities in the compiled result"
6557
7638
  }
6558
7639
  },
6559
- required: ["topicId"],
7640
+ required: [],
6560
7641
  response: {
6561
7642
  description: "Compiled context pack for the requested topic",
6562
7643
  fields: {
@@ -6730,18 +7811,60 @@ var CREATE_TASK = {
6730
7811
  name: "create_task",
6731
7812
  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.",
6732
7813
  parameters: {
6733
- title: { type: "string", description: "Task description" },
7814
+ title: { type: "string", description: "Task title" },
6734
7815
  topicId: { type: "string", description: "Topic scope" },
7816
+ description: {
7817
+ type: "string",
7818
+ description: "Long-form task description"
7819
+ },
6735
7820
  taskType: {
6736
7821
  type: "string",
6737
- description: "Type: research, interview, analysis, data_collection",
6738
- enum: ["research", "interview", "analysis", "data_collection"]
7822
+ description: "Task taxonomy",
7823
+ enum: [
7824
+ "general",
7825
+ "find_evidence",
7826
+ "verify_claim",
7827
+ "research",
7828
+ "review",
7829
+ "interview",
7830
+ "analysis",
7831
+ "track_metrics"
7832
+ ]
7833
+ },
7834
+ priority: {
7835
+ type: "string",
7836
+ description: "Priority",
7837
+ enum: ["urgent", "high", "medium", "low"]
7838
+ },
7839
+ status: {
7840
+ type: "string",
7841
+ description: "Initial status (defaults to todo)",
7842
+ enum: ["todo", "in_progress", "blocked", "done"]
7843
+ },
7844
+ linkedWorktreeId: {
7845
+ type: "string",
7846
+ description: "Worktree this task belongs to"
7847
+ },
7848
+ linkedBeliefId: {
7849
+ type: "string",
7850
+ description: "Belief this task supports"
6739
7851
  },
6740
7852
  linkedQuestionId: {
6741
7853
  type: "string",
6742
7854
  description: "Question this task addresses"
6743
7855
  },
6744
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
7856
+ assigneeId: {
7857
+ type: "string",
7858
+ description: "Principal assigned to the task"
7859
+ },
7860
+ dueDate: {
7861
+ type: "number",
7862
+ description: "Due date as epoch milliseconds"
7863
+ },
7864
+ tags: {
7865
+ type: "array",
7866
+ description: "Free-form string tags"
7867
+ }
6745
7868
  },
6746
7869
  required: ["title"],
6747
7870
  response: {
@@ -6861,6 +7984,10 @@ var CREATE_TOPIC = {
6861
7984
  name: "create_topic",
6862
7985
  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.",
6863
7986
  parameters: {
7987
+ globalId: {
7988
+ type: "string",
7989
+ description: "Optional idempotent topic global ID"
7990
+ },
6864
7991
  name: { type: "string", description: "Topic name" },
6865
7992
  type: {
6866
7993
  type: "string",
@@ -6871,6 +7998,18 @@ var CREATE_TOPIC = {
6871
7998
  type: "string",
6872
7999
  description: "Optional parent topic for nesting"
6873
8000
  },
8001
+ parentTopicGlobalId: {
8002
+ type: "string",
8003
+ description: "Optional parent topic global ID for nesting"
8004
+ },
8005
+ tenantId: { type: "string", description: "Optional tenant scope" },
8006
+ workspaceId: { type: "string", description: "Optional workspace scope" },
8007
+ visibility: {
8008
+ type: "string",
8009
+ description: "Topic visibility",
8010
+ enum: ["private", "team", "firm", "external", "public"]
8011
+ },
8012
+ metadata: { type: "object", description: "Optional topic metadata" },
6874
8013
  createdBy: { type: "string", description: "Who created this topic" }
6875
8014
  },
6876
8015
  required: ["name", "type"],
@@ -6879,6 +8018,9 @@ var CREATE_TOPIC = {
6879
8018
  fields: {
6880
8019
  id: "string \u2014 topic ID",
6881
8020
  globalId: "string \u2014 globally unique ID",
8021
+ topicGlobalId: "string \u2014 topic global ID",
8022
+ epistemicNodeId: "string \u2014 materialized topic node ID",
8023
+ epistemicNodeGlobalId: "string \u2014 materialized topic node global ID",
6882
8024
  depth: "number \u2014 nesting depth"
6883
8025
  }
6884
8026
  },
@@ -7009,6 +8151,65 @@ var GET_TOPIC_TREE = {
7009
8151
  ontologyPrimitive: "graph",
7010
8152
  tier: "workhorse"
7011
8153
  };
8154
+ var MATERIALIZE_TOPIC_GRAPH = {
8155
+ name: "materialize_topic_graph",
8156
+ description: "Backfill the topic graph spine. Like `git fsck --connectivity-only` with repair enabled \u2014 creates missing topic nodes and parent-child edges idempotently.",
8157
+ parameters: {
8158
+ rootTopicId: {
8159
+ type: "string",
8160
+ description: "Optional root topic for a bounded materialization pass"
8161
+ },
8162
+ dryRun: {
8163
+ type: "boolean",
8164
+ description: "When true, report missing rows without writing them"
8165
+ }
8166
+ },
8167
+ required: [],
8168
+ response: {
8169
+ description: "Topic graph materialization counts",
8170
+ fields: {
8171
+ topicsSeen: "number",
8172
+ nodesCreated: "number",
8173
+ nodesExisting: "number",
8174
+ edgesCreated: "number",
8175
+ edgesExisting: "number",
8176
+ errors: "array"
8177
+ }
8178
+ },
8179
+ ownerModule: "reasoning-kernel",
8180
+ ontologyPrimitive: "graph",
8181
+ tier: "workhorse"
8182
+ };
8183
+ var GET_TOPIC_GRAPH_SPINE = {
8184
+ name: "get_topic_graph_spine",
8185
+ description: "Verify the topic graph spine. Like `git fsck` \u2014 reads topics, materialized topic nodes, parent-child edges, and missing spine rows.",
8186
+ parameters: {
8187
+ rootTopicId: {
8188
+ type: "string",
8189
+ description: "Optional root topic for a bounded verifier pass"
8190
+ },
8191
+ includeTopicBeliefEdges: {
8192
+ type: "boolean",
8193
+ description: "Include topic -> belief edges in the verifier payload"
8194
+ }
8195
+ },
8196
+ required: [],
8197
+ response: {
8198
+ description: "Topic graph spine verification payload",
8199
+ fields: {
8200
+ ok: "boolean",
8201
+ counts: "object",
8202
+ topics: "array",
8203
+ topicNodes: "array",
8204
+ parentEdges: "array",
8205
+ missingTopicNodes: "array",
8206
+ missingParentEdges: "array"
8207
+ }
8208
+ },
8209
+ ownerModule: "reasoning-kernel",
8210
+ ontologyPrimitive: "graph",
8211
+ tier: "workhorse"
8212
+ };
7012
8213
  var GET_CODE_CONTEXT = {
7013
8214
  name: "get_code_context",
7014
8215
  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.",
@@ -8141,27 +9342,90 @@ var GENERATE_SESSION_HANDOFF = {
8141
9342
  tier: "showcase",
8142
9343
  internal: true
8143
9344
  };
8144
- var MCP_TOOL_CONTRACTS = {
8145
- // Belief lifecycle (commit, amend, fork, archive)
8146
- create_belief: CREATE_BELIEF,
8147
- get_belief: GET_BELIEF,
8148
- refine_belief: REFINE_BELIEF,
8149
- modulate_confidence: MODULATE_CONFIDENCE,
8150
- fork_belief: FORK_BELIEF,
8151
- archive_belief: ARCHIVE_BELIEF,
8152
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8153
- evaluate_contract: EVALUATE_CONTRACT,
8154
- get_contract_status: GET_CONTRACT_STATUS,
8155
- // Evidence (commit)
8156
- create_evidence: CREATE_EVIDENCE,
8157
- get_evidence: GET_EVIDENCE,
8158
- list_evidence: LIST_EVIDENCE,
8159
- link_evidence: LINK_EVIDENCE,
8160
- add_evidence: ADD_EVIDENCE,
8161
- // Contradictions (merge conflict)
8162
- flag_contradiction: FLAG_CONTRADICTION,
8163
- // Lens lifecycle (workspace-scoped operational frames)
8164
- create_lens: CREATE_LENS,
9345
+ var BEGIN_BUILD_SESSION = {
9346
+ name: "begin_build_session",
9347
+ 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.",
9348
+ parameters: {
9349
+ worktreeId: {
9350
+ type: "string",
9351
+ description: "The Lucern worktree ID to bootstrap."
9352
+ },
9353
+ branch: {
9354
+ type: "string",
9355
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
9356
+ },
9357
+ branchBase: {
9358
+ type: "string",
9359
+ description: 'Base branch for the feature branch. Default: "staging".'
9360
+ },
9361
+ prBase: {
9362
+ type: "string",
9363
+ description: 'Target branch for the PR. Default: "staging".'
9364
+ },
9365
+ sessionMode: {
9366
+ type: "string",
9367
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
9368
+ enum: ["async", "interactive"]
9369
+ },
9370
+ activateIfPlanning: {
9371
+ type: "boolean",
9372
+ description: "When true, automatically activate a planning worktree during bootstrap."
9373
+ }
9374
+ },
9375
+ required: ["worktreeId"],
9376
+ response: {
9377
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
9378
+ fields: {
9379
+ topicId: "string \u2014 canonical topic scope",
9380
+ topicName: "string \u2014 human-readable topic name",
9381
+ worktreeId: "string \u2014 worktree ID",
9382
+ worktreeName: "string \u2014 human-readable worktree name",
9383
+ branch: "string \u2014 git branch name",
9384
+ branchBase: "string \u2014 base branch",
9385
+ prBase: "string \u2014 PR target branch",
9386
+ campaign: "number | null \u2014 top-level pipeline campaign",
9387
+ lane: "string \u2014 campaign lane",
9388
+ gate: "string \u2014 exit gate",
9389
+ hypothesis: "string \u2014 worktree hypothesis",
9390
+ focus: "string \u2014 session focus",
9391
+ status: "string \u2014 worktree status after optional activation",
9392
+ sessionMode: "string \u2014 async | interactive",
9393
+ targetBeliefIds: "array \u2014 scoped belief IDs",
9394
+ targetQuestionIds: "array \u2014 scoped question IDs",
9395
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
9396
+ openQuestions: "array \u2014 open scoped questions",
9397
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
9398
+ dependencies: "array \u2014 upstream worktrees",
9399
+ unblocks: "array \u2014 downstream worktrees",
9400
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
9401
+ }
9402
+ },
9403
+ ownerModule: "bootstrap",
9404
+ ontologyPrimitive: "worktree",
9405
+ tier: "showcase",
9406
+ internal: true
9407
+ };
9408
+ var MCP_TOOL_CONTRACTS = {
9409
+ // Belief lifecycle (commit, amend, fork, archive)
9410
+ create_belief: CREATE_BELIEF,
9411
+ get_belief: GET_BELIEF,
9412
+ refine_belief: REFINE_BELIEF,
9413
+ modulate_confidence: MODULATE_CONFIDENCE,
9414
+ fork_belief: FORK_BELIEF,
9415
+ archive_belief: ARCHIVE_BELIEF,
9416
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
9417
+ evaluate_contract: EVALUATE_CONTRACT,
9418
+ get_contract_status: GET_CONTRACT_STATUS,
9419
+ // Evidence (commit)
9420
+ create_evidence: CREATE_EVIDENCE,
9421
+ get_evidence: GET_EVIDENCE,
9422
+ list_evidence: LIST_EVIDENCE,
9423
+ link_evidence: LINK_EVIDENCE,
9424
+ add_evidence: ADD_EVIDENCE,
9425
+ // Contradictions (merge conflict)
9426
+ flag_contradiction: FLAG_CONTRADICTION,
9427
+ // Lens lifecycle (workspace-scoped operational frames)
9428
+ create_lens: CREATE_LENS,
8165
9429
  list_lenses: LIST_LENSES,
8166
9430
  apply_lens_to_topic: APPLY_LENS_TO_TOPIC,
8167
9431
  remove_lens_from_topic: REMOVE_LENS_FROM_TOPIC,
@@ -8183,11 +9447,26 @@ var MCP_TOOL_CONTRACTS = {
8183
9447
  bisect_confidence: BISECT_CONFIDENCE,
8184
9448
  // Edges (commit)
8185
9449
  create_edge: CREATE_EDGE,
9450
+ update_edge: UPDATE_EDGE,
9451
+ remove_edge: REMOVE_EDGE,
9452
+ remove_edges_between: REMOVE_EDGES_BETWEEN,
9453
+ batch_create_edges: BATCH_CREATE_EDGES,
9454
+ // Epistemic node spine (commit/amend/show)
9455
+ create_epistemic_node: CREATE_EPISTEMIC_NODE,
9456
+ get_epistemic_node: GET_EPISTEMIC_NODE,
9457
+ list_epistemic_nodes: LIST_EPISTEMIC_NODES,
9458
+ update_epistemic_node: UPDATE_EPISTEMIC_NODE,
9459
+ archive_epistemic_node: ARCHIVE_EPISTEMIC_NODE,
9460
+ verify_epistemic_node: VERIFY_EPISTEMIC_NODE,
9461
+ supersede_epistemic_node: SUPERSEDE_EPISTEMIC_NODE,
9462
+ batch_create_epistemic_nodes: BATCH_CREATE_EPISTEMIC_NODES,
8186
9463
  // Judgments (tag)
8187
9464
  record_judgment: RECORD_JUDGMENT,
8188
9465
  // Graph intelligence (showcase)
8189
9466
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8190
9467
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9468
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9469
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8191
9470
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8192
9471
  // Evidence operations (workhorse)
8193
9472
  search_evidence: SEARCH_EVIDENCE,
@@ -8234,6 +9513,7 @@ var MCP_TOOL_CONTRACTS = {
8234
9513
  get_agent_inbox: GET_AGENT_INBOX,
8235
9514
  claim_files: CLAIM_FILES,
8236
9515
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9516
+ begin_build_session: BEGIN_BUILD_SESSION,
8237
9517
  // Policy / ACL (workhorse)
8238
9518
  check_permission: CHECK_PERMISSION,
8239
9519
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8253,6 +9533,8 @@ var MCP_TOOL_CONTRACTS = {
8253
9533
  get_topic: GET_TOPIC,
8254
9534
  update_topic: UPDATE_TOPIC,
8255
9535
  get_topic_tree: GET_TOPIC_TREE,
9536
+ materialize_topic_graph: MATERIALIZE_TOPIC_GRAPH,
9537
+ get_topic_graph_spine: GET_TOPIC_GRAPH_SPINE,
8256
9538
  // Coding intelligence (code-grounded knowledge)
8257
9539
  get_code_context: GET_CODE_CONTEXT,
8258
9540
  get_change_history: GET_CHANGE_HISTORY,
@@ -8357,18 +9639,34 @@ var MCP_CORE_OPERATION_NAMES = [
8357
9639
  "find_missing_questions",
8358
9640
  "get_high_priority_questions",
8359
9641
  "get_falsification_questions",
9642
+ "create_epistemic_node",
9643
+ "get_epistemic_node",
9644
+ "list_epistemic_nodes",
9645
+ "update_epistemic_node",
9646
+ "archive_epistemic_node",
9647
+ "verify_epistemic_node",
9648
+ "supersede_epistemic_node",
9649
+ "batch_create_epistemic_nodes",
8360
9650
  "create_topic",
8361
9651
  "get_topic",
8362
9652
  "list_topics",
8363
9653
  "update_topic",
8364
- "get_topic_tree"
9654
+ "get_topic_tree",
9655
+ "materialize_topic_graph",
9656
+ "get_topic_graph_spine"
8365
9657
  ];
8366
9658
  var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8367
9659
  "create_edge",
9660
+ "update_edge",
9661
+ "remove_edge",
9662
+ "remove_edges_between",
9663
+ "batch_create_edges",
8368
9664
  "query_lineage",
8369
9665
  "traverse_graph",
8370
9666
  "get_graph_neighborhood",
8371
9667
  "get_graph_structure_analysis",
9668
+ "list_graph_intelligence_queries",
9669
+ "run_graph_intelligence_query",
8372
9670
  "find_contradictions",
8373
9671
  "flag_contradiction",
8374
9672
  "detect_confirmation_bias",
@@ -8447,6 +9745,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8447
9745
  "get_change_history",
8448
9746
  "get_failure_log",
8449
9747
  "record_attempt",
9748
+ "begin_build_session",
8450
9749
  "push",
8451
9750
  "open_pull_request",
8452
9751
  "record_judgment",
@@ -8501,7 +9800,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8501
9800
  "find_semantic_orphans"
8502
9801
  ];
8503
9802
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8504
- "begin_build_session",
8505
9803
  "evaluate_engineering_contract",
8506
9804
  "evaluate_research_contract"
8507
9805
  ];
@@ -8756,9 +10054,7 @@ function mcpContractFromArgsSchema(base, args, contractName) {
8756
10054
  required: converted.filter(([, field]) => field.required).map(([fieldName]) => fieldName)
8757
10055
  };
8758
10056
  }
8759
- function defineFunctionContract(contract) {
8760
- return contract;
8761
- }
10057
+ var defineFunctionContract = (contract) => contract;
8762
10058
  function authUserId(context) {
8763
10059
  return context.userId ?? context.principalId ?? "lucern-agent";
8764
10060
  }
@@ -8887,8 +10183,34 @@ function assertSurfaceCoverage(contracts) {
8887
10183
  }
8888
10184
  }
8889
10185
  }
8890
-
8891
- // ../contracts/src/function-registry/context.ts
10186
+ var jsonRecordSchema2 = z.record(z.unknown());
10187
+ var observationArgs = z.object({
10188
+ topicId: z.string().optional().describe("Topic scope for the observation."),
10189
+ summary: z.string().describe("Short observation summary."),
10190
+ text: z.string().optional().describe("Canonical observation text alias."),
10191
+ title: z.string().optional().describe("Optional observation title."),
10192
+ content: z.string().optional().describe("Optional rich observation content."),
10193
+ contentType: z.string().optional().describe("Observation content type."),
10194
+ kind: z.string().optional().describe("Evidence kind to store."),
10195
+ observationType: z.string().optional().describe("Observation type."),
10196
+ tags: z.array(z.string()).optional().describe("Observation tags."),
10197
+ source: z.string().optional().describe("Observation source label."),
10198
+ sourceType: z.string().optional().describe("Evidence source type."),
10199
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
10200
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10201
+ confidence: z.number().optional().describe("Observation confidence."),
10202
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
10203
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
10204
+ });
10205
+ var observationContextArgs = z.object({
10206
+ topicId: z.string().describe("Topic scope."),
10207
+ query: z.string().optional().describe("Optional context query."),
10208
+ limit: z.number().optional().describe("Maximum observations to return."),
10209
+ status: z.string().optional().describe("Observation status filter.")
10210
+ });
10211
+ function isRecord2(value) {
10212
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10213
+ }
8892
10214
  var observationInput = (input, context) => withUserId(
8893
10215
  compactRecord4({
8894
10216
  projectId: input.projectId,
@@ -8921,7 +10243,7 @@ var contextContracts = [
8921
10243
  path: "/context/compile",
8922
10244
  sdkNamespace: "context",
8923
10245
  sdkMethod: "compileContext",
8924
- summary: "Compile a focused reasoning context for a topic.",
10246
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
8925
10247
  convex: {
8926
10248
  module: "contextCompiler",
8927
10249
  functionName: "compile",
@@ -8943,11 +10265,12 @@ var contextContracts = [
8943
10265
  kind: "mutation",
8944
10266
  inputProjection: observationInput,
8945
10267
  outputProjection: (output, input) => ({
8946
- ...output && typeof output === "object" ? output : {},
8947
- observationId: output && typeof output === "object" ? output.nodeId : void 0,
10268
+ ...isRecord2(output) ? output : {},
10269
+ observationId: isRecord2(output) ? output.nodeId : void 0,
8948
10270
  observationType: input.observationType
8949
10271
  })
8950
- }
10272
+ },
10273
+ args: observationArgs
8951
10274
  }),
8952
10275
  surfaceContract({
8953
10276
  name: "get_observation_context",
@@ -8968,7 +10291,8 @@ var contextContracts = [
8968
10291
  status: input.status,
8969
10292
  userId: input.userId
8970
10293
  })
8971
- }
10294
+ },
10295
+ args: observationContextArgs
8972
10296
  })
8973
10297
  ];
8974
10298
 
@@ -9031,8 +10355,45 @@ var identityContracts = [
9031
10355
  }
9032
10356
  })
9033
10357
  ];
9034
-
9035
- // ../contracts/src/function-registry/beliefs.ts
10358
+ var jsonRecordSchema3 = z.record(z.unknown());
10359
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
10360
+ var reversibilitySchema = z.enum([
10361
+ "irreversible",
10362
+ "hard_to_reverse",
10363
+ "reversible",
10364
+ "trivial"
10365
+ ]);
10366
+ var predictionMetaSchema = z.object({
10367
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
10368
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
10369
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
10370
+ });
10371
+ var createBeliefArgs = z.object({
10372
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
10373
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
10374
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
10375
+ beliefType: z.string().optional().describe("Schema belief type."),
10376
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
10377
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
10378
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
10379
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
10380
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
10381
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
10382
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
10383
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
10384
+ });
10385
+ var forkBeliefArgs = z.object({
10386
+ nodeId: z.string().describe("The scored belief to fork from."),
10387
+ newFormulation: z.string().describe("The evolved belief statement."),
10388
+ forkReason: z.enum([
10389
+ "refinement",
10390
+ "contradiction_response",
10391
+ "scope_change",
10392
+ "confidence_collapse",
10393
+ "manual"
10394
+ ]).describe("Why this fork was created."),
10395
+ rationale: z.string().optional().describe("Why the fork is warranted.")
10396
+ });
9036
10397
  var beliefLookupInput = (input) => compactRecord4({
9037
10398
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9038
10399
  beliefId: input.beliefId
@@ -9107,7 +10468,8 @@ var beliefsContracts = [
9107
10468
  functionName: "create",
9108
10469
  kind: "mutation",
9109
10470
  inputProjection: createBeliefInput
9110
- }
10471
+ },
10472
+ args: createBeliefArgs
9111
10473
  }),
9112
10474
  surfaceContract({
9113
10475
  name: "get_belief",
@@ -9198,7 +10560,8 @@ var beliefsContracts = [
9198
10560
  functionName: "forkBelief",
9199
10561
  kind: "mutation",
9200
10562
  inputProjection: forkBeliefInput
9201
- }
10563
+ },
10564
+ args: forkBeliefArgs
9202
10565
  }),
9203
10566
  surfaceContract({
9204
10567
  name: "archive_belief",
@@ -9279,8 +10642,46 @@ var beliefsContracts = [
9279
10642
  }
9280
10643
  })
9281
10644
  ];
9282
-
9283
- // ../contracts/src/function-registry/evidence.ts
10645
+ var jsonRecordSchema4 = z.record(z.unknown());
10646
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10647
+ var createEvidenceArgs = z.object({
10648
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10649
+ text: z.string().describe("Canonical evidence text."),
10650
+ source: z.string().optional().describe("Source URL or source label."),
10651
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10652
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10653
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10654
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10655
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10656
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10657
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10658
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10659
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10660
+ title: z.string().optional().describe("Optional short title."),
10661
+ content: z.string().optional().describe("Optional long-form content."),
10662
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10663
+ kind: z.string().optional().describe("Evidence kind."),
10664
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10665
+ sourceType: z.string().optional().describe("Evidence source type."),
10666
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10667
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10668
+ methodology: z.string().optional().describe("Collection methodology."),
10669
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10670
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10671
+ });
10672
+ var addEvidenceArgs = z.object({
10673
+ canonicalText: z.string().describe("The evidence statement."),
10674
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10675
+ topicId: z.string().optional().describe("Topic scope hint."),
10676
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10677
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10678
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10679
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10680
+ title: z.string().optional().describe("Optional short title."),
10681
+ content: z.string().optional().describe("Optional long-form evidence content."),
10682
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10683
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10684
+ });
9284
10685
  var evidenceIdInput = (input) => compactRecord4({
9285
10686
  evidenceId: input.evidenceId,
9286
10687
  insightId: input.insightId,
@@ -9308,12 +10709,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
9308
10709
  compactRecord4({
9309
10710
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9310
10711
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
9311
- edgeType: "evidence_supports_belief",
10712
+ edgeType: "informs",
9312
10713
  globalId: input.globalId ?? `edge:${String(
9313
10714
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9314
10715
  )}:${String(
9315
10716
  input.beliefNodeId ?? input.beliefId ?? input.targetId
9316
- )}:evidence_supports_belief`,
10717
+ )}:informs`,
9317
10718
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
9318
10719
  context: input.rationale ?? input.context,
9319
10720
  skipLayerValidation: true,
@@ -9326,12 +10727,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
9326
10727
  compactRecord4({
9327
10728
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9328
10729
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
9329
- edgeType: "evidence_supports_question",
10730
+ edgeType: "responds_to",
9330
10731
  globalId: input.globalId ?? `edge:${String(
9331
10732
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9332
10733
  )}:${String(
9333
10734
  input.questionId ?? input.questionNodeId ?? input.targetId
9334
- )}:evidence_supports_question`,
10735
+ )}:responds_to`,
9335
10736
  weight: input.impactScore ?? input.weight,
9336
10737
  context: input.rationale ?? input.context,
9337
10738
  skipLayerValidation: true,
@@ -9355,7 +10756,8 @@ var evidenceContracts = [
9355
10756
  functionName: "create",
9356
10757
  kind: "mutation",
9357
10758
  inputProjection: createEvidenceInput
9358
- }
10759
+ },
10760
+ args: createEvidenceArgs
9359
10761
  }),
9360
10762
  surfaceContract({
9361
10763
  name: "add_evidence",
@@ -9391,7 +10793,8 @@ var evidenceContracts = [
9391
10793
  context
9392
10794
  );
9393
10795
  }
9394
- }
10796
+ },
10797
+ args: addEvidenceArgs
9395
10798
  }),
9396
10799
  surfaceContract({
9397
10800
  name: "get_evidence",
@@ -9498,8 +10901,91 @@ var evidenceContracts = [
9498
10901
  }
9499
10902
  })
9500
10903
  ];
9501
-
9502
- // ../contracts/src/function-registry/questions.ts
10904
+ var jsonRecordSchema5 = z.record(z.unknown());
10905
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
10906
+ var kernelQuestionPrioritySchema = z.enum([
10907
+ "critical",
10908
+ "high",
10909
+ "medium",
10910
+ "low"
10911
+ ]);
10912
+ var questionTypeSchema = z.enum([
10913
+ "validation",
10914
+ "falsification",
10915
+ "assumption_probe",
10916
+ "prediction_test",
10917
+ "counterfactual",
10918
+ "discovery",
10919
+ "clarification",
10920
+ "comparison",
10921
+ "causal",
10922
+ "mechanism",
10923
+ "general"
10924
+ ]);
10925
+ var createQuestionArgs = z.object({
10926
+ text: z.string().describe("The question text."),
10927
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10928
+ topicId: z.string().optional().describe("Topic scope hint."),
10929
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
10930
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
10931
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
10932
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
10933
+ category: z.string().optional().describe("Question category."),
10934
+ source: z.string().optional().describe("Question source."),
10935
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
10936
+ importance: z.number().optional().describe("Numeric importance score."),
10937
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
10938
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
10939
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
10940
+ questionType: questionTypeSchema.optional().describe("Question type."),
10941
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
10942
+ });
10943
+ var refineQuestionArgs = z.object({
10944
+ id: z.string().describe("The question to refine."),
10945
+ text: z.string().describe("Updated question text."),
10946
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10947
+ rationale: z.string().optional().describe("Why the question is refined."),
10948
+ category: z.string().optional().describe("Updated question category."),
10949
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
10950
+ });
10951
+ var createAnswerArgs = z.object({
10952
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
10953
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10954
+ answerText: z.string().describe("The answer content."),
10955
+ topicId: z.string().optional().describe("Topic scope for the answer."),
10956
+ confidence: z.string().optional().describe("Answer confidence."),
10957
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
10958
+ answerSource: z.string().optional().describe("How the answer was produced."),
10959
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10960
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10961
+ });
10962
+ var answerQuestionArgs = z.object({
10963
+ id: z.string().describe("Canonical question ID."),
10964
+ topicId: z.string().describe("Topic scope for the answer."),
10965
+ text: z.string().describe("Answer text."),
10966
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
10967
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
10968
+ rationale: z.string().optional().describe("Why this answer is credible."),
10969
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10970
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
10971
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
10972
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
10973
+ answerSource: z.string().optional().describe("How the answer was produced."),
10974
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10975
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10976
+ });
10977
+ var missingQuestionsArgs = z.object({
10978
+ topicId: z.string().describe("Topic scope."),
10979
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
10980
+ status: z.string().optional().describe("Question status filter."),
10981
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10982
+ });
10983
+ var falsificationQuestionsArgs = z.object({
10984
+ topicId: z.string().describe("Topic scope."),
10985
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
10986
+ status: z.string().optional().describe("Question status filter."),
10987
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10988
+ });
9503
10989
  var questionNodeInput = (input) => compactRecord4({
9504
10990
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9505
10991
  questionId: input.questionId
@@ -9546,7 +11032,8 @@ var questionsContracts = [
9546
11032
  functionName: "create",
9547
11033
  kind: "mutation",
9548
11034
  inputProjection: createQuestionInput
9549
- }
11035
+ },
11036
+ args: createQuestionArgs
9550
11037
  }),
9551
11038
  surfaceContract({
9552
11039
  name: "get_question",
@@ -9602,7 +11089,8 @@ var questionsContracts = [
9602
11089
  category: input.category,
9603
11090
  priority: input.priority
9604
11091
  })
9605
- }
11092
+ },
11093
+ args: refineQuestionArgs
9606
11094
  }),
9607
11095
  surfaceContract({
9608
11096
  name: "update_question_status",
@@ -9678,7 +11166,8 @@ var questionsContracts = [
9678
11166
  }),
9679
11167
  context
9680
11168
  )
9681
- }
11169
+ },
11170
+ args: createAnswerArgs
9682
11171
  }),
9683
11172
  surfaceContract({
9684
11173
  name: "answer_question",
@@ -9707,7 +11196,8 @@ var questionsContracts = [
9707
11196
  }),
9708
11197
  context
9709
11198
  )
9710
- }
11199
+ },
11200
+ args: answerQuestionArgs
9711
11201
  }),
9712
11202
  surfaceContract({
9713
11203
  name: "get_answer",
@@ -9739,7 +11229,8 @@ var questionsContracts = [
9739
11229
  functionName: "getByTopic",
9740
11230
  kind: "query",
9741
11231
  inputProjection: questionTopicInput
9742
- }
11232
+ },
11233
+ args: missingQuestionsArgs
9743
11234
  }),
9744
11235
  surfaceContract({
9745
11236
  name: "get_high_priority_questions",
@@ -9774,11 +11265,54 @@ var questionsContracts = [
9774
11265
  functionName: "getByTopic",
9775
11266
  kind: "query",
9776
11267
  inputProjection: questionTopicInput
9777
- }
11268
+ },
11269
+ args: falsificationQuestionsArgs
9778
11270
  })
9779
11271
  ];
9780
-
9781
- // ../contracts/src/function-registry/topics.ts
11272
+ var topicVisibilitySchema = z.enum([
11273
+ "private",
11274
+ "team",
11275
+ "firm",
11276
+ "external",
11277
+ "public"
11278
+ ]);
11279
+ var topicStatusSchema = z.enum(["active", "archived", "watching"]);
11280
+ var createTopicArgs = z.object({
11281
+ globalId: z.string().optional().describe("Optional idempotent topic global ID."),
11282
+ name: z.string().describe("Topic name."),
11283
+ description: z.string().optional().describe("Topic description."),
11284
+ type: z.string().describe("Topic type."),
11285
+ parentTopicId: z.string().optional().describe("Optional parent topic ID."),
11286
+ parentTopicGlobalId: z.string().optional().describe("Optional parent topic global ID."),
11287
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11288
+ tenantId: z.string().optional().describe("Optional tenant scope."),
11289
+ workspaceId: z.string().optional().describe("Optional workspace scope."),
11290
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11291
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata."),
11292
+ graphScopeProjectId: z.string().optional(),
11293
+ createdBy: z.string().optional()
11294
+ });
11295
+ var updateTopicArgs = z.object({
11296
+ id: z.string().describe("Topic ID."),
11297
+ topicId: z.string().optional().describe("Topic ID alias."),
11298
+ name: z.string().optional().describe("Topic name."),
11299
+ description: z.string().optional().describe("Topic description."),
11300
+ type: z.string().optional().describe("Topic type."),
11301
+ status: topicStatusSchema.optional().describe("Topic status."),
11302
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11303
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11304
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
11305
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
11306
+ });
11307
+ var materializeTopicGraphArgs = z.object({
11308
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11309
+ dryRun: z.boolean().optional().describe("Report missing rows without writing."),
11310
+ createdBy: z.string().optional()
11311
+ });
11312
+ var getTopicGraphSpineArgs = z.object({
11313
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11314
+ includeTopicBeliefEdges: z.boolean().optional()
11315
+ });
9782
11316
  var topicIdInput = (input) => compactRecord4({
9783
11317
  id: input.id ?? input.topicId
9784
11318
  });
@@ -9809,7 +11343,8 @@ var topicsContracts = [
9809
11343
  functionName: "create",
9810
11344
  kind: "mutation",
9811
11345
  inputProjection: withCreatedBy
9812
- }
11346
+ },
11347
+ args: createTopicArgs
9813
11348
  }),
9814
11349
  surfaceContract({
9815
11350
  name: "get_topic",
@@ -9859,7 +11394,8 @@ var topicsContracts = [
9859
11394
  functionName: "update",
9860
11395
  kind: "mutation",
9861
11396
  inputProjection: updateTopicInput
9862
- }
11397
+ },
11398
+ args: updateTopicArgs
9863
11399
  }),
9864
11400
  surfaceContract({
9865
11401
  name: "get_topic_tree",
@@ -9876,85 +11412,505 @@ var topicsContracts = [
9876
11412
  functionName: "getTree",
9877
11413
  kind: "query"
9878
11414
  }
11415
+ }),
11416
+ surfaceContract({
11417
+ name: "materialize_topic_graph",
11418
+ kind: "mutation",
11419
+ domain: "topics",
11420
+ surfaceClass: "platform_public",
11421
+ path: "/topics/materialize-graph",
11422
+ sdkNamespace: "topics",
11423
+ sdkMethod: "materializeTopicGraph",
11424
+ summary: "Materialize topic nodes and parent-child graph edges.",
11425
+ convex: {
11426
+ module: "topics",
11427
+ functionName: "materializeTopicGraph",
11428
+ kind: "mutation",
11429
+ inputProjection: withCreatedBy
11430
+ },
11431
+ args: materializeTopicGraphArgs
11432
+ }),
11433
+ surfaceContract({
11434
+ name: "get_topic_graph_spine",
11435
+ kind: "query",
11436
+ domain: "topics",
11437
+ surfaceClass: "platform_public",
11438
+ method: "GET",
11439
+ path: "/topics/graph-spine",
11440
+ sdkNamespace: "topics",
11441
+ sdkMethod: "getTopicGraphSpine",
11442
+ summary: "Verify topic nodes and parent-child graph edges.",
11443
+ convex: {
11444
+ module: "topics",
11445
+ functionName: "getTopicGraphSpine",
11446
+ kind: "query"
11447
+ },
11448
+ args: getTopicGraphSpineArgs
9879
11449
  })
9880
11450
  ];
9881
-
9882
- // ../contracts/src/function-registry/lenses.ts
9883
- var createLensInput = (input, context) => compactRecord4({
9884
- name: input.name,
9885
- description: input.description,
9886
- workspaceId: input.workspaceId,
9887
- topicId: input.topicId,
9888
- perspectiveType: input.perspectiveType,
9889
- promptTemplates: input.promptTemplates,
9890
- workflowTemplates: input.workflowTemplates,
9891
- taskTemplates: input.taskTemplates,
9892
- questionTemplates: input.questionTemplates,
9893
- filterCriteria: input.filterCriteria,
9894
- metadata: input.metadata,
9895
- createdBy: authUserId(context)
11451
+ var sourceTypeSchema2 = z.enum([
11452
+ "human",
11453
+ "ai_extracted",
11454
+ "ai_generated",
11455
+ "imported",
11456
+ "system",
11457
+ "verified",
11458
+ "proprietary"
11459
+ ]);
11460
+ var verificationStatusSchema = z.enum([
11461
+ "unverified",
11462
+ "human_verified",
11463
+ "ai_verified",
11464
+ "contradicted",
11465
+ "outdated"
11466
+ ]);
11467
+ var nodeStatusSchema = z.enum([
11468
+ "active",
11469
+ "superseded",
11470
+ "archived",
11471
+ "deleted"
11472
+ ]);
11473
+ var externalIdsArgs = z.object({
11474
+ crunchbase: z.string().optional(),
11475
+ linkedin: z.string().optional(),
11476
+ pitchbook: z.string().optional(),
11477
+ twitter: z.string().optional(),
11478
+ website: z.string().optional()
11479
+ }).optional();
11480
+ var createEpistemicNodeItemArgs = z.object({
11481
+ globalId: z.string().optional().describe("Optional idempotent node global ID."),
11482
+ nodeType: NODE_TYPE.describe("Public epistemic node type."),
11483
+ subtype: z.string().optional(),
11484
+ canonicalText: z.string().optional().describe("Canonical node text."),
11485
+ text: z.string().optional().describe("Alias for canonicalText."),
11486
+ contentHash: z.string().optional().describe("Optional idempotency content hash."),
11487
+ content: z.string().optional(),
11488
+ contentType: z.string().optional(),
11489
+ title: z.string().optional(),
11490
+ tags: z.array(z.string()).optional(),
11491
+ domain: z.string().optional(),
11492
+ metadata: z.record(z.unknown()).optional(),
11493
+ externalIds: externalIdsArgs,
11494
+ sourceType: sourceTypeSchema2.optional(),
11495
+ aiProvider: z.string().optional(),
11496
+ extractedFromNodeId: z.string().optional(),
11497
+ confidence: z.number().optional(),
11498
+ verificationStatus: verificationStatusSchema.optional(),
11499
+ topicId: z.string().optional(),
11500
+ projectId: z.string().optional(),
11501
+ createdBy: z.string().optional(),
11502
+ trustedBypassAccessCheck: z.boolean().optional()
9896
11503
  });
9897
- var lensListInput = (input, context) => compactRecord4({
9898
- actorId: input.actorId ?? authUserId(context),
9899
- workspaceId: input.workspaceId,
11504
+ var createEpistemicNodeArgs = createEpistemicNodeItemArgs;
11505
+ var batchCreateEpistemicNodesArgs = z.object({
11506
+ nodes: z.array(createEpistemicNodeItemArgs)
11507
+ });
11508
+ var getEpistemicNodeArgs = z.object({
11509
+ nodeId: z.string().describe("Node ID or global ID."),
11510
+ globalId: z.string().optional().describe("Node global ID alias.")
11511
+ });
11512
+ var listEpistemicNodesArgs = z.object({
11513
+ topicId: z.string().optional(),
11514
+ projectId: z.string().optional(),
11515
+ nodeType: NODE_TYPE.optional(),
11516
+ status: nodeStatusSchema.optional(),
11517
+ searchQuery: z.string().optional(),
11518
+ query: z.string().optional(),
11519
+ limit: z.number().optional()
11520
+ });
11521
+ var updateEpistemicNodeArgs = z.object({
11522
+ nodeId: z.string().describe("Node ID or global ID."),
11523
+ id: z.string().optional().describe("Node ID alias."),
11524
+ subtype: z.string().optional(),
11525
+ canonicalText: z.string().optional(),
11526
+ text: z.string().optional(),
11527
+ contentHash: z.string().optional(),
11528
+ content: z.string().optional(),
11529
+ contentType: z.string().optional(),
11530
+ title: z.string().optional(),
11531
+ tags: z.array(z.string()).optional(),
11532
+ domain: z.string().optional(),
11533
+ metadata: z.record(z.unknown()).optional(),
11534
+ externalIds: externalIdsArgs,
11535
+ confidence: z.number().optional(),
11536
+ verificationStatus: verificationStatusSchema.optional(),
11537
+ status: nodeStatusSchema.optional(),
11538
+ userId: z.string().optional(),
11539
+ trustedBypassAccessCheck: z.boolean().optional()
11540
+ });
11541
+ var archiveEpistemicNodeArgs = z.object({
11542
+ nodeId: z.string().describe("Node ID or global ID."),
11543
+ id: z.string().optional().describe("Node ID alias."),
11544
+ userId: z.string().optional(),
11545
+ trustedBypassAccessCheck: z.boolean().optional()
11546
+ });
11547
+ var verifyEpistemicNodeArgs = z.object({
11548
+ nodeId: z.string().describe("Node ID or global ID."),
11549
+ id: z.string().optional().describe("Node ID alias."),
11550
+ verificationStatus: verificationStatusSchema,
11551
+ confidence: z.number().optional(),
11552
+ userId: z.string().optional()
11553
+ });
11554
+ var supersedeEpistemicNodeArgs = z.object({
11555
+ oldNodeId: z.string().describe("Node ID or global ID to supersede."),
11556
+ nodeId: z.string().optional().describe("Old node ID alias."),
11557
+ newGlobalId: z.string().optional(),
11558
+ newCanonicalText: z.string().optional(),
11559
+ text: z.string().optional(),
11560
+ canonicalText: z.string().optional(),
11561
+ newContentHash: z.string().optional(),
11562
+ reason: z.string().optional(),
11563
+ createdBy: z.string().optional(),
11564
+ trustedBypassAccessCheck: z.boolean().optional()
11565
+ });
11566
+ function generatedGlobalId(prefix) {
11567
+ return `${prefix}:${crypto.randomUUID()}`;
11568
+ }
11569
+ function resolveCanonicalText(input) {
11570
+ const text = input.canonicalText ?? input.text ?? input.title ?? input.content;
11571
+ if (typeof text !== "string" || text.trim().length === 0) {
11572
+ throw new Error("canonicalText or text is required.");
11573
+ }
11574
+ return text;
11575
+ }
11576
+ function createNodeInput(input, context) {
11577
+ const canonicalText = resolveCanonicalText(input);
11578
+ const nodeType = String(input.nodeType);
11579
+ return withCreatedBy(
11580
+ compactRecord4({
11581
+ globalId: typeof input.globalId === "string" && input.globalId.trim() ? input.globalId : generatedGlobalId(nodeType),
11582
+ nodeType,
11583
+ subtype: input.subtype,
11584
+ canonicalText,
11585
+ contentHash: typeof input.contentHash === "string" && input.contentHash.trim() ? input.contentHash : `${nodeType}:${canonicalText}`,
11586
+ content: input.content,
11587
+ contentType: input.contentType,
11588
+ title: input.title,
11589
+ tags: input.tags,
11590
+ domain: input.domain,
11591
+ metadata: input.metadata,
11592
+ externalIds: input.externalIds,
11593
+ sourceType: typeof input.sourceType === "string" && input.sourceType.trim() ? input.sourceType : "human",
11594
+ aiProvider: input.aiProvider,
11595
+ extractedFromNodeId: input.extractedFromNodeId,
11596
+ confidence: input.confidence,
11597
+ verificationStatus: input.verificationStatus,
11598
+ topicId: input.topicId,
11599
+ projectId: input.projectId
11600
+ }),
11601
+ context
11602
+ );
11603
+ }
11604
+ var getNodeInput = (input) => compactRecord4({
11605
+ nodeId: input.nodeId ?? input.globalId
11606
+ });
11607
+ var listNodesInput = (input) => compactRecord4({
9900
11608
  topicId: input.topicId,
11609
+ projectId: input.projectId,
11610
+ nodeType: input.nodeType,
9901
11611
  status: input.status,
9902
- perspectiveType: input.perspectiveType
11612
+ searchQuery: input.searchQuery ?? input.query,
11613
+ limit: input.limit
9903
11614
  });
9904
- var lensesContracts = [
11615
+ var updateNodeInput = (input, context) => withUserId(
11616
+ compactRecord4({
11617
+ nodeId: input.nodeId ?? input.id,
11618
+ subtype: input.subtype,
11619
+ canonicalText: input.canonicalText ?? input.text,
11620
+ contentHash: input.contentHash,
11621
+ content: input.content,
11622
+ contentType: input.contentType,
11623
+ title: input.title,
11624
+ tags: input.tags,
11625
+ domain: input.domain,
11626
+ metadata: input.metadata,
11627
+ externalIds: input.externalIds,
11628
+ confidence: input.confidence,
11629
+ verificationStatus: input.verificationStatus,
11630
+ status: input.status,
11631
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11632
+ }),
11633
+ context
11634
+ );
11635
+ var archiveNodeInput = (input, context) => withUserId(
11636
+ compactRecord4({
11637
+ nodeId: input.nodeId ?? input.id,
11638
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11639
+ }),
11640
+ context
11641
+ );
11642
+ var verifyNodeInput = (input, context) => withUserId(
11643
+ compactRecord4({
11644
+ nodeId: input.nodeId ?? input.id,
11645
+ verificationStatus: input.verificationStatus,
11646
+ confidence: input.confidence
11647
+ }),
11648
+ context
11649
+ );
11650
+ var supersedeNodeInput = (input, context) => {
11651
+ const newCanonicalText = input.newCanonicalText ?? input.canonicalText ?? input.text;
11652
+ if (typeof newCanonicalText !== "string" || newCanonicalText.trim().length === 0) {
11653
+ throw new Error("newCanonicalText or text is required.");
11654
+ }
11655
+ return {
11656
+ oldNodeId: input.oldNodeId ?? input.nodeId,
11657
+ newGlobalId: typeof input.newGlobalId === "string" && input.newGlobalId.trim() ? input.newGlobalId : generatedGlobalId("node"),
11658
+ newCanonicalText,
11659
+ newContentHash: typeof input.newContentHash === "string" && input.newContentHash.trim() ? input.newContentHash : `superseded:${newCanonicalText}`,
11660
+ createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context),
11661
+ reason: input.reason,
11662
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11663
+ };
11664
+ };
11665
+ var batchCreateNodesInput = (input, context) => {
11666
+ const nodes = Array.isArray(input.nodes) ? input.nodes : [];
11667
+ return {
11668
+ nodes: nodes.map(
11669
+ (node) => createNodeInput(
11670
+ node && typeof node === "object" ? node : {},
11671
+ context
11672
+ )
11673
+ )
11674
+ };
11675
+ };
11676
+ var nodesContracts = [
9905
11677
  surfaceContract({
9906
- name: "create_lens",
11678
+ name: "create_epistemic_node",
9907
11679
  kind: "mutation",
9908
- domain: "lenses",
11680
+ domain: "nodes",
9909
11681
  surfaceClass: "platform_public",
9910
- path: "/lenses",
9911
- sdkNamespace: "lenses",
9912
- sdkMethod: "createLens",
9913
- summary: "Create a lens.",
11682
+ path: "/nodes",
11683
+ sdkNamespace: "nodes",
11684
+ sdkMethod: "createEpistemicNode",
11685
+ summary: "Create a generic epistemic graph node.",
9914
11686
  convex: {
9915
- module: "lenses",
11687
+ module: "nodes",
9916
11688
  functionName: "create",
9917
11689
  kind: "mutation",
9918
- inputProjection: createLensInput
9919
- }
11690
+ inputProjection: createNodeInput
11691
+ },
11692
+ args: createEpistemicNodeArgs
9920
11693
  }),
9921
11694
  surfaceContract({
9922
- name: "list_lenses",
11695
+ name: "get_epistemic_node",
9923
11696
  kind: "query",
9924
- domain: "lenses",
11697
+ domain: "nodes",
9925
11698
  surfaceClass: "platform_public",
9926
11699
  method: "GET",
9927
- path: "/lenses",
9928
- sdkNamespace: "lenses",
9929
- sdkMethod: "listLenses",
9930
- summary: "List lenses.",
11700
+ path: "/nodes/get",
11701
+ sdkNamespace: "nodes",
11702
+ sdkMethod: "getEpistemicNode",
11703
+ summary: "Get a generic epistemic graph node.",
9931
11704
  convex: {
9932
- module: "lenses",
11705
+ module: "nodes",
11706
+ functionName: "get",
11707
+ kind: "query",
11708
+ inputProjection: getNodeInput
11709
+ },
11710
+ args: getEpistemicNodeArgs
11711
+ }),
11712
+ surfaceContract({
11713
+ name: "list_epistemic_nodes",
11714
+ kind: "query",
11715
+ domain: "nodes",
11716
+ surfaceClass: "platform_public",
11717
+ method: "GET",
11718
+ path: "/nodes",
11719
+ sdkNamespace: "nodes",
11720
+ sdkMethod: "listEpistemicNodes",
11721
+ summary: "List generic epistemic graph nodes.",
11722
+ convex: {
11723
+ module: "nodes",
9933
11724
  functionName: "list",
9934
11725
  kind: "query",
9935
- inputProjection: lensListInput
9936
- }
11726
+ inputProjection: listNodesInput
11727
+ },
11728
+ args: listEpistemicNodesArgs
9937
11729
  }),
9938
11730
  surfaceContract({
9939
- name: "apply_lens_to_topic",
11731
+ name: "update_epistemic_node",
9940
11732
  kind: "mutation",
9941
- domain: "lenses",
11733
+ domain: "nodes",
9942
11734
  surfaceClass: "platform_public",
9943
- path: "/lenses/apply",
9944
- sdkNamespace: "lenses",
9945
- sdkMethod: "applyLensToTopic",
9946
- summary: "Apply a lens to a topic.",
11735
+ method: "PATCH",
11736
+ path: "/nodes",
11737
+ sdkNamespace: "nodes",
11738
+ sdkMethod: "updateEpistemicNode",
11739
+ summary: "Update a generic epistemic graph node.",
9947
11740
  convex: {
9948
- module: "lenses",
9949
- functionName: "applyToTopic",
11741
+ module: "nodes",
11742
+ functionName: "update",
9950
11743
  kind: "mutation",
9951
- inputProjection: (input, context) => compactRecord4({
9952
- lensId: input.lensId,
9953
- topicId: input.topicId,
9954
- metadata: input.metadata,
9955
- appliedBy: authUserId(context)
9956
- })
9957
- }
11744
+ inputProjection: updateNodeInput
11745
+ },
11746
+ args: updateEpistemicNodeArgs
11747
+ }),
11748
+ surfaceContract({
11749
+ name: "archive_epistemic_node",
11750
+ kind: "mutation",
11751
+ domain: "nodes",
11752
+ surfaceClass: "platform_public",
11753
+ path: "/nodes/archive",
11754
+ sdkNamespace: "nodes",
11755
+ sdkMethod: "archiveEpistemicNode",
11756
+ summary: "Archive a generic epistemic graph node.",
11757
+ convex: {
11758
+ module: "nodes",
11759
+ functionName: "archive",
11760
+ kind: "mutation",
11761
+ inputProjection: archiveNodeInput
11762
+ },
11763
+ args: archiveEpistemicNodeArgs
11764
+ }),
11765
+ surfaceContract({
11766
+ name: "verify_epistemic_node",
11767
+ kind: "mutation",
11768
+ domain: "nodes",
11769
+ surfaceClass: "platform_public",
11770
+ path: "/nodes/verify",
11771
+ sdkNamespace: "nodes",
11772
+ sdkMethod: "verifyEpistemicNode",
11773
+ summary: "Verify a generic epistemic graph node.",
11774
+ convex: {
11775
+ module: "nodes",
11776
+ functionName: "verify",
11777
+ kind: "mutation",
11778
+ inputProjection: verifyNodeInput
11779
+ },
11780
+ args: verifyEpistemicNodeArgs
11781
+ }),
11782
+ surfaceContract({
11783
+ name: "supersede_epistemic_node",
11784
+ kind: "mutation",
11785
+ domain: "nodes",
11786
+ surfaceClass: "platform_public",
11787
+ path: "/nodes/supersede",
11788
+ sdkNamespace: "nodes",
11789
+ sdkMethod: "supersedeEpistemicNode",
11790
+ summary: "Supersede a generic epistemic graph node.",
11791
+ convex: {
11792
+ module: "nodes",
11793
+ functionName: "supersede",
11794
+ kind: "mutation",
11795
+ inputProjection: supersedeNodeInput
11796
+ },
11797
+ args: supersedeEpistemicNodeArgs
11798
+ }),
11799
+ surfaceContract({
11800
+ name: "batch_create_epistemic_nodes",
11801
+ kind: "mutation",
11802
+ domain: "nodes",
11803
+ surfaceClass: "platform_public",
11804
+ path: "/nodes/batch",
11805
+ sdkNamespace: "nodes",
11806
+ sdkMethod: "batchCreateEpistemicNodes",
11807
+ summary: "Batch create generic epistemic graph nodes.",
11808
+ convex: {
11809
+ module: "nodes",
11810
+ functionName: "batchCreate",
11811
+ kind: "mutation",
11812
+ inputProjection: batchCreateNodesInput
11813
+ },
11814
+ args: batchCreateEpistemicNodesArgs
11815
+ })
11816
+ ];
11817
+ var lensPerspectiveSchema = z.enum([
11818
+ "investigation",
11819
+ "monitoring",
11820
+ "analysis",
11821
+ "comparison",
11822
+ "taxonomy"
11823
+ ]);
11824
+ var jsonRecordSchema6 = z.record(z.unknown());
11825
+ var createLensArgs = z.object({
11826
+ name: z.string().describe("Lens name."),
11827
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
11828
+ topicId: z.string().optional().describe("Originating topic scope."),
11829
+ description: z.string().optional().describe("What this lens investigates or monitors."),
11830
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
11831
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
11832
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
11833
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
11834
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
11835
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
11836
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
11837
+ });
11838
+ var createLensInput = (input, context) => compactRecord4({
11839
+ name: input.name,
11840
+ description: input.description,
11841
+ workspaceId: input.workspaceId,
11842
+ topicId: input.topicId,
11843
+ perspectiveType: input.perspectiveType,
11844
+ promptTemplates: input.promptTemplates,
11845
+ workflowTemplates: input.workflowTemplates,
11846
+ taskTemplates: input.taskTemplates,
11847
+ questionTemplates: input.questionTemplates,
11848
+ filterCriteria: input.filterCriteria,
11849
+ metadata: input.metadata,
11850
+ createdBy: authUserId(context)
11851
+ });
11852
+ var lensListInput = (input, context) => compactRecord4({
11853
+ actorId: input.actorId ?? authUserId(context),
11854
+ workspaceId: input.workspaceId,
11855
+ topicId: input.topicId,
11856
+ status: input.status,
11857
+ perspectiveType: input.perspectiveType
11858
+ });
11859
+ var lensesContracts = [
11860
+ surfaceContract({
11861
+ name: "create_lens",
11862
+ kind: "mutation",
11863
+ domain: "lenses",
11864
+ surfaceClass: "platform_public",
11865
+ path: "/lenses",
11866
+ sdkNamespace: "lenses",
11867
+ sdkMethod: "createLens",
11868
+ summary: "Create a lens.",
11869
+ convex: {
11870
+ module: "lenses",
11871
+ functionName: "create",
11872
+ kind: "mutation",
11873
+ inputProjection: createLensInput
11874
+ },
11875
+ args: createLensArgs
11876
+ }),
11877
+ surfaceContract({
11878
+ name: "list_lenses",
11879
+ kind: "query",
11880
+ domain: "lenses",
11881
+ surfaceClass: "platform_public",
11882
+ method: "GET",
11883
+ path: "/lenses",
11884
+ sdkNamespace: "lenses",
11885
+ sdkMethod: "listLenses",
11886
+ summary: "List lenses.",
11887
+ convex: {
11888
+ module: "lenses",
11889
+ functionName: "list",
11890
+ kind: "query",
11891
+ inputProjection: lensListInput
11892
+ }
11893
+ }),
11894
+ surfaceContract({
11895
+ name: "apply_lens_to_topic",
11896
+ kind: "mutation",
11897
+ domain: "lenses",
11898
+ surfaceClass: "platform_public",
11899
+ path: "/lenses/apply",
11900
+ sdkNamespace: "lenses",
11901
+ sdkMethod: "applyLensToTopic",
11902
+ summary: "Apply a lens to a topic.",
11903
+ convex: {
11904
+ module: "lenses",
11905
+ functionName: "applyToTopic",
11906
+ kind: "mutation",
11907
+ inputProjection: (input, context) => compactRecord4({
11908
+ lensId: input.lensId,
11909
+ topicId: input.topicId,
11910
+ metadata: input.metadata,
11911
+ appliedBy: authUserId(context)
11912
+ })
11913
+ }
9958
11914
  }),
9959
11915
  surfaceContract({
9960
11916
  name: "remove_lens_from_topic",
@@ -9978,8 +11934,18 @@ var lensesContracts = [
9978
11934
  }
9979
11935
  })
9980
11936
  ];
9981
-
9982
- // ../contracts/src/function-registry/ontologies.ts
11937
+ var updateOntologyArgs = z.object({
11938
+ id: z.string().describe("Ontology definition ID."),
11939
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
11940
+ name: z.string().optional().describe("Ontology display name."),
11941
+ description: z.string().optional().describe("Ontology description."),
11942
+ status: z.string().optional().describe("Ontology lifecycle status.")
11943
+ });
11944
+ var ontologyVersionLifecycleArgs = z.object({
11945
+ id: z.string().describe("Ontology version ID."),
11946
+ versionId: z.string().optional().describe("Ontology version ID alias."),
11947
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
11948
+ });
9983
11949
  var ontologyIdInput = (input) => compactRecord4({
9984
11950
  id: input.id ?? input.ontologyId
9985
11951
  });
@@ -10058,11 +12024,11 @@ var ontologiesContracts = [
10058
12024
  id: input.id ?? input.ontologyId,
10059
12025
  name: input.name,
10060
12026
  description: input.description,
10061
- parentOntologyId: input.parentOntologyId,
10062
12027
  status: input.status,
10063
12028
  actorId: input.actorId
10064
12029
  })
10065
- }
12030
+ },
12031
+ args: updateOntologyArgs
10066
12032
  }),
10067
12033
  surfaceContract({
10068
12034
  name: "archive_ontology",
@@ -10145,7 +12111,8 @@ var ontologiesContracts = [
10145
12111
  functionName: "publishOntologyVersion",
10146
12112
  kind: "mutation",
10147
12113
  inputProjection: ontologyVersionIdInput
10148
- }
12114
+ },
12115
+ args: ontologyVersionLifecycleArgs
10149
12116
  }),
10150
12117
  surfaceContract({
10151
12118
  name: "deprecate_ontology_version",
@@ -10161,7 +12128,8 @@ var ontologiesContracts = [
10161
12128
  functionName: "deprecateOntologyVersion",
10162
12129
  kind: "mutation",
10163
12130
  inputProjection: ontologyVersionIdInput
10164
- }
12131
+ },
12132
+ args: ontologyVersionLifecycleArgs
10165
12133
  }),
10166
12134
  surfaceContract({
10167
12135
  name: "resolve_effective_ontology",
@@ -10180,8 +12148,81 @@ var ontologiesContracts = [
10180
12148
  }
10181
12149
  })
10182
12150
  ];
10183
-
10184
- // ../contracts/src/function-registry/worktrees.ts
12151
+ var autoFixPolicyInputSchema = z.object({
12152
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
12153
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
12154
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
12155
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
12156
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
12157
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
12158
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
12159
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
12160
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
12161
+ var worktreeKeyQuestionInputSchema = z.object({
12162
+ question: z.string().describe("Question the worktree must resolve."),
12163
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
12164
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
12165
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
12166
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
12167
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
12168
+ var worktreeEvidenceSignalInputSchema = z.object({
12169
+ signal: z.string().describe("Evidence signal the worktree should collect."),
12170
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
12171
+ progress: z.string().optional().describe("Collection progress note for the signal."),
12172
+ notes: z.string().optional().describe("Additional evidence collection notes.")
12173
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
12174
+ var worktreeDecisionGateInputSchema = z.object({
12175
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
12176
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
12177
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
12178
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
12179
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
12180
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
12181
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
12182
+ var addWorktreeArgs = z.object({
12183
+ title: z.string().describe("Human-readable worktree name or objective."),
12184
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
12185
+ topicId: z.string().optional().describe("Optional primary topic scope hint for resolver validation."),
12186
+ projectId: z.string().optional().describe("Legacy topicId alias/hint."),
12187
+ topicHint: z.string().optional().describe("Natural-language topic hint for automatic topic resolution."),
12188
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
12189
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
12190
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12191
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
12192
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
12193
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12194
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
12195
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
12196
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
12197
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
12198
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
12199
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12200
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12201
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
12202
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
12203
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
12204
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
12205
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
12206
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
12207
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
12208
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
12209
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
12210
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12211
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
12212
+ tags: z.array(z.string()).optional().describe("Additional topic-resolution tags for the worktree."),
12213
+ touchedPaths: z.array(z.string()).optional().describe("File paths used as topic-resolution signals."),
12214
+ sourceRef: z.string().optional().describe("Source reference used as a topic-resolution signal."),
12215
+ sourceKind: z.string().optional().describe("Source kind used as a topic-resolution signal."),
12216
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
12217
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
12218
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12219
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12220
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
12221
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12222
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12223
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
12224
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
12225
+ });
10185
12226
  var worktreeIdInput = (input) => compactRecord4({
10186
12227
  worktreeId: input.worktreeId ?? input.id
10187
12228
  });
@@ -10214,6 +12255,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10214
12255
  autoFixPolicy: input.autoFixPolicy,
10215
12256
  lastReconciledAt: input.lastReconciledAt
10216
12257
  });
12258
+ var worktreeMetadataArgs = z.object({
12259
+ worktreeId: z.string().describe("The worktree to update."),
12260
+ id: z.string().optional().describe("Worktree ID alias."),
12261
+ topicId: z.string().optional().describe("Primary topic scope."),
12262
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
12263
+ status: z.string().optional().describe("Worktree lifecycle status."),
12264
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
12265
+ lane: z.string().optional().describe("Campaign lane."),
12266
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12267
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12268
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12269
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12270
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
12271
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
12272
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
12273
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12274
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12275
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
12276
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
12277
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12278
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
12279
+ });
12280
+ var pushArgs = worktreeMetadataArgs.extend({
12281
+ targetContext: z.string().describe("Where to push merged findings."),
12282
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
12283
+ });
12284
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
12285
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
12286
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
12287
+ });
12288
+ var mergeKeyFindingsInput = (input) => {
12289
+ if (Array.isArray(input.keyFindings)) {
12290
+ return input.keyFindings;
12291
+ }
12292
+ if (Array.isArray(input.outcomes)) {
12293
+ const findings = input.outcomes.filter(
12294
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
12295
+ );
12296
+ if (findings.length > 0) {
12297
+ return findings;
12298
+ }
12299
+ }
12300
+ return [input.summary ?? "Merged worktree"];
12301
+ };
10217
12302
  var listAllWorktreesInput = (input) => compactRecord4({
10218
12303
  status: input.status,
10219
12304
  lane: input.lane,
@@ -10221,6 +12306,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10221
12306
  limit: input.limit
10222
12307
  });
10223
12308
  var worktreesContracts = [
12309
+ surfaceContract({
12310
+ name: "begin_build_session",
12311
+ kind: "mutation",
12312
+ domain: "worktrees",
12313
+ surfaceClass: "platform_internal",
12314
+ path: "/mcp/build-session/begin",
12315
+ sdkNamespace: "worktrees",
12316
+ sdkMethod: "beginBuildSession",
12317
+ summary: "Begin a coding build session for a worktree."
12318
+ }),
10224
12319
  surfaceContract({
10225
12320
  name: "add_worktree",
10226
12321
  kind: "mutation",
@@ -10237,13 +12332,12 @@ var worktreesContracts = [
10237
12332
  inputProjection: (input, context) => withCreatedBy(
10238
12333
  compactRecord4({
10239
12334
  name: input.name ?? input.title,
10240
- topicId: input.topicId,
12335
+ topicId: input.topicId ?? input.projectId,
10241
12336
  worktreeType: input.worktreeType,
10242
12337
  objective: input.objective,
10243
12338
  gate: input.gate,
10244
12339
  hypothesis: input.hypothesis,
10245
12340
  rationale: input.rationale,
10246
- signal: input.signal,
10247
12341
  startDate: input.startDate,
10248
12342
  endDate: input.endDate,
10249
12343
  durationWeeks: input.durationWeeks,
@@ -10269,12 +12363,12 @@ var worktreesContracts = [
10269
12363
  staffingHint: input.staffingHint,
10270
12364
  domainPackId: input.domainPackId,
10271
12365
  lensId: input.lensId,
10272
- linkedQuestionId: input.linkedQuestionId,
10273
12366
  lastReconciledAt: input.lastReconciledAt
10274
12367
  }),
10275
12368
  context
10276
12369
  )
10277
- }
12370
+ },
12371
+ args: addWorktreeArgs
10278
12372
  }),
10279
12373
  surfaceContract({
10280
12374
  name: "activate_worktree",
@@ -10386,7 +12480,8 @@ var worktreesContracts = [
10386
12480
  functionName: "updateMetadata",
10387
12481
  kind: "mutation",
10388
12482
  inputProjection: worktreeMetadataInput
10389
- }
12483
+ },
12484
+ args: worktreeMetadataArgs
10390
12485
  }),
10391
12486
  surfaceContract({
10392
12487
  name: "merge",
@@ -10404,9 +12499,7 @@ var worktreesContracts = [
10404
12499
  inputProjection: (input, context) => withUserId(
10405
12500
  {
10406
12501
  ...worktreeIdInput(input),
10407
- keyFindings: input.keyFindings ?? [
10408
- input.summary ?? "Merged worktree"
10409
- ],
12502
+ keyFindings: mergeKeyFindingsInput(input),
10410
12503
  decisionsReached: input.decisionsReached ?? [],
10411
12504
  nextSteps: input.nextSteps ?? []
10412
12505
  },
@@ -10428,7 +12521,8 @@ var worktreesContracts = [
10428
12521
  functionName: "updateMetadata",
10429
12522
  kind: "mutation",
10430
12523
  inputProjection: worktreeMetadataInput
10431
- }
12524
+ },
12525
+ args: pushArgs
10432
12526
  }),
10433
12527
  surfaceContract({
10434
12528
  name: "open_pull_request",
@@ -10444,11 +12538,50 @@ var worktreesContracts = [
10444
12538
  functionName: "updateMetadata",
10445
12539
  kind: "mutation",
10446
12540
  inputProjection: worktreeMetadataInput
10447
- }
12541
+ },
12542
+ args: openPullRequestArgs
10448
12543
  })
10449
12544
  ];
10450
-
10451
- // ../contracts/src/function-registry/tasks.ts
12545
+ var taskPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
12546
+ var taskStatusSchema2 = z.enum(["todo", "in_progress", "blocked", "done"]);
12547
+ var taskTypeSchema = z.enum([
12548
+ "general",
12549
+ "find_evidence",
12550
+ "verify_claim",
12551
+ "research",
12552
+ "review",
12553
+ "interview",
12554
+ "analysis",
12555
+ "track_metrics"
12556
+ ]);
12557
+ var createTaskArgs = z.object({
12558
+ title: z.string().describe("Task title."),
12559
+ topicId: z.string().optional().describe("Topic scope."),
12560
+ description: z.string().optional().describe("Long-form task description."),
12561
+ taskType: taskTypeSchema.optional().describe("Task taxonomy."),
12562
+ priority: taskPrioritySchema.optional().describe("Priority. Defaults to medium when omitted by the server."),
12563
+ status: taskStatusSchema2.optional().describe("Initial status. Defaults to todo."),
12564
+ linkedWorktreeId: z.string().optional().describe("Worktree this task belongs to."),
12565
+ linkedBeliefId: z.string().optional().describe("Belief this task supports."),
12566
+ linkedQuestionId: z.string().optional().describe("Question this task addresses."),
12567
+ assigneeId: z.string().optional().describe("Principal assigned to the task."),
12568
+ dueDate: z.number().optional().describe("Due date as epoch milliseconds."),
12569
+ tags: z.array(z.string()).optional().describe("Free-form tags.")
12570
+ });
12571
+ var createTaskInput = (input) => compactRecord4({
12572
+ title: input.title,
12573
+ topicId: input.topicId,
12574
+ description: input.description,
12575
+ taskType: input.taskType,
12576
+ priority: input.priority ?? "medium",
12577
+ status: input.status ?? "todo",
12578
+ linkedWorktreeId: input.linkedWorktreeId,
12579
+ linkedBeliefId: input.linkedBeliefId,
12580
+ linkedQuestionId: input.linkedQuestionId,
12581
+ assigneeId: input.assigneeId,
12582
+ dueDate: input.dueDate,
12583
+ tags: input.tags
12584
+ });
10452
12585
  var taskInput = (input) => compactRecord4({
10453
12586
  ...input,
10454
12587
  taskId: input.taskId ?? input.id
@@ -10480,8 +12613,10 @@ var tasksContracts = [
10480
12613
  convex: {
10481
12614
  module: "tasks",
10482
12615
  functionName: "create",
10483
- kind: "mutation"
10484
- }
12616
+ kind: "mutation",
12617
+ inputProjection: createTaskInput
12618
+ },
12619
+ args: createTaskArgs
10485
12620
  }),
10486
12621
  surfaceContract({
10487
12622
  name: "list_tasks",
@@ -10535,19 +12670,57 @@ var tasksContracts = [
10535
12670
  }
10536
12671
  })
10537
12672
  ];
12673
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12674
+ (policy) => policy.edgeType
12675
+ );
10538
12676
  var createEdgeArgs = z.object({
10539
12677
  from: GraphRefSchema,
10540
12678
  to: GraphRefSchema,
10541
- edgeType: z.string(),
12679
+ edgeType: z.enum(CREATE_EDGE_TYPES),
10542
12680
  globalId: z.string().optional(),
10543
12681
  weight: z.number().optional(),
10544
12682
  confidence: z.number().optional(),
10545
12683
  context: z.string().optional(),
10546
12684
  reasoning: z.string().optional(),
10547
12685
  derivationType: z.string().optional(),
12686
+ metadata: z.record(z.unknown()).optional(),
10548
12687
  topicId: z.string().optional(),
10549
12688
  trustedBypassAccessCheck: z.boolean().optional()
10550
12689
  });
12690
+ var updateEdgeArgs = z.object({
12691
+ edgeId: z.string().describe("Edge ID or global ID."),
12692
+ weight: z.number().optional(),
12693
+ confidence: z.number().optional(),
12694
+ context: z.string().optional(),
12695
+ reasoning: z.string().optional(),
12696
+ derivationType: z.string().optional(),
12697
+ metadata: z.record(z.unknown()).optional(),
12698
+ userId: z.string().optional()
12699
+ });
12700
+ var removeEdgeArgs = z.object({
12701
+ edgeId: z.string().describe("Edge ID or global ID."),
12702
+ userId: z.string().optional()
12703
+ });
12704
+ var removeEdgesBetweenArgs = z.object({
12705
+ from: GraphRefSchema.optional(),
12706
+ to: GraphRefSchema.optional(),
12707
+ fromNodeId: z.string().optional(),
12708
+ toNodeId: z.string().optional(),
12709
+ edgeType: z.enum(CREATE_EDGE_TYPES).optional()
12710
+ });
12711
+ var batchCreateEdgesArgs = z.object({
12712
+ edges: z.array(createEdgeArgs),
12713
+ skipLayerValidation: z.boolean().optional()
12714
+ });
12715
+ var queryLineageArgs = z.object({
12716
+ nodeId: z.string().describe("Starting node to trace from."),
12717
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
12718
+ depth: z.number().optional().describe("Traversal depth alias."),
12719
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12720
+ mode: z.string().optional().describe("Traversal mode."),
12721
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12722
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12723
+ });
10551
12724
  function graphRefNodeId(ref) {
10552
12725
  if (ref.kind === "epistemic_node") {
10553
12726
  return ref.nodeId;
@@ -10588,6 +12761,7 @@ var edgesContracts = [
10588
12761
  confidence: parsed.confidence,
10589
12762
  context: parsed.context ?? parsed.reasoning,
10590
12763
  derivationType: parsed.derivationType,
12764
+ metadata: parsed.metadata,
10591
12765
  skipLayerValidation: true,
10592
12766
  topicId: parsed.topicId,
10593
12767
  trustedBypassAccessCheck: parsed.trustedBypassAccessCheck
@@ -10598,6 +12772,130 @@ var edgesContracts = [
10598
12772
  },
10599
12773
  args: createEdgeArgs
10600
12774
  }),
12775
+ surfaceContract({
12776
+ name: "update_edge",
12777
+ kind: "mutation",
12778
+ domain: "edges",
12779
+ surfaceClass: "platform_public",
12780
+ method: "PATCH",
12781
+ path: "/edges",
12782
+ sdkNamespace: "edges",
12783
+ sdkMethod: "updateEdge",
12784
+ summary: "Update an epistemic edge.",
12785
+ convex: {
12786
+ module: "edges",
12787
+ functionName: "update",
12788
+ kind: "mutation",
12789
+ inputProjection: (input, context) => compactRecord4({
12790
+ edgeId: input.edgeId,
12791
+ weight: input.weight,
12792
+ confidence: input.confidence,
12793
+ context: input.context ?? input.reasoning,
12794
+ derivationType: input.derivationType,
12795
+ metadata: input.metadata,
12796
+ userId: input.userId ?? context.userId ?? context.principalId
12797
+ })
12798
+ },
12799
+ args: updateEdgeArgs
12800
+ }),
12801
+ surfaceContract({
12802
+ name: "remove_edge",
12803
+ kind: "mutation",
12804
+ domain: "edges",
12805
+ surfaceClass: "platform_public",
12806
+ method: "DELETE",
12807
+ path: "/edges",
12808
+ sdkNamespace: "edges",
12809
+ sdkMethod: "removeEdge",
12810
+ summary: "Remove an epistemic edge.",
12811
+ convex: {
12812
+ module: "edges",
12813
+ functionName: "remove",
12814
+ kind: "mutation",
12815
+ inputProjection: (input, context) => compactRecord4({
12816
+ edgeId: input.edgeId,
12817
+ userId: input.userId ?? context.userId ?? context.principalId
12818
+ })
12819
+ },
12820
+ args: removeEdgeArgs
12821
+ }),
12822
+ surfaceContract({
12823
+ name: "remove_edges_between",
12824
+ kind: "mutation",
12825
+ domain: "edges",
12826
+ surfaceClass: "platform_public",
12827
+ method: "DELETE",
12828
+ path: "/edges/between",
12829
+ sdkNamespace: "edges",
12830
+ sdkMethod: "removeEdgesBetween",
12831
+ summary: "Remove epistemic edges between two nodes.",
12832
+ convex: {
12833
+ module: "edges",
12834
+ functionName: "removeBetween",
12835
+ kind: "mutation",
12836
+ inputProjection: (input) => {
12837
+ const parsed = removeEdgesBetweenArgs.parse(input);
12838
+ const fromNodeId = parsed.from ? graphRefNodeId(parsed.from) : parsed.fromNodeId;
12839
+ const toNodeId = parsed.to ? graphRefNodeId(parsed.to) : parsed.toNodeId;
12840
+ if (!fromNodeId || !toNodeId) {
12841
+ throw new Error("from/to or fromNodeId/toNodeId are required.");
12842
+ }
12843
+ return compactRecord4({
12844
+ fromNodeId,
12845
+ toNodeId,
12846
+ edgeType: parsed.edgeType
12847
+ });
12848
+ }
12849
+ },
12850
+ args: removeEdgesBetweenArgs
12851
+ }),
12852
+ surfaceContract({
12853
+ name: "batch_create_edges",
12854
+ kind: "mutation",
12855
+ domain: "edges",
12856
+ surfaceClass: "platform_public",
12857
+ path: "/edges/batch",
12858
+ sdkNamespace: "edges",
12859
+ sdkMethod: "batchCreateEdges",
12860
+ summary: "Batch create epistemic edges.",
12861
+ convex: {
12862
+ module: "edges",
12863
+ functionName: "batchCreate",
12864
+ kind: "mutation",
12865
+ inputProjection: (input, context) => {
12866
+ const parsed = batchCreateEdgesArgs.parse(input);
12867
+ return {
12868
+ skipLayerValidation: parsed.skipLayerValidation ?? true,
12869
+ edges: parsed.edges.map((edge) => {
12870
+ assertEdgePolicyAllowed(
12871
+ edgePolicyManifest,
12872
+ edge.edgeType,
12873
+ edge.from,
12874
+ edge.to
12875
+ );
12876
+ const fromNodeId = graphRefNodeId(edge.from);
12877
+ const toNodeId = graphRefNodeId(edge.to);
12878
+ return withCreatedBy(
12879
+ compactRecord4({
12880
+ fromNodeId,
12881
+ toNodeId,
12882
+ edgeType: edge.edgeType,
12883
+ globalId: edge.globalId ?? `edge:${fromNodeId}:${toNodeId}:${edge.edgeType}`,
12884
+ weight: edge.weight,
12885
+ confidence: edge.confidence,
12886
+ context: edge.context ?? edge.reasoning,
12887
+ derivationType: edge.derivationType,
12888
+ metadata: edge.metadata,
12889
+ topicId: edge.topicId
12890
+ }),
12891
+ context
12892
+ );
12893
+ })
12894
+ };
12895
+ }
12896
+ },
12897
+ args: batchCreateEdgesArgs
12898
+ }),
10601
12899
  surfaceContract({
10602
12900
  name: "query_lineage",
10603
12901
  kind: "query",
@@ -10618,11 +12916,84 @@ var edgesContracts = [
10618
12916
  minLayer: input.minLayer,
10619
12917
  maxLayer: input.maxLayer
10620
12918
  })
10621
- }
12919
+ },
12920
+ args: queryLineageArgs
10622
12921
  })
10623
12922
  ];
10624
-
10625
- // ../contracts/src/function-registry/graph.ts
12923
+ var graphIntelligenceQueryModes = [
12924
+ "core",
12925
+ "bias",
12926
+ "stress",
12927
+ "operational",
12928
+ "alpha",
12929
+ "semantic",
12930
+ "evidence"
12931
+ ];
12932
+ var traversalLayerSchema = z.enum([
12933
+ "L4",
12934
+ "L3",
12935
+ "L2",
12936
+ "L1",
12937
+ "ontological",
12938
+ "organizational"
12939
+ ]);
12940
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
12941
+ var lineageAliasArgs = z.object({
12942
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
12943
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
12944
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
12945
+ depth: z.number().optional().describe("Traversal depth alias."),
12946
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12947
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
12948
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
12949
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
12950
+ });
12951
+ var lineageArgs = lineageAliasArgs.extend({
12952
+ nodeId: z.string().describe("Starting node to traverse from.")
12953
+ });
12954
+ var traverseGraphArgs = lineageAliasArgs.extend({
12955
+ startNode: z.string().describe("Node to start traversal from."),
12956
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
12957
+ });
12958
+ var graphNeighborhoodArgs = z.object({
12959
+ globalId: z.string().optional().describe("Single root global ID."),
12960
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
12961
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12962
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
12963
+ limit: z.number().optional().describe("Maximum edges to return.")
12964
+ });
12965
+ var graphIntelligenceModeSchema = z.enum([
12966
+ graphIntelligenceQueryModes[0],
12967
+ ...graphIntelligenceQueryModes.slice(1)
12968
+ ]);
12969
+ var graphIntelligenceCatalogArgs = z.object({
12970
+ categoryId: z.string().optional().describe("Optional query category filter."),
12971
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
12972
+ });
12973
+ var graphIntelligenceRunArgs = z.object({
12974
+ topicId: z.string().describe("Topic to analyze."),
12975
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
12976
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
12977
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
12978
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
12979
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
12980
+ });
12981
+ var flagContradictionArgs = z.object({
12982
+ beliefA: z.string().describe("First belief in tension."),
12983
+ beliefB: z.string().describe("Second belief in tension."),
12984
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
12985
+ description: z.string().optional().describe("Human-readable contradiction."),
12986
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
12987
+ defeatType: z.string().optional().describe("Defeat type annotation."),
12988
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
12989
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
12990
+ });
12991
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
12992
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
12993
+ topicId: z.string().optional().describe("Topic scope override."),
12994
+ minScore: z.number().optional().describe("Minimum match score."),
12995
+ limit: z.number().optional().describe("Maximum candidates to return.")
12996
+ });
10626
12997
  var contradictionSeverity = (value) => {
10627
12998
  switch (value) {
10628
12999
  case "critical":
@@ -10677,7 +13048,8 @@ var graphContracts = [
10677
13048
  functionName: "getLineage",
10678
13049
  kind: "query",
10679
13050
  inputProjection: lineageInput
10680
- }
13051
+ },
13052
+ args: traverseGraphArgs
10681
13053
  }),
10682
13054
  surfaceContract({
10683
13055
  name: "get_graph_neighborhood",
@@ -10693,7 +13065,8 @@ var graphContracts = [
10693
13065
  functionName: "getByTopic",
10694
13066
  kind: "query",
10695
13067
  inputProjection: topicEdgesInput
10696
- }
13068
+ },
13069
+ args: graphNeighborhoodArgs
10697
13070
  }),
10698
13071
  surfaceContract({
10699
13072
  name: "get_graph_structure_analysis",
@@ -10710,6 +13083,38 @@ var graphContracts = [
10710
13083
  kind: "query"
10711
13084
  }
10712
13085
  }),
13086
+ surfaceContract({
13087
+ name: "list_graph_intelligence_queries",
13088
+ kind: "query",
13089
+ domain: "graph",
13090
+ surfaceClass: "platform_public",
13091
+ path: "/graph-intelligence/queries",
13092
+ sdkNamespace: "graphAnalysis",
13093
+ sdkMethod: "listGraphIntelligenceQueries",
13094
+ summary: "List Graph Intelligence query catalog entries.",
13095
+ convex: {
13096
+ module: "contextCompiler",
13097
+ functionName: "listGraphIntelligenceQueries",
13098
+ kind: "query"
13099
+ },
13100
+ args: graphIntelligenceCatalogArgs
13101
+ }),
13102
+ surfaceContract({
13103
+ name: "run_graph_intelligence_query",
13104
+ kind: "query",
13105
+ domain: "graph",
13106
+ surfaceClass: "platform_public",
13107
+ path: "/graph-intelligence/run",
13108
+ sdkNamespace: "graphAnalysis",
13109
+ sdkMethod: "runGraphIntelligenceQuery",
13110
+ summary: "Run a Graph Intelligence query against a topic graph.",
13111
+ convex: {
13112
+ module: "contextCompiler",
13113
+ functionName: "runGraphIntelligenceQuery",
13114
+ kind: "query"
13115
+ },
13116
+ args: graphIntelligenceRunArgs
13117
+ }),
10713
13118
  surfaceContract({
10714
13119
  name: "find_contradictions",
10715
13120
  kind: "query",
@@ -10742,7 +13147,8 @@ var graphContracts = [
10742
13147
  functionName: "create",
10743
13148
  kind: "mutation",
10744
13149
  inputProjection: flagContradictionInput
10745
- }
13150
+ },
13151
+ args: flagContradictionArgs
10746
13152
  }),
10747
13153
  surfaceContract({
10748
13154
  name: "detect_confirmation_bias",
@@ -10833,7 +13239,8 @@ var graphContracts = [
10833
13239
  functionName: "getLineage",
10834
13240
  kind: "query",
10835
13241
  inputProjection: lineageInput
10836
- }
13242
+ },
13243
+ args: discoverEntityConnectionsArgs
10837
13244
  }),
10838
13245
  surfaceContract({
10839
13246
  name: "trigger_belief_review",
@@ -10864,7 +13271,8 @@ var graphContracts = [
10864
13271
  functionName: "getLineage",
10865
13272
  kind: "query",
10866
13273
  inputProjection: lineageInput
10867
- }
13274
+ },
13275
+ args: lineageArgs
10868
13276
  })
10869
13277
  ];
10870
13278
 
@@ -10916,8 +13324,16 @@ var contractsContracts = [
10916
13324
  }
10917
13325
  })
10918
13326
  ];
10919
-
10920
- // ../contracts/src/function-registry/judgments.ts
13327
+ var auditTrailArgs = z.object({
13328
+ nodeId: z.string().describe("The node to audit."),
13329
+ id: z.string().optional().describe("Node ID alias."),
13330
+ limit: z.number().optional().describe("Maximum entries to return."),
13331
+ depth: z.number().optional().describe("Traversal depth alias."),
13332
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
13333
+ mode: z.string().optional().describe("Traversal mode."),
13334
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
13335
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
13336
+ });
10921
13337
  var judgmentsContracts = [
10922
13338
  surfaceContract({
10923
13339
  name: "record_judgment",
@@ -10972,7 +13388,8 @@ var judgmentsContracts = [
10972
13388
  minLayer: input.minLayer,
10973
13389
  maxLayer: input.maxLayer
10974
13390
  })
10975
- }
13391
+ },
13392
+ args: auditTrailArgs
10976
13393
  })
10977
13394
  ];
10978
13395
 
@@ -11140,8 +13557,13 @@ var coordinationContracts = [
11140
13557
  }
11141
13558
  })
11142
13559
  ];
11143
-
11144
- // ../contracts/src/function-registry/pipeline.ts
13560
+ var pipelineSnapshotArgs = z.object({
13561
+ topicId: z.string().describe("Topic scope ID."),
13562
+ status: z.string().optional().describe("Worktree status filter."),
13563
+ lane: z.string().optional().describe("Campaign lane filter."),
13564
+ campaign: z.number().optional().describe("Campaign number filter."),
13565
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
13566
+ });
11145
13567
  var pipelineContracts = [
11146
13568
  surfaceContract({
11147
13569
  name: "pipeline_snapshot",
@@ -11162,7 +13584,8 @@ var pipelineContracts = [
11162
13584
  campaign: input.campaign,
11163
13585
  limit: input.limit
11164
13586
  })
11165
- }
13587
+ },
13588
+ args: pipelineSnapshotArgs
11166
13589
  }),
11167
13590
  surfaceContract({
11168
13591
  name: "seed_belief_lattice",
@@ -11214,7 +13637,31 @@ var recordScopeLearningArgs = z.object({
11214
13637
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11215
13638
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11216
13639
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11217
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
13640
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
13641
+ text: z.string().optional().describe("Canonical learning text alias."),
13642
+ content: z.string().optional().describe("Canonical learning content alias."),
13643
+ kind: z.string().optional().describe("Evidence kind to store."),
13644
+ sourceType: z.string().optional().describe("Evidence source type."),
13645
+ externalSourceType: z.string().optional().describe("External source type alias."),
13646
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
13647
+ });
13648
+ var codeContextArgs = z.object({
13649
+ topicId: z.string().optional().describe("Topic scope."),
13650
+ filePath: z.string().optional().describe("File path anchor."),
13651
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
13652
+ limit: z.number().optional().describe("Maximum records to return."),
13653
+ status: z.string().optional().describe("Evidence status filter.")
13654
+ });
13655
+ var recordAttemptArgs = z.object({
13656
+ topicId: z.string().optional().describe("Topic scope."),
13657
+ description: z.string().describe("Attempt description."),
13658
+ errorMessage: z.string().optional().describe("Failure or error message."),
13659
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
13660
+ filePath: z.string().optional().describe("Single file path alias."),
13661
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
13662
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
13663
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
13664
+ title: z.string().optional().describe("Attempt evidence title.")
11218
13665
  });
11219
13666
  var learningInput = (input, context) => {
11220
13667
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11331,7 +13778,8 @@ var codingContracts = [
11331
13778
  status: input.status,
11332
13779
  userId: input.userId
11333
13780
  })
11334
- }
13781
+ },
13782
+ args: codeContextArgs
11335
13783
  }),
11336
13784
  surfaceContract({
11337
13785
  name: "get_change_history",
@@ -11368,7 +13816,8 @@ var codingContracts = [
11368
13816
  functionName: "create",
11369
13817
  kind: "mutation",
11370
13818
  inputProjection: attemptInput
11371
- }
13819
+ },
13820
+ args: recordAttemptArgs
11372
13821
  }),
11373
13822
  surfaceContract({
11374
13823
  name: "get_failure_log",
@@ -11425,6 +13874,7 @@ var ALL_FUNCTION_CONTRACTS = [
11425
13874
  ...evidenceContracts,
11426
13875
  ...questionsContracts,
11427
13876
  ...topicsContracts,
13877
+ ...nodesContracts,
11428
13878
  ...lensesContracts,
11429
13879
  ...ontologiesContracts,
11430
13880
  ...worktreesContracts,
@@ -11439,9 +13889,610 @@ var ALL_FUNCTION_CONTRACTS = [
11439
13889
  ...legacyContracts
11440
13890
  ];
11441
13891
  assertSurfaceCoverage(ALL_FUNCTION_CONTRACTS);
11442
- new Map(
13892
+ var FUNCTION_CONTRACTS_BY_NAME = new Map(
11443
13893
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11444
13894
  );
13895
+ FUNCTION_CONTRACTS_BY_NAME.get.bind(
13896
+ FUNCTION_CONTRACTS_BY_NAME
13897
+ );
13898
+
13899
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
13900
+ function isCopyableSeedRequirement(entry) {
13901
+ 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;
13902
+ }
13903
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
13904
+ {
13905
+ component: "kernel",
13906
+ table: "agentMessages",
13907
+ prepopulation: "runtime_data",
13908
+ copyMode: "none",
13909
+ description: "Agent coordination messages are session data, not template data."
13910
+ },
13911
+ {
13912
+ component: "kernel",
13913
+ table: "agentSessions",
13914
+ prepopulation: "runtime_data",
13915
+ copyMode: "none",
13916
+ description: "Agent coordination sessions are created by active clients."
13917
+ },
13918
+ {
13919
+ component: "kernel",
13920
+ table: "autofixJobs",
13921
+ prepopulation: "runtime_queue",
13922
+ copyMode: "none",
13923
+ description: "Autofix work items are runtime queue rows."
13924
+ },
13925
+ {
13926
+ component: "kernel",
13927
+ table: "backgroundJobRuns",
13928
+ prepopulation: "runtime_log",
13929
+ copyMode: "none",
13930
+ description: "Background job executions are runtime logs."
13931
+ },
13932
+ {
13933
+ component: "kernel",
13934
+ table: "backgroundJobSettings",
13935
+ prepopulation: "required_template",
13936
+ copyMode: "template_global",
13937
+ scope: "global",
13938
+ uniqueKey: ["jobKey"],
13939
+ description: "Default job enablement settings must come from the K template."
13940
+ },
13941
+ {
13942
+ component: "kernel",
13943
+ table: "beliefConfidence",
13944
+ prepopulation: "runtime_data",
13945
+ copyMode: "none",
13946
+ description: "Belief confidence rows are created with tenant graph facts."
13947
+ },
13948
+ {
13949
+ component: "kernel",
13950
+ table: "beliefEvidenceLinks",
13951
+ prepopulation: "runtime_data",
13952
+ copyMode: "none",
13953
+ description: "Belief-to-evidence links are tenant graph data."
13954
+ },
13955
+ {
13956
+ component: "kernel",
13957
+ table: "beliefHistory",
13958
+ prepopulation: "runtime_data",
13959
+ copyMode: "none",
13960
+ description: "Belief history is append-only tenant graph data."
13961
+ },
13962
+ {
13963
+ component: "kernel",
13964
+ table: "beliefScenarios",
13965
+ prepopulation: "runtime_data",
13966
+ copyMode: "none",
13967
+ description: "Scenario rows are tenant-authored reasoning data."
13968
+ },
13969
+ {
13970
+ component: "kernel",
13971
+ table: "beliefVotes",
13972
+ prepopulation: "runtime_data",
13973
+ copyMode: "none",
13974
+ description: "Decision belief votes are tenant-authored data."
13975
+ },
13976
+ {
13977
+ component: "kernel",
13978
+ table: "calibrationScores",
13979
+ prepopulation: "runtime_derived",
13980
+ copyMode: "none",
13981
+ description: "Calibration scores are computed from tenant outcomes."
13982
+ },
13983
+ {
13984
+ component: "kernel",
13985
+ table: "contractEvaluations",
13986
+ prepopulation: "runtime_log",
13987
+ copyMode: "none",
13988
+ description: "Contract evaluation rows are runtime computation logs."
13989
+ },
13990
+ {
13991
+ component: "kernel",
13992
+ table: "contradictions",
13993
+ prepopulation: "runtime_data",
13994
+ copyMode: "none",
13995
+ description: "Contradictions are tenant graph facts."
13996
+ },
13997
+ {
13998
+ component: "kernel",
13999
+ table: "crossProjectConnections",
14000
+ prepopulation: "runtime_data",
14001
+ copyMode: "none",
14002
+ description: "Cross-topic connections are tenant graph facts."
14003
+ },
14004
+ {
14005
+ component: "kernel",
14006
+ table: "decisionComputedSummaries",
14007
+ prepopulation: "runtime_derived",
14008
+ copyMode: "none",
14009
+ description: "Decision summaries are derived tenant outputs."
14010
+ },
14011
+ {
14012
+ component: "kernel",
14013
+ table: "decisionEvents",
14014
+ prepopulation: "runtime_data",
14015
+ copyMode: "none",
14016
+ description: "Decision events are lifecycle data."
14017
+ },
14018
+ {
14019
+ component: "kernel",
14020
+ table: "decisionParticipants",
14021
+ prepopulation: "runtime_data",
14022
+ copyMode: "none",
14023
+ description: "Decision participants are tenant-selected actors."
14024
+ },
14025
+ {
14026
+ component: "kernel",
14027
+ table: "decisionRiskLedger",
14028
+ prepopulation: "runtime_data",
14029
+ copyMode: "none",
14030
+ description: "Decision risk rows are tenant decision data."
14031
+ },
14032
+ {
14033
+ component: "kernel",
14034
+ table: "decisionSnapshots",
14035
+ prepopulation: "runtime_derived",
14036
+ copyMode: "none",
14037
+ description: "Decision snapshots are derived from tenant state."
14038
+ },
14039
+ {
14040
+ component: "kernel",
14041
+ table: "deliberationContributions",
14042
+ prepopulation: "runtime_data",
14043
+ copyMode: "none",
14044
+ description: "Deliberation contributions are tenant-authored data."
14045
+ },
14046
+ {
14047
+ component: "kernel",
14048
+ table: "deliberationSessions",
14049
+ prepopulation: "runtime_data",
14050
+ copyMode: "none",
14051
+ description: "Deliberation sessions are created by tenant workflows."
14052
+ },
14053
+ {
14054
+ component: "kernel",
14055
+ table: "epistemicAudit",
14056
+ prepopulation: "runtime_log",
14057
+ copyMode: "none",
14058
+ description: "Epistemic audit rows are append-only runtime audit data."
14059
+ },
14060
+ {
14061
+ component: "kernel",
14062
+ table: "epistemicContracts",
14063
+ prepopulation: "runtime_data",
14064
+ copyMode: "none",
14065
+ description: "Epistemic contracts are tenant-authored governance data."
14066
+ },
14067
+ {
14068
+ component: "kernel",
14069
+ table: "epistemicEdges",
14070
+ prepopulation: "runtime_data",
14071
+ copyMode: "none",
14072
+ description: "Edges are tenant reasoning graph data."
14073
+ },
14074
+ {
14075
+ component: "kernel",
14076
+ table: "epistemicNodeEmbeddings",
14077
+ prepopulation: "runtime_derived",
14078
+ copyMode: "none",
14079
+ description: "Embeddings are derived from tenant graph nodes."
14080
+ },
14081
+ {
14082
+ component: "kernel",
14083
+ table: "epistemicNodes",
14084
+ prepopulation: "runtime_data",
14085
+ copyMode: "none",
14086
+ description: "Nodes are tenant reasoning graph data."
14087
+ },
14088
+ {
14089
+ component: "kernel",
14090
+ table: "graphAnalysisCache",
14091
+ prepopulation: "runtime_derived",
14092
+ copyMode: "none",
14093
+ description: "Graph analysis cache rows are derived from tenant graph state."
14094
+ },
14095
+ {
14096
+ component: "kernel",
14097
+ table: "graphAnalysisResults",
14098
+ prepopulation: "runtime_derived",
14099
+ copyMode: "none",
14100
+ description: "Graph analysis result rows are derived tenant outputs."
14101
+ },
14102
+ {
14103
+ component: "kernel",
14104
+ table: "graphSuggestions",
14105
+ prepopulation: "runtime_derived",
14106
+ copyMode: "none",
14107
+ description: "Graph suggestions are derived recommendations."
14108
+ },
14109
+ {
14110
+ component: "kernel",
14111
+ table: "harnessReplays",
14112
+ prepopulation: "runtime_log",
14113
+ copyMode: "none",
14114
+ description: "Harness replay rows are runtime verification logs."
14115
+ },
14116
+ {
14117
+ component: "kernel",
14118
+ table: "harnessRuns",
14119
+ prepopulation: "runtime_log",
14120
+ copyMode: "none",
14121
+ description: "Harness run rows are runtime verification logs."
14122
+ },
14123
+ {
14124
+ component: "kernel",
14125
+ table: "idempotencyTokens",
14126
+ prepopulation: "runtime_log",
14127
+ copyMode: "none",
14128
+ description: "Idempotency tokens are request-scoped runtime guards."
14129
+ },
14130
+ {
14131
+ component: "kernel",
14132
+ table: "lenses",
14133
+ prepopulation: "optional_template",
14134
+ copyMode: "none",
14135
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
14136
+ },
14137
+ {
14138
+ component: "kernel",
14139
+ table: "lensTopicBindings",
14140
+ prepopulation: "runtime_data",
14141
+ copyMode: "none",
14142
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
14143
+ },
14144
+ {
14145
+ component: "kernel",
14146
+ table: "neo4jSyncQueue",
14147
+ prepopulation: "runtime_queue",
14148
+ copyMode: "none",
14149
+ description: "Neo4j sync queue rows are runtime work items."
14150
+ },
14151
+ {
14152
+ component: "kernel",
14153
+ table: "ontologyDefinitions",
14154
+ prepopulation: "required_template",
14155
+ copyMode: "template_global",
14156
+ scope: "global",
14157
+ uniqueKey: ["ontologyKey"],
14158
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
14159
+ },
14160
+ {
14161
+ component: "kernel",
14162
+ table: "ontologyVersions",
14163
+ prepopulation: "required_template",
14164
+ copyMode: "template_reference_remap",
14165
+ scope: "global",
14166
+ uniqueKey: ["ontologyKey", "version"],
14167
+ dependsOn: ["ontologyDefinitions"],
14168
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
14169
+ },
14170
+ {
14171
+ component: "kernel",
14172
+ table: "platformAgentRunPolicyDecisions",
14173
+ prepopulation: "runtime_log",
14174
+ copyMode: "none",
14175
+ description: "Agent-run policy decisions are audit logs."
14176
+ },
14177
+ {
14178
+ component: "kernel",
14179
+ table: "platformAgentRunPromptResolutions",
14180
+ prepopulation: "runtime_log",
14181
+ copyMode: "none",
14182
+ description: "Agent-run prompt resolution rows are runtime logs."
14183
+ },
14184
+ {
14185
+ component: "kernel",
14186
+ table: "platformAgentRuns",
14187
+ prepopulation: "runtime_log",
14188
+ copyMode: "none",
14189
+ description: "Agent runs are runtime execution records."
14190
+ },
14191
+ {
14192
+ component: "kernel",
14193
+ table: "platformAgentRunToolCalls",
14194
+ prepopulation: "runtime_log",
14195
+ copyMode: "none",
14196
+ description: "Agent-run tool calls are runtime execution records."
14197
+ },
14198
+ {
14199
+ component: "kernel",
14200
+ table: "platformHarnessShadowAudit",
14201
+ prepopulation: "runtime_log",
14202
+ copyMode: "none",
14203
+ description: "Harness shadow audit rows are runtime audit records."
14204
+ },
14205
+ {
14206
+ component: "kernel",
14207
+ table: "publicationRules",
14208
+ prepopulation: "required_template",
14209
+ copyMode: "template_tenant_rewrite",
14210
+ scope: "tenant",
14211
+ uniqueKey: ["tenantId", "workspaceId", "name"],
14212
+ description: "Default publication policy rules are rewritten into each tenant."
14213
+ },
14214
+ {
14215
+ component: "kernel",
14216
+ table: "questionEvidenceLinks",
14217
+ prepopulation: "runtime_data",
14218
+ copyMode: "none",
14219
+ description: "Question-to-evidence links are tenant graph data."
14220
+ },
14221
+ {
14222
+ component: "kernel",
14223
+ table: "researchJobs",
14224
+ prepopulation: "runtime_queue",
14225
+ copyMode: "none",
14226
+ description: "Research job rows are runtime queue items."
14227
+ },
14228
+ {
14229
+ component: "kernel",
14230
+ table: "schemaEnumConfig",
14231
+ prepopulation: "required_template",
14232
+ copyMode: "template_global",
14233
+ scope: "global",
14234
+ uniqueKey: ["category", "value"],
14235
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
14236
+ },
14237
+ {
14238
+ component: "kernel",
14239
+ table: "stakeholderGroups",
14240
+ prepopulation: "runtime_data",
14241
+ copyMode: "none",
14242
+ description: "Stakeholder groups are tenant decision data."
14243
+ },
14244
+ {
14245
+ component: "kernel",
14246
+ table: "systemLogs",
14247
+ prepopulation: "runtime_log",
14248
+ copyMode: "none",
14249
+ description: "System logs are runtime telemetry."
14250
+ },
14251
+ {
14252
+ component: "kernel",
14253
+ table: "tasks",
14254
+ prepopulation: "runtime_data",
14255
+ copyMode: "none",
14256
+ description: "Tasks are tenant-authored work items."
14257
+ },
14258
+ {
14259
+ component: "kernel",
14260
+ table: "topics",
14261
+ prepopulation: "runtime_bootstrap",
14262
+ copyMode: "none",
14263
+ description: "Default topics are created by tenant provisioning, not copied from templates."
14264
+ },
14265
+ {
14266
+ component: "kernel",
14267
+ table: "workflowDefinitions",
14268
+ prepopulation: "optional_template",
14269
+ copyMode: "none",
14270
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
14271
+ },
14272
+ {
14273
+ component: "kernel",
14274
+ table: "workflowPullRequests",
14275
+ prepopulation: "runtime_data",
14276
+ copyMode: "none",
14277
+ description: "Workflow pull requests are tenant workflow data."
14278
+ },
14279
+ {
14280
+ component: "kernel",
14281
+ table: "workflowStages",
14282
+ prepopulation: "optional_template",
14283
+ copyMode: "none",
14284
+ dependsOn: ["workflowDefinitions"],
14285
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
14286
+ },
14287
+ {
14288
+ component: "kernel",
14289
+ table: "worktreeBeliefCluster",
14290
+ prepopulation: "runtime_data",
14291
+ copyMode: "none",
14292
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
14293
+ },
14294
+ {
14295
+ component: "kernel",
14296
+ table: "worktrees",
14297
+ prepopulation: "runtime_data",
14298
+ copyMode: "none",
14299
+ description: "Worktrees are tenant/runtime planning data."
14300
+ },
14301
+ {
14302
+ component: "identity",
14303
+ table: "agents",
14304
+ prepopulation: "runtime_bootstrap",
14305
+ copyMode: "none",
14306
+ description: "Service agents are provisioned per tenant or service, not copied."
14307
+ },
14308
+ {
14309
+ component: "identity",
14310
+ table: "mcpWritePolicy",
14311
+ prepopulation: "required_template",
14312
+ copyMode: "template_global",
14313
+ scope: "global",
14314
+ uniqueKey: ["topicId", "role", "toolCategory"],
14315
+ description: "Global write policy defaults govern service and interactive MCP writes."
14316
+ },
14317
+ {
14318
+ component: "identity",
14319
+ table: "modelCallLogs",
14320
+ prepopulation: "runtime_log",
14321
+ copyMode: "none",
14322
+ description: "Model call logs are runtime telemetry."
14323
+ },
14324
+ {
14325
+ component: "identity",
14326
+ table: "modelFunctionSlots",
14327
+ prepopulation: "required_template",
14328
+ copyMode: "template_global",
14329
+ scope: "global",
14330
+ uniqueKey: ["slot"],
14331
+ description: "Function-to-model slots are required by model runtime resolution."
14332
+ },
14333
+ {
14334
+ component: "identity",
14335
+ table: "modelRegistry",
14336
+ prepopulation: "required_template",
14337
+ copyMode: "template_global",
14338
+ scope: "global",
14339
+ uniqueKey: ["key"],
14340
+ description: "Model catalog defaults are required by model runtime clients."
14341
+ },
14342
+ {
14343
+ component: "identity",
14344
+ table: "modelSlotConfigs",
14345
+ prepopulation: "required_template",
14346
+ copyMode: "template_global",
14347
+ scope: "global",
14348
+ uniqueKey: ["slot"],
14349
+ description: "Slot-level defaults are required before tenant overrides exist."
14350
+ },
14351
+ {
14352
+ component: "identity",
14353
+ table: "platformAudienceGrants",
14354
+ prepopulation: "runtime_data",
14355
+ copyMode: "none",
14356
+ description: "Audience grants are principal/group-specific access rows."
14357
+ },
14358
+ {
14359
+ component: "identity",
14360
+ table: "platformAudiences",
14361
+ prepopulation: "required_template",
14362
+ copyMode: "template_tenant_rewrite",
14363
+ scope: "tenant",
14364
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
14365
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
14366
+ },
14367
+ {
14368
+ component: "identity",
14369
+ table: "platformPolicyDecisionLogs",
14370
+ prepopulation: "runtime_log",
14371
+ copyMode: "none",
14372
+ description: "Policy decisions are runtime audit logs."
14373
+ },
14374
+ {
14375
+ component: "identity",
14376
+ table: "projectGrants",
14377
+ prepopulation: "runtime_data",
14378
+ copyMode: "none",
14379
+ description: "Project/topic grants are principal or group-specific access rows."
14380
+ },
14381
+ {
14382
+ component: "identity",
14383
+ table: "reasoningPermissions",
14384
+ prepopulation: "runtime_data",
14385
+ copyMode: "none",
14386
+ description: "Reasoning permissions are principal-specific policy rows."
14387
+ },
14388
+ {
14389
+ component: "identity",
14390
+ table: "tenantApiKeys",
14391
+ prepopulation: "runtime_secret",
14392
+ copyMode: "none",
14393
+ description: "API keys are tenant credentials and must never be copied."
14394
+ },
14395
+ {
14396
+ component: "identity",
14397
+ table: "tenantConfig",
14398
+ prepopulation: "required_template",
14399
+ copyMode: "template_tenant_rewrite",
14400
+ scope: "tenant",
14401
+ uniqueKey: ["tenantId"],
14402
+ description: "Tenant-local config defaults are rewritten during bootstrap."
14403
+ },
14404
+ {
14405
+ component: "identity",
14406
+ table: "tenantIntegrations",
14407
+ prepopulation: "required_template",
14408
+ copyMode: "template_tenant_rewrite",
14409
+ scope: "tenant",
14410
+ uniqueKey: ["tenantId", "integrationKey"],
14411
+ description: "Non-secret integration descriptors are rewritten into each tenant."
14412
+ },
14413
+ {
14414
+ component: "identity",
14415
+ table: "tenantModelSlotBindings",
14416
+ prepopulation: "runtime_secret",
14417
+ copyMode: "none",
14418
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
14419
+ },
14420
+ {
14421
+ component: "identity",
14422
+ table: "tenantPolicies",
14423
+ prepopulation: "required_template",
14424
+ copyMode: "template_tenant_rewrite",
14425
+ scope: "tenant",
14426
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
14427
+ description: "Default tenant policy roles are rewritten during bootstrap."
14428
+ },
14429
+ {
14430
+ component: "identity",
14431
+ table: "tenantProviderSecrets",
14432
+ prepopulation: "runtime_secret",
14433
+ copyMode: "none",
14434
+ description: "Provider secrets are credentials and must never be copied."
14435
+ },
14436
+ {
14437
+ component: "identity",
14438
+ table: "tenantProxyGatewayUsage",
14439
+ prepopulation: "runtime_log",
14440
+ copyMode: "none",
14441
+ description: "Proxy gateway usage rows are runtime telemetry."
14442
+ },
14443
+ {
14444
+ component: "identity",
14445
+ table: "tenantProxyTokenMints",
14446
+ prepopulation: "runtime_secret",
14447
+ copyMode: "none",
14448
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
14449
+ },
14450
+ {
14451
+ component: "identity",
14452
+ table: "tenantSandboxAuditEvents",
14453
+ prepopulation: "runtime_log",
14454
+ copyMode: "none",
14455
+ description: "Sandbox audit rows are runtime security logs."
14456
+ },
14457
+ {
14458
+ component: "identity",
14459
+ table: "tenantSecrets",
14460
+ prepopulation: "runtime_secret",
14461
+ copyMode: "none",
14462
+ description: "Tenant secrets are credentials and must never be copied."
14463
+ },
14464
+ {
14465
+ component: "identity",
14466
+ table: "toolAcls",
14467
+ prepopulation: "required_template",
14468
+ copyMode: "template_global",
14469
+ scope: "global",
14470
+ uniqueKey: ["role", "toolName"],
14471
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
14472
+ },
14473
+ {
14474
+ component: "identity",
14475
+ table: "toolRegistry",
14476
+ prepopulation: "required_template",
14477
+ copyMode: "template_global",
14478
+ scope: "global",
14479
+ uniqueKey: ["toolName"],
14480
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
14481
+ },
14482
+ {
14483
+ component: "identity",
14484
+ table: "users",
14485
+ prepopulation: "runtime_bootstrap",
14486
+ copyMode: "none",
14487
+ description: "Users are created from Clerk/MC principal resolution, not copied."
14488
+ }
14489
+ ];
14490
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14491
+ isCopyableSeedRequirement
14492
+ );
14493
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14494
+ (entry) => !isCopyableSeedRequirement(entry)
14495
+ ).map((entry) => entry.table);
11445
14496
 
11446
14497
  export { DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, EVENT_RETENTION_DEFAULT_DAYS, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS };
11447
14498
  //# sourceMappingURL=types.js.map