@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/outbox.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;
@@ -112,7 +593,10 @@ function idOf(table) {
112
593
  return schema;
113
594
  }
114
595
  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"]);
115
- 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"]);
596
+ 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"];
597
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
598
+ z.enum(EDGE_TYPE_VALUES);
599
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
116
600
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
117
601
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
118
602
  defineTable({
@@ -1597,7 +2081,7 @@ defineTable({
1597
2081
  "toNodeId": z.string().optional(),
1598
2082
  "sourceGlobalId": z.string().optional(),
1599
2083
  "targetGlobalId": z.string().optional(),
1600
- "edgeType": EDGE_TYPE,
2084
+ "edgeType": STORAGE_EDGE_TYPE,
1601
2085
  "edgeTier": z.string().optional(),
1602
2086
  "domainNamespace": z.string().optional(),
1603
2087
  "constraint": z.string().optional(),
@@ -1940,6 +2424,40 @@ defineTable({
1940
2424
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
1941
2425
  ]
1942
2426
  });
2427
+ defineTable({
2428
+ name: "oauthDeviceCodes",
2429
+ component: "mc",
2430
+ category: "identity",
2431
+ shape: z.object({
2432
+ "deviceCodeHash": z.string(),
2433
+ "userCode": z.string(),
2434
+ "clientId": z.string(),
2435
+ "scope": z.string(),
2436
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
2437
+ "expiresAt": z.number(),
2438
+ "intervalSeconds": z.number(),
2439
+ "lastPolledAt": z.number().optional(),
2440
+ "slowDownCount": z.number().optional(),
2441
+ "clerkUserId": z.string().optional(),
2442
+ "tenantId": idOf("tenants").optional(),
2443
+ "workspaceId": z.string().optional(),
2444
+ "principalId": z.string().optional(),
2445
+ "role": z.string().optional(),
2446
+ "scopes": z.array(z.string()).optional(),
2447
+ "sessionId": z.string().optional(),
2448
+ "approvedAt": z.number().optional(),
2449
+ "deniedAt": z.number().optional(),
2450
+ "consumedAt": z.number().optional(),
2451
+ "createdAt": z.number(),
2452
+ "updatedAt": z.number()
2453
+ }),
2454
+ indices: [
2455
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
2456
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
2457
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
2458
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
2459
+ ]
2460
+ });
1943
2461
  defineTable({
1944
2462
  name: "servicePrincipalKeys",
1945
2463
  component: "mc",
@@ -3772,6 +4290,7 @@ defineTable({
3772
4290
  "updatedAt": z.number()
3773
4291
  }),
3774
4292
  indices: [
4293
+ { kind: "index", name: "by_globalId", columns: ["globalId"] },
3775
4294
  { kind: "index", name: "by_parent", columns: ["parentTopicId"] },
3776
4295
  { kind: "index", name: "by_type", columns: ["type"] },
3777
4296
  { kind: "index", name: "by_graph_scope_project", columns: ["graphScopeProjectId"] },
@@ -3896,7 +4415,9 @@ defineTable({
3896
4415
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3897
4416
  "deployments": z.record(z.object({
3898
4417
  "url": z.string(),
3899
- "encryptedDeployKey": z.string()
4418
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4419
+ "encryptedDeployKey": z.string().optional(),
4420
+ "credentialRef": z.string().optional()
3900
4421
  })).optional(),
3901
4422
  "metadata": z.record(z.any()).optional(),
3902
4423
  "createdBy": z.string().optional(),
@@ -4246,17 +4767,44 @@ z.object({
4246
4767
  message: "SL invariant b+d+u=1 violated at API boundary"
4247
4768
  }
4248
4769
  );
4249
- var EpistemicNodeTypeSchema = z.enum([
4770
+
4771
+ // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
4772
+ var NODE_TYPES = [
4773
+ "decision",
4250
4774
  "belief",
4251
- "evidence",
4252
4775
  "question",
4253
- "answer",
4776
+ "theme",
4777
+ "deal",
4254
4778
  "topic",
4779
+ "claim",
4780
+ "evidence",
4781
+ "synthesis",
4782
+ "answer",
4783
+ "atomic_fact",
4784
+ "excerpt",
4785
+ "source",
4786
+ "company",
4787
+ "person",
4788
+ "investor",
4789
+ "function",
4790
+ "value_chain"
4791
+ ];
4792
+ new Set(NODE_TYPES);
4793
+
4794
+ // ../contracts/src/types/graph-ref.ts
4795
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4255
4796
  "edge",
4256
4797
  "ontology",
4257
4798
  "lens",
4258
4799
  "contradiction"
4259
- ]);
4800
+ ];
4801
+ var GRAPH_REF_NODE_TYPES = [
4802
+ ...NODE_TYPES,
4803
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4804
+ ];
4805
+ var EpistemicNodeTypeSchema = z.enum(
4806
+ GRAPH_REF_NODE_TYPES
4807
+ );
4260
4808
  var GraphRefSchema = z.discriminatedUnion("kind", [
4261
4809
  z.object({
4262
4810
  kind: z.literal("epistemic_node"),
@@ -4304,34 +4852,142 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4304
4852
  }
4305
4853
 
4306
4854
  // ../contracts/src/manifests/edge-policy-manifest.data.ts
4855
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
4856
+ edgeType,
4857
+ fromKinds: ["epistemic_node"],
4858
+ toKinds: ["epistemic_node"],
4859
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
4860
+ });
4307
4861
  var edgePolicyManifest = {
4308
- policies: [
4309
- {
4310
- edgeType: "evidence_derived_from_evidence",
4311
- fromKinds: ["epistemic_node"],
4312
- fromNodeTypes: ["evidence"],
4313
- toKinds: ["epistemic_node"],
4314
- toNodeTypes: ["evidence"],
4315
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4316
- },
4317
- {
4318
- edgeType: "evidence_supports_belief",
4319
- fromKinds: ["epistemic_node"],
4320
- fromNodeTypes: ["evidence"],
4321
- toKinds: ["epistemic_node"],
4322
- toNodeTypes: ["belief"],
4323
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4324
- },
4325
- {
4326
- edgeType: "evidence_supports_question",
4327
- fromKinds: ["epistemic_node"],
4328
- fromNodeTypes: ["evidence"],
4329
- toKinds: ["epistemic_node"],
4330
- toNodeTypes: ["question"],
4331
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4332
- }
4333
- ]
4862
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
4334
4863
  };
4864
+
4865
+ // ../contracts/src/tenant-client.contract.ts
4866
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4867
+ {
4868
+ packageName: "@lucern/access-control",
4869
+ role: "runtime_entrypoint",
4870
+ directTenantImport: true
4871
+ },
4872
+ {
4873
+ packageName: "@lucern/agent",
4874
+ role: "platform_runtime",
4875
+ directTenantImport: false
4876
+ },
4877
+ {
4878
+ packageName: "@lucern/auth",
4879
+ role: "sdk_dependency",
4880
+ directTenantImport: false
4881
+ },
4882
+ {
4883
+ packageName: "@lucern/cli",
4884
+ role: "developer_tool",
4885
+ directTenantImport: false
4886
+ },
4887
+ {
4888
+ packageName: "@lucern/client-core",
4889
+ role: "sdk_dependency",
4890
+ directTenantImport: false
4891
+ },
4892
+ {
4893
+ packageName: "@lucern/confidence",
4894
+ role: "sdk_dependency",
4895
+ directTenantImport: false
4896
+ },
4897
+ {
4898
+ packageName: "@lucern/config",
4899
+ role: "configuration",
4900
+ directTenantImport: false
4901
+ },
4902
+ {
4903
+ packageName: "@lucern/contracts",
4904
+ role: "contract_entrypoint",
4905
+ directTenantImport: true
4906
+ },
4907
+ {
4908
+ packageName: "@lucern/control-plane",
4909
+ role: "platform_runtime",
4910
+ directTenantImport: false
4911
+ },
4912
+ {
4913
+ packageName: "@lucern/developer-kit",
4914
+ role: "developer_tool",
4915
+ directTenantImport: false
4916
+ },
4917
+ {
4918
+ packageName: "@lucern/events",
4919
+ role: "sdk_dependency",
4920
+ directTenantImport: false
4921
+ },
4922
+ {
4923
+ packageName: "@lucern/graph-primitives",
4924
+ role: "sdk_dependency",
4925
+ directTenantImport: false
4926
+ },
4927
+ {
4928
+ packageName: "@lucern/graph-sync",
4929
+ role: "host_addon_runtime",
4930
+ directTenantImport: true
4931
+ },
4932
+ {
4933
+ packageName: "@lucern/identity",
4934
+ role: "component_runtime",
4935
+ directTenantImport: false
4936
+ },
4937
+ {
4938
+ packageName: "@lucern/mcp",
4939
+ role: "runtime_entrypoint",
4940
+ directTenantImport: true
4941
+ },
4942
+ {
4943
+ packageName: "@lucern/pack-host",
4944
+ role: "platform_runtime",
4945
+ directTenantImport: false
4946
+ },
4947
+ {
4948
+ packageName: "@lucern/pack-installer",
4949
+ role: "developer_tool",
4950
+ directTenantImport: false
4951
+ },
4952
+ {
4953
+ packageName: "@lucern/proof-compiler",
4954
+ role: "developer_tool",
4955
+ directTenantImport: false
4956
+ },
4957
+ {
4958
+ packageName: "@lucern/react",
4959
+ role: "runtime_entrypoint",
4960
+ directTenantImport: true
4961
+ },
4962
+ {
4963
+ packageName: "@lucern/reasoning-kernel",
4964
+ role: "component_runtime",
4965
+ directTenantImport: false
4966
+ },
4967
+ {
4968
+ packageName: "@lucern/sdk",
4969
+ role: "runtime_entrypoint",
4970
+ directTenantImport: true
4971
+ },
4972
+ {
4973
+ packageName: "@lucern/server-core",
4974
+ role: "platform_runtime",
4975
+ directTenantImport: false
4976
+ },
4977
+ {
4978
+ packageName: "@lucern/testing",
4979
+ role: "test_support",
4980
+ directTenantImport: false
4981
+ },
4982
+ {
4983
+ packageName: "@lucern/types",
4984
+ role: "contract_entrypoint",
4985
+ directTenantImport: true
4986
+ }
4987
+ ];
4988
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
4989
+ (entry) => entry.packageName
4990
+ );
4335
4991
  z.object({
4336
4992
  manifestVersion: z.literal("1.0.0"),
4337
4993
  rules: z.array(
@@ -4392,8 +5048,11 @@ function compactRecord(input) {
4392
5048
  Object.entries(input).filter(([, value]) => value !== void 0)
4393
5049
  );
4394
5050
  }
5051
+ function isRecord(value) {
5052
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5053
+ }
4395
5054
  function recordValue(value) {
4396
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
5055
+ return isRecord(value) ? value : {};
4397
5056
  }
4398
5057
  var createEvidenceProjection = defineProjection({
4399
5058
  contractName: "create_evidence",
@@ -5093,7 +5752,22 @@ var ADD_WORKTREE = {
5093
5752
  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.",
5094
5753
  parameters: {
5095
5754
  title: { type: "string", description: "Worktree name/objective" },
5096
- topicId: { type: "string", description: "Optional topic scope hint" },
5755
+ name: {
5756
+ type: "string",
5757
+ description: "Optional storage-name alias for callers that already use backend naming"
5758
+ },
5759
+ projectId: {
5760
+ type: "string",
5761
+ description: "Legacy topicId alias or resolver hint"
5762
+ },
5763
+ topicId: {
5764
+ type: "string",
5765
+ description: "Optional topic scope hint for resolver validation"
5766
+ },
5767
+ topicHint: {
5768
+ type: "string",
5769
+ description: "Natural-language topic hint for automatic topic resolution"
5770
+ },
5097
5771
  branchId: {
5098
5772
  type: "string",
5099
5773
  description: "The branch this worktree investigates"
@@ -5106,18 +5780,107 @@ var ADD_WORKTREE = {
5106
5780
  type: "string",
5107
5781
  description: "The testable claim this worktree investigates"
5108
5782
  },
5783
+ rationale: {
5784
+ type: "string",
5785
+ description: "Why this worktree exists and why it belongs in the campaign"
5786
+ },
5787
+ worktreeType: {
5788
+ type: "string",
5789
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5790
+ },
5791
+ gate: {
5792
+ type: "string",
5793
+ description: "Exit gate name for this worktree"
5794
+ },
5795
+ startDate: {
5796
+ type: "number",
5797
+ description: "Planned start timestamp in milliseconds since epoch"
5798
+ },
5799
+ endDate: {
5800
+ type: "number",
5801
+ description: "Planned end timestamp in milliseconds since epoch"
5802
+ },
5803
+ durationWeeks: {
5804
+ type: "number",
5805
+ description: "Planned duration in weeks"
5806
+ },
5807
+ confidenceImpact: {
5808
+ type: "string",
5809
+ description: "Expected confidence impact if the worktree succeeds",
5810
+ enum: ["high", "medium", "low"]
5811
+ },
5812
+ beliefFocus: {
5813
+ type: "string",
5814
+ description: "Natural-language focus spanning the target belief neighborhood"
5815
+ },
5109
5816
  beliefIds: {
5110
5817
  type: "array",
5111
- description: "Beliefs to test in this worktree"
5818
+ description: "Legacy alias for targetBeliefIds"
5819
+ },
5820
+ beliefs: {
5821
+ type: "array",
5822
+ description: "Legacy alias for targetBeliefIds"
5823
+ },
5824
+ targetBeliefIds: {
5825
+ type: "array",
5826
+ description: "Belief node IDs this worktree is expected to test or update"
5827
+ },
5828
+ targetQuestionIds: {
5829
+ type: "array",
5830
+ description: "Question node IDs this worktree is expected to answer"
5831
+ },
5832
+ keyQuestions: {
5833
+ type: "array",
5834
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5835
+ },
5836
+ evidenceSignals: {
5837
+ type: "array",
5838
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5839
+ },
5840
+ decisionGate: {
5841
+ type: "object",
5842
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5843
+ },
5844
+ goCriteria: {
5845
+ type: "array",
5846
+ description: "Shorthand go criteria used to build decisionGate"
5847
+ },
5848
+ noGoSignals: {
5849
+ type: "array",
5850
+ description: "Shorthand no-go signals used to build decisionGate"
5851
+ },
5852
+ proofArtifacts: {
5853
+ type: "array",
5854
+ description: "Expected proof artifacts required to close the worktree"
5112
5855
  },
5113
5856
  autoShape: {
5114
5857
  type: "boolean",
5115
5858
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5116
5859
  },
5860
+ autoFixPolicy: {
5861
+ type: "object",
5862
+ description: "Policy for permitted automatic remediation inside the worktree"
5863
+ },
5117
5864
  domainPackId: {
5118
5865
  type: "string",
5119
5866
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5120
5867
  },
5868
+ tags: {
5869
+ type: "array",
5870
+ description: "Additional topic-resolution tags for the worktree"
5871
+ },
5872
+ touchedPaths: {
5873
+ type: "array",
5874
+ description: "File paths used as topic-resolution signals"
5875
+ },
5876
+ sourceRef: {
5877
+ type: "string",
5878
+ description: "Source reference used as a topic-resolution signal"
5879
+ },
5880
+ sourceKind: {
5881
+ type: "string",
5882
+ description: "Source kind used as a topic-resolution signal"
5883
+ },
5121
5884
  campaign: {
5122
5885
  type: "number",
5123
5886
  description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
@@ -5142,13 +5905,21 @@ var ADD_WORKTREE = {
5142
5905
  type: "array",
5143
5906
  description: "Worktree IDs blocked by this worktree"
5144
5907
  },
5145
- gate: {
5908
+ staffingHint: {
5146
5909
  type: "string",
5147
- description: "Exit gate name for this worktree"
5148
- }
5149
- },
5150
- required: ["title", "topicId"],
5151
- response: {
5910
+ description: "Suggested staffing or agent allocation note"
5911
+ },
5912
+ lensId: {
5913
+ type: "string",
5914
+ description: "Lens that scopes this worktree when applicable"
5915
+ },
5916
+ lastReconciledAt: {
5917
+ type: "number",
5918
+ description: "Timestamp when worktree metadata was last reconciled"
5919
+ }
5920
+ },
5921
+ required: ["title"],
5922
+ response: {
5152
5923
  description: "The created worktree",
5153
5924
  fields: {
5154
5925
  worktreeId: "string",
@@ -5174,7 +5945,7 @@ var MERGE = {
5174
5945
  worktreeId: { type: "string", description: "The worktree to merge" },
5175
5946
  outcomes: {
5176
5947
  type: "array",
5177
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5948
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5178
5949
  },
5179
5950
  summary: { type: "string", description: "Overall findings summary" }
5180
5951
  },
@@ -5392,19 +6163,23 @@ var FIND_CONTRADICTIONS = {
5392
6163
  };
5393
6164
  var CREATE_EDGE = {
5394
6165
  name: "create_edge",
5395
- 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).",
6166
+ 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.",
5396
6167
  parameters: {
5397
- sourceId: {
5398
- type: "string",
5399
- description: "Source node of the relationship"
6168
+ from: {
6169
+ type: "object",
6170
+ description: "Source graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'topic' }"
5400
6171
  },
5401
- targetId: {
5402
- type: "string",
5403
- description: "Target node of the relationship"
6172
+ to: {
6173
+ type: "object",
6174
+ description: "Target graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'belief' }"
5404
6175
  },
5405
6176
  edgeType: {
5406
6177
  type: "string",
5407
- description: "Relationship type (informs, tests, depends_on, supersedes, etc.)"
6178
+ description: "Relationship type from the public epistemic edge enum."
6179
+ },
6180
+ globalId: {
6181
+ type: "string",
6182
+ description: "Optional idempotent edge global ID."
5408
6183
  },
5409
6184
  weight: {
5410
6185
  type: "number",
@@ -5415,9 +6190,13 @@ var CREATE_EDGE = {
5415
6190
  type: "string",
5416
6191
  description: "How this was determined",
5417
6192
  enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
6193
+ },
6194
+ metadata: {
6195
+ type: "object",
6196
+ description: "Optional edge metadata."
5418
6197
  }
5419
6198
  },
5420
- required: ["sourceId", "targetId", "edgeType"],
6199
+ required: ["from", "to", "edgeType"],
5421
6200
  response: {
5422
6201
  description: "The created edge",
5423
6202
  fields: {
@@ -5431,6 +6210,240 @@ var CREATE_EDGE = {
5431
6210
  ontologyPrimitive: "edge",
5432
6211
  tier: "showcase"
5433
6212
  };
6213
+ var UPDATE_EDGE = {
6214
+ name: "update_edge",
6215
+ description: "Amend metadata on an existing graph edge. Like `git commit --amend` \u2014 changes the edge annotation without recreating the relationship.",
6216
+ parameters: {
6217
+ edgeId: { type: "string", description: "Edge ID or global ID to update" },
6218
+ weight: { type: "number", description: "Updated edge weight" },
6219
+ confidence: { type: "number", description: "Updated confidence" },
6220
+ context: { type: "string", description: "Updated human-readable context" },
6221
+ derivationType: { type: "string", description: "Updated derivation type" },
6222
+ metadata: { type: "object", description: "Updated metadata" }
6223
+ },
6224
+ required: ["edgeId"],
6225
+ response: {
6226
+ description: "Edge update result",
6227
+ fields: { success: "boolean" }
6228
+ },
6229
+ ownerModule: "graph-primitives",
6230
+ ontologyPrimitive: "edge",
6231
+ tier: "workhorse"
6232
+ };
6233
+ var REMOVE_EDGE = {
6234
+ name: "remove_edge",
6235
+ description: "Remove one graph edge by ID. Like `git rm` \u2014 deletes a single explicit relationship from the spine.",
6236
+ parameters: {
6237
+ edgeId: { type: "string", description: "Edge ID or global ID to remove" }
6238
+ },
6239
+ required: ["edgeId"],
6240
+ response: {
6241
+ description: "Edge removal result",
6242
+ fields: { success: "boolean" }
6243
+ },
6244
+ ownerModule: "graph-primitives",
6245
+ ontologyPrimitive: "edge",
6246
+ tier: "workhorse"
6247
+ };
6248
+ var REMOVE_EDGES_BETWEEN = {
6249
+ name: "remove_edges_between",
6250
+ description: "Remove graph edges between two nodes. Like `git rm <pathspec>` \u2014 deletes relationships matching a source, target, and optional type.",
6251
+ parameters: {
6252
+ fromNodeId: { type: "string", description: "Source node ID or global ID" },
6253
+ toNodeId: { type: "string", description: "Target node ID or global ID" },
6254
+ edgeType: { type: "string", description: "Optional edge type filter" }
6255
+ },
6256
+ required: ["fromNodeId", "toNodeId"],
6257
+ response: {
6258
+ description: "Matched edge removal result",
6259
+ fields: { deleted: "number" }
6260
+ },
6261
+ ownerModule: "graph-primitives",
6262
+ ontologyPrimitive: "edge",
6263
+ tier: "workhorse"
6264
+ };
6265
+ var BATCH_CREATE_EDGES = {
6266
+ name: "batch_create_edges",
6267
+ description: "Commit multiple typed graph edges. Like `git commit` with many staged paths \u2014 writes a batch of explicit relationships atomically per edge.",
6268
+ parameters: {
6269
+ edges: {
6270
+ type: "array",
6271
+ description: "Edges to create, each with from, to, edgeType, and optional weight/confidence/context."
6272
+ },
6273
+ skipLayerValidation: {
6274
+ type: "boolean",
6275
+ description: "Skip kernel layer validation for trusted materialization flows."
6276
+ }
6277
+ },
6278
+ required: ["edges"],
6279
+ response: {
6280
+ description: "Batch edge creation result",
6281
+ fields: {
6282
+ created: "number",
6283
+ results: "array",
6284
+ errors: "array"
6285
+ }
6286
+ },
6287
+ ownerModule: "graph-primitives",
6288
+ ontologyPrimitive: "edge",
6289
+ tier: "workhorse"
6290
+ };
6291
+ var CREATE_EPISTEMIC_NODE = {
6292
+ name: "create_epistemic_node",
6293
+ 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.",
6294
+ parameters: {
6295
+ globalId: { type: "string", description: "Optional idempotent node global ID" },
6296
+ nodeType: { type: "string", description: "Public epistemic node type" },
6297
+ canonicalText: { type: "string", description: "Canonical node text" },
6298
+ text: { type: "string", description: "Alias for canonicalText" },
6299
+ contentHash: { type: "string", description: "Optional idempotency content hash" },
6300
+ sourceType: { type: "string", description: "Source type for provenance" },
6301
+ topicId: { type: "string", description: "Optional topic scope" },
6302
+ content: { type: "string", description: "Extended content" },
6303
+ title: { type: "string", description: "Display title" },
6304
+ metadata: { type: "object", description: "Optional node metadata" }
6305
+ },
6306
+ required: ["nodeType"],
6307
+ response: {
6308
+ description: "Created node result",
6309
+ fields: {
6310
+ nodeId: "string",
6311
+ nodeGlobalId: "string",
6312
+ isDuplicate: "boolean"
6313
+ }
6314
+ },
6315
+ ownerModule: "reasoning-kernel",
6316
+ ontologyPrimitive: "graph",
6317
+ tier: "showcase"
6318
+ };
6319
+ var GET_EPISTEMIC_NODE = {
6320
+ name: "get_epistemic_node",
6321
+ description: "Read one epistemic graph node. Like `git show` \u2014 resolves a canonical spine node by ID or global ID.",
6322
+ parameters: {
6323
+ nodeId: { type: "string", description: "Node ID or global ID" }
6324
+ },
6325
+ required: ["nodeId"],
6326
+ response: {
6327
+ description: "The resolved node",
6328
+ fields: { node: "object" }
6329
+ },
6330
+ ownerModule: "reasoning-kernel",
6331
+ ontologyPrimitive: "graph",
6332
+ tier: "workhorse"
6333
+ };
6334
+ var LIST_EPISTEMIC_NODES = {
6335
+ name: "list_epistemic_nodes",
6336
+ description: "List epistemic graph nodes. Like `git ls-tree` \u2014 lists canonical spine nodes by topic, type, status, or search query.",
6337
+ parameters: {
6338
+ topicId: { type: "string", description: "Optional topic scope" },
6339
+ nodeType: { type: "string", description: "Optional node type filter" },
6340
+ status: { type: "string", description: "Optional lifecycle status" },
6341
+ searchQuery: { type: "string", description: "Optional text search query" },
6342
+ limit: { type: "number", description: "Maximum nodes to return" }
6343
+ },
6344
+ required: [],
6345
+ response: {
6346
+ description: "Matching nodes",
6347
+ fields: { nodes: "array" }
6348
+ },
6349
+ ownerModule: "reasoning-kernel",
6350
+ ontologyPrimitive: "graph",
6351
+ tier: "workhorse"
6352
+ };
6353
+ var UPDATE_EPISTEMIC_NODE = {
6354
+ name: "update_epistemic_node",
6355
+ description: "Amend an epistemic graph node. Like `git commit --amend` \u2014 updates mutable node metadata, text, status, or verification fields.",
6356
+ parameters: {
6357
+ nodeId: { type: "string", description: "Node ID or global ID" },
6358
+ canonicalText: { type: "string", description: "Updated canonical text" },
6359
+ text: { type: "string", description: "Alias for canonicalText" },
6360
+ contentHash: { type: "string", description: "Updated content hash" },
6361
+ content: { type: "string", description: "Updated content" },
6362
+ title: { type: "string", description: "Updated display title" },
6363
+ metadata: { type: "object", description: "Updated metadata" },
6364
+ confidence: { type: "number", description: "Updated confidence" },
6365
+ verificationStatus: { type: "string", description: "Updated verification status" },
6366
+ status: { type: "string", description: "Updated lifecycle status" }
6367
+ },
6368
+ required: ["nodeId"],
6369
+ response: {
6370
+ description: "Node update result",
6371
+ fields: { success: "boolean" }
6372
+ },
6373
+ ownerModule: "reasoning-kernel",
6374
+ ontologyPrimitive: "graph",
6375
+ tier: "workhorse"
6376
+ };
6377
+ var ARCHIVE_EPISTEMIC_NODE = {
6378
+ name: "archive_epistemic_node",
6379
+ description: "Archive an epistemic graph node. Like `git rm --cached` \u2014 removes a node from active traversal without hard-deleting it.",
6380
+ parameters: {
6381
+ nodeId: { type: "string", description: "Node ID or global ID" }
6382
+ },
6383
+ required: ["nodeId"],
6384
+ response: {
6385
+ description: "Archive result",
6386
+ fields: { success: "boolean", effectiveStatus: "string" }
6387
+ },
6388
+ ownerModule: "reasoning-kernel",
6389
+ ontologyPrimitive: "graph",
6390
+ tier: "workhorse"
6391
+ };
6392
+ var VERIFY_EPISTEMIC_NODE = {
6393
+ name: "verify_epistemic_node",
6394
+ description: "Record verification state on an epistemic graph node. Like `git tag` \u2014 marks the node with a reviewed verification state.",
6395
+ parameters: {
6396
+ nodeId: { type: "string", description: "Node ID or global ID" },
6397
+ verificationStatus: { type: "string", description: "Verification status" },
6398
+ confidence: { type: "number", description: "Optional confidence update" }
6399
+ },
6400
+ required: ["nodeId", "verificationStatus"],
6401
+ response: {
6402
+ description: "Verification result",
6403
+ fields: { success: "boolean" }
6404
+ },
6405
+ ownerModule: "reasoning-kernel",
6406
+ ontologyPrimitive: "graph",
6407
+ tier: "workhorse"
6408
+ };
6409
+ var SUPERSEDE_EPISTEMIC_NODE = {
6410
+ name: "supersede_epistemic_node",
6411
+ 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.",
6412
+ parameters: {
6413
+ oldNodeId: { type: "string", description: "Node ID or global ID to supersede" },
6414
+ newGlobalId: { type: "string", description: "Optional replacement global ID" },
6415
+ newCanonicalText: { type: "string", description: "Replacement canonical text" },
6416
+ text: { type: "string", description: "Alias for newCanonicalText" },
6417
+ newContentHash: { type: "string", description: "Optional replacement content hash" },
6418
+ reason: { type: "string", description: "Reason for superseding" }
6419
+ },
6420
+ required: ["oldNodeId"],
6421
+ response: {
6422
+ description: "Supersede result",
6423
+ fields: { oldNodeId: "string", newNodeId: "string" }
6424
+ },
6425
+ ownerModule: "reasoning-kernel",
6426
+ ontologyPrimitive: "graph",
6427
+ tier: "workhorse"
6428
+ };
6429
+ var BATCH_CREATE_EPISTEMIC_NODES = {
6430
+ name: "batch_create_epistemic_nodes",
6431
+ description: "Commit multiple epistemic graph nodes. Like `git commit` with many staged files \u2014 writes a batch of canonical spine nodes.",
6432
+ parameters: {
6433
+ nodes: {
6434
+ type: "array",
6435
+ description: "Nodes to create with nodeType, canonicalText/text, and optional metadata."
6436
+ }
6437
+ },
6438
+ required: ["nodes"],
6439
+ response: {
6440
+ description: "Batch node creation result",
6441
+ fields: { created: "number", results: "array" }
6442
+ },
6443
+ ownerModule: "reasoning-kernel",
6444
+ ontologyPrimitive: "graph",
6445
+ tier: "workhorse"
6446
+ };
5434
6447
  var RECORD_JUDGMENT = {
5435
6448
  name: "record_judgment",
5436
6449
  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).",
@@ -5728,6 +6741,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5728
6741
  ontologyPrimitive: "graph",
5729
6742
  tier: "showcase"
5730
6743
  };
6744
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6745
+ name: "list_graph_intelligence_queries",
6746
+ 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.",
6747
+ parameters: {
6748
+ categoryId: {
6749
+ type: "string",
6750
+ description: "Optional category filter, such as problems or strategic"
6751
+ },
6752
+ mode: {
6753
+ type: "string",
6754
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6755
+ }
6756
+ },
6757
+ required: [],
6758
+ response: {
6759
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6760
+ fields: {
6761
+ categories: "array \u2014 query categories",
6762
+ queries: "array \u2014 query definitions with prompt templates and tools",
6763
+ quickQueries: "array \u2014 recommended one-click query presets",
6764
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6765
+ }
6766
+ },
6767
+ ownerModule: "graph-intelligence",
6768
+ ontologyPrimitive: "graph",
6769
+ tier: "showcase"
6770
+ };
6771
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6772
+ name: "run_graph_intelligence_query",
6773
+ 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.",
6774
+ parameters: {
6775
+ topicId: { type: "string", description: "Topic to analyze" },
6776
+ queryId: {
6777
+ type: "string",
6778
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6779
+ },
6780
+ prompt: {
6781
+ type: "string",
6782
+ description: "Optional custom prompt for custom analysis runs"
6783
+ },
6784
+ input: {
6785
+ type: "string",
6786
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6787
+ },
6788
+ mode: {
6789
+ type: "string",
6790
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6791
+ },
6792
+ limit: {
6793
+ type: "number",
6794
+ description: "Maximum graph context rows to return"
6795
+ }
6796
+ },
6797
+ required: ["topicId"],
6798
+ response: {
6799
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6800
+ fields: {
6801
+ query: "object \u2014 selected query definition",
6802
+ prompt: "string \u2014 resolved prompt template",
6803
+ toolPlan: "array \u2014 public tools and args the model can call next",
6804
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6805
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6806
+ }
6807
+ },
6808
+ ownerModule: "graph-intelligence",
6809
+ ontologyPrimitive: "graph",
6810
+ tier: "showcase"
6811
+ };
5731
6812
  var GET_FALSIFICATION_QUESTIONS = {
5732
6813
  name: "get_falsification_questions",
5733
6814
  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.",
@@ -6576,15 +7657,15 @@ var IDENTITY_WHOAMI = {
6576
7657
  };
6577
7658
  var COMPILE_CONTEXT = {
6578
7659
  name: "compile_context",
6579
- 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.",
7660
+ 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.",
6580
7661
  parameters: {
6581
7662
  topicId: {
6582
7663
  type: "string",
6583
- description: "Topic scope ID to compile"
7664
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
6584
7665
  },
6585
7666
  query: {
6586
7667
  type: "string",
6587
- description: "Optional focus query used to rank context items"
7668
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
6588
7669
  },
6589
7670
  budget: {
6590
7671
  type: "number",
@@ -6608,7 +7689,7 @@ var COMPILE_CONTEXT = {
6608
7689
  description: "Include related ontological entities in the compiled result"
6609
7690
  }
6610
7691
  },
6611
- required: ["topicId"],
7692
+ required: [],
6612
7693
  response: {
6613
7694
  description: "Compiled context pack for the requested topic",
6614
7695
  fields: {
@@ -6782,18 +7863,60 @@ var CREATE_TASK = {
6782
7863
  name: "create_task",
6783
7864
  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.",
6784
7865
  parameters: {
6785
- title: { type: "string", description: "Task description" },
7866
+ title: { type: "string", description: "Task title" },
6786
7867
  topicId: { type: "string", description: "Topic scope" },
7868
+ description: {
7869
+ type: "string",
7870
+ description: "Long-form task description"
7871
+ },
6787
7872
  taskType: {
6788
7873
  type: "string",
6789
- description: "Type: research, interview, analysis, data_collection",
6790
- enum: ["research", "interview", "analysis", "data_collection"]
7874
+ description: "Task taxonomy",
7875
+ enum: [
7876
+ "general",
7877
+ "find_evidence",
7878
+ "verify_claim",
7879
+ "research",
7880
+ "review",
7881
+ "interview",
7882
+ "analysis",
7883
+ "track_metrics"
7884
+ ]
7885
+ },
7886
+ priority: {
7887
+ type: "string",
7888
+ description: "Priority",
7889
+ enum: ["urgent", "high", "medium", "low"]
7890
+ },
7891
+ status: {
7892
+ type: "string",
7893
+ description: "Initial status (defaults to todo)",
7894
+ enum: ["todo", "in_progress", "blocked", "done"]
7895
+ },
7896
+ linkedWorktreeId: {
7897
+ type: "string",
7898
+ description: "Worktree this task belongs to"
7899
+ },
7900
+ linkedBeliefId: {
7901
+ type: "string",
7902
+ description: "Belief this task supports"
6791
7903
  },
6792
7904
  linkedQuestionId: {
6793
7905
  type: "string",
6794
7906
  description: "Question this task addresses"
6795
7907
  },
6796
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
7908
+ assigneeId: {
7909
+ type: "string",
7910
+ description: "Principal assigned to the task"
7911
+ },
7912
+ dueDate: {
7913
+ type: "number",
7914
+ description: "Due date as epoch milliseconds"
7915
+ },
7916
+ tags: {
7917
+ type: "array",
7918
+ description: "Free-form string tags"
7919
+ }
6797
7920
  },
6798
7921
  required: ["title"],
6799
7922
  response: {
@@ -6913,6 +8036,10 @@ var CREATE_TOPIC = {
6913
8036
  name: "create_topic",
6914
8037
  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.",
6915
8038
  parameters: {
8039
+ globalId: {
8040
+ type: "string",
8041
+ description: "Optional idempotent topic global ID"
8042
+ },
6916
8043
  name: { type: "string", description: "Topic name" },
6917
8044
  type: {
6918
8045
  type: "string",
@@ -6923,6 +8050,18 @@ var CREATE_TOPIC = {
6923
8050
  type: "string",
6924
8051
  description: "Optional parent topic for nesting"
6925
8052
  },
8053
+ parentTopicGlobalId: {
8054
+ type: "string",
8055
+ description: "Optional parent topic global ID for nesting"
8056
+ },
8057
+ tenantId: { type: "string", description: "Optional tenant scope" },
8058
+ workspaceId: { type: "string", description: "Optional workspace scope" },
8059
+ visibility: {
8060
+ type: "string",
8061
+ description: "Topic visibility",
8062
+ enum: ["private", "team", "firm", "external", "public"]
8063
+ },
8064
+ metadata: { type: "object", description: "Optional topic metadata" },
6926
8065
  createdBy: { type: "string", description: "Who created this topic" }
6927
8066
  },
6928
8067
  required: ["name", "type"],
@@ -6931,6 +8070,9 @@ var CREATE_TOPIC = {
6931
8070
  fields: {
6932
8071
  id: "string \u2014 topic ID",
6933
8072
  globalId: "string \u2014 globally unique ID",
8073
+ topicGlobalId: "string \u2014 topic global ID",
8074
+ epistemicNodeId: "string \u2014 materialized topic node ID",
8075
+ epistemicNodeGlobalId: "string \u2014 materialized topic node global ID",
6934
8076
  depth: "number \u2014 nesting depth"
6935
8077
  }
6936
8078
  },
@@ -7061,6 +8203,65 @@ var GET_TOPIC_TREE = {
7061
8203
  ontologyPrimitive: "graph",
7062
8204
  tier: "workhorse"
7063
8205
  };
8206
+ var MATERIALIZE_TOPIC_GRAPH = {
8207
+ name: "materialize_topic_graph",
8208
+ description: "Backfill the topic graph spine. Like `git fsck --connectivity-only` with repair enabled \u2014 creates missing topic nodes and parent-child edges idempotently.",
8209
+ parameters: {
8210
+ rootTopicId: {
8211
+ type: "string",
8212
+ description: "Optional root topic for a bounded materialization pass"
8213
+ },
8214
+ dryRun: {
8215
+ type: "boolean",
8216
+ description: "When true, report missing rows without writing them"
8217
+ }
8218
+ },
8219
+ required: [],
8220
+ response: {
8221
+ description: "Topic graph materialization counts",
8222
+ fields: {
8223
+ topicsSeen: "number",
8224
+ nodesCreated: "number",
8225
+ nodesExisting: "number",
8226
+ edgesCreated: "number",
8227
+ edgesExisting: "number",
8228
+ errors: "array"
8229
+ }
8230
+ },
8231
+ ownerModule: "reasoning-kernel",
8232
+ ontologyPrimitive: "graph",
8233
+ tier: "workhorse"
8234
+ };
8235
+ var GET_TOPIC_GRAPH_SPINE = {
8236
+ name: "get_topic_graph_spine",
8237
+ description: "Verify the topic graph spine. Like `git fsck` \u2014 reads topics, materialized topic nodes, parent-child edges, and missing spine rows.",
8238
+ parameters: {
8239
+ rootTopicId: {
8240
+ type: "string",
8241
+ description: "Optional root topic for a bounded verifier pass"
8242
+ },
8243
+ includeTopicBeliefEdges: {
8244
+ type: "boolean",
8245
+ description: "Include topic -> belief edges in the verifier payload"
8246
+ }
8247
+ },
8248
+ required: [],
8249
+ response: {
8250
+ description: "Topic graph spine verification payload",
8251
+ fields: {
8252
+ ok: "boolean",
8253
+ counts: "object",
8254
+ topics: "array",
8255
+ topicNodes: "array",
8256
+ parentEdges: "array",
8257
+ missingTopicNodes: "array",
8258
+ missingParentEdges: "array"
8259
+ }
8260
+ },
8261
+ ownerModule: "reasoning-kernel",
8262
+ ontologyPrimitive: "graph",
8263
+ tier: "workhorse"
8264
+ };
7064
8265
  var GET_CODE_CONTEXT = {
7065
8266
  name: "get_code_context",
7066
8267
  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.",
@@ -8193,27 +9394,90 @@ var GENERATE_SESSION_HANDOFF = {
8193
9394
  tier: "showcase",
8194
9395
  internal: true
8195
9396
  };
8196
- var MCP_TOOL_CONTRACTS = {
8197
- // Belief lifecycle (commit, amend, fork, archive)
8198
- create_belief: CREATE_BELIEF,
8199
- get_belief: GET_BELIEF,
8200
- refine_belief: REFINE_BELIEF,
8201
- modulate_confidence: MODULATE_CONFIDENCE,
8202
- fork_belief: FORK_BELIEF,
8203
- archive_belief: ARCHIVE_BELIEF,
8204
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8205
- evaluate_contract: EVALUATE_CONTRACT,
8206
- get_contract_status: GET_CONTRACT_STATUS,
8207
- // Evidence (commit)
8208
- create_evidence: CREATE_EVIDENCE,
8209
- get_evidence: GET_EVIDENCE,
8210
- list_evidence: LIST_EVIDENCE,
8211
- link_evidence: LINK_EVIDENCE,
8212
- add_evidence: ADD_EVIDENCE,
8213
- // Contradictions (merge conflict)
8214
- flag_contradiction: FLAG_CONTRADICTION,
8215
- // Lens lifecycle (workspace-scoped operational frames)
8216
- create_lens: CREATE_LENS,
9397
+ var BEGIN_BUILD_SESSION = {
9398
+ name: "begin_build_session",
9399
+ 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.",
9400
+ parameters: {
9401
+ worktreeId: {
9402
+ type: "string",
9403
+ description: "The Lucern worktree ID to bootstrap."
9404
+ },
9405
+ branch: {
9406
+ type: "string",
9407
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
9408
+ },
9409
+ branchBase: {
9410
+ type: "string",
9411
+ description: 'Base branch for the feature branch. Default: "staging".'
9412
+ },
9413
+ prBase: {
9414
+ type: "string",
9415
+ description: 'Target branch for the PR. Default: "staging".'
9416
+ },
9417
+ sessionMode: {
9418
+ type: "string",
9419
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
9420
+ enum: ["async", "interactive"]
9421
+ },
9422
+ activateIfPlanning: {
9423
+ type: "boolean",
9424
+ description: "When true, automatically activate a planning worktree during bootstrap."
9425
+ }
9426
+ },
9427
+ required: ["worktreeId"],
9428
+ response: {
9429
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
9430
+ fields: {
9431
+ topicId: "string \u2014 canonical topic scope",
9432
+ topicName: "string \u2014 human-readable topic name",
9433
+ worktreeId: "string \u2014 worktree ID",
9434
+ worktreeName: "string \u2014 human-readable worktree name",
9435
+ branch: "string \u2014 git branch name",
9436
+ branchBase: "string \u2014 base branch",
9437
+ prBase: "string \u2014 PR target branch",
9438
+ campaign: "number | null \u2014 top-level pipeline campaign",
9439
+ lane: "string \u2014 campaign lane",
9440
+ gate: "string \u2014 exit gate",
9441
+ hypothesis: "string \u2014 worktree hypothesis",
9442
+ focus: "string \u2014 session focus",
9443
+ status: "string \u2014 worktree status after optional activation",
9444
+ sessionMode: "string \u2014 async | interactive",
9445
+ targetBeliefIds: "array \u2014 scoped belief IDs",
9446
+ targetQuestionIds: "array \u2014 scoped question IDs",
9447
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
9448
+ openQuestions: "array \u2014 open scoped questions",
9449
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
9450
+ dependencies: "array \u2014 upstream worktrees",
9451
+ unblocks: "array \u2014 downstream worktrees",
9452
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
9453
+ }
9454
+ },
9455
+ ownerModule: "bootstrap",
9456
+ ontologyPrimitive: "worktree",
9457
+ tier: "showcase",
9458
+ internal: true
9459
+ };
9460
+ var MCP_TOOL_CONTRACTS = {
9461
+ // Belief lifecycle (commit, amend, fork, archive)
9462
+ create_belief: CREATE_BELIEF,
9463
+ get_belief: GET_BELIEF,
9464
+ refine_belief: REFINE_BELIEF,
9465
+ modulate_confidence: MODULATE_CONFIDENCE,
9466
+ fork_belief: FORK_BELIEF,
9467
+ archive_belief: ARCHIVE_BELIEF,
9468
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
9469
+ evaluate_contract: EVALUATE_CONTRACT,
9470
+ get_contract_status: GET_CONTRACT_STATUS,
9471
+ // Evidence (commit)
9472
+ create_evidence: CREATE_EVIDENCE,
9473
+ get_evidence: GET_EVIDENCE,
9474
+ list_evidence: LIST_EVIDENCE,
9475
+ link_evidence: LINK_EVIDENCE,
9476
+ add_evidence: ADD_EVIDENCE,
9477
+ // Contradictions (merge conflict)
9478
+ flag_contradiction: FLAG_CONTRADICTION,
9479
+ // Lens lifecycle (workspace-scoped operational frames)
9480
+ create_lens: CREATE_LENS,
8217
9481
  list_lenses: LIST_LENSES,
8218
9482
  apply_lens_to_topic: APPLY_LENS_TO_TOPIC,
8219
9483
  remove_lens_from_topic: REMOVE_LENS_FROM_TOPIC,
@@ -8235,11 +9499,26 @@ var MCP_TOOL_CONTRACTS = {
8235
9499
  bisect_confidence: BISECT_CONFIDENCE,
8236
9500
  // Edges (commit)
8237
9501
  create_edge: CREATE_EDGE,
9502
+ update_edge: UPDATE_EDGE,
9503
+ remove_edge: REMOVE_EDGE,
9504
+ remove_edges_between: REMOVE_EDGES_BETWEEN,
9505
+ batch_create_edges: BATCH_CREATE_EDGES,
9506
+ // Epistemic node spine (commit/amend/show)
9507
+ create_epistemic_node: CREATE_EPISTEMIC_NODE,
9508
+ get_epistemic_node: GET_EPISTEMIC_NODE,
9509
+ list_epistemic_nodes: LIST_EPISTEMIC_NODES,
9510
+ update_epistemic_node: UPDATE_EPISTEMIC_NODE,
9511
+ archive_epistemic_node: ARCHIVE_EPISTEMIC_NODE,
9512
+ verify_epistemic_node: VERIFY_EPISTEMIC_NODE,
9513
+ supersede_epistemic_node: SUPERSEDE_EPISTEMIC_NODE,
9514
+ batch_create_epistemic_nodes: BATCH_CREATE_EPISTEMIC_NODES,
8238
9515
  // Judgments (tag)
8239
9516
  record_judgment: RECORD_JUDGMENT,
8240
9517
  // Graph intelligence (showcase)
8241
9518
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8242
9519
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9520
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9521
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8243
9522
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8244
9523
  // Evidence operations (workhorse)
8245
9524
  search_evidence: SEARCH_EVIDENCE,
@@ -8286,6 +9565,7 @@ var MCP_TOOL_CONTRACTS = {
8286
9565
  get_agent_inbox: GET_AGENT_INBOX,
8287
9566
  claim_files: CLAIM_FILES,
8288
9567
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9568
+ begin_build_session: BEGIN_BUILD_SESSION,
8289
9569
  // Policy / ACL (workhorse)
8290
9570
  check_permission: CHECK_PERMISSION,
8291
9571
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8305,6 +9585,8 @@ var MCP_TOOL_CONTRACTS = {
8305
9585
  get_topic: GET_TOPIC,
8306
9586
  update_topic: UPDATE_TOPIC,
8307
9587
  get_topic_tree: GET_TOPIC_TREE,
9588
+ materialize_topic_graph: MATERIALIZE_TOPIC_GRAPH,
9589
+ get_topic_graph_spine: GET_TOPIC_GRAPH_SPINE,
8308
9590
  // Coding intelligence (code-grounded knowledge)
8309
9591
  get_code_context: GET_CODE_CONTEXT,
8310
9592
  get_change_history: GET_CHANGE_HISTORY,
@@ -8409,18 +9691,34 @@ var MCP_CORE_OPERATION_NAMES = [
8409
9691
  "find_missing_questions",
8410
9692
  "get_high_priority_questions",
8411
9693
  "get_falsification_questions",
9694
+ "create_epistemic_node",
9695
+ "get_epistemic_node",
9696
+ "list_epistemic_nodes",
9697
+ "update_epistemic_node",
9698
+ "archive_epistemic_node",
9699
+ "verify_epistemic_node",
9700
+ "supersede_epistemic_node",
9701
+ "batch_create_epistemic_nodes",
8412
9702
  "create_topic",
8413
9703
  "get_topic",
8414
9704
  "list_topics",
8415
9705
  "update_topic",
8416
- "get_topic_tree"
9706
+ "get_topic_tree",
9707
+ "materialize_topic_graph",
9708
+ "get_topic_graph_spine"
8417
9709
  ];
8418
9710
  var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8419
9711
  "create_edge",
9712
+ "update_edge",
9713
+ "remove_edge",
9714
+ "remove_edges_between",
9715
+ "batch_create_edges",
8420
9716
  "query_lineage",
8421
9717
  "traverse_graph",
8422
9718
  "get_graph_neighborhood",
8423
9719
  "get_graph_structure_analysis",
9720
+ "list_graph_intelligence_queries",
9721
+ "run_graph_intelligence_query",
8424
9722
  "find_contradictions",
8425
9723
  "flag_contradiction",
8426
9724
  "detect_confirmation_bias",
@@ -8499,6 +9797,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8499
9797
  "get_change_history",
8500
9798
  "get_failure_log",
8501
9799
  "record_attempt",
9800
+ "begin_build_session",
8502
9801
  "push",
8503
9802
  "open_pull_request",
8504
9803
  "record_judgment",
@@ -8553,7 +9852,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8553
9852
  "find_semantic_orphans"
8554
9853
  ];
8555
9854
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8556
- "begin_build_session",
8557
9855
  "evaluate_engineering_contract",
8558
9856
  "evaluate_research_contract"
8559
9857
  ];
@@ -8808,9 +10106,7 @@ function mcpContractFromArgsSchema(base, args, contractName) {
8808
10106
  required: converted.filter(([, field]) => field.required).map(([fieldName]) => fieldName)
8809
10107
  };
8810
10108
  }
8811
- function defineFunctionContract(contract) {
8812
- return contract;
8813
- }
10109
+ var defineFunctionContract = (contract) => contract;
8814
10110
  function authUserId(context) {
8815
10111
  return context.userId ?? context.principalId ?? "lucern-agent";
8816
10112
  }
@@ -8939,8 +10235,34 @@ function assertSurfaceCoverage(contracts) {
8939
10235
  }
8940
10236
  }
8941
10237
  }
8942
-
8943
- // ../contracts/src/function-registry/context.ts
10238
+ var jsonRecordSchema2 = z.record(z.unknown());
10239
+ var observationArgs = z.object({
10240
+ topicId: z.string().optional().describe("Topic scope for the observation."),
10241
+ summary: z.string().describe("Short observation summary."),
10242
+ text: z.string().optional().describe("Canonical observation text alias."),
10243
+ title: z.string().optional().describe("Optional observation title."),
10244
+ content: z.string().optional().describe("Optional rich observation content."),
10245
+ contentType: z.string().optional().describe("Observation content type."),
10246
+ kind: z.string().optional().describe("Evidence kind to store."),
10247
+ observationType: z.string().optional().describe("Observation type."),
10248
+ tags: z.array(z.string()).optional().describe("Observation tags."),
10249
+ source: z.string().optional().describe("Observation source label."),
10250
+ sourceType: z.string().optional().describe("Evidence source type."),
10251
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
10252
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10253
+ confidence: z.number().optional().describe("Observation confidence."),
10254
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
10255
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
10256
+ });
10257
+ var observationContextArgs = z.object({
10258
+ topicId: z.string().describe("Topic scope."),
10259
+ query: z.string().optional().describe("Optional context query."),
10260
+ limit: z.number().optional().describe("Maximum observations to return."),
10261
+ status: z.string().optional().describe("Observation status filter.")
10262
+ });
10263
+ function isRecord2(value) {
10264
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10265
+ }
8944
10266
  var observationInput = (input, context) => withUserId(
8945
10267
  compactRecord4({
8946
10268
  projectId: input.projectId,
@@ -8973,7 +10295,7 @@ var contextContracts = [
8973
10295
  path: "/context/compile",
8974
10296
  sdkNamespace: "context",
8975
10297
  sdkMethod: "compileContext",
8976
- summary: "Compile a focused reasoning context for a topic.",
10298
+ summary: "Compile a focused reasoning context, resolving topic from query when omitted.",
8977
10299
  convex: {
8978
10300
  module: "contextCompiler",
8979
10301
  functionName: "compile",
@@ -8995,11 +10317,12 @@ var contextContracts = [
8995
10317
  kind: "mutation",
8996
10318
  inputProjection: observationInput,
8997
10319
  outputProjection: (output, input) => ({
8998
- ...output && typeof output === "object" ? output : {},
8999
- observationId: output && typeof output === "object" ? output.nodeId : void 0,
10320
+ ...isRecord2(output) ? output : {},
10321
+ observationId: isRecord2(output) ? output.nodeId : void 0,
9000
10322
  observationType: input.observationType
9001
10323
  })
9002
- }
10324
+ },
10325
+ args: observationArgs
9003
10326
  }),
9004
10327
  surfaceContract({
9005
10328
  name: "get_observation_context",
@@ -9020,7 +10343,8 @@ var contextContracts = [
9020
10343
  status: input.status,
9021
10344
  userId: input.userId
9022
10345
  })
9023
- }
10346
+ },
10347
+ args: observationContextArgs
9024
10348
  })
9025
10349
  ];
9026
10350
 
@@ -9083,8 +10407,45 @@ var identityContracts = [
9083
10407
  }
9084
10408
  })
9085
10409
  ];
9086
-
9087
- // ../contracts/src/function-registry/beliefs.ts
10410
+ var jsonRecordSchema3 = z.record(z.unknown());
10411
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
10412
+ var reversibilitySchema = z.enum([
10413
+ "irreversible",
10414
+ "hard_to_reverse",
10415
+ "reversible",
10416
+ "trivial"
10417
+ ]);
10418
+ var predictionMetaSchema = z.object({
10419
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
10420
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
10421
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
10422
+ });
10423
+ var createBeliefArgs = z.object({
10424
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
10425
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
10426
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
10427
+ beliefType: z.string().optional().describe("Schema belief type."),
10428
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
10429
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
10430
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
10431
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
10432
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
10433
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
10434
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
10435
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
10436
+ });
10437
+ var forkBeliefArgs = z.object({
10438
+ nodeId: z.string().describe("The scored belief to fork from."),
10439
+ newFormulation: z.string().describe("The evolved belief statement."),
10440
+ forkReason: z.enum([
10441
+ "refinement",
10442
+ "contradiction_response",
10443
+ "scope_change",
10444
+ "confidence_collapse",
10445
+ "manual"
10446
+ ]).describe("Why this fork was created."),
10447
+ rationale: z.string().optional().describe("Why the fork is warranted.")
10448
+ });
9088
10449
  var beliefLookupInput = (input) => compactRecord4({
9089
10450
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9090
10451
  beliefId: input.beliefId
@@ -9159,7 +10520,8 @@ var beliefsContracts = [
9159
10520
  functionName: "create",
9160
10521
  kind: "mutation",
9161
10522
  inputProjection: createBeliefInput
9162
- }
10523
+ },
10524
+ args: createBeliefArgs
9163
10525
  }),
9164
10526
  surfaceContract({
9165
10527
  name: "get_belief",
@@ -9250,7 +10612,8 @@ var beliefsContracts = [
9250
10612
  functionName: "forkBelief",
9251
10613
  kind: "mutation",
9252
10614
  inputProjection: forkBeliefInput
9253
- }
10615
+ },
10616
+ args: forkBeliefArgs
9254
10617
  }),
9255
10618
  surfaceContract({
9256
10619
  name: "archive_belief",
@@ -9331,8 +10694,46 @@ var beliefsContracts = [
9331
10694
  }
9332
10695
  })
9333
10696
  ];
9334
-
9335
- // ../contracts/src/function-registry/evidence.ts
10697
+ var jsonRecordSchema4 = z.record(z.unknown());
10698
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10699
+ var createEvidenceArgs = z.object({
10700
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10701
+ text: z.string().describe("Canonical evidence text."),
10702
+ source: z.string().optional().describe("Source URL or source label."),
10703
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10704
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10705
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10706
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10707
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10708
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10709
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10710
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10711
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10712
+ title: z.string().optional().describe("Optional short title."),
10713
+ content: z.string().optional().describe("Optional long-form content."),
10714
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10715
+ kind: z.string().optional().describe("Evidence kind."),
10716
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10717
+ sourceType: z.string().optional().describe("Evidence source type."),
10718
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10719
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10720
+ methodology: z.string().optional().describe("Collection methodology."),
10721
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10722
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10723
+ });
10724
+ var addEvidenceArgs = z.object({
10725
+ canonicalText: z.string().describe("The evidence statement."),
10726
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10727
+ topicId: z.string().optional().describe("Topic scope hint."),
10728
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10729
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10730
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10731
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10732
+ title: z.string().optional().describe("Optional short title."),
10733
+ content: z.string().optional().describe("Optional long-form evidence content."),
10734
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10735
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10736
+ });
9336
10737
  var evidenceIdInput = (input) => compactRecord4({
9337
10738
  evidenceId: input.evidenceId,
9338
10739
  insightId: input.insightId,
@@ -9360,12 +10761,12 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
9360
10761
  compactRecord4({
9361
10762
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9362
10763
  toNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
9363
- edgeType: "evidence_supports_belief",
10764
+ edgeType: "informs",
9364
10765
  globalId: input.globalId ?? `edge:${String(
9365
10766
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9366
10767
  )}:${String(
9367
10768
  input.beliefNodeId ?? input.beliefId ?? input.targetId
9368
- )}:evidence_supports_belief`,
10769
+ )}:informs`,
9369
10770
  weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
9370
10771
  context: input.rationale ?? input.context,
9371
10772
  skipLayerValidation: true,
@@ -9378,12 +10779,12 @@ var linkEvidenceToQuestionEdgeInput = (input, context) => withCreatedBy(
9378
10779
  compactRecord4({
9379
10780
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
9380
10781
  toNodeId: input.questionId ?? input.questionNodeId ?? input.targetId,
9381
- edgeType: "evidence_supports_question",
10782
+ edgeType: "responds_to",
9382
10783
  globalId: input.globalId ?? `edge:${String(
9383
10784
  input.insightId ?? input.evidenceNodeId ?? input.evidenceId
9384
10785
  )}:${String(
9385
10786
  input.questionId ?? input.questionNodeId ?? input.targetId
9386
- )}:evidence_supports_question`,
10787
+ )}:responds_to`,
9387
10788
  weight: input.impactScore ?? input.weight,
9388
10789
  context: input.rationale ?? input.context,
9389
10790
  skipLayerValidation: true,
@@ -9407,7 +10808,8 @@ var evidenceContracts = [
9407
10808
  functionName: "create",
9408
10809
  kind: "mutation",
9409
10810
  inputProjection: createEvidenceInput
9410
- }
10811
+ },
10812
+ args: createEvidenceArgs
9411
10813
  }),
9412
10814
  surfaceContract({
9413
10815
  name: "add_evidence",
@@ -9443,7 +10845,8 @@ var evidenceContracts = [
9443
10845
  context
9444
10846
  );
9445
10847
  }
9446
- }
10848
+ },
10849
+ args: addEvidenceArgs
9447
10850
  }),
9448
10851
  surfaceContract({
9449
10852
  name: "get_evidence",
@@ -9550,8 +10953,91 @@ var evidenceContracts = [
9550
10953
  }
9551
10954
  })
9552
10955
  ];
9553
-
9554
- // ../contracts/src/function-registry/questions.ts
10956
+ var jsonRecordSchema5 = z.record(z.unknown());
10957
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
10958
+ var kernelQuestionPrioritySchema = z.enum([
10959
+ "critical",
10960
+ "high",
10961
+ "medium",
10962
+ "low"
10963
+ ]);
10964
+ var questionTypeSchema = z.enum([
10965
+ "validation",
10966
+ "falsification",
10967
+ "assumption_probe",
10968
+ "prediction_test",
10969
+ "counterfactual",
10970
+ "discovery",
10971
+ "clarification",
10972
+ "comparison",
10973
+ "causal",
10974
+ "mechanism",
10975
+ "general"
10976
+ ]);
10977
+ var createQuestionArgs = z.object({
10978
+ text: z.string().describe("The question text."),
10979
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10980
+ topicId: z.string().optional().describe("Topic scope hint."),
10981
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
10982
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
10983
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
10984
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
10985
+ category: z.string().optional().describe("Question category."),
10986
+ source: z.string().optional().describe("Question source."),
10987
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
10988
+ importance: z.number().optional().describe("Numeric importance score."),
10989
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
10990
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
10991
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
10992
+ questionType: questionTypeSchema.optional().describe("Question type."),
10993
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
10994
+ });
10995
+ var refineQuestionArgs = z.object({
10996
+ id: z.string().describe("The question to refine."),
10997
+ text: z.string().describe("Updated question text."),
10998
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10999
+ rationale: z.string().optional().describe("Why the question is refined."),
11000
+ category: z.string().optional().describe("Updated question category."),
11001
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
11002
+ });
11003
+ var createAnswerArgs = z.object({
11004
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
11005
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
11006
+ answerText: z.string().describe("The answer content."),
11007
+ topicId: z.string().optional().describe("Topic scope for the answer."),
11008
+ confidence: z.string().optional().describe("Answer confidence."),
11009
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
11010
+ answerSource: z.string().optional().describe("How the answer was produced."),
11011
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
11012
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
11013
+ });
11014
+ var answerQuestionArgs = z.object({
11015
+ id: z.string().describe("Canonical question ID."),
11016
+ topicId: z.string().describe("Topic scope for the answer."),
11017
+ text: z.string().describe("Answer text."),
11018
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
11019
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
11020
+ rationale: z.string().optional().describe("Why this answer is credible."),
11021
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
11022
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
11023
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
11024
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
11025
+ answerSource: z.string().optional().describe("How the answer was produced."),
11026
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
11027
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
11028
+ });
11029
+ var missingQuestionsArgs = z.object({
11030
+ topicId: z.string().describe("Topic scope."),
11031
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
11032
+ status: z.string().optional().describe("Question status filter."),
11033
+ limit: z.number().optional().describe("Maximum questions to inspect.")
11034
+ });
11035
+ var falsificationQuestionsArgs = z.object({
11036
+ topicId: z.string().describe("Topic scope."),
11037
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
11038
+ status: z.string().optional().describe("Question status filter."),
11039
+ limit: z.number().optional().describe("Maximum questions to inspect.")
11040
+ });
9555
11041
  var questionNodeInput = (input) => compactRecord4({
9556
11042
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9557
11043
  questionId: input.questionId
@@ -9598,7 +11084,8 @@ var questionsContracts = [
9598
11084
  functionName: "create",
9599
11085
  kind: "mutation",
9600
11086
  inputProjection: createQuestionInput
9601
- }
11087
+ },
11088
+ args: createQuestionArgs
9602
11089
  }),
9603
11090
  surfaceContract({
9604
11091
  name: "get_question",
@@ -9654,7 +11141,8 @@ var questionsContracts = [
9654
11141
  category: input.category,
9655
11142
  priority: input.priority
9656
11143
  })
9657
- }
11144
+ },
11145
+ args: refineQuestionArgs
9658
11146
  }),
9659
11147
  surfaceContract({
9660
11148
  name: "update_question_status",
@@ -9730,7 +11218,8 @@ var questionsContracts = [
9730
11218
  }),
9731
11219
  context
9732
11220
  )
9733
- }
11221
+ },
11222
+ args: createAnswerArgs
9734
11223
  }),
9735
11224
  surfaceContract({
9736
11225
  name: "answer_question",
@@ -9759,7 +11248,8 @@ var questionsContracts = [
9759
11248
  }),
9760
11249
  context
9761
11250
  )
9762
- }
11251
+ },
11252
+ args: answerQuestionArgs
9763
11253
  }),
9764
11254
  surfaceContract({
9765
11255
  name: "get_answer",
@@ -9791,7 +11281,8 @@ var questionsContracts = [
9791
11281
  functionName: "getByTopic",
9792
11282
  kind: "query",
9793
11283
  inputProjection: questionTopicInput
9794
- }
11284
+ },
11285
+ args: missingQuestionsArgs
9795
11286
  }),
9796
11287
  surfaceContract({
9797
11288
  name: "get_high_priority_questions",
@@ -9826,11 +11317,54 @@ var questionsContracts = [
9826
11317
  functionName: "getByTopic",
9827
11318
  kind: "query",
9828
11319
  inputProjection: questionTopicInput
9829
- }
11320
+ },
11321
+ args: falsificationQuestionsArgs
9830
11322
  })
9831
11323
  ];
9832
-
9833
- // ../contracts/src/function-registry/topics.ts
11324
+ var topicVisibilitySchema = z.enum([
11325
+ "private",
11326
+ "team",
11327
+ "firm",
11328
+ "external",
11329
+ "public"
11330
+ ]);
11331
+ var topicStatusSchema = z.enum(["active", "archived", "watching"]);
11332
+ var createTopicArgs = z.object({
11333
+ globalId: z.string().optional().describe("Optional idempotent topic global ID."),
11334
+ name: z.string().describe("Topic name."),
11335
+ description: z.string().optional().describe("Topic description."),
11336
+ type: z.string().describe("Topic type."),
11337
+ parentTopicId: z.string().optional().describe("Optional parent topic ID."),
11338
+ parentTopicGlobalId: z.string().optional().describe("Optional parent topic global ID."),
11339
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11340
+ tenantId: z.string().optional().describe("Optional tenant scope."),
11341
+ workspaceId: z.string().optional().describe("Optional workspace scope."),
11342
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11343
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata."),
11344
+ graphScopeProjectId: z.string().optional(),
11345
+ createdBy: z.string().optional()
11346
+ });
11347
+ var updateTopicArgs = z.object({
11348
+ id: z.string().describe("Topic ID."),
11349
+ topicId: z.string().optional().describe("Topic ID alias."),
11350
+ name: z.string().optional().describe("Topic name."),
11351
+ description: z.string().optional().describe("Topic description."),
11352
+ type: z.string().optional().describe("Topic type."),
11353
+ status: topicStatusSchema.optional().describe("Topic status."),
11354
+ visibility: topicVisibilitySchema.optional().describe("Topic visibility."),
11355
+ ontologyId: z.string().optional().describe("Ontology to bind."),
11356
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
11357
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
11358
+ });
11359
+ var materializeTopicGraphArgs = z.object({
11360
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11361
+ dryRun: z.boolean().optional().describe("Report missing rows without writing."),
11362
+ createdBy: z.string().optional()
11363
+ });
11364
+ var getTopicGraphSpineArgs = z.object({
11365
+ rootTopicId: z.string().optional().describe("Optional root topic ID."),
11366
+ includeTopicBeliefEdges: z.boolean().optional()
11367
+ });
9834
11368
  var topicIdInput = (input) => compactRecord4({
9835
11369
  id: input.id ?? input.topicId
9836
11370
  });
@@ -9861,7 +11395,8 @@ var topicsContracts = [
9861
11395
  functionName: "create",
9862
11396
  kind: "mutation",
9863
11397
  inputProjection: withCreatedBy
9864
- }
11398
+ },
11399
+ args: createTopicArgs
9865
11400
  }),
9866
11401
  surfaceContract({
9867
11402
  name: "get_topic",
@@ -9911,7 +11446,8 @@ var topicsContracts = [
9911
11446
  functionName: "update",
9912
11447
  kind: "mutation",
9913
11448
  inputProjection: updateTopicInput
9914
- }
11449
+ },
11450
+ args: updateTopicArgs
9915
11451
  }),
9916
11452
  surfaceContract({
9917
11453
  name: "get_topic_tree",
@@ -9928,85 +11464,505 @@ var topicsContracts = [
9928
11464
  functionName: "getTree",
9929
11465
  kind: "query"
9930
11466
  }
11467
+ }),
11468
+ surfaceContract({
11469
+ name: "materialize_topic_graph",
11470
+ kind: "mutation",
11471
+ domain: "topics",
11472
+ surfaceClass: "platform_public",
11473
+ path: "/topics/materialize-graph",
11474
+ sdkNamespace: "topics",
11475
+ sdkMethod: "materializeTopicGraph",
11476
+ summary: "Materialize topic nodes and parent-child graph edges.",
11477
+ convex: {
11478
+ module: "topics",
11479
+ functionName: "materializeTopicGraph",
11480
+ kind: "mutation",
11481
+ inputProjection: withCreatedBy
11482
+ },
11483
+ args: materializeTopicGraphArgs
11484
+ }),
11485
+ surfaceContract({
11486
+ name: "get_topic_graph_spine",
11487
+ kind: "query",
11488
+ domain: "topics",
11489
+ surfaceClass: "platform_public",
11490
+ method: "GET",
11491
+ path: "/topics/graph-spine",
11492
+ sdkNamespace: "topics",
11493
+ sdkMethod: "getTopicGraphSpine",
11494
+ summary: "Verify topic nodes and parent-child graph edges.",
11495
+ convex: {
11496
+ module: "topics",
11497
+ functionName: "getTopicGraphSpine",
11498
+ kind: "query"
11499
+ },
11500
+ args: getTopicGraphSpineArgs
9931
11501
  })
9932
11502
  ];
9933
-
9934
- // ../contracts/src/function-registry/lenses.ts
9935
- var createLensInput = (input, context) => compactRecord4({
9936
- name: input.name,
9937
- description: input.description,
9938
- workspaceId: input.workspaceId,
9939
- topicId: input.topicId,
9940
- perspectiveType: input.perspectiveType,
9941
- promptTemplates: input.promptTemplates,
9942
- workflowTemplates: input.workflowTemplates,
9943
- taskTemplates: input.taskTemplates,
9944
- questionTemplates: input.questionTemplates,
9945
- filterCriteria: input.filterCriteria,
9946
- metadata: input.metadata,
9947
- createdBy: authUserId(context)
11503
+ var sourceTypeSchema2 = z.enum([
11504
+ "human",
11505
+ "ai_extracted",
11506
+ "ai_generated",
11507
+ "imported",
11508
+ "system",
11509
+ "verified",
11510
+ "proprietary"
11511
+ ]);
11512
+ var verificationStatusSchema = z.enum([
11513
+ "unverified",
11514
+ "human_verified",
11515
+ "ai_verified",
11516
+ "contradicted",
11517
+ "outdated"
11518
+ ]);
11519
+ var nodeStatusSchema = z.enum([
11520
+ "active",
11521
+ "superseded",
11522
+ "archived",
11523
+ "deleted"
11524
+ ]);
11525
+ var externalIdsArgs = z.object({
11526
+ crunchbase: z.string().optional(),
11527
+ linkedin: z.string().optional(),
11528
+ pitchbook: z.string().optional(),
11529
+ twitter: z.string().optional(),
11530
+ website: z.string().optional()
11531
+ }).optional();
11532
+ var createEpistemicNodeItemArgs = z.object({
11533
+ globalId: z.string().optional().describe("Optional idempotent node global ID."),
11534
+ nodeType: NODE_TYPE.describe("Public epistemic node type."),
11535
+ subtype: z.string().optional(),
11536
+ canonicalText: z.string().optional().describe("Canonical node text."),
11537
+ text: z.string().optional().describe("Alias for canonicalText."),
11538
+ contentHash: z.string().optional().describe("Optional idempotency content hash."),
11539
+ content: z.string().optional(),
11540
+ contentType: z.string().optional(),
11541
+ title: z.string().optional(),
11542
+ tags: z.array(z.string()).optional(),
11543
+ domain: z.string().optional(),
11544
+ metadata: z.record(z.unknown()).optional(),
11545
+ externalIds: externalIdsArgs,
11546
+ sourceType: sourceTypeSchema2.optional(),
11547
+ aiProvider: z.string().optional(),
11548
+ extractedFromNodeId: z.string().optional(),
11549
+ confidence: z.number().optional(),
11550
+ verificationStatus: verificationStatusSchema.optional(),
11551
+ topicId: z.string().optional(),
11552
+ projectId: z.string().optional(),
11553
+ createdBy: z.string().optional(),
11554
+ trustedBypassAccessCheck: z.boolean().optional()
9948
11555
  });
9949
- var lensListInput = (input, context) => compactRecord4({
9950
- actorId: input.actorId ?? authUserId(context),
9951
- workspaceId: input.workspaceId,
11556
+ var createEpistemicNodeArgs = createEpistemicNodeItemArgs;
11557
+ var batchCreateEpistemicNodesArgs = z.object({
11558
+ nodes: z.array(createEpistemicNodeItemArgs)
11559
+ });
11560
+ var getEpistemicNodeArgs = z.object({
11561
+ nodeId: z.string().describe("Node ID or global ID."),
11562
+ globalId: z.string().optional().describe("Node global ID alias.")
11563
+ });
11564
+ var listEpistemicNodesArgs = z.object({
11565
+ topicId: z.string().optional(),
11566
+ projectId: z.string().optional(),
11567
+ nodeType: NODE_TYPE.optional(),
11568
+ status: nodeStatusSchema.optional(),
11569
+ searchQuery: z.string().optional(),
11570
+ query: z.string().optional(),
11571
+ limit: z.number().optional()
11572
+ });
11573
+ var updateEpistemicNodeArgs = z.object({
11574
+ nodeId: z.string().describe("Node ID or global ID."),
11575
+ id: z.string().optional().describe("Node ID alias."),
11576
+ subtype: z.string().optional(),
11577
+ canonicalText: z.string().optional(),
11578
+ text: z.string().optional(),
11579
+ contentHash: z.string().optional(),
11580
+ content: z.string().optional(),
11581
+ contentType: z.string().optional(),
11582
+ title: z.string().optional(),
11583
+ tags: z.array(z.string()).optional(),
11584
+ domain: z.string().optional(),
11585
+ metadata: z.record(z.unknown()).optional(),
11586
+ externalIds: externalIdsArgs,
11587
+ confidence: z.number().optional(),
11588
+ verificationStatus: verificationStatusSchema.optional(),
11589
+ status: nodeStatusSchema.optional(),
11590
+ userId: z.string().optional(),
11591
+ trustedBypassAccessCheck: z.boolean().optional()
11592
+ });
11593
+ var archiveEpistemicNodeArgs = z.object({
11594
+ nodeId: z.string().describe("Node ID or global ID."),
11595
+ id: z.string().optional().describe("Node ID alias."),
11596
+ userId: z.string().optional(),
11597
+ trustedBypassAccessCheck: z.boolean().optional()
11598
+ });
11599
+ var verifyEpistemicNodeArgs = z.object({
11600
+ nodeId: z.string().describe("Node ID or global ID."),
11601
+ id: z.string().optional().describe("Node ID alias."),
11602
+ verificationStatus: verificationStatusSchema,
11603
+ confidence: z.number().optional(),
11604
+ userId: z.string().optional()
11605
+ });
11606
+ var supersedeEpistemicNodeArgs = z.object({
11607
+ oldNodeId: z.string().describe("Node ID or global ID to supersede."),
11608
+ nodeId: z.string().optional().describe("Old node ID alias."),
11609
+ newGlobalId: z.string().optional(),
11610
+ newCanonicalText: z.string().optional(),
11611
+ text: z.string().optional(),
11612
+ canonicalText: z.string().optional(),
11613
+ newContentHash: z.string().optional(),
11614
+ reason: z.string().optional(),
11615
+ createdBy: z.string().optional(),
11616
+ trustedBypassAccessCheck: z.boolean().optional()
11617
+ });
11618
+ function generatedGlobalId(prefix) {
11619
+ return `${prefix}:${crypto.randomUUID()}`;
11620
+ }
11621
+ function resolveCanonicalText(input) {
11622
+ const text = input.canonicalText ?? input.text ?? input.title ?? input.content;
11623
+ if (typeof text !== "string" || text.trim().length === 0) {
11624
+ throw new Error("canonicalText or text is required.");
11625
+ }
11626
+ return text;
11627
+ }
11628
+ function createNodeInput(input, context) {
11629
+ const canonicalText = resolveCanonicalText(input);
11630
+ const nodeType = String(input.nodeType);
11631
+ return withCreatedBy(
11632
+ compactRecord4({
11633
+ globalId: typeof input.globalId === "string" && input.globalId.trim() ? input.globalId : generatedGlobalId(nodeType),
11634
+ nodeType,
11635
+ subtype: input.subtype,
11636
+ canonicalText,
11637
+ contentHash: typeof input.contentHash === "string" && input.contentHash.trim() ? input.contentHash : `${nodeType}:${canonicalText}`,
11638
+ content: input.content,
11639
+ contentType: input.contentType,
11640
+ title: input.title,
11641
+ tags: input.tags,
11642
+ domain: input.domain,
11643
+ metadata: input.metadata,
11644
+ externalIds: input.externalIds,
11645
+ sourceType: typeof input.sourceType === "string" && input.sourceType.trim() ? input.sourceType : "human",
11646
+ aiProvider: input.aiProvider,
11647
+ extractedFromNodeId: input.extractedFromNodeId,
11648
+ confidence: input.confidence,
11649
+ verificationStatus: input.verificationStatus,
11650
+ topicId: input.topicId,
11651
+ projectId: input.projectId
11652
+ }),
11653
+ context
11654
+ );
11655
+ }
11656
+ var getNodeInput = (input) => compactRecord4({
11657
+ nodeId: input.nodeId ?? input.globalId
11658
+ });
11659
+ var listNodesInput = (input) => compactRecord4({
9952
11660
  topicId: input.topicId,
11661
+ projectId: input.projectId,
11662
+ nodeType: input.nodeType,
9953
11663
  status: input.status,
9954
- perspectiveType: input.perspectiveType
11664
+ searchQuery: input.searchQuery ?? input.query,
11665
+ limit: input.limit
9955
11666
  });
9956
- var lensesContracts = [
11667
+ var updateNodeInput = (input, context) => withUserId(
11668
+ compactRecord4({
11669
+ nodeId: input.nodeId ?? input.id,
11670
+ subtype: input.subtype,
11671
+ canonicalText: input.canonicalText ?? input.text,
11672
+ contentHash: input.contentHash,
11673
+ content: input.content,
11674
+ contentType: input.contentType,
11675
+ title: input.title,
11676
+ tags: input.tags,
11677
+ domain: input.domain,
11678
+ metadata: input.metadata,
11679
+ externalIds: input.externalIds,
11680
+ confidence: input.confidence,
11681
+ verificationStatus: input.verificationStatus,
11682
+ status: input.status,
11683
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11684
+ }),
11685
+ context
11686
+ );
11687
+ var archiveNodeInput = (input, context) => withUserId(
11688
+ compactRecord4({
11689
+ nodeId: input.nodeId ?? input.id,
11690
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11691
+ }),
11692
+ context
11693
+ );
11694
+ var verifyNodeInput = (input, context) => withUserId(
11695
+ compactRecord4({
11696
+ nodeId: input.nodeId ?? input.id,
11697
+ verificationStatus: input.verificationStatus,
11698
+ confidence: input.confidence
11699
+ }),
11700
+ context
11701
+ );
11702
+ var supersedeNodeInput = (input, context) => {
11703
+ const newCanonicalText = input.newCanonicalText ?? input.canonicalText ?? input.text;
11704
+ if (typeof newCanonicalText !== "string" || newCanonicalText.trim().length === 0) {
11705
+ throw new Error("newCanonicalText or text is required.");
11706
+ }
11707
+ return {
11708
+ oldNodeId: input.oldNodeId ?? input.nodeId,
11709
+ newGlobalId: typeof input.newGlobalId === "string" && input.newGlobalId.trim() ? input.newGlobalId : generatedGlobalId("node"),
11710
+ newCanonicalText,
11711
+ newContentHash: typeof input.newContentHash === "string" && input.newContentHash.trim() ? input.newContentHash : `superseded:${newCanonicalText}`,
11712
+ createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context),
11713
+ reason: input.reason,
11714
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck
11715
+ };
11716
+ };
11717
+ var batchCreateNodesInput = (input, context) => {
11718
+ const nodes = Array.isArray(input.nodes) ? input.nodes : [];
11719
+ return {
11720
+ nodes: nodes.map(
11721
+ (node) => createNodeInput(
11722
+ node && typeof node === "object" ? node : {},
11723
+ context
11724
+ )
11725
+ )
11726
+ };
11727
+ };
11728
+ var nodesContracts = [
9957
11729
  surfaceContract({
9958
- name: "create_lens",
11730
+ name: "create_epistemic_node",
9959
11731
  kind: "mutation",
9960
- domain: "lenses",
11732
+ domain: "nodes",
9961
11733
  surfaceClass: "platform_public",
9962
- path: "/lenses",
9963
- sdkNamespace: "lenses",
9964
- sdkMethod: "createLens",
9965
- summary: "Create a lens.",
11734
+ path: "/nodes",
11735
+ sdkNamespace: "nodes",
11736
+ sdkMethod: "createEpistemicNode",
11737
+ summary: "Create a generic epistemic graph node.",
9966
11738
  convex: {
9967
- module: "lenses",
11739
+ module: "nodes",
9968
11740
  functionName: "create",
9969
11741
  kind: "mutation",
9970
- inputProjection: createLensInput
9971
- }
11742
+ inputProjection: createNodeInput
11743
+ },
11744
+ args: createEpistemicNodeArgs
9972
11745
  }),
9973
11746
  surfaceContract({
9974
- name: "list_lenses",
11747
+ name: "get_epistemic_node",
9975
11748
  kind: "query",
9976
- domain: "lenses",
11749
+ domain: "nodes",
9977
11750
  surfaceClass: "platform_public",
9978
11751
  method: "GET",
9979
- path: "/lenses",
9980
- sdkNamespace: "lenses",
9981
- sdkMethod: "listLenses",
9982
- summary: "List lenses.",
11752
+ path: "/nodes/get",
11753
+ sdkNamespace: "nodes",
11754
+ sdkMethod: "getEpistemicNode",
11755
+ summary: "Get a generic epistemic graph node.",
9983
11756
  convex: {
9984
- module: "lenses",
11757
+ module: "nodes",
11758
+ functionName: "get",
11759
+ kind: "query",
11760
+ inputProjection: getNodeInput
11761
+ },
11762
+ args: getEpistemicNodeArgs
11763
+ }),
11764
+ surfaceContract({
11765
+ name: "list_epistemic_nodes",
11766
+ kind: "query",
11767
+ domain: "nodes",
11768
+ surfaceClass: "platform_public",
11769
+ method: "GET",
11770
+ path: "/nodes",
11771
+ sdkNamespace: "nodes",
11772
+ sdkMethod: "listEpistemicNodes",
11773
+ summary: "List generic epistemic graph nodes.",
11774
+ convex: {
11775
+ module: "nodes",
9985
11776
  functionName: "list",
9986
11777
  kind: "query",
9987
- inputProjection: lensListInput
9988
- }
11778
+ inputProjection: listNodesInput
11779
+ },
11780
+ args: listEpistemicNodesArgs
9989
11781
  }),
9990
11782
  surfaceContract({
9991
- name: "apply_lens_to_topic",
11783
+ name: "update_epistemic_node",
9992
11784
  kind: "mutation",
9993
- domain: "lenses",
11785
+ domain: "nodes",
9994
11786
  surfaceClass: "platform_public",
9995
- path: "/lenses/apply",
9996
- sdkNamespace: "lenses",
9997
- sdkMethod: "applyLensToTopic",
9998
- summary: "Apply a lens to a topic.",
11787
+ method: "PATCH",
11788
+ path: "/nodes",
11789
+ sdkNamespace: "nodes",
11790
+ sdkMethod: "updateEpistemicNode",
11791
+ summary: "Update a generic epistemic graph node.",
9999
11792
  convex: {
10000
- module: "lenses",
10001
- functionName: "applyToTopic",
11793
+ module: "nodes",
11794
+ functionName: "update",
10002
11795
  kind: "mutation",
10003
- inputProjection: (input, context) => compactRecord4({
10004
- lensId: input.lensId,
10005
- topicId: input.topicId,
10006
- metadata: input.metadata,
10007
- appliedBy: authUserId(context)
10008
- })
10009
- }
11796
+ inputProjection: updateNodeInput
11797
+ },
11798
+ args: updateEpistemicNodeArgs
11799
+ }),
11800
+ surfaceContract({
11801
+ name: "archive_epistemic_node",
11802
+ kind: "mutation",
11803
+ domain: "nodes",
11804
+ surfaceClass: "platform_public",
11805
+ path: "/nodes/archive",
11806
+ sdkNamespace: "nodes",
11807
+ sdkMethod: "archiveEpistemicNode",
11808
+ summary: "Archive a generic epistemic graph node.",
11809
+ convex: {
11810
+ module: "nodes",
11811
+ functionName: "archive",
11812
+ kind: "mutation",
11813
+ inputProjection: archiveNodeInput
11814
+ },
11815
+ args: archiveEpistemicNodeArgs
11816
+ }),
11817
+ surfaceContract({
11818
+ name: "verify_epistemic_node",
11819
+ kind: "mutation",
11820
+ domain: "nodes",
11821
+ surfaceClass: "platform_public",
11822
+ path: "/nodes/verify",
11823
+ sdkNamespace: "nodes",
11824
+ sdkMethod: "verifyEpistemicNode",
11825
+ summary: "Verify a generic epistemic graph node.",
11826
+ convex: {
11827
+ module: "nodes",
11828
+ functionName: "verify",
11829
+ kind: "mutation",
11830
+ inputProjection: verifyNodeInput
11831
+ },
11832
+ args: verifyEpistemicNodeArgs
11833
+ }),
11834
+ surfaceContract({
11835
+ name: "supersede_epistemic_node",
11836
+ kind: "mutation",
11837
+ domain: "nodes",
11838
+ surfaceClass: "platform_public",
11839
+ path: "/nodes/supersede",
11840
+ sdkNamespace: "nodes",
11841
+ sdkMethod: "supersedeEpistemicNode",
11842
+ summary: "Supersede a generic epistemic graph node.",
11843
+ convex: {
11844
+ module: "nodes",
11845
+ functionName: "supersede",
11846
+ kind: "mutation",
11847
+ inputProjection: supersedeNodeInput
11848
+ },
11849
+ args: supersedeEpistemicNodeArgs
11850
+ }),
11851
+ surfaceContract({
11852
+ name: "batch_create_epistemic_nodes",
11853
+ kind: "mutation",
11854
+ domain: "nodes",
11855
+ surfaceClass: "platform_public",
11856
+ path: "/nodes/batch",
11857
+ sdkNamespace: "nodes",
11858
+ sdkMethod: "batchCreateEpistemicNodes",
11859
+ summary: "Batch create generic epistemic graph nodes.",
11860
+ convex: {
11861
+ module: "nodes",
11862
+ functionName: "batchCreate",
11863
+ kind: "mutation",
11864
+ inputProjection: batchCreateNodesInput
11865
+ },
11866
+ args: batchCreateEpistemicNodesArgs
11867
+ })
11868
+ ];
11869
+ var lensPerspectiveSchema = z.enum([
11870
+ "investigation",
11871
+ "monitoring",
11872
+ "analysis",
11873
+ "comparison",
11874
+ "taxonomy"
11875
+ ]);
11876
+ var jsonRecordSchema6 = z.record(z.unknown());
11877
+ var createLensArgs = z.object({
11878
+ name: z.string().describe("Lens name."),
11879
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
11880
+ topicId: z.string().optional().describe("Originating topic scope."),
11881
+ description: z.string().optional().describe("What this lens investigates or monitors."),
11882
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
11883
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
11884
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
11885
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
11886
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
11887
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
11888
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
11889
+ });
11890
+ var createLensInput = (input, context) => compactRecord4({
11891
+ name: input.name,
11892
+ description: input.description,
11893
+ workspaceId: input.workspaceId,
11894
+ topicId: input.topicId,
11895
+ perspectiveType: input.perspectiveType,
11896
+ promptTemplates: input.promptTemplates,
11897
+ workflowTemplates: input.workflowTemplates,
11898
+ taskTemplates: input.taskTemplates,
11899
+ questionTemplates: input.questionTemplates,
11900
+ filterCriteria: input.filterCriteria,
11901
+ metadata: input.metadata,
11902
+ createdBy: authUserId(context)
11903
+ });
11904
+ var lensListInput = (input, context) => compactRecord4({
11905
+ actorId: input.actorId ?? authUserId(context),
11906
+ workspaceId: input.workspaceId,
11907
+ topicId: input.topicId,
11908
+ status: input.status,
11909
+ perspectiveType: input.perspectiveType
11910
+ });
11911
+ var lensesContracts = [
11912
+ surfaceContract({
11913
+ name: "create_lens",
11914
+ kind: "mutation",
11915
+ domain: "lenses",
11916
+ surfaceClass: "platform_public",
11917
+ path: "/lenses",
11918
+ sdkNamespace: "lenses",
11919
+ sdkMethod: "createLens",
11920
+ summary: "Create a lens.",
11921
+ convex: {
11922
+ module: "lenses",
11923
+ functionName: "create",
11924
+ kind: "mutation",
11925
+ inputProjection: createLensInput
11926
+ },
11927
+ args: createLensArgs
11928
+ }),
11929
+ surfaceContract({
11930
+ name: "list_lenses",
11931
+ kind: "query",
11932
+ domain: "lenses",
11933
+ surfaceClass: "platform_public",
11934
+ method: "GET",
11935
+ path: "/lenses",
11936
+ sdkNamespace: "lenses",
11937
+ sdkMethod: "listLenses",
11938
+ summary: "List lenses.",
11939
+ convex: {
11940
+ module: "lenses",
11941
+ functionName: "list",
11942
+ kind: "query",
11943
+ inputProjection: lensListInput
11944
+ }
11945
+ }),
11946
+ surfaceContract({
11947
+ name: "apply_lens_to_topic",
11948
+ kind: "mutation",
11949
+ domain: "lenses",
11950
+ surfaceClass: "platform_public",
11951
+ path: "/lenses/apply",
11952
+ sdkNamespace: "lenses",
11953
+ sdkMethod: "applyLensToTopic",
11954
+ summary: "Apply a lens to a topic.",
11955
+ convex: {
11956
+ module: "lenses",
11957
+ functionName: "applyToTopic",
11958
+ kind: "mutation",
11959
+ inputProjection: (input, context) => compactRecord4({
11960
+ lensId: input.lensId,
11961
+ topicId: input.topicId,
11962
+ metadata: input.metadata,
11963
+ appliedBy: authUserId(context)
11964
+ })
11965
+ }
10010
11966
  }),
10011
11967
  surfaceContract({
10012
11968
  name: "remove_lens_from_topic",
@@ -10030,8 +11986,18 @@ var lensesContracts = [
10030
11986
  }
10031
11987
  })
10032
11988
  ];
10033
-
10034
- // ../contracts/src/function-registry/ontologies.ts
11989
+ var updateOntologyArgs = z.object({
11990
+ id: z.string().describe("Ontology definition ID."),
11991
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
11992
+ name: z.string().optional().describe("Ontology display name."),
11993
+ description: z.string().optional().describe("Ontology description."),
11994
+ status: z.string().optional().describe("Ontology lifecycle status.")
11995
+ });
11996
+ var ontologyVersionLifecycleArgs = z.object({
11997
+ id: z.string().describe("Ontology version ID."),
11998
+ versionId: z.string().optional().describe("Ontology version ID alias."),
11999
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
12000
+ });
10035
12001
  var ontologyIdInput = (input) => compactRecord4({
10036
12002
  id: input.id ?? input.ontologyId
10037
12003
  });
@@ -10110,11 +12076,11 @@ var ontologiesContracts = [
10110
12076
  id: input.id ?? input.ontologyId,
10111
12077
  name: input.name,
10112
12078
  description: input.description,
10113
- parentOntologyId: input.parentOntologyId,
10114
12079
  status: input.status,
10115
12080
  actorId: input.actorId
10116
12081
  })
10117
- }
12082
+ },
12083
+ args: updateOntologyArgs
10118
12084
  }),
10119
12085
  surfaceContract({
10120
12086
  name: "archive_ontology",
@@ -10197,7 +12163,8 @@ var ontologiesContracts = [
10197
12163
  functionName: "publishOntologyVersion",
10198
12164
  kind: "mutation",
10199
12165
  inputProjection: ontologyVersionIdInput
10200
- }
12166
+ },
12167
+ args: ontologyVersionLifecycleArgs
10201
12168
  }),
10202
12169
  surfaceContract({
10203
12170
  name: "deprecate_ontology_version",
@@ -10213,7 +12180,8 @@ var ontologiesContracts = [
10213
12180
  functionName: "deprecateOntologyVersion",
10214
12181
  kind: "mutation",
10215
12182
  inputProjection: ontologyVersionIdInput
10216
- }
12183
+ },
12184
+ args: ontologyVersionLifecycleArgs
10217
12185
  }),
10218
12186
  surfaceContract({
10219
12187
  name: "resolve_effective_ontology",
@@ -10232,8 +12200,81 @@ var ontologiesContracts = [
10232
12200
  }
10233
12201
  })
10234
12202
  ];
10235
-
10236
- // ../contracts/src/function-registry/worktrees.ts
12203
+ var autoFixPolicyInputSchema = z.object({
12204
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
12205
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
12206
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
12207
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
12208
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
12209
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
12210
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
12211
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
12212
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
12213
+ var worktreeKeyQuestionInputSchema = z.object({
12214
+ question: z.string().describe("Question the worktree must resolve."),
12215
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
12216
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
12217
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
12218
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
12219
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
12220
+ var worktreeEvidenceSignalInputSchema = z.object({
12221
+ signal: z.string().describe("Evidence signal the worktree should collect."),
12222
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
12223
+ progress: z.string().optional().describe("Collection progress note for the signal."),
12224
+ notes: z.string().optional().describe("Additional evidence collection notes.")
12225
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
12226
+ var worktreeDecisionGateInputSchema = z.object({
12227
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
12228
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
12229
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
12230
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
12231
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
12232
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
12233
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
12234
+ var addWorktreeArgs = z.object({
12235
+ title: z.string().describe("Human-readable worktree name or objective."),
12236
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
12237
+ topicId: z.string().optional().describe("Optional primary topic scope hint for resolver validation."),
12238
+ projectId: z.string().optional().describe("Legacy topicId alias/hint."),
12239
+ topicHint: z.string().optional().describe("Natural-language topic hint for automatic topic resolution."),
12240
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
12241
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
12242
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12243
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
12244
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
12245
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12246
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
12247
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
12248
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
12249
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
12250
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
12251
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12252
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
12253
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
12254
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
12255
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
12256
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
12257
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
12258
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
12259
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
12260
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
12261
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
12262
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12263
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
12264
+ tags: z.array(z.string()).optional().describe("Additional topic-resolution tags for the worktree."),
12265
+ touchedPaths: z.array(z.string()).optional().describe("File paths used as topic-resolution signals."),
12266
+ sourceRef: z.string().optional().describe("Source reference used as a topic-resolution signal."),
12267
+ sourceKind: z.string().optional().describe("Source kind used as a topic-resolution signal."),
12268
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
12269
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
12270
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12271
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12272
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
12273
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12274
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12275
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
12276
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
12277
+ });
10237
12278
  var worktreeIdInput = (input) => compactRecord4({
10238
12279
  worktreeId: input.worktreeId ?? input.id
10239
12280
  });
@@ -10266,6 +12307,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10266
12307
  autoFixPolicy: input.autoFixPolicy,
10267
12308
  lastReconciledAt: input.lastReconciledAt
10268
12309
  });
12310
+ var worktreeMetadataArgs = z.object({
12311
+ worktreeId: z.string().describe("The worktree to update."),
12312
+ id: z.string().optional().describe("Worktree ID alias."),
12313
+ topicId: z.string().optional().describe("Primary topic scope."),
12314
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
12315
+ status: z.string().optional().describe("Worktree lifecycle status."),
12316
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
12317
+ lane: z.string().optional().describe("Campaign lane."),
12318
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
12319
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
12320
+ gate: z.string().optional().describe("Exit gate for this worktree."),
12321
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
12322
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
12323
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
12324
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
12325
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
12326
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
12327
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
12328
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
12329
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
12330
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
12331
+ });
12332
+ var pushArgs = worktreeMetadataArgs.extend({
12333
+ targetContext: z.string().describe("Where to push merged findings."),
12334
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
12335
+ });
12336
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
12337
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
12338
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
12339
+ });
12340
+ var mergeKeyFindingsInput = (input) => {
12341
+ if (Array.isArray(input.keyFindings)) {
12342
+ return input.keyFindings;
12343
+ }
12344
+ if (Array.isArray(input.outcomes)) {
12345
+ const findings = input.outcomes.filter(
12346
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
12347
+ );
12348
+ if (findings.length > 0) {
12349
+ return findings;
12350
+ }
12351
+ }
12352
+ return [input.summary ?? "Merged worktree"];
12353
+ };
10269
12354
  var listAllWorktreesInput = (input) => compactRecord4({
10270
12355
  status: input.status,
10271
12356
  lane: input.lane,
@@ -10273,6 +12358,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10273
12358
  limit: input.limit
10274
12359
  });
10275
12360
  var worktreesContracts = [
12361
+ surfaceContract({
12362
+ name: "begin_build_session",
12363
+ kind: "mutation",
12364
+ domain: "worktrees",
12365
+ surfaceClass: "platform_internal",
12366
+ path: "/mcp/build-session/begin",
12367
+ sdkNamespace: "worktrees",
12368
+ sdkMethod: "beginBuildSession",
12369
+ summary: "Begin a coding build session for a worktree."
12370
+ }),
10276
12371
  surfaceContract({
10277
12372
  name: "add_worktree",
10278
12373
  kind: "mutation",
@@ -10289,13 +12384,12 @@ var worktreesContracts = [
10289
12384
  inputProjection: (input, context) => withCreatedBy(
10290
12385
  compactRecord4({
10291
12386
  name: input.name ?? input.title,
10292
- topicId: input.topicId,
12387
+ topicId: input.topicId ?? input.projectId,
10293
12388
  worktreeType: input.worktreeType,
10294
12389
  objective: input.objective,
10295
12390
  gate: input.gate,
10296
12391
  hypothesis: input.hypothesis,
10297
12392
  rationale: input.rationale,
10298
- signal: input.signal,
10299
12393
  startDate: input.startDate,
10300
12394
  endDate: input.endDate,
10301
12395
  durationWeeks: input.durationWeeks,
@@ -10321,12 +12415,12 @@ var worktreesContracts = [
10321
12415
  staffingHint: input.staffingHint,
10322
12416
  domainPackId: input.domainPackId,
10323
12417
  lensId: input.lensId,
10324
- linkedQuestionId: input.linkedQuestionId,
10325
12418
  lastReconciledAt: input.lastReconciledAt
10326
12419
  }),
10327
12420
  context
10328
12421
  )
10329
- }
12422
+ },
12423
+ args: addWorktreeArgs
10330
12424
  }),
10331
12425
  surfaceContract({
10332
12426
  name: "activate_worktree",
@@ -10438,7 +12532,8 @@ var worktreesContracts = [
10438
12532
  functionName: "updateMetadata",
10439
12533
  kind: "mutation",
10440
12534
  inputProjection: worktreeMetadataInput
10441
- }
12535
+ },
12536
+ args: worktreeMetadataArgs
10442
12537
  }),
10443
12538
  surfaceContract({
10444
12539
  name: "merge",
@@ -10456,9 +12551,7 @@ var worktreesContracts = [
10456
12551
  inputProjection: (input, context) => withUserId(
10457
12552
  {
10458
12553
  ...worktreeIdInput(input),
10459
- keyFindings: input.keyFindings ?? [
10460
- input.summary ?? "Merged worktree"
10461
- ],
12554
+ keyFindings: mergeKeyFindingsInput(input),
10462
12555
  decisionsReached: input.decisionsReached ?? [],
10463
12556
  nextSteps: input.nextSteps ?? []
10464
12557
  },
@@ -10480,7 +12573,8 @@ var worktreesContracts = [
10480
12573
  functionName: "updateMetadata",
10481
12574
  kind: "mutation",
10482
12575
  inputProjection: worktreeMetadataInput
10483
- }
12576
+ },
12577
+ args: pushArgs
10484
12578
  }),
10485
12579
  surfaceContract({
10486
12580
  name: "open_pull_request",
@@ -10496,11 +12590,50 @@ var worktreesContracts = [
10496
12590
  functionName: "updateMetadata",
10497
12591
  kind: "mutation",
10498
12592
  inputProjection: worktreeMetadataInput
10499
- }
12593
+ },
12594
+ args: openPullRequestArgs
10500
12595
  })
10501
12596
  ];
10502
-
10503
- // ../contracts/src/function-registry/tasks.ts
12597
+ var taskPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
12598
+ var taskStatusSchema2 = z.enum(["todo", "in_progress", "blocked", "done"]);
12599
+ var taskTypeSchema = z.enum([
12600
+ "general",
12601
+ "find_evidence",
12602
+ "verify_claim",
12603
+ "research",
12604
+ "review",
12605
+ "interview",
12606
+ "analysis",
12607
+ "track_metrics"
12608
+ ]);
12609
+ var createTaskArgs = z.object({
12610
+ title: z.string().describe("Task title."),
12611
+ topicId: z.string().optional().describe("Topic scope."),
12612
+ description: z.string().optional().describe("Long-form task description."),
12613
+ taskType: taskTypeSchema.optional().describe("Task taxonomy."),
12614
+ priority: taskPrioritySchema.optional().describe("Priority. Defaults to medium when omitted by the server."),
12615
+ status: taskStatusSchema2.optional().describe("Initial status. Defaults to todo."),
12616
+ linkedWorktreeId: z.string().optional().describe("Worktree this task belongs to."),
12617
+ linkedBeliefId: z.string().optional().describe("Belief this task supports."),
12618
+ linkedQuestionId: z.string().optional().describe("Question this task addresses."),
12619
+ assigneeId: z.string().optional().describe("Principal assigned to the task."),
12620
+ dueDate: z.number().optional().describe("Due date as epoch milliseconds."),
12621
+ tags: z.array(z.string()).optional().describe("Free-form tags.")
12622
+ });
12623
+ var createTaskInput = (input) => compactRecord4({
12624
+ title: input.title,
12625
+ topicId: input.topicId,
12626
+ description: input.description,
12627
+ taskType: input.taskType,
12628
+ priority: input.priority ?? "medium",
12629
+ status: input.status ?? "todo",
12630
+ linkedWorktreeId: input.linkedWorktreeId,
12631
+ linkedBeliefId: input.linkedBeliefId,
12632
+ linkedQuestionId: input.linkedQuestionId,
12633
+ assigneeId: input.assigneeId,
12634
+ dueDate: input.dueDate,
12635
+ tags: input.tags
12636
+ });
10504
12637
  var taskInput = (input) => compactRecord4({
10505
12638
  ...input,
10506
12639
  taskId: input.taskId ?? input.id
@@ -10532,8 +12665,10 @@ var tasksContracts = [
10532
12665
  convex: {
10533
12666
  module: "tasks",
10534
12667
  functionName: "create",
10535
- kind: "mutation"
10536
- }
12668
+ kind: "mutation",
12669
+ inputProjection: createTaskInput
12670
+ },
12671
+ args: createTaskArgs
10537
12672
  }),
10538
12673
  surfaceContract({
10539
12674
  name: "list_tasks",
@@ -10587,19 +12722,57 @@ var tasksContracts = [
10587
12722
  }
10588
12723
  })
10589
12724
  ];
12725
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
12726
+ (policy) => policy.edgeType
12727
+ );
10590
12728
  var createEdgeArgs = z.object({
10591
12729
  from: GraphRefSchema,
10592
12730
  to: GraphRefSchema,
10593
- edgeType: z.string(),
12731
+ edgeType: z.enum(CREATE_EDGE_TYPES),
10594
12732
  globalId: z.string().optional(),
10595
12733
  weight: z.number().optional(),
10596
12734
  confidence: z.number().optional(),
10597
12735
  context: z.string().optional(),
10598
12736
  reasoning: z.string().optional(),
10599
12737
  derivationType: z.string().optional(),
12738
+ metadata: z.record(z.unknown()).optional(),
10600
12739
  topicId: z.string().optional(),
10601
12740
  trustedBypassAccessCheck: z.boolean().optional()
10602
12741
  });
12742
+ var updateEdgeArgs = z.object({
12743
+ edgeId: z.string().describe("Edge ID or global ID."),
12744
+ weight: z.number().optional(),
12745
+ confidence: z.number().optional(),
12746
+ context: z.string().optional(),
12747
+ reasoning: z.string().optional(),
12748
+ derivationType: z.string().optional(),
12749
+ metadata: z.record(z.unknown()).optional(),
12750
+ userId: z.string().optional()
12751
+ });
12752
+ var removeEdgeArgs = z.object({
12753
+ edgeId: z.string().describe("Edge ID or global ID."),
12754
+ userId: z.string().optional()
12755
+ });
12756
+ var removeEdgesBetweenArgs = z.object({
12757
+ from: GraphRefSchema.optional(),
12758
+ to: GraphRefSchema.optional(),
12759
+ fromNodeId: z.string().optional(),
12760
+ toNodeId: z.string().optional(),
12761
+ edgeType: z.enum(CREATE_EDGE_TYPES).optional()
12762
+ });
12763
+ var batchCreateEdgesArgs = z.object({
12764
+ edges: z.array(createEdgeArgs),
12765
+ skipLayerValidation: z.boolean().optional()
12766
+ });
12767
+ var queryLineageArgs = z.object({
12768
+ nodeId: z.string().describe("Starting node to trace from."),
12769
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
12770
+ depth: z.number().optional().describe("Traversal depth alias."),
12771
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12772
+ mode: z.string().optional().describe("Traversal mode."),
12773
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12774
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12775
+ });
10603
12776
  function graphRefNodeId(ref) {
10604
12777
  if (ref.kind === "epistemic_node") {
10605
12778
  return ref.nodeId;
@@ -10640,6 +12813,7 @@ var edgesContracts = [
10640
12813
  confidence: parsed.confidence,
10641
12814
  context: parsed.context ?? parsed.reasoning,
10642
12815
  derivationType: parsed.derivationType,
12816
+ metadata: parsed.metadata,
10643
12817
  skipLayerValidation: true,
10644
12818
  topicId: parsed.topicId,
10645
12819
  trustedBypassAccessCheck: parsed.trustedBypassAccessCheck
@@ -10650,6 +12824,130 @@ var edgesContracts = [
10650
12824
  },
10651
12825
  args: createEdgeArgs
10652
12826
  }),
12827
+ surfaceContract({
12828
+ name: "update_edge",
12829
+ kind: "mutation",
12830
+ domain: "edges",
12831
+ surfaceClass: "platform_public",
12832
+ method: "PATCH",
12833
+ path: "/edges",
12834
+ sdkNamespace: "edges",
12835
+ sdkMethod: "updateEdge",
12836
+ summary: "Update an epistemic edge.",
12837
+ convex: {
12838
+ module: "edges",
12839
+ functionName: "update",
12840
+ kind: "mutation",
12841
+ inputProjection: (input, context) => compactRecord4({
12842
+ edgeId: input.edgeId,
12843
+ weight: input.weight,
12844
+ confidence: input.confidence,
12845
+ context: input.context ?? input.reasoning,
12846
+ derivationType: input.derivationType,
12847
+ metadata: input.metadata,
12848
+ userId: input.userId ?? context.userId ?? context.principalId
12849
+ })
12850
+ },
12851
+ args: updateEdgeArgs
12852
+ }),
12853
+ surfaceContract({
12854
+ name: "remove_edge",
12855
+ kind: "mutation",
12856
+ domain: "edges",
12857
+ surfaceClass: "platform_public",
12858
+ method: "DELETE",
12859
+ path: "/edges",
12860
+ sdkNamespace: "edges",
12861
+ sdkMethod: "removeEdge",
12862
+ summary: "Remove an epistemic edge.",
12863
+ convex: {
12864
+ module: "edges",
12865
+ functionName: "remove",
12866
+ kind: "mutation",
12867
+ inputProjection: (input, context) => compactRecord4({
12868
+ edgeId: input.edgeId,
12869
+ userId: input.userId ?? context.userId ?? context.principalId
12870
+ })
12871
+ },
12872
+ args: removeEdgeArgs
12873
+ }),
12874
+ surfaceContract({
12875
+ name: "remove_edges_between",
12876
+ kind: "mutation",
12877
+ domain: "edges",
12878
+ surfaceClass: "platform_public",
12879
+ method: "DELETE",
12880
+ path: "/edges/between",
12881
+ sdkNamespace: "edges",
12882
+ sdkMethod: "removeEdgesBetween",
12883
+ summary: "Remove epistemic edges between two nodes.",
12884
+ convex: {
12885
+ module: "edges",
12886
+ functionName: "removeBetween",
12887
+ kind: "mutation",
12888
+ inputProjection: (input) => {
12889
+ const parsed = removeEdgesBetweenArgs.parse(input);
12890
+ const fromNodeId = parsed.from ? graphRefNodeId(parsed.from) : parsed.fromNodeId;
12891
+ const toNodeId = parsed.to ? graphRefNodeId(parsed.to) : parsed.toNodeId;
12892
+ if (!fromNodeId || !toNodeId) {
12893
+ throw new Error("from/to or fromNodeId/toNodeId are required.");
12894
+ }
12895
+ return compactRecord4({
12896
+ fromNodeId,
12897
+ toNodeId,
12898
+ edgeType: parsed.edgeType
12899
+ });
12900
+ }
12901
+ },
12902
+ args: removeEdgesBetweenArgs
12903
+ }),
12904
+ surfaceContract({
12905
+ name: "batch_create_edges",
12906
+ kind: "mutation",
12907
+ domain: "edges",
12908
+ surfaceClass: "platform_public",
12909
+ path: "/edges/batch",
12910
+ sdkNamespace: "edges",
12911
+ sdkMethod: "batchCreateEdges",
12912
+ summary: "Batch create epistemic edges.",
12913
+ convex: {
12914
+ module: "edges",
12915
+ functionName: "batchCreate",
12916
+ kind: "mutation",
12917
+ inputProjection: (input, context) => {
12918
+ const parsed = batchCreateEdgesArgs.parse(input);
12919
+ return {
12920
+ skipLayerValidation: parsed.skipLayerValidation ?? true,
12921
+ edges: parsed.edges.map((edge) => {
12922
+ assertEdgePolicyAllowed(
12923
+ edgePolicyManifest,
12924
+ edge.edgeType,
12925
+ edge.from,
12926
+ edge.to
12927
+ );
12928
+ const fromNodeId = graphRefNodeId(edge.from);
12929
+ const toNodeId = graphRefNodeId(edge.to);
12930
+ return withCreatedBy(
12931
+ compactRecord4({
12932
+ fromNodeId,
12933
+ toNodeId,
12934
+ edgeType: edge.edgeType,
12935
+ globalId: edge.globalId ?? `edge:${fromNodeId}:${toNodeId}:${edge.edgeType}`,
12936
+ weight: edge.weight,
12937
+ confidence: edge.confidence,
12938
+ context: edge.context ?? edge.reasoning,
12939
+ derivationType: edge.derivationType,
12940
+ metadata: edge.metadata,
12941
+ topicId: edge.topicId
12942
+ }),
12943
+ context
12944
+ );
12945
+ })
12946
+ };
12947
+ }
12948
+ },
12949
+ args: batchCreateEdgesArgs
12950
+ }),
10653
12951
  surfaceContract({
10654
12952
  name: "query_lineage",
10655
12953
  kind: "query",
@@ -10670,11 +12968,84 @@ var edgesContracts = [
10670
12968
  minLayer: input.minLayer,
10671
12969
  maxLayer: input.maxLayer
10672
12970
  })
10673
- }
12971
+ },
12972
+ args: queryLineageArgs
10674
12973
  })
10675
12974
  ];
10676
-
10677
- // ../contracts/src/function-registry/graph.ts
12975
+ var graphIntelligenceQueryModes = [
12976
+ "core",
12977
+ "bias",
12978
+ "stress",
12979
+ "operational",
12980
+ "alpha",
12981
+ "semantic",
12982
+ "evidence"
12983
+ ];
12984
+ var traversalLayerSchema = z.enum([
12985
+ "L4",
12986
+ "L3",
12987
+ "L2",
12988
+ "L1",
12989
+ "ontological",
12990
+ "organizational"
12991
+ ]);
12992
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
12993
+ var lineageAliasArgs = z.object({
12994
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
12995
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
12996
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
12997
+ depth: z.number().optional().describe("Traversal depth alias."),
12998
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12999
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
13000
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
13001
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
13002
+ });
13003
+ var lineageArgs = lineageAliasArgs.extend({
13004
+ nodeId: z.string().describe("Starting node to traverse from.")
13005
+ });
13006
+ var traverseGraphArgs = lineageAliasArgs.extend({
13007
+ startNode: z.string().describe("Node to start traversal from."),
13008
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
13009
+ });
13010
+ var graphNeighborhoodArgs = z.object({
13011
+ globalId: z.string().optional().describe("Single root global ID."),
13012
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
13013
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
13014
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
13015
+ limit: z.number().optional().describe("Maximum edges to return.")
13016
+ });
13017
+ var graphIntelligenceModeSchema = z.enum([
13018
+ graphIntelligenceQueryModes[0],
13019
+ ...graphIntelligenceQueryModes.slice(1)
13020
+ ]);
13021
+ var graphIntelligenceCatalogArgs = z.object({
13022
+ categoryId: z.string().optional().describe("Optional query category filter."),
13023
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
13024
+ });
13025
+ var graphIntelligenceRunArgs = z.object({
13026
+ topicId: z.string().describe("Topic to analyze."),
13027
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
13028
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
13029
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
13030
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
13031
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
13032
+ });
13033
+ var flagContradictionArgs = z.object({
13034
+ beliefA: z.string().describe("First belief in tension."),
13035
+ beliefB: z.string().describe("Second belief in tension."),
13036
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
13037
+ description: z.string().optional().describe("Human-readable contradiction."),
13038
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
13039
+ defeatType: z.string().optional().describe("Defeat type annotation."),
13040
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
13041
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
13042
+ });
13043
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
13044
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
13045
+ topicId: z.string().optional().describe("Topic scope override."),
13046
+ minScore: z.number().optional().describe("Minimum match score."),
13047
+ limit: z.number().optional().describe("Maximum candidates to return.")
13048
+ });
10678
13049
  var contradictionSeverity = (value) => {
10679
13050
  switch (value) {
10680
13051
  case "critical":
@@ -10729,7 +13100,8 @@ var graphContracts = [
10729
13100
  functionName: "getLineage",
10730
13101
  kind: "query",
10731
13102
  inputProjection: lineageInput
10732
- }
13103
+ },
13104
+ args: traverseGraphArgs
10733
13105
  }),
10734
13106
  surfaceContract({
10735
13107
  name: "get_graph_neighborhood",
@@ -10745,7 +13117,8 @@ var graphContracts = [
10745
13117
  functionName: "getByTopic",
10746
13118
  kind: "query",
10747
13119
  inputProjection: topicEdgesInput
10748
- }
13120
+ },
13121
+ args: graphNeighborhoodArgs
10749
13122
  }),
10750
13123
  surfaceContract({
10751
13124
  name: "get_graph_structure_analysis",
@@ -10762,6 +13135,38 @@ var graphContracts = [
10762
13135
  kind: "query"
10763
13136
  }
10764
13137
  }),
13138
+ surfaceContract({
13139
+ name: "list_graph_intelligence_queries",
13140
+ kind: "query",
13141
+ domain: "graph",
13142
+ surfaceClass: "platform_public",
13143
+ path: "/graph-intelligence/queries",
13144
+ sdkNamespace: "graphAnalysis",
13145
+ sdkMethod: "listGraphIntelligenceQueries",
13146
+ summary: "List Graph Intelligence query catalog entries.",
13147
+ convex: {
13148
+ module: "contextCompiler",
13149
+ functionName: "listGraphIntelligenceQueries",
13150
+ kind: "query"
13151
+ },
13152
+ args: graphIntelligenceCatalogArgs
13153
+ }),
13154
+ surfaceContract({
13155
+ name: "run_graph_intelligence_query",
13156
+ kind: "query",
13157
+ domain: "graph",
13158
+ surfaceClass: "platform_public",
13159
+ path: "/graph-intelligence/run",
13160
+ sdkNamespace: "graphAnalysis",
13161
+ sdkMethod: "runGraphIntelligenceQuery",
13162
+ summary: "Run a Graph Intelligence query against a topic graph.",
13163
+ convex: {
13164
+ module: "contextCompiler",
13165
+ functionName: "runGraphIntelligenceQuery",
13166
+ kind: "query"
13167
+ },
13168
+ args: graphIntelligenceRunArgs
13169
+ }),
10765
13170
  surfaceContract({
10766
13171
  name: "find_contradictions",
10767
13172
  kind: "query",
@@ -10794,7 +13199,8 @@ var graphContracts = [
10794
13199
  functionName: "create",
10795
13200
  kind: "mutation",
10796
13201
  inputProjection: flagContradictionInput
10797
- }
13202
+ },
13203
+ args: flagContradictionArgs
10798
13204
  }),
10799
13205
  surfaceContract({
10800
13206
  name: "detect_confirmation_bias",
@@ -10885,7 +13291,8 @@ var graphContracts = [
10885
13291
  functionName: "getLineage",
10886
13292
  kind: "query",
10887
13293
  inputProjection: lineageInput
10888
- }
13294
+ },
13295
+ args: discoverEntityConnectionsArgs
10889
13296
  }),
10890
13297
  surfaceContract({
10891
13298
  name: "trigger_belief_review",
@@ -10916,7 +13323,8 @@ var graphContracts = [
10916
13323
  functionName: "getLineage",
10917
13324
  kind: "query",
10918
13325
  inputProjection: lineageInput
10919
- }
13326
+ },
13327
+ args: lineageArgs
10920
13328
  })
10921
13329
  ];
10922
13330
 
@@ -10968,8 +13376,16 @@ var contractsContracts = [
10968
13376
  }
10969
13377
  })
10970
13378
  ];
10971
-
10972
- // ../contracts/src/function-registry/judgments.ts
13379
+ var auditTrailArgs = z.object({
13380
+ nodeId: z.string().describe("The node to audit."),
13381
+ id: z.string().optional().describe("Node ID alias."),
13382
+ limit: z.number().optional().describe("Maximum entries to return."),
13383
+ depth: z.number().optional().describe("Traversal depth alias."),
13384
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
13385
+ mode: z.string().optional().describe("Traversal mode."),
13386
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
13387
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
13388
+ });
10973
13389
  var judgmentsContracts = [
10974
13390
  surfaceContract({
10975
13391
  name: "record_judgment",
@@ -11024,7 +13440,8 @@ var judgmentsContracts = [
11024
13440
  minLayer: input.minLayer,
11025
13441
  maxLayer: input.maxLayer
11026
13442
  })
11027
- }
13443
+ },
13444
+ args: auditTrailArgs
11028
13445
  })
11029
13446
  ];
11030
13447
 
@@ -11192,8 +13609,13 @@ var coordinationContracts = [
11192
13609
  }
11193
13610
  })
11194
13611
  ];
11195
-
11196
- // ../contracts/src/function-registry/pipeline.ts
13612
+ var pipelineSnapshotArgs = z.object({
13613
+ topicId: z.string().describe("Topic scope ID."),
13614
+ status: z.string().optional().describe("Worktree status filter."),
13615
+ lane: z.string().optional().describe("Campaign lane filter."),
13616
+ campaign: z.number().optional().describe("Campaign number filter."),
13617
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
13618
+ });
11197
13619
  var pipelineContracts = [
11198
13620
  surfaceContract({
11199
13621
  name: "pipeline_snapshot",
@@ -11214,7 +13636,8 @@ var pipelineContracts = [
11214
13636
  campaign: input.campaign,
11215
13637
  limit: input.limit
11216
13638
  })
11217
- }
13639
+ },
13640
+ args: pipelineSnapshotArgs
11218
13641
  }),
11219
13642
  surfaceContract({
11220
13643
  name: "seed_belief_lattice",
@@ -11266,7 +13689,31 @@ var recordScopeLearningArgs = z.object({
11266
13689
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11267
13690
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11268
13691
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11269
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
13692
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
13693
+ text: z.string().optional().describe("Canonical learning text alias."),
13694
+ content: z.string().optional().describe("Canonical learning content alias."),
13695
+ kind: z.string().optional().describe("Evidence kind to store."),
13696
+ sourceType: z.string().optional().describe("Evidence source type."),
13697
+ externalSourceType: z.string().optional().describe("External source type alias."),
13698
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
13699
+ });
13700
+ var codeContextArgs = z.object({
13701
+ topicId: z.string().optional().describe("Topic scope."),
13702
+ filePath: z.string().optional().describe("File path anchor."),
13703
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
13704
+ limit: z.number().optional().describe("Maximum records to return."),
13705
+ status: z.string().optional().describe("Evidence status filter.")
13706
+ });
13707
+ var recordAttemptArgs = z.object({
13708
+ topicId: z.string().optional().describe("Topic scope."),
13709
+ description: z.string().describe("Attempt description."),
13710
+ errorMessage: z.string().optional().describe("Failure or error message."),
13711
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
13712
+ filePath: z.string().optional().describe("Single file path alias."),
13713
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
13714
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
13715
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
13716
+ title: z.string().optional().describe("Attempt evidence title.")
11270
13717
  });
11271
13718
  var learningInput = (input, context) => {
11272
13719
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11383,7 +13830,8 @@ var codingContracts = [
11383
13830
  status: input.status,
11384
13831
  userId: input.userId
11385
13832
  })
11386
- }
13833
+ },
13834
+ args: codeContextArgs
11387
13835
  }),
11388
13836
  surfaceContract({
11389
13837
  name: "get_change_history",
@@ -11420,7 +13868,8 @@ var codingContracts = [
11420
13868
  functionName: "create",
11421
13869
  kind: "mutation",
11422
13870
  inputProjection: attemptInput
11423
- }
13871
+ },
13872
+ args: recordAttemptArgs
11424
13873
  }),
11425
13874
  surfaceContract({
11426
13875
  name: "get_failure_log",
@@ -11477,6 +13926,7 @@ var ALL_FUNCTION_CONTRACTS = [
11477
13926
  ...evidenceContracts,
11478
13927
  ...questionsContracts,
11479
13928
  ...topicsContracts,
13929
+ ...nodesContracts,
11480
13930
  ...lensesContracts,
11481
13931
  ...ontologiesContracts,
11482
13932
  ...worktreesContracts,
@@ -11491,9 +13941,610 @@ var ALL_FUNCTION_CONTRACTS = [
11491
13941
  ...legacyContracts
11492
13942
  ];
11493
13943
  assertSurfaceCoverage(ALL_FUNCTION_CONTRACTS);
11494
- new Map(
13944
+ var FUNCTION_CONTRACTS_BY_NAME = new Map(
11495
13945
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11496
13946
  );
13947
+ FUNCTION_CONTRACTS_BY_NAME.get.bind(
13948
+ FUNCTION_CONTRACTS_BY_NAME
13949
+ );
13950
+
13951
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
13952
+ function isCopyableSeedRequirement(entry) {
13953
+ 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;
13954
+ }
13955
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
13956
+ {
13957
+ component: "kernel",
13958
+ table: "agentMessages",
13959
+ prepopulation: "runtime_data",
13960
+ copyMode: "none",
13961
+ description: "Agent coordination messages are session data, not template data."
13962
+ },
13963
+ {
13964
+ component: "kernel",
13965
+ table: "agentSessions",
13966
+ prepopulation: "runtime_data",
13967
+ copyMode: "none",
13968
+ description: "Agent coordination sessions are created by active clients."
13969
+ },
13970
+ {
13971
+ component: "kernel",
13972
+ table: "autofixJobs",
13973
+ prepopulation: "runtime_queue",
13974
+ copyMode: "none",
13975
+ description: "Autofix work items are runtime queue rows."
13976
+ },
13977
+ {
13978
+ component: "kernel",
13979
+ table: "backgroundJobRuns",
13980
+ prepopulation: "runtime_log",
13981
+ copyMode: "none",
13982
+ description: "Background job executions are runtime logs."
13983
+ },
13984
+ {
13985
+ component: "kernel",
13986
+ table: "backgroundJobSettings",
13987
+ prepopulation: "required_template",
13988
+ copyMode: "template_global",
13989
+ scope: "global",
13990
+ uniqueKey: ["jobKey"],
13991
+ description: "Default job enablement settings must come from the K template."
13992
+ },
13993
+ {
13994
+ component: "kernel",
13995
+ table: "beliefConfidence",
13996
+ prepopulation: "runtime_data",
13997
+ copyMode: "none",
13998
+ description: "Belief confidence rows are created with tenant graph facts."
13999
+ },
14000
+ {
14001
+ component: "kernel",
14002
+ table: "beliefEvidenceLinks",
14003
+ prepopulation: "runtime_data",
14004
+ copyMode: "none",
14005
+ description: "Belief-to-evidence links are tenant graph data."
14006
+ },
14007
+ {
14008
+ component: "kernel",
14009
+ table: "beliefHistory",
14010
+ prepopulation: "runtime_data",
14011
+ copyMode: "none",
14012
+ description: "Belief history is append-only tenant graph data."
14013
+ },
14014
+ {
14015
+ component: "kernel",
14016
+ table: "beliefScenarios",
14017
+ prepopulation: "runtime_data",
14018
+ copyMode: "none",
14019
+ description: "Scenario rows are tenant-authored reasoning data."
14020
+ },
14021
+ {
14022
+ component: "kernel",
14023
+ table: "beliefVotes",
14024
+ prepopulation: "runtime_data",
14025
+ copyMode: "none",
14026
+ description: "Decision belief votes are tenant-authored data."
14027
+ },
14028
+ {
14029
+ component: "kernel",
14030
+ table: "calibrationScores",
14031
+ prepopulation: "runtime_derived",
14032
+ copyMode: "none",
14033
+ description: "Calibration scores are computed from tenant outcomes."
14034
+ },
14035
+ {
14036
+ component: "kernel",
14037
+ table: "contractEvaluations",
14038
+ prepopulation: "runtime_log",
14039
+ copyMode: "none",
14040
+ description: "Contract evaluation rows are runtime computation logs."
14041
+ },
14042
+ {
14043
+ component: "kernel",
14044
+ table: "contradictions",
14045
+ prepopulation: "runtime_data",
14046
+ copyMode: "none",
14047
+ description: "Contradictions are tenant graph facts."
14048
+ },
14049
+ {
14050
+ component: "kernel",
14051
+ table: "crossProjectConnections",
14052
+ prepopulation: "runtime_data",
14053
+ copyMode: "none",
14054
+ description: "Cross-topic connections are tenant graph facts."
14055
+ },
14056
+ {
14057
+ component: "kernel",
14058
+ table: "decisionComputedSummaries",
14059
+ prepopulation: "runtime_derived",
14060
+ copyMode: "none",
14061
+ description: "Decision summaries are derived tenant outputs."
14062
+ },
14063
+ {
14064
+ component: "kernel",
14065
+ table: "decisionEvents",
14066
+ prepopulation: "runtime_data",
14067
+ copyMode: "none",
14068
+ description: "Decision events are lifecycle data."
14069
+ },
14070
+ {
14071
+ component: "kernel",
14072
+ table: "decisionParticipants",
14073
+ prepopulation: "runtime_data",
14074
+ copyMode: "none",
14075
+ description: "Decision participants are tenant-selected actors."
14076
+ },
14077
+ {
14078
+ component: "kernel",
14079
+ table: "decisionRiskLedger",
14080
+ prepopulation: "runtime_data",
14081
+ copyMode: "none",
14082
+ description: "Decision risk rows are tenant decision data."
14083
+ },
14084
+ {
14085
+ component: "kernel",
14086
+ table: "decisionSnapshots",
14087
+ prepopulation: "runtime_derived",
14088
+ copyMode: "none",
14089
+ description: "Decision snapshots are derived from tenant state."
14090
+ },
14091
+ {
14092
+ component: "kernel",
14093
+ table: "deliberationContributions",
14094
+ prepopulation: "runtime_data",
14095
+ copyMode: "none",
14096
+ description: "Deliberation contributions are tenant-authored data."
14097
+ },
14098
+ {
14099
+ component: "kernel",
14100
+ table: "deliberationSessions",
14101
+ prepopulation: "runtime_data",
14102
+ copyMode: "none",
14103
+ description: "Deliberation sessions are created by tenant workflows."
14104
+ },
14105
+ {
14106
+ component: "kernel",
14107
+ table: "epistemicAudit",
14108
+ prepopulation: "runtime_log",
14109
+ copyMode: "none",
14110
+ description: "Epistemic audit rows are append-only runtime audit data."
14111
+ },
14112
+ {
14113
+ component: "kernel",
14114
+ table: "epistemicContracts",
14115
+ prepopulation: "runtime_data",
14116
+ copyMode: "none",
14117
+ description: "Epistemic contracts are tenant-authored governance data."
14118
+ },
14119
+ {
14120
+ component: "kernel",
14121
+ table: "epistemicEdges",
14122
+ prepopulation: "runtime_data",
14123
+ copyMode: "none",
14124
+ description: "Edges are tenant reasoning graph data."
14125
+ },
14126
+ {
14127
+ component: "kernel",
14128
+ table: "epistemicNodeEmbeddings",
14129
+ prepopulation: "runtime_derived",
14130
+ copyMode: "none",
14131
+ description: "Embeddings are derived from tenant graph nodes."
14132
+ },
14133
+ {
14134
+ component: "kernel",
14135
+ table: "epistemicNodes",
14136
+ prepopulation: "runtime_data",
14137
+ copyMode: "none",
14138
+ description: "Nodes are tenant reasoning graph data."
14139
+ },
14140
+ {
14141
+ component: "kernel",
14142
+ table: "graphAnalysisCache",
14143
+ prepopulation: "runtime_derived",
14144
+ copyMode: "none",
14145
+ description: "Graph analysis cache rows are derived from tenant graph state."
14146
+ },
14147
+ {
14148
+ component: "kernel",
14149
+ table: "graphAnalysisResults",
14150
+ prepopulation: "runtime_derived",
14151
+ copyMode: "none",
14152
+ description: "Graph analysis result rows are derived tenant outputs."
14153
+ },
14154
+ {
14155
+ component: "kernel",
14156
+ table: "graphSuggestions",
14157
+ prepopulation: "runtime_derived",
14158
+ copyMode: "none",
14159
+ description: "Graph suggestions are derived recommendations."
14160
+ },
14161
+ {
14162
+ component: "kernel",
14163
+ table: "harnessReplays",
14164
+ prepopulation: "runtime_log",
14165
+ copyMode: "none",
14166
+ description: "Harness replay rows are runtime verification logs."
14167
+ },
14168
+ {
14169
+ component: "kernel",
14170
+ table: "harnessRuns",
14171
+ prepopulation: "runtime_log",
14172
+ copyMode: "none",
14173
+ description: "Harness run rows are runtime verification logs."
14174
+ },
14175
+ {
14176
+ component: "kernel",
14177
+ table: "idempotencyTokens",
14178
+ prepopulation: "runtime_log",
14179
+ copyMode: "none",
14180
+ description: "Idempotency tokens are request-scoped runtime guards."
14181
+ },
14182
+ {
14183
+ component: "kernel",
14184
+ table: "lenses",
14185
+ prepopulation: "optional_template",
14186
+ copyMode: "none",
14187
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
14188
+ },
14189
+ {
14190
+ component: "kernel",
14191
+ table: "lensTopicBindings",
14192
+ prepopulation: "runtime_data",
14193
+ copyMode: "none",
14194
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
14195
+ },
14196
+ {
14197
+ component: "kernel",
14198
+ table: "neo4jSyncQueue",
14199
+ prepopulation: "runtime_queue",
14200
+ copyMode: "none",
14201
+ description: "Neo4j sync queue rows are runtime work items."
14202
+ },
14203
+ {
14204
+ component: "kernel",
14205
+ table: "ontologyDefinitions",
14206
+ prepopulation: "required_template",
14207
+ copyMode: "template_global",
14208
+ scope: "global",
14209
+ uniqueKey: ["ontologyKey"],
14210
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
14211
+ },
14212
+ {
14213
+ component: "kernel",
14214
+ table: "ontologyVersions",
14215
+ prepopulation: "required_template",
14216
+ copyMode: "template_reference_remap",
14217
+ scope: "global",
14218
+ uniqueKey: ["ontologyKey", "version"],
14219
+ dependsOn: ["ontologyDefinitions"],
14220
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
14221
+ },
14222
+ {
14223
+ component: "kernel",
14224
+ table: "platformAgentRunPolicyDecisions",
14225
+ prepopulation: "runtime_log",
14226
+ copyMode: "none",
14227
+ description: "Agent-run policy decisions are audit logs."
14228
+ },
14229
+ {
14230
+ component: "kernel",
14231
+ table: "platformAgentRunPromptResolutions",
14232
+ prepopulation: "runtime_log",
14233
+ copyMode: "none",
14234
+ description: "Agent-run prompt resolution rows are runtime logs."
14235
+ },
14236
+ {
14237
+ component: "kernel",
14238
+ table: "platformAgentRuns",
14239
+ prepopulation: "runtime_log",
14240
+ copyMode: "none",
14241
+ description: "Agent runs are runtime execution records."
14242
+ },
14243
+ {
14244
+ component: "kernel",
14245
+ table: "platformAgentRunToolCalls",
14246
+ prepopulation: "runtime_log",
14247
+ copyMode: "none",
14248
+ description: "Agent-run tool calls are runtime execution records."
14249
+ },
14250
+ {
14251
+ component: "kernel",
14252
+ table: "platformHarnessShadowAudit",
14253
+ prepopulation: "runtime_log",
14254
+ copyMode: "none",
14255
+ description: "Harness shadow audit rows are runtime audit records."
14256
+ },
14257
+ {
14258
+ component: "kernel",
14259
+ table: "publicationRules",
14260
+ prepopulation: "required_template",
14261
+ copyMode: "template_tenant_rewrite",
14262
+ scope: "tenant",
14263
+ uniqueKey: ["tenantId", "workspaceId", "name"],
14264
+ description: "Default publication policy rules are rewritten into each tenant."
14265
+ },
14266
+ {
14267
+ component: "kernel",
14268
+ table: "questionEvidenceLinks",
14269
+ prepopulation: "runtime_data",
14270
+ copyMode: "none",
14271
+ description: "Question-to-evidence links are tenant graph data."
14272
+ },
14273
+ {
14274
+ component: "kernel",
14275
+ table: "researchJobs",
14276
+ prepopulation: "runtime_queue",
14277
+ copyMode: "none",
14278
+ description: "Research job rows are runtime queue items."
14279
+ },
14280
+ {
14281
+ component: "kernel",
14282
+ table: "schemaEnumConfig",
14283
+ prepopulation: "required_template",
14284
+ copyMode: "template_global",
14285
+ scope: "global",
14286
+ uniqueKey: ["category", "value"],
14287
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
14288
+ },
14289
+ {
14290
+ component: "kernel",
14291
+ table: "stakeholderGroups",
14292
+ prepopulation: "runtime_data",
14293
+ copyMode: "none",
14294
+ description: "Stakeholder groups are tenant decision data."
14295
+ },
14296
+ {
14297
+ component: "kernel",
14298
+ table: "systemLogs",
14299
+ prepopulation: "runtime_log",
14300
+ copyMode: "none",
14301
+ description: "System logs are runtime telemetry."
14302
+ },
14303
+ {
14304
+ component: "kernel",
14305
+ table: "tasks",
14306
+ prepopulation: "runtime_data",
14307
+ copyMode: "none",
14308
+ description: "Tasks are tenant-authored work items."
14309
+ },
14310
+ {
14311
+ component: "kernel",
14312
+ table: "topics",
14313
+ prepopulation: "runtime_bootstrap",
14314
+ copyMode: "none",
14315
+ description: "Default topics are created by tenant provisioning, not copied from templates."
14316
+ },
14317
+ {
14318
+ component: "kernel",
14319
+ table: "workflowDefinitions",
14320
+ prepopulation: "optional_template",
14321
+ copyMode: "none",
14322
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
14323
+ },
14324
+ {
14325
+ component: "kernel",
14326
+ table: "workflowPullRequests",
14327
+ prepopulation: "runtime_data",
14328
+ copyMode: "none",
14329
+ description: "Workflow pull requests are tenant workflow data."
14330
+ },
14331
+ {
14332
+ component: "kernel",
14333
+ table: "workflowStages",
14334
+ prepopulation: "optional_template",
14335
+ copyMode: "none",
14336
+ dependsOn: ["workflowDefinitions"],
14337
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
14338
+ },
14339
+ {
14340
+ component: "kernel",
14341
+ table: "worktreeBeliefCluster",
14342
+ prepopulation: "runtime_data",
14343
+ copyMode: "none",
14344
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
14345
+ },
14346
+ {
14347
+ component: "kernel",
14348
+ table: "worktrees",
14349
+ prepopulation: "runtime_data",
14350
+ copyMode: "none",
14351
+ description: "Worktrees are tenant/runtime planning data."
14352
+ },
14353
+ {
14354
+ component: "identity",
14355
+ table: "agents",
14356
+ prepopulation: "runtime_bootstrap",
14357
+ copyMode: "none",
14358
+ description: "Service agents are provisioned per tenant or service, not copied."
14359
+ },
14360
+ {
14361
+ component: "identity",
14362
+ table: "mcpWritePolicy",
14363
+ prepopulation: "required_template",
14364
+ copyMode: "template_global",
14365
+ scope: "global",
14366
+ uniqueKey: ["topicId", "role", "toolCategory"],
14367
+ description: "Global write policy defaults govern service and interactive MCP writes."
14368
+ },
14369
+ {
14370
+ component: "identity",
14371
+ table: "modelCallLogs",
14372
+ prepopulation: "runtime_log",
14373
+ copyMode: "none",
14374
+ description: "Model call logs are runtime telemetry."
14375
+ },
14376
+ {
14377
+ component: "identity",
14378
+ table: "modelFunctionSlots",
14379
+ prepopulation: "required_template",
14380
+ copyMode: "template_global",
14381
+ scope: "global",
14382
+ uniqueKey: ["slot"],
14383
+ description: "Function-to-model slots are required by model runtime resolution."
14384
+ },
14385
+ {
14386
+ component: "identity",
14387
+ table: "modelRegistry",
14388
+ prepopulation: "required_template",
14389
+ copyMode: "template_global",
14390
+ scope: "global",
14391
+ uniqueKey: ["key"],
14392
+ description: "Model catalog defaults are required by model runtime clients."
14393
+ },
14394
+ {
14395
+ component: "identity",
14396
+ table: "modelSlotConfigs",
14397
+ prepopulation: "required_template",
14398
+ copyMode: "template_global",
14399
+ scope: "global",
14400
+ uniqueKey: ["slot"],
14401
+ description: "Slot-level defaults are required before tenant overrides exist."
14402
+ },
14403
+ {
14404
+ component: "identity",
14405
+ table: "platformAudienceGrants",
14406
+ prepopulation: "runtime_data",
14407
+ copyMode: "none",
14408
+ description: "Audience grants are principal/group-specific access rows."
14409
+ },
14410
+ {
14411
+ component: "identity",
14412
+ table: "platformAudiences",
14413
+ prepopulation: "required_template",
14414
+ copyMode: "template_tenant_rewrite",
14415
+ scope: "tenant",
14416
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
14417
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
14418
+ },
14419
+ {
14420
+ component: "identity",
14421
+ table: "platformPolicyDecisionLogs",
14422
+ prepopulation: "runtime_log",
14423
+ copyMode: "none",
14424
+ description: "Policy decisions are runtime audit logs."
14425
+ },
14426
+ {
14427
+ component: "identity",
14428
+ table: "projectGrants",
14429
+ prepopulation: "runtime_data",
14430
+ copyMode: "none",
14431
+ description: "Project/topic grants are principal or group-specific access rows."
14432
+ },
14433
+ {
14434
+ component: "identity",
14435
+ table: "reasoningPermissions",
14436
+ prepopulation: "runtime_data",
14437
+ copyMode: "none",
14438
+ description: "Reasoning permissions are principal-specific policy rows."
14439
+ },
14440
+ {
14441
+ component: "identity",
14442
+ table: "tenantApiKeys",
14443
+ prepopulation: "runtime_secret",
14444
+ copyMode: "none",
14445
+ description: "API keys are tenant credentials and must never be copied."
14446
+ },
14447
+ {
14448
+ component: "identity",
14449
+ table: "tenantConfig",
14450
+ prepopulation: "required_template",
14451
+ copyMode: "template_tenant_rewrite",
14452
+ scope: "tenant",
14453
+ uniqueKey: ["tenantId"],
14454
+ description: "Tenant-local config defaults are rewritten during bootstrap."
14455
+ },
14456
+ {
14457
+ component: "identity",
14458
+ table: "tenantIntegrations",
14459
+ prepopulation: "required_template",
14460
+ copyMode: "template_tenant_rewrite",
14461
+ scope: "tenant",
14462
+ uniqueKey: ["tenantId", "integrationKey"],
14463
+ description: "Non-secret integration descriptors are rewritten into each tenant."
14464
+ },
14465
+ {
14466
+ component: "identity",
14467
+ table: "tenantModelSlotBindings",
14468
+ prepopulation: "runtime_secret",
14469
+ copyMode: "none",
14470
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
14471
+ },
14472
+ {
14473
+ component: "identity",
14474
+ table: "tenantPolicies",
14475
+ prepopulation: "required_template",
14476
+ copyMode: "template_tenant_rewrite",
14477
+ scope: "tenant",
14478
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
14479
+ description: "Default tenant policy roles are rewritten during bootstrap."
14480
+ },
14481
+ {
14482
+ component: "identity",
14483
+ table: "tenantProviderSecrets",
14484
+ prepopulation: "runtime_secret",
14485
+ copyMode: "none",
14486
+ description: "Provider secrets are credentials and must never be copied."
14487
+ },
14488
+ {
14489
+ component: "identity",
14490
+ table: "tenantProxyGatewayUsage",
14491
+ prepopulation: "runtime_log",
14492
+ copyMode: "none",
14493
+ description: "Proxy gateway usage rows are runtime telemetry."
14494
+ },
14495
+ {
14496
+ component: "identity",
14497
+ table: "tenantProxyTokenMints",
14498
+ prepopulation: "runtime_secret",
14499
+ copyMode: "none",
14500
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
14501
+ },
14502
+ {
14503
+ component: "identity",
14504
+ table: "tenantSandboxAuditEvents",
14505
+ prepopulation: "runtime_log",
14506
+ copyMode: "none",
14507
+ description: "Sandbox audit rows are runtime security logs."
14508
+ },
14509
+ {
14510
+ component: "identity",
14511
+ table: "tenantSecrets",
14512
+ prepopulation: "runtime_secret",
14513
+ copyMode: "none",
14514
+ description: "Tenant secrets are credentials and must never be copied."
14515
+ },
14516
+ {
14517
+ component: "identity",
14518
+ table: "toolAcls",
14519
+ prepopulation: "required_template",
14520
+ copyMode: "template_global",
14521
+ scope: "global",
14522
+ uniqueKey: ["role", "toolName"],
14523
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
14524
+ },
14525
+ {
14526
+ component: "identity",
14527
+ table: "toolRegistry",
14528
+ prepopulation: "required_template",
14529
+ copyMode: "template_global",
14530
+ scope: "global",
14531
+ uniqueKey: ["toolName"],
14532
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
14533
+ },
14534
+ {
14535
+ component: "identity",
14536
+ table: "users",
14537
+ prepopulation: "runtime_bootstrap",
14538
+ copyMode: "none",
14539
+ description: "Users are created from Clerk/MC principal resolution, not copied."
14540
+ }
14541
+ ];
14542
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14543
+ isCopyableSeedRequirement
14544
+ );
14545
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14546
+ (entry) => !isCopyableSeedRequirement(entry)
14547
+ ).map((entry) => entry.table);
11497
14548
 
11498
14549
  export { buildDomainEvent, compareEventCursor, createEventId, decodeEventCursor, emitDomainEvent, encodeEventCursor, inferActorType, isAfterCursor, normalizeRetentionDays, sortEventsByCursor };
11499
14550
  //# sourceMappingURL=outbox.js.map