@lucern/events 0.3.0-alpha.3 → 0.3.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/webhooks.js CHANGED
@@ -1,6 +1,487 @@
1
1
  import { z } from 'zod';
2
2
  import { v } from 'convex/values';
3
3
 
4
+ // ../contracts/src/graph-intelligence.contract.ts
5
+ var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
6
+ core: [
7
+ "get_graph_structure_analysis",
8
+ "get_topic_coverage",
9
+ "get_graph_gaps",
10
+ "list_beliefs",
11
+ "list_questions",
12
+ "search_evidence"
13
+ ],
14
+ bias: [
15
+ "get_graph_structure_analysis",
16
+ "detect_confirmation_bias",
17
+ "find_contradictions",
18
+ "search_evidence",
19
+ "list_beliefs"
20
+ ],
21
+ stress: [
22
+ "get_graph_structure_analysis",
23
+ "get_graph_gaps",
24
+ "find_contradictions",
25
+ "get_falsification_questions",
26
+ "list_beliefs",
27
+ "list_questions"
28
+ ],
29
+ operational: [
30
+ "get_topic_coverage",
31
+ "get_graph_gaps",
32
+ "list_beliefs",
33
+ "list_questions",
34
+ "search_evidence"
35
+ ],
36
+ alpha: [
37
+ "get_graph_structure_analysis",
38
+ "detect_confirmation_bias",
39
+ "find_contradictions",
40
+ "search_beliefs",
41
+ "search_evidence"
42
+ ],
43
+ semantic: [
44
+ "get_graph_structure_analysis",
45
+ "search_beliefs",
46
+ "search_evidence",
47
+ "traverse_graph",
48
+ "query_lineage",
49
+ "get_graph_neighborhood"
50
+ ],
51
+ evidence: [
52
+ "get_graph_structure_analysis",
53
+ "get_topic_coverage",
54
+ "search_evidence",
55
+ "get_falsification_questions",
56
+ "find_contradictions"
57
+ ]
58
+ };
59
+ var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
60
+ var GRAPH_INTELLIGENCE_QUERIES = [
61
+ {
62
+ id: "confirmation-bias",
63
+ categoryId: "problems",
64
+ mode: "bias",
65
+ name: "Find Confirmation Bias",
66
+ description: "Find beliefs supported mainly by confirming evidence.",
67
+ prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
68
+ highlightStrategy: "bias-risk",
69
+ riskLevel: "high"
70
+ },
71
+ {
72
+ id: "contradiction-map",
73
+ categoryId: "problems",
74
+ mode: "stress",
75
+ name: "Map Contradictions",
76
+ description: "Surface direct and indirect contradiction clusters.",
77
+ prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
78
+ highlightStrategy: "contradictions",
79
+ riskLevel: "high"
80
+ },
81
+ {
82
+ id: "weak-evidence",
83
+ categoryId: "problems",
84
+ mode: "stress",
85
+ name: "Weak Evidence Chains",
86
+ description: "Find important claims with thin or indirect evidence.",
87
+ prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
88
+ highlightStrategy: "weak-support",
89
+ riskLevel: "medium"
90
+ },
91
+ {
92
+ id: "single-source",
93
+ categoryId: "problems",
94
+ mode: "bias",
95
+ name: "Single-Source Risk",
96
+ description: "Find claims overly dependent on one source or source type.",
97
+ prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
98
+ highlightStrategy: "source-concentration",
99
+ riskLevel: "medium"
100
+ },
101
+ {
102
+ id: "untested-assumptions",
103
+ categoryId: "problems",
104
+ mode: "stress",
105
+ name: "Untested Assumptions",
106
+ description: "Find load-bearing assumptions without falsification paths.",
107
+ prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
108
+ highlightStrategy: "untested",
109
+ riskLevel: "high"
110
+ },
111
+ {
112
+ id: "load-bearing-beliefs",
113
+ categoryId: "problems",
114
+ mode: "stress",
115
+ name: "Load-Bearing Beliefs",
116
+ description: "Find central beliefs whose failure would affect many claims.",
117
+ prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
118
+ highlightStrategy: "load-bearing",
119
+ riskLevel: "high"
120
+ },
121
+ {
122
+ id: "cascade-analysis",
123
+ categoryId: "problems",
124
+ mode: "stress",
125
+ name: "Cascade Analysis",
126
+ description: "Trace what changes if a belief is weakened or invalidated.",
127
+ prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
128
+ highlightStrategy: "cascade",
129
+ riskLevel: "high"
130
+ },
131
+ {
132
+ id: "unanswered-questions",
133
+ categoryId: "gaps",
134
+ mode: "operational",
135
+ name: "Unanswered Questions",
136
+ description: "Find important open questions that block confidence.",
137
+ prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
138
+ highlightStrategy: "open-questions"
139
+ },
140
+ {
141
+ id: "thin-themes",
142
+ categoryId: "gaps",
143
+ mode: "operational",
144
+ name: "Thin Themes",
145
+ description: "Find topics with shallow belief or evidence coverage.",
146
+ prompt: "Find themes that look underdeveloped relative to their role in the graph.",
147
+ highlightStrategy: "thin-themes"
148
+ },
149
+ {
150
+ id: "missing-evidence",
151
+ categoryId: "gaps",
152
+ mode: "stress",
153
+ name: "Missing Evidence",
154
+ description: "Find beliefs that need specific missing evidence.",
155
+ prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
156
+ highlightStrategy: "missing-evidence"
157
+ },
158
+ {
159
+ id: "isolated-clusters",
160
+ categoryId: "gaps",
161
+ mode: "operational",
162
+ name: "Isolated Clusters",
163
+ description: "Find clusters not connected to the broader graph.",
164
+ prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
165
+ highlightStrategy: "isolated-clusters"
166
+ },
167
+ {
168
+ id: "source-contribution",
169
+ categoryId: "gaps",
170
+ mode: "evidence",
171
+ name: "Source Contribution",
172
+ description: "Assess how source mix shapes the graph.",
173
+ prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
174
+ highlightStrategy: "source-mix"
175
+ },
176
+ {
177
+ id: "stale-beliefs",
178
+ categoryId: "gaps",
179
+ mode: "operational",
180
+ name: "Stale Beliefs",
181
+ description: "Find beliefs that need review because they are old or stale.",
182
+ prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
183
+ highlightStrategy: "staleness"
184
+ },
185
+ {
186
+ id: "assumption-pyramid",
187
+ categoryId: "reasoning",
188
+ mode: "operational",
189
+ name: "Assumption Pyramid",
190
+ description: "Show which conclusions rest on which assumptions.",
191
+ prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
192
+ highlightStrategy: "assumptions"
193
+ },
194
+ {
195
+ id: "converging-evidence",
196
+ categoryId: "reasoning",
197
+ mode: "evidence",
198
+ name: "Converging Evidence",
199
+ description: "Find claims supported by independent evidence streams.",
200
+ prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
201
+ highlightStrategy: "convergence"
202
+ },
203
+ {
204
+ id: "weakest-links",
205
+ categoryId: "reasoning",
206
+ mode: "stress",
207
+ name: "Weakest Links",
208
+ description: "Find the weakest links in important reasoning chains.",
209
+ prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
210
+ highlightStrategy: "weak-links",
211
+ riskLevel: "medium"
212
+ },
213
+ {
214
+ id: "challenged-beliefs",
215
+ categoryId: "reasoning",
216
+ mode: "stress",
217
+ name: "Challenged Beliefs",
218
+ description: "Find beliefs with active challenges or defeaters.",
219
+ prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
220
+ highlightStrategy: "challenged"
221
+ },
222
+ {
223
+ id: "contrarian-map",
224
+ categoryId: "strategic",
225
+ mode: "alpha",
226
+ name: "Contrarian Map",
227
+ description: "Find non-consensus beliefs and where they are grounded.",
228
+ prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
229
+ highlightStrategy: "contrarian"
230
+ },
231
+ {
232
+ id: "irreversibility-audit",
233
+ categoryId: "strategic",
234
+ mode: "stress",
235
+ name: "Irreversibility Audit",
236
+ description: "Find irreversible bets and assumptions behind them.",
237
+ prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
238
+ highlightStrategy: "irreversible",
239
+ riskLevel: "high"
240
+ },
241
+ {
242
+ id: "pre-mortem",
243
+ categoryId: "strategic",
244
+ mode: "stress",
245
+ name: "Pre-Mortem",
246
+ description: "Explain how the graph could be wrong.",
247
+ prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
248
+ highlightStrategy: "failure-paths",
249
+ riskLevel: "high"
250
+ },
251
+ {
252
+ id: "devils-advocate",
253
+ categoryId: "strategic",
254
+ mode: "stress",
255
+ name: "Devil's Advocate",
256
+ description: "Generate the strongest critique of the graph.",
257
+ prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
258
+ highlightStrategy: "critique"
259
+ },
260
+ {
261
+ id: "falsification-map",
262
+ categoryId: "strategic",
263
+ mode: "stress",
264
+ name: "Falsification Map",
265
+ description: "Find the cheapest tests that would disprove key beliefs.",
266
+ prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
267
+ highlightStrategy: "falsification",
268
+ riskLevel: "high"
269
+ },
270
+ {
271
+ id: "prediction-tracker",
272
+ categoryId: "strategic",
273
+ mode: "evidence",
274
+ name: "Prediction Tracker",
275
+ description: "Find beliefs that imply measurable predictions.",
276
+ prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
277
+ highlightStrategy: "predictions"
278
+ },
279
+ {
280
+ id: "belief-pagerank",
281
+ categoryId: "deep",
282
+ mode: "semantic",
283
+ name: "Belief PageRank",
284
+ description: "Identify structurally central beliefs.",
285
+ prompt: "Use graph centrality to identify the most structurally important beliefs.",
286
+ highlightStrategy: "centrality"
287
+ },
288
+ {
289
+ id: "underdetermination",
290
+ categoryId: "deep",
291
+ mode: "semantic",
292
+ name: "Underdetermination",
293
+ description: "Find places where evidence supports multiple explanations.",
294
+ prompt: "Find places where the same evidence could support multiple incompatible explanations.",
295
+ highlightStrategy: "underdetermination"
296
+ },
297
+ {
298
+ id: "confidence-propagation",
299
+ categoryId: "deep",
300
+ mode: "semantic",
301
+ name: "Confidence Propagation",
302
+ description: "Assess how uncertainty moves through the graph.",
303
+ prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
304
+ highlightStrategy: "confidence-flow"
305
+ },
306
+ {
307
+ id: "argument-depth",
308
+ categoryId: "deep",
309
+ mode: "evidence",
310
+ name: "Argument Depth",
311
+ description: "Assess reasoning depth and chain quality.",
312
+ prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
313
+ highlightStrategy: "depth"
314
+ },
315
+ {
316
+ id: "information-edge",
317
+ categoryId: "deep",
318
+ mode: "alpha",
319
+ name: "Information Edge",
320
+ description: "Find differentiated evidence or signals.",
321
+ prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
322
+ highlightStrategy: "information-edge"
323
+ },
324
+ {
325
+ id: "thesis-summary",
326
+ categoryId: "browse",
327
+ mode: "semantic",
328
+ name: "Thesis Summary",
329
+ description: "Summarize the graph's core thesis and support.",
330
+ prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
331
+ highlightStrategy: "summary"
332
+ },
333
+ {
334
+ id: "theme-deep-dive",
335
+ categoryId: "browse",
336
+ mode: "semantic",
337
+ name: "Theme Deep Dive",
338
+ description: "Deep dive into a named theme.",
339
+ prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
340
+ inputType: "theme",
341
+ highlightStrategy: "theme"
342
+ },
343
+ {
344
+ id: "belief-detail",
345
+ categoryId: "browse",
346
+ mode: "semantic",
347
+ name: "Belief Detail",
348
+ description: "Explain one belief and its graph neighborhood.",
349
+ prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
350
+ inputType: "belief",
351
+ highlightStrategy: "belief"
352
+ },
353
+ {
354
+ id: "strongest-beliefs",
355
+ categoryId: "browse",
356
+ mode: "operational",
357
+ name: "Strongest Beliefs",
358
+ description: "Find the graph's strongest current beliefs.",
359
+ prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
360
+ highlightStrategy: "strongest"
361
+ },
362
+ {
363
+ id: "cross-theme-connection",
364
+ categoryId: "browse",
365
+ mode: "semantic",
366
+ name: "Cross-Theme Connections",
367
+ description: "Find bridges between themes.",
368
+ prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
369
+ highlightStrategy: "bridges"
370
+ },
371
+ {
372
+ id: "research-velocity",
373
+ categoryId: "browse",
374
+ mode: "operational",
375
+ name: "Research Velocity",
376
+ description: "Summarize recent graph movement and momentum.",
377
+ prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
378
+ highlightStrategy: "velocity"
379
+ },
380
+ {
381
+ id: "search",
382
+ categoryId: "browse",
383
+ mode: "semantic",
384
+ name: "Graph Search",
385
+ description: "Search the graph with semantic context.",
386
+ prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
387
+ inputType: "search",
388
+ highlightStrategy: "search"
389
+ },
390
+ {
391
+ id: "expert-coverage",
392
+ categoryId: "browse",
393
+ mode: "semantic",
394
+ name: "Expert Coverage",
395
+ description: "Assess coverage from expert/source perspectives.",
396
+ prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
397
+ highlightStrategy: "expert-coverage"
398
+ },
399
+ {
400
+ id: "value-chain-map",
401
+ categoryId: "browse",
402
+ mode: "semantic",
403
+ name: "Value Chain Map",
404
+ description: "Map entities, dependencies, and value-chain logic.",
405
+ prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
406
+ highlightStrategy: "value-chain"
407
+ },
408
+ {
409
+ id: "meeting-brief",
410
+ categoryId: "prep",
411
+ mode: "semantic",
412
+ name: "Meeting Brief",
413
+ description: "Prepare a meeting brief from graph context.",
414
+ prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
415
+ highlightStrategy: "brief"
416
+ },
417
+ {
418
+ id: "open-questions-entity",
419
+ categoryId: "prep",
420
+ mode: "semantic",
421
+ name: "Entity Open Questions",
422
+ description: "Find open questions about a specific entity.",
423
+ prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
424
+ inputType: "entity",
425
+ highlightStrategy: "entity-questions"
426
+ },
427
+ {
428
+ id: "company-context",
429
+ categoryId: "prep",
430
+ mode: "semantic",
431
+ name: "Company Context",
432
+ description: "Summarize graph context about a company.",
433
+ prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
434
+ inputType: "company",
435
+ highlightStrategy: "company"
436
+ },
437
+ {
438
+ id: "company-theme-fit",
439
+ categoryId: "prep",
440
+ mode: "semantic",
441
+ name: "Company Theme Fit",
442
+ description: "Assess how a company fits graph themes.",
443
+ prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
444
+ inputType: "company",
445
+ highlightStrategy: "fit"
446
+ },
447
+ {
448
+ id: "company-comparison",
449
+ categoryId: "prep",
450
+ mode: "semantic",
451
+ name: "Company Comparison",
452
+ description: "Compare companies through graph context.",
453
+ prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
454
+ inputType: "company-list",
455
+ highlightStrategy: "comparison"
456
+ },
457
+ {
458
+ id: "questions-to-ask",
459
+ categoryId: "prep",
460
+ mode: "operational",
461
+ name: "Questions to Ask",
462
+ description: "Generate high-signal questions from graph gaps.",
463
+ prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
464
+ highlightStrategy: "questions"
465
+ },
466
+ {
467
+ id: "beliefs-to-test",
468
+ categoryId: "prep",
469
+ mode: "stress",
470
+ name: "Beliefs to Test",
471
+ description: "Prioritize beliefs that should be tested next.",
472
+ prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
473
+ highlightStrategy: "tests",
474
+ riskLevel: "medium"
475
+ }
476
+ ];
477
+ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
478
+ const definition = query;
479
+ return {
480
+ ...definition,
481
+ tools: definition.tools ?? byMode(definition.mode)
482
+ };
483
+ });
484
+
4
485
  // ../contracts/src/events.contract.ts
5
486
  var WEBHOOK_MAX_ATTEMPTS = 5;
6
487
  var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
@@ -21,7 +502,10 @@ function idOf(table) {
21
502
  return schema;
22
503
  }
23
504
  var NODE_TYPE = z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
24
- var EDGE_TYPE = z.enum(["supports", "informs", "depends_on", "extracted_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"]);
505
+ var EDGE_TYPE_VALUES = ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"];
506
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
507
+ z.enum(EDGE_TYPE_VALUES);
508
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
25
509
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
26
510
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
27
511
  defineTable({
@@ -1506,7 +1990,7 @@ defineTable({
1506
1990
  "toNodeId": z.string().optional(),
1507
1991
  "sourceGlobalId": z.string().optional(),
1508
1992
  "targetGlobalId": z.string().optional(),
1509
- "edgeType": EDGE_TYPE,
1993
+ "edgeType": STORAGE_EDGE_TYPE,
1510
1994
  "edgeTier": z.string().optional(),
1511
1995
  "domainNamespace": z.string().optional(),
1512
1996
  "constraint": z.string().optional(),
@@ -3839,7 +4323,9 @@ defineTable({
3839
4323
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3840
4324
  "deployments": z.record(z.object({
3841
4325
  "url": z.string(),
3842
- "encryptedDeployKey": z.string()
4326
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4327
+ "encryptedDeployKey": z.string().optional(),
4328
+ "credentialRef": z.string().optional()
3843
4329
  })).optional(),
3844
4330
  "metadata": z.record(z.any()).optional(),
3845
4331
  "createdBy": z.string().optional(),
@@ -4275,6 +4761,128 @@ var edgePolicyManifest = {
4275
4761
  }
4276
4762
  ]
4277
4763
  };
4764
+
4765
+ // ../contracts/src/tenant-client.contract.ts
4766
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4767
+ {
4768
+ packageName: "@lucern/access-control",
4769
+ role: "runtime_entrypoint",
4770
+ directTenantImport: true
4771
+ },
4772
+ {
4773
+ packageName: "@lucern/agent",
4774
+ role: "platform_runtime",
4775
+ directTenantImport: false
4776
+ },
4777
+ {
4778
+ packageName: "@lucern/auth",
4779
+ role: "sdk_dependency",
4780
+ directTenantImport: false
4781
+ },
4782
+ {
4783
+ packageName: "@lucern/cli",
4784
+ role: "developer_tool",
4785
+ directTenantImport: false
4786
+ },
4787
+ {
4788
+ packageName: "@lucern/client-core",
4789
+ role: "sdk_dependency",
4790
+ directTenantImport: false
4791
+ },
4792
+ {
4793
+ packageName: "@lucern/confidence",
4794
+ role: "sdk_dependency",
4795
+ directTenantImport: false
4796
+ },
4797
+ {
4798
+ packageName: "@lucern/config",
4799
+ role: "configuration",
4800
+ directTenantImport: false
4801
+ },
4802
+ {
4803
+ packageName: "@lucern/contracts",
4804
+ role: "contract_entrypoint",
4805
+ directTenantImport: true
4806
+ },
4807
+ {
4808
+ packageName: "@lucern/control-plane",
4809
+ role: "platform_runtime",
4810
+ directTenantImport: false
4811
+ },
4812
+ {
4813
+ packageName: "@lucern/developer-kit",
4814
+ role: "developer_tool",
4815
+ directTenantImport: false
4816
+ },
4817
+ {
4818
+ packageName: "@lucern/events",
4819
+ role: "sdk_dependency",
4820
+ directTenantImport: false
4821
+ },
4822
+ {
4823
+ packageName: "@lucern/graph-primitives",
4824
+ role: "sdk_dependency",
4825
+ directTenantImport: false
4826
+ },
4827
+ {
4828
+ packageName: "@lucern/identity",
4829
+ role: "component_runtime",
4830
+ directTenantImport: false
4831
+ },
4832
+ {
4833
+ packageName: "@lucern/mcp",
4834
+ role: "runtime_entrypoint",
4835
+ directTenantImport: true
4836
+ },
4837
+ {
4838
+ packageName: "@lucern/pack-host",
4839
+ role: "platform_runtime",
4840
+ directTenantImport: false
4841
+ },
4842
+ {
4843
+ packageName: "@lucern/pack-installer",
4844
+ role: "developer_tool",
4845
+ directTenantImport: false
4846
+ },
4847
+ {
4848
+ packageName: "@lucern/proof-compiler",
4849
+ role: "developer_tool",
4850
+ directTenantImport: false
4851
+ },
4852
+ {
4853
+ packageName: "@lucern/react",
4854
+ role: "runtime_entrypoint",
4855
+ directTenantImport: true
4856
+ },
4857
+ {
4858
+ packageName: "@lucern/reasoning-kernel",
4859
+ role: "component_runtime",
4860
+ directTenantImport: false
4861
+ },
4862
+ {
4863
+ packageName: "@lucern/sdk",
4864
+ role: "runtime_entrypoint",
4865
+ directTenantImport: true
4866
+ },
4867
+ {
4868
+ packageName: "@lucern/server-core",
4869
+ role: "platform_runtime",
4870
+ directTenantImport: false
4871
+ },
4872
+ {
4873
+ packageName: "@lucern/testing",
4874
+ role: "test_support",
4875
+ directTenantImport: false
4876
+ },
4877
+ {
4878
+ packageName: "@lucern/types",
4879
+ role: "contract_entrypoint",
4880
+ directTenantImport: true
4881
+ }
4882
+ ];
4883
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
4884
+ (entry) => entry.packageName
4885
+ );
4278
4886
  z.object({
4279
4887
  manifestVersion: z.literal("1.0.0"),
4280
4888
  rules: z.array(
@@ -5036,6 +5644,14 @@ var ADD_WORKTREE = {
5036
5644
  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.",
5037
5645
  parameters: {
5038
5646
  title: { type: "string", description: "Worktree name/objective" },
5647
+ name: {
5648
+ type: "string",
5649
+ description: "Optional storage-name alias for callers that already use backend naming"
5650
+ },
5651
+ projectId: {
5652
+ type: "string",
5653
+ description: "Legacy topicId alias"
5654
+ },
5039
5655
  topicId: { type: "string", description: "Optional topic scope hint" },
5040
5656
  branchId: {
5041
5657
  type: "string",
@@ -5049,14 +5665,87 @@ var ADD_WORKTREE = {
5049
5665
  type: "string",
5050
5666
  description: "The testable claim this worktree investigates"
5051
5667
  },
5668
+ rationale: {
5669
+ type: "string",
5670
+ description: "Why this worktree exists and why it belongs in the campaign"
5671
+ },
5672
+ worktreeType: {
5673
+ type: "string",
5674
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5675
+ },
5676
+ gate: {
5677
+ type: "string",
5678
+ description: "Exit gate name for this worktree"
5679
+ },
5680
+ startDate: {
5681
+ type: "number",
5682
+ description: "Planned start timestamp in milliseconds since epoch"
5683
+ },
5684
+ endDate: {
5685
+ type: "number",
5686
+ description: "Planned end timestamp in milliseconds since epoch"
5687
+ },
5688
+ durationWeeks: {
5689
+ type: "number",
5690
+ description: "Planned duration in weeks"
5691
+ },
5692
+ confidenceImpact: {
5693
+ type: "string",
5694
+ description: "Expected confidence impact if the worktree succeeds",
5695
+ enum: ["high", "medium", "low"]
5696
+ },
5697
+ beliefFocus: {
5698
+ type: "string",
5699
+ description: "Natural-language focus spanning the target belief neighborhood"
5700
+ },
5052
5701
  beliefIds: {
5053
5702
  type: "array",
5054
- description: "Beliefs to test in this worktree"
5703
+ description: "Legacy alias for targetBeliefIds"
5704
+ },
5705
+ beliefs: {
5706
+ type: "array",
5707
+ description: "Legacy alias for targetBeliefIds"
5708
+ },
5709
+ targetBeliefIds: {
5710
+ type: "array",
5711
+ description: "Belief node IDs this worktree is expected to test or update"
5712
+ },
5713
+ targetQuestionIds: {
5714
+ type: "array",
5715
+ description: "Question node IDs this worktree is expected to answer"
5716
+ },
5717
+ keyQuestions: {
5718
+ type: "array",
5719
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5720
+ },
5721
+ evidenceSignals: {
5722
+ type: "array",
5723
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5724
+ },
5725
+ decisionGate: {
5726
+ type: "object",
5727
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5728
+ },
5729
+ goCriteria: {
5730
+ type: "array",
5731
+ description: "Shorthand go criteria used to build decisionGate"
5732
+ },
5733
+ noGoSignals: {
5734
+ type: "array",
5735
+ description: "Shorthand no-go signals used to build decisionGate"
5736
+ },
5737
+ proofArtifacts: {
5738
+ type: "array",
5739
+ description: "Expected proof artifacts required to close the worktree"
5055
5740
  },
5056
5741
  autoShape: {
5057
5742
  type: "boolean",
5058
5743
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5059
5744
  },
5745
+ autoFixPolicy: {
5746
+ type: "object",
5747
+ description: "Policy for permitted automatic remediation inside the worktree"
5748
+ },
5060
5749
  domainPackId: {
5061
5750
  type: "string",
5062
5751
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
@@ -5085,9 +5774,17 @@ var ADD_WORKTREE = {
5085
5774
  type: "array",
5086
5775
  description: "Worktree IDs blocked by this worktree"
5087
5776
  },
5088
- gate: {
5777
+ staffingHint: {
5089
5778
  type: "string",
5090
- description: "Exit gate name for this worktree"
5779
+ description: "Suggested staffing or agent allocation note"
5780
+ },
5781
+ lensId: {
5782
+ type: "string",
5783
+ description: "Lens that scopes this worktree when applicable"
5784
+ },
5785
+ lastReconciledAt: {
5786
+ type: "number",
5787
+ description: "Timestamp when worktree metadata was last reconciled"
5091
5788
  }
5092
5789
  },
5093
5790
  required: ["title", "topicId"],
@@ -5117,7 +5814,7 @@ var MERGE = {
5117
5814
  worktreeId: { type: "string", description: "The worktree to merge" },
5118
5815
  outcomes: {
5119
5816
  type: "array",
5120
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5817
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5121
5818
  },
5122
5819
  summary: { type: "string", description: "Overall findings summary" }
5123
5820
  },
@@ -5671,6 +6368,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5671
6368
  ontologyPrimitive: "graph",
5672
6369
  tier: "showcase"
5673
6370
  };
6371
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6372
+ name: "list_graph_intelligence_queries",
6373
+ 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.",
6374
+ parameters: {
6375
+ categoryId: {
6376
+ type: "string",
6377
+ description: "Optional category filter, such as problems or strategic"
6378
+ },
6379
+ mode: {
6380
+ type: "string",
6381
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6382
+ }
6383
+ },
6384
+ required: [],
6385
+ response: {
6386
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6387
+ fields: {
6388
+ categories: "array \u2014 query categories",
6389
+ queries: "array \u2014 query definitions with prompt templates and tools",
6390
+ quickQueries: "array \u2014 recommended one-click query presets",
6391
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6392
+ }
6393
+ },
6394
+ ownerModule: "graph-intelligence",
6395
+ ontologyPrimitive: "graph",
6396
+ tier: "showcase"
6397
+ };
6398
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6399
+ name: "run_graph_intelligence_query",
6400
+ 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.",
6401
+ parameters: {
6402
+ topicId: { type: "string", description: "Topic to analyze" },
6403
+ queryId: {
6404
+ type: "string",
6405
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6406
+ },
6407
+ prompt: {
6408
+ type: "string",
6409
+ description: "Optional custom prompt for custom analysis runs"
6410
+ },
6411
+ input: {
6412
+ type: "string",
6413
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6414
+ },
6415
+ mode: {
6416
+ type: "string",
6417
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6418
+ },
6419
+ limit: {
6420
+ type: "number",
6421
+ description: "Maximum graph context rows to return"
6422
+ }
6423
+ },
6424
+ required: ["topicId"],
6425
+ response: {
6426
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6427
+ fields: {
6428
+ query: "object \u2014 selected query definition",
6429
+ prompt: "string \u2014 resolved prompt template",
6430
+ toolPlan: "array \u2014 public tools and args the model can call next",
6431
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6432
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6433
+ }
6434
+ },
6435
+ ownerModule: "graph-intelligence",
6436
+ ontologyPrimitive: "graph",
6437
+ tier: "showcase"
6438
+ };
5674
6439
  var GET_FALSIFICATION_QUESTIONS = {
5675
6440
  name: "get_falsification_questions",
5676
6441
  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.",
@@ -8136,22 +8901,85 @@ var GENERATE_SESSION_HANDOFF = {
8136
8901
  tier: "showcase",
8137
8902
  internal: true
8138
8903
  };
8139
- var MCP_TOOL_CONTRACTS = {
8140
- // Belief lifecycle (commit, amend, fork, archive)
8141
- create_belief: CREATE_BELIEF,
8142
- get_belief: GET_BELIEF,
8143
- refine_belief: REFINE_BELIEF,
8144
- modulate_confidence: MODULATE_CONFIDENCE,
8145
- fork_belief: FORK_BELIEF,
8146
- archive_belief: ARCHIVE_BELIEF,
8147
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8148
- evaluate_contract: EVALUATE_CONTRACT,
8149
- get_contract_status: GET_CONTRACT_STATUS,
8150
- // Evidence (commit)
8151
- create_evidence: CREATE_EVIDENCE,
8152
- get_evidence: GET_EVIDENCE,
8153
- list_evidence: LIST_EVIDENCE,
8154
- link_evidence: LINK_EVIDENCE,
8904
+ var BEGIN_BUILD_SESSION = {
8905
+ name: "begin_build_session",
8906
+ 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.",
8907
+ parameters: {
8908
+ worktreeId: {
8909
+ type: "string",
8910
+ description: "The Lucern worktree ID to bootstrap."
8911
+ },
8912
+ branch: {
8913
+ type: "string",
8914
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
8915
+ },
8916
+ branchBase: {
8917
+ type: "string",
8918
+ description: 'Base branch for the feature branch. Default: "staging".'
8919
+ },
8920
+ prBase: {
8921
+ type: "string",
8922
+ description: 'Target branch for the PR. Default: "staging".'
8923
+ },
8924
+ sessionMode: {
8925
+ type: "string",
8926
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
8927
+ enum: ["async", "interactive"]
8928
+ },
8929
+ activateIfPlanning: {
8930
+ type: "boolean",
8931
+ description: "When true, automatically activate a planning worktree during bootstrap."
8932
+ }
8933
+ },
8934
+ required: ["worktreeId"],
8935
+ response: {
8936
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
8937
+ fields: {
8938
+ topicId: "string \u2014 canonical topic scope",
8939
+ topicName: "string \u2014 human-readable topic name",
8940
+ worktreeId: "string \u2014 worktree ID",
8941
+ worktreeName: "string \u2014 human-readable worktree name",
8942
+ branch: "string \u2014 git branch name",
8943
+ branchBase: "string \u2014 base branch",
8944
+ prBase: "string \u2014 PR target branch",
8945
+ campaign: "number | null \u2014 top-level pipeline campaign",
8946
+ lane: "string \u2014 campaign lane",
8947
+ gate: "string \u2014 exit gate",
8948
+ hypothesis: "string \u2014 worktree hypothesis",
8949
+ focus: "string \u2014 session focus",
8950
+ status: "string \u2014 worktree status after optional activation",
8951
+ sessionMode: "string \u2014 async | interactive",
8952
+ targetBeliefIds: "array \u2014 scoped belief IDs",
8953
+ targetQuestionIds: "array \u2014 scoped question IDs",
8954
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
8955
+ openQuestions: "array \u2014 open scoped questions",
8956
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
8957
+ dependencies: "array \u2014 upstream worktrees",
8958
+ unblocks: "array \u2014 downstream worktrees",
8959
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
8960
+ }
8961
+ },
8962
+ ownerModule: "bootstrap",
8963
+ ontologyPrimitive: "worktree",
8964
+ tier: "showcase",
8965
+ internal: true
8966
+ };
8967
+ var MCP_TOOL_CONTRACTS = {
8968
+ // Belief lifecycle (commit, amend, fork, archive)
8969
+ create_belief: CREATE_BELIEF,
8970
+ get_belief: GET_BELIEF,
8971
+ refine_belief: REFINE_BELIEF,
8972
+ modulate_confidence: MODULATE_CONFIDENCE,
8973
+ fork_belief: FORK_BELIEF,
8974
+ archive_belief: ARCHIVE_BELIEF,
8975
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8976
+ evaluate_contract: EVALUATE_CONTRACT,
8977
+ get_contract_status: GET_CONTRACT_STATUS,
8978
+ // Evidence (commit)
8979
+ create_evidence: CREATE_EVIDENCE,
8980
+ get_evidence: GET_EVIDENCE,
8981
+ list_evidence: LIST_EVIDENCE,
8982
+ link_evidence: LINK_EVIDENCE,
8155
8983
  add_evidence: ADD_EVIDENCE,
8156
8984
  // Contradictions (merge conflict)
8157
8985
  flag_contradiction: FLAG_CONTRADICTION,
@@ -8183,6 +9011,8 @@ var MCP_TOOL_CONTRACTS = {
8183
9011
  // Graph intelligence (showcase)
8184
9012
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8185
9013
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9014
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9015
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8186
9016
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8187
9017
  // Evidence operations (workhorse)
8188
9018
  search_evidence: SEARCH_EVIDENCE,
@@ -8229,6 +9059,7 @@ var MCP_TOOL_CONTRACTS = {
8229
9059
  get_agent_inbox: GET_AGENT_INBOX,
8230
9060
  claim_files: CLAIM_FILES,
8231
9061
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9062
+ begin_build_session: BEGIN_BUILD_SESSION,
8232
9063
  // Policy / ACL (workhorse)
8233
9064
  check_permission: CHECK_PERMISSION,
8234
9065
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8364,6 +9195,8 @@ var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8364
9195
  "traverse_graph",
8365
9196
  "get_graph_neighborhood",
8366
9197
  "get_graph_structure_analysis",
9198
+ "list_graph_intelligence_queries",
9199
+ "run_graph_intelligence_query",
8367
9200
  "find_contradictions",
8368
9201
  "flag_contradiction",
8369
9202
  "detect_confirmation_bias",
@@ -8442,6 +9275,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8442
9275
  "get_change_history",
8443
9276
  "get_failure_log",
8444
9277
  "record_attempt",
9278
+ "begin_build_session",
8445
9279
  "push",
8446
9280
  "open_pull_request",
8447
9281
  "record_judgment",
@@ -8496,7 +9330,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8496
9330
  "find_semantic_orphans"
8497
9331
  ];
8498
9332
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8499
- "begin_build_session",
8500
9333
  "evaluate_engineering_contract",
8501
9334
  "evaluate_research_contract"
8502
9335
  ];
@@ -8882,8 +9715,31 @@ function assertSurfaceCoverage(contracts) {
8882
9715
  }
8883
9716
  }
8884
9717
  }
8885
-
8886
- // ../contracts/src/function-registry/context.ts
9718
+ var jsonRecordSchema2 = z.record(z.unknown());
9719
+ var observationArgs = z.object({
9720
+ topicId: z.string().optional().describe("Topic scope for the observation."),
9721
+ summary: z.string().describe("Short observation summary."),
9722
+ text: z.string().optional().describe("Canonical observation text alias."),
9723
+ title: z.string().optional().describe("Optional observation title."),
9724
+ content: z.string().optional().describe("Optional rich observation content."),
9725
+ contentType: z.string().optional().describe("Observation content type."),
9726
+ kind: z.string().optional().describe("Evidence kind to store."),
9727
+ observationType: z.string().optional().describe("Observation type."),
9728
+ tags: z.array(z.string()).optional().describe("Observation tags."),
9729
+ source: z.string().optional().describe("Observation source label."),
9730
+ sourceType: z.string().optional().describe("Evidence source type."),
9731
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
9732
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9733
+ confidence: z.number().optional().describe("Observation confidence."),
9734
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
9735
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
9736
+ });
9737
+ var observationContextArgs = z.object({
9738
+ topicId: z.string().describe("Topic scope."),
9739
+ query: z.string().optional().describe("Optional context query."),
9740
+ limit: z.number().optional().describe("Maximum observations to return."),
9741
+ status: z.string().optional().describe("Observation status filter.")
9742
+ });
8887
9743
  var observationInput = (input, context) => withUserId(
8888
9744
  compactRecord4({
8889
9745
  projectId: input.projectId,
@@ -8942,7 +9798,8 @@ var contextContracts = [
8942
9798
  observationId: output && typeof output === "object" ? output.nodeId : void 0,
8943
9799
  observationType: input.observationType
8944
9800
  })
8945
- }
9801
+ },
9802
+ args: observationArgs
8946
9803
  }),
8947
9804
  surfaceContract({
8948
9805
  name: "get_observation_context",
@@ -8963,7 +9820,8 @@ var contextContracts = [
8963
9820
  status: input.status,
8964
9821
  userId: input.userId
8965
9822
  })
8966
- }
9823
+ },
9824
+ args: observationContextArgs
8967
9825
  })
8968
9826
  ];
8969
9827
 
@@ -9026,8 +9884,45 @@ var identityContracts = [
9026
9884
  }
9027
9885
  })
9028
9886
  ];
9029
-
9030
- // ../contracts/src/function-registry/beliefs.ts
9887
+ var jsonRecordSchema3 = z.record(z.unknown());
9888
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
9889
+ var reversibilitySchema = z.enum([
9890
+ "irreversible",
9891
+ "hard_to_reverse",
9892
+ "reversible",
9893
+ "trivial"
9894
+ ]);
9895
+ var predictionMetaSchema = z.object({
9896
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
9897
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
9898
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
9899
+ });
9900
+ var createBeliefArgs = z.object({
9901
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
9902
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
9903
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
9904
+ beliefType: z.string().optional().describe("Schema belief type."),
9905
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
9906
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
9907
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
9908
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
9909
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
9910
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
9911
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
9912
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
9913
+ });
9914
+ var forkBeliefArgs = z.object({
9915
+ nodeId: z.string().describe("The scored belief to fork from."),
9916
+ newFormulation: z.string().describe("The evolved belief statement."),
9917
+ forkReason: z.enum([
9918
+ "refinement",
9919
+ "contradiction_response",
9920
+ "scope_change",
9921
+ "confidence_collapse",
9922
+ "manual"
9923
+ ]).describe("Why this fork was created."),
9924
+ rationale: z.string().optional().describe("Why the fork is warranted.")
9925
+ });
9031
9926
  var beliefLookupInput = (input) => compactRecord4({
9032
9927
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9033
9928
  beliefId: input.beliefId
@@ -9102,7 +9997,8 @@ var beliefsContracts = [
9102
9997
  functionName: "create",
9103
9998
  kind: "mutation",
9104
9999
  inputProjection: createBeliefInput
9105
- }
10000
+ },
10001
+ args: createBeliefArgs
9106
10002
  }),
9107
10003
  surfaceContract({
9108
10004
  name: "get_belief",
@@ -9193,7 +10089,8 @@ var beliefsContracts = [
9193
10089
  functionName: "forkBelief",
9194
10090
  kind: "mutation",
9195
10091
  inputProjection: forkBeliefInput
9196
- }
10092
+ },
10093
+ args: forkBeliefArgs
9197
10094
  }),
9198
10095
  surfaceContract({
9199
10096
  name: "archive_belief",
@@ -9274,8 +10171,46 @@ var beliefsContracts = [
9274
10171
  }
9275
10172
  })
9276
10173
  ];
9277
-
9278
- // ../contracts/src/function-registry/evidence.ts
10174
+ var jsonRecordSchema4 = z.record(z.unknown());
10175
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10176
+ var createEvidenceArgs = z.object({
10177
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10178
+ text: z.string().describe("Canonical evidence text."),
10179
+ source: z.string().optional().describe("Source URL or source label."),
10180
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10181
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10182
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10183
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10184
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10185
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10186
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10187
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10188
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10189
+ title: z.string().optional().describe("Optional short title."),
10190
+ content: z.string().optional().describe("Optional long-form content."),
10191
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10192
+ kind: z.string().optional().describe("Evidence kind."),
10193
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10194
+ sourceType: z.string().optional().describe("Evidence source type."),
10195
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10196
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10197
+ methodology: z.string().optional().describe("Collection methodology."),
10198
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10199
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10200
+ });
10201
+ var addEvidenceArgs = z.object({
10202
+ canonicalText: z.string().describe("The evidence statement."),
10203
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10204
+ topicId: z.string().optional().describe("Topic scope hint."),
10205
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10206
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10207
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10208
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10209
+ title: z.string().optional().describe("Optional short title."),
10210
+ content: z.string().optional().describe("Optional long-form evidence content."),
10211
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10212
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10213
+ });
9279
10214
  var evidenceIdInput = (input) => compactRecord4({
9280
10215
  evidenceId: input.evidenceId,
9281
10216
  insightId: input.insightId,
@@ -9350,7 +10285,8 @@ var evidenceContracts = [
9350
10285
  functionName: "create",
9351
10286
  kind: "mutation",
9352
10287
  inputProjection: createEvidenceInput
9353
- }
10288
+ },
10289
+ args: createEvidenceArgs
9354
10290
  }),
9355
10291
  surfaceContract({
9356
10292
  name: "add_evidence",
@@ -9386,7 +10322,8 @@ var evidenceContracts = [
9386
10322
  context
9387
10323
  );
9388
10324
  }
9389
- }
10325
+ },
10326
+ args: addEvidenceArgs
9390
10327
  }),
9391
10328
  surfaceContract({
9392
10329
  name: "get_evidence",
@@ -9493,8 +10430,91 @@ var evidenceContracts = [
9493
10430
  }
9494
10431
  })
9495
10432
  ];
9496
-
9497
- // ../contracts/src/function-registry/questions.ts
10433
+ var jsonRecordSchema5 = z.record(z.unknown());
10434
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
10435
+ var kernelQuestionPrioritySchema = z.enum([
10436
+ "critical",
10437
+ "high",
10438
+ "medium",
10439
+ "low"
10440
+ ]);
10441
+ var questionTypeSchema = z.enum([
10442
+ "validation",
10443
+ "falsification",
10444
+ "assumption_probe",
10445
+ "prediction_test",
10446
+ "counterfactual",
10447
+ "discovery",
10448
+ "clarification",
10449
+ "comparison",
10450
+ "causal",
10451
+ "mechanism",
10452
+ "general"
10453
+ ]);
10454
+ var createQuestionArgs = z.object({
10455
+ text: z.string().describe("The question text."),
10456
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10457
+ topicId: z.string().optional().describe("Topic scope hint."),
10458
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
10459
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
10460
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
10461
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
10462
+ category: z.string().optional().describe("Question category."),
10463
+ source: z.string().optional().describe("Question source."),
10464
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
10465
+ importance: z.number().optional().describe("Numeric importance score."),
10466
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
10467
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
10468
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
10469
+ questionType: questionTypeSchema.optional().describe("Question type."),
10470
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
10471
+ });
10472
+ var refineQuestionArgs = z.object({
10473
+ id: z.string().describe("The question to refine."),
10474
+ text: z.string().describe("Updated question text."),
10475
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10476
+ rationale: z.string().optional().describe("Why the question is refined."),
10477
+ category: z.string().optional().describe("Updated question category."),
10478
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
10479
+ });
10480
+ var createAnswerArgs = z.object({
10481
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
10482
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10483
+ answerText: z.string().describe("The answer content."),
10484
+ topicId: z.string().optional().describe("Topic scope for the answer."),
10485
+ confidence: z.string().optional().describe("Answer confidence."),
10486
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
10487
+ answerSource: z.string().optional().describe("How the answer was produced."),
10488
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10489
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10490
+ });
10491
+ var answerQuestionArgs = z.object({
10492
+ id: z.string().describe("Canonical question ID."),
10493
+ topicId: z.string().describe("Topic scope for the answer."),
10494
+ text: z.string().describe("Answer text."),
10495
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
10496
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
10497
+ rationale: z.string().optional().describe("Why this answer is credible."),
10498
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10499
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
10500
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
10501
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
10502
+ answerSource: z.string().optional().describe("How the answer was produced."),
10503
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10504
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10505
+ });
10506
+ var missingQuestionsArgs = z.object({
10507
+ topicId: z.string().describe("Topic scope."),
10508
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
10509
+ status: z.string().optional().describe("Question status filter."),
10510
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10511
+ });
10512
+ var falsificationQuestionsArgs = z.object({
10513
+ topicId: z.string().describe("Topic scope."),
10514
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
10515
+ status: z.string().optional().describe("Question status filter."),
10516
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10517
+ });
9498
10518
  var questionNodeInput = (input) => compactRecord4({
9499
10519
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9500
10520
  questionId: input.questionId
@@ -9541,7 +10561,8 @@ var questionsContracts = [
9541
10561
  functionName: "create",
9542
10562
  kind: "mutation",
9543
10563
  inputProjection: createQuestionInput
9544
- }
10564
+ },
10565
+ args: createQuestionArgs
9545
10566
  }),
9546
10567
  surfaceContract({
9547
10568
  name: "get_question",
@@ -9597,7 +10618,8 @@ var questionsContracts = [
9597
10618
  category: input.category,
9598
10619
  priority: input.priority
9599
10620
  })
9600
- }
10621
+ },
10622
+ args: refineQuestionArgs
9601
10623
  }),
9602
10624
  surfaceContract({
9603
10625
  name: "update_question_status",
@@ -9673,7 +10695,8 @@ var questionsContracts = [
9673
10695
  }),
9674
10696
  context
9675
10697
  )
9676
- }
10698
+ },
10699
+ args: createAnswerArgs
9677
10700
  }),
9678
10701
  surfaceContract({
9679
10702
  name: "answer_question",
@@ -9702,7 +10725,8 @@ var questionsContracts = [
9702
10725
  }),
9703
10726
  context
9704
10727
  )
9705
- }
10728
+ },
10729
+ args: answerQuestionArgs
9706
10730
  }),
9707
10731
  surfaceContract({
9708
10732
  name: "get_answer",
@@ -9734,7 +10758,8 @@ var questionsContracts = [
9734
10758
  functionName: "getByTopic",
9735
10759
  kind: "query",
9736
10760
  inputProjection: questionTopicInput
9737
- }
10761
+ },
10762
+ args: missingQuestionsArgs
9738
10763
  }),
9739
10764
  surfaceContract({
9740
10765
  name: "get_high_priority_questions",
@@ -9769,11 +10794,22 @@ var questionsContracts = [
9769
10794
  functionName: "getByTopic",
9770
10795
  kind: "query",
9771
10796
  inputProjection: questionTopicInput
9772
- }
10797
+ },
10798
+ args: falsificationQuestionsArgs
9773
10799
  })
9774
10800
  ];
9775
-
9776
- // ../contracts/src/function-registry/topics.ts
10801
+ var updateTopicArgs = z.object({
10802
+ id: z.string().describe("Topic ID."),
10803
+ topicId: z.string().optional().describe("Topic ID alias."),
10804
+ name: z.string().optional().describe("Topic name."),
10805
+ description: z.string().optional().describe("Topic description."),
10806
+ type: z.string().optional().describe("Topic type."),
10807
+ status: z.string().optional().describe("Topic status."),
10808
+ visibility: z.string().optional().describe("Topic visibility."),
10809
+ ontologyId: z.string().optional().describe("Ontology to bind."),
10810
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
10811
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
10812
+ });
9777
10813
  var topicIdInput = (input) => compactRecord4({
9778
10814
  id: input.id ?? input.topicId
9779
10815
  });
@@ -9854,7 +10890,8 @@ var topicsContracts = [
9854
10890
  functionName: "update",
9855
10891
  kind: "mutation",
9856
10892
  inputProjection: updateTopicInput
9857
- }
10893
+ },
10894
+ args: updateTopicArgs
9858
10895
  }),
9859
10896
  surfaceContract({
9860
10897
  name: "get_topic_tree",
@@ -9873,8 +10910,27 @@ var topicsContracts = [
9873
10910
  }
9874
10911
  })
9875
10912
  ];
9876
-
9877
- // ../contracts/src/function-registry/lenses.ts
10913
+ var lensPerspectiveSchema = z.enum([
10914
+ "investigation",
10915
+ "monitoring",
10916
+ "analysis",
10917
+ "comparison",
10918
+ "taxonomy"
10919
+ ]);
10920
+ var jsonRecordSchema6 = z.record(z.unknown());
10921
+ var createLensArgs = z.object({
10922
+ name: z.string().describe("Lens name."),
10923
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
10924
+ topicId: z.string().optional().describe("Originating topic scope."),
10925
+ description: z.string().optional().describe("What this lens investigates or monitors."),
10926
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
10927
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
10928
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
10929
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
10930
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
10931
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
10932
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
10933
+ });
9878
10934
  var createLensInput = (input, context) => compactRecord4({
9879
10935
  name: input.name,
9880
10936
  description: input.description,
@@ -9911,7 +10967,8 @@ var lensesContracts = [
9911
10967
  functionName: "create",
9912
10968
  kind: "mutation",
9913
10969
  inputProjection: createLensInput
9914
- }
10970
+ },
10971
+ args: createLensArgs
9915
10972
  }),
9916
10973
  surfaceContract({
9917
10974
  name: "list_lenses",
@@ -9973,8 +11030,18 @@ var lensesContracts = [
9973
11030
  }
9974
11031
  })
9975
11032
  ];
9976
-
9977
- // ../contracts/src/function-registry/ontologies.ts
11033
+ var updateOntologyArgs = z.object({
11034
+ id: z.string().describe("Ontology definition ID."),
11035
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
11036
+ name: z.string().optional().describe("Ontology display name."),
11037
+ description: z.string().optional().describe("Ontology description."),
11038
+ status: z.string().optional().describe("Ontology lifecycle status.")
11039
+ });
11040
+ var ontologyVersionLifecycleArgs = z.object({
11041
+ id: z.string().describe("Ontology version ID."),
11042
+ versionId: z.string().optional().describe("Ontology version ID alias."),
11043
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
11044
+ });
9978
11045
  var ontologyIdInput = (input) => compactRecord4({
9979
11046
  id: input.id ?? input.ontologyId
9980
11047
  });
@@ -10053,11 +11120,11 @@ var ontologiesContracts = [
10053
11120
  id: input.id ?? input.ontologyId,
10054
11121
  name: input.name,
10055
11122
  description: input.description,
10056
- parentOntologyId: input.parentOntologyId,
10057
11123
  status: input.status,
10058
11124
  actorId: input.actorId
10059
11125
  })
10060
- }
11126
+ },
11127
+ args: updateOntologyArgs
10061
11128
  }),
10062
11129
  surfaceContract({
10063
11130
  name: "archive_ontology",
@@ -10140,7 +11207,8 @@ var ontologiesContracts = [
10140
11207
  functionName: "publishOntologyVersion",
10141
11208
  kind: "mutation",
10142
11209
  inputProjection: ontologyVersionIdInput
10143
- }
11210
+ },
11211
+ args: ontologyVersionLifecycleArgs
10144
11212
  }),
10145
11213
  surfaceContract({
10146
11214
  name: "deprecate_ontology_version",
@@ -10156,7 +11224,8 @@ var ontologiesContracts = [
10156
11224
  functionName: "deprecateOntologyVersion",
10157
11225
  kind: "mutation",
10158
11226
  inputProjection: ontologyVersionIdInput
10159
- }
11227
+ },
11228
+ args: ontologyVersionLifecycleArgs
10160
11229
  }),
10161
11230
  surfaceContract({
10162
11231
  name: "resolve_effective_ontology",
@@ -10175,8 +11244,76 @@ var ontologiesContracts = [
10175
11244
  }
10176
11245
  })
10177
11246
  ];
10178
-
10179
- // ../contracts/src/function-registry/worktrees.ts
11247
+ var autoFixPolicyInputSchema = z.object({
11248
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
11249
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
11250
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
11251
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
11252
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
11253
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
11254
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
11255
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
11256
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
11257
+ var worktreeKeyQuestionInputSchema = z.object({
11258
+ question: z.string().describe("Question the worktree must resolve."),
11259
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
11260
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
11261
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
11262
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
11263
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
11264
+ var worktreeEvidenceSignalInputSchema = z.object({
11265
+ signal: z.string().describe("Evidence signal the worktree should collect."),
11266
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
11267
+ progress: z.string().optional().describe("Collection progress note for the signal."),
11268
+ notes: z.string().optional().describe("Additional evidence collection notes.")
11269
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
11270
+ var worktreeDecisionGateInputSchema = z.object({
11271
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
11272
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
11273
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
11274
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
11275
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
11276
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
11277
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
11278
+ var addWorktreeArgs = z.object({
11279
+ title: z.string().optional().describe("Human-readable worktree name or objective."),
11280
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
11281
+ topicId: z.string().describe("Primary topic scope for the worktree."),
11282
+ projectId: z.string().optional().describe("Legacy topicId alias."),
11283
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
11284
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
11285
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
11286
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
11287
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
11288
+ gate: z.string().optional().describe("Exit gate for this worktree."),
11289
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
11290
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
11291
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
11292
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
11293
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
11294
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
11295
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
11296
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
11297
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
11298
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
11299
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
11300
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
11301
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
11302
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
11303
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
11304
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
11305
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
11306
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
11307
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
11308
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
11309
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
11310
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
11311
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
11312
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
11313
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
11314
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
11315
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
11316
+ });
10180
11317
  var worktreeIdInput = (input) => compactRecord4({
10181
11318
  worktreeId: input.worktreeId ?? input.id
10182
11319
  });
@@ -10209,6 +11346,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10209
11346
  autoFixPolicy: input.autoFixPolicy,
10210
11347
  lastReconciledAt: input.lastReconciledAt
10211
11348
  });
11349
+ var worktreeMetadataArgs = z.object({
11350
+ worktreeId: z.string().describe("The worktree to update."),
11351
+ id: z.string().optional().describe("Worktree ID alias."),
11352
+ topicId: z.string().optional().describe("Primary topic scope."),
11353
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
11354
+ status: z.string().optional().describe("Worktree lifecycle status."),
11355
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
11356
+ lane: z.string().optional().describe("Campaign lane."),
11357
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
11358
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
11359
+ gate: z.string().optional().describe("Exit gate for this worktree."),
11360
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
11361
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
11362
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
11363
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
11364
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
11365
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
11366
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
11367
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
11368
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
11369
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
11370
+ });
11371
+ var pushArgs = worktreeMetadataArgs.extend({
11372
+ targetContext: z.string().describe("Where to push merged findings."),
11373
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
11374
+ });
11375
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
11376
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
11377
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
11378
+ });
11379
+ var mergeKeyFindingsInput = (input) => {
11380
+ if (Array.isArray(input.keyFindings)) {
11381
+ return input.keyFindings;
11382
+ }
11383
+ if (Array.isArray(input.outcomes)) {
11384
+ const findings = input.outcomes.filter(
11385
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
11386
+ );
11387
+ if (findings.length > 0) {
11388
+ return findings;
11389
+ }
11390
+ }
11391
+ return [input.summary ?? "Merged worktree"];
11392
+ };
10212
11393
  var listAllWorktreesInput = (input) => compactRecord4({
10213
11394
  status: input.status,
10214
11395
  lane: input.lane,
@@ -10216,6 +11397,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10216
11397
  limit: input.limit
10217
11398
  });
10218
11399
  var worktreesContracts = [
11400
+ surfaceContract({
11401
+ name: "begin_build_session",
11402
+ kind: "mutation",
11403
+ domain: "worktrees",
11404
+ surfaceClass: "platform_internal",
11405
+ path: "/mcp/build-session/begin",
11406
+ sdkNamespace: "worktrees",
11407
+ sdkMethod: "beginBuildSession",
11408
+ summary: "Begin a coding build session for a worktree."
11409
+ }),
10219
11410
  surfaceContract({
10220
11411
  name: "add_worktree",
10221
11412
  kind: "mutation",
@@ -10232,13 +11423,12 @@ var worktreesContracts = [
10232
11423
  inputProjection: (input, context) => withCreatedBy(
10233
11424
  compactRecord4({
10234
11425
  name: input.name ?? input.title,
10235
- topicId: input.topicId,
11426
+ topicId: input.topicId ?? input.projectId,
10236
11427
  worktreeType: input.worktreeType,
10237
11428
  objective: input.objective,
10238
11429
  gate: input.gate,
10239
11430
  hypothesis: input.hypothesis,
10240
11431
  rationale: input.rationale,
10241
- signal: input.signal,
10242
11432
  startDate: input.startDate,
10243
11433
  endDate: input.endDate,
10244
11434
  durationWeeks: input.durationWeeks,
@@ -10264,12 +11454,12 @@ var worktreesContracts = [
10264
11454
  staffingHint: input.staffingHint,
10265
11455
  domainPackId: input.domainPackId,
10266
11456
  lensId: input.lensId,
10267
- linkedQuestionId: input.linkedQuestionId,
10268
11457
  lastReconciledAt: input.lastReconciledAt
10269
11458
  }),
10270
11459
  context
10271
11460
  )
10272
- }
11461
+ },
11462
+ args: addWorktreeArgs
10273
11463
  }),
10274
11464
  surfaceContract({
10275
11465
  name: "activate_worktree",
@@ -10381,7 +11571,8 @@ var worktreesContracts = [
10381
11571
  functionName: "updateMetadata",
10382
11572
  kind: "mutation",
10383
11573
  inputProjection: worktreeMetadataInput
10384
- }
11574
+ },
11575
+ args: worktreeMetadataArgs
10385
11576
  }),
10386
11577
  surfaceContract({
10387
11578
  name: "merge",
@@ -10399,9 +11590,7 @@ var worktreesContracts = [
10399
11590
  inputProjection: (input, context) => withUserId(
10400
11591
  {
10401
11592
  ...worktreeIdInput(input),
10402
- keyFindings: input.keyFindings ?? [
10403
- input.summary ?? "Merged worktree"
10404
- ],
11593
+ keyFindings: mergeKeyFindingsInput(input),
10405
11594
  decisionsReached: input.decisionsReached ?? [],
10406
11595
  nextSteps: input.nextSteps ?? []
10407
11596
  },
@@ -10423,7 +11612,8 @@ var worktreesContracts = [
10423
11612
  functionName: "updateMetadata",
10424
11613
  kind: "mutation",
10425
11614
  inputProjection: worktreeMetadataInput
10426
- }
11615
+ },
11616
+ args: pushArgs
10427
11617
  }),
10428
11618
  surfaceContract({
10429
11619
  name: "open_pull_request",
@@ -10439,7 +11629,8 @@ var worktreesContracts = [
10439
11629
  functionName: "updateMetadata",
10440
11630
  kind: "mutation",
10441
11631
  inputProjection: worktreeMetadataInput
10442
- }
11632
+ },
11633
+ args: openPullRequestArgs
10443
11634
  })
10444
11635
  ];
10445
11636
 
@@ -10543,6 +11734,15 @@ var createEdgeArgs = z.object({
10543
11734
  topicId: z.string().optional(),
10544
11735
  trustedBypassAccessCheck: z.boolean().optional()
10545
11736
  });
11737
+ var queryLineageArgs = z.object({
11738
+ nodeId: z.string().describe("Starting node to trace from."),
11739
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
11740
+ depth: z.number().optional().describe("Traversal depth alias."),
11741
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11742
+ mode: z.string().optional().describe("Traversal mode."),
11743
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11744
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11745
+ });
10546
11746
  function graphRefNodeId(ref) {
10547
11747
  if (ref.kind === "epistemic_node") {
10548
11748
  return ref.nodeId;
@@ -10613,11 +11813,84 @@ var edgesContracts = [
10613
11813
  minLayer: input.minLayer,
10614
11814
  maxLayer: input.maxLayer
10615
11815
  })
10616
- }
11816
+ },
11817
+ args: queryLineageArgs
10617
11818
  })
10618
11819
  ];
10619
-
10620
- // ../contracts/src/function-registry/graph.ts
11820
+ var graphIntelligenceQueryModes = [
11821
+ "core",
11822
+ "bias",
11823
+ "stress",
11824
+ "operational",
11825
+ "alpha",
11826
+ "semantic",
11827
+ "evidence"
11828
+ ];
11829
+ var traversalLayerSchema = z.enum([
11830
+ "L4",
11831
+ "L3",
11832
+ "L2",
11833
+ "L1",
11834
+ "ontological",
11835
+ "organizational"
11836
+ ]);
11837
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
11838
+ var lineageAliasArgs = z.object({
11839
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
11840
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
11841
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
11842
+ depth: z.number().optional().describe("Traversal depth alias."),
11843
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11844
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
11845
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
11846
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
11847
+ });
11848
+ var lineageArgs = lineageAliasArgs.extend({
11849
+ nodeId: z.string().describe("Starting node to traverse from.")
11850
+ });
11851
+ var traverseGraphArgs = lineageAliasArgs.extend({
11852
+ startNode: z.string().describe("Node to start traversal from."),
11853
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
11854
+ });
11855
+ var graphNeighborhoodArgs = z.object({
11856
+ globalId: z.string().optional().describe("Single root global ID."),
11857
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
11858
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11859
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
11860
+ limit: z.number().optional().describe("Maximum edges to return.")
11861
+ });
11862
+ var graphIntelligenceModeSchema = z.enum([
11863
+ graphIntelligenceQueryModes[0],
11864
+ ...graphIntelligenceQueryModes.slice(1)
11865
+ ]);
11866
+ var graphIntelligenceCatalogArgs = z.object({
11867
+ categoryId: z.string().optional().describe("Optional query category filter."),
11868
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
11869
+ });
11870
+ var graphIntelligenceRunArgs = z.object({
11871
+ topicId: z.string().describe("Topic to analyze."),
11872
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
11873
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
11874
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
11875
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
11876
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
11877
+ });
11878
+ var flagContradictionArgs = z.object({
11879
+ beliefA: z.string().describe("First belief in tension."),
11880
+ beliefB: z.string().describe("Second belief in tension."),
11881
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
11882
+ description: z.string().optional().describe("Human-readable contradiction."),
11883
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
11884
+ defeatType: z.string().optional().describe("Defeat type annotation."),
11885
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
11886
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
11887
+ });
11888
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
11889
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
11890
+ topicId: z.string().optional().describe("Topic scope override."),
11891
+ minScore: z.number().optional().describe("Minimum match score."),
11892
+ limit: z.number().optional().describe("Maximum candidates to return.")
11893
+ });
10621
11894
  var contradictionSeverity = (value) => {
10622
11895
  switch (value) {
10623
11896
  case "critical":
@@ -10672,7 +11945,8 @@ var graphContracts = [
10672
11945
  functionName: "getLineage",
10673
11946
  kind: "query",
10674
11947
  inputProjection: lineageInput
10675
- }
11948
+ },
11949
+ args: traverseGraphArgs
10676
11950
  }),
10677
11951
  surfaceContract({
10678
11952
  name: "get_graph_neighborhood",
@@ -10688,7 +11962,8 @@ var graphContracts = [
10688
11962
  functionName: "getByTopic",
10689
11963
  kind: "query",
10690
11964
  inputProjection: topicEdgesInput
10691
- }
11965
+ },
11966
+ args: graphNeighborhoodArgs
10692
11967
  }),
10693
11968
  surfaceContract({
10694
11969
  name: "get_graph_structure_analysis",
@@ -10705,6 +11980,38 @@ var graphContracts = [
10705
11980
  kind: "query"
10706
11981
  }
10707
11982
  }),
11983
+ surfaceContract({
11984
+ name: "list_graph_intelligence_queries",
11985
+ kind: "query",
11986
+ domain: "graph",
11987
+ surfaceClass: "platform_public",
11988
+ path: "/graph-intelligence/queries",
11989
+ sdkNamespace: "graphAnalysis",
11990
+ sdkMethod: "listGraphIntelligenceQueries",
11991
+ summary: "List Graph Intelligence query catalog entries.",
11992
+ convex: {
11993
+ module: "contextCompiler",
11994
+ functionName: "listGraphIntelligenceQueries",
11995
+ kind: "query"
11996
+ },
11997
+ args: graphIntelligenceCatalogArgs
11998
+ }),
11999
+ surfaceContract({
12000
+ name: "run_graph_intelligence_query",
12001
+ kind: "query",
12002
+ domain: "graph",
12003
+ surfaceClass: "platform_public",
12004
+ path: "/graph-intelligence/run",
12005
+ sdkNamespace: "graphAnalysis",
12006
+ sdkMethod: "runGraphIntelligenceQuery",
12007
+ summary: "Run a Graph Intelligence query against a topic graph.",
12008
+ convex: {
12009
+ module: "contextCompiler",
12010
+ functionName: "runGraphIntelligenceQuery",
12011
+ kind: "query"
12012
+ },
12013
+ args: graphIntelligenceRunArgs
12014
+ }),
10708
12015
  surfaceContract({
10709
12016
  name: "find_contradictions",
10710
12017
  kind: "query",
@@ -10737,7 +12044,8 @@ var graphContracts = [
10737
12044
  functionName: "create",
10738
12045
  kind: "mutation",
10739
12046
  inputProjection: flagContradictionInput
10740
- }
12047
+ },
12048
+ args: flagContradictionArgs
10741
12049
  }),
10742
12050
  surfaceContract({
10743
12051
  name: "detect_confirmation_bias",
@@ -10828,7 +12136,8 @@ var graphContracts = [
10828
12136
  functionName: "getLineage",
10829
12137
  kind: "query",
10830
12138
  inputProjection: lineageInput
10831
- }
12139
+ },
12140
+ args: discoverEntityConnectionsArgs
10832
12141
  }),
10833
12142
  surfaceContract({
10834
12143
  name: "trigger_belief_review",
@@ -10859,7 +12168,8 @@ var graphContracts = [
10859
12168
  functionName: "getLineage",
10860
12169
  kind: "query",
10861
12170
  inputProjection: lineageInput
10862
- }
12171
+ },
12172
+ args: lineageArgs
10863
12173
  })
10864
12174
  ];
10865
12175
 
@@ -10911,8 +12221,16 @@ var contractsContracts = [
10911
12221
  }
10912
12222
  })
10913
12223
  ];
10914
-
10915
- // ../contracts/src/function-registry/judgments.ts
12224
+ var auditTrailArgs = z.object({
12225
+ nodeId: z.string().describe("The node to audit."),
12226
+ id: z.string().optional().describe("Node ID alias."),
12227
+ limit: z.number().optional().describe("Maximum entries to return."),
12228
+ depth: z.number().optional().describe("Traversal depth alias."),
12229
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
12230
+ mode: z.string().optional().describe("Traversal mode."),
12231
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12232
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12233
+ });
10916
12234
  var judgmentsContracts = [
10917
12235
  surfaceContract({
10918
12236
  name: "record_judgment",
@@ -10967,7 +12285,8 @@ var judgmentsContracts = [
10967
12285
  minLayer: input.minLayer,
10968
12286
  maxLayer: input.maxLayer
10969
12287
  })
10970
- }
12288
+ },
12289
+ args: auditTrailArgs
10971
12290
  })
10972
12291
  ];
10973
12292
 
@@ -11135,8 +12454,13 @@ var coordinationContracts = [
11135
12454
  }
11136
12455
  })
11137
12456
  ];
11138
-
11139
- // ../contracts/src/function-registry/pipeline.ts
12457
+ var pipelineSnapshotArgs = z.object({
12458
+ topicId: z.string().describe("Topic scope ID."),
12459
+ status: z.string().optional().describe("Worktree status filter."),
12460
+ lane: z.string().optional().describe("Campaign lane filter."),
12461
+ campaign: z.number().optional().describe("Campaign number filter."),
12462
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
12463
+ });
11140
12464
  var pipelineContracts = [
11141
12465
  surfaceContract({
11142
12466
  name: "pipeline_snapshot",
@@ -11157,7 +12481,8 @@ var pipelineContracts = [
11157
12481
  campaign: input.campaign,
11158
12482
  limit: input.limit
11159
12483
  })
11160
- }
12484
+ },
12485
+ args: pipelineSnapshotArgs
11161
12486
  }),
11162
12487
  surfaceContract({
11163
12488
  name: "seed_belief_lattice",
@@ -11209,7 +12534,31 @@ var recordScopeLearningArgs = z.object({
11209
12534
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11210
12535
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11211
12536
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11212
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
12537
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
12538
+ text: z.string().optional().describe("Canonical learning text alias."),
12539
+ content: z.string().optional().describe("Canonical learning content alias."),
12540
+ kind: z.string().optional().describe("Evidence kind to store."),
12541
+ sourceType: z.string().optional().describe("Evidence source type."),
12542
+ externalSourceType: z.string().optional().describe("External source type alias."),
12543
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
12544
+ });
12545
+ var codeContextArgs = z.object({
12546
+ topicId: z.string().optional().describe("Topic scope."),
12547
+ filePath: z.string().optional().describe("File path anchor."),
12548
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
12549
+ limit: z.number().optional().describe("Maximum records to return."),
12550
+ status: z.string().optional().describe("Evidence status filter.")
12551
+ });
12552
+ var recordAttemptArgs = z.object({
12553
+ topicId: z.string().optional().describe("Topic scope."),
12554
+ description: z.string().describe("Attempt description."),
12555
+ errorMessage: z.string().optional().describe("Failure or error message."),
12556
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
12557
+ filePath: z.string().optional().describe("Single file path alias."),
12558
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
12559
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
12560
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
12561
+ title: z.string().optional().describe("Attempt evidence title.")
11213
12562
  });
11214
12563
  var learningInput = (input, context) => {
11215
12564
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11326,7 +12675,8 @@ var codingContracts = [
11326
12675
  status: input.status,
11327
12676
  userId: input.userId
11328
12677
  })
11329
- }
12678
+ },
12679
+ args: codeContextArgs
11330
12680
  }),
11331
12681
  surfaceContract({
11332
12682
  name: "get_change_history",
@@ -11363,7 +12713,8 @@ var codingContracts = [
11363
12713
  functionName: "create",
11364
12714
  kind: "mutation",
11365
12715
  inputProjection: attemptInput
11366
- }
12716
+ },
12717
+ args: recordAttemptArgs
11367
12718
  }),
11368
12719
  surfaceContract({
11369
12720
  name: "get_failure_log",
@@ -11438,6 +12789,604 @@ new Map(
11438
12789
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11439
12790
  );
11440
12791
 
12792
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
12793
+ function isCopyableSeedRequirement(entry) {
12794
+ 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;
12795
+ }
12796
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
12797
+ {
12798
+ component: "kernel",
12799
+ table: "agentMessages",
12800
+ prepopulation: "runtime_data",
12801
+ copyMode: "none",
12802
+ description: "Agent coordination messages are session data, not template data."
12803
+ },
12804
+ {
12805
+ component: "kernel",
12806
+ table: "agentSessions",
12807
+ prepopulation: "runtime_data",
12808
+ copyMode: "none",
12809
+ description: "Agent coordination sessions are created by active clients."
12810
+ },
12811
+ {
12812
+ component: "kernel",
12813
+ table: "autofixJobs",
12814
+ prepopulation: "runtime_queue",
12815
+ copyMode: "none",
12816
+ description: "Autofix work items are runtime queue rows."
12817
+ },
12818
+ {
12819
+ component: "kernel",
12820
+ table: "backgroundJobRuns",
12821
+ prepopulation: "runtime_log",
12822
+ copyMode: "none",
12823
+ description: "Background job executions are runtime logs."
12824
+ },
12825
+ {
12826
+ component: "kernel",
12827
+ table: "backgroundJobSettings",
12828
+ prepopulation: "required_template",
12829
+ copyMode: "template_global",
12830
+ scope: "global",
12831
+ uniqueKey: ["jobKey"],
12832
+ description: "Default job enablement settings must come from the K template."
12833
+ },
12834
+ {
12835
+ component: "kernel",
12836
+ table: "beliefConfidence",
12837
+ prepopulation: "runtime_data",
12838
+ copyMode: "none",
12839
+ description: "Belief confidence rows are created with tenant graph facts."
12840
+ },
12841
+ {
12842
+ component: "kernel",
12843
+ table: "beliefEvidenceLinks",
12844
+ prepopulation: "runtime_data",
12845
+ copyMode: "none",
12846
+ description: "Belief-to-evidence links are tenant graph data."
12847
+ },
12848
+ {
12849
+ component: "kernel",
12850
+ table: "beliefHistory",
12851
+ prepopulation: "runtime_data",
12852
+ copyMode: "none",
12853
+ description: "Belief history is append-only tenant graph data."
12854
+ },
12855
+ {
12856
+ component: "kernel",
12857
+ table: "beliefScenarios",
12858
+ prepopulation: "runtime_data",
12859
+ copyMode: "none",
12860
+ description: "Scenario rows are tenant-authored reasoning data."
12861
+ },
12862
+ {
12863
+ component: "kernel",
12864
+ table: "beliefVotes",
12865
+ prepopulation: "runtime_data",
12866
+ copyMode: "none",
12867
+ description: "Decision belief votes are tenant-authored data."
12868
+ },
12869
+ {
12870
+ component: "kernel",
12871
+ table: "calibrationScores",
12872
+ prepopulation: "runtime_derived",
12873
+ copyMode: "none",
12874
+ description: "Calibration scores are computed from tenant outcomes."
12875
+ },
12876
+ {
12877
+ component: "kernel",
12878
+ table: "contractEvaluations",
12879
+ prepopulation: "runtime_log",
12880
+ copyMode: "none",
12881
+ description: "Contract evaluation rows are runtime computation logs."
12882
+ },
12883
+ {
12884
+ component: "kernel",
12885
+ table: "contradictions",
12886
+ prepopulation: "runtime_data",
12887
+ copyMode: "none",
12888
+ description: "Contradictions are tenant graph facts."
12889
+ },
12890
+ {
12891
+ component: "kernel",
12892
+ table: "crossProjectConnections",
12893
+ prepopulation: "runtime_data",
12894
+ copyMode: "none",
12895
+ description: "Cross-topic connections are tenant graph facts."
12896
+ },
12897
+ {
12898
+ component: "kernel",
12899
+ table: "decisionComputedSummaries",
12900
+ prepopulation: "runtime_derived",
12901
+ copyMode: "none",
12902
+ description: "Decision summaries are derived tenant outputs."
12903
+ },
12904
+ {
12905
+ component: "kernel",
12906
+ table: "decisionEvents",
12907
+ prepopulation: "runtime_data",
12908
+ copyMode: "none",
12909
+ description: "Decision events are lifecycle data."
12910
+ },
12911
+ {
12912
+ component: "kernel",
12913
+ table: "decisionParticipants",
12914
+ prepopulation: "runtime_data",
12915
+ copyMode: "none",
12916
+ description: "Decision participants are tenant-selected actors."
12917
+ },
12918
+ {
12919
+ component: "kernel",
12920
+ table: "decisionRiskLedger",
12921
+ prepopulation: "runtime_data",
12922
+ copyMode: "none",
12923
+ description: "Decision risk rows are tenant decision data."
12924
+ },
12925
+ {
12926
+ component: "kernel",
12927
+ table: "decisionSnapshots",
12928
+ prepopulation: "runtime_derived",
12929
+ copyMode: "none",
12930
+ description: "Decision snapshots are derived from tenant state."
12931
+ },
12932
+ {
12933
+ component: "kernel",
12934
+ table: "deliberationContributions",
12935
+ prepopulation: "runtime_data",
12936
+ copyMode: "none",
12937
+ description: "Deliberation contributions are tenant-authored data."
12938
+ },
12939
+ {
12940
+ component: "kernel",
12941
+ table: "deliberationSessions",
12942
+ prepopulation: "runtime_data",
12943
+ copyMode: "none",
12944
+ description: "Deliberation sessions are created by tenant workflows."
12945
+ },
12946
+ {
12947
+ component: "kernel",
12948
+ table: "epistemicAudit",
12949
+ prepopulation: "runtime_log",
12950
+ copyMode: "none",
12951
+ description: "Epistemic audit rows are append-only runtime audit data."
12952
+ },
12953
+ {
12954
+ component: "kernel",
12955
+ table: "epistemicContracts",
12956
+ prepopulation: "runtime_data",
12957
+ copyMode: "none",
12958
+ description: "Epistemic contracts are tenant-authored governance data."
12959
+ },
12960
+ {
12961
+ component: "kernel",
12962
+ table: "epistemicEdges",
12963
+ prepopulation: "runtime_data",
12964
+ copyMode: "none",
12965
+ description: "Edges are tenant reasoning graph data."
12966
+ },
12967
+ {
12968
+ component: "kernel",
12969
+ table: "epistemicNodeEmbeddings",
12970
+ prepopulation: "runtime_derived",
12971
+ copyMode: "none",
12972
+ description: "Embeddings are derived from tenant graph nodes."
12973
+ },
12974
+ {
12975
+ component: "kernel",
12976
+ table: "epistemicNodes",
12977
+ prepopulation: "runtime_data",
12978
+ copyMode: "none",
12979
+ description: "Nodes are tenant reasoning graph data."
12980
+ },
12981
+ {
12982
+ component: "kernel",
12983
+ table: "graphAnalysisCache",
12984
+ prepopulation: "runtime_derived",
12985
+ copyMode: "none",
12986
+ description: "Graph analysis cache rows are derived from tenant graph state."
12987
+ },
12988
+ {
12989
+ component: "kernel",
12990
+ table: "graphAnalysisResults",
12991
+ prepopulation: "runtime_derived",
12992
+ copyMode: "none",
12993
+ description: "Graph analysis result rows are derived tenant outputs."
12994
+ },
12995
+ {
12996
+ component: "kernel",
12997
+ table: "graphSuggestions",
12998
+ prepopulation: "runtime_derived",
12999
+ copyMode: "none",
13000
+ description: "Graph suggestions are derived recommendations."
13001
+ },
13002
+ {
13003
+ component: "kernel",
13004
+ table: "harnessReplays",
13005
+ prepopulation: "runtime_log",
13006
+ copyMode: "none",
13007
+ description: "Harness replay rows are runtime verification logs."
13008
+ },
13009
+ {
13010
+ component: "kernel",
13011
+ table: "harnessRuns",
13012
+ prepopulation: "runtime_log",
13013
+ copyMode: "none",
13014
+ description: "Harness run rows are runtime verification logs."
13015
+ },
13016
+ {
13017
+ component: "kernel",
13018
+ table: "idempotencyTokens",
13019
+ prepopulation: "runtime_log",
13020
+ copyMode: "none",
13021
+ description: "Idempotency tokens are request-scoped runtime guards."
13022
+ },
13023
+ {
13024
+ component: "kernel",
13025
+ table: "lenses",
13026
+ prepopulation: "optional_template",
13027
+ copyMode: "none",
13028
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
13029
+ },
13030
+ {
13031
+ component: "kernel",
13032
+ table: "lensTopicBindings",
13033
+ prepopulation: "runtime_data",
13034
+ copyMode: "none",
13035
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
13036
+ },
13037
+ {
13038
+ component: "kernel",
13039
+ table: "neo4jSyncQueue",
13040
+ prepopulation: "runtime_queue",
13041
+ copyMode: "none",
13042
+ description: "Neo4j sync queue rows are runtime work items."
13043
+ },
13044
+ {
13045
+ component: "kernel",
13046
+ table: "ontologyDefinitions",
13047
+ prepopulation: "required_template",
13048
+ copyMode: "template_global",
13049
+ scope: "global",
13050
+ uniqueKey: ["ontologyKey"],
13051
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
13052
+ },
13053
+ {
13054
+ component: "kernel",
13055
+ table: "ontologyVersions",
13056
+ prepopulation: "required_template",
13057
+ copyMode: "template_reference_remap",
13058
+ scope: "global",
13059
+ uniqueKey: ["ontologyKey", "version"],
13060
+ dependsOn: ["ontologyDefinitions"],
13061
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
13062
+ },
13063
+ {
13064
+ component: "kernel",
13065
+ table: "platformAgentRunPolicyDecisions",
13066
+ prepopulation: "runtime_log",
13067
+ copyMode: "none",
13068
+ description: "Agent-run policy decisions are audit logs."
13069
+ },
13070
+ {
13071
+ component: "kernel",
13072
+ table: "platformAgentRunPromptResolutions",
13073
+ prepopulation: "runtime_log",
13074
+ copyMode: "none",
13075
+ description: "Agent-run prompt resolution rows are runtime logs."
13076
+ },
13077
+ {
13078
+ component: "kernel",
13079
+ table: "platformAgentRuns",
13080
+ prepopulation: "runtime_log",
13081
+ copyMode: "none",
13082
+ description: "Agent runs are runtime execution records."
13083
+ },
13084
+ {
13085
+ component: "kernel",
13086
+ table: "platformAgentRunToolCalls",
13087
+ prepopulation: "runtime_log",
13088
+ copyMode: "none",
13089
+ description: "Agent-run tool calls are runtime execution records."
13090
+ },
13091
+ {
13092
+ component: "kernel",
13093
+ table: "platformHarnessShadowAudit",
13094
+ prepopulation: "runtime_log",
13095
+ copyMode: "none",
13096
+ description: "Harness shadow audit rows are runtime audit records."
13097
+ },
13098
+ {
13099
+ component: "kernel",
13100
+ table: "publicationRules",
13101
+ prepopulation: "required_template",
13102
+ copyMode: "template_tenant_rewrite",
13103
+ scope: "tenant",
13104
+ uniqueKey: ["tenantId", "workspaceId", "name"],
13105
+ description: "Default publication policy rules are rewritten into each tenant."
13106
+ },
13107
+ {
13108
+ component: "kernel",
13109
+ table: "questionEvidenceLinks",
13110
+ prepopulation: "runtime_data",
13111
+ copyMode: "none",
13112
+ description: "Question-to-evidence links are tenant graph data."
13113
+ },
13114
+ {
13115
+ component: "kernel",
13116
+ table: "researchJobs",
13117
+ prepopulation: "runtime_queue",
13118
+ copyMode: "none",
13119
+ description: "Research job rows are runtime queue items."
13120
+ },
13121
+ {
13122
+ component: "kernel",
13123
+ table: "schemaEnumConfig",
13124
+ prepopulation: "required_template",
13125
+ copyMode: "template_global",
13126
+ scope: "global",
13127
+ uniqueKey: ["category", "value"],
13128
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
13129
+ },
13130
+ {
13131
+ component: "kernel",
13132
+ table: "stakeholderGroups",
13133
+ prepopulation: "runtime_data",
13134
+ copyMode: "none",
13135
+ description: "Stakeholder groups are tenant decision data."
13136
+ },
13137
+ {
13138
+ component: "kernel",
13139
+ table: "systemLogs",
13140
+ prepopulation: "runtime_log",
13141
+ copyMode: "none",
13142
+ description: "System logs are runtime telemetry."
13143
+ },
13144
+ {
13145
+ component: "kernel",
13146
+ table: "tasks",
13147
+ prepopulation: "runtime_data",
13148
+ copyMode: "none",
13149
+ description: "Tasks are tenant-authored work items."
13150
+ },
13151
+ {
13152
+ component: "kernel",
13153
+ table: "topics",
13154
+ prepopulation: "runtime_bootstrap",
13155
+ copyMode: "none",
13156
+ description: "Default topics are created by tenant provisioning, not copied from templates."
13157
+ },
13158
+ {
13159
+ component: "kernel",
13160
+ table: "workflowDefinitions",
13161
+ prepopulation: "optional_template",
13162
+ copyMode: "none",
13163
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
13164
+ },
13165
+ {
13166
+ component: "kernel",
13167
+ table: "workflowPullRequests",
13168
+ prepopulation: "runtime_data",
13169
+ copyMode: "none",
13170
+ description: "Workflow pull requests are tenant workflow data."
13171
+ },
13172
+ {
13173
+ component: "kernel",
13174
+ table: "workflowStages",
13175
+ prepopulation: "optional_template",
13176
+ copyMode: "none",
13177
+ dependsOn: ["workflowDefinitions"],
13178
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
13179
+ },
13180
+ {
13181
+ component: "kernel",
13182
+ table: "worktreeBeliefCluster",
13183
+ prepopulation: "runtime_data",
13184
+ copyMode: "none",
13185
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
13186
+ },
13187
+ {
13188
+ component: "kernel",
13189
+ table: "worktrees",
13190
+ prepopulation: "runtime_data",
13191
+ copyMode: "none",
13192
+ description: "Worktrees are tenant/runtime planning data."
13193
+ },
13194
+ {
13195
+ component: "identity",
13196
+ table: "agents",
13197
+ prepopulation: "runtime_bootstrap",
13198
+ copyMode: "none",
13199
+ description: "Service agents are provisioned per tenant or service, not copied."
13200
+ },
13201
+ {
13202
+ component: "identity",
13203
+ table: "mcpWritePolicy",
13204
+ prepopulation: "required_template",
13205
+ copyMode: "template_global",
13206
+ scope: "global",
13207
+ uniqueKey: ["topicId", "role", "toolCategory"],
13208
+ description: "Global write policy defaults govern service and interactive MCP writes."
13209
+ },
13210
+ {
13211
+ component: "identity",
13212
+ table: "modelCallLogs",
13213
+ prepopulation: "runtime_log",
13214
+ copyMode: "none",
13215
+ description: "Model call logs are runtime telemetry."
13216
+ },
13217
+ {
13218
+ component: "identity",
13219
+ table: "modelFunctionSlots",
13220
+ prepopulation: "required_template",
13221
+ copyMode: "template_global",
13222
+ scope: "global",
13223
+ uniqueKey: ["slot"],
13224
+ description: "Function-to-model slots are required by model runtime resolution."
13225
+ },
13226
+ {
13227
+ component: "identity",
13228
+ table: "modelRegistry",
13229
+ prepopulation: "required_template",
13230
+ copyMode: "template_global",
13231
+ scope: "global",
13232
+ uniqueKey: ["key"],
13233
+ description: "Model catalog defaults are required by model runtime clients."
13234
+ },
13235
+ {
13236
+ component: "identity",
13237
+ table: "modelSlotConfigs",
13238
+ prepopulation: "required_template",
13239
+ copyMode: "template_global",
13240
+ scope: "global",
13241
+ uniqueKey: ["slot"],
13242
+ description: "Slot-level defaults are required before tenant overrides exist."
13243
+ },
13244
+ {
13245
+ component: "identity",
13246
+ table: "platformAudienceGrants",
13247
+ prepopulation: "runtime_data",
13248
+ copyMode: "none",
13249
+ description: "Audience grants are principal/group-specific access rows."
13250
+ },
13251
+ {
13252
+ component: "identity",
13253
+ table: "platformAudiences",
13254
+ prepopulation: "required_template",
13255
+ copyMode: "template_tenant_rewrite",
13256
+ scope: "tenant",
13257
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
13258
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
13259
+ },
13260
+ {
13261
+ component: "identity",
13262
+ table: "platformPolicyDecisionLogs",
13263
+ prepopulation: "runtime_log",
13264
+ copyMode: "none",
13265
+ description: "Policy decisions are runtime audit logs."
13266
+ },
13267
+ {
13268
+ component: "identity",
13269
+ table: "projectGrants",
13270
+ prepopulation: "runtime_data",
13271
+ copyMode: "none",
13272
+ description: "Project/topic grants are principal or group-specific access rows."
13273
+ },
13274
+ {
13275
+ component: "identity",
13276
+ table: "reasoningPermissions",
13277
+ prepopulation: "runtime_data",
13278
+ copyMode: "none",
13279
+ description: "Reasoning permissions are principal-specific policy rows."
13280
+ },
13281
+ {
13282
+ component: "identity",
13283
+ table: "tenantApiKeys",
13284
+ prepopulation: "runtime_secret",
13285
+ copyMode: "none",
13286
+ description: "API keys are tenant credentials and must never be copied."
13287
+ },
13288
+ {
13289
+ component: "identity",
13290
+ table: "tenantConfig",
13291
+ prepopulation: "required_template",
13292
+ copyMode: "template_tenant_rewrite",
13293
+ scope: "tenant",
13294
+ uniqueKey: ["tenantId"],
13295
+ description: "Tenant-local config defaults are rewritten during bootstrap."
13296
+ },
13297
+ {
13298
+ component: "identity",
13299
+ table: "tenantIntegrations",
13300
+ prepopulation: "required_template",
13301
+ copyMode: "template_tenant_rewrite",
13302
+ scope: "tenant",
13303
+ uniqueKey: ["tenantId", "integrationKey"],
13304
+ description: "Non-secret integration descriptors are rewritten into each tenant."
13305
+ },
13306
+ {
13307
+ component: "identity",
13308
+ table: "tenantModelSlotBindings",
13309
+ prepopulation: "runtime_secret",
13310
+ copyMode: "none",
13311
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
13312
+ },
13313
+ {
13314
+ component: "identity",
13315
+ table: "tenantPolicies",
13316
+ prepopulation: "required_template",
13317
+ copyMode: "template_tenant_rewrite",
13318
+ scope: "tenant",
13319
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
13320
+ description: "Default tenant policy roles are rewritten during bootstrap."
13321
+ },
13322
+ {
13323
+ component: "identity",
13324
+ table: "tenantProviderSecrets",
13325
+ prepopulation: "runtime_secret",
13326
+ copyMode: "none",
13327
+ description: "Provider secrets are credentials and must never be copied."
13328
+ },
13329
+ {
13330
+ component: "identity",
13331
+ table: "tenantProxyGatewayUsage",
13332
+ prepopulation: "runtime_log",
13333
+ copyMode: "none",
13334
+ description: "Proxy gateway usage rows are runtime telemetry."
13335
+ },
13336
+ {
13337
+ component: "identity",
13338
+ table: "tenantProxyTokenMints",
13339
+ prepopulation: "runtime_secret",
13340
+ copyMode: "none",
13341
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
13342
+ },
13343
+ {
13344
+ component: "identity",
13345
+ table: "tenantSandboxAuditEvents",
13346
+ prepopulation: "runtime_log",
13347
+ copyMode: "none",
13348
+ description: "Sandbox audit rows are runtime security logs."
13349
+ },
13350
+ {
13351
+ component: "identity",
13352
+ table: "tenantSecrets",
13353
+ prepopulation: "runtime_secret",
13354
+ copyMode: "none",
13355
+ description: "Tenant secrets are credentials and must never be copied."
13356
+ },
13357
+ {
13358
+ component: "identity",
13359
+ table: "toolAcls",
13360
+ prepopulation: "required_template",
13361
+ copyMode: "template_global",
13362
+ scope: "global",
13363
+ uniqueKey: ["role", "toolName"],
13364
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
13365
+ },
13366
+ {
13367
+ component: "identity",
13368
+ table: "toolRegistry",
13369
+ prepopulation: "required_template",
13370
+ copyMode: "template_global",
13371
+ scope: "global",
13372
+ uniqueKey: ["toolName"],
13373
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
13374
+ },
13375
+ {
13376
+ component: "identity",
13377
+ table: "users",
13378
+ prepopulation: "runtime_bootstrap",
13379
+ copyMode: "none",
13380
+ description: "Users are created from Clerk/MC principal resolution, not copied."
13381
+ }
13382
+ ];
13383
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
13384
+ isCopyableSeedRequirement
13385
+ );
13386
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
13387
+ (entry) => !isCopyableSeedRequirement(entry)
13388
+ ).map((entry) => entry.table);
13389
+
11441
13390
  // src/webhooks.ts
11442
13391
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
11443
13392
  function normalizeUrl(url) {