@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/index.js CHANGED
@@ -26,6 +26,487 @@ function matchesAnyEventPattern(eventType, patterns) {
26
26
  return patterns.some((pattern) => matchesEventPattern(eventType, pattern));
27
27
  }
28
28
 
29
+ // ../contracts/src/graph-intelligence.contract.ts
30
+ var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
31
+ core: [
32
+ "get_graph_structure_analysis",
33
+ "get_topic_coverage",
34
+ "get_graph_gaps",
35
+ "list_beliefs",
36
+ "list_questions",
37
+ "search_evidence"
38
+ ],
39
+ bias: [
40
+ "get_graph_structure_analysis",
41
+ "detect_confirmation_bias",
42
+ "find_contradictions",
43
+ "search_evidence",
44
+ "list_beliefs"
45
+ ],
46
+ stress: [
47
+ "get_graph_structure_analysis",
48
+ "get_graph_gaps",
49
+ "find_contradictions",
50
+ "get_falsification_questions",
51
+ "list_beliefs",
52
+ "list_questions"
53
+ ],
54
+ operational: [
55
+ "get_topic_coverage",
56
+ "get_graph_gaps",
57
+ "list_beliefs",
58
+ "list_questions",
59
+ "search_evidence"
60
+ ],
61
+ alpha: [
62
+ "get_graph_structure_analysis",
63
+ "detect_confirmation_bias",
64
+ "find_contradictions",
65
+ "search_beliefs",
66
+ "search_evidence"
67
+ ],
68
+ semantic: [
69
+ "get_graph_structure_analysis",
70
+ "search_beliefs",
71
+ "search_evidence",
72
+ "traverse_graph",
73
+ "query_lineage",
74
+ "get_graph_neighborhood"
75
+ ],
76
+ evidence: [
77
+ "get_graph_structure_analysis",
78
+ "get_topic_coverage",
79
+ "search_evidence",
80
+ "get_falsification_questions",
81
+ "find_contradictions"
82
+ ]
83
+ };
84
+ var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
85
+ var GRAPH_INTELLIGENCE_QUERIES = [
86
+ {
87
+ id: "confirmation-bias",
88
+ categoryId: "problems",
89
+ mode: "bias",
90
+ name: "Find Confirmation Bias",
91
+ description: "Find beliefs supported mainly by confirming evidence.",
92
+ prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
93
+ highlightStrategy: "bias-risk",
94
+ riskLevel: "high"
95
+ },
96
+ {
97
+ id: "contradiction-map",
98
+ categoryId: "problems",
99
+ mode: "stress",
100
+ name: "Map Contradictions",
101
+ description: "Surface direct and indirect contradiction clusters.",
102
+ prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
103
+ highlightStrategy: "contradictions",
104
+ riskLevel: "high"
105
+ },
106
+ {
107
+ id: "weak-evidence",
108
+ categoryId: "problems",
109
+ mode: "stress",
110
+ name: "Weak Evidence Chains",
111
+ description: "Find important claims with thin or indirect evidence.",
112
+ prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
113
+ highlightStrategy: "weak-support",
114
+ riskLevel: "medium"
115
+ },
116
+ {
117
+ id: "single-source",
118
+ categoryId: "problems",
119
+ mode: "bias",
120
+ name: "Single-Source Risk",
121
+ description: "Find claims overly dependent on one source or source type.",
122
+ prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
123
+ highlightStrategy: "source-concentration",
124
+ riskLevel: "medium"
125
+ },
126
+ {
127
+ id: "untested-assumptions",
128
+ categoryId: "problems",
129
+ mode: "stress",
130
+ name: "Untested Assumptions",
131
+ description: "Find load-bearing assumptions without falsification paths.",
132
+ prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
133
+ highlightStrategy: "untested",
134
+ riskLevel: "high"
135
+ },
136
+ {
137
+ id: "load-bearing-beliefs",
138
+ categoryId: "problems",
139
+ mode: "stress",
140
+ name: "Load-Bearing Beliefs",
141
+ description: "Find central beliefs whose failure would affect many claims.",
142
+ prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
143
+ highlightStrategy: "load-bearing",
144
+ riskLevel: "high"
145
+ },
146
+ {
147
+ id: "cascade-analysis",
148
+ categoryId: "problems",
149
+ mode: "stress",
150
+ name: "Cascade Analysis",
151
+ description: "Trace what changes if a belief is weakened or invalidated.",
152
+ prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
153
+ highlightStrategy: "cascade",
154
+ riskLevel: "high"
155
+ },
156
+ {
157
+ id: "unanswered-questions",
158
+ categoryId: "gaps",
159
+ mode: "operational",
160
+ name: "Unanswered Questions",
161
+ description: "Find important open questions that block confidence.",
162
+ prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
163
+ highlightStrategy: "open-questions"
164
+ },
165
+ {
166
+ id: "thin-themes",
167
+ categoryId: "gaps",
168
+ mode: "operational",
169
+ name: "Thin Themes",
170
+ description: "Find topics with shallow belief or evidence coverage.",
171
+ prompt: "Find themes that look underdeveloped relative to their role in the graph.",
172
+ highlightStrategy: "thin-themes"
173
+ },
174
+ {
175
+ id: "missing-evidence",
176
+ categoryId: "gaps",
177
+ mode: "stress",
178
+ name: "Missing Evidence",
179
+ description: "Find beliefs that need specific missing evidence.",
180
+ prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
181
+ highlightStrategy: "missing-evidence"
182
+ },
183
+ {
184
+ id: "isolated-clusters",
185
+ categoryId: "gaps",
186
+ mode: "operational",
187
+ name: "Isolated Clusters",
188
+ description: "Find clusters not connected to the broader graph.",
189
+ prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
190
+ highlightStrategy: "isolated-clusters"
191
+ },
192
+ {
193
+ id: "source-contribution",
194
+ categoryId: "gaps",
195
+ mode: "evidence",
196
+ name: "Source Contribution",
197
+ description: "Assess how source mix shapes the graph.",
198
+ prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
199
+ highlightStrategy: "source-mix"
200
+ },
201
+ {
202
+ id: "stale-beliefs",
203
+ categoryId: "gaps",
204
+ mode: "operational",
205
+ name: "Stale Beliefs",
206
+ description: "Find beliefs that need review because they are old or stale.",
207
+ prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
208
+ highlightStrategy: "staleness"
209
+ },
210
+ {
211
+ id: "assumption-pyramid",
212
+ categoryId: "reasoning",
213
+ mode: "operational",
214
+ name: "Assumption Pyramid",
215
+ description: "Show which conclusions rest on which assumptions.",
216
+ prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
217
+ highlightStrategy: "assumptions"
218
+ },
219
+ {
220
+ id: "converging-evidence",
221
+ categoryId: "reasoning",
222
+ mode: "evidence",
223
+ name: "Converging Evidence",
224
+ description: "Find claims supported by independent evidence streams.",
225
+ prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
226
+ highlightStrategy: "convergence"
227
+ },
228
+ {
229
+ id: "weakest-links",
230
+ categoryId: "reasoning",
231
+ mode: "stress",
232
+ name: "Weakest Links",
233
+ description: "Find the weakest links in important reasoning chains.",
234
+ prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
235
+ highlightStrategy: "weak-links",
236
+ riskLevel: "medium"
237
+ },
238
+ {
239
+ id: "challenged-beliefs",
240
+ categoryId: "reasoning",
241
+ mode: "stress",
242
+ name: "Challenged Beliefs",
243
+ description: "Find beliefs with active challenges or defeaters.",
244
+ prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
245
+ highlightStrategy: "challenged"
246
+ },
247
+ {
248
+ id: "contrarian-map",
249
+ categoryId: "strategic",
250
+ mode: "alpha",
251
+ name: "Contrarian Map",
252
+ description: "Find non-consensus beliefs and where they are grounded.",
253
+ prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
254
+ highlightStrategy: "contrarian"
255
+ },
256
+ {
257
+ id: "irreversibility-audit",
258
+ categoryId: "strategic",
259
+ mode: "stress",
260
+ name: "Irreversibility Audit",
261
+ description: "Find irreversible bets and assumptions behind them.",
262
+ prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
263
+ highlightStrategy: "irreversible",
264
+ riskLevel: "high"
265
+ },
266
+ {
267
+ id: "pre-mortem",
268
+ categoryId: "strategic",
269
+ mode: "stress",
270
+ name: "Pre-Mortem",
271
+ description: "Explain how the graph could be wrong.",
272
+ prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
273
+ highlightStrategy: "failure-paths",
274
+ riskLevel: "high"
275
+ },
276
+ {
277
+ id: "devils-advocate",
278
+ categoryId: "strategic",
279
+ mode: "stress",
280
+ name: "Devil's Advocate",
281
+ description: "Generate the strongest critique of the graph.",
282
+ prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
283
+ highlightStrategy: "critique"
284
+ },
285
+ {
286
+ id: "falsification-map",
287
+ categoryId: "strategic",
288
+ mode: "stress",
289
+ name: "Falsification Map",
290
+ description: "Find the cheapest tests that would disprove key beliefs.",
291
+ prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
292
+ highlightStrategy: "falsification",
293
+ riskLevel: "high"
294
+ },
295
+ {
296
+ id: "prediction-tracker",
297
+ categoryId: "strategic",
298
+ mode: "evidence",
299
+ name: "Prediction Tracker",
300
+ description: "Find beliefs that imply measurable predictions.",
301
+ prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
302
+ highlightStrategy: "predictions"
303
+ },
304
+ {
305
+ id: "belief-pagerank",
306
+ categoryId: "deep",
307
+ mode: "semantic",
308
+ name: "Belief PageRank",
309
+ description: "Identify structurally central beliefs.",
310
+ prompt: "Use graph centrality to identify the most structurally important beliefs.",
311
+ highlightStrategy: "centrality"
312
+ },
313
+ {
314
+ id: "underdetermination",
315
+ categoryId: "deep",
316
+ mode: "semantic",
317
+ name: "Underdetermination",
318
+ description: "Find places where evidence supports multiple explanations.",
319
+ prompt: "Find places where the same evidence could support multiple incompatible explanations.",
320
+ highlightStrategy: "underdetermination"
321
+ },
322
+ {
323
+ id: "confidence-propagation",
324
+ categoryId: "deep",
325
+ mode: "semantic",
326
+ name: "Confidence Propagation",
327
+ description: "Assess how uncertainty moves through the graph.",
328
+ prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
329
+ highlightStrategy: "confidence-flow"
330
+ },
331
+ {
332
+ id: "argument-depth",
333
+ categoryId: "deep",
334
+ mode: "evidence",
335
+ name: "Argument Depth",
336
+ description: "Assess reasoning depth and chain quality.",
337
+ prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
338
+ highlightStrategy: "depth"
339
+ },
340
+ {
341
+ id: "information-edge",
342
+ categoryId: "deep",
343
+ mode: "alpha",
344
+ name: "Information Edge",
345
+ description: "Find differentiated evidence or signals.",
346
+ prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
347
+ highlightStrategy: "information-edge"
348
+ },
349
+ {
350
+ id: "thesis-summary",
351
+ categoryId: "browse",
352
+ mode: "semantic",
353
+ name: "Thesis Summary",
354
+ description: "Summarize the graph's core thesis and support.",
355
+ prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
356
+ highlightStrategy: "summary"
357
+ },
358
+ {
359
+ id: "theme-deep-dive",
360
+ categoryId: "browse",
361
+ mode: "semantic",
362
+ name: "Theme Deep Dive",
363
+ description: "Deep dive into a named theme.",
364
+ prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
365
+ inputType: "theme",
366
+ highlightStrategy: "theme"
367
+ },
368
+ {
369
+ id: "belief-detail",
370
+ categoryId: "browse",
371
+ mode: "semantic",
372
+ name: "Belief Detail",
373
+ description: "Explain one belief and its graph neighborhood.",
374
+ prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
375
+ inputType: "belief",
376
+ highlightStrategy: "belief"
377
+ },
378
+ {
379
+ id: "strongest-beliefs",
380
+ categoryId: "browse",
381
+ mode: "operational",
382
+ name: "Strongest Beliefs",
383
+ description: "Find the graph's strongest current beliefs.",
384
+ prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
385
+ highlightStrategy: "strongest"
386
+ },
387
+ {
388
+ id: "cross-theme-connection",
389
+ categoryId: "browse",
390
+ mode: "semantic",
391
+ name: "Cross-Theme Connections",
392
+ description: "Find bridges between themes.",
393
+ prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
394
+ highlightStrategy: "bridges"
395
+ },
396
+ {
397
+ id: "research-velocity",
398
+ categoryId: "browse",
399
+ mode: "operational",
400
+ name: "Research Velocity",
401
+ description: "Summarize recent graph movement and momentum.",
402
+ prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
403
+ highlightStrategy: "velocity"
404
+ },
405
+ {
406
+ id: "search",
407
+ categoryId: "browse",
408
+ mode: "semantic",
409
+ name: "Graph Search",
410
+ description: "Search the graph with semantic context.",
411
+ prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
412
+ inputType: "search",
413
+ highlightStrategy: "search"
414
+ },
415
+ {
416
+ id: "expert-coverage",
417
+ categoryId: "browse",
418
+ mode: "semantic",
419
+ name: "Expert Coverage",
420
+ description: "Assess coverage from expert/source perspectives.",
421
+ prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
422
+ highlightStrategy: "expert-coverage"
423
+ },
424
+ {
425
+ id: "value-chain-map",
426
+ categoryId: "browse",
427
+ mode: "semantic",
428
+ name: "Value Chain Map",
429
+ description: "Map entities, dependencies, and value-chain logic.",
430
+ prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
431
+ highlightStrategy: "value-chain"
432
+ },
433
+ {
434
+ id: "meeting-brief",
435
+ categoryId: "prep",
436
+ mode: "semantic",
437
+ name: "Meeting Brief",
438
+ description: "Prepare a meeting brief from graph context.",
439
+ prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
440
+ highlightStrategy: "brief"
441
+ },
442
+ {
443
+ id: "open-questions-entity",
444
+ categoryId: "prep",
445
+ mode: "semantic",
446
+ name: "Entity Open Questions",
447
+ description: "Find open questions about a specific entity.",
448
+ prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
449
+ inputType: "entity",
450
+ highlightStrategy: "entity-questions"
451
+ },
452
+ {
453
+ id: "company-context",
454
+ categoryId: "prep",
455
+ mode: "semantic",
456
+ name: "Company Context",
457
+ description: "Summarize graph context about a company.",
458
+ prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
459
+ inputType: "company",
460
+ highlightStrategy: "company"
461
+ },
462
+ {
463
+ id: "company-theme-fit",
464
+ categoryId: "prep",
465
+ mode: "semantic",
466
+ name: "Company Theme Fit",
467
+ description: "Assess how a company fits graph themes.",
468
+ prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
469
+ inputType: "company",
470
+ highlightStrategy: "fit"
471
+ },
472
+ {
473
+ id: "company-comparison",
474
+ categoryId: "prep",
475
+ mode: "semantic",
476
+ name: "Company Comparison",
477
+ description: "Compare companies through graph context.",
478
+ prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
479
+ inputType: "company-list",
480
+ highlightStrategy: "comparison"
481
+ },
482
+ {
483
+ id: "questions-to-ask",
484
+ categoryId: "prep",
485
+ mode: "operational",
486
+ name: "Questions to Ask",
487
+ description: "Generate high-signal questions from graph gaps.",
488
+ prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
489
+ highlightStrategy: "questions"
490
+ },
491
+ {
492
+ id: "beliefs-to-test",
493
+ categoryId: "prep",
494
+ mode: "stress",
495
+ name: "Beliefs to Test",
496
+ description: "Prioritize beliefs that should be tested next.",
497
+ prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
498
+ highlightStrategy: "tests",
499
+ riskLevel: "medium"
500
+ }
501
+ ];
502
+ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
503
+ const definition = query;
504
+ return {
505
+ ...definition,
506
+ tools: definition.tools ?? byMode(definition.mode)
507
+ };
508
+ });
509
+
29
510
  // ../contracts/src/events.contract.ts
30
511
  var DOMAIN_EVENT_VERSION = "1.0";
31
512
  var EVENT_RETENTION_DEFAULT_DAYS = 30;
@@ -176,7 +657,10 @@ function idOf(table) {
176
657
  return schema;
177
658
  }
178
659
  var NODE_TYPE = z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
179
- var EDGE_TYPE = z.enum(["supports", "informs", "depends_on", "extracted_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"]);
660
+ var EDGE_TYPE_VALUES = ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"];
661
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
662
+ z.enum(EDGE_TYPE_VALUES);
663
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
180
664
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
181
665
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
182
666
  defineTable({
@@ -1661,7 +2145,7 @@ defineTable({
1661
2145
  "toNodeId": z.string().optional(),
1662
2146
  "sourceGlobalId": z.string().optional(),
1663
2147
  "targetGlobalId": z.string().optional(),
1664
- "edgeType": EDGE_TYPE,
2148
+ "edgeType": STORAGE_EDGE_TYPE,
1665
2149
  "edgeTier": z.string().optional(),
1666
2150
  "domainNamespace": z.string().optional(),
1667
2151
  "constraint": z.string().optional(),
@@ -3994,7 +4478,9 @@ defineTable({
3994
4478
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3995
4479
  "deployments": z.record(z.object({
3996
4480
  "url": z.string(),
3997
- "encryptedDeployKey": z.string()
4481
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
4482
+ "encryptedDeployKey": z.string().optional(),
4483
+ "credentialRef": z.string().optional()
3998
4484
  })).optional(),
3999
4485
  "metadata": z.record(z.any()).optional(),
4000
4486
  "createdBy": z.string().optional(),
@@ -4430,6 +4916,128 @@ var edgePolicyManifest = {
4430
4916
  }
4431
4917
  ]
4432
4918
  };
4919
+
4920
+ // ../contracts/src/tenant-client.contract.ts
4921
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
4922
+ {
4923
+ packageName: "@lucern/access-control",
4924
+ role: "runtime_entrypoint",
4925
+ directTenantImport: true
4926
+ },
4927
+ {
4928
+ packageName: "@lucern/agent",
4929
+ role: "platform_runtime",
4930
+ directTenantImport: false
4931
+ },
4932
+ {
4933
+ packageName: "@lucern/auth",
4934
+ role: "sdk_dependency",
4935
+ directTenantImport: false
4936
+ },
4937
+ {
4938
+ packageName: "@lucern/cli",
4939
+ role: "developer_tool",
4940
+ directTenantImport: false
4941
+ },
4942
+ {
4943
+ packageName: "@lucern/client-core",
4944
+ role: "sdk_dependency",
4945
+ directTenantImport: false
4946
+ },
4947
+ {
4948
+ packageName: "@lucern/confidence",
4949
+ role: "sdk_dependency",
4950
+ directTenantImport: false
4951
+ },
4952
+ {
4953
+ packageName: "@lucern/config",
4954
+ role: "configuration",
4955
+ directTenantImport: false
4956
+ },
4957
+ {
4958
+ packageName: "@lucern/contracts",
4959
+ role: "contract_entrypoint",
4960
+ directTenantImport: true
4961
+ },
4962
+ {
4963
+ packageName: "@lucern/control-plane",
4964
+ role: "platform_runtime",
4965
+ directTenantImport: false
4966
+ },
4967
+ {
4968
+ packageName: "@lucern/developer-kit",
4969
+ role: "developer_tool",
4970
+ directTenantImport: false
4971
+ },
4972
+ {
4973
+ packageName: "@lucern/events",
4974
+ role: "sdk_dependency",
4975
+ directTenantImport: false
4976
+ },
4977
+ {
4978
+ packageName: "@lucern/graph-primitives",
4979
+ role: "sdk_dependency",
4980
+ directTenantImport: false
4981
+ },
4982
+ {
4983
+ packageName: "@lucern/identity",
4984
+ role: "component_runtime",
4985
+ directTenantImport: false
4986
+ },
4987
+ {
4988
+ packageName: "@lucern/mcp",
4989
+ role: "runtime_entrypoint",
4990
+ directTenantImport: true
4991
+ },
4992
+ {
4993
+ packageName: "@lucern/pack-host",
4994
+ role: "platform_runtime",
4995
+ directTenantImport: false
4996
+ },
4997
+ {
4998
+ packageName: "@lucern/pack-installer",
4999
+ role: "developer_tool",
5000
+ directTenantImport: false
5001
+ },
5002
+ {
5003
+ packageName: "@lucern/proof-compiler",
5004
+ role: "developer_tool",
5005
+ directTenantImport: false
5006
+ },
5007
+ {
5008
+ packageName: "@lucern/react",
5009
+ role: "runtime_entrypoint",
5010
+ directTenantImport: true
5011
+ },
5012
+ {
5013
+ packageName: "@lucern/reasoning-kernel",
5014
+ role: "component_runtime",
5015
+ directTenantImport: false
5016
+ },
5017
+ {
5018
+ packageName: "@lucern/sdk",
5019
+ role: "runtime_entrypoint",
5020
+ directTenantImport: true
5021
+ },
5022
+ {
5023
+ packageName: "@lucern/server-core",
5024
+ role: "platform_runtime",
5025
+ directTenantImport: false
5026
+ },
5027
+ {
5028
+ packageName: "@lucern/testing",
5029
+ role: "test_support",
5030
+ directTenantImport: false
5031
+ },
5032
+ {
5033
+ packageName: "@lucern/types",
5034
+ role: "contract_entrypoint",
5035
+ directTenantImport: true
5036
+ }
5037
+ ];
5038
+ TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
5039
+ (entry) => entry.packageName
5040
+ );
4433
5041
  z.object({
4434
5042
  manifestVersion: z.literal("1.0.0"),
4435
5043
  rules: z.array(
@@ -5191,6 +5799,14 @@ var ADD_WORKTREE = {
5191
5799
  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.",
5192
5800
  parameters: {
5193
5801
  title: { type: "string", description: "Worktree name/objective" },
5802
+ name: {
5803
+ type: "string",
5804
+ description: "Optional storage-name alias for callers that already use backend naming"
5805
+ },
5806
+ projectId: {
5807
+ type: "string",
5808
+ description: "Legacy topicId alias"
5809
+ },
5194
5810
  topicId: { type: "string", description: "Optional topic scope hint" },
5195
5811
  branchId: {
5196
5812
  type: "string",
@@ -5204,14 +5820,87 @@ var ADD_WORKTREE = {
5204
5820
  type: "string",
5205
5821
  description: "The testable claim this worktree investigates"
5206
5822
  },
5823
+ rationale: {
5824
+ type: "string",
5825
+ description: "Why this worktree exists and why it belongs in the campaign"
5826
+ },
5827
+ worktreeType: {
5828
+ type: "string",
5829
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5830
+ },
5831
+ gate: {
5832
+ type: "string",
5833
+ description: "Exit gate name for this worktree"
5834
+ },
5835
+ startDate: {
5836
+ type: "number",
5837
+ description: "Planned start timestamp in milliseconds since epoch"
5838
+ },
5839
+ endDate: {
5840
+ type: "number",
5841
+ description: "Planned end timestamp in milliseconds since epoch"
5842
+ },
5843
+ durationWeeks: {
5844
+ type: "number",
5845
+ description: "Planned duration in weeks"
5846
+ },
5847
+ confidenceImpact: {
5848
+ type: "string",
5849
+ description: "Expected confidence impact if the worktree succeeds",
5850
+ enum: ["high", "medium", "low"]
5851
+ },
5852
+ beliefFocus: {
5853
+ type: "string",
5854
+ description: "Natural-language focus spanning the target belief neighborhood"
5855
+ },
5207
5856
  beliefIds: {
5208
5857
  type: "array",
5209
- description: "Beliefs to test in this worktree"
5858
+ description: "Legacy alias for targetBeliefIds"
5859
+ },
5860
+ beliefs: {
5861
+ type: "array",
5862
+ description: "Legacy alias for targetBeliefIds"
5863
+ },
5864
+ targetBeliefIds: {
5865
+ type: "array",
5866
+ description: "Belief node IDs this worktree is expected to test or update"
5867
+ },
5868
+ targetQuestionIds: {
5869
+ type: "array",
5870
+ description: "Question node IDs this worktree is expected to answer"
5871
+ },
5872
+ keyQuestions: {
5873
+ type: "array",
5874
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5875
+ },
5876
+ evidenceSignals: {
5877
+ type: "array",
5878
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5879
+ },
5880
+ decisionGate: {
5881
+ type: "object",
5882
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5883
+ },
5884
+ goCriteria: {
5885
+ type: "array",
5886
+ description: "Shorthand go criteria used to build decisionGate"
5887
+ },
5888
+ noGoSignals: {
5889
+ type: "array",
5890
+ description: "Shorthand no-go signals used to build decisionGate"
5891
+ },
5892
+ proofArtifacts: {
5893
+ type: "array",
5894
+ description: "Expected proof artifacts required to close the worktree"
5210
5895
  },
5211
5896
  autoShape: {
5212
5897
  type: "boolean",
5213
5898
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5214
5899
  },
5900
+ autoFixPolicy: {
5901
+ type: "object",
5902
+ description: "Policy for permitted automatic remediation inside the worktree"
5903
+ },
5215
5904
  domainPackId: {
5216
5905
  type: "string",
5217
5906
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
@@ -5240,9 +5929,17 @@ var ADD_WORKTREE = {
5240
5929
  type: "array",
5241
5930
  description: "Worktree IDs blocked by this worktree"
5242
5931
  },
5243
- gate: {
5932
+ staffingHint: {
5244
5933
  type: "string",
5245
- description: "Exit gate name for this worktree"
5934
+ description: "Suggested staffing or agent allocation note"
5935
+ },
5936
+ lensId: {
5937
+ type: "string",
5938
+ description: "Lens that scopes this worktree when applicable"
5939
+ },
5940
+ lastReconciledAt: {
5941
+ type: "number",
5942
+ description: "Timestamp when worktree metadata was last reconciled"
5246
5943
  }
5247
5944
  },
5248
5945
  required: ["title", "topicId"],
@@ -5272,7 +5969,7 @@ var MERGE = {
5272
5969
  worktreeId: { type: "string", description: "The worktree to merge" },
5273
5970
  outcomes: {
5274
5971
  type: "array",
5275
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5972
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5276
5973
  },
5277
5974
  summary: { type: "string", description: "Overall findings summary" }
5278
5975
  },
@@ -5826,6 +6523,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
5826
6523
  ontologyPrimitive: "graph",
5827
6524
  tier: "showcase"
5828
6525
  };
6526
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
6527
+ name: "list_graph_intelligence_queries",
6528
+ 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.",
6529
+ parameters: {
6530
+ categoryId: {
6531
+ type: "string",
6532
+ description: "Optional category filter, such as problems or strategic"
6533
+ },
6534
+ mode: {
6535
+ type: "string",
6536
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
6537
+ }
6538
+ },
6539
+ required: [],
6540
+ response: {
6541
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
6542
+ fields: {
6543
+ categories: "array \u2014 query categories",
6544
+ queries: "array \u2014 query definitions with prompt templates and tools",
6545
+ quickQueries: "array \u2014 recommended one-click query presets",
6546
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
6547
+ }
6548
+ },
6549
+ ownerModule: "graph-intelligence",
6550
+ ontologyPrimitive: "graph",
6551
+ tier: "showcase"
6552
+ };
6553
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
6554
+ name: "run_graph_intelligence_query",
6555
+ 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.",
6556
+ parameters: {
6557
+ topicId: { type: "string", description: "Topic to analyze" },
6558
+ queryId: {
6559
+ type: "string",
6560
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
6561
+ },
6562
+ prompt: {
6563
+ type: "string",
6564
+ description: "Optional custom prompt for custom analysis runs"
6565
+ },
6566
+ input: {
6567
+ type: "string",
6568
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
6569
+ },
6570
+ mode: {
6571
+ type: "string",
6572
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
6573
+ },
6574
+ limit: {
6575
+ type: "number",
6576
+ description: "Maximum graph context rows to return"
6577
+ }
6578
+ },
6579
+ required: ["topicId"],
6580
+ response: {
6581
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
6582
+ fields: {
6583
+ query: "object \u2014 selected query definition",
6584
+ prompt: "string \u2014 resolved prompt template",
6585
+ toolPlan: "array \u2014 public tools and args the model can call next",
6586
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
6587
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
6588
+ }
6589
+ },
6590
+ ownerModule: "graph-intelligence",
6591
+ ontologyPrimitive: "graph",
6592
+ tier: "showcase"
6593
+ };
5829
6594
  var GET_FALSIFICATION_QUESTIONS = {
5830
6595
  name: "get_falsification_questions",
5831
6596
  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.",
@@ -8291,22 +9056,85 @@ var GENERATE_SESSION_HANDOFF = {
8291
9056
  tier: "showcase",
8292
9057
  internal: true
8293
9058
  };
8294
- var MCP_TOOL_CONTRACTS = {
8295
- // Belief lifecycle (commit, amend, fork, archive)
8296
- create_belief: CREATE_BELIEF,
8297
- get_belief: GET_BELIEF,
8298
- refine_belief: REFINE_BELIEF,
8299
- modulate_confidence: MODULATE_CONFIDENCE,
8300
- fork_belief: FORK_BELIEF,
8301
- archive_belief: ARCHIVE_BELIEF,
8302
- create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
8303
- evaluate_contract: EVALUATE_CONTRACT,
8304
- get_contract_status: GET_CONTRACT_STATUS,
8305
- // Evidence (commit)
8306
- create_evidence: CREATE_EVIDENCE,
8307
- get_evidence: GET_EVIDENCE,
8308
- list_evidence: LIST_EVIDENCE,
8309
- link_evidence: LINK_EVIDENCE,
9059
+ var BEGIN_BUILD_SESSION = {
9060
+ name: "begin_build_session",
9061
+ 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.",
9062
+ parameters: {
9063
+ worktreeId: {
9064
+ type: "string",
9065
+ description: "The Lucern worktree ID to bootstrap."
9066
+ },
9067
+ branch: {
9068
+ type: "string",
9069
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
9070
+ },
9071
+ branchBase: {
9072
+ type: "string",
9073
+ description: 'Base branch for the feature branch. Default: "staging".'
9074
+ },
9075
+ prBase: {
9076
+ type: "string",
9077
+ description: 'Target branch for the PR. Default: "staging".'
9078
+ },
9079
+ sessionMode: {
9080
+ type: "string",
9081
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
9082
+ enum: ["async", "interactive"]
9083
+ },
9084
+ activateIfPlanning: {
9085
+ type: "boolean",
9086
+ description: "When true, automatically activate a planning worktree during bootstrap."
9087
+ }
9088
+ },
9089
+ required: ["worktreeId"],
9090
+ response: {
9091
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
9092
+ fields: {
9093
+ topicId: "string \u2014 canonical topic scope",
9094
+ topicName: "string \u2014 human-readable topic name",
9095
+ worktreeId: "string \u2014 worktree ID",
9096
+ worktreeName: "string \u2014 human-readable worktree name",
9097
+ branch: "string \u2014 git branch name",
9098
+ branchBase: "string \u2014 base branch",
9099
+ prBase: "string \u2014 PR target branch",
9100
+ campaign: "number | null \u2014 top-level pipeline campaign",
9101
+ lane: "string \u2014 campaign lane",
9102
+ gate: "string \u2014 exit gate",
9103
+ hypothesis: "string \u2014 worktree hypothesis",
9104
+ focus: "string \u2014 session focus",
9105
+ status: "string \u2014 worktree status after optional activation",
9106
+ sessionMode: "string \u2014 async | interactive",
9107
+ targetBeliefIds: "array \u2014 scoped belief IDs",
9108
+ targetQuestionIds: "array \u2014 scoped question IDs",
9109
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
9110
+ openQuestions: "array \u2014 open scoped questions",
9111
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
9112
+ dependencies: "array \u2014 upstream worktrees",
9113
+ unblocks: "array \u2014 downstream worktrees",
9114
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
9115
+ }
9116
+ },
9117
+ ownerModule: "bootstrap",
9118
+ ontologyPrimitive: "worktree",
9119
+ tier: "showcase",
9120
+ internal: true
9121
+ };
9122
+ var MCP_TOOL_CONTRACTS = {
9123
+ // Belief lifecycle (commit, amend, fork, archive)
9124
+ create_belief: CREATE_BELIEF,
9125
+ get_belief: GET_BELIEF,
9126
+ refine_belief: REFINE_BELIEF,
9127
+ modulate_confidence: MODULATE_CONFIDENCE,
9128
+ fork_belief: FORK_BELIEF,
9129
+ archive_belief: ARCHIVE_BELIEF,
9130
+ create_epistemic_contract: CREATE_EPISTEMIC_CONTRACT,
9131
+ evaluate_contract: EVALUATE_CONTRACT,
9132
+ get_contract_status: GET_CONTRACT_STATUS,
9133
+ // Evidence (commit)
9134
+ create_evidence: CREATE_EVIDENCE,
9135
+ get_evidence: GET_EVIDENCE,
9136
+ list_evidence: LIST_EVIDENCE,
9137
+ link_evidence: LINK_EVIDENCE,
8310
9138
  add_evidence: ADD_EVIDENCE,
8311
9139
  // Contradictions (merge conflict)
8312
9140
  flag_contradiction: FLAG_CONTRADICTION,
@@ -8338,6 +9166,8 @@ var MCP_TOOL_CONTRACTS = {
8338
9166
  // Graph intelligence (showcase)
8339
9167
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8340
9168
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
9169
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
9170
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8341
9171
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8342
9172
  // Evidence operations (workhorse)
8343
9173
  search_evidence: SEARCH_EVIDENCE,
@@ -8384,6 +9214,7 @@ var MCP_TOOL_CONTRACTS = {
8384
9214
  get_agent_inbox: GET_AGENT_INBOX,
8385
9215
  claim_files: CLAIM_FILES,
8386
9216
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
9217
+ begin_build_session: BEGIN_BUILD_SESSION,
8387
9218
  // Policy / ACL (workhorse)
8388
9219
  check_permission: CHECK_PERMISSION,
8389
9220
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8519,6 +9350,8 @@ var MCP_ANALYSIS_PLATFORM_OPERATION_NAMES = [
8519
9350
  "traverse_graph",
8520
9351
  "get_graph_neighborhood",
8521
9352
  "get_graph_structure_analysis",
9353
+ "list_graph_intelligence_queries",
9354
+ "run_graph_intelligence_query",
8522
9355
  "find_contradictions",
8523
9356
  "flag_contradiction",
8524
9357
  "detect_confirmation_bias",
@@ -8597,6 +9430,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8597
9430
  "get_change_history",
8598
9431
  "get_failure_log",
8599
9432
  "record_attempt",
9433
+ "begin_build_session",
8600
9434
  "push",
8601
9435
  "open_pull_request",
8602
9436
  "record_judgment",
@@ -8651,7 +9485,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8651
9485
  "find_semantic_orphans"
8652
9486
  ];
8653
9487
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8654
- "begin_build_session",
8655
9488
  "evaluate_engineering_contract",
8656
9489
  "evaluate_research_contract"
8657
9490
  ];
@@ -9037,8 +9870,31 @@ function assertSurfaceCoverage(contracts) {
9037
9870
  }
9038
9871
  }
9039
9872
  }
9040
-
9041
- // ../contracts/src/function-registry/context.ts
9873
+ var jsonRecordSchema2 = z.record(z.unknown());
9874
+ var observationArgs = z.object({
9875
+ topicId: z.string().optional().describe("Topic scope for the observation."),
9876
+ summary: z.string().describe("Short observation summary."),
9877
+ text: z.string().optional().describe("Canonical observation text alias."),
9878
+ title: z.string().optional().describe("Optional observation title."),
9879
+ content: z.string().optional().describe("Optional rich observation content."),
9880
+ contentType: z.string().optional().describe("Observation content type."),
9881
+ kind: z.string().optional().describe("Evidence kind to store."),
9882
+ observationType: z.string().optional().describe("Observation type."),
9883
+ tags: z.array(z.string()).optional().describe("Observation tags."),
9884
+ source: z.string().optional().describe("Observation source label."),
9885
+ sourceType: z.string().optional().describe("Evidence source type."),
9886
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
9887
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9888
+ confidence: z.number().optional().describe("Observation confidence."),
9889
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
9890
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
9891
+ });
9892
+ var observationContextArgs = z.object({
9893
+ topicId: z.string().describe("Topic scope."),
9894
+ query: z.string().optional().describe("Optional context query."),
9895
+ limit: z.number().optional().describe("Maximum observations to return."),
9896
+ status: z.string().optional().describe("Observation status filter.")
9897
+ });
9042
9898
  var observationInput = (input, context) => withUserId(
9043
9899
  compactRecord4({
9044
9900
  projectId: input.projectId,
@@ -9097,7 +9953,8 @@ var contextContracts = [
9097
9953
  observationId: output && typeof output === "object" ? output.nodeId : void 0,
9098
9954
  observationType: input.observationType
9099
9955
  })
9100
- }
9956
+ },
9957
+ args: observationArgs
9101
9958
  }),
9102
9959
  surfaceContract({
9103
9960
  name: "get_observation_context",
@@ -9118,7 +9975,8 @@ var contextContracts = [
9118
9975
  status: input.status,
9119
9976
  userId: input.userId
9120
9977
  })
9121
- }
9978
+ },
9979
+ args: observationContextArgs
9122
9980
  })
9123
9981
  ];
9124
9982
 
@@ -9181,8 +10039,45 @@ var identityContracts = [
9181
10039
  }
9182
10040
  })
9183
10041
  ];
9184
-
9185
- // ../contracts/src/function-registry/beliefs.ts
10042
+ var jsonRecordSchema3 = z.record(z.unknown());
10043
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
10044
+ var reversibilitySchema = z.enum([
10045
+ "irreversible",
10046
+ "hard_to_reverse",
10047
+ "reversible",
10048
+ "trivial"
10049
+ ]);
10050
+ var predictionMetaSchema = z.object({
10051
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
10052
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
10053
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
10054
+ });
10055
+ var createBeliefArgs = z.object({
10056
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
10057
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
10058
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
10059
+ beliefType: z.string().optional().describe("Schema belief type."),
10060
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
10061
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
10062
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
10063
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
10064
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
10065
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
10066
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
10067
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
10068
+ });
10069
+ var forkBeliefArgs = z.object({
10070
+ nodeId: z.string().describe("The scored belief to fork from."),
10071
+ newFormulation: z.string().describe("The evolved belief statement."),
10072
+ forkReason: z.enum([
10073
+ "refinement",
10074
+ "contradiction_response",
10075
+ "scope_change",
10076
+ "confidence_collapse",
10077
+ "manual"
10078
+ ]).describe("Why this fork was created."),
10079
+ rationale: z.string().optional().describe("Why the fork is warranted.")
10080
+ });
9186
10081
  var beliefLookupInput = (input) => compactRecord4({
9187
10082
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9188
10083
  beliefId: input.beliefId
@@ -9257,7 +10152,8 @@ var beliefsContracts = [
9257
10152
  functionName: "create",
9258
10153
  kind: "mutation",
9259
10154
  inputProjection: createBeliefInput
9260
- }
10155
+ },
10156
+ args: createBeliefArgs
9261
10157
  }),
9262
10158
  surfaceContract({
9263
10159
  name: "get_belief",
@@ -9348,7 +10244,8 @@ var beliefsContracts = [
9348
10244
  functionName: "forkBelief",
9349
10245
  kind: "mutation",
9350
10246
  inputProjection: forkBeliefInput
9351
- }
10247
+ },
10248
+ args: forkBeliefArgs
9352
10249
  }),
9353
10250
  surfaceContract({
9354
10251
  name: "archive_belief",
@@ -9429,8 +10326,46 @@ var beliefsContracts = [
9429
10326
  }
9430
10327
  })
9431
10328
  ];
9432
-
9433
- // ../contracts/src/function-registry/evidence.ts
10329
+ var jsonRecordSchema4 = z.record(z.unknown());
10330
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
10331
+ var createEvidenceArgs = z.object({
10332
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
10333
+ text: z.string().describe("Canonical evidence text."),
10334
+ source: z.string().optional().describe("Source URL or source label."),
10335
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
10336
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
10337
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
10338
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
10339
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
10340
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10341
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
10342
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
10343
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
10344
+ title: z.string().optional().describe("Optional short title."),
10345
+ content: z.string().optional().describe("Optional long-form content."),
10346
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10347
+ kind: z.string().optional().describe("Evidence kind."),
10348
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
10349
+ sourceType: z.string().optional().describe("Evidence source type."),
10350
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
10351
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
10352
+ methodology: z.string().optional().describe("Collection methodology."),
10353
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
10354
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
10355
+ });
10356
+ var addEvidenceArgs = z.object({
10357
+ canonicalText: z.string().describe("The evidence statement."),
10358
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
10359
+ topicId: z.string().optional().describe("Topic scope hint."),
10360
+ sourceUrl: z.string().optional().describe("URL of the source material."),
10361
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
10362
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
10363
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
10364
+ title: z.string().optional().describe("Optional short title."),
10365
+ content: z.string().optional().describe("Optional long-form evidence content."),
10366
+ contentType: z.string().optional().describe("Content format or MIME hint."),
10367
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
10368
+ });
9434
10369
  var evidenceIdInput = (input) => compactRecord4({
9435
10370
  evidenceId: input.evidenceId,
9436
10371
  insightId: input.insightId,
@@ -9505,7 +10440,8 @@ var evidenceContracts = [
9505
10440
  functionName: "create",
9506
10441
  kind: "mutation",
9507
10442
  inputProjection: createEvidenceInput
9508
- }
10443
+ },
10444
+ args: createEvidenceArgs
9509
10445
  }),
9510
10446
  surfaceContract({
9511
10447
  name: "add_evidence",
@@ -9541,7 +10477,8 @@ var evidenceContracts = [
9541
10477
  context
9542
10478
  );
9543
10479
  }
9544
- }
10480
+ },
10481
+ args: addEvidenceArgs
9545
10482
  }),
9546
10483
  surfaceContract({
9547
10484
  name: "get_evidence",
@@ -9648,8 +10585,91 @@ var evidenceContracts = [
9648
10585
  }
9649
10586
  })
9650
10587
  ];
9651
-
9652
- // ../contracts/src/function-registry/questions.ts
10588
+ var jsonRecordSchema5 = z.record(z.unknown());
10589
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
10590
+ var kernelQuestionPrioritySchema = z.enum([
10591
+ "critical",
10592
+ "high",
10593
+ "medium",
10594
+ "low"
10595
+ ]);
10596
+ var questionTypeSchema = z.enum([
10597
+ "validation",
10598
+ "falsification",
10599
+ "assumption_probe",
10600
+ "prediction_test",
10601
+ "counterfactual",
10602
+ "discovery",
10603
+ "clarification",
10604
+ "comparison",
10605
+ "causal",
10606
+ "mechanism",
10607
+ "general"
10608
+ ]);
10609
+ var createQuestionArgs = z.object({
10610
+ text: z.string().describe("The question text."),
10611
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10612
+ topicId: z.string().optional().describe("Topic scope hint."),
10613
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
10614
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
10615
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
10616
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
10617
+ category: z.string().optional().describe("Question category."),
10618
+ source: z.string().optional().describe("Question source."),
10619
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
10620
+ importance: z.number().optional().describe("Numeric importance score."),
10621
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
10622
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
10623
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
10624
+ questionType: questionTypeSchema.optional().describe("Question type."),
10625
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
10626
+ });
10627
+ var refineQuestionArgs = z.object({
10628
+ id: z.string().describe("The question to refine."),
10629
+ text: z.string().describe("Updated question text."),
10630
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
10631
+ rationale: z.string().optional().describe("Why the question is refined."),
10632
+ category: z.string().optional().describe("Updated question category."),
10633
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
10634
+ });
10635
+ var createAnswerArgs = z.object({
10636
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
10637
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10638
+ answerText: z.string().describe("The answer content."),
10639
+ topicId: z.string().optional().describe("Topic scope for the answer."),
10640
+ confidence: z.string().optional().describe("Answer confidence."),
10641
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
10642
+ answerSource: z.string().optional().describe("How the answer was produced."),
10643
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10644
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10645
+ });
10646
+ var answerQuestionArgs = z.object({
10647
+ id: z.string().describe("Canonical question ID."),
10648
+ topicId: z.string().describe("Topic scope for the answer."),
10649
+ text: z.string().describe("Answer text."),
10650
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
10651
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
10652
+ rationale: z.string().optional().describe("Why this answer is credible."),
10653
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
10654
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
10655
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
10656
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
10657
+ answerSource: z.string().optional().describe("How the answer was produced."),
10658
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
10659
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
10660
+ });
10661
+ var missingQuestionsArgs = z.object({
10662
+ topicId: z.string().describe("Topic scope."),
10663
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
10664
+ status: z.string().optional().describe("Question status filter."),
10665
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10666
+ });
10667
+ var falsificationQuestionsArgs = z.object({
10668
+ topicId: z.string().describe("Topic scope."),
10669
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
10670
+ status: z.string().optional().describe("Question status filter."),
10671
+ limit: z.number().optional().describe("Maximum questions to inspect.")
10672
+ });
9653
10673
  var questionNodeInput = (input) => compactRecord4({
9654
10674
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9655
10675
  questionId: input.questionId
@@ -9696,7 +10716,8 @@ var questionsContracts = [
9696
10716
  functionName: "create",
9697
10717
  kind: "mutation",
9698
10718
  inputProjection: createQuestionInput
9699
- }
10719
+ },
10720
+ args: createQuestionArgs
9700
10721
  }),
9701
10722
  surfaceContract({
9702
10723
  name: "get_question",
@@ -9752,7 +10773,8 @@ var questionsContracts = [
9752
10773
  category: input.category,
9753
10774
  priority: input.priority
9754
10775
  })
9755
- }
10776
+ },
10777
+ args: refineQuestionArgs
9756
10778
  }),
9757
10779
  surfaceContract({
9758
10780
  name: "update_question_status",
@@ -9828,7 +10850,8 @@ var questionsContracts = [
9828
10850
  }),
9829
10851
  context
9830
10852
  )
9831
- }
10853
+ },
10854
+ args: createAnswerArgs
9832
10855
  }),
9833
10856
  surfaceContract({
9834
10857
  name: "answer_question",
@@ -9857,7 +10880,8 @@ var questionsContracts = [
9857
10880
  }),
9858
10881
  context
9859
10882
  )
9860
- }
10883
+ },
10884
+ args: answerQuestionArgs
9861
10885
  }),
9862
10886
  surfaceContract({
9863
10887
  name: "get_answer",
@@ -9889,7 +10913,8 @@ var questionsContracts = [
9889
10913
  functionName: "getByTopic",
9890
10914
  kind: "query",
9891
10915
  inputProjection: questionTopicInput
9892
- }
10916
+ },
10917
+ args: missingQuestionsArgs
9893
10918
  }),
9894
10919
  surfaceContract({
9895
10920
  name: "get_high_priority_questions",
@@ -9924,11 +10949,22 @@ var questionsContracts = [
9924
10949
  functionName: "getByTopic",
9925
10950
  kind: "query",
9926
10951
  inputProjection: questionTopicInput
9927
- }
10952
+ },
10953
+ args: falsificationQuestionsArgs
9928
10954
  })
9929
10955
  ];
9930
-
9931
- // ../contracts/src/function-registry/topics.ts
10956
+ var updateTopicArgs = z.object({
10957
+ id: z.string().describe("Topic ID."),
10958
+ topicId: z.string().optional().describe("Topic ID alias."),
10959
+ name: z.string().optional().describe("Topic name."),
10960
+ description: z.string().optional().describe("Topic description."),
10961
+ type: z.string().optional().describe("Topic type."),
10962
+ status: z.string().optional().describe("Topic status."),
10963
+ visibility: z.string().optional().describe("Topic visibility."),
10964
+ ontologyId: z.string().optional().describe("Ontology to bind."),
10965
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
10966
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
10967
+ });
9932
10968
  var topicIdInput = (input) => compactRecord4({
9933
10969
  id: input.id ?? input.topicId
9934
10970
  });
@@ -10009,7 +11045,8 @@ var topicsContracts = [
10009
11045
  functionName: "update",
10010
11046
  kind: "mutation",
10011
11047
  inputProjection: updateTopicInput
10012
- }
11048
+ },
11049
+ args: updateTopicArgs
10013
11050
  }),
10014
11051
  surfaceContract({
10015
11052
  name: "get_topic_tree",
@@ -10028,8 +11065,27 @@ var topicsContracts = [
10028
11065
  }
10029
11066
  })
10030
11067
  ];
10031
-
10032
- // ../contracts/src/function-registry/lenses.ts
11068
+ var lensPerspectiveSchema = z.enum([
11069
+ "investigation",
11070
+ "monitoring",
11071
+ "analysis",
11072
+ "comparison",
11073
+ "taxonomy"
11074
+ ]);
11075
+ var jsonRecordSchema6 = z.record(z.unknown());
11076
+ var createLensArgs = z.object({
11077
+ name: z.string().describe("Lens name."),
11078
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
11079
+ topicId: z.string().optional().describe("Originating topic scope."),
11080
+ description: z.string().optional().describe("What this lens investigates or monitors."),
11081
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
11082
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
11083
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
11084
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
11085
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
11086
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
11087
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
11088
+ });
10033
11089
  var createLensInput = (input, context) => compactRecord4({
10034
11090
  name: input.name,
10035
11091
  description: input.description,
@@ -10066,7 +11122,8 @@ var lensesContracts = [
10066
11122
  functionName: "create",
10067
11123
  kind: "mutation",
10068
11124
  inputProjection: createLensInput
10069
- }
11125
+ },
11126
+ args: createLensArgs
10070
11127
  }),
10071
11128
  surfaceContract({
10072
11129
  name: "list_lenses",
@@ -10128,8 +11185,18 @@ var lensesContracts = [
10128
11185
  }
10129
11186
  })
10130
11187
  ];
10131
-
10132
- // ../contracts/src/function-registry/ontologies.ts
11188
+ var updateOntologyArgs = z.object({
11189
+ id: z.string().describe("Ontology definition ID."),
11190
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
11191
+ name: z.string().optional().describe("Ontology display name."),
11192
+ description: z.string().optional().describe("Ontology description."),
11193
+ status: z.string().optional().describe("Ontology lifecycle status.")
11194
+ });
11195
+ var ontologyVersionLifecycleArgs = z.object({
11196
+ id: z.string().describe("Ontology version ID."),
11197
+ versionId: z.string().optional().describe("Ontology version ID alias."),
11198
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
11199
+ });
10133
11200
  var ontologyIdInput = (input) => compactRecord4({
10134
11201
  id: input.id ?? input.ontologyId
10135
11202
  });
@@ -10208,11 +11275,11 @@ var ontologiesContracts = [
10208
11275
  id: input.id ?? input.ontologyId,
10209
11276
  name: input.name,
10210
11277
  description: input.description,
10211
- parentOntologyId: input.parentOntologyId,
10212
11278
  status: input.status,
10213
11279
  actorId: input.actorId
10214
11280
  })
10215
- }
11281
+ },
11282
+ args: updateOntologyArgs
10216
11283
  }),
10217
11284
  surfaceContract({
10218
11285
  name: "archive_ontology",
@@ -10295,7 +11362,8 @@ var ontologiesContracts = [
10295
11362
  functionName: "publishOntologyVersion",
10296
11363
  kind: "mutation",
10297
11364
  inputProjection: ontologyVersionIdInput
10298
- }
11365
+ },
11366
+ args: ontologyVersionLifecycleArgs
10299
11367
  }),
10300
11368
  surfaceContract({
10301
11369
  name: "deprecate_ontology_version",
@@ -10311,7 +11379,8 @@ var ontologiesContracts = [
10311
11379
  functionName: "deprecateOntologyVersion",
10312
11380
  kind: "mutation",
10313
11381
  inputProjection: ontologyVersionIdInput
10314
- }
11382
+ },
11383
+ args: ontologyVersionLifecycleArgs
10315
11384
  }),
10316
11385
  surfaceContract({
10317
11386
  name: "resolve_effective_ontology",
@@ -10330,8 +11399,76 @@ var ontologiesContracts = [
10330
11399
  }
10331
11400
  })
10332
11401
  ];
10333
-
10334
- // ../contracts/src/function-registry/worktrees.ts
11402
+ var autoFixPolicyInputSchema = z.object({
11403
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
11404
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
11405
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
11406
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
11407
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
11408
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
11409
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
11410
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
11411
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
11412
+ var worktreeKeyQuestionInputSchema = z.object({
11413
+ question: z.string().describe("Question the worktree must resolve."),
11414
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
11415
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
11416
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
11417
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
11418
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
11419
+ var worktreeEvidenceSignalInputSchema = z.object({
11420
+ signal: z.string().describe("Evidence signal the worktree should collect."),
11421
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
11422
+ progress: z.string().optional().describe("Collection progress note for the signal."),
11423
+ notes: z.string().optional().describe("Additional evidence collection notes.")
11424
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
11425
+ var worktreeDecisionGateInputSchema = z.object({
11426
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
11427
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
11428
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
11429
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
11430
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
11431
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
11432
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
11433
+ var addWorktreeArgs = z.object({
11434
+ title: z.string().optional().describe("Human-readable worktree name or objective."),
11435
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
11436
+ topicId: z.string().describe("Primary topic scope for the worktree."),
11437
+ projectId: z.string().optional().describe("Legacy topicId alias."),
11438
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
11439
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
11440
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
11441
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
11442
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
11443
+ gate: z.string().optional().describe("Exit gate for this worktree."),
11444
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
11445
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
11446
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
11447
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
11448
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
11449
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
11450
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
11451
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
11452
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
11453
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
11454
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
11455
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
11456
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
11457
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
11458
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
11459
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
11460
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
11461
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
11462
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
11463
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
11464
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
11465
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
11466
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
11467
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
11468
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
11469
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
11470
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
11471
+ });
10335
11472
  var worktreeIdInput = (input) => compactRecord4({
10336
11473
  worktreeId: input.worktreeId ?? input.id
10337
11474
  });
@@ -10364,6 +11501,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10364
11501
  autoFixPolicy: input.autoFixPolicy,
10365
11502
  lastReconciledAt: input.lastReconciledAt
10366
11503
  });
11504
+ var worktreeMetadataArgs = z.object({
11505
+ worktreeId: z.string().describe("The worktree to update."),
11506
+ id: z.string().optional().describe("Worktree ID alias."),
11507
+ topicId: z.string().optional().describe("Primary topic scope."),
11508
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
11509
+ status: z.string().optional().describe("Worktree lifecycle status."),
11510
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
11511
+ lane: z.string().optional().describe("Campaign lane."),
11512
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
11513
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
11514
+ gate: z.string().optional().describe("Exit gate for this worktree."),
11515
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
11516
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
11517
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
11518
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
11519
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
11520
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
11521
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
11522
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
11523
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
11524
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
11525
+ });
11526
+ var pushArgs = worktreeMetadataArgs.extend({
11527
+ targetContext: z.string().describe("Where to push merged findings."),
11528
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
11529
+ });
11530
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
11531
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
11532
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
11533
+ });
11534
+ var mergeKeyFindingsInput = (input) => {
11535
+ if (Array.isArray(input.keyFindings)) {
11536
+ return input.keyFindings;
11537
+ }
11538
+ if (Array.isArray(input.outcomes)) {
11539
+ const findings = input.outcomes.filter(
11540
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
11541
+ );
11542
+ if (findings.length > 0) {
11543
+ return findings;
11544
+ }
11545
+ }
11546
+ return [input.summary ?? "Merged worktree"];
11547
+ };
10367
11548
  var listAllWorktreesInput = (input) => compactRecord4({
10368
11549
  status: input.status,
10369
11550
  lane: input.lane,
@@ -10371,6 +11552,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10371
11552
  limit: input.limit
10372
11553
  });
10373
11554
  var worktreesContracts = [
11555
+ surfaceContract({
11556
+ name: "begin_build_session",
11557
+ kind: "mutation",
11558
+ domain: "worktrees",
11559
+ surfaceClass: "platform_internal",
11560
+ path: "/mcp/build-session/begin",
11561
+ sdkNamespace: "worktrees",
11562
+ sdkMethod: "beginBuildSession",
11563
+ summary: "Begin a coding build session for a worktree."
11564
+ }),
10374
11565
  surfaceContract({
10375
11566
  name: "add_worktree",
10376
11567
  kind: "mutation",
@@ -10387,13 +11578,12 @@ var worktreesContracts = [
10387
11578
  inputProjection: (input, context) => withCreatedBy(
10388
11579
  compactRecord4({
10389
11580
  name: input.name ?? input.title,
10390
- topicId: input.topicId,
11581
+ topicId: input.topicId ?? input.projectId,
10391
11582
  worktreeType: input.worktreeType,
10392
11583
  objective: input.objective,
10393
11584
  gate: input.gate,
10394
11585
  hypothesis: input.hypothesis,
10395
11586
  rationale: input.rationale,
10396
- signal: input.signal,
10397
11587
  startDate: input.startDate,
10398
11588
  endDate: input.endDate,
10399
11589
  durationWeeks: input.durationWeeks,
@@ -10419,12 +11609,12 @@ var worktreesContracts = [
10419
11609
  staffingHint: input.staffingHint,
10420
11610
  domainPackId: input.domainPackId,
10421
11611
  lensId: input.lensId,
10422
- linkedQuestionId: input.linkedQuestionId,
10423
11612
  lastReconciledAt: input.lastReconciledAt
10424
11613
  }),
10425
11614
  context
10426
11615
  )
10427
- }
11616
+ },
11617
+ args: addWorktreeArgs
10428
11618
  }),
10429
11619
  surfaceContract({
10430
11620
  name: "activate_worktree",
@@ -10536,7 +11726,8 @@ var worktreesContracts = [
10536
11726
  functionName: "updateMetadata",
10537
11727
  kind: "mutation",
10538
11728
  inputProjection: worktreeMetadataInput
10539
- }
11729
+ },
11730
+ args: worktreeMetadataArgs
10540
11731
  }),
10541
11732
  surfaceContract({
10542
11733
  name: "merge",
@@ -10554,9 +11745,7 @@ var worktreesContracts = [
10554
11745
  inputProjection: (input, context) => withUserId(
10555
11746
  {
10556
11747
  ...worktreeIdInput(input),
10557
- keyFindings: input.keyFindings ?? [
10558
- input.summary ?? "Merged worktree"
10559
- ],
11748
+ keyFindings: mergeKeyFindingsInput(input),
10560
11749
  decisionsReached: input.decisionsReached ?? [],
10561
11750
  nextSteps: input.nextSteps ?? []
10562
11751
  },
@@ -10578,7 +11767,8 @@ var worktreesContracts = [
10578
11767
  functionName: "updateMetadata",
10579
11768
  kind: "mutation",
10580
11769
  inputProjection: worktreeMetadataInput
10581
- }
11770
+ },
11771
+ args: pushArgs
10582
11772
  }),
10583
11773
  surfaceContract({
10584
11774
  name: "open_pull_request",
@@ -10594,7 +11784,8 @@ var worktreesContracts = [
10594
11784
  functionName: "updateMetadata",
10595
11785
  kind: "mutation",
10596
11786
  inputProjection: worktreeMetadataInput
10597
- }
11787
+ },
11788
+ args: openPullRequestArgs
10598
11789
  })
10599
11790
  ];
10600
11791
 
@@ -10698,6 +11889,15 @@ var createEdgeArgs = z.object({
10698
11889
  topicId: z.string().optional(),
10699
11890
  trustedBypassAccessCheck: z.boolean().optional()
10700
11891
  });
11892
+ var queryLineageArgs = z.object({
11893
+ nodeId: z.string().describe("Starting node to trace from."),
11894
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
11895
+ depth: z.number().optional().describe("Traversal depth alias."),
11896
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11897
+ mode: z.string().optional().describe("Traversal mode."),
11898
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11899
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11900
+ });
10701
11901
  function graphRefNodeId(ref) {
10702
11902
  if (ref.kind === "epistemic_node") {
10703
11903
  return ref.nodeId;
@@ -10768,11 +11968,84 @@ var edgesContracts = [
10768
11968
  minLayer: input.minLayer,
10769
11969
  maxLayer: input.maxLayer
10770
11970
  })
10771
- }
11971
+ },
11972
+ args: queryLineageArgs
10772
11973
  })
10773
11974
  ];
10774
-
10775
- // ../contracts/src/function-registry/graph.ts
11975
+ var graphIntelligenceQueryModes = [
11976
+ "core",
11977
+ "bias",
11978
+ "stress",
11979
+ "operational",
11980
+ "alpha",
11981
+ "semantic",
11982
+ "evidence"
11983
+ ];
11984
+ var traversalLayerSchema = z.enum([
11985
+ "L4",
11986
+ "L3",
11987
+ "L2",
11988
+ "L1",
11989
+ "ontological",
11990
+ "organizational"
11991
+ ]);
11992
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
11993
+ var lineageAliasArgs = z.object({
11994
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
11995
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
11996
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
11997
+ depth: z.number().optional().describe("Traversal depth alias."),
11998
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11999
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
12000
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
12001
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
12002
+ });
12003
+ var lineageArgs = lineageAliasArgs.extend({
12004
+ nodeId: z.string().describe("Starting node to traverse from.")
12005
+ });
12006
+ var traverseGraphArgs = lineageAliasArgs.extend({
12007
+ startNode: z.string().describe("Node to start traversal from."),
12008
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
12009
+ });
12010
+ var graphNeighborhoodArgs = z.object({
12011
+ globalId: z.string().optional().describe("Single root global ID."),
12012
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
12013
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
12014
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
12015
+ limit: z.number().optional().describe("Maximum edges to return.")
12016
+ });
12017
+ var graphIntelligenceModeSchema = z.enum([
12018
+ graphIntelligenceQueryModes[0],
12019
+ ...graphIntelligenceQueryModes.slice(1)
12020
+ ]);
12021
+ var graphIntelligenceCatalogArgs = z.object({
12022
+ categoryId: z.string().optional().describe("Optional query category filter."),
12023
+ mode: graphIntelligenceModeSchema.optional().describe("Optional Graph Intelligence query mode filter.")
12024
+ });
12025
+ var graphIntelligenceRunArgs = z.object({
12026
+ topicId: z.string().describe("Topic to analyze."),
12027
+ queryId: z.string().optional().describe("Catalog query ID to run, such as pre-mortem."),
12028
+ prompt: z.string().optional().describe("Custom prompt when queryId is omitted or overridden."),
12029
+ input: z.string().optional().describe("Optional entity, theme, belief, company, or search text."),
12030
+ mode: graphIntelligenceModeSchema.optional().describe("Optional query mode override for custom prompts."),
12031
+ limit: z.number().optional().describe("Maximum graph context rows to return.")
12032
+ });
12033
+ var flagContradictionArgs = z.object({
12034
+ beliefA: z.string().describe("First belief in tension."),
12035
+ beliefB: z.string().describe("Second belief in tension."),
12036
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
12037
+ description: z.string().optional().describe("Human-readable contradiction."),
12038
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
12039
+ defeatType: z.string().optional().describe("Defeat type annotation."),
12040
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
12041
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
12042
+ });
12043
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
12044
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
12045
+ topicId: z.string().optional().describe("Topic scope override."),
12046
+ minScore: z.number().optional().describe("Minimum match score."),
12047
+ limit: z.number().optional().describe("Maximum candidates to return.")
12048
+ });
10776
12049
  var contradictionSeverity = (value) => {
10777
12050
  switch (value) {
10778
12051
  case "critical":
@@ -10827,7 +12100,8 @@ var graphContracts = [
10827
12100
  functionName: "getLineage",
10828
12101
  kind: "query",
10829
12102
  inputProjection: lineageInput
10830
- }
12103
+ },
12104
+ args: traverseGraphArgs
10831
12105
  }),
10832
12106
  surfaceContract({
10833
12107
  name: "get_graph_neighborhood",
@@ -10843,7 +12117,8 @@ var graphContracts = [
10843
12117
  functionName: "getByTopic",
10844
12118
  kind: "query",
10845
12119
  inputProjection: topicEdgesInput
10846
- }
12120
+ },
12121
+ args: graphNeighborhoodArgs
10847
12122
  }),
10848
12123
  surfaceContract({
10849
12124
  name: "get_graph_structure_analysis",
@@ -10860,6 +12135,38 @@ var graphContracts = [
10860
12135
  kind: "query"
10861
12136
  }
10862
12137
  }),
12138
+ surfaceContract({
12139
+ name: "list_graph_intelligence_queries",
12140
+ kind: "query",
12141
+ domain: "graph",
12142
+ surfaceClass: "platform_public",
12143
+ path: "/graph-intelligence/queries",
12144
+ sdkNamespace: "graphAnalysis",
12145
+ sdkMethod: "listGraphIntelligenceQueries",
12146
+ summary: "List Graph Intelligence query catalog entries.",
12147
+ convex: {
12148
+ module: "contextCompiler",
12149
+ functionName: "listGraphIntelligenceQueries",
12150
+ kind: "query"
12151
+ },
12152
+ args: graphIntelligenceCatalogArgs
12153
+ }),
12154
+ surfaceContract({
12155
+ name: "run_graph_intelligence_query",
12156
+ kind: "query",
12157
+ domain: "graph",
12158
+ surfaceClass: "platform_public",
12159
+ path: "/graph-intelligence/run",
12160
+ sdkNamespace: "graphAnalysis",
12161
+ sdkMethod: "runGraphIntelligenceQuery",
12162
+ summary: "Run a Graph Intelligence query against a topic graph.",
12163
+ convex: {
12164
+ module: "contextCompiler",
12165
+ functionName: "runGraphIntelligenceQuery",
12166
+ kind: "query"
12167
+ },
12168
+ args: graphIntelligenceRunArgs
12169
+ }),
10863
12170
  surfaceContract({
10864
12171
  name: "find_contradictions",
10865
12172
  kind: "query",
@@ -10892,7 +12199,8 @@ var graphContracts = [
10892
12199
  functionName: "create",
10893
12200
  kind: "mutation",
10894
12201
  inputProjection: flagContradictionInput
10895
- }
12202
+ },
12203
+ args: flagContradictionArgs
10896
12204
  }),
10897
12205
  surfaceContract({
10898
12206
  name: "detect_confirmation_bias",
@@ -10983,7 +12291,8 @@ var graphContracts = [
10983
12291
  functionName: "getLineage",
10984
12292
  kind: "query",
10985
12293
  inputProjection: lineageInput
10986
- }
12294
+ },
12295
+ args: discoverEntityConnectionsArgs
10987
12296
  }),
10988
12297
  surfaceContract({
10989
12298
  name: "trigger_belief_review",
@@ -11014,7 +12323,8 @@ var graphContracts = [
11014
12323
  functionName: "getLineage",
11015
12324
  kind: "query",
11016
12325
  inputProjection: lineageInput
11017
- }
12326
+ },
12327
+ args: lineageArgs
11018
12328
  })
11019
12329
  ];
11020
12330
 
@@ -11066,8 +12376,16 @@ var contractsContracts = [
11066
12376
  }
11067
12377
  })
11068
12378
  ];
11069
-
11070
- // ../contracts/src/function-registry/judgments.ts
12379
+ var auditTrailArgs = z.object({
12380
+ nodeId: z.string().describe("The node to audit."),
12381
+ id: z.string().optional().describe("Node ID alias."),
12382
+ limit: z.number().optional().describe("Maximum entries to return."),
12383
+ depth: z.number().optional().describe("Traversal depth alias."),
12384
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
12385
+ mode: z.string().optional().describe("Traversal mode."),
12386
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
12387
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
12388
+ });
11071
12389
  var judgmentsContracts = [
11072
12390
  surfaceContract({
11073
12391
  name: "record_judgment",
@@ -11122,7 +12440,8 @@ var judgmentsContracts = [
11122
12440
  minLayer: input.minLayer,
11123
12441
  maxLayer: input.maxLayer
11124
12442
  })
11125
- }
12443
+ },
12444
+ args: auditTrailArgs
11126
12445
  })
11127
12446
  ];
11128
12447
 
@@ -11290,8 +12609,13 @@ var coordinationContracts = [
11290
12609
  }
11291
12610
  })
11292
12611
  ];
11293
-
11294
- // ../contracts/src/function-registry/pipeline.ts
12612
+ var pipelineSnapshotArgs = z.object({
12613
+ topicId: z.string().describe("Topic scope ID."),
12614
+ status: z.string().optional().describe("Worktree status filter."),
12615
+ lane: z.string().optional().describe("Campaign lane filter."),
12616
+ campaign: z.number().optional().describe("Campaign number filter."),
12617
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
12618
+ });
11295
12619
  var pipelineContracts = [
11296
12620
  surfaceContract({
11297
12621
  name: "pipeline_snapshot",
@@ -11312,7 +12636,8 @@ var pipelineContracts = [
11312
12636
  campaign: input.campaign,
11313
12637
  limit: input.limit
11314
12638
  })
11315
- }
12639
+ },
12640
+ args: pipelineSnapshotArgs
11316
12641
  }),
11317
12642
  surfaceContract({
11318
12643
  name: "seed_belief_lattice",
@@ -11364,7 +12689,31 @@ var recordScopeLearningArgs = z.object({
11364
12689
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11365
12690
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11366
12691
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11367
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
12692
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
12693
+ text: z.string().optional().describe("Canonical learning text alias."),
12694
+ content: z.string().optional().describe("Canonical learning content alias."),
12695
+ kind: z.string().optional().describe("Evidence kind to store."),
12696
+ sourceType: z.string().optional().describe("Evidence source type."),
12697
+ externalSourceType: z.string().optional().describe("External source type alias."),
12698
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
12699
+ });
12700
+ var codeContextArgs = z.object({
12701
+ topicId: z.string().optional().describe("Topic scope."),
12702
+ filePath: z.string().optional().describe("File path anchor."),
12703
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
12704
+ limit: z.number().optional().describe("Maximum records to return."),
12705
+ status: z.string().optional().describe("Evidence status filter.")
12706
+ });
12707
+ var recordAttemptArgs = z.object({
12708
+ topicId: z.string().optional().describe("Topic scope."),
12709
+ description: z.string().describe("Attempt description."),
12710
+ errorMessage: z.string().optional().describe("Failure or error message."),
12711
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
12712
+ filePath: z.string().optional().describe("Single file path alias."),
12713
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
12714
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
12715
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
12716
+ title: z.string().optional().describe("Attempt evidence title.")
11368
12717
  });
11369
12718
  var learningInput = (input, context) => {
11370
12719
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11481,7 +12830,8 @@ var codingContracts = [
11481
12830
  status: input.status,
11482
12831
  userId: input.userId
11483
12832
  })
11484
- }
12833
+ },
12834
+ args: codeContextArgs
11485
12835
  }),
11486
12836
  surfaceContract({
11487
12837
  name: "get_change_history",
@@ -11518,7 +12868,8 @@ var codingContracts = [
11518
12868
  functionName: "create",
11519
12869
  kind: "mutation",
11520
12870
  inputProjection: attemptInput
11521
- }
12871
+ },
12872
+ args: recordAttemptArgs
11522
12873
  }),
11523
12874
  surfaceContract({
11524
12875
  name: "get_failure_log",
@@ -11593,6 +12944,604 @@ new Map(
11593
12944
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11594
12945
  );
11595
12946
 
12947
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
12948
+ function isCopyableSeedRequirement(entry) {
12949
+ 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;
12950
+ }
12951
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
12952
+ {
12953
+ component: "kernel",
12954
+ table: "agentMessages",
12955
+ prepopulation: "runtime_data",
12956
+ copyMode: "none",
12957
+ description: "Agent coordination messages are session data, not template data."
12958
+ },
12959
+ {
12960
+ component: "kernel",
12961
+ table: "agentSessions",
12962
+ prepopulation: "runtime_data",
12963
+ copyMode: "none",
12964
+ description: "Agent coordination sessions are created by active clients."
12965
+ },
12966
+ {
12967
+ component: "kernel",
12968
+ table: "autofixJobs",
12969
+ prepopulation: "runtime_queue",
12970
+ copyMode: "none",
12971
+ description: "Autofix work items are runtime queue rows."
12972
+ },
12973
+ {
12974
+ component: "kernel",
12975
+ table: "backgroundJobRuns",
12976
+ prepopulation: "runtime_log",
12977
+ copyMode: "none",
12978
+ description: "Background job executions are runtime logs."
12979
+ },
12980
+ {
12981
+ component: "kernel",
12982
+ table: "backgroundJobSettings",
12983
+ prepopulation: "required_template",
12984
+ copyMode: "template_global",
12985
+ scope: "global",
12986
+ uniqueKey: ["jobKey"],
12987
+ description: "Default job enablement settings must come from the K template."
12988
+ },
12989
+ {
12990
+ component: "kernel",
12991
+ table: "beliefConfidence",
12992
+ prepopulation: "runtime_data",
12993
+ copyMode: "none",
12994
+ description: "Belief confidence rows are created with tenant graph facts."
12995
+ },
12996
+ {
12997
+ component: "kernel",
12998
+ table: "beliefEvidenceLinks",
12999
+ prepopulation: "runtime_data",
13000
+ copyMode: "none",
13001
+ description: "Belief-to-evidence links are tenant graph data."
13002
+ },
13003
+ {
13004
+ component: "kernel",
13005
+ table: "beliefHistory",
13006
+ prepopulation: "runtime_data",
13007
+ copyMode: "none",
13008
+ description: "Belief history is append-only tenant graph data."
13009
+ },
13010
+ {
13011
+ component: "kernel",
13012
+ table: "beliefScenarios",
13013
+ prepopulation: "runtime_data",
13014
+ copyMode: "none",
13015
+ description: "Scenario rows are tenant-authored reasoning data."
13016
+ },
13017
+ {
13018
+ component: "kernel",
13019
+ table: "beliefVotes",
13020
+ prepopulation: "runtime_data",
13021
+ copyMode: "none",
13022
+ description: "Decision belief votes are tenant-authored data."
13023
+ },
13024
+ {
13025
+ component: "kernel",
13026
+ table: "calibrationScores",
13027
+ prepopulation: "runtime_derived",
13028
+ copyMode: "none",
13029
+ description: "Calibration scores are computed from tenant outcomes."
13030
+ },
13031
+ {
13032
+ component: "kernel",
13033
+ table: "contractEvaluations",
13034
+ prepopulation: "runtime_log",
13035
+ copyMode: "none",
13036
+ description: "Contract evaluation rows are runtime computation logs."
13037
+ },
13038
+ {
13039
+ component: "kernel",
13040
+ table: "contradictions",
13041
+ prepopulation: "runtime_data",
13042
+ copyMode: "none",
13043
+ description: "Contradictions are tenant graph facts."
13044
+ },
13045
+ {
13046
+ component: "kernel",
13047
+ table: "crossProjectConnections",
13048
+ prepopulation: "runtime_data",
13049
+ copyMode: "none",
13050
+ description: "Cross-topic connections are tenant graph facts."
13051
+ },
13052
+ {
13053
+ component: "kernel",
13054
+ table: "decisionComputedSummaries",
13055
+ prepopulation: "runtime_derived",
13056
+ copyMode: "none",
13057
+ description: "Decision summaries are derived tenant outputs."
13058
+ },
13059
+ {
13060
+ component: "kernel",
13061
+ table: "decisionEvents",
13062
+ prepopulation: "runtime_data",
13063
+ copyMode: "none",
13064
+ description: "Decision events are lifecycle data."
13065
+ },
13066
+ {
13067
+ component: "kernel",
13068
+ table: "decisionParticipants",
13069
+ prepopulation: "runtime_data",
13070
+ copyMode: "none",
13071
+ description: "Decision participants are tenant-selected actors."
13072
+ },
13073
+ {
13074
+ component: "kernel",
13075
+ table: "decisionRiskLedger",
13076
+ prepopulation: "runtime_data",
13077
+ copyMode: "none",
13078
+ description: "Decision risk rows are tenant decision data."
13079
+ },
13080
+ {
13081
+ component: "kernel",
13082
+ table: "decisionSnapshots",
13083
+ prepopulation: "runtime_derived",
13084
+ copyMode: "none",
13085
+ description: "Decision snapshots are derived from tenant state."
13086
+ },
13087
+ {
13088
+ component: "kernel",
13089
+ table: "deliberationContributions",
13090
+ prepopulation: "runtime_data",
13091
+ copyMode: "none",
13092
+ description: "Deliberation contributions are tenant-authored data."
13093
+ },
13094
+ {
13095
+ component: "kernel",
13096
+ table: "deliberationSessions",
13097
+ prepopulation: "runtime_data",
13098
+ copyMode: "none",
13099
+ description: "Deliberation sessions are created by tenant workflows."
13100
+ },
13101
+ {
13102
+ component: "kernel",
13103
+ table: "epistemicAudit",
13104
+ prepopulation: "runtime_log",
13105
+ copyMode: "none",
13106
+ description: "Epistemic audit rows are append-only runtime audit data."
13107
+ },
13108
+ {
13109
+ component: "kernel",
13110
+ table: "epistemicContracts",
13111
+ prepopulation: "runtime_data",
13112
+ copyMode: "none",
13113
+ description: "Epistemic contracts are tenant-authored governance data."
13114
+ },
13115
+ {
13116
+ component: "kernel",
13117
+ table: "epistemicEdges",
13118
+ prepopulation: "runtime_data",
13119
+ copyMode: "none",
13120
+ description: "Edges are tenant reasoning graph data."
13121
+ },
13122
+ {
13123
+ component: "kernel",
13124
+ table: "epistemicNodeEmbeddings",
13125
+ prepopulation: "runtime_derived",
13126
+ copyMode: "none",
13127
+ description: "Embeddings are derived from tenant graph nodes."
13128
+ },
13129
+ {
13130
+ component: "kernel",
13131
+ table: "epistemicNodes",
13132
+ prepopulation: "runtime_data",
13133
+ copyMode: "none",
13134
+ description: "Nodes are tenant reasoning graph data."
13135
+ },
13136
+ {
13137
+ component: "kernel",
13138
+ table: "graphAnalysisCache",
13139
+ prepopulation: "runtime_derived",
13140
+ copyMode: "none",
13141
+ description: "Graph analysis cache rows are derived from tenant graph state."
13142
+ },
13143
+ {
13144
+ component: "kernel",
13145
+ table: "graphAnalysisResults",
13146
+ prepopulation: "runtime_derived",
13147
+ copyMode: "none",
13148
+ description: "Graph analysis result rows are derived tenant outputs."
13149
+ },
13150
+ {
13151
+ component: "kernel",
13152
+ table: "graphSuggestions",
13153
+ prepopulation: "runtime_derived",
13154
+ copyMode: "none",
13155
+ description: "Graph suggestions are derived recommendations."
13156
+ },
13157
+ {
13158
+ component: "kernel",
13159
+ table: "harnessReplays",
13160
+ prepopulation: "runtime_log",
13161
+ copyMode: "none",
13162
+ description: "Harness replay rows are runtime verification logs."
13163
+ },
13164
+ {
13165
+ component: "kernel",
13166
+ table: "harnessRuns",
13167
+ prepopulation: "runtime_log",
13168
+ copyMode: "none",
13169
+ description: "Harness run rows are runtime verification logs."
13170
+ },
13171
+ {
13172
+ component: "kernel",
13173
+ table: "idempotencyTokens",
13174
+ prepopulation: "runtime_log",
13175
+ copyMode: "none",
13176
+ description: "Idempotency tokens are request-scoped runtime guards."
13177
+ },
13178
+ {
13179
+ component: "kernel",
13180
+ table: "lenses",
13181
+ prepopulation: "optional_template",
13182
+ copyMode: "none",
13183
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
13184
+ },
13185
+ {
13186
+ component: "kernel",
13187
+ table: "lensTopicBindings",
13188
+ prepopulation: "runtime_data",
13189
+ copyMode: "none",
13190
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
13191
+ },
13192
+ {
13193
+ component: "kernel",
13194
+ table: "neo4jSyncQueue",
13195
+ prepopulation: "runtime_queue",
13196
+ copyMode: "none",
13197
+ description: "Neo4j sync queue rows are runtime work items."
13198
+ },
13199
+ {
13200
+ component: "kernel",
13201
+ table: "ontologyDefinitions",
13202
+ prepopulation: "required_template",
13203
+ copyMode: "template_global",
13204
+ scope: "global",
13205
+ uniqueKey: ["ontologyKey"],
13206
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
13207
+ },
13208
+ {
13209
+ component: "kernel",
13210
+ table: "ontologyVersions",
13211
+ prepopulation: "required_template",
13212
+ copyMode: "template_reference_remap",
13213
+ scope: "global",
13214
+ uniqueKey: ["ontologyKey", "version"],
13215
+ dependsOn: ["ontologyDefinitions"],
13216
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
13217
+ },
13218
+ {
13219
+ component: "kernel",
13220
+ table: "platformAgentRunPolicyDecisions",
13221
+ prepopulation: "runtime_log",
13222
+ copyMode: "none",
13223
+ description: "Agent-run policy decisions are audit logs."
13224
+ },
13225
+ {
13226
+ component: "kernel",
13227
+ table: "platformAgentRunPromptResolutions",
13228
+ prepopulation: "runtime_log",
13229
+ copyMode: "none",
13230
+ description: "Agent-run prompt resolution rows are runtime logs."
13231
+ },
13232
+ {
13233
+ component: "kernel",
13234
+ table: "platformAgentRuns",
13235
+ prepopulation: "runtime_log",
13236
+ copyMode: "none",
13237
+ description: "Agent runs are runtime execution records."
13238
+ },
13239
+ {
13240
+ component: "kernel",
13241
+ table: "platformAgentRunToolCalls",
13242
+ prepopulation: "runtime_log",
13243
+ copyMode: "none",
13244
+ description: "Agent-run tool calls are runtime execution records."
13245
+ },
13246
+ {
13247
+ component: "kernel",
13248
+ table: "platformHarnessShadowAudit",
13249
+ prepopulation: "runtime_log",
13250
+ copyMode: "none",
13251
+ description: "Harness shadow audit rows are runtime audit records."
13252
+ },
13253
+ {
13254
+ component: "kernel",
13255
+ table: "publicationRules",
13256
+ prepopulation: "required_template",
13257
+ copyMode: "template_tenant_rewrite",
13258
+ scope: "tenant",
13259
+ uniqueKey: ["tenantId", "workspaceId", "name"],
13260
+ description: "Default publication policy rules are rewritten into each tenant."
13261
+ },
13262
+ {
13263
+ component: "kernel",
13264
+ table: "questionEvidenceLinks",
13265
+ prepopulation: "runtime_data",
13266
+ copyMode: "none",
13267
+ description: "Question-to-evidence links are tenant graph data."
13268
+ },
13269
+ {
13270
+ component: "kernel",
13271
+ table: "researchJobs",
13272
+ prepopulation: "runtime_queue",
13273
+ copyMode: "none",
13274
+ description: "Research job rows are runtime queue items."
13275
+ },
13276
+ {
13277
+ component: "kernel",
13278
+ table: "schemaEnumConfig",
13279
+ prepopulation: "required_template",
13280
+ copyMode: "template_global",
13281
+ scope: "global",
13282
+ uniqueKey: ["category", "value"],
13283
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
13284
+ },
13285
+ {
13286
+ component: "kernel",
13287
+ table: "stakeholderGroups",
13288
+ prepopulation: "runtime_data",
13289
+ copyMode: "none",
13290
+ description: "Stakeholder groups are tenant decision data."
13291
+ },
13292
+ {
13293
+ component: "kernel",
13294
+ table: "systemLogs",
13295
+ prepopulation: "runtime_log",
13296
+ copyMode: "none",
13297
+ description: "System logs are runtime telemetry."
13298
+ },
13299
+ {
13300
+ component: "kernel",
13301
+ table: "tasks",
13302
+ prepopulation: "runtime_data",
13303
+ copyMode: "none",
13304
+ description: "Tasks are tenant-authored work items."
13305
+ },
13306
+ {
13307
+ component: "kernel",
13308
+ table: "topics",
13309
+ prepopulation: "runtime_bootstrap",
13310
+ copyMode: "none",
13311
+ description: "Default topics are created by tenant provisioning, not copied from templates."
13312
+ },
13313
+ {
13314
+ component: "kernel",
13315
+ table: "workflowDefinitions",
13316
+ prepopulation: "optional_template",
13317
+ copyMode: "none",
13318
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
13319
+ },
13320
+ {
13321
+ component: "kernel",
13322
+ table: "workflowPullRequests",
13323
+ prepopulation: "runtime_data",
13324
+ copyMode: "none",
13325
+ description: "Workflow pull requests are tenant workflow data."
13326
+ },
13327
+ {
13328
+ component: "kernel",
13329
+ table: "workflowStages",
13330
+ prepopulation: "optional_template",
13331
+ copyMode: "none",
13332
+ dependsOn: ["workflowDefinitions"],
13333
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
13334
+ },
13335
+ {
13336
+ component: "kernel",
13337
+ table: "worktreeBeliefCluster",
13338
+ prepopulation: "runtime_data",
13339
+ copyMode: "none",
13340
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
13341
+ },
13342
+ {
13343
+ component: "kernel",
13344
+ table: "worktrees",
13345
+ prepopulation: "runtime_data",
13346
+ copyMode: "none",
13347
+ description: "Worktrees are tenant/runtime planning data."
13348
+ },
13349
+ {
13350
+ component: "identity",
13351
+ table: "agents",
13352
+ prepopulation: "runtime_bootstrap",
13353
+ copyMode: "none",
13354
+ description: "Service agents are provisioned per tenant or service, not copied."
13355
+ },
13356
+ {
13357
+ component: "identity",
13358
+ table: "mcpWritePolicy",
13359
+ prepopulation: "required_template",
13360
+ copyMode: "template_global",
13361
+ scope: "global",
13362
+ uniqueKey: ["topicId", "role", "toolCategory"],
13363
+ description: "Global write policy defaults govern service and interactive MCP writes."
13364
+ },
13365
+ {
13366
+ component: "identity",
13367
+ table: "modelCallLogs",
13368
+ prepopulation: "runtime_log",
13369
+ copyMode: "none",
13370
+ description: "Model call logs are runtime telemetry."
13371
+ },
13372
+ {
13373
+ component: "identity",
13374
+ table: "modelFunctionSlots",
13375
+ prepopulation: "required_template",
13376
+ copyMode: "template_global",
13377
+ scope: "global",
13378
+ uniqueKey: ["slot"],
13379
+ description: "Function-to-model slots are required by model runtime resolution."
13380
+ },
13381
+ {
13382
+ component: "identity",
13383
+ table: "modelRegistry",
13384
+ prepopulation: "required_template",
13385
+ copyMode: "template_global",
13386
+ scope: "global",
13387
+ uniqueKey: ["key"],
13388
+ description: "Model catalog defaults are required by model runtime clients."
13389
+ },
13390
+ {
13391
+ component: "identity",
13392
+ table: "modelSlotConfigs",
13393
+ prepopulation: "required_template",
13394
+ copyMode: "template_global",
13395
+ scope: "global",
13396
+ uniqueKey: ["slot"],
13397
+ description: "Slot-level defaults are required before tenant overrides exist."
13398
+ },
13399
+ {
13400
+ component: "identity",
13401
+ table: "platformAudienceGrants",
13402
+ prepopulation: "runtime_data",
13403
+ copyMode: "none",
13404
+ description: "Audience grants are principal/group-specific access rows."
13405
+ },
13406
+ {
13407
+ component: "identity",
13408
+ table: "platformAudiences",
13409
+ prepopulation: "required_template",
13410
+ copyMode: "template_tenant_rewrite",
13411
+ scope: "tenant",
13412
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
13413
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
13414
+ },
13415
+ {
13416
+ component: "identity",
13417
+ table: "platformPolicyDecisionLogs",
13418
+ prepopulation: "runtime_log",
13419
+ copyMode: "none",
13420
+ description: "Policy decisions are runtime audit logs."
13421
+ },
13422
+ {
13423
+ component: "identity",
13424
+ table: "projectGrants",
13425
+ prepopulation: "runtime_data",
13426
+ copyMode: "none",
13427
+ description: "Project/topic grants are principal or group-specific access rows."
13428
+ },
13429
+ {
13430
+ component: "identity",
13431
+ table: "reasoningPermissions",
13432
+ prepopulation: "runtime_data",
13433
+ copyMode: "none",
13434
+ description: "Reasoning permissions are principal-specific policy rows."
13435
+ },
13436
+ {
13437
+ component: "identity",
13438
+ table: "tenantApiKeys",
13439
+ prepopulation: "runtime_secret",
13440
+ copyMode: "none",
13441
+ description: "API keys are tenant credentials and must never be copied."
13442
+ },
13443
+ {
13444
+ component: "identity",
13445
+ table: "tenantConfig",
13446
+ prepopulation: "required_template",
13447
+ copyMode: "template_tenant_rewrite",
13448
+ scope: "tenant",
13449
+ uniqueKey: ["tenantId"],
13450
+ description: "Tenant-local config defaults are rewritten during bootstrap."
13451
+ },
13452
+ {
13453
+ component: "identity",
13454
+ table: "tenantIntegrations",
13455
+ prepopulation: "required_template",
13456
+ copyMode: "template_tenant_rewrite",
13457
+ scope: "tenant",
13458
+ uniqueKey: ["tenantId", "integrationKey"],
13459
+ description: "Non-secret integration descriptors are rewritten into each tenant."
13460
+ },
13461
+ {
13462
+ component: "identity",
13463
+ table: "tenantModelSlotBindings",
13464
+ prepopulation: "runtime_secret",
13465
+ copyMode: "none",
13466
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
13467
+ },
13468
+ {
13469
+ component: "identity",
13470
+ table: "tenantPolicies",
13471
+ prepopulation: "required_template",
13472
+ copyMode: "template_tenant_rewrite",
13473
+ scope: "tenant",
13474
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
13475
+ description: "Default tenant policy roles are rewritten during bootstrap."
13476
+ },
13477
+ {
13478
+ component: "identity",
13479
+ table: "tenantProviderSecrets",
13480
+ prepopulation: "runtime_secret",
13481
+ copyMode: "none",
13482
+ description: "Provider secrets are credentials and must never be copied."
13483
+ },
13484
+ {
13485
+ component: "identity",
13486
+ table: "tenantProxyGatewayUsage",
13487
+ prepopulation: "runtime_log",
13488
+ copyMode: "none",
13489
+ description: "Proxy gateway usage rows are runtime telemetry."
13490
+ },
13491
+ {
13492
+ component: "identity",
13493
+ table: "tenantProxyTokenMints",
13494
+ prepopulation: "runtime_secret",
13495
+ copyMode: "none",
13496
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
13497
+ },
13498
+ {
13499
+ component: "identity",
13500
+ table: "tenantSandboxAuditEvents",
13501
+ prepopulation: "runtime_log",
13502
+ copyMode: "none",
13503
+ description: "Sandbox audit rows are runtime security logs."
13504
+ },
13505
+ {
13506
+ component: "identity",
13507
+ table: "tenantSecrets",
13508
+ prepopulation: "runtime_secret",
13509
+ copyMode: "none",
13510
+ description: "Tenant secrets are credentials and must never be copied."
13511
+ },
13512
+ {
13513
+ component: "identity",
13514
+ table: "toolAcls",
13515
+ prepopulation: "required_template",
13516
+ copyMode: "template_global",
13517
+ scope: "global",
13518
+ uniqueKey: ["role", "toolName"],
13519
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
13520
+ },
13521
+ {
13522
+ component: "identity",
13523
+ table: "toolRegistry",
13524
+ prepopulation: "required_template",
13525
+ copyMode: "template_global",
13526
+ scope: "global",
13527
+ uniqueKey: ["toolName"],
13528
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
13529
+ },
13530
+ {
13531
+ component: "identity",
13532
+ table: "users",
13533
+ prepopulation: "runtime_bootstrap",
13534
+ copyMode: "none",
13535
+ description: "Users are created from Clerk/MC principal resolution, not copied."
13536
+ }
13537
+ ];
13538
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
13539
+ isCopyableSeedRequirement
13540
+ );
13541
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
13542
+ (entry) => !isCopyableSeedRequirement(entry)
13543
+ ).map((entry) => entry.table);
13544
+
11596
13545
  // src/webhooks.ts
11597
13546
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
11598
13547
  function normalizeUrl(url) {