@lucern/contracts 0.3.0-alpha.0 → 0.3.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/component-boundary.contract.d.ts +14 -0
  3. package/dist/component-boundary.contract.js +155 -0
  4. package/dist/component-boundary.contract.js.map +1 -0
  5. package/dist/component-host-boundary.contract.d.ts +41 -0
  6. package/dist/component-host-boundary.contract.js +54 -0
  7. package/dist/component-host-boundary.contract.js.map +1 -0
  8. package/dist/context-pack.contract.d.ts +5 -3
  9. package/dist/context-pack.contract.js.map +1 -1
  10. package/dist/{dsl-BgpoVOVQ.d.ts → dsl-djCRfuWC.d.ts} +1 -1
  11. package/dist/dsl.d.ts +1 -1
  12. package/dist/dsl.js +4 -4
  13. package/dist/dsl.js.map +1 -1
  14. package/dist/edge-policy-manifest-Dw5IhT1L.d.ts +133 -0
  15. package/dist/function-registry/beliefs.d.ts +42 -82
  16. package/dist/function-registry/beliefs.js +1154 -125
  17. package/dist/function-registry/beliefs.js.map +1 -1
  18. package/dist/function-registry/coding.d.ts +7 -31
  19. package/dist/function-registry/coding.js +958 -112
  20. package/dist/function-registry/coding.js.map +1 -1
  21. package/dist/function-registry/context.d.ts +14 -26
  22. package/dist/function-registry/context.js +923 -97
  23. package/dist/function-registry/context.js.map +1 -1
  24. package/dist/function-registry/contracts.d.ts +4 -16
  25. package/dist/function-registry/contracts.js +860 -82
  26. package/dist/function-registry/contracts.js.map +1 -1
  27. package/dist/function-registry/coordination.d.ts +10 -46
  28. package/dist/function-registry/coordination.js +872 -84
  29. package/dist/function-registry/coordination.js.map +1 -1
  30. package/dist/function-registry/edges.d.ts +166 -18
  31. package/dist/function-registry/edges.js +1188 -97
  32. package/dist/function-registry/edges.js.map +1 -1
  33. package/dist/function-registry/evidence.d.ts +42 -74
  34. package/dist/function-registry/evidence.js +1106 -130
  35. package/dist/function-registry/evidence.js.map +1 -1
  36. package/dist/function-registry/graph.d.ts +132 -106
  37. package/dist/function-registry/graph.js +1006 -100
  38. package/dist/function-registry/graph.js.map +1 -1
  39. package/dist/function-registry/helpers.d.ts +8 -10
  40. package/dist/function-registry/helpers.js +869 -83
  41. package/dist/function-registry/helpers.js.map +1 -1
  42. package/dist/function-registry/identity.d.ts +4 -16
  43. package/dist/function-registry/identity.js +860 -82
  44. package/dist/function-registry/identity.js.map +1 -1
  45. package/dist/function-registry/index.d.ts +322 -8
  46. package/dist/function-registry/index.js +1249 -87
  47. package/dist/function-registry/index.js.map +1 -1
  48. package/dist/function-registry/judgments.d.ts +12 -20
  49. package/dist/function-registry/judgments.js +891 -94
  50. package/dist/function-registry/judgments.js.map +1 -1
  51. package/dist/function-registry/legacy.d.ts +2 -6
  52. package/dist/function-registry/legacy.js +860 -82
  53. package/dist/function-registry/legacy.js.map +1 -1
  54. package/dist/function-registry/lenses.d.ts +18 -34
  55. package/dist/function-registry/lenses.js +928 -88
  56. package/dist/function-registry/lenses.js.map +1 -1
  57. package/dist/function-registry/manifest.d.ts +7 -7
  58. package/dist/function-registry/manifest.js +19 -2
  59. package/dist/function-registry/manifest.js.map +1 -1
  60. package/dist/function-registry/ontologies.d.ts +46 -90
  61. package/dist/function-registry/ontologies.js +908 -109
  62. package/dist/function-registry/ontologies.js.map +1 -1
  63. package/dist/function-registry/pipeline.d.ts +14 -26
  64. package/dist/function-registry/pipeline.js +880 -85
  65. package/dist/function-registry/pipeline.js.map +1 -1
  66. package/dist/function-registry/questions.d.ts +50 -98
  67. package/dist/function-registry/questions.js +1043 -118
  68. package/dist/function-registry/questions.js.map +1 -1
  69. package/dist/function-registry/tasks.d.ts +18 -34
  70. package/dist/function-registry/tasks.js +973 -87
  71. package/dist/function-registry/tasks.js.map +1 -1
  72. package/dist/function-registry/topics.d.ts +100 -42
  73. package/dist/function-registry/topics.js +961 -89
  74. package/dist/function-registry/topics.js.map +1 -1
  75. package/dist/function-registry/types.d.ts +2 -2
  76. package/dist/function-registry/worktrees.d.ts +116 -74
  77. package/dist/function-registry/worktrees.js +1124 -115
  78. package/dist/function-registry/worktrees.js.map +1 -1
  79. package/dist/function-registry-input-audit.d.ts +13 -0
  80. package/dist/function-registry-input-audit.js +166 -0
  81. package/dist/function-registry-input-audit.js.map +1 -0
  82. package/dist/gateway.contract.d.ts +2 -0
  83. package/dist/gateway.contract.js.map +1 -1
  84. package/dist/generated/convexSchemas.js +8 -6
  85. package/dist/generated/convexSchemas.js.map +1 -1
  86. package/dist/generated/schema-manifest.json +103 -5
  87. package/dist/generated/tableOwnership.d.ts +4 -2
  88. package/dist/generated/tableOwnership.js +4 -0
  89. package/dist/generated/tableOwnership.js.map +1 -1
  90. package/dist/generated/tier-expectations.json +9 -4
  91. package/dist/graph-intelligence.contract.d.ts +506 -0
  92. package/dist/graph-intelligence.contract.js +595 -0
  93. package/dist/graph-intelligence.contract.js.map +1 -0
  94. package/dist/graph-types/index.d.ts +5 -1
  95. package/dist/graph-types/index.js +15 -4
  96. package/dist/graph-types/index.js.map +1 -1
  97. package/dist/index-O09U2xHk.d.ts +28 -0
  98. package/dist/index.d.ts +25 -4
  99. package/dist/index.js +3989 -236
  100. package/dist/index.js.map +1 -1
  101. package/dist/infisical-runtime.contract.d.ts +174 -0
  102. package/dist/infisical-runtime.contract.js +317 -0
  103. package/dist/infisical-runtime.contract.js.map +1 -0
  104. package/dist/lens-filter.contract.js +4 -3
  105. package/dist/lens-filter.contract.js.map +1 -1
  106. package/dist/lens-workflow.contract.js +4 -3
  107. package/dist/lens-workflow.contract.js.map +1 -1
  108. package/dist/manifests/edge-policy-manifest.d.ts +2 -0
  109. package/dist/manifests/edge-policy-manifest.data.d.ts +13 -0
  110. package/dist/manifests/edge-policy-manifest.data.js +26 -0
  111. package/dist/manifests/edge-policy-manifest.data.js.map +1 -0
  112. package/dist/manifests/edge-policy-manifest.js +92 -0
  113. package/dist/manifests/edge-policy-manifest.js.map +1 -0
  114. package/dist/manifests/infisical-runtime-manifest.d.ts +151 -0
  115. package/dist/manifests/infisical-runtime-manifest.js +316 -0
  116. package/dist/manifests/infisical-runtime-manifest.js.map +1 -0
  117. package/dist/manifests/invariant-manifest.d.ts +65 -0
  118. package/dist/manifests/invariant-manifest.js +18 -0
  119. package/dist/manifests/invariant-manifest.js.map +1 -0
  120. package/dist/manifests/invariants/ast-utils.d.ts +14 -0
  121. package/dist/manifests/invariants/ast-utils.js +54 -0
  122. package/dist/manifests/invariants/ast-utils.js.map +1 -0
  123. package/dist/manifests/invariants/index.d.ts +15 -0
  124. package/dist/manifests/invariants/index.js +183 -0
  125. package/dist/manifests/invariants/index.js.map +1 -0
  126. package/dist/manifests/invariants/inv-1-beliefs-append-only.d.ts +12 -0
  127. package/dist/manifests/invariants/inv-1-beliefs-append-only.js +94 -0
  128. package/dist/manifests/invariants/inv-1-beliefs-append-only.js.map +1 -0
  129. package/dist/manifests/invariants/inv-14-no-silent-transitions.d.ts +12 -0
  130. package/dist/manifests/invariants/inv-14-no-silent-transitions.js +99 -0
  131. package/dist/manifests/invariants/inv-14-no-silent-transitions.js.map +1 -0
  132. package/dist/manifests/invariants/manifest-1-projections-declare-audit.d.ts +12 -0
  133. package/dist/manifests/invariants/manifest-1-projections-declare-audit.js +42 -0
  134. package/dist/manifests/invariants/manifest-1-projections-declare-audit.js.map +1 -0
  135. package/dist/manifests/tenant-client-manifest.d.ts +322 -0
  136. package/dist/manifests/tenant-client-manifest.js +432 -0
  137. package/dist/manifests/tenant-client-manifest.js.map +1 -0
  138. package/dist/mcp-gateway-boundary.contract.d.ts +181 -0
  139. package/dist/mcp-gateway-boundary.contract.js +43 -0
  140. package/dist/mcp-gateway-boundary.contract.js.map +1 -0
  141. package/dist/projections/check-convex-args-shape.d.ts +3 -0
  142. package/dist/projections/check-convex-args-shape.js +399 -0
  143. package/dist/projections/check-convex-args-shape.js.map +1 -0
  144. package/dist/projections/create-evidence.projection.d.ts +176 -0
  145. package/dist/projections/create-evidence.projection.js +131 -0
  146. package/dist/projections/create-evidence.projection.js.map +1 -0
  147. package/dist/projections/index.d.ts +102 -0
  148. package/dist/projections/index.js +348 -0
  149. package/dist/projections/index.js.map +1 -0
  150. package/dist/projections/list-beliefs.projection.d.ts +36 -0
  151. package/dist/projections/list-beliefs.projection.js +54 -0
  152. package/dist/projections/list-beliefs.projection.js.map +1 -0
  153. package/dist/projections/list-tasks.projection.d.ts +32 -0
  154. package/dist/projections/list-tasks.projection.js +52 -0
  155. package/dist/projections/list-tasks.projection.js.map +1 -0
  156. package/dist/projections/modulate-confidence.projection.d.ts +219 -0
  157. package/dist/projections/modulate-confidence.projection.js +148 -0
  158. package/dist/projections/modulate-confidence.projection.js.map +1 -0
  159. package/dist/projections/projection-dsl.d.ts +11 -0
  160. package/dist/projections/projection-dsl.js +8 -0
  161. package/dist/projections/projection-dsl.js.map +1 -0
  162. package/dist/schema-helpers/enumValidation.js +2 -5
  163. package/dist/schema-helpers/enumValidation.js.map +1 -1
  164. package/dist/schema-helpers/spine/nodes/decision.js +2 -1
  165. package/dist/schema-helpers/spine/nodes/decision.js.map +1 -1
  166. package/dist/schema-helpers/spine/tables/epistemicNodes.js +27 -27
  167. package/dist/schema-helpers/spine/tables/epistemicNodes.js.map +1 -1
  168. package/dist/schema-helpers/validators.d.ts +1 -1
  169. package/dist/schema-helpers/validators.js +1 -1
  170. package/dist/schema-helpers/validators.js.map +1 -1
  171. package/dist/schemas/component-table-manifest.d.ts +74 -0
  172. package/dist/schemas/component-table-manifest.js +26 -0
  173. package/dist/schemas/component-table-manifest.js.map +1 -0
  174. package/dist/schemas/enums.d.ts +5 -2
  175. package/dist/schemas/enums.js +5 -2
  176. package/dist/schemas/enums.js.map +1 -1
  177. package/dist/schemas/index.d.ts +3 -1
  178. package/dist/schemas/index.js +112 -13
  179. package/dist/schemas/index.js.map +1 -1
  180. package/dist/schemas/manifest.d.ts +1154 -949
  181. package/dist/schemas/manifest.js +80 -12
  182. package/dist/schemas/manifest.js.map +1 -1
  183. package/dist/schemas/sl-opinion.d.ts +31 -0
  184. package/dist/schemas/sl-opinion.js +19 -0
  185. package/dist/schemas/sl-opinion.js.map +1 -0
  186. package/dist/schemas/tables/identity/platform.d.ts +10 -10
  187. package/dist/schemas/tables/kernel/epistemic.d.ts +12 -10
  188. package/dist/schemas/tables/kernel/epistemic.js +6 -4
  189. package/dist/schemas/tables/kernel/epistemic.js.map +1 -1
  190. package/dist/schemas/tables/kernel/infra.d.ts +17 -5
  191. package/dist/schemas/tables/kernel/infra.js +23 -1
  192. package/dist/schemas/tables/kernel/infra.js.map +1 -1
  193. package/dist/schemas/tables/kernel/intelligence.d.ts +10 -10
  194. package/dist/schemas/tables/kernel/lens.d.ts +4 -4
  195. package/dist/schemas/tables/kernel/platform.d.ts +12 -12
  196. package/dist/schemas/tables/kernel/spine.d.ts +3 -3
  197. package/dist/schemas/tables/kernel/spine.js +5 -2
  198. package/dist/schemas/tables/kernel/spine.js.map +1 -1
  199. package/dist/schemas/tables/kernel/task.d.ts +42 -42
  200. package/dist/schemas/tables/kernel/topic.js +5 -1
  201. package/dist/schemas/tables/kernel/topic.js.map +1 -1
  202. package/dist/schemas/tables/kernel/worktree.d.ts +62 -62
  203. package/dist/schemas/tables/kernel/worktree.js +6 -4
  204. package/dist/schemas/tables/kernel/worktree.js.map +1 -1
  205. package/dist/schemas/tables/mc/identity.d.ts +26 -3
  206. package/dist/schemas/tables/mc/identity.js +35 -1
  207. package/dist/schemas/tables/mc/identity.js.map +1 -1
  208. package/dist/schemas/tables/mc/pack.d.ts +20 -20
  209. package/dist/schemas/tables/mc/registry.d.ts +4 -4
  210. package/dist/schemas/tables/mc/runtime.d.ts +1 -1
  211. package/dist/schemas/tables/mc/runtime.js +1 -1
  212. package/dist/schemas/tables/mc/runtime.js.map +1 -1
  213. package/dist/schemas/tables/mc/workspace.d.ts +9 -3
  214. package/dist/schemas/tables/mc/workspace.js +3 -1
  215. package/dist/schemas/tables/mc/workspace.js.map +1 -1
  216. package/dist/sdk-methods.contract.d.ts +7 -4
  217. package/dist/{sdk-tools.contract-C2kQN_Xk.d.ts → sdk-tools.contract-BNklQDfB.d.ts} +2 -2
  218. package/dist/sdk-tools.contract.d.ts +2 -2
  219. package/dist/sdk-tools.contract.js +800 -74
  220. package/dist/sdk-tools.contract.js.map +1 -1
  221. package/dist/tenant-bootstrap-seed.contract.d.ts +1101 -0
  222. package/dist/tenant-bootstrap-seed.contract.js +653 -0
  223. package/dist/tenant-bootstrap-seed.contract.js.map +1 -0
  224. package/dist/tenant-bootstrap-seed.defaults.d.ts +16 -0
  225. package/dist/tenant-bootstrap-seed.defaults.js +303 -0
  226. package/dist/tenant-bootstrap-seed.defaults.js.map +1 -0
  227. package/dist/tenant-client.contract.d.ts +349 -0
  228. package/dist/tenant-client.contract.js +488 -0
  229. package/dist/tenant-client.contract.js.map +1 -0
  230. package/dist/{tool-contracts-WCnuE9DW.d.ts → tool-contracts-BevD9Ho2.d.ts} +39 -3
  231. package/dist/tool-contracts.d.ts +1 -1
  232. package/dist/tool-contracts.js +801 -75
  233. package/dist/tool-contracts.js.map +1 -1
  234. package/dist/workflow-runtime.contract.js +1 -1
  235. package/dist/workflow-runtime.contract.js.map +1 -1
  236. package/package.json +27 -1
  237. package/dist/index-DoDXl8KS.d.ts +0 -19
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { z, ZodFirstPartyTypeKind } from 'zod';
2
+ import { v } from 'convex/values';
3
+ import { ALL_FUNCTION_CONTRACTS } from './function-registry/index.js';
2
4
  export * from './function-registry/index.js';
3
5
 
4
6
  var __defProp = Object.defineProperty;
@@ -223,6 +225,209 @@ function lastDelegator(delegationChain) {
223
225
  return delegationChain[delegationChain.length - 1]?.principalId;
224
226
  }
225
227
 
228
+ // src/generated/tableOwnership.ts
229
+ var TABLE_OWNERSHIP = {
230
+ "agentMessages": "K",
231
+ "agentRegistryEntries": "L",
232
+ "agents": "I",
233
+ "agentSessions": "K",
234
+ "apiKeys": "L",
235
+ "auditLog": "L",
236
+ "autofixJobs": "K",
237
+ "backgroundJobRuns": "K",
238
+ "backgroundJobSettings": "K",
239
+ "beliefConfidence": "K",
240
+ "beliefEvidenceLinks": "K",
241
+ "beliefHistory": "K",
242
+ "beliefScenarios": "K",
243
+ "beliefVotes": "K",
244
+ "calibrationScores": "K",
245
+ "compatibilityShims": "L",
246
+ "contractEvaluations": "K",
247
+ "contradictions": "K",
248
+ "controlPlaneTenantModelSlotBindings": "L",
249
+ "controlPlaneTenantProviderSecrets": "L",
250
+ "controlPlaneTenantProxyGatewayUsage": "L",
251
+ "controlPlaneToolAcls": "L",
252
+ "crossProjectConnections": "K",
253
+ "cutoverFlags": "L",
254
+ "decisionComputedSummaries": "K",
255
+ "decisionEvents": "K",
256
+ "decisionParticipants": "K",
257
+ "decisionRiskLedger": "K",
258
+ "decisionSnapshots": "K",
259
+ "deliberationContributions": "K",
260
+ "deliberationSessions": "K",
261
+ "epistemicAudit": "K",
262
+ "epistemicContracts": "K",
263
+ "epistemicEdges": "K",
264
+ "epistemicNodeEmbeddings": "K",
265
+ "epistemicNodes": "K",
266
+ "graphAnalysisCache": "K",
267
+ "graphAnalysisResults": "K",
268
+ "graphSuggestions": "K",
269
+ "groupMemberships": "L",
270
+ "groups": "L",
271
+ "harnessReplays": "K",
272
+ "harnessRuns": "K",
273
+ "idempotencyTokens": "K",
274
+ "lenses": "K",
275
+ "lensTopicBindings": "K",
276
+ "mcpWritePolicy": "I",
277
+ "memberships": "L",
278
+ "methodologyPacks": "L",
279
+ "modelCallLogs": "I",
280
+ "modelFunctionSlots": "I",
281
+ "modelRegistry": "I",
282
+ "modelSlotConfigs": "I",
283
+ "neo4jSyncQueue": "K",
284
+ "oauthDeviceCodes": "L",
285
+ "ontologyDefinitions": "K",
286
+ "ontologyVersions": "K",
287
+ "packAssignments": "L",
288
+ "packDefinitions": "L",
289
+ "packEntitlements": "L",
290
+ "packGroupAssignments": "L",
291
+ "packInstallations": "L",
292
+ "packVersions": "L",
293
+ "platformAgentRunPolicyDecisions": "K",
294
+ "platformAgentRunPromptResolutions": "K",
295
+ "platformAgentRuns": "K",
296
+ "platformAgentRunToolCalls": "K",
297
+ "platformAudienceGrants": "I",
298
+ "platformAudiences": "I",
299
+ "platformHarnessShadowAudit": "K",
300
+ "platformPolicyDecisionLogs": "I",
301
+ "policyBundles": "L",
302
+ "policyDecisionLogs": "L",
303
+ "policySimulations": "L",
304
+ "principals": "L",
305
+ "projectGrants": "I",
306
+ "publicationRules": "K",
307
+ "questionEvidenceLinks": "K",
308
+ "rateLimitWindows": "L",
309
+ "reasoningPermissions": "I",
310
+ "researchJobs": "K",
311
+ "schemaEnumConfig": "K",
312
+ "servicePrincipalKeys": "L",
313
+ "stakeholderGroups": "K",
314
+ "systemLogs": "K",
315
+ "tasks": "K",
316
+ "tenantApiKeys": "I",
317
+ "tenantConfig": "I",
318
+ "tenantDeploymentCredentials": "L",
319
+ "tenantIntegrations": "I",
320
+ "tenantMethodologyAssignments": "L",
321
+ "tenantModelSlotBindings": "I",
322
+ "tenantPolicies": "I",
323
+ "tenantProviderSecrets": "I",
324
+ "tenantProxyGatewayUsage": "I",
325
+ "tenantProxyTokenMints": "I",
326
+ "tenants": "L",
327
+ "tenantSandboxAuditEvents": "I",
328
+ "tenantSecrets": "I",
329
+ "toolAcls": "I",
330
+ "toolCatalog": "L",
331
+ "toolRegistry": "I",
332
+ "toolRegistryEntries": "L",
333
+ "topics": "K",
334
+ "users": "I",
335
+ "userSessions": "L",
336
+ "workflowDefinitions": "K",
337
+ "workflowPullRequests": "K",
338
+ "workflowStages": "K",
339
+ "workspaces": "L",
340
+ "worktreeBeliefCluster": "K",
341
+ "worktrees": "K"
342
+ };
343
+
344
+ // src/component-boundary.contract.ts
345
+ var COMPONENT_BOUNDARY_CONTRACT_VERSION = "2026-04-27";
346
+ var COMPONENT_BOUNDARY_COMPONENT_LAYERS = [
347
+ "I",
348
+ "K"
349
+ ];
350
+ var COMPONENT_BOUNDARY_DIRECT_DB_METHODS = [
351
+ "insert",
352
+ "patch",
353
+ "replace",
354
+ "delete",
355
+ "query"
356
+ ];
357
+ var COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS = [
358
+ "services",
359
+ "apps",
360
+ "convex"
361
+ ];
362
+ var COMPONENT_BOUNDARY_HIGH_RISK_TABLES = [
363
+ "backgroundJobRuns",
364
+ "backgroundJobSettings",
365
+ "systemLogs",
366
+ "epistemicAudit",
367
+ "platformPolicyDecisionLogs",
368
+ "tenantApiKeys",
369
+ "projectGrants",
370
+ "userSessions"
371
+ ];
372
+ function getComponentBoundaryTableLayer(tableName) {
373
+ return TABLE_OWNERSHIP[tableName];
374
+ }
375
+ function isComponentBoundaryComponentOwnedTable(tableName) {
376
+ const layer = getComponentBoundaryTableLayer(tableName);
377
+ return layer === "I" || layer === "K";
378
+ }
379
+
380
+ // src/component-host-boundary.contract.ts
381
+ var COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION = "2026-04-28";
382
+ var COMPONENT_HOST_PROTECTED_TABLES = [
383
+ "backgroundJobRuns",
384
+ "backgroundJobSettings",
385
+ "systemLogs",
386
+ "epistemicAudit",
387
+ "platformPolicyDecisionLogs",
388
+ "tenantApiKeys",
389
+ "projectGrants",
390
+ "userSessions"
391
+ ];
392
+ var COMPONENT_HOST_PROTECTED_TABLE_OWNERS = {
393
+ backgroundJobRuns: "kernel_component",
394
+ backgroundJobSettings: "kernel_component",
395
+ systemLogs: "kernel_component",
396
+ epistemicAudit: "reasoning_kernel_component",
397
+ platformPolicyDecisionLogs: "identity_component",
398
+ tenantApiKeys: "identity_component",
399
+ projectGrants: "identity_component",
400
+ userSessions: "tenant_or_control_plane_schema"
401
+ };
402
+ var COMPONENT_HOST_DB_WRITE_OPERATIONS = [
403
+ "insert",
404
+ "patch",
405
+ "replace",
406
+ "delete"
407
+ ];
408
+ var COMPONENT_HOST_DB_READ_OPERATIONS = ["query"];
409
+ var COMPONENT_HOST_WRITE_AUDIT_ROOTS = [
410
+ "apps/web/convex",
411
+ "packages/server-core/src",
412
+ "services/kernel-template/convex",
413
+ "services/identity-template/convex",
414
+ "services/master-control/convex"
415
+ ];
416
+ var COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS = [
417
+ {
418
+ file: "services/master-control/convex/userSessions.ts",
419
+ table: "userSessions",
420
+ operation: "insert",
421
+ reason: "Master Control declares and owns its own userSessions table for gateway session validation."
422
+ },
423
+ {
424
+ file: "services/master-control/convex/userSessions.ts",
425
+ table: "userSessions",
426
+ operation: "query",
427
+ reason: "Master Control declares and owns its own userSessions table for gateway session validation."
428
+ }
429
+ ];
430
+
226
431
  // src/gateway.contract.ts
227
432
  function requireActorPrincipalId(authContext) {
228
433
  const principalId = typeof authContext.principalId === "string" ? authContext.principalId.trim() : "";
@@ -232,6 +437,598 @@ function requireActorPrincipalId(authContext) {
232
437
  throw new Error("Access denied: federated principal context required.");
233
438
  }
234
439
 
440
+ // src/graph-intelligence.contract.ts
441
+ var GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION = "graph_intelligence_query_catalog.v1";
442
+ var GRAPH_INTELLIGENCE_QUERY_MODES = [
443
+ "core",
444
+ "bias",
445
+ "stress",
446
+ "operational",
447
+ "alpha",
448
+ "semantic",
449
+ "evidence"
450
+ ];
451
+ var GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES = [
452
+ "get_graph_structure_analysis",
453
+ "detect_confirmation_bias",
454
+ "get_graph_gaps",
455
+ "get_topic_coverage",
456
+ "find_contradictions",
457
+ "get_falsification_questions",
458
+ "search_beliefs",
459
+ "search_evidence",
460
+ "list_beliefs",
461
+ "list_questions",
462
+ "traverse_graph",
463
+ "query_lineage",
464
+ "get_graph_neighborhood"
465
+ ];
466
+ var GRAPH_INTELLIGENCE_MODE_TOOL_NAMES = {
467
+ core: [
468
+ "get_graph_structure_analysis",
469
+ "get_topic_coverage",
470
+ "get_graph_gaps",
471
+ "list_beliefs",
472
+ "list_questions",
473
+ "search_evidence"
474
+ ],
475
+ bias: [
476
+ "get_graph_structure_analysis",
477
+ "detect_confirmation_bias",
478
+ "find_contradictions",
479
+ "search_evidence",
480
+ "list_beliefs"
481
+ ],
482
+ stress: [
483
+ "get_graph_structure_analysis",
484
+ "get_graph_gaps",
485
+ "find_contradictions",
486
+ "get_falsification_questions",
487
+ "list_beliefs",
488
+ "list_questions"
489
+ ],
490
+ operational: [
491
+ "get_topic_coverage",
492
+ "get_graph_gaps",
493
+ "list_beliefs",
494
+ "list_questions",
495
+ "search_evidence"
496
+ ],
497
+ alpha: [
498
+ "get_graph_structure_analysis",
499
+ "detect_confirmation_bias",
500
+ "find_contradictions",
501
+ "search_beliefs",
502
+ "search_evidence"
503
+ ],
504
+ semantic: [
505
+ "get_graph_structure_analysis",
506
+ "search_beliefs",
507
+ "search_evidence",
508
+ "traverse_graph",
509
+ "query_lineage",
510
+ "get_graph_neighborhood"
511
+ ],
512
+ evidence: [
513
+ "get_graph_structure_analysis",
514
+ "get_topic_coverage",
515
+ "search_evidence",
516
+ "get_falsification_questions",
517
+ "find_contradictions"
518
+ ]
519
+ };
520
+ var GRAPH_INTELLIGENCE_QUERY_CATEGORIES = [
521
+ {
522
+ id: "problems",
523
+ name: "Find Problems",
524
+ description: "Risk, contradiction, bias, and structural weakness queries."
525
+ },
526
+ {
527
+ id: "gaps",
528
+ name: "Find Gaps",
529
+ description: "Missing evidence, unanswered questions, and sparse areas."
530
+ },
531
+ {
532
+ id: "reasoning",
533
+ name: "Reasoning Quality",
534
+ description: "Assumption chains, evidence convergence, and weak links."
535
+ },
536
+ {
537
+ id: "strategic",
538
+ name: "Strategic Analysis",
539
+ description: "Pre-mortems, falsification, contrarian signals, and bets."
540
+ },
541
+ {
542
+ id: "deep",
543
+ name: "Deep Graph Analysis",
544
+ description: "Centrality, propagation, underdetermination, and topology."
545
+ },
546
+ {
547
+ id: "browse",
548
+ name: "Browse and Explore",
549
+ description: "Narrative summaries, search, theme exploration, and bridges."
550
+ },
551
+ {
552
+ id: "prep",
553
+ name: "Meeting Prep",
554
+ description: "Company, entity, and question prep from graph context."
555
+ }
556
+ ];
557
+ var byMode = (mode) => GRAPH_INTELLIGENCE_MODE_TOOL_NAMES[mode];
558
+ var GRAPH_INTELLIGENCE_QUERIES = [
559
+ {
560
+ id: "confirmation-bias",
561
+ categoryId: "problems",
562
+ mode: "bias",
563
+ name: "Find Confirmation Bias",
564
+ description: "Find beliefs supported mainly by confirming evidence.",
565
+ prompt: "Find beliefs where supporting evidence overwhelms challenging evidence. Prioritize high-conviction beliefs with few defeaters.",
566
+ highlightStrategy: "bias-risk",
567
+ riskLevel: "high"
568
+ },
569
+ {
570
+ id: "contradiction-map",
571
+ categoryId: "problems",
572
+ mode: "stress",
573
+ name: "Map Contradictions",
574
+ description: "Surface direct and indirect contradiction clusters.",
575
+ prompt: "Map the graph's contradiction clusters and explain which tensions matter most.",
576
+ highlightStrategy: "contradictions",
577
+ riskLevel: "high"
578
+ },
579
+ {
580
+ id: "weak-evidence",
581
+ categoryId: "problems",
582
+ mode: "stress",
583
+ name: "Weak Evidence Chains",
584
+ description: "Find important claims with thin or indirect evidence.",
585
+ prompt: "Find high-importance beliefs whose evidence support is thin, indirect, stale, or low quality.",
586
+ highlightStrategy: "weak-support",
587
+ riskLevel: "medium"
588
+ },
589
+ {
590
+ id: "single-source",
591
+ categoryId: "problems",
592
+ mode: "bias",
593
+ name: "Single-Source Risk",
594
+ description: "Find claims overly dependent on one source or source type.",
595
+ prompt: "Identify beliefs that rely on a single source, one methodology, or one repeated perspective.",
596
+ highlightStrategy: "source-concentration",
597
+ riskLevel: "medium"
598
+ },
599
+ {
600
+ id: "untested-assumptions",
601
+ categoryId: "problems",
602
+ mode: "stress",
603
+ name: "Untested Assumptions",
604
+ description: "Find load-bearing assumptions without falsification paths.",
605
+ prompt: "Find assumptions that appear load-bearing but do not have direct testing questions or falsification evidence.",
606
+ highlightStrategy: "untested",
607
+ riskLevel: "high"
608
+ },
609
+ {
610
+ id: "load-bearing-beliefs",
611
+ categoryId: "problems",
612
+ mode: "stress",
613
+ name: "Load-Bearing Beliefs",
614
+ description: "Find central beliefs whose failure would affect many claims.",
615
+ prompt: "Find the beliefs with the largest downstream impact if they are wrong.",
616
+ highlightStrategy: "load-bearing",
617
+ riskLevel: "high"
618
+ },
619
+ {
620
+ id: "cascade-analysis",
621
+ categoryId: "problems",
622
+ mode: "stress",
623
+ name: "Cascade Analysis",
624
+ description: "Trace what changes if a belief is weakened or invalidated.",
625
+ prompt: "Analyze likely downstream cascades if the most central or uncertain beliefs are weakened.",
626
+ highlightStrategy: "cascade",
627
+ riskLevel: "high"
628
+ },
629
+ {
630
+ id: "unanswered-questions",
631
+ categoryId: "gaps",
632
+ mode: "operational",
633
+ name: "Unanswered Questions",
634
+ description: "Find important open questions that block confidence.",
635
+ prompt: "Identify the most important unanswered questions and explain which beliefs they block.",
636
+ highlightStrategy: "open-questions"
637
+ },
638
+ {
639
+ id: "thin-themes",
640
+ categoryId: "gaps",
641
+ mode: "operational",
642
+ name: "Thin Themes",
643
+ description: "Find topics with shallow belief or evidence coverage.",
644
+ prompt: "Find themes that look underdeveloped relative to their role in the graph.",
645
+ highlightStrategy: "thin-themes"
646
+ },
647
+ {
648
+ id: "missing-evidence",
649
+ categoryId: "gaps",
650
+ mode: "stress",
651
+ name: "Missing Evidence",
652
+ description: "Find beliefs that need specific missing evidence.",
653
+ prompt: "Find the most valuable missing evidence needed to strengthen or falsify the graph.",
654
+ highlightStrategy: "missing-evidence"
655
+ },
656
+ {
657
+ id: "isolated-clusters",
658
+ categoryId: "gaps",
659
+ mode: "operational",
660
+ name: "Isolated Clusters",
661
+ description: "Find clusters not connected to the broader graph.",
662
+ prompt: "Find isolated graph clusters and recommend bridge questions or bridge evidence.",
663
+ highlightStrategy: "isolated-clusters"
664
+ },
665
+ {
666
+ id: "source-contribution",
667
+ categoryId: "gaps",
668
+ mode: "evidence",
669
+ name: "Source Contribution",
670
+ description: "Assess how source mix shapes the graph.",
671
+ prompt: "Assess whether the source mix is balanced enough for the graph's strongest claims.",
672
+ highlightStrategy: "source-mix"
673
+ },
674
+ {
675
+ id: "stale-beliefs",
676
+ categoryId: "gaps",
677
+ mode: "operational",
678
+ name: "Stale Beliefs",
679
+ description: "Find beliefs that need review because they are old or stale.",
680
+ prompt: "Find beliefs that should be revisited because they are stale, unsupported by recent evidence, or contradicted by newer context.",
681
+ highlightStrategy: "staleness"
682
+ },
683
+ {
684
+ id: "assumption-pyramid",
685
+ categoryId: "reasoning",
686
+ mode: "operational",
687
+ name: "Assumption Pyramid",
688
+ description: "Show which conclusions rest on which assumptions.",
689
+ prompt: "Build an assumption pyramid from the graph: foundational assumptions, intermediate claims, and top-level conclusions.",
690
+ highlightStrategy: "assumptions"
691
+ },
692
+ {
693
+ id: "converging-evidence",
694
+ categoryId: "reasoning",
695
+ mode: "evidence",
696
+ name: "Converging Evidence",
697
+ description: "Find claims supported by independent evidence streams.",
698
+ prompt: "Find beliefs with genuinely independent converging evidence and explain why they are robust.",
699
+ highlightStrategy: "convergence"
700
+ },
701
+ {
702
+ id: "weakest-links",
703
+ categoryId: "reasoning",
704
+ mode: "stress",
705
+ name: "Weakest Links",
706
+ description: "Find the weakest links in important reasoning chains.",
707
+ prompt: "Find the weakest links in important reasoning chains and explain how to test them.",
708
+ highlightStrategy: "weak-links",
709
+ riskLevel: "medium"
710
+ },
711
+ {
712
+ id: "challenged-beliefs",
713
+ categoryId: "reasoning",
714
+ mode: "stress",
715
+ name: "Challenged Beliefs",
716
+ description: "Find beliefs with active challenges or defeaters.",
717
+ prompt: "Find beliefs with active challenges, contradiction edges, or unresolved defeaters.",
718
+ highlightStrategy: "challenged"
719
+ },
720
+ {
721
+ id: "contrarian-map",
722
+ categoryId: "strategic",
723
+ mode: "alpha",
724
+ name: "Contrarian Map",
725
+ description: "Find non-consensus beliefs and where they are grounded.",
726
+ prompt: "Find the graph's strongest contrarian or non-consensus beliefs and explain their support.",
727
+ highlightStrategy: "contrarian"
728
+ },
729
+ {
730
+ id: "irreversibility-audit",
731
+ categoryId: "strategic",
732
+ mode: "stress",
733
+ name: "Irreversibility Audit",
734
+ description: "Find irreversible bets and assumptions behind them.",
735
+ prompt: "Audit irreversible decisions or beliefs and identify what must be true before acting.",
736
+ highlightStrategy: "irreversible",
737
+ riskLevel: "high"
738
+ },
739
+ {
740
+ id: "pre-mortem",
741
+ categoryId: "strategic",
742
+ mode: "stress",
743
+ name: "Pre-Mortem",
744
+ description: "Explain how the graph could be wrong.",
745
+ prompt: "Run a pre-mortem: assume the current thesis fails and identify the most plausible failure paths.",
746
+ highlightStrategy: "failure-paths",
747
+ riskLevel: "high"
748
+ },
749
+ {
750
+ id: "devils-advocate",
751
+ categoryId: "strategic",
752
+ mode: "stress",
753
+ name: "Devil's Advocate",
754
+ description: "Generate the strongest critique of the graph.",
755
+ prompt: "Produce the strongest evidence-grounded critique of the current graph and its main thesis.",
756
+ highlightStrategy: "critique"
757
+ },
758
+ {
759
+ id: "falsification-map",
760
+ categoryId: "strategic",
761
+ mode: "stress",
762
+ name: "Falsification Map",
763
+ description: "Find the cheapest tests that would disprove key beliefs.",
764
+ prompt: "Map the cheapest, clearest falsification tests for the graph's key claims.",
765
+ highlightStrategy: "falsification",
766
+ riskLevel: "high"
767
+ },
768
+ {
769
+ id: "prediction-tracker",
770
+ categoryId: "strategic",
771
+ mode: "evidence",
772
+ name: "Prediction Tracker",
773
+ description: "Find beliefs that imply measurable predictions.",
774
+ prompt: "Find beliefs that imply measurable predictions and suggest tracking signals.",
775
+ highlightStrategy: "predictions"
776
+ },
777
+ {
778
+ id: "belief-pagerank",
779
+ categoryId: "deep",
780
+ mode: "semantic",
781
+ name: "Belief PageRank",
782
+ description: "Identify structurally central beliefs.",
783
+ prompt: "Use graph centrality to identify the most structurally important beliefs.",
784
+ highlightStrategy: "centrality"
785
+ },
786
+ {
787
+ id: "underdetermination",
788
+ categoryId: "deep",
789
+ mode: "semantic",
790
+ name: "Underdetermination",
791
+ description: "Find places where evidence supports multiple explanations.",
792
+ prompt: "Find places where the same evidence could support multiple incompatible explanations.",
793
+ highlightStrategy: "underdetermination"
794
+ },
795
+ {
796
+ id: "confidence-propagation",
797
+ categoryId: "deep",
798
+ mode: "semantic",
799
+ name: "Confidence Propagation",
800
+ description: "Assess how uncertainty moves through the graph.",
801
+ prompt: "Explain how uncertainty propagates from weak or contested beliefs through downstream conclusions.",
802
+ highlightStrategy: "confidence-flow"
803
+ },
804
+ {
805
+ id: "argument-depth",
806
+ categoryId: "deep",
807
+ mode: "evidence",
808
+ name: "Argument Depth",
809
+ description: "Assess reasoning depth and chain quality.",
810
+ prompt: "Assess reasoning depth: where claims are shallow, deeply supported, or overextended.",
811
+ highlightStrategy: "depth"
812
+ },
813
+ {
814
+ id: "information-edge",
815
+ categoryId: "deep",
816
+ mode: "alpha",
817
+ name: "Information Edge",
818
+ description: "Find differentiated evidence or signals.",
819
+ prompt: "Find evidence, sources, or beliefs that could represent differentiated information edge.",
820
+ highlightStrategy: "information-edge"
821
+ },
822
+ {
823
+ id: "thesis-summary",
824
+ categoryId: "browse",
825
+ mode: "semantic",
826
+ name: "Thesis Summary",
827
+ description: "Summarize the graph's core thesis and support.",
828
+ prompt: "Summarize the graph's core thesis, strongest support, weakest support, and open questions.",
829
+ highlightStrategy: "summary"
830
+ },
831
+ {
832
+ id: "theme-deep-dive",
833
+ categoryId: "browse",
834
+ mode: "semantic",
835
+ name: "Theme Deep Dive",
836
+ description: "Deep dive into a named theme.",
837
+ prompt: "Deep dive into {input}. Explain the key beliefs, evidence, contradictions, and open questions.",
838
+ inputType: "theme",
839
+ highlightStrategy: "theme"
840
+ },
841
+ {
842
+ id: "belief-detail",
843
+ categoryId: "browse",
844
+ mode: "semantic",
845
+ name: "Belief Detail",
846
+ description: "Explain one belief and its graph neighborhood.",
847
+ prompt: "Explain {input} and its support, challenges, related beliefs, and downstream implications.",
848
+ inputType: "belief",
849
+ highlightStrategy: "belief"
850
+ },
851
+ {
852
+ id: "strongest-beliefs",
853
+ categoryId: "browse",
854
+ mode: "operational",
855
+ name: "Strongest Beliefs",
856
+ description: "Find the graph's strongest current beliefs.",
857
+ prompt: "Find the strongest current beliefs and explain why each one deserves confidence.",
858
+ highlightStrategy: "strongest"
859
+ },
860
+ {
861
+ id: "cross-theme-connection",
862
+ categoryId: "browse",
863
+ mode: "semantic",
864
+ name: "Cross-Theme Connections",
865
+ description: "Find bridges between themes.",
866
+ prompt: "Find meaningful connections across themes and explain which bridge beliefs matter.",
867
+ highlightStrategy: "bridges"
868
+ },
869
+ {
870
+ id: "research-velocity",
871
+ categoryId: "browse",
872
+ mode: "operational",
873
+ name: "Research Velocity",
874
+ description: "Summarize recent graph movement and momentum.",
875
+ prompt: "Assess research velocity: what changed recently, where progress is fastest, and what is stuck.",
876
+ highlightStrategy: "velocity"
877
+ },
878
+ {
879
+ id: "search",
880
+ categoryId: "browse",
881
+ mode: "semantic",
882
+ name: "Graph Search",
883
+ description: "Search the graph with semantic context.",
884
+ prompt: "Search the graph for {input}. Return the most relevant beliefs, evidence, and questions.",
885
+ inputType: "search",
886
+ highlightStrategy: "search"
887
+ },
888
+ {
889
+ id: "expert-coverage",
890
+ categoryId: "browse",
891
+ mode: "semantic",
892
+ name: "Expert Coverage",
893
+ description: "Assess coverage from expert/source perspectives.",
894
+ prompt: "Assess whether the graph has enough expert, primary, and dissenting coverage.",
895
+ highlightStrategy: "expert-coverage"
896
+ },
897
+ {
898
+ id: "value-chain-map",
899
+ categoryId: "browse",
900
+ mode: "semantic",
901
+ name: "Value Chain Map",
902
+ description: "Map entities, dependencies, and value-chain logic.",
903
+ prompt: "Map the value chain implied by this graph: entities, dependencies, pressure points, and missing links.",
904
+ highlightStrategy: "value-chain"
905
+ },
906
+ {
907
+ id: "meeting-brief",
908
+ categoryId: "prep",
909
+ mode: "semantic",
910
+ name: "Meeting Brief",
911
+ description: "Prepare a meeting brief from graph context.",
912
+ prompt: "Prepare a concise meeting brief using the graph: thesis, open questions, risks, and recommended asks.",
913
+ highlightStrategy: "brief"
914
+ },
915
+ {
916
+ id: "open-questions-entity",
917
+ categoryId: "prep",
918
+ mode: "semantic",
919
+ name: "Entity Open Questions",
920
+ description: "Find open questions about a specific entity.",
921
+ prompt: "Find the most important open questions about {input} and the beliefs those questions would unlock.",
922
+ inputType: "entity",
923
+ highlightStrategy: "entity-questions"
924
+ },
925
+ {
926
+ id: "company-context",
927
+ categoryId: "prep",
928
+ mode: "semantic",
929
+ name: "Company Context",
930
+ description: "Summarize graph context about a company.",
931
+ prompt: "Summarize what the graph knows about {input}: thesis relevance, evidence, risks, and open questions.",
932
+ inputType: "company",
933
+ highlightStrategy: "company"
934
+ },
935
+ {
936
+ id: "company-theme-fit",
937
+ categoryId: "prep",
938
+ mode: "semantic",
939
+ name: "Company Theme Fit",
940
+ description: "Assess how a company fits graph themes.",
941
+ prompt: "Assess how {input} fits the graph's themes and where the fit is weak or uncertain.",
942
+ inputType: "company",
943
+ highlightStrategy: "fit"
944
+ },
945
+ {
946
+ id: "company-comparison",
947
+ categoryId: "prep",
948
+ mode: "semantic",
949
+ name: "Company Comparison",
950
+ description: "Compare companies through graph context.",
951
+ prompt: "Compare {input} using graph beliefs, evidence, risks, and open questions.",
952
+ inputType: "company-list",
953
+ highlightStrategy: "comparison"
954
+ },
955
+ {
956
+ id: "questions-to-ask",
957
+ categoryId: "prep",
958
+ mode: "operational",
959
+ name: "Questions to Ask",
960
+ description: "Generate high-signal questions from graph gaps.",
961
+ prompt: "Generate the highest-signal questions to ask next, grounded in current graph gaps.",
962
+ highlightStrategy: "questions"
963
+ },
964
+ {
965
+ id: "beliefs-to-test",
966
+ categoryId: "prep",
967
+ mode: "stress",
968
+ name: "Beliefs to Test",
969
+ description: "Prioritize beliefs that should be tested next.",
970
+ prompt: "Prioritize the beliefs that should be tested next and explain the cheapest test for each.",
971
+ highlightStrategy: "tests",
972
+ riskLevel: "medium"
973
+ }
974
+ ];
975
+ var GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS = GRAPH_INTELLIGENCE_QUERIES.map((query) => {
976
+ const definition = query;
977
+ return {
978
+ ...definition,
979
+ tools: definition.tools ?? byMode(definition.mode)
980
+ };
981
+ });
982
+ var GRAPH_INTELLIGENCE_QUICK_QUERIES = [
983
+ {
984
+ id: "health-check",
985
+ name: "Health Check",
986
+ queryId: "thesis-summary",
987
+ prompt: "Give me a fast graph health check: biggest strengths, biggest risks, and next best action."
988
+ },
989
+ {
990
+ id: "find-risks",
991
+ name: "Find Risks",
992
+ queryId: "weakest-links",
993
+ prompt: "Find the most important risks in this graph and the beliefs or evidence behind each one."
994
+ },
995
+ {
996
+ id: "pre-mortem",
997
+ name: "Pre-Mortem",
998
+ queryId: "pre-mortem",
999
+ prompt: "Assume this thesis fails. Explain the most plausible failure paths and what would reveal them early."
1000
+ },
1001
+ {
1002
+ id: "whats-next",
1003
+ name: "What's Next",
1004
+ queryId: "questions-to-ask",
1005
+ prompt: "What should I learn or test next to make this graph more useful?"
1006
+ }
1007
+ ];
1008
+ function isGraphIntelligenceQueryMode(value) {
1009
+ return typeof value === "string" && GRAPH_INTELLIGENCE_QUERY_MODES.includes(value);
1010
+ }
1011
+ function getGraphIntelligenceQuery(queryId) {
1012
+ return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.find(
1013
+ (query) => query.id === queryId
1014
+ );
1015
+ }
1016
+ function listGraphIntelligenceQueries(filter = {}) {
1017
+ return GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS.filter((query) => {
1018
+ if (filter.categoryId && query.categoryId !== filter.categoryId) {
1019
+ return false;
1020
+ }
1021
+ if (filter.mode && query.mode !== filter.mode) {
1022
+ return false;
1023
+ }
1024
+ return true;
1025
+ });
1026
+ }
1027
+ function fillGraphIntelligencePromptTemplate(prompt, input) {
1028
+ const replacement = input?.trim() || "the current topic";
1029
+ return prompt.split("{input}").join(replacement);
1030
+ }
1031
+
235
1032
  // src/context-pack.contract.ts
236
1033
  var CONTEXT_PACK_SCHEMA_VERSION = "1.0.0";
237
1034
  var CONTEXT_RANKING_PROFILES = [
@@ -711,9 +1508,6 @@ function encodeLiteral(value) {
711
1508
  }
712
1509
  return JSON.stringify(value);
713
1510
  }
714
- function quoteKey(value) {
715
- return JSON.stringify(value);
716
- }
717
1511
  function sortEntries(entries) {
718
1512
  return [...entries].sort(([left], [right]) => left.localeCompare(right));
719
1513
  }
@@ -876,7 +1670,7 @@ function convertSchemaInner(schema, state, path) {
876
1670
  convertSchema(value, state, [...path, key])
877
1671
  ]);
878
1672
  return {
879
- source: `v.object({ ${convertedFields.map(([key, converted]) => `${quoteKey(key)}: ${converted.source}`).join(", ")} })`,
1673
+ source: `v.object({ ${convertedFields.map(([key, converted]) => `${JSON.stringify(key)}: ${converted.source}`).join(", ")} })`,
880
1674
  defaults: convertedFields.flatMap(([, converted]) => converted.defaults)
881
1675
  };
882
1676
  }
@@ -920,6 +1714,9 @@ function convertSchemaInner(schema, state, path) {
920
1714
  case ZodFirstPartyTypeKind.ZodBranded: {
921
1715
  return convertSchema(schema._def.type, state, path);
922
1716
  }
1717
+ case ZodFirstPartyTypeKind.ZodEffects: {
1718
+ return convertSchema(schema._def.schema, state, path);
1719
+ }
923
1720
  default:
924
1721
  unsupported2(`Unsupported Zod schema kind ${schema._def.typeName}`, state, path);
925
1722
  }
@@ -1177,11 +1974,16 @@ function zodToJsonSchema(schema, options = {}) {
1177
1974
  var schemas_exports = {};
1178
1975
  __export(schemas_exports, {
1179
1976
  ALL_TABLE_CONTRACTS: () => ALL_TABLE_CONTRACTS,
1977
+ ComponentTableManifestSchema: () => ComponentTableManifestSchema,
1180
1978
  EDGE_TYPE: () => EDGE_TYPE,
1979
+ EDGE_TYPE_VALUES: () => EDGE_TYPE_VALUES,
1181
1980
  IDENTITY_TABLE_CONTRACTS: () => IDENTITY_TABLE_CONTRACTS,
1182
1981
  KERNEL_TABLE_CONTRACTS: () => KERNEL_TABLE_CONTRACTS,
1183
1982
  MC_TABLE_CONTRACTS: () => MC_TABLE_CONTRACTS,
1184
1983
  NODE_TYPE: () => NODE_TYPE,
1984
+ SLOpinionInputSchema: () => SLOpinionInputSchema,
1985
+ STORAGE_EDGE_TYPE: () => STORAGE_EDGE_TYPE,
1986
+ STORAGE_EDGE_TYPE_VALUES: () => STORAGE_EDGE_TYPE_VALUES,
1185
1987
  TABLE_CONTRACTS_BY_COMPONENT: () => TABLE_CONTRACTS_BY_COMPONENT,
1186
1988
  TOPIC_STATUS: () => TOPIC_STATUS,
1187
1989
  TOPIC_VISIBILITY: () => TOPIC_VISIBILITY,
@@ -1189,7 +1991,10 @@ __export(schemas_exports, {
1189
1991
  listTableContractsByName: () => listTableContractsByName
1190
1992
  });
1191
1993
  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"]);
1192
- 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"]);
1994
+ 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"];
1995
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
1996
+ var EDGE_TYPE = z.enum(EDGE_TYPE_VALUES);
1997
+ var STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);
1193
1998
  var TOPIC_STATUS = z.enum(["active", "archived", "watching"]);
1194
1999
  var TOPIC_VISIBILITY = z.enum(["private", "team", "firm", "external", "public"]);
1195
2000
  var agentMessages = defineTable({
@@ -1573,6 +2378,28 @@ var autofixJobs = defineTable({
1573
2378
  { kind: "index", name: "by_createdAt", columns: ["createdAt"] }
1574
2379
  ]
1575
2380
  });
2381
+ var neo4jSyncQueue = defineTable({
2382
+ name: "neo4jSyncQueue",
2383
+ component: "kernel",
2384
+ category: "infra",
2385
+ shape: z.object({
2386
+ "entityType": z.enum(["node", "edge"]),
2387
+ "entityId": z.string(),
2388
+ "operation": z.enum(["upsert", "delete"]),
2389
+ "attempts": z.number(),
2390
+ "maxAttempts": z.number(),
2391
+ "lastAttemptAt": z.number().optional(),
2392
+ "lastError": z.string().optional(),
2393
+ "status": z.enum(["pending", "in_progress", "failed", "succeeded"]),
2394
+ "createdAt": z.number(),
2395
+ "updatedAt": z.number()
2396
+ }),
2397
+ indices: [
2398
+ { kind: "index", name: "by_status", columns: ["status"] },
2399
+ { kind: "index", name: "by_entity", columns: ["entityType", "entityId"] },
2400
+ { kind: "index", name: "by_status_attempts", columns: ["status", "attempts"] }
2401
+ ]
2402
+ });
1576
2403
  var backgroundJobRuns = defineTable({
1577
2404
  name: "backgroundJobRuns",
1578
2405
  component: "kernel",
@@ -1642,9 +2469,9 @@ var beliefConfidence = defineTable({
1642
2469
  category: "epistemic",
1643
2470
  shape: z.object({
1644
2471
  "beliefId": z.string(),
1645
- "belief": z.number().optional(),
1646
- "disbelief": z.number().optional(),
1647
- "uncertainty": z.number().optional(),
2472
+ "belief": z.number(),
2473
+ "disbelief": z.number(),
2474
+ "uncertainty": z.number(),
1648
2475
  "baseRate": z.number(),
1649
2476
  "slOperator": z.string().optional(),
1650
2477
  "confidence": z.number(),
@@ -1653,10 +2480,12 @@ var beliefConfidence = defineTable({
1653
2480
  "certainty": z.number().optional(),
1654
2481
  "assessedAt": z.number(),
1655
2482
  "assessedBy": z.string(),
1656
- "trigger": z.enum(["initial", "evidence_added", "evidence_removed", "contradiction_detected", "contradiction_resolved", "manual", "decay", "propagation", "agent_assessment", "worktree_outcome", "worktree_completed", "fusion", "discount", "deduction", "backfill_synthetic"]),
2483
+ "trigger": z.enum(["initial", "evidence_added", "evidence_removed", "contradiction_detected", "contradiction_resolved", "propagation", "agent_assessment", "worktree_outcome", "worktree_completed", "fusion", "discount", "deduction", "backfill_synthetic"]),
1657
2484
  "rationale": z.string().optional(),
1658
2485
  "triggeringEvidenceId": z.string().optional(),
1659
2486
  "triggeringEvidenceIds": z.array(z.string()).optional(),
2487
+ "triggeringQuestionId": z.string().optional(),
2488
+ "triggeringAnswerId": z.string().optional(),
1660
2489
  "triggeringContradictionId": idOf("contradictions").optional(),
1661
2490
  "triggeringWorktreeId": z.string().optional(),
1662
2491
  "triggeringAgentId": z.string().optional(),
@@ -2339,7 +3168,7 @@ var tenantDeploymentCredentials = defineTable({
2339
3168
  "credentialRef": z.string(),
2340
3169
  "tenantId": idOf("tenants"),
2341
3170
  "target": z.enum(["kernelDeployment", "appDeployment"]),
2342
- "environment": z.enum(["dev", "prod"]),
3171
+ "environment": z.enum(["dev", "staging", "prod"]),
2343
3172
  "encryptedDeployKey": z.string(),
2344
3173
  "encryptionVersion": z.string(),
2345
3174
  "keyFingerprint": z.string(),
@@ -2650,7 +3479,7 @@ var epistemicEdges = defineTable({
2650
3479
  "toNodeId": z.string().optional(),
2651
3480
  "sourceGlobalId": z.string().optional(),
2652
3481
  "targetGlobalId": z.string().optional(),
2653
- "edgeType": EDGE_TYPE,
3482
+ "edgeType": STORAGE_EDGE_TYPE,
2654
3483
  "edgeTier": z.string().optional(),
2655
3484
  "domainNamespace": z.string().optional(),
2656
3485
  "constraint": z.string().optional(),
@@ -2993,6 +3822,40 @@ var rateLimitWindows = defineTable({
2993
3822
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
2994
3823
  ]
2995
3824
  });
3825
+ var oauthDeviceCodes = defineTable({
3826
+ name: "oauthDeviceCodes",
3827
+ component: "mc",
3828
+ category: "identity",
3829
+ shape: z.object({
3830
+ "deviceCodeHash": z.string(),
3831
+ "userCode": z.string(),
3832
+ "clientId": z.string(),
3833
+ "scope": z.string(),
3834
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
3835
+ "expiresAt": z.number(),
3836
+ "intervalSeconds": z.number(),
3837
+ "lastPolledAt": z.number().optional(),
3838
+ "slowDownCount": z.number().optional(),
3839
+ "clerkUserId": z.string().optional(),
3840
+ "tenantId": idOf("tenants").optional(),
3841
+ "workspaceId": z.string().optional(),
3842
+ "principalId": z.string().optional(),
3843
+ "role": z.string().optional(),
3844
+ "scopes": z.array(z.string()).optional(),
3845
+ "sessionId": z.string().optional(),
3846
+ "approvedAt": z.number().optional(),
3847
+ "deniedAt": z.number().optional(),
3848
+ "consumedAt": z.number().optional(),
3849
+ "createdAt": z.number(),
3850
+ "updatedAt": z.number()
3851
+ }),
3852
+ indices: [
3853
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
3854
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
3855
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
3856
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
3857
+ ]
3858
+ });
2996
3859
  var servicePrincipalKeys = defineTable({
2997
3860
  name: "servicePrincipalKeys",
2998
3861
  component: "mc",
@@ -4825,6 +5688,7 @@ var topics = defineTable({
4825
5688
  "updatedAt": z.number()
4826
5689
  }),
4827
5690
  indices: [
5691
+ { kind: "index", name: "by_globalId", columns: ["globalId"] },
4828
5692
  { kind: "index", name: "by_parent", columns: ["parentTopicId"] },
4829
5693
  { kind: "index", name: "by_type", columns: ["type"] },
4830
5694
  { kind: "index", name: "by_graph_scope_project", columns: ["graphScopeProjectId"] },
@@ -4949,7 +5813,9 @@ var workspaces = defineTable({
4949
5813
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
4950
5814
  "deployments": z.record(z.object({
4951
5815
  "url": z.string(),
4952
- "encryptedDeployKey": z.string()
5816
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
5817
+ "encryptedDeployKey": z.string().optional(),
5818
+ "credentialRef": z.string().optional()
4953
5819
  })).optional(),
4954
5820
  "metadata": z.record(z.any()).optional(),
4955
5821
  "createdBy": z.string().optional(),
@@ -5008,13 +5874,13 @@ var worktrees = defineTable({
5008
5874
  "rationale": z.string().optional(),
5009
5875
  "confidenceImpact": z.enum(["high", "medium", "low"]).optional(),
5010
5876
  "hypothesis": z.string().optional(),
5011
- "executionOrder": z.number().optional(),
5012
5877
  "dependsOn": z.array(idOf("worktrees")).optional(),
5013
5878
  "blocks": z.array(idOf("worktrees")).optional(),
5014
5879
  "gate": z.string().optional(),
5015
- "track": z.string().optional(),
5016
- "trackPosition": z.number().optional(),
5017
- "executionBand": z.number().optional(),
5880
+ "campaign": z.number().optional(),
5881
+ "lane": z.string().optional(),
5882
+ "laneOrderInCampaign": z.number().optional(),
5883
+ "orderInLane": z.number().optional(),
5018
5884
  "startDate": z.number(),
5019
5885
  "endDate": z.number(),
5020
5886
  "durationWeeks": z.number(),
@@ -5262,6 +6128,8 @@ var worktrees = defineTable({
5262
6128
  { kind: "index", name: "by_topicId_index", columns: ["topicId", "index"] },
5263
6129
  { kind: "index", name: "by_worktreeType", columns: ["topicId", "worktreeType"] },
5264
6130
  { kind: "index", name: "by_topicId_priority", columns: ["topicId", "priority"] },
6131
+ { kind: "index", name: "by_topicId_campaign_lane_order", columns: ["topicId", "campaign", "laneOrderInCampaign", "orderInLane"] },
6132
+ { kind: "index", name: "by_topicId_lane_order", columns: ["topicId", "lane", "orderInLane"] },
5265
6133
  { kind: "index", name: "by_topicId_branch", columns: ["topicId", "targetBranch"] },
5266
6134
  { kind: "index", name: "by_topicId_scope", columns: ["topicId", "worktreeScope"] }
5267
6135
  ]
@@ -5294,6 +6162,7 @@ var KERNEL_TABLE_CONTRACTS = [
5294
6162
  questionEvidenceLinks,
5295
6163
  idempotencyTokens,
5296
6164
  autofixJobs,
6165
+ neo4jSyncQueue,
5297
6166
  backgroundJobRuns,
5298
6167
  backgroundJobSettings,
5299
6168
  systemLogs,
@@ -5354,6 +6223,7 @@ var MC_TABLE_CONTRACTS = [
5354
6223
  groupMemberships,
5355
6224
  groups,
5356
6225
  memberships,
6226
+ oauthDeviceCodes,
5357
6227
  principals,
5358
6228
  rateLimitWindows,
5359
6229
  servicePrincipalKeys,
@@ -5403,71 +6273,1271 @@ function getTableContract(name, component) {
5403
6273
  (contract) => contract.name === name && (component ? contract.component === component : true)
5404
6274
  );
5405
6275
  }
6276
+ var ComponentTableManifestSchema = z.object({
6277
+ manifestVersion: z.string(),
6278
+ componentName: z.enum(["kernel", "identity"]),
6279
+ tier: z.enum(["K", "I"]),
6280
+ packageVersion: z.string(),
6281
+ tables: z.array(
6282
+ z.object({
6283
+ name: z.string(),
6284
+ fields: z.array(
6285
+ z.object({
6286
+ name: z.string(),
6287
+ type: z.string(),
6288
+ optional: z.boolean(),
6289
+ validator: z.string().optional()
6290
+ })
6291
+ )
6292
+ })
6293
+ )
6294
+ });
6295
+ var SL_EPSILON = 1e-9;
6296
+ var SLOpinionInputSchema = z.object({
6297
+ belief: z.number(),
6298
+ disbelief: z.number(),
6299
+ uncertainty: z.number(),
6300
+ baseRate: z.number()
6301
+ }).refine(
6302
+ (o) => Math.abs(o.belief + o.disbelief + o.uncertainty - 1) < SL_EPSILON,
6303
+ {
6304
+ message: "SL invariant b+d+u=1 violated at API boundary"
6305
+ }
6306
+ );
5406
6307
 
5407
- // src/tool-contracts.ts
5408
- var tool_contracts_exports = {};
5409
- __export(tool_contracts_exports, {
5410
- ACTIVATE_WORKTREE: () => ACTIVATE_WORKTREE,
5411
- ADD_EVIDENCE: () => ADD_EVIDENCE,
5412
- ADD_WORKTREE: () => ADD_WORKTREE,
5413
- ANALYZE_TOPIC_DENSITY: () => ANALYZE_TOPIC_DENSITY,
5414
- ANSWER_QUESTION: () => ANSWER_QUESTION,
5415
- APPLY_AUTO_BRANCHING: () => APPLY_AUTO_BRANCHING,
5416
- APPLY_LENS_TO_TOPIC: () => APPLY_LENS_TO_TOPIC,
5417
- APPLY_ONTOLOGY: () => APPLY_ONTOLOGY,
5418
- ARCHIVE_BELIEF: () => ARCHIVE_BELIEF,
5419
- ARCHIVE_ONTOLOGY: () => ARCHIVE_ONTOLOGY,
5420
- ARCHIVE_QUESTION: () => ARCHIVE_QUESTION,
5421
- BISECT_CONFIDENCE: () => BISECT_CONFIDENCE,
5422
- BROADCAST_MESSAGE: () => BROADCAST_MESSAGE,
5423
- CHECK_PERMISSION: () => CHECK_PERMISSION,
5424
- CLAIM_FILES: () => CLAIM_FILES,
5425
- COMPILE_CONTEXT: () => COMPILE_CONTEXT,
5426
- COMPLETE_TASK: () => COMPLETE_TASK,
5427
- CREATE_ANSWER: () => CREATE_ANSWER,
5428
- CREATE_BELIEF: () => CREATE_BELIEF,
5429
- CREATE_EDGE: () => CREATE_EDGE,
5430
- CREATE_EPISTEMIC_CONTRACT: () => CREATE_EPISTEMIC_CONTRACT,
5431
- CREATE_EVIDENCE: () => CREATE_EVIDENCE,
5432
- CREATE_LENS: () => CREATE_LENS,
5433
- CREATE_ONTOLOGY: () => CREATE_ONTOLOGY,
5434
- CREATE_ONTOLOGY_VERSION: () => CREATE_ONTOLOGY_VERSION,
5435
- CREATE_QUESTION: () => CREATE_QUESTION,
5436
- CREATE_TASK: () => CREATE_TASK,
5437
- CREATE_TOPIC: () => CREATE_TOPIC,
5438
- DEPRECATE_ONTOLOGY_VERSION: () => DEPRECATE_ONTOLOGY_VERSION,
5439
- DETECT_CONFIRMATION_BIAS: () => DETECT_CONFIRMATION_BIAS,
5440
- DISCOVER: () => DISCOVER,
5441
- DISCOVER_ENTITY_CONNECTIONS: () => DISCOVER_ENTITY_CONNECTIONS,
5442
- END_SESSION: () => END_SESSION,
5443
- EVALUATE_CONTRACT: () => EVALUATE_CONTRACT,
5444
- FILTER_BY_PERMISSION: () => FILTER_BY_PERMISSION,
5445
- FIND_CONTRADICTIONS: () => FIND_CONTRADICTIONS,
5446
- FIND_MISSING_QUESTIONS: () => FIND_MISSING_QUESTIONS,
5447
- FLAG_CONTRADICTION: () => FLAG_CONTRADICTION,
5448
- FORK_BELIEF: () => FORK_BELIEF,
5449
- GENERATE_SESSION_HANDOFF: () => GENERATE_SESSION_HANDOFF,
5450
- GET_AGENT_INBOX: () => GET_AGENT_INBOX,
5451
- GET_ANSWER: () => GET_ANSWER,
5452
- GET_AUDIT_TRAIL: () => GET_AUDIT_TRAIL,
5453
- GET_BELIEF: () => GET_BELIEF,
5454
- GET_CHANGE_HISTORY: () => GET_CHANGE_HISTORY,
5455
- GET_CODE_CONTEXT: () => GET_CODE_CONTEXT,
5456
- GET_CONFIDENCE_HISTORY: () => GET_CONFIDENCE_HISTORY,
5457
- GET_CONTRACT_STATUS: () => GET_CONTRACT_STATUS,
5458
- GET_EVIDENCE: () => GET_EVIDENCE,
5459
- GET_FAILURE_LOG: () => GET_FAILURE_LOG,
5460
- GET_FALSIFICATION_QUESTIONS: () => GET_FALSIFICATION_QUESTIONS,
5461
- GET_GRAPH_GAPS: () => GET_GRAPH_GAPS,
5462
- GET_GRAPH_NEIGHBORHOOD: () => GET_GRAPH_NEIGHBORHOOD,
5463
- GET_GRAPH_STRUCTURE_ANALYSIS: () => GET_GRAPH_STRUCTURE_ANALYSIS,
5464
- GET_HIGH_PRIORITY_QUESTIONS: () => GET_HIGH_PRIORITY_QUESTIONS,
5465
- GET_LATTICE_COVERAGE: () => GET_LATTICE_COVERAGE,
5466
- GET_OBSERVATION_CONTEXT: () => GET_OBSERVATION_CONTEXT,
5467
- GET_ONTOLOGY: () => GET_ONTOLOGY,
5468
- GET_QUESTION: () => GET_QUESTION,
5469
- GET_TOPIC: () => GET_TOPIC,
6308
+ // src/schema-helpers/spine/tables/epistemicNodes.ts
6309
+ var NODE_TYPES = [
6310
+ "decision",
6311
+ "belief",
6312
+ "question",
6313
+ "theme",
6314
+ "deal",
6315
+ "topic",
6316
+ "claim",
6317
+ "evidence",
6318
+ "synthesis",
6319
+ "answer",
6320
+ "atomic_fact",
6321
+ "excerpt",
6322
+ "source",
6323
+ "company",
6324
+ "person",
6325
+ "investor",
6326
+ "function",
6327
+ "value_chain"
6328
+ ];
6329
+ new Set(NODE_TYPES);
6330
+
6331
+ // src/types/graph-ref.ts
6332
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
6333
+ "edge",
6334
+ "ontology",
6335
+ "lens",
6336
+ "contradiction"
6337
+ ];
6338
+ var GRAPH_REF_NODE_TYPES = [
6339
+ ...NODE_TYPES,
6340
+ ...GRAPH_REF_EXTRA_NODE_TYPES
6341
+ ];
6342
+ var EpistemicNodeTypeSchema = z.enum(
6343
+ GRAPH_REF_NODE_TYPES
6344
+ );
6345
+ var GraphRefSchema = z.discriminatedUnion("kind", [
6346
+ z.object({
6347
+ kind: z.literal("epistemic_node"),
6348
+ nodeId: z.string(),
6349
+ nodeType: EpistemicNodeTypeSchema
6350
+ }),
6351
+ z.object({
6352
+ kind: z.literal("external_belief"),
6353
+ ref: z.object({
6354
+ tenantId: z.string(),
6355
+ beliefId: z.string()
6356
+ })
6357
+ })
6358
+ ]);
6359
+ var graphRefKind = z.enum(["epistemic_node", "external_belief"]);
6360
+ var EdgePolicyEntrySchema = z.object({
6361
+ edgeType: z.string(),
6362
+ fromKinds: z.array(graphRefKind),
6363
+ fromNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
6364
+ toKinds: z.array(graphRefKind),
6365
+ toNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
6366
+ description: z.string()
6367
+ });
6368
+ var EdgePolicyManifestSchema = z.object({
6369
+ manifestVersion: z.literal("1.0.0"),
6370
+ policies: z.array(EdgePolicyEntrySchema)
6371
+ });
6372
+ function findEdgePolicy(manifest, edgeType) {
6373
+ return manifest.policies.find((policy) => policy.edgeType === edgeType);
6374
+ }
6375
+ function nodeTypeAllowed(allowed, ref) {
6376
+ return ref.kind !== "epistemic_node" || !allowed || allowed.includes(ref.nodeType);
6377
+ }
6378
+ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
6379
+ const policy = findEdgePolicy(manifest, edgeType);
6380
+ const allowed = Boolean(policy) && policy.fromKinds.includes(from.kind) && policy.toKinds.includes(to.kind) && nodeTypeAllowed(policy.fromNodeTypes, from) && nodeTypeAllowed(policy.toNodeTypes, to);
6381
+ if (!allowed) {
6382
+ const error = new Error(
6383
+ `Edge policy violation for ${edgeType}: ${from.kind} -> ${to.kind}`
6384
+ );
6385
+ error.code = "POLICY_VIOLATION";
6386
+ error.details = { code: "POLICY_VIOLATION", edgeType, from, to };
6387
+ throw error;
6388
+ }
6389
+ }
6390
+
6391
+ // src/manifests/edge-policy-manifest.data.ts
6392
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
6393
+ edgeType,
6394
+ fromKinds: ["epistemic_node"],
6395
+ toKinds: ["epistemic_node"],
6396
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
6397
+ });
6398
+ var edgePolicyManifest = {
6399
+ manifestVersion: "1.0.0",
6400
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
6401
+ };
6402
+
6403
+ // src/tenant-client.contract.ts
6404
+ var TENANT_CLIENT_CONTRACT_VERSION = "2026-04-27";
6405
+ var TENANT_CLIENT_AUTH_MODES = [
6406
+ "interactive_user",
6407
+ "service_principal",
6408
+ "tenant_api_key",
6409
+ "session_token"
6410
+ ];
6411
+ var TENANT_CLIENT_PRINCIPAL_TYPES = [
6412
+ "human",
6413
+ "service",
6414
+ "agent"
6415
+ ];
6416
+ var TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS = [
6417
+ "tenantId",
6418
+ "workspaceId",
6419
+ "principalId",
6420
+ "authMode",
6421
+ "scopes"
6422
+ ];
6423
+ var TENANT_CLIENT_OPTIONAL_CONTEXT_FIELDS = [
6424
+ "principalType",
6425
+ "roles",
6426
+ "sessionId",
6427
+ "delegationChain"
6428
+ ];
6429
+ var TENANT_CLIENT_INSTALL_TOKEN_ENV = "INSTALL_LUCERN_NPM";
6430
+ var TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH = "tenants/shared";
6431
+ var TENANT_CLIENT_FORBIDDEN_INSTALL_TOKEN_INFISICAL_PATHS = [
6432
+ "/platform/publish"
6433
+ ];
6434
+ var TENANT_CLIENT_FORBIDDEN_SECRET_ENV = ["NPM_TOKEN"];
6435
+ var TENANT_CLIENT_INSTALLABLE_PACKAGES = [
6436
+ {
6437
+ packageName: "@lucern/access-control",
6438
+ role: "runtime_entrypoint",
6439
+ directTenantImport: true
6440
+ },
6441
+ {
6442
+ packageName: "@lucern/agent",
6443
+ role: "platform_runtime",
6444
+ directTenantImport: false
6445
+ },
6446
+ {
6447
+ packageName: "@lucern/auth",
6448
+ role: "sdk_dependency",
6449
+ directTenantImport: false
6450
+ },
6451
+ {
6452
+ packageName: "@lucern/cli",
6453
+ role: "developer_tool",
6454
+ directTenantImport: false
6455
+ },
6456
+ {
6457
+ packageName: "@lucern/client-core",
6458
+ role: "sdk_dependency",
6459
+ directTenantImport: false
6460
+ },
6461
+ {
6462
+ packageName: "@lucern/confidence",
6463
+ role: "sdk_dependency",
6464
+ directTenantImport: false
6465
+ },
6466
+ {
6467
+ packageName: "@lucern/config",
6468
+ role: "configuration",
6469
+ directTenantImport: false
6470
+ },
6471
+ {
6472
+ packageName: "@lucern/contracts",
6473
+ role: "contract_entrypoint",
6474
+ directTenantImport: true
6475
+ },
6476
+ {
6477
+ packageName: "@lucern/control-plane",
6478
+ role: "platform_runtime",
6479
+ directTenantImport: false
6480
+ },
6481
+ {
6482
+ packageName: "@lucern/developer-kit",
6483
+ role: "developer_tool",
6484
+ directTenantImport: false
6485
+ },
6486
+ {
6487
+ packageName: "@lucern/events",
6488
+ role: "sdk_dependency",
6489
+ directTenantImport: false
6490
+ },
6491
+ {
6492
+ packageName: "@lucern/graph-primitives",
6493
+ role: "sdk_dependency",
6494
+ directTenantImport: false
6495
+ },
6496
+ {
6497
+ packageName: "@lucern/graph-sync",
6498
+ role: "host_addon_runtime",
6499
+ directTenantImport: true
6500
+ },
6501
+ {
6502
+ packageName: "@lucern/identity",
6503
+ role: "component_runtime",
6504
+ directTenantImport: false
6505
+ },
6506
+ {
6507
+ packageName: "@lucern/mcp",
6508
+ role: "runtime_entrypoint",
6509
+ directTenantImport: true
6510
+ },
6511
+ {
6512
+ packageName: "@lucern/pack-host",
6513
+ role: "platform_runtime",
6514
+ directTenantImport: false
6515
+ },
6516
+ {
6517
+ packageName: "@lucern/pack-installer",
6518
+ role: "developer_tool",
6519
+ directTenantImport: false
6520
+ },
6521
+ {
6522
+ packageName: "@lucern/proof-compiler",
6523
+ role: "developer_tool",
6524
+ directTenantImport: false
6525
+ },
6526
+ {
6527
+ packageName: "@lucern/react",
6528
+ role: "runtime_entrypoint",
6529
+ directTenantImport: true
6530
+ },
6531
+ {
6532
+ packageName: "@lucern/reasoning-kernel",
6533
+ role: "component_runtime",
6534
+ directTenantImport: false
6535
+ },
6536
+ {
6537
+ packageName: "@lucern/sdk",
6538
+ role: "runtime_entrypoint",
6539
+ directTenantImport: true
6540
+ },
6541
+ {
6542
+ packageName: "@lucern/server-core",
6543
+ role: "platform_runtime",
6544
+ directTenantImport: false
6545
+ },
6546
+ {
6547
+ packageName: "@lucern/testing",
6548
+ role: "test_support",
6549
+ directTenantImport: false
6550
+ },
6551
+ {
6552
+ packageName: "@lucern/types",
6553
+ role: "contract_entrypoint",
6554
+ directTenantImport: true
6555
+ }
6556
+ ];
6557
+ var TENANT_CLIENT_FULL_SUITE_PACKAGE_NAMES = TENANT_CLIENT_INSTALLABLE_PACKAGES.map(
6558
+ (entry) => entry.packageName
6559
+ );
6560
+ var TENANT_CLIENT_INSTALL_PROFILES = [
6561
+ {
6562
+ id: "core_app_runtime",
6563
+ description: "Smallest tenant app/runtime install for typed Lucern API calls plus tool-access policy helpers.",
6564
+ packageNames: ["@lucern/sdk", "@lucern/access-control"],
6565
+ dependencyField: "dependencies"
6566
+ },
6567
+ {
6568
+ id: "react_app_runtime",
6569
+ description: "React tenant app install for hooks, provider, curated graph components, and direct SDK calls.",
6570
+ packageNames: ["@lucern/react", "@lucern/sdk", "@lucern/access-control"],
6571
+ dependencyField: "dependencies"
6572
+ },
6573
+ {
6574
+ id: "convex_components",
6575
+ description: "Tenant Convex host install for binding the Lucern identity and reasoning-kernel components.",
6576
+ packageNames: ["@lucern/identity", "@lucern/reasoning-kernel"],
6577
+ dependencyField: "dependencies"
6578
+ },
6579
+ {
6580
+ id: "graph_mirroring_addon",
6581
+ description: "Optional tenant Convex host install for Neo4j graph projection, edge topology writes, backfill, health checks, and query proxy helpers.",
6582
+ packageNames: ["@lucern/graph-sync"],
6583
+ dependencyField: "dependencies"
6584
+ },
6585
+ {
6586
+ id: "operator_cli",
6587
+ description: "Developer/operator install for the `lucern` binary, including tenant bootstrap seed commands.",
6588
+ packageNames: ["@lucern/cli"],
6589
+ dependencyField: "devDependencies"
6590
+ },
6591
+ {
6592
+ id: "mcp_runtime",
6593
+ description: "Agent runtime install for the standalone Lucern MCP server and hosted route helpers.",
6594
+ packageNames: ["@lucern/mcp"],
6595
+ dependencyField: "dependencies"
6596
+ },
6597
+ {
6598
+ id: "contracts_and_types",
6599
+ description: "Compile-time contract/type install for codegen, audits, and tenant integration validation.",
6600
+ packageNames: ["@lucern/contracts", "@lucern/types"],
6601
+ dependencyField: "dependencies"
6602
+ },
6603
+ {
6604
+ id: "full_suite",
6605
+ description: "Full coherent Lucern package suite for design-partner repos that want every published runtime, tool, component, test, and config package pinned together.",
6606
+ packageNames: TENANT_CLIENT_FULL_SUITE_PACKAGE_NAMES,
6607
+ dependencyField: "mixed"
6608
+ }
6609
+ ];
6610
+ var TENANT_CLIENT_PUBLIC_IMPORTS = [
6611
+ {
6612
+ packageName: "@lucern/sdk",
6613
+ surface: "runtime",
6614
+ subpaths: "published_exports",
6615
+ description: "TypeScript SDK runtime and generated operation namespaces."
6616
+ },
6617
+ {
6618
+ packageName: "@lucern/react",
6619
+ surface: "runtime",
6620
+ subpaths: "published_exports",
6621
+ description: "React bindings for tenant-owned UI applications."
6622
+ },
6623
+ {
6624
+ packageName: "@lucern/mcp",
6625
+ surface: "runtime",
6626
+ subpaths: "published_exports",
6627
+ description: "MCP client/server entry points and hosted route helpers."
6628
+ },
6629
+ {
6630
+ packageName: "@lucern/graph-sync",
6631
+ surface: "runtime",
6632
+ subpaths: "published_exports",
6633
+ description: "Optional Neo4j graph mirroring host actions, edge API, query proxy, backfill, and health helpers."
6634
+ },
6635
+ {
6636
+ packageName: "@lucern/contracts",
6637
+ surface: "contract",
6638
+ subpaths: "published_exports",
6639
+ description: "Published type and manifest contracts."
6640
+ },
6641
+ {
6642
+ packageName: "@lucern/access-control",
6643
+ surface: "runtime",
6644
+ subpaths: "published_exports",
6645
+ description: "Tenant runtime access-control helpers, including effective tool access."
6646
+ },
6647
+ {
6648
+ packageName: "@lucern/types",
6649
+ surface: "contract",
6650
+ subpaths: "published_exports",
6651
+ description: "Published type-only helpers for tenant integration code."
6652
+ }
6653
+ ];
6654
+ var TENANT_CLIENT_COMPONENT_CONFIG_IMPORTS = [
6655
+ {
6656
+ packageName: "@lucern/identity",
6657
+ importPath: "@lucern/identity/convex.config",
6658
+ surface: "component_config",
6659
+ description: "Convex component binding config for tenant deployments that install Lucern identity."
6660
+ },
6661
+ {
6662
+ packageName: "@lucern/reasoning-kernel",
6663
+ importPath: "@lucern/reasoning-kernel/convex.config",
6664
+ surface: "component_config",
6665
+ description: "Convex component binding config for tenant deployments that install the Lucern reasoning kernel."
6666
+ },
6667
+ {
6668
+ packageName: "@lucern/reasoning-kernel",
6669
+ importPath: "@lucern/reasoning-kernel/runtime.config",
6670
+ surface: "component_config",
6671
+ description: "Runtime config alias for tenant deployments that install the Lucern reasoning kernel."
6672
+ }
6673
+ ];
6674
+ function findTenantClientInstallablePackage(packageName) {
6675
+ return TENANT_CLIENT_INSTALLABLE_PACKAGES.find(
6676
+ (entry) => entry.packageName === packageName
6677
+ );
6678
+ }
6679
+ function isTenantClientInstallablePackage(packageName) {
6680
+ return Boolean(findTenantClientInstallablePackage(packageName));
6681
+ }
6682
+ var TENANT_CLIENT_REQUIRED_SDK_NAMESPACES = [
6683
+ "bootstrap",
6684
+ "context",
6685
+ "beliefs",
6686
+ "evidence",
6687
+ "questions",
6688
+ "graph",
6689
+ "worktrees",
6690
+ "topics",
6691
+ "edges",
6692
+ "contradictions",
6693
+ "contracts",
6694
+ "graphIntel",
6695
+ "graphIntelligence",
6696
+ "graphAnalysis",
6697
+ "graphRecommendations",
6698
+ "orgGraphSearch",
6699
+ "embeddings",
6700
+ "ontologyLinks",
6701
+ "graphStateClassifier",
6702
+ "tools",
6703
+ "identity",
6704
+ "modelRuntime",
6705
+ "events",
6706
+ "jobs",
6707
+ "telemetry"
6708
+ ];
6709
+ var TENANT_CLIENT_CAPABILITIES = [
6710
+ {
6711
+ id: "identity.bootstrap_session",
6712
+ description: "Start a scoped Lucern session for a tenant principal.",
6713
+ surfaces: ["@lucern/sdk", "@lucern/mcp"],
6714
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6715
+ },
6716
+ {
6717
+ id: "reasoning.context.compile",
6718
+ description: "Compile tenant and workspace scoped reasoning context.",
6719
+ surfaces: ["@lucern/sdk", "@lucern/react", "@lucern/mcp"],
6720
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6721
+ },
6722
+ {
6723
+ id: "reasoning.graph.read",
6724
+ description: "Read beliefs, evidence, questions, topics, graph edges, and lineage.",
6725
+ surfaces: ["@lucern/sdk", "@lucern/react", "@lucern/mcp"],
6726
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6727
+ },
6728
+ {
6729
+ id: "reasoning.graph.write",
6730
+ description: "Create and update graph objects through authorized APIs.",
6731
+ surfaces: ["@lucern/sdk", "@lucern/mcp"],
6732
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6733
+ },
6734
+ {
6735
+ id: "reasoning.graph_intelligence.run",
6736
+ description: "Discover and run Graph Intelligence query recipes for structural graph analysis.",
6737
+ surfaces: ["@lucern/sdk", "@lucern/cli", "@lucern/mcp"],
6738
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6739
+ },
6740
+ {
6741
+ id: "reasoning.graph_mirroring.install",
6742
+ description: "Install and run the optional Neo4j graph mirror for paid or enterprise tenant deployments.",
6743
+ surfaces: ["@lucern/graph-sync", "@lucern/cli"],
6744
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6745
+ },
6746
+ {
6747
+ id: "workflow.worktree_lifecycle",
6748
+ description: "Create, review, merge, and close scoped worktrees.",
6749
+ surfaces: ["@lucern/sdk", "@lucern/react", "@lucern/mcp"],
6750
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS
6751
+ }
6752
+ ];
6753
+ var TENANT_CLIENT_ISOLATION_RULES = [
6754
+ {
6755
+ id: "tenant_workspace_scope_required",
6756
+ description: "Runtime operations must resolve both tenantId and workspaceId before reaching Lucern reasoning state."
6757
+ },
6758
+ {
6759
+ id: "principal_audit_required",
6760
+ description: "Runtime operations must carry principalId, authMode, and scopes for audit attribution."
6761
+ },
6762
+ {
6763
+ id: "no_private_lucern_imports",
6764
+ description: "Tenant code must not import Lucern source, Convex internals, generated adapters, or unpublished package internals."
6765
+ }
6766
+ ];
6767
+ var TENANT_CLIENT_FORBIDDEN_IMPORT_PATTERNS = [
6768
+ {
6769
+ id: "deep_src_import",
6770
+ pattern: "^@lucern/[^/]+/src(?:/|$)",
6771
+ description: "Published packages must not be bypassed through src paths."
6772
+ },
6773
+ {
6774
+ id: "deep_dist_import",
6775
+ pattern: "^@lucern/[^/]+/dist(?:/|$)",
6776
+ description: "Published package exports must be used instead of dist file paths."
6777
+ },
6778
+ {
6779
+ id: "generated_adapter_import",
6780
+ pattern: "^@lucern/[^/]+/(?:adapters/)?_generated(?:/|$)",
6781
+ description: "Generated Lucern adapters are internal deployment artifacts."
6782
+ },
6783
+ {
6784
+ id: "private_runtime_import",
6785
+ pattern: "^@lucern/[^/]+/(?:internal|private)(?:/|$)",
6786
+ description: "Internal and private package subpaths are not public SDK API."
6787
+ },
6788
+ {
6789
+ id: "workspace_source_import",
6790
+ pattern: "^(?:packages|modules|services|lucern|apps)/(?:.+/)?src(?:/|$)",
6791
+ description: "Tenant clients must not import source files from the Lucern monorepo."
6792
+ },
6793
+ {
6794
+ id: "root_alias_lucern_import",
6795
+ pattern: "^@/(?:lucern|packages|modules|services|apps)(?:/|$)",
6796
+ description: "Tenant clients must not depend on Lucern repo-local path aliases."
6797
+ },
6798
+ {
6799
+ id: "relative_lucern_source_import",
6800
+ pattern: "^\\.\\.?/(?:.+/)?(?:packages|modules|services|lucern|apps)(?:/|$)",
6801
+ description: "Tenant clients must not reach back into Lucern source through relative paths."
6802
+ },
6803
+ {
6804
+ id: "monorepo_path_import",
6805
+ pattern: "lucern-repo",
6806
+ description: "Absolute imports that name the Lucern repository are not portable tenant code."
6807
+ }
6808
+ ];
6809
+ function matchesPublicImport(importPath) {
6810
+ const componentConfig = TENANT_CLIENT_COMPONENT_CONFIG_IMPORTS.find(
6811
+ (entry) => importPath === entry.importPath
6812
+ );
6813
+ if (componentConfig) {
6814
+ return componentConfig;
6815
+ }
6816
+ return TENANT_CLIENT_PUBLIC_IMPORTS.find(
6817
+ (entry) => importPath === entry.packageName || importPath.startsWith(`${entry.packageName}/`)
6818
+ );
6819
+ }
6820
+ function matchesForbiddenPattern(importPath) {
6821
+ return TENANT_CLIENT_FORBIDDEN_IMPORT_PATTERNS.find(
6822
+ (entry) => new RegExp(entry.pattern, "u").test(importPath)
6823
+ );
6824
+ }
6825
+ function classifyTenantClientImport(importPath) {
6826
+ const normalizedImportPath = importPath.trim();
6827
+ const pattern = matchesForbiddenPattern(normalizedImportPath);
6828
+ if (pattern) {
6829
+ return {
6830
+ importPath: normalizedImportPath,
6831
+ decision: "forbidden",
6832
+ pattern,
6833
+ reason: pattern.description
6834
+ };
6835
+ }
6836
+ const publicImport = matchesPublicImport(normalizedImportPath);
6837
+ if (publicImport) {
6838
+ return {
6839
+ importPath: normalizedImportPath,
6840
+ decision: "public",
6841
+ publicImport,
6842
+ reason: publicImport.description
6843
+ };
6844
+ }
6845
+ if (normalizedImportPath.startsWith("@lucern/")) {
6846
+ return {
6847
+ importPath: normalizedImportPath,
6848
+ decision: "forbidden",
6849
+ reason: "This @lucern package is not part of the tenant client public surface."
6850
+ };
6851
+ }
6852
+ if (normalizedImportPath.startsWith("./") || normalizedImportPath.startsWith("../")) {
6853
+ return {
6854
+ importPath: normalizedImportPath,
6855
+ decision: "local",
6856
+ reason: "Local tenant-owned import."
6857
+ };
6858
+ }
6859
+ return {
6860
+ importPath: normalizedImportPath,
6861
+ decision: "external",
6862
+ reason: "External dependency outside the Lucern package namespace."
6863
+ };
6864
+ }
6865
+ function isTenantClientPublicImport(importPath) {
6866
+ return classifyTenantClientImport(importPath).decision === "public";
6867
+ }
6868
+ function isTenantClientComponentConfigImport(importPath) {
6869
+ return TENANT_CLIENT_COMPONENT_CONFIG_IMPORTS.some(
6870
+ (entry) => importPath === entry.importPath
6871
+ );
6872
+ }
6873
+ function isTenantClientAllowedImport(importPath) {
6874
+ return classifyTenantClientImport(importPath).decision === "public";
6875
+ }
6876
+ function assertTenantClientImportAllowed(importPath) {
6877
+ const classification = classifyTenantClientImport(importPath);
6878
+ if (classification.decision !== "forbidden") {
6879
+ return;
6880
+ }
6881
+ throw new Error(formatTenantClientImportViolation(classification));
6882
+ }
6883
+ function formatTenantClientImportViolation(classification) {
6884
+ const patternId = classification.pattern ? ` [${classification.pattern.id}]` : "";
6885
+ return `Tenant client import is not allowed${patternId}: ${classification.importPath}. ${classification.reason}`;
6886
+ }
6887
+
6888
+ // src/infisical-runtime.contract.ts
6889
+ var INFISICAL_RUNTIME_CONTRACT_VERSION = "2026-04-28";
6890
+ var INFISICAL_RUNTIME_DEFAULT_API_URL = "https://app.infisical.com";
6891
+ var INFISICAL_RUNTIME_DEFAULT_PROJECT_ID = "344b0526-90df-4606-ba50-22c647a36c65";
6892
+ var INFISICAL_RUNTIME_ENVIRONMENTS = [
6893
+ "dev",
6894
+ "staging",
6895
+ "prod"
6896
+ ];
6897
+ var INFISICAL_RUNTIME_DELIVERY_MODES = [
6898
+ "vercel_sync",
6899
+ "runtime_fetch",
6900
+ "device_auth"
6901
+ ];
6902
+ var INFISICAL_RUNTIME_SURFACE_IDS = [
6903
+ "lucern-web",
6904
+ "lucern-gateway",
6905
+ "lucern-sdk",
6906
+ "lucern-cli",
6907
+ "lucern-mcp",
6908
+ "tenant-client"
6909
+ ];
6910
+ var INFISICAL_RUNTIME_BOOTSTRAP_ENV = {
6911
+ apiUrl: ["INFISICAL_API_URL", "INFISICAL_URL"],
6912
+ projectId: ["INFISICAL_PROJECT_ID", "INFISICAL_WORKSPACE_ID"],
6913
+ clientId: [
6914
+ "INFISICAL_CLIENT_ID",
6915
+ "INFISICAL_MACHINE_CLIENT_ID",
6916
+ "INFISICAL_UNIVERSAL_AUTH_CLIENT_ID"
6917
+ ],
6918
+ clientSecret: [
6919
+ "INFISICAL_CLIENT_SECRET",
6920
+ "INFISICAL_MACHINE_CLIENT_SECRET",
6921
+ "INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET"
6922
+ ],
6923
+ environment: ["INFISICAL_ENV", "LUCERN_INFISICAL_ENV"],
6924
+ organizationSlug: ["INFISICAL_ORG_SLUG", "INFISICAL_ORGANIZATION_SLUG"],
6925
+ disabled: ["LUCERN_INFISICAL_DISABLE", "INFISICAL_DISABLE"]
6926
+ };
6927
+ var INFISICAL_RUNTIME_PATHS = [
6928
+ {
6929
+ id: "platform-auth",
6930
+ secretPath: "/platform/auth",
6931
+ description: "Lucern platform authentication secrets. Synced into Vercel web/gateway projects; never distributed to tenant tools.",
6932
+ variables: [
6933
+ {
6934
+ name: "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
6935
+ required: true,
6936
+ secret: false,
6937
+ public: true,
6938
+ description: "Clerk publishable key for the Lucern web origin."
6939
+ },
6940
+ {
6941
+ name: "CLERK_SECRET_KEY",
6942
+ required: true,
6943
+ secret: true,
6944
+ public: false,
6945
+ description: "Clerk backend secret key for Lucern server runtimes."
6946
+ },
6947
+ {
6948
+ name: "CLERK_JWT_ISSUER_DOMAIN",
6949
+ required: false,
6950
+ secret: false,
6951
+ public: false,
6952
+ description: "Expected Clerk issuer/JWKS domain for JWT verification."
6953
+ },
6954
+ {
6955
+ name: "NEXT_PUBLIC_CLERK_SIGN_IN_URL",
6956
+ required: false,
6957
+ secret: false,
6958
+ public: true,
6959
+ description: "Public sign-in URL for Lucern-owned web flows."
6960
+ },
6961
+ {
6962
+ name: "NEXT_PUBLIC_CLERK_SIGN_UP_URL",
6963
+ required: false,
6964
+ secret: false,
6965
+ public: true,
6966
+ description: "Public sign-up URL for Lucern-owned web flows."
6967
+ }
6968
+ ]
6969
+ },
6970
+ {
6971
+ id: "platform-runtime",
6972
+ secretPath: "/platform/runtime",
6973
+ description: "Runtime defaults shared by server-side Lucern clients and operator tooling.",
6974
+ variables: [
6975
+ {
6976
+ name: "LUCERN_API_URL",
6977
+ required: true,
6978
+ secret: false,
6979
+ public: false,
6980
+ aliases: ["LUCERN_API_BASE_URL", "LUCERN_BASE_URL"],
6981
+ description: "Canonical Lucern API gateway URL."
6982
+ },
6983
+ {
6984
+ name: "LUCERN_LOGIN_BASE_URL",
6985
+ required: false,
6986
+ secret: false,
6987
+ public: false,
6988
+ aliases: ["LUCERN_AUTH_BASE_URL"],
6989
+ description: "Browser login origin used when it differs from the API."
6990
+ },
6991
+ {
6992
+ name: "LUCERN_ENVIRONMENT",
6993
+ required: false,
6994
+ secret: false,
6995
+ public: false,
6996
+ aliases: ["LUCERN_ENV"],
6997
+ description: "Lucern environment label consumed by CLI profiles."
6998
+ }
6999
+ ]
7000
+ },
7001
+ {
7002
+ id: "tenant-shared-install",
7003
+ secretPath: TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH,
7004
+ description: "Tenant package-install secrets. This is install-only and distinct from platform publish credentials.",
7005
+ variables: [
7006
+ {
7007
+ name: "INSTALL_LUCERN_NPM",
7008
+ required: true,
7009
+ secret: true,
7010
+ public: false,
7011
+ description: "Read-only install token for the published @lucern/* suite."
7012
+ }
7013
+ ]
7014
+ }
7015
+ ];
7016
+ var INFISICAL_RUNTIME_SURFACES = [
7017
+ {
7018
+ id: "lucern-web",
7019
+ delivery: "vercel_sync",
7020
+ sourcePathIds: ["platform-auth", "platform-runtime"],
7021
+ consumer: "apps/web on Vercel project lucern",
7022
+ description: "Lucern web consumes Clerk and runtime config via Infisical-to-Vercel syncs."
7023
+ },
7024
+ {
7025
+ id: "lucern-gateway",
7026
+ delivery: "vercel_sync",
7027
+ sourcePathIds: ["platform-auth", "platform-runtime"],
7028
+ consumer: "apps/gateway on Vercel project lucern-gateway",
7029
+ description: "Lucern gateway consumes platform config via Infisical-to-Vercel syncs."
7030
+ },
7031
+ {
7032
+ id: "lucern-sdk",
7033
+ packageName: "@lucern/sdk",
7034
+ delivery: "runtime_fetch",
7035
+ sourcePathIds: ["platform-runtime"],
7036
+ consumer: "server-side SDK operator contexts with a scoped Infisical identity",
7037
+ description: "SDK exposes the runtime Infisical resolver used by clients that have machine identity credentials."
7038
+ },
7039
+ {
7040
+ id: "lucern-cli",
7041
+ packageName: "@lucern/cli",
7042
+ delivery: "runtime_fetch",
7043
+ fallback: "device_auth",
7044
+ sourcePathIds: ["platform-runtime"],
7045
+ consumer: "developer/operator CLI processes",
7046
+ description: "CLI hydrates runtime defaults from Infisical when configured, then authenticates users through Lucern device login."
7047
+ },
7048
+ {
7049
+ id: "lucern-mcp",
7050
+ packageName: "@lucern/mcp",
7051
+ delivery: "runtime_fetch",
7052
+ fallback: "device_auth",
7053
+ sourcePathIds: ["platform-runtime"],
7054
+ consumer: "MCP server/client processes",
7055
+ description: "MCP hydrates runtime defaults through the SDK resolver and remains a Lucern client, not a platform secret owner."
7056
+ },
7057
+ {
7058
+ id: "tenant-client",
7059
+ delivery: "device_auth",
7060
+ sourcePathIds: ["tenant-shared-install"],
7061
+ consumer: "tenant-owned apps and coding agents",
7062
+ description: "Tenant clients install the published packages and receive user/service credentials through Lucern auth surfaces."
7063
+ }
7064
+ ];
7065
+ function findInfisicalRuntimePath(pathId) {
7066
+ return INFISICAL_RUNTIME_PATHS.find((path) => path.id === pathId);
7067
+ }
7068
+ function findInfisicalRuntimeSurface(surfaceId) {
7069
+ return INFISICAL_RUNTIME_SURFACES.find(
7070
+ (surface) => surface.id === surfaceId
7071
+ );
7072
+ }
7073
+
7074
+ // src/manifests/infisical-runtime-manifest.ts
7075
+ var INFISICAL_RUNTIME_MANIFEST = {
7076
+ manifestVersion: "1.0.0",
7077
+ contractVersion: INFISICAL_RUNTIME_CONTRACT_VERSION,
7078
+ project: {
7079
+ id: INFISICAL_RUNTIME_DEFAULT_PROJECT_ID,
7080
+ apiUrl: INFISICAL_RUNTIME_DEFAULT_API_URL
7081
+ },
7082
+ environments: INFISICAL_RUNTIME_ENVIRONMENTS,
7083
+ deliveryModes: INFISICAL_RUNTIME_DELIVERY_MODES,
7084
+ bootstrapEnv: INFISICAL_RUNTIME_BOOTSTRAP_ENV,
7085
+ paths: INFISICAL_RUNTIME_PATHS,
7086
+ surfaces: INFISICAL_RUNTIME_SURFACES
7087
+ };
7088
+ var InvariantManifestSchema = z.object({
7089
+ manifestVersion: z.literal("1.0.0"),
7090
+ rules: z.array(
7091
+ z.object({
7092
+ invariant: z.string(),
7093
+ description: z.string(),
7094
+ checker: z.enum(["ast", "manifest", "runtime"]),
7095
+ severity: z.enum(["block_publish", "block_pr", "warn"])
7096
+ })
7097
+ )
7098
+ });
7099
+
7100
+ // src/manifests/tenant-client-manifest.ts
7101
+ var TENANT_CLIENT_MANIFEST = {
7102
+ manifestVersion: "1.0.0",
7103
+ contractVersion: TENANT_CLIENT_CONTRACT_VERSION,
7104
+ auth: {
7105
+ modes: TENANT_CLIENT_AUTH_MODES,
7106
+ principalTypes: TENANT_CLIENT_PRINCIPAL_TYPES,
7107
+ requiredContextFields: TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS,
7108
+ optionalContextFields: TENANT_CLIENT_OPTIONAL_CONTEXT_FIELDS
7109
+ },
7110
+ installToken: {
7111
+ env: TENANT_CLIENT_INSTALL_TOKEN_ENV,
7112
+ infisicalPath: TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH,
7113
+ forbiddenInfisicalPaths: TENANT_CLIENT_FORBIDDEN_INSTALL_TOKEN_INFISICAL_PATHS,
7114
+ forbiddenSecretEnv: TENANT_CLIENT_FORBIDDEN_SECRET_ENV
7115
+ },
7116
+ packages: {
7117
+ installable: TENANT_CLIENT_INSTALLABLE_PACKAGES,
7118
+ installProfiles: TENANT_CLIENT_INSTALL_PROFILES,
7119
+ directImports: TENANT_CLIENT_PUBLIC_IMPORTS,
7120
+ componentConfigImports: TENANT_CLIENT_COMPONENT_CONFIG_IMPORTS
7121
+ },
7122
+ sdk: {
7123
+ requiredNamespaces: TENANT_CLIENT_REQUIRED_SDK_NAMESPACES
7124
+ },
7125
+ capabilities: TENANT_CLIENT_CAPABILITIES,
7126
+ isolationRules: TENANT_CLIENT_ISOLATION_RULES,
7127
+ forbiddenImportPatterns: TENANT_CLIENT_FORBIDDEN_IMPORT_PATTERNS
7128
+ };
7129
+
7130
+ // src/projections/projection-dsl.ts
7131
+ function defineProjection(def) {
7132
+ return def;
7133
+ }
7134
+
7135
+ // src/projections/create-evidence.projection.ts
7136
+ var jsonRecordSchema = z.record(z.unknown());
7137
+ var createEvidenceInputSchemaBase = z.object({
7138
+ projectId: z.string().optional(),
7139
+ topicId: z.string().optional(),
7140
+ text: z.string().optional(),
7141
+ canonicalText: z.string().optional(),
7142
+ title: z.string().optional(),
7143
+ content: z.string().optional(),
7144
+ contentType: z.string().optional(),
7145
+ kind: z.string().optional(),
7146
+ tags: z.array(z.string()).optional(),
7147
+ source: z.string().optional(),
7148
+ sourceUrl: z.string().optional(),
7149
+ sourceType: z.string().optional(),
7150
+ externalSourceType: z.string().optional(),
7151
+ sourceQuestionId: z.string().optional(),
7152
+ methodology: z.string().optional(),
7153
+ informationAsymmetry: z.string().optional(),
7154
+ sourceDescription: z.string().optional(),
7155
+ targetId: z.string().optional(),
7156
+ targetNodeId: z.string().optional(),
7157
+ linkedBeliefNodeId: z.string().optional(),
7158
+ evidenceRelation: z.enum(["supports", "contradicts", "neutral"]).optional(),
7159
+ confidence: z.number().optional(),
7160
+ weight: z.number().optional(),
7161
+ reasoning: z.string().optional(),
7162
+ rationale: z.string(),
7163
+ metadata: jsonRecordSchema.optional(),
7164
+ trustedBypassAccessCheck: z.boolean().optional()
7165
+ }).passthrough();
7166
+ var createEvidenceInputSchema = createEvidenceInputSchemaBase.refine(
7167
+ (input) => Boolean(input.text ?? input.canonicalText),
7168
+ {
7169
+ message: "create_evidence requires text",
7170
+ path: ["text"]
7171
+ }
7172
+ );
7173
+ function compactRecord(input) {
7174
+ return Object.fromEntries(
7175
+ Object.entries(input).filter(([, value]) => value !== void 0)
7176
+ );
7177
+ }
7178
+ function isRecord(value) {
7179
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7180
+ }
7181
+ function recordValue(value) {
7182
+ return isRecord(value) ? value : {};
7183
+ }
7184
+ var createEvidenceProjection = defineProjection({
7185
+ contractName: "create_evidence",
7186
+ inputSchema: createEvidenceInputSchema,
7187
+ project: (input) => {
7188
+ const text = input.text ?? input.canonicalText;
7189
+ const weight = typeof input.weight === "number" ? input.weight : void 0;
7190
+ return compactRecord({
7191
+ projectId: input.projectId,
7192
+ topicId: input.topicId,
7193
+ text,
7194
+ title: input.title ?? text,
7195
+ content: input.content ?? text,
7196
+ contentType: input.contentType,
7197
+ kind: input.kind,
7198
+ tags: input.tags,
7199
+ sourceType: input.sourceType,
7200
+ externalSourceType: input.externalSourceType,
7201
+ sourceUrl: input.sourceUrl ?? input.source,
7202
+ sourceQuestionId: input.sourceQuestionId,
7203
+ methodology: input.methodology,
7204
+ informationAsymmetry: input.informationAsymmetry,
7205
+ sourceDescription: input.sourceDescription,
7206
+ metadata: compactRecord({
7207
+ ...recordValue(input.metadata),
7208
+ source: input.source,
7209
+ targetId: input.targetId,
7210
+ targetNodeId: input.targetNodeId,
7211
+ weight,
7212
+ reasoning: input.reasoning,
7213
+ rationale: input.rationale
7214
+ }),
7215
+ linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
7216
+ evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
7217
+ confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
7218
+ rationale: input.rationale,
7219
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
7220
+ });
7221
+ },
7222
+ convexArgsValidator: v.object({
7223
+ projectId: v.optional(v.string()),
7224
+ topicId: v.optional(v.string()),
7225
+ text: v.string(),
7226
+ title: v.optional(v.string()),
7227
+ content: v.optional(v.string()),
7228
+ contentType: v.optional(v.string()),
7229
+ kind: v.optional(v.string()),
7230
+ tags: v.optional(v.array(v.string())),
7231
+ sourceType: v.optional(v.string()),
7232
+ externalSourceType: v.optional(v.string()),
7233
+ sourceUrl: v.optional(v.string()),
7234
+ sourceQuestionId: v.optional(v.string()),
7235
+ methodology: v.optional(v.string()),
7236
+ informationAsymmetry: v.optional(v.string()),
7237
+ sourceDescription: v.optional(v.string()),
7238
+ metadata: v.optional(v.record(v.string(), v.any())),
7239
+ linkedBeliefNodeId: v.optional(v.string()),
7240
+ evidenceRelation: v.optional(
7241
+ v.union(
7242
+ v.literal("supports"),
7243
+ v.literal("contradicts"),
7244
+ v.literal("neutral")
7245
+ )
7246
+ ),
7247
+ confidence: v.optional(v.number()),
7248
+ rationale: v.string(),
7249
+ trustedBypassAccessCheck: v.optional(v.boolean())
7250
+ })
7251
+ });
7252
+ var beliefStatusSchema = z.enum(["active", "superseded", "archived", "unscored", "scored"]).optional().describe("Filter by belief lifecycle or scoring status");
7253
+ var listBeliefsInputSchema = z.object({
7254
+ topicId: z.string().describe("Topic scope"),
7255
+ worktreeId: z.string().optional().describe("Filter to worktree scope"),
7256
+ status: beliefStatusSchema,
7257
+ minConfidence: z.number().optional().describe("Minimum confidence threshold"),
7258
+ limit: z.number().optional().describe("Maximum results"),
7259
+ includeEdgeAssociated: z.boolean().optional().describe("Include beliefs associated to the topic through edges")
7260
+ });
7261
+ function kernelStatus(status) {
7262
+ return status === "active" || status === "superseded" || status === "archived" ? status : void 0;
7263
+ }
7264
+ function compactRecord2(input) {
7265
+ return Object.fromEntries(
7266
+ Object.entries(input).filter(([, value]) => value !== void 0)
7267
+ );
7268
+ }
7269
+ var listBeliefsProjection = defineProjection({
7270
+ contractName: "list_beliefs",
7271
+ inputSchema: listBeliefsInputSchema,
7272
+ project: (input) => compactRecord2({
7273
+ topicId: input.topicId,
7274
+ status: kernelStatus(input.status),
7275
+ limit: input.limit,
7276
+ includeEdgeAssociated: input.includeEdgeAssociated
7277
+ }),
7278
+ convexArgsValidator: v.object({
7279
+ topicId: v.string(),
7280
+ status: v.optional(
7281
+ v.union(
7282
+ v.literal("active"),
7283
+ v.literal("superseded"),
7284
+ v.literal("archived")
7285
+ )
7286
+ ),
7287
+ limit: v.optional(v.number()),
7288
+ includeEdgeAssociated: v.optional(v.boolean())
7289
+ })
7290
+ });
7291
+ var taskStatusSchema = z.enum(["todo", "in_progress", "blocked", "done"]).optional().describe("Filter by task status");
7292
+ var listTasksInputSchema = z.object({
7293
+ topicId: z.string().describe("Topic scope"),
7294
+ worktreeId: z.string().optional().describe("Alias for linkedWorktreeId"),
7295
+ linkedWorktreeId: z.string().optional().describe("Filter to tasks linked to this worktree"),
7296
+ status: taskStatusSchema,
7297
+ limit: z.number().optional().describe("Maximum results")
7298
+ });
7299
+ function compactRecord3(input) {
7300
+ return Object.fromEntries(
7301
+ Object.entries(input).filter(([, value]) => value !== void 0)
7302
+ );
7303
+ }
7304
+ var listTasksProjection = defineProjection({
7305
+ contractName: "list_tasks",
7306
+ inputSchema: listTasksInputSchema,
7307
+ project: (input) => compactRecord3({
7308
+ topicId: input.topicId,
7309
+ status: input.status,
7310
+ userId: void 0,
7311
+ limit: input.limit,
7312
+ linkedWorktreeId: input.linkedWorktreeId ?? input.worktreeId
7313
+ }),
7314
+ convexArgsValidator: v.object({
7315
+ topicId: v.string(),
7316
+ status: v.optional(
7317
+ v.union(
7318
+ v.literal("todo"),
7319
+ v.literal("in_progress"),
7320
+ v.literal("blocked"),
7321
+ v.literal("done")
7322
+ )
7323
+ ),
7324
+ limit: v.optional(v.number()),
7325
+ linkedWorktreeId: v.optional(v.string())
7326
+ })
7327
+ });
7328
+ var confidenceTriggerSchema = z.enum([
7329
+ "evidence_added",
7330
+ "evidence_removed",
7331
+ "contradiction_resolved",
7332
+ "agent_assessment",
7333
+ "worktree_outcome",
7334
+ "worktree_completed",
7335
+ "contradiction_detected",
7336
+ "answer_recorded",
7337
+ "fusion",
7338
+ "discount",
7339
+ "deduction",
7340
+ "backfill_synthetic"
7341
+ ]);
7342
+ var provenanceSchema = z.object({
7343
+ evidence: z.string().optional(),
7344
+ question: z.string().optional(),
7345
+ answer: z.string().optional(),
7346
+ contradiction: z.string().optional(),
7347
+ worktree: z.string().optional()
7348
+ });
7349
+ var slOpinionProjectionSchema = z.object({
7350
+ belief: z.number(),
7351
+ disbelief: z.number(),
7352
+ uncertainty: z.number(),
7353
+ baseRate: z.number()
7354
+ });
7355
+ var modulateConfidenceInputObjectSchema = z.object({
7356
+ nodeId: z.string().optional(),
7357
+ beliefNodeId: z.string().optional(),
7358
+ worktreeId: z.string().optional(),
7359
+ opinion: slOpinionProjectionSchema.optional(),
7360
+ belief: z.number().optional(),
7361
+ disbelief: z.number().optional(),
7362
+ uncertainty: z.number().optional(),
7363
+ baseRate: z.number().optional(),
7364
+ trigger: confidenceTriggerSchema,
7365
+ provenance: provenanceSchema.optional(),
7366
+ triggeringEvidenceId: z.string().optional(),
7367
+ triggeringQuestionId: z.string().optional(),
7368
+ triggeringAnswerId: z.string().optional(),
7369
+ triggeringContradictionId: z.string().optional(),
7370
+ triggeringWorktreeId: z.string().optional(),
7371
+ rationale: z.string(),
7372
+ trustedBypassAccessCheck: z.boolean().optional()
7373
+ });
7374
+ var modulateConfidenceInputSchema = modulateConfidenceInputObjectSchema.superRefine((input, ctx) => {
7375
+ if (hasProvenance(input)) {
7376
+ return;
7377
+ }
7378
+ ctx.addIssue({
7379
+ code: z.ZodIssueCode.custom,
7380
+ message: "modulate_confidence requires evidence, question, answer, contradiction, or worktree provenance",
7381
+ path: ["provenance"]
7382
+ });
7383
+ });
7384
+ var modulateConfidenceProjection = defineProjection({
7385
+ contractName: "modulate_confidence",
7386
+ inputSchema: modulateConfidenceInputSchema,
7387
+ project: (input) => {
7388
+ const nodeId = input.beliefNodeId ?? input.nodeId;
7389
+ if (!nodeId) {
7390
+ throw new Error("modulate_confidence requires beliefNodeId or nodeId");
7391
+ }
7392
+ const opinion = input.opinion ?? {
7393
+ belief: requireNumber(input.belief, "belief"),
7394
+ disbelief: requireNumber(input.disbelief, "disbelief"),
7395
+ uncertainty: requireNumber(input.uncertainty, "uncertainty"),
7396
+ baseRate: requireNumber(input.baseRate, "baseRate")
7397
+ };
7398
+ assertProvenance(input);
7399
+ return {
7400
+ nodeId,
7401
+ worktreeId: input.worktreeId,
7402
+ belief: opinion.belief,
7403
+ disbelief: opinion.disbelief,
7404
+ uncertainty: opinion.uncertainty,
7405
+ baseRate: opinion.baseRate,
7406
+ trigger: input.trigger === "answer_recorded" ? "agent_assessment" : input.trigger,
7407
+ triggeringEvidenceId: input.provenance?.evidence ?? input.triggeringEvidenceId,
7408
+ triggeringQuestionId: input.provenance?.question ?? input.triggeringQuestionId,
7409
+ triggeringAnswerId: input.provenance?.answer ?? input.triggeringAnswerId,
7410
+ triggeringContradictionId: input.provenance?.contradiction ?? input.triggeringContradictionId,
7411
+ triggeringWorktreeId: input.provenance?.worktree ?? input.triggeringWorktreeId,
7412
+ rationale: input.rationale,
7413
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
7414
+ };
7415
+ },
7416
+ convexArgsValidator: v.object({
7417
+ nodeId: v.string(),
7418
+ worktreeId: v.optional(v.string()),
7419
+ belief: v.number(),
7420
+ disbelief: v.number(),
7421
+ uncertainty: v.number(),
7422
+ baseRate: v.number(),
7423
+ trigger: v.union(
7424
+ v.literal("evidence_added"),
7425
+ v.literal("evidence_removed"),
7426
+ v.literal("worktree_completed"),
7427
+ v.literal("contradiction_detected"),
7428
+ v.literal("contradiction_resolved"),
7429
+ v.literal("agent_assessment"),
7430
+ v.literal("worktree_outcome"),
7431
+ v.literal("fusion"),
7432
+ v.literal("discount"),
7433
+ v.literal("deduction"),
7434
+ v.literal("backfill_synthetic")
7435
+ ),
7436
+ triggeringEvidenceId: v.optional(v.string()),
7437
+ triggeringQuestionId: v.optional(v.string()),
7438
+ triggeringAnswerId: v.optional(v.string()),
7439
+ triggeringContradictionId: v.optional(v.string()),
7440
+ triggeringWorktreeId: v.optional(v.string()),
7441
+ rationale: v.string(),
7442
+ trustedBypassAccessCheck: v.optional(v.boolean())
7443
+ })
7444
+ });
7445
+ function requireNumber(value, field) {
7446
+ if (value === void 0) {
7447
+ throw new Error(`modulate_confidence requires ${field}`);
7448
+ }
7449
+ return value;
7450
+ }
7451
+ function assertProvenance(input) {
7452
+ if (!hasProvenance(input)) {
7453
+ throw new Error(
7454
+ "modulate_confidence requires evidence, question, answer, contradiction, or worktree provenance"
7455
+ );
7456
+ }
7457
+ }
7458
+ function hasProvenance(input) {
7459
+ return input.trigger === "backfill_synthetic" || Boolean(input.provenance && Object.values(input.provenance).some(Boolean)) || Boolean(input.triggeringEvidenceId) || Boolean(input.triggeringQuestionId) || Boolean(input.triggeringAnswerId) || Boolean(input.triggeringContradictionId) || Boolean(input.triggeringWorktreeId);
7460
+ }
7461
+
7462
+ // src/projections/index.ts
7463
+ var projections = {
7464
+ create_evidence: createEvidenceProjection,
7465
+ list_beliefs: listBeliefsProjection,
7466
+ list_tasks: listTasksProjection,
7467
+ modulate_confidence: modulateConfidenceProjection
7468
+ };
7469
+
7470
+ // src/tool-contracts.ts
7471
+ var tool_contracts_exports = {};
7472
+ __export(tool_contracts_exports, {
7473
+ ACTIVATE_WORKTREE: () => ACTIVATE_WORKTREE,
7474
+ ADD_EVIDENCE: () => ADD_EVIDENCE,
7475
+ ADD_WORKTREE: () => ADD_WORKTREE,
7476
+ ANALYZE_TOPIC_DENSITY: () => ANALYZE_TOPIC_DENSITY,
7477
+ ANSWER_QUESTION: () => ANSWER_QUESTION,
7478
+ APPLY_AUTO_BRANCHING: () => APPLY_AUTO_BRANCHING,
7479
+ APPLY_LENS_TO_TOPIC: () => APPLY_LENS_TO_TOPIC,
7480
+ APPLY_ONTOLOGY: () => APPLY_ONTOLOGY,
7481
+ ARCHIVE_BELIEF: () => ARCHIVE_BELIEF,
7482
+ ARCHIVE_EPISTEMIC_NODE: () => ARCHIVE_EPISTEMIC_NODE,
7483
+ ARCHIVE_ONTOLOGY: () => ARCHIVE_ONTOLOGY,
7484
+ ARCHIVE_QUESTION: () => ARCHIVE_QUESTION,
7485
+ BATCH_CREATE_EDGES: () => BATCH_CREATE_EDGES,
7486
+ BATCH_CREATE_EPISTEMIC_NODES: () => BATCH_CREATE_EPISTEMIC_NODES,
7487
+ BEGIN_BUILD_SESSION: () => BEGIN_BUILD_SESSION,
7488
+ BISECT_CONFIDENCE: () => BISECT_CONFIDENCE,
7489
+ BROADCAST_MESSAGE: () => BROADCAST_MESSAGE,
7490
+ CHECK_PERMISSION: () => CHECK_PERMISSION,
7491
+ CLAIM_FILES: () => CLAIM_FILES,
7492
+ COMPILE_CONTEXT: () => COMPILE_CONTEXT,
7493
+ COMPLETE_TASK: () => COMPLETE_TASK,
7494
+ CREATE_ANSWER: () => CREATE_ANSWER,
7495
+ CREATE_BELIEF: () => CREATE_BELIEF,
7496
+ CREATE_EDGE: () => CREATE_EDGE,
7497
+ CREATE_EPISTEMIC_CONTRACT: () => CREATE_EPISTEMIC_CONTRACT,
7498
+ CREATE_EPISTEMIC_NODE: () => CREATE_EPISTEMIC_NODE,
7499
+ CREATE_EVIDENCE: () => CREATE_EVIDENCE,
7500
+ CREATE_LENS: () => CREATE_LENS,
7501
+ CREATE_ONTOLOGY: () => CREATE_ONTOLOGY,
7502
+ CREATE_ONTOLOGY_VERSION: () => CREATE_ONTOLOGY_VERSION,
7503
+ CREATE_QUESTION: () => CREATE_QUESTION,
7504
+ CREATE_TASK: () => CREATE_TASK,
7505
+ CREATE_TOPIC: () => CREATE_TOPIC,
7506
+ DEPRECATE_ONTOLOGY_VERSION: () => DEPRECATE_ONTOLOGY_VERSION,
7507
+ DETECT_CONFIRMATION_BIAS: () => DETECT_CONFIRMATION_BIAS,
7508
+ DISCOVER: () => DISCOVER,
7509
+ DISCOVER_ENTITY_CONNECTIONS: () => DISCOVER_ENTITY_CONNECTIONS,
7510
+ END_SESSION: () => END_SESSION,
7511
+ EVALUATE_CONTRACT: () => EVALUATE_CONTRACT,
7512
+ FILTER_BY_PERMISSION: () => FILTER_BY_PERMISSION,
7513
+ FIND_CONTRADICTIONS: () => FIND_CONTRADICTIONS,
7514
+ FIND_MISSING_QUESTIONS: () => FIND_MISSING_QUESTIONS,
7515
+ FLAG_CONTRADICTION: () => FLAG_CONTRADICTION,
7516
+ FORK_BELIEF: () => FORK_BELIEF,
7517
+ GENERATE_SESSION_HANDOFF: () => GENERATE_SESSION_HANDOFF,
7518
+ GET_AGENT_INBOX: () => GET_AGENT_INBOX,
7519
+ GET_ANSWER: () => GET_ANSWER,
7520
+ GET_AUDIT_TRAIL: () => GET_AUDIT_TRAIL,
7521
+ GET_BELIEF: () => GET_BELIEF,
7522
+ GET_CHANGE_HISTORY: () => GET_CHANGE_HISTORY,
7523
+ GET_CODE_CONTEXT: () => GET_CODE_CONTEXT,
7524
+ GET_CONFIDENCE_HISTORY: () => GET_CONFIDENCE_HISTORY,
7525
+ GET_CONTRACT_STATUS: () => GET_CONTRACT_STATUS,
7526
+ GET_EPISTEMIC_NODE: () => GET_EPISTEMIC_NODE,
7527
+ GET_EVIDENCE: () => GET_EVIDENCE,
7528
+ GET_FAILURE_LOG: () => GET_FAILURE_LOG,
7529
+ GET_FALSIFICATION_QUESTIONS: () => GET_FALSIFICATION_QUESTIONS,
7530
+ GET_GRAPH_GAPS: () => GET_GRAPH_GAPS,
7531
+ GET_GRAPH_NEIGHBORHOOD: () => GET_GRAPH_NEIGHBORHOOD,
7532
+ GET_GRAPH_STRUCTURE_ANALYSIS: () => GET_GRAPH_STRUCTURE_ANALYSIS,
7533
+ GET_HIGH_PRIORITY_QUESTIONS: () => GET_HIGH_PRIORITY_QUESTIONS,
7534
+ GET_LATTICE_COVERAGE: () => GET_LATTICE_COVERAGE,
7535
+ GET_OBSERVATION_CONTEXT: () => GET_OBSERVATION_CONTEXT,
7536
+ GET_ONTOLOGY: () => GET_ONTOLOGY,
7537
+ GET_QUESTION: () => GET_QUESTION,
7538
+ GET_TOPIC: () => GET_TOPIC,
5470
7539
  GET_TOPIC_COVERAGE: () => GET_TOPIC_COVERAGE,
7540
+ GET_TOPIC_GRAPH_SPINE: () => GET_TOPIC_GRAPH_SPINE,
5471
7541
  GET_TOPIC_TREE: () => GET_TOPIC_TREE,
5472
7542
  GIT_SEMANTIC_REQUIRED_TOOLS: () => GIT_SEMANTIC_REQUIRED_TOOLS,
5473
7543
  HEARTBEAT_SESSION: () => HEARTBEAT_SESSION,
@@ -5479,7 +7549,10 @@ __export(tool_contracts_exports, {
5479
7549
  LIST_ACTIVE_SESSIONS: () => LIST_ACTIVE_SESSIONS,
5480
7550
  LIST_ALL_WORKTREES: () => LIST_ALL_WORKTREES,
5481
7551
  LIST_BELIEFS: () => LIST_BELIEFS,
7552
+ LIST_CAMPAIGNS: () => LIST_CAMPAIGNS,
7553
+ LIST_EPISTEMIC_NODES: () => LIST_EPISTEMIC_NODES,
5482
7554
  LIST_EVIDENCE: () => LIST_EVIDENCE,
7555
+ LIST_GRAPH_INTELLIGENCE_QUERIES: () => LIST_GRAPH_INTELLIGENCE_QUERIES,
5483
7556
  LIST_LENSES: () => LIST_LENSES,
5484
7557
  LIST_ONTOLOGIES: () => LIST_ONTOLOGIES,
5485
7558
  LIST_QUESTIONS: () => LIST_QUESTIONS,
@@ -5488,6 +7561,7 @@ __export(tool_contracts_exports, {
5488
7561
  LIST_WORKTREES: () => LIST_WORKTREES,
5489
7562
  MANAGE_WRITE_POLICY: () => MANAGE_WRITE_POLICY,
5490
7563
  MATCH_ENTITY_TYPE: () => MATCH_ENTITY_TYPE,
7564
+ MATERIALIZE_TOPIC_GRAPH: () => MATERIALIZE_TOPIC_GRAPH,
5491
7565
  MCP_TOOL_CONTRACTS: () => MCP_TOOL_CONTRACTS,
5492
7566
  MERGE: () => MERGE,
5493
7567
  MODULATE_CONFIDENCE: () => MODULATE_CONFIDENCE,
@@ -5502,21 +7576,28 @@ __export(tool_contracts_exports, {
5502
7576
  REFINE_BELIEF: () => REFINE_BELIEF,
5503
7577
  REFINE_QUESTION: () => REFINE_QUESTION,
5504
7578
  REGISTER_SESSION: () => REGISTER_SESSION,
7579
+ REMOVE_EDGE: () => REMOVE_EDGE,
7580
+ REMOVE_EDGES_BETWEEN: () => REMOVE_EDGES_BETWEEN,
5505
7581
  REMOVE_LENS_FROM_TOPIC: () => REMOVE_LENS_FROM_TOPIC,
5506
7582
  RESOLVE_EFFECTIVE_ONTOLOGY: () => RESOLVE_EFFECTIVE_ONTOLOGY,
7583
+ RUN_GRAPH_INTELLIGENCE_QUERY: () => RUN_GRAPH_INTELLIGENCE_QUERY,
5507
7584
  SEARCH_BELIEFS: () => SEARCH_BELIEFS,
5508
7585
  SEARCH_EVIDENCE: () => SEARCH_EVIDENCE,
5509
7586
  SEED_BELIEF_LATTICE: () => SEED_BELIEF_LATTICE,
5510
7587
  SEND_AGENT_MESSAGE: () => SEND_AGENT_MESSAGE,
7588
+ SUPERSEDE_EPISTEMIC_NODE: () => SUPERSEDE_EPISTEMIC_NODE,
5511
7589
  TRACE_ENTITY_IMPACT: () => TRACE_ENTITY_IMPACT,
5512
7590
  TRAVERSE_GRAPH: () => TRAVERSE_GRAPH,
5513
7591
  TRIGGER_BELIEF_REVIEW: () => TRIGGER_BELIEF_REVIEW,
7592
+ UPDATE_EDGE: () => UPDATE_EDGE,
7593
+ UPDATE_EPISTEMIC_NODE: () => UPDATE_EPISTEMIC_NODE,
5514
7594
  UPDATE_ONTOLOGY: () => UPDATE_ONTOLOGY,
5515
7595
  UPDATE_QUESTION_STATUS: () => UPDATE_QUESTION_STATUS,
5516
7596
  UPDATE_TASK: () => UPDATE_TASK,
5517
7597
  UPDATE_TOPIC: () => UPDATE_TOPIC,
5518
7598
  UPDATE_WORKTREE_METADATA: () => UPDATE_WORKTREE_METADATA,
5519
7599
  UPDATE_WORKTREE_TARGETS: () => UPDATE_WORKTREE_TARGETS,
7600
+ VERIFY_EPISTEMIC_NODE: () => VERIFY_EPISTEMIC_NODE,
5520
7601
  validateGitSemantics: () => validateGitSemantics
5521
7602
  });
5522
7603
 
@@ -5532,7 +7613,7 @@ var LENS_PERSPECTIVE_TYPES = [
5532
7613
  // src/tool-contracts.ts
5533
7614
  var CREATE_BELIEF = {
5534
7615
  name: "create_belief",
5535
- description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a mandatory prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
7616
+ description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
5536
7617
  parameters: {
5537
7618
  canonicalText: {
5538
7619
  type: "string",
@@ -5544,7 +7625,7 @@ var CREATE_BELIEF = {
5544
7625
  },
5545
7626
  baseRate: {
5546
7627
  type: "number",
5547
- description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
7628
+ description: "Prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time. Defaults to 0.5 when omitted."
5548
7629
  },
5549
7630
  beliefType: {
5550
7631
  type: "string",
@@ -5555,7 +7636,7 @@ var CREATE_BELIEF = {
5555
7636
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
5556
7637
  }
5557
7638
  },
5558
- required: ["canonicalText", "baseRate"],
7639
+ required: ["canonicalText"],
5559
7640
  response: {
5560
7641
  description: "The created canonical belief record",
5561
7642
  fields: {
@@ -5618,7 +7699,7 @@ var REFINE_BELIEF = {
5618
7699
  };
5619
7700
  var MODULATE_CONFIDENCE = {
5620
7701
  name: "modulate_confidence",
5621
- description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction, manual, decay.",
7702
+ description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Every modulation must cite a truth-bearing artifact: triggeringEvidenceId, triggeringQuestionId, triggeringAnswerId, triggeringContradictionId, or triggeringWorktreeId. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction.",
5622
7703
  parameters: {
5623
7704
  nodeId: { type: "string", description: "The belief to score" },
5624
7705
  belief: {
@@ -5637,9 +7718,9 @@ var MODULATE_CONFIDENCE = {
5637
7718
  type: "number",
5638
7719
  description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
5639
7720
  },
5640
- confidence: {
5641
- type: "number",
5642
- description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
7721
+ worktreeId: {
7722
+ type: "string",
7723
+ description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
5643
7724
  },
5644
7725
  trigger: {
5645
7726
  type: "string",
@@ -5654,17 +7735,43 @@ var MODULATE_CONFIDENCE = {
5654
7735
  "worktree_completed",
5655
7736
  "fusion",
5656
7737
  "discount",
5657
- "deduction",
5658
- "manual",
5659
- "decay"
7738
+ "deduction"
5660
7739
  ]
5661
7740
  },
7741
+ triggeringEvidenceId: {
7742
+ type: "string",
7743
+ description: "Evidence node that caused an evidence-triggered modulation"
7744
+ },
7745
+ triggeringQuestionId: {
7746
+ type: "string",
7747
+ description: "Answered question whose resolution supports this modulation"
7748
+ },
7749
+ triggeringAnswerId: {
7750
+ type: "string",
7751
+ description: "Answer node whose content supports this modulation"
7752
+ },
7753
+ triggeringContradictionId: {
7754
+ type: "string",
7755
+ description: "Contradiction record that caused a contradiction-triggered modulation"
7756
+ },
7757
+ triggeringWorktreeId: {
7758
+ type: "string",
7759
+ description: "Completed worktree whose outcome caused a worktree-triggered modulation"
7760
+ },
5662
7761
  rationale: {
5663
7762
  type: "string",
5664
7763
  description: "Human-readable explanation of why confidence changed"
5665
7764
  }
5666
7765
  },
5667
- required: ["nodeId", "trigger", "rationale"],
7766
+ required: [
7767
+ "nodeId",
7768
+ "belief",
7769
+ "disbelief",
7770
+ "uncertainty",
7771
+ "baseRate",
7772
+ "trigger",
7773
+ "rationale"
7774
+ ],
5668
7775
  response: {
5669
7776
  description: "Confidence modulation result",
5670
7777
  fields: {
@@ -5858,7 +7965,7 @@ var ADD_EVIDENCE = {
5858
7965
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'], failedApproach: true } for coding intelligence)"
5859
7966
  }
5860
7967
  },
5861
- required: ["canonicalText", "targetNodeId"],
7968
+ required: ["canonicalText", "targetNodeId", "reasoning"],
5862
7969
  response: {
5863
7970
  description: "The created evidence node and its edge",
5864
7971
  fields: {
@@ -5914,7 +8021,22 @@ var ADD_WORKTREE = {
5914
8021
  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.",
5915
8022
  parameters: {
5916
8023
  title: { type: "string", description: "Worktree name/objective" },
5917
- topicId: { type: "string", description: "Optional topic scope hint" },
8024
+ name: {
8025
+ type: "string",
8026
+ description: "Optional storage-name alias for callers that already use backend naming"
8027
+ },
8028
+ projectId: {
8029
+ type: "string",
8030
+ description: "Legacy topicId alias or resolver hint"
8031
+ },
8032
+ topicId: {
8033
+ type: "string",
8034
+ description: "Optional topic scope hint for resolver validation"
8035
+ },
8036
+ topicHint: {
8037
+ type: "string",
8038
+ description: "Natural-language topic hint for automatic topic resolution"
8039
+ },
5918
8040
  branchId: {
5919
8041
  type: "string",
5920
8042
  description: "The branch this worktree investigates"
@@ -5927,21 +8049,122 @@ var ADD_WORKTREE = {
5927
8049
  type: "string",
5928
8050
  description: "The testable claim this worktree investigates"
5929
8051
  },
8052
+ rationale: {
8053
+ type: "string",
8054
+ description: "Why this worktree exists and why it belongs in the campaign"
8055
+ },
8056
+ worktreeType: {
8057
+ type: "string",
8058
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
8059
+ },
8060
+ gate: {
8061
+ type: "string",
8062
+ description: "Exit gate name for this worktree"
8063
+ },
8064
+ startDate: {
8065
+ type: "number",
8066
+ description: "Planned start timestamp in milliseconds since epoch"
8067
+ },
8068
+ endDate: {
8069
+ type: "number",
8070
+ description: "Planned end timestamp in milliseconds since epoch"
8071
+ },
8072
+ durationWeeks: {
8073
+ type: "number",
8074
+ description: "Planned duration in weeks"
8075
+ },
8076
+ confidenceImpact: {
8077
+ type: "string",
8078
+ description: "Expected confidence impact if the worktree succeeds",
8079
+ enum: ["high", "medium", "low"]
8080
+ },
8081
+ beliefFocus: {
8082
+ type: "string",
8083
+ description: "Natural-language focus spanning the target belief neighborhood"
8084
+ },
5930
8085
  beliefIds: {
5931
8086
  type: "array",
5932
- description: "Beliefs to test in this worktree"
8087
+ description: "Legacy alias for targetBeliefIds"
8088
+ },
8089
+ beliefs: {
8090
+ type: "array",
8091
+ description: "Legacy alias for targetBeliefIds"
8092
+ },
8093
+ targetBeliefIds: {
8094
+ type: "array",
8095
+ description: "Belief node IDs this worktree is expected to test or update"
8096
+ },
8097
+ targetQuestionIds: {
8098
+ type: "array",
8099
+ description: "Question node IDs this worktree is expected to answer"
8100
+ },
8101
+ keyQuestions: {
8102
+ type: "array",
8103
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
8104
+ },
8105
+ evidenceSignals: {
8106
+ type: "array",
8107
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
8108
+ },
8109
+ decisionGate: {
8110
+ type: "object",
8111
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
8112
+ },
8113
+ goCriteria: {
8114
+ type: "array",
8115
+ description: "Shorthand go criteria used to build decisionGate"
8116
+ },
8117
+ noGoSignals: {
8118
+ type: "array",
8119
+ description: "Shorthand no-go signals used to build decisionGate"
8120
+ },
8121
+ proofArtifacts: {
8122
+ type: "array",
8123
+ description: "Expected proof artifacts required to close the worktree"
5933
8124
  },
5934
8125
  autoShape: {
5935
8126
  type: "boolean",
5936
8127
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5937
8128
  },
8129
+ autoFixPolicy: {
8130
+ type: "object",
8131
+ description: "Policy for permitted automatic remediation inside the worktree"
8132
+ },
5938
8133
  domainPackId: {
5939
8134
  type: "string",
5940
8135
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5941
8136
  },
5942
- executionOrder: {
8137
+ tags: {
8138
+ type: "array",
8139
+ description: "Additional topic-resolution tags for the worktree"
8140
+ },
8141
+ touchedPaths: {
8142
+ type: "array",
8143
+ description: "File paths used as topic-resolution signals"
8144
+ },
8145
+ sourceRef: {
8146
+ type: "string",
8147
+ description: "Source reference used as a topic-resolution signal"
8148
+ },
8149
+ sourceKind: {
8150
+ type: "string",
8151
+ description: "Source kind used as a topic-resolution signal"
8152
+ },
8153
+ campaign: {
8154
+ type: "number",
8155
+ description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
8156
+ },
8157
+ lane: {
8158
+ type: "string",
8159
+ description: "GitButler-aligned workstream lane name inside the campaign."
8160
+ },
8161
+ laneOrderInCampaign: {
8162
+ type: "number",
8163
+ description: "Ordering for this lane within its campaign."
8164
+ },
8165
+ orderInLane: {
5943
8166
  type: "number",
5944
- description: "Global execution order for this worktree"
8167
+ description: "Position of this worktree inside its lane."
5945
8168
  },
5946
8169
  dependsOn: {
5947
8170
  type: "array",
@@ -5951,12 +8174,20 @@ var ADD_WORKTREE = {
5951
8174
  type: "array",
5952
8175
  description: "Worktree IDs blocked by this worktree"
5953
8176
  },
5954
- gate: {
8177
+ staffingHint: {
5955
8178
  type: "string",
5956
- description: "Exit gate name for this worktree"
8179
+ description: "Suggested staffing or agent allocation note"
8180
+ },
8181
+ lensId: {
8182
+ type: "string",
8183
+ description: "Lens that scopes this worktree when applicable"
8184
+ },
8185
+ lastReconciledAt: {
8186
+ type: "number",
8187
+ description: "Timestamp when worktree metadata was last reconciled"
5957
8188
  }
5958
8189
  },
5959
- required: ["title", "topicId"],
8190
+ required: ["title"],
5960
8191
  response: {
5961
8192
  description: "The created worktree",
5962
8193
  fields: {
@@ -5983,7 +8214,7 @@ var MERGE = {
5983
8214
  worktreeId: { type: "string", description: "The worktree to merge" },
5984
8215
  outcomes: {
5985
8216
  type: "array",
5986
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
8217
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5987
8218
  },
5988
8219
  summary: { type: "string", description: "Overall findings summary" }
5989
8220
  },
@@ -6149,96 +8380,338 @@ var SEARCH_BELIEFS = {
6149
8380
  name: "search_beliefs",
6150
8381
  description: "Search for beliefs in the reasoning graph. Like `git grep` \u2014 finds relevant beliefs across the full history and active state. Supports semantic search, filtering by status (unscored, scored, archived), confidence thresholds, and topic scope. Returns beliefs with their current confidence, lineage depth, and contradiction count.",
6151
8382
  parameters: {
6152
- query: { type: "string", description: "Semantic search query" },
6153
- status: {
6154
- type: "string",
6155
- description: "Filter by belief status",
6156
- enum: ["unscored", "scored", "archived"]
6157
- },
6158
- minConfidence: {
6159
- type: "number",
6160
- description: "Minimum confidence threshold (0-1)"
6161
- },
6162
- topicId: { type: "string", description: "Filter by topic" },
6163
- limit: { type: "number", description: "Maximum results (default: 10)" }
8383
+ query: { type: "string", description: "Semantic search query" },
8384
+ status: {
8385
+ type: "string",
8386
+ description: "Filter by belief status",
8387
+ enum: ["unscored", "scored", "archived"]
8388
+ },
8389
+ minConfidence: {
8390
+ type: "number",
8391
+ description: "Minimum confidence threshold (0-1)"
8392
+ },
8393
+ topicId: { type: "string", description: "Filter by topic" },
8394
+ limit: { type: "number", description: "Maximum results (default: 10)" }
8395
+ },
8396
+ required: ["query"],
8397
+ response: {
8398
+ description: "Matching beliefs with metadata",
8399
+ fields: {
8400
+ results: "array \u2014 { nodeId, canonicalText, confidence, status, contradictionCount }"
8401
+ }
8402
+ },
8403
+ ownerModule: "graph-search",
8404
+ ontologyPrimitive: "belief",
8405
+ tier: "workhorse"
8406
+ };
8407
+ var FIND_CONTRADICTIONS = {
8408
+ name: "find_contradictions",
8409
+ description: "Find contradictions in the reasoning graph \u2014 beliefs that are in tension with each other. Like a merge conflict in `git` \u2014 surfaces incompatible states that require explicit resolution. Contradictions are first-class objects that may remain permanently unresolved. They can block judgments, trigger forks, or collapse confidence. Filter by project, status (unresolved, resolved, accepted), and severity.",
8410
+ parameters: {
8411
+ topicId: { type: "string", description: "Filter by topic" },
8412
+ nodeId: {
8413
+ type: "string",
8414
+ description: "Find contradictions involving a specific belief"
8415
+ },
8416
+ status: {
8417
+ type: "string",
8418
+ description: "Filter by status",
8419
+ enum: ["unresolved", "resolved", "accepted"]
8420
+ }
8421
+ },
8422
+ required: [],
8423
+ response: {
8424
+ description: "Contradiction objects",
8425
+ fields: {
8426
+ contradictions: "array \u2014 { beliefA, beliefB, description, severity, status, defeatType }"
8427
+ }
8428
+ },
8429
+ ownerModule: "graph-search",
8430
+ ontologyPrimitive: "belief",
8431
+ tier: "showcase"
8432
+ };
8433
+ var CREATE_EDGE = {
8434
+ name: "create_edge",
8435
+ description: "Commit a typed relationship between two nodes in the reasoning graph. Like `git commit` \u2014 an atomic write that declares a dependency between nodes. Accepts any public epistemic edge type between public graph node refs so agents can author the full spine.",
8436
+ parameters: {
8437
+ from: {
8438
+ type: "object",
8439
+ description: "Source graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'topic' }"
8440
+ },
8441
+ to: {
8442
+ type: "object",
8443
+ description: "Target graph ref, e.g. { kind: 'epistemic_node', nodeId: '...', nodeType: 'belief' }"
8444
+ },
8445
+ edgeType: {
8446
+ type: "string",
8447
+ description: "Relationship type from the public epistemic edge enum."
8448
+ },
8449
+ globalId: {
8450
+ type: "string",
8451
+ description: "Optional idempotent edge global ID."
8452
+ },
8453
+ weight: {
8454
+ type: "number",
8455
+ description: "Edge weight: -1.0 to +1.0 for informs edges, 0-1 for structural"
8456
+ },
8457
+ reasoning: { type: "string", description: "Why this relationship exists" },
8458
+ reasoningMethod: {
8459
+ type: "string",
8460
+ description: "How this was determined",
8461
+ enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
8462
+ },
8463
+ metadata: {
8464
+ type: "object",
8465
+ description: "Optional edge metadata."
8466
+ }
8467
+ },
8468
+ required: ["from", "to", "edgeType"],
8469
+ response: {
8470
+ description: "The created edge",
8471
+ fields: {
8472
+ globalId: "string \u2014 edge identifier",
8473
+ edgeType: "string",
8474
+ fromLayer: "string",
8475
+ toLayer: "string"
8476
+ }
8477
+ },
8478
+ ownerModule: "graph-primitives",
8479
+ ontologyPrimitive: "edge",
8480
+ tier: "showcase"
8481
+ };
8482
+ var UPDATE_EDGE = {
8483
+ name: "update_edge",
8484
+ description: "Amend metadata on an existing graph edge. Like `git commit --amend` \u2014 changes the edge annotation without recreating the relationship.",
8485
+ parameters: {
8486
+ edgeId: { type: "string", description: "Edge ID or global ID to update" },
8487
+ weight: { type: "number", description: "Updated edge weight" },
8488
+ confidence: { type: "number", description: "Updated confidence" },
8489
+ context: { type: "string", description: "Updated human-readable context" },
8490
+ derivationType: { type: "string", description: "Updated derivation type" },
8491
+ metadata: { type: "object", description: "Updated metadata" }
8492
+ },
8493
+ required: ["edgeId"],
8494
+ response: {
8495
+ description: "Edge update result",
8496
+ fields: { success: "boolean" }
8497
+ },
8498
+ ownerModule: "graph-primitives",
8499
+ ontologyPrimitive: "edge",
8500
+ tier: "workhorse"
8501
+ };
8502
+ var REMOVE_EDGE = {
8503
+ name: "remove_edge",
8504
+ description: "Remove one graph edge by ID. Like `git rm` \u2014 deletes a single explicit relationship from the spine.",
8505
+ parameters: {
8506
+ edgeId: { type: "string", description: "Edge ID or global ID to remove" }
8507
+ },
8508
+ required: ["edgeId"],
8509
+ response: {
8510
+ description: "Edge removal result",
8511
+ fields: { success: "boolean" }
8512
+ },
8513
+ ownerModule: "graph-primitives",
8514
+ ontologyPrimitive: "edge",
8515
+ tier: "workhorse"
8516
+ };
8517
+ var REMOVE_EDGES_BETWEEN = {
8518
+ name: "remove_edges_between",
8519
+ description: "Remove graph edges between two nodes. Like `git rm <pathspec>` \u2014 deletes relationships matching a source, target, and optional type.",
8520
+ parameters: {
8521
+ fromNodeId: { type: "string", description: "Source node ID or global ID" },
8522
+ toNodeId: { type: "string", description: "Target node ID or global ID" },
8523
+ edgeType: { type: "string", description: "Optional edge type filter" }
8524
+ },
8525
+ required: ["fromNodeId", "toNodeId"],
8526
+ response: {
8527
+ description: "Matched edge removal result",
8528
+ fields: { deleted: "number" }
8529
+ },
8530
+ ownerModule: "graph-primitives",
8531
+ ontologyPrimitive: "edge",
8532
+ tier: "workhorse"
8533
+ };
8534
+ var BATCH_CREATE_EDGES = {
8535
+ name: "batch_create_edges",
8536
+ description: "Commit multiple typed graph edges. Like `git commit` with many staged paths \u2014 writes a batch of explicit relationships atomically per edge.",
8537
+ parameters: {
8538
+ edges: {
8539
+ type: "array",
8540
+ description: "Edges to create, each with from, to, edgeType, and optional weight/confidence/context."
8541
+ },
8542
+ skipLayerValidation: {
8543
+ type: "boolean",
8544
+ description: "Skip kernel layer validation for trusted materialization flows."
8545
+ }
8546
+ },
8547
+ required: ["edges"],
8548
+ response: {
8549
+ description: "Batch edge creation result",
8550
+ fields: {
8551
+ created: "number",
8552
+ results: "array",
8553
+ errors: "array"
8554
+ }
8555
+ },
8556
+ ownerModule: "graph-primitives",
8557
+ ontologyPrimitive: "edge",
8558
+ tier: "workhorse"
8559
+ };
8560
+ var CREATE_EPISTEMIC_NODE = {
8561
+ name: "create_epistemic_node",
8562
+ description: "Commit a generic epistemic graph node. Like `git commit` \u2014 creates a canonical node in the public spine for topics, beliefs, evidence, questions, answers, sources, and entities.",
8563
+ parameters: {
8564
+ globalId: { type: "string", description: "Optional idempotent node global ID" },
8565
+ nodeType: { type: "string", description: "Public epistemic node type" },
8566
+ canonicalText: { type: "string", description: "Canonical node text" },
8567
+ text: { type: "string", description: "Alias for canonicalText" },
8568
+ contentHash: { type: "string", description: "Optional idempotency content hash" },
8569
+ sourceType: { type: "string", description: "Source type for provenance" },
8570
+ topicId: { type: "string", description: "Optional topic scope" },
8571
+ content: { type: "string", description: "Extended content" },
8572
+ title: { type: "string", description: "Display title" },
8573
+ metadata: { type: "object", description: "Optional node metadata" }
8574
+ },
8575
+ required: ["nodeType"],
8576
+ response: {
8577
+ description: "Created node result",
8578
+ fields: {
8579
+ nodeId: "string",
8580
+ nodeGlobalId: "string",
8581
+ isDuplicate: "boolean"
8582
+ }
8583
+ },
8584
+ ownerModule: "reasoning-kernel",
8585
+ ontologyPrimitive: "graph",
8586
+ tier: "showcase"
8587
+ };
8588
+ var GET_EPISTEMIC_NODE = {
8589
+ name: "get_epistemic_node",
8590
+ description: "Read one epistemic graph node. Like `git show` \u2014 resolves a canonical spine node by ID or global ID.",
8591
+ parameters: {
8592
+ nodeId: { type: "string", description: "Node ID or global ID" }
8593
+ },
8594
+ required: ["nodeId"],
8595
+ response: {
8596
+ description: "The resolved node",
8597
+ fields: { node: "object" }
8598
+ },
8599
+ ownerModule: "reasoning-kernel",
8600
+ ontologyPrimitive: "graph",
8601
+ tier: "workhorse"
8602
+ };
8603
+ var LIST_EPISTEMIC_NODES = {
8604
+ name: "list_epistemic_nodes",
8605
+ description: "List epistemic graph nodes. Like `git ls-tree` \u2014 lists canonical spine nodes by topic, type, status, or search query.",
8606
+ parameters: {
8607
+ topicId: { type: "string", description: "Optional topic scope" },
8608
+ nodeType: { type: "string", description: "Optional node type filter" },
8609
+ status: { type: "string", description: "Optional lifecycle status" },
8610
+ searchQuery: { type: "string", description: "Optional text search query" },
8611
+ limit: { type: "number", description: "Maximum nodes to return" }
8612
+ },
8613
+ required: [],
8614
+ response: {
8615
+ description: "Matching nodes",
8616
+ fields: { nodes: "array" }
8617
+ },
8618
+ ownerModule: "reasoning-kernel",
8619
+ ontologyPrimitive: "graph",
8620
+ tier: "workhorse"
8621
+ };
8622
+ var UPDATE_EPISTEMIC_NODE = {
8623
+ name: "update_epistemic_node",
8624
+ description: "Amend an epistemic graph node. Like `git commit --amend` \u2014 updates mutable node metadata, text, status, or verification fields.",
8625
+ parameters: {
8626
+ nodeId: { type: "string", description: "Node ID or global ID" },
8627
+ canonicalText: { type: "string", description: "Updated canonical text" },
8628
+ text: { type: "string", description: "Alias for canonicalText" },
8629
+ contentHash: { type: "string", description: "Updated content hash" },
8630
+ content: { type: "string", description: "Updated content" },
8631
+ title: { type: "string", description: "Updated display title" },
8632
+ metadata: { type: "object", description: "Updated metadata" },
8633
+ confidence: { type: "number", description: "Updated confidence" },
8634
+ verificationStatus: { type: "string", description: "Updated verification status" },
8635
+ status: { type: "string", description: "Updated lifecycle status" }
8636
+ },
8637
+ required: ["nodeId"],
8638
+ response: {
8639
+ description: "Node update result",
8640
+ fields: { success: "boolean" }
8641
+ },
8642
+ ownerModule: "reasoning-kernel",
8643
+ ontologyPrimitive: "graph",
8644
+ tier: "workhorse"
8645
+ };
8646
+ var ARCHIVE_EPISTEMIC_NODE = {
8647
+ name: "archive_epistemic_node",
8648
+ description: "Archive an epistemic graph node. Like `git rm --cached` \u2014 removes a node from active traversal without hard-deleting it.",
8649
+ parameters: {
8650
+ nodeId: { type: "string", description: "Node ID or global ID" }
8651
+ },
8652
+ required: ["nodeId"],
8653
+ response: {
8654
+ description: "Archive result",
8655
+ fields: { success: "boolean", effectiveStatus: "string" }
8656
+ },
8657
+ ownerModule: "reasoning-kernel",
8658
+ ontologyPrimitive: "graph",
8659
+ tier: "workhorse"
8660
+ };
8661
+ var VERIFY_EPISTEMIC_NODE = {
8662
+ name: "verify_epistemic_node",
8663
+ description: "Record verification state on an epistemic graph node. Like `git tag` \u2014 marks the node with a reviewed verification state.",
8664
+ parameters: {
8665
+ nodeId: { type: "string", description: "Node ID or global ID" },
8666
+ verificationStatus: { type: "string", description: "Verification status" },
8667
+ confidence: { type: "number", description: "Optional confidence update" }
6164
8668
  },
6165
- required: ["query"],
8669
+ required: ["nodeId", "verificationStatus"],
6166
8670
  response: {
6167
- description: "Matching beliefs with metadata",
6168
- fields: {
6169
- results: "array \u2014 { nodeId, canonicalText, confidence, status, contradictionCount }"
6170
- }
8671
+ description: "Verification result",
8672
+ fields: { success: "boolean" }
6171
8673
  },
6172
- ownerModule: "graph-search",
6173
- ontologyPrimitive: "belief",
8674
+ ownerModule: "reasoning-kernel",
8675
+ ontologyPrimitive: "graph",
6174
8676
  tier: "workhorse"
6175
8677
  };
6176
- var FIND_CONTRADICTIONS = {
6177
- name: "find_contradictions",
6178
- description: "Find contradictions in the reasoning graph \u2014 beliefs that are in tension with each other. Like a merge conflict in `git` \u2014 surfaces incompatible states that require explicit resolution. Contradictions are first-class objects that may remain permanently unresolved. They can block judgments, trigger forks, or collapse confidence. Filter by project, status (unresolved, resolved, accepted), and severity.",
8678
+ var SUPERSEDE_EPISTEMIC_NODE = {
8679
+ name: "supersede_epistemic_node",
8680
+ description: "Supersede an epistemic graph node with a new version. Like `git commit --amend` on an immutable history branch \u2014 creates the replacement and marks the old node superseded.",
6179
8681
  parameters: {
6180
- topicId: { type: "string", description: "Filter by topic" },
6181
- nodeId: {
6182
- type: "string",
6183
- description: "Find contradictions involving a specific belief"
6184
- },
6185
- status: {
6186
- type: "string",
6187
- description: "Filter by status",
6188
- enum: ["unresolved", "resolved", "accepted"]
6189
- }
8682
+ oldNodeId: { type: "string", description: "Node ID or global ID to supersede" },
8683
+ newGlobalId: { type: "string", description: "Optional replacement global ID" },
8684
+ newCanonicalText: { type: "string", description: "Replacement canonical text" },
8685
+ text: { type: "string", description: "Alias for newCanonicalText" },
8686
+ newContentHash: { type: "string", description: "Optional replacement content hash" },
8687
+ reason: { type: "string", description: "Reason for superseding" }
6190
8688
  },
6191
- required: [],
8689
+ required: ["oldNodeId"],
6192
8690
  response: {
6193
- description: "Contradiction objects",
6194
- fields: {
6195
- contradictions: "array \u2014 { beliefA, beliefB, description, severity, status, defeatType }"
6196
- }
8691
+ description: "Supersede result",
8692
+ fields: { oldNodeId: "string", newNodeId: "string" }
6197
8693
  },
6198
- ownerModule: "graph-search",
6199
- ontologyPrimitive: "belief",
6200
- tier: "showcase"
8694
+ ownerModule: "reasoning-kernel",
8695
+ ontologyPrimitive: "graph",
8696
+ tier: "workhorse"
6201
8697
  };
6202
- var CREATE_EDGE = {
6203
- name: "create_edge",
6204
- description: "Commit a typed relationship between two nodes in the reasoning graph. Like `git commit` \u2014 an atomic write that declares a dependency between nodes. The engine enforces layer transition rules \u2014 for example, L1 \u2192 L3 direct edges are forbidden (must go through L2).",
8698
+ var BATCH_CREATE_EPISTEMIC_NODES = {
8699
+ name: "batch_create_epistemic_nodes",
8700
+ description: "Commit multiple epistemic graph nodes. Like `git commit` with many staged files \u2014 writes a batch of canonical spine nodes.",
6205
8701
  parameters: {
6206
- sourceId: {
6207
- type: "string",
6208
- description: "Source node of the relationship"
6209
- },
6210
- targetId: {
6211
- type: "string",
6212
- description: "Target node of the relationship"
6213
- },
6214
- edgeType: {
6215
- type: "string",
6216
- description: "Relationship type (informs, tests, depends_on, supersedes, etc.)"
6217
- },
6218
- weight: {
6219
- type: "number",
6220
- description: "Edge weight: -1.0 to +1.0 for informs edges, 0-1 for structural"
6221
- },
6222
- reasoning: { type: "string", description: "Why this relationship exists" },
6223
- reasoningMethod: {
6224
- type: "string",
6225
- description: "How this was determined",
6226
- enum: ["deductive", "inductive", "abductive", "analogical", "empirical"]
8702
+ nodes: {
8703
+ type: "array",
8704
+ description: "Nodes to create with nodeType, canonicalText/text, and optional metadata."
6227
8705
  }
6228
8706
  },
6229
- required: ["sourceId", "targetId", "edgeType"],
8707
+ required: ["nodes"],
6230
8708
  response: {
6231
- description: "The created edge",
6232
- fields: {
6233
- globalId: "string \u2014 edge identifier",
6234
- edgeType: "string",
6235
- fromLayer: "string",
6236
- toLayer: "string"
6237
- }
8709
+ description: "Batch node creation result",
8710
+ fields: { created: "number", results: "array" }
6238
8711
  },
6239
- ownerModule: "graph-primitives",
6240
- ontologyPrimitive: "edge",
6241
- tier: "showcase"
8712
+ ownerModule: "reasoning-kernel",
8713
+ ontologyPrimitive: "graph",
8714
+ tier: "workhorse"
6242
8715
  };
6243
8716
  var RECORD_JUDGMENT = {
6244
8717
  name: "record_judgment",
@@ -6537,6 +9010,74 @@ var GET_GRAPH_STRUCTURE_ANALYSIS = {
6537
9010
  ontologyPrimitive: "graph",
6538
9011
  tier: "showcase"
6539
9012
  };
9013
+ var LIST_GRAPH_INTELLIGENCE_QUERIES = {
9014
+ name: "list_graph_intelligence_queries",
9015
+ 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.",
9016
+ parameters: {
9017
+ categoryId: {
9018
+ type: "string",
9019
+ description: "Optional category filter, such as problems or strategic"
9020
+ },
9021
+ mode: {
9022
+ type: "string",
9023
+ description: "Optional mode filter: core, bias, stress, operational, alpha, semantic, or evidence"
9024
+ }
9025
+ },
9026
+ required: [],
9027
+ response: {
9028
+ description: "Graph Intelligence query catalog and mode-to-tool mapping",
9029
+ fields: {
9030
+ categories: "array \u2014 query categories",
9031
+ queries: "array \u2014 query definitions with prompt templates and tools",
9032
+ quickQueries: "array \u2014 recommended one-click query presets",
9033
+ publicToolNamesByMode: "object \u2014 public tool names available to each Graph Intelligence mode"
9034
+ }
9035
+ },
9036
+ ownerModule: "graph-intelligence",
9037
+ ontologyPrimitive: "graph",
9038
+ tier: "showcase"
9039
+ };
9040
+ var RUN_GRAPH_INTELLIGENCE_QUERY = {
9041
+ name: "run_graph_intelligence_query",
9042
+ 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.",
9043
+ parameters: {
9044
+ topicId: { type: "string", description: "Topic to analyze" },
9045
+ queryId: {
9046
+ type: "string",
9047
+ description: "Graph Intelligence query ID, such as confirmation-bias, pre-mortem, or thesis-summary"
9048
+ },
9049
+ prompt: {
9050
+ type: "string",
9051
+ description: "Optional custom prompt for custom analysis runs"
9052
+ },
9053
+ input: {
9054
+ type: "string",
9055
+ description: "Optional entity, theme, belief, company, or search text for input-driven queries"
9056
+ },
9057
+ mode: {
9058
+ type: "string",
9059
+ description: "Optional mode override: core, bias, stress, operational, alpha, semantic, or evidence"
9060
+ },
9061
+ limit: {
9062
+ type: "number",
9063
+ description: "Maximum graph context rows to return"
9064
+ }
9065
+ },
9066
+ required: ["topicId"],
9067
+ response: {
9068
+ description: "Graph Intelligence query result bundle ready for model or prompt-library synthesis",
9069
+ fields: {
9070
+ query: "object \u2014 selected query definition",
9071
+ prompt: "string \u2014 resolved prompt template",
9072
+ toolPlan: "array \u2014 public tools and args the model can call next",
9073
+ analysis: "object \u2014 structure, coverage, gap, and confirmation-bias analysis",
9074
+ context: "object \u2014 sampled beliefs, questions, evidence, edges, and contradictions"
9075
+ }
9076
+ },
9077
+ ownerModule: "graph-intelligence",
9078
+ ontologyPrimitive: "graph",
9079
+ tier: "showcase"
9080
+ };
6540
9081
  var GET_FALSIFICATION_QUESTIONS = {
6541
9082
  name: "get_falsification_questions",
6542
9083
  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.",
@@ -6599,6 +9140,10 @@ var CREATE_EVIDENCE = {
6599
9140
  type: "object",
6600
9141
  description: "Optional metadata merged into the canonical evidence node"
6601
9142
  },
9143
+ rationale: {
9144
+ type: "string",
9145
+ description: "Why this evidence should enter the reasoning graph"
9146
+ },
6602
9147
  title: { type: "string", description: "Optional short title" },
6603
9148
  content: { type: "string", description: "Optional long-form content" },
6604
9149
  contentType: {
@@ -6607,7 +9152,7 @@ var CREATE_EVIDENCE = {
6607
9152
  },
6608
9153
  kind: { type: "string", description: "Optional evidence kind" }
6609
9154
  },
6610
- required: ["text"],
9155
+ required: ["text", "rationale"],
6611
9156
  response: {
6612
9157
  description: "The created canonical evidence record",
6613
9158
  fields: {
@@ -6655,7 +9200,7 @@ var LIST_EVIDENCE = {
6655
9200
  limit: { type: "number", description: "Max results" },
6656
9201
  cursor: { type: "string", description: "Pagination cursor" }
6657
9202
  },
6658
- required: [],
9203
+ required: ["topicId"],
6659
9204
  response: {
6660
9205
  description: "Canonical evidence page",
6661
9206
  fields: {
@@ -6840,6 +9385,7 @@ var ANSWER_QUESTION = {
6840
9385
  description: "Answer a question with optional evidence links. Like `git commit` on the question thread \u2014 records the answer and closes the loop with a canonical answered state.",
6841
9386
  parameters: {
6842
9387
  id: { type: "string", description: "Canonical question ID" },
9388
+ topicId: { type: "string", description: "Topic scope for the answer" },
6843
9389
  text: { type: "string", description: "Answer text" },
6844
9390
  confidence: {
6845
9391
  type: "string",
@@ -6852,7 +9398,7 @@ var ANSWER_QUESTION = {
6852
9398
  },
6853
9399
  rationale: { type: "string", description: "Why this answer is credible" }
6854
9400
  },
6855
- required: ["id", "text"],
9401
+ required: ["id", "topicId", "text"],
6856
9402
  response: {
6857
9403
  description: "Answer result",
6858
9404
  fields: {
@@ -7071,6 +9617,10 @@ var LIST_BELIEFS = {
7071
9617
  minConfidence: {
7072
9618
  type: "number",
7073
9619
  description: "Minimum confidence threshold"
9620
+ },
9621
+ limit: {
9622
+ type: "number",
9623
+ description: "Maximum results"
7074
9624
  }
7075
9625
  },
7076
9626
  required: ["topicId"],
@@ -7087,20 +9637,37 @@ var LIST_BELIEFS = {
7087
9637
  };
7088
9638
  var LIST_WORKTREES = {
7089
9639
  name: "list_worktrees",
7090
- description: "List all worktrees for a topic. Like `git worktree list` \u2014 shows active and completed investigation branches with their phase, status, and belief counts.",
9640
+ description: "List all worktrees for a topic. Like `git worktree list` \u2014 shows active and completed investigation branches with lifecycle phase, pipeline campaign/lane, status, and belief counts.",
7091
9641
  parameters: {
7092
9642
  topicId: { type: "string", description: "Topic scope" },
7093
9643
  status: {
7094
9644
  type: "string",
7095
9645
  description: "Filter: active, merged, abandoned",
7096
9646
  enum: ["active", "merged", "abandoned"]
9647
+ },
9648
+ groupBy: {
9649
+ type: "string",
9650
+ description: "Optional grouping mode for the response.",
9651
+ enum: ["campaign", "lane", "flat"]
9652
+ },
9653
+ lane: {
9654
+ type: "string",
9655
+ description: "Filter by GitButler-aligned lane name."
9656
+ },
9657
+ campaign: {
9658
+ type: "number",
9659
+ description: "Filter by top-level pipeline campaign number."
9660
+ },
9661
+ limit: {
9662
+ type: "number",
9663
+ description: "Maximum results to return."
7097
9664
  }
7098
9665
  },
7099
9666
  required: ["topicId"],
7100
9667
  response: {
7101
- description: "Worktrees with phase, status, belief count, and creation time",
9668
+ description: "Worktrees with lifecycle phase, campaign, lane, status, belief count, and creation time",
7102
9669
  fields: {
7103
- worktrees: "array \u2014 { worktreeId, title, phase, status, beliefCount, createdAt }"
9670
+ worktrees: "array \u2014 { worktreeId, title, phase, campaign, lane, laneOrderInCampaign, orderInLane, status, beliefCount, createdAt }"
7104
9671
  }
7105
9672
  },
7106
9673
  ownerModule: "workflow-engine",
@@ -7109,7 +9676,7 @@ var LIST_WORKTREES = {
7109
9676
  };
7110
9677
  var LIST_ALL_WORKTREES = {
7111
9678
  name: "list_all_worktrees",
7112
- description: "List ALL worktrees across ALL topics in one query. No topic scope required. Like `git worktree list --all` \u2014 returns the complete pipeline inventory with track, trackPosition, executionBand, dependencies, and status. Supports filtering by status, track, and executionBand. This is the PM's primary pipeline query \u2014 one call, full picture.",
9679
+ description: "List ALL worktrees across ALL topics in one query. No topic scope required. Like `git worktree list --all` \u2014 returns the complete pipeline inventory with campaign, lane, lane order, dependencies, and status. Supports filtering by status, lane, and campaign. This is the PM's primary pipeline query \u2014 one call, full picture.",
7113
9680
  parameters: {
7114
9681
  status: {
7115
9682
  type: "string",
@@ -7127,13 +9694,18 @@ var LIST_ALL_WORKTREES = {
7127
9694
  "dismissed"
7128
9695
  ]
7129
9696
  },
7130
- track: {
9697
+ lane: {
7131
9698
  type: "string",
7132
- description: "Filter by track name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
9699
+ description: "Filter by lane name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
7133
9700
  },
7134
- executionBand: {
9701
+ campaign: {
7135
9702
  type: "number",
7136
- description: "Filter by execution band number (e.g., 1, 2, 3). Returns only worktrees in that parallel execution group."
9703
+ description: "Filter by campaign number (e.g., 1, 2, 3). Returns only worktrees in that campaign."
9704
+ },
9705
+ groupBy: {
9706
+ type: "string",
9707
+ description: "Optional grouping mode for the response.",
9708
+ enum: ["campaign", "lane", "flat"]
7137
9709
  },
7138
9710
  limit: {
7139
9711
  type: "number",
@@ -7144,10 +9716,39 @@ var LIST_ALL_WORKTREES = {
7144
9716
  response: {
7145
9717
  description: "All worktrees across all topics with full pipeline metadata",
7146
9718
  fields: {
7147
- worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, track, trackPosition, executionBand, executionOrder, dependsOn, blocks, gate, createdAt }",
9719
+ worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, campaign, lane, laneOrderInCampaign, orderInLane, dependsOn, blocks, gate, createdAt }",
7148
9720
  total: "number \u2014 total count after filtering",
7149
- tracks: "object \u2014 { trackName: count } summary of worktrees per track",
7150
- bands: "object \u2014 { bandNumber: count } summary of worktrees per execution band"
9721
+ lanes: "object \u2014 { laneName: count } summary of worktrees per lane",
9722
+ campaigns: "object \u2014 { campaignNumber: count } summary of worktrees per campaign"
9723
+ }
9724
+ },
9725
+ ownerModule: "workflow-engine",
9726
+ ontologyPrimitive: "worktree",
9727
+ tier: "showcase"
9728
+ };
9729
+ var LIST_CAMPAIGNS = {
9730
+ name: "list_campaigns",
9731
+ description: "List compact pipeline campaigns with their nested lanes. Use this to see the top-level campaign > lane > worktree shape without pulling the full worktree inventory.",
9732
+ parameters: {
9733
+ topicId: {
9734
+ type: "string",
9735
+ description: "Optional topic scope."
9736
+ },
9737
+ status: {
9738
+ type: "string",
9739
+ description: "Optional worktree status filter before grouping campaigns and lanes."
9740
+ },
9741
+ limit: {
9742
+ type: "number",
9743
+ description: "Maximum worktrees to scan before grouping."
9744
+ }
9745
+ },
9746
+ required: [],
9747
+ response: {
9748
+ description: "Pipeline campaigns with nested lane summaries.",
9749
+ fields: {
9750
+ campaigns: "array \u2014 { campaign, lanes: [{ lane, laneOrderInCampaign, worktreeCount, activeCount, readyCount, blockedCount, completedCount, nextWorktree }] }",
9751
+ totalWorktrees: "number \u2014 total worktrees scanned after filtering"
7151
9752
  }
7152
9753
  },
7153
9754
  ownerModule: "workflow-engine",
@@ -7210,16 +9811,28 @@ var UPDATE_WORKTREE_TARGETS = {
7210
9811
  };
7211
9812
  var UPDATE_WORKTREE_METADATA = {
7212
9813
  name: "update_worktree_metadata",
7213
- description: "Update worktree sequencing metadata \u2014 execution order, dependencies, blocking relations, and gates. Like `git config` for a worktree \u2014 sets the scheduling and dependency metadata that determines when this worktree can activate relative to others. Use to backfill or correct sequencing data.",
9814
+ description: "Update worktree sequencing metadata \u2014 campaign, lane, dependencies, blocking relations, and gates. Like `git config` for a worktree \u2014 sets the scheduling and dependency metadata that determines when this worktree can activate relative to others. Use to backfill or correct sequencing data.",
7214
9815
  parameters: {
7215
9816
  worktreeId: { type: "string", description: "The worktree to update" },
7216
9817
  hypothesis: {
7217
9818
  type: "string",
7218
9819
  description: "Testable claim this worktree investigates"
7219
9820
  },
7220
- executionOrder: {
9821
+ campaign: {
7221
9822
  type: "number",
7222
- description: "Global execution order (1 = first, higher = later)"
9823
+ description: "Top-level pipeline campaign number."
9824
+ },
9825
+ lane: {
9826
+ type: "string",
9827
+ description: "GitButler-aligned workstream lane name inside the campaign."
9828
+ },
9829
+ laneOrderInCampaign: {
9830
+ type: "number",
9831
+ description: "Ordering for this lane within the campaign."
9832
+ },
9833
+ orderInLane: {
9834
+ type: "number",
9835
+ description: "Position of this worktree inside its lane."
7223
9836
  },
7224
9837
  dependsOn: {
7225
9838
  type: "array",
@@ -7257,18 +9870,6 @@ var UPDATE_WORKTREE_METADATA = {
7257
9870
  type: "object",
7258
9871
  description: "Calibrated auto-fix policy controlling dry-run vs safe execution, per-run action caps, and permitted mutation tiers."
7259
9872
  },
7260
- track: {
7261
- type: "string",
7262
- description: "Parallel workstream name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity', 'execution-program'). Groups worktrees into named lanes for pipeline visualization and PM analysis."
7263
- },
7264
- trackPosition: {
7265
- type: "number",
7266
- description: "Position within the track (1-indexed). E.g., TC-A=1, TC-B=2, TC-C=3 within the 'tc-scope' track."
7267
- },
7268
- executionBand: {
7269
- type: "number",
7270
- description: "Parallel execution band number. All worktrees in the same band can run simultaneously. Band 2 = OE-B + TC-A, Band 3 = TC-B + 11D-R + S2-13A, etc."
7271
- },
7272
9873
  status: {
7273
9874
  type: "string",
7274
9875
  description: "Override the worktree status. Use for lifecycle transitions like marking a worktree superseded, long-term, or as a raw idea.",
@@ -7325,15 +9926,15 @@ var IDENTITY_WHOAMI = {
7325
9926
  };
7326
9927
  var COMPILE_CONTEXT = {
7327
9928
  name: "compile_context",
7328
- description: "Compile a focused reasoning context for a topic. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
9929
+ description: "Compile a focused reasoning context. If topicId is omitted, Lucern resolves the best topic from the query. Like `git log --graph --decorate` for the reasoning substrate \u2014 returns the canonical Pillar 3 context pack through the public API shape.",
7329
9930
  parameters: {
7330
9931
  topicId: {
7331
9932
  type: "string",
7332
- description: "Topic scope ID to compile"
9933
+ description: "Optional topic scope ID. Omit to resolve the topic from query."
7333
9934
  },
7334
9935
  query: {
7335
9936
  type: "string",
7336
- description: "Optional focus query used to rank context items"
9937
+ description: "Focus query used to resolve the topic and rank context items. Required when topicId is omitted."
7337
9938
  },
7338
9939
  budget: {
7339
9940
  type: "number",
@@ -7357,7 +9958,7 @@ var COMPILE_CONTEXT = {
7357
9958
  description: "Include related ontological entities in the compiled result"
7358
9959
  }
7359
9960
  },
7360
- required: ["topicId"],
9961
+ required: [],
7361
9962
  response: {
7362
9963
  description: "Compiled context pack for the requested topic",
7363
9964
  fields: {
@@ -7531,18 +10132,60 @@ var CREATE_TASK = {
7531
10132
  name: "create_task",
7532
10133
  description: "Create an execution task tied to the reasoning state. Like `git task` \u2014 tracks concrete work items (calls to make, data to gather, analyses to run) linked to questions, beliefs, or worktrees.",
7533
10134
  parameters: {
7534
- title: { type: "string", description: "Task description" },
10135
+ title: { type: "string", description: "Task title" },
7535
10136
  topicId: { type: "string", description: "Topic scope" },
10137
+ description: {
10138
+ type: "string",
10139
+ description: "Long-form task description"
10140
+ },
7536
10141
  taskType: {
7537
10142
  type: "string",
7538
- description: "Type: research, interview, analysis, data_collection",
7539
- enum: ["research", "interview", "analysis", "data_collection"]
10143
+ description: "Task taxonomy",
10144
+ enum: [
10145
+ "general",
10146
+ "find_evidence",
10147
+ "verify_claim",
10148
+ "research",
10149
+ "review",
10150
+ "interview",
10151
+ "analysis",
10152
+ "track_metrics"
10153
+ ]
10154
+ },
10155
+ priority: {
10156
+ type: "string",
10157
+ description: "Priority",
10158
+ enum: ["urgent", "high", "medium", "low"]
10159
+ },
10160
+ status: {
10161
+ type: "string",
10162
+ description: "Initial status (defaults to todo)",
10163
+ enum: ["todo", "in_progress", "blocked", "done"]
10164
+ },
10165
+ linkedWorktreeId: {
10166
+ type: "string",
10167
+ description: "Worktree this task belongs to"
10168
+ },
10169
+ linkedBeliefId: {
10170
+ type: "string",
10171
+ description: "Belief this task supports"
7540
10172
  },
7541
10173
  linkedQuestionId: {
7542
10174
  type: "string",
7543
10175
  description: "Question this task addresses"
7544
10176
  },
7545
- linkedWorktreeId: { type: "string", description: "Worktree scope" }
10177
+ assigneeId: {
10178
+ type: "string",
10179
+ description: "Principal assigned to the task"
10180
+ },
10181
+ dueDate: {
10182
+ type: "number",
10183
+ description: "Due date as epoch milliseconds"
10184
+ },
10185
+ tags: {
10186
+ type: "array",
10187
+ description: "Free-form string tags"
10188
+ }
7546
10189
  },
7547
10190
  required: ["title"],
7548
10191
  response: {
@@ -7638,6 +10281,10 @@ var LIST_TASKS = {
7638
10281
  type: "string",
7639
10282
  description: "Filter to tasks linked to this worktree"
7640
10283
  },
10284
+ worktreeId: {
10285
+ type: "string",
10286
+ description: "Alias for linkedWorktreeId"
10287
+ },
7641
10288
  status: {
7642
10289
  type: "string",
7643
10290
  description: "Filter by status: todo, in_progress, blocked, done",
@@ -7658,6 +10305,10 @@ var CREATE_TOPIC = {
7658
10305
  name: "create_topic",
7659
10306
  description: "Create a new topic container for scoping knowledge. Like `git init` \u2014 initializes a new repository for a knowledge domain. Topics are hierarchical: a deal topic can nest under a theme topic. Types: domain, theme, deal, strategy, constitution, project, portfolio.",
7660
10307
  parameters: {
10308
+ globalId: {
10309
+ type: "string",
10310
+ description: "Optional idempotent topic global ID"
10311
+ },
7661
10312
  name: { type: "string", description: "Topic name" },
7662
10313
  type: {
7663
10314
  type: "string",
@@ -7668,6 +10319,18 @@ var CREATE_TOPIC = {
7668
10319
  type: "string",
7669
10320
  description: "Optional parent topic for nesting"
7670
10321
  },
10322
+ parentTopicGlobalId: {
10323
+ type: "string",
10324
+ description: "Optional parent topic global ID for nesting"
10325
+ },
10326
+ tenantId: { type: "string", description: "Optional tenant scope" },
10327
+ workspaceId: { type: "string", description: "Optional workspace scope" },
10328
+ visibility: {
10329
+ type: "string",
10330
+ description: "Topic visibility",
10331
+ enum: ["private", "team", "firm", "external", "public"]
10332
+ },
10333
+ metadata: { type: "object", description: "Optional topic metadata" },
7671
10334
  createdBy: { type: "string", description: "Who created this topic" }
7672
10335
  },
7673
10336
  required: ["name", "type"],
@@ -7676,6 +10339,9 @@ var CREATE_TOPIC = {
7676
10339
  fields: {
7677
10340
  id: "string \u2014 topic ID",
7678
10341
  globalId: "string \u2014 globally unique ID",
10342
+ topicGlobalId: "string \u2014 topic global ID",
10343
+ epistemicNodeId: "string \u2014 materialized topic node ID",
10344
+ epistemicNodeGlobalId: "string \u2014 materialized topic node global ID",
7679
10345
  depth: "number \u2014 nesting depth"
7680
10346
  }
7681
10347
  },
@@ -7725,7 +10391,7 @@ var GET_TOPIC = {
7725
10391
  description: "Legacy alias for topicId"
7726
10392
  }
7727
10393
  },
7728
- required: [],
10394
+ required: ["topicId"],
7729
10395
  response: {
7730
10396
  description: "Single topic record",
7731
10397
  fields: {
@@ -7775,32 +10441,91 @@ var UPDATE_TOPIC = {
7775
10441
  },
7776
10442
  required: [],
7777
10443
  response: {
7778
- description: "The updated topic",
10444
+ description: "The updated topic",
10445
+ fields: {
10446
+ id: "string \u2014 topic ID",
10447
+ globalId: "string \u2014 globally unique ID",
10448
+ status: "string \u2014 topic lifecycle status",
10449
+ visibility: "string \u2014 topic visibility"
10450
+ }
10451
+ },
10452
+ ownerModule: "reasoning-kernel",
10453
+ ontologyPrimitive: "graph",
10454
+ tier: "workhorse"
10455
+ };
10456
+ var GET_TOPIC_TREE = {
10457
+ name: "get_topic_tree",
10458
+ description: "Get the full topic hierarchy from a root. Like `git log --graph --all` \u2014 shows the complete tree of nested topics.",
10459
+ parameters: {
10460
+ rootId: { type: "string", description: "Root topic to start from" },
10461
+ maxDepth: {
10462
+ type: "number",
10463
+ description: "Maximum depth to traverse (default: 5)"
10464
+ }
10465
+ },
10466
+ required: ["rootId"],
10467
+ response: {
10468
+ description: "Tree of topics with nesting",
10469
+ fields: { tree: "array \u2014 topics in BFS order with depth and path" }
10470
+ },
10471
+ ownerModule: "reasoning-kernel",
10472
+ ontologyPrimitive: "graph",
10473
+ tier: "workhorse"
10474
+ };
10475
+ var MATERIALIZE_TOPIC_GRAPH = {
10476
+ name: "materialize_topic_graph",
10477
+ description: "Backfill the topic graph spine. Like `git fsck --connectivity-only` with repair enabled \u2014 creates missing topic nodes and parent-child edges idempotently.",
10478
+ parameters: {
10479
+ rootTopicId: {
10480
+ type: "string",
10481
+ description: "Optional root topic for a bounded materialization pass"
10482
+ },
10483
+ dryRun: {
10484
+ type: "boolean",
10485
+ description: "When true, report missing rows without writing them"
10486
+ }
10487
+ },
10488
+ required: [],
10489
+ response: {
10490
+ description: "Topic graph materialization counts",
7779
10491
  fields: {
7780
- id: "string \u2014 topic ID",
7781
- globalId: "string \u2014 globally unique ID",
7782
- status: "string \u2014 topic lifecycle status",
7783
- visibility: "string \u2014 topic visibility"
10492
+ topicsSeen: "number",
10493
+ nodesCreated: "number",
10494
+ nodesExisting: "number",
10495
+ edgesCreated: "number",
10496
+ edgesExisting: "number",
10497
+ errors: "array"
7784
10498
  }
7785
10499
  },
7786
10500
  ownerModule: "reasoning-kernel",
7787
10501
  ontologyPrimitive: "graph",
7788
10502
  tier: "workhorse"
7789
10503
  };
7790
- var GET_TOPIC_TREE = {
7791
- name: "get_topic_tree",
7792
- description: "Get the full topic hierarchy from a root. Like `git log --graph --all` \u2014 shows the complete tree of nested topics.",
10504
+ var GET_TOPIC_GRAPH_SPINE = {
10505
+ name: "get_topic_graph_spine",
10506
+ description: "Verify the topic graph spine. Like `git fsck` \u2014 reads topics, materialized topic nodes, parent-child edges, and missing spine rows.",
7793
10507
  parameters: {
7794
- rootId: { type: "string", description: "Root topic to start from" },
7795
- maxDepth: {
7796
- type: "number",
7797
- description: "Maximum depth to traverse (default: 5)"
10508
+ rootTopicId: {
10509
+ type: "string",
10510
+ description: "Optional root topic for a bounded verifier pass"
10511
+ },
10512
+ includeTopicBeliefEdges: {
10513
+ type: "boolean",
10514
+ description: "Include topic -> belief edges in the verifier payload"
7798
10515
  }
7799
10516
  },
7800
- required: ["rootId"],
10517
+ required: [],
7801
10518
  response: {
7802
- description: "Tree of topics with nesting",
7803
- fields: { tree: "array \u2014 topics in BFS order with depth and path" }
10519
+ description: "Topic graph spine verification payload",
10520
+ fields: {
10521
+ ok: "boolean",
10522
+ counts: "object",
10523
+ topics: "array",
10524
+ topicNodes: "array",
10525
+ parentEdges: "array",
10526
+ missingTopicNodes: "array",
10527
+ missingParentEdges: "array"
10528
+ }
7804
10529
  },
7805
10530
  ownerModule: "reasoning-kernel",
7806
10531
  ontologyPrimitive: "graph",
@@ -8080,7 +10805,7 @@ var GET_ONTOLOGY = {
8080
10805
  description: "Tenant scope for key lookup. Omit for platform-level."
8081
10806
  }
8082
10807
  },
8083
- required: [],
10808
+ required: ["id"],
8084
10809
  response: {
8085
10810
  description: "Ontology definition with latest published version",
8086
10811
  fields: {
@@ -8147,7 +10872,7 @@ var MATCH_ENTITY_TYPE = {
8147
10872
  description: "Optional maximum number of ranked matches to return"
8148
10873
  }
8149
10874
  },
8150
- required: ["text"],
10875
+ required: ["text", "ontologyId"],
8151
10876
  response: {
8152
10877
  description: "Ranked ontology entity type matches",
8153
10878
  fields: {
@@ -8401,7 +11126,7 @@ var RECORD_SCOPE_LEARNING = {
8401
11126
  };
8402
11127
  var PIPELINE_SNAPSHOT = {
8403
11128
  name: "pipeline_snapshot",
8404
- description: "Summarize a topic's worktree pipeline in band-and-lane form. Like `git status --short` for Lucern execution \u2014 returns the hinge worktree, next planned wave, blockers, critical path, superseded work, and graph hygiene debt.",
11129
+ description: "Summarize a topic's worktree pipeline in campaign-and-lane form. Like `git status --short` for Lucern execution \u2014 returns the hinge worktree, next planned wave, blockers, critical path, superseded work, and graph hygiene debt.",
8405
11130
  parameters: {
8406
11131
  topicId: { type: "string", description: "Topic scope ID" }
8407
11132
  },
@@ -8411,14 +11136,14 @@ var PIPELINE_SNAPSHOT = {
8411
11136
  fields: {
8412
11137
  topicId: "string",
8413
11138
  topicName: "string",
8414
- currentBand: "number | null",
8415
- nextBand: "number | null",
11139
+ currentCampaign: "number | null",
11140
+ nextCampaign: "number | null",
8416
11141
  activeWorktrees: "array \u2014 current hinge worktree(s)",
8417
- nextWave: "array \u2014 worktrees in the next planned band",
11142
+ nextWave: "array \u2014 worktrees in the next planned campaign",
8418
11143
  readyNow: "array \u2014 planning worktrees with dependencies completed",
8419
11144
  blockedBy: "array \u2014 grouped blockers",
8420
11145
  criticalPath: "array \u2014 ordered incomplete worktree chain",
8421
- bands: "array \u2014 incomplete worktrees grouped by executionBand",
11146
+ campaigns: "array \u2014 incomplete worktrees grouped by campaign",
8422
11147
  superseded: "array \u2014 worktrees marked superseded or not for activation",
8423
11148
  graphHygiene: "object \u2014 untargeted and taskless worktree debt",
8424
11149
  riskQuestions: "array \u2014 critical/high open questions",
@@ -8938,6 +11663,69 @@ var GENERATE_SESSION_HANDOFF = {
8938
11663
  tier: "showcase",
8939
11664
  internal: true
8940
11665
  };
11666
+ var BEGIN_BUILD_SESSION = {
11667
+ name: "begin_build_session",
11668
+ 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.",
11669
+ parameters: {
11670
+ worktreeId: {
11671
+ type: "string",
11672
+ description: "The Lucern worktree ID to bootstrap."
11673
+ },
11674
+ branch: {
11675
+ type: "string",
11676
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
11677
+ },
11678
+ branchBase: {
11679
+ type: "string",
11680
+ description: 'Base branch for the feature branch. Default: "staging".'
11681
+ },
11682
+ prBase: {
11683
+ type: "string",
11684
+ description: 'Target branch for the PR. Default: "staging".'
11685
+ },
11686
+ sessionMode: {
11687
+ type: "string",
11688
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
11689
+ enum: ["async", "interactive"]
11690
+ },
11691
+ activateIfPlanning: {
11692
+ type: "boolean",
11693
+ description: "When true, automatically activate a planning worktree during bootstrap."
11694
+ }
11695
+ },
11696
+ required: ["worktreeId"],
11697
+ response: {
11698
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
11699
+ fields: {
11700
+ topicId: "string \u2014 canonical topic scope",
11701
+ topicName: "string \u2014 human-readable topic name",
11702
+ worktreeId: "string \u2014 worktree ID",
11703
+ worktreeName: "string \u2014 human-readable worktree name",
11704
+ branch: "string \u2014 git branch name",
11705
+ branchBase: "string \u2014 base branch",
11706
+ prBase: "string \u2014 PR target branch",
11707
+ campaign: "number | null \u2014 top-level pipeline campaign",
11708
+ lane: "string \u2014 campaign lane",
11709
+ gate: "string \u2014 exit gate",
11710
+ hypothesis: "string \u2014 worktree hypothesis",
11711
+ focus: "string \u2014 session focus",
11712
+ status: "string \u2014 worktree status after optional activation",
11713
+ sessionMode: "string \u2014 async | interactive",
11714
+ targetBeliefIds: "array \u2014 scoped belief IDs",
11715
+ targetQuestionIds: "array \u2014 scoped question IDs",
11716
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
11717
+ openQuestions: "array \u2014 open scoped questions",
11718
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
11719
+ dependencies: "array \u2014 upstream worktrees",
11720
+ unblocks: "array \u2014 downstream worktrees",
11721
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
11722
+ }
11723
+ },
11724
+ ownerModule: "bootstrap",
11725
+ ontologyPrimitive: "worktree",
11726
+ tier: "showcase",
11727
+ internal: true
11728
+ };
8941
11729
  var MCP_TOOL_CONTRACTS = {
8942
11730
  // Belief lifecycle (commit, amend, fork, archive)
8943
11731
  create_belief: CREATE_BELIEF,
@@ -8980,11 +11768,26 @@ var MCP_TOOL_CONTRACTS = {
8980
11768
  bisect_confidence: BISECT_CONFIDENCE,
8981
11769
  // Edges (commit)
8982
11770
  create_edge: CREATE_EDGE,
11771
+ update_edge: UPDATE_EDGE,
11772
+ remove_edge: REMOVE_EDGE,
11773
+ remove_edges_between: REMOVE_EDGES_BETWEEN,
11774
+ batch_create_edges: BATCH_CREATE_EDGES,
11775
+ // Epistemic node spine (commit/amend/show)
11776
+ create_epistemic_node: CREATE_EPISTEMIC_NODE,
11777
+ get_epistemic_node: GET_EPISTEMIC_NODE,
11778
+ list_epistemic_nodes: LIST_EPISTEMIC_NODES,
11779
+ update_epistemic_node: UPDATE_EPISTEMIC_NODE,
11780
+ archive_epistemic_node: ARCHIVE_EPISTEMIC_NODE,
11781
+ verify_epistemic_node: VERIFY_EPISTEMIC_NODE,
11782
+ supersede_epistemic_node: SUPERSEDE_EPISTEMIC_NODE,
11783
+ batch_create_epistemic_nodes: BATCH_CREATE_EPISTEMIC_NODES,
8983
11784
  // Judgments (tag)
8984
11785
  record_judgment: RECORD_JUDGMENT,
8985
11786
  // Graph intelligence (showcase)
8986
11787
  detect_confirmation_bias: DETECT_CONFIRMATION_BIAS,
8987
11788
  get_graph_structure_analysis: GET_GRAPH_STRUCTURE_ANALYSIS,
11789
+ list_graph_intelligence_queries: LIST_GRAPH_INTELLIGENCE_QUERIES,
11790
+ run_graph_intelligence_query: RUN_GRAPH_INTELLIGENCE_QUERY,
8988
11791
  get_falsification_questions: GET_FALSIFICATION_QUESTIONS,
8989
11792
  // Evidence operations (workhorse)
8990
11793
  search_evidence: SEARCH_EVIDENCE,
@@ -9007,6 +11810,7 @@ var MCP_TOOL_CONTRACTS = {
9007
11810
  list_beliefs: LIST_BELIEFS,
9008
11811
  list_worktrees: LIST_WORKTREES,
9009
11812
  list_all_worktrees: LIST_ALL_WORKTREES,
11813
+ list_campaigns: LIST_CAMPAIGNS,
9010
11814
  activate_worktree: ACTIVATE_WORKTREE,
9011
11815
  update_worktree_targets: UPDATE_WORKTREE_TARGETS,
9012
11816
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
@@ -9030,6 +11834,7 @@ var MCP_TOOL_CONTRACTS = {
9030
11834
  get_agent_inbox: GET_AGENT_INBOX,
9031
11835
  claim_files: CLAIM_FILES,
9032
11836
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
11837
+ begin_build_session: BEGIN_BUILD_SESSION,
9033
11838
  // Policy / ACL (workhorse)
9034
11839
  check_permission: CHECK_PERMISSION,
9035
11840
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -9049,6 +11854,8 @@ var MCP_TOOL_CONTRACTS = {
9049
11854
  get_topic: GET_TOPIC,
9050
11855
  update_topic: UPDATE_TOPIC,
9051
11856
  get_topic_tree: GET_TOPIC_TREE,
11857
+ materialize_topic_graph: MATERIALIZE_TOPIC_GRAPH,
11858
+ get_topic_graph_spine: GET_TOPIC_GRAPH_SPINE,
9052
11859
  // Coding intelligence (code-grounded knowledge)
9053
11860
  get_code_context: GET_CODE_CONTEXT,
9054
11861
  get_change_history: GET_CHANGE_HISTORY,
@@ -10697,6 +13504,952 @@ function validateSdkGitSemantics(tool) {
10697
13504
  return { valid: true };
10698
13505
  }
10699
13506
 
13507
+ // src/tenant-bootstrap-seed.contract.ts
13508
+ var TENANT_BOOTSTRAP_SEED_CONTRACT_VERSION = "2026-04-30";
13509
+ var TENANT_BOOTSTRAP_SEED_AUTH_METADATA_FIELDS = [
13510
+ "tenantId",
13511
+ "workspaceId",
13512
+ "principalId",
13513
+ "role",
13514
+ "authMode",
13515
+ "correlationId",
13516
+ "auditMetadata"
13517
+ ];
13518
+ var TENANT_BOOTSTRAP_SEED_COMPONENTS = {
13519
+ kernel: {
13520
+ componentName: "lucern",
13521
+ migrationModule: "adapters/migration",
13522
+ templateService: "services/kernel-template",
13523
+ templateDeployments: {
13524
+ staging: "kindly-goldfish-162",
13525
+ prod: "cool-badger-368"
13526
+ }
13527
+ },
13528
+ identity: {
13529
+ componentName: "identity",
13530
+ migrationModule: "migration",
13531
+ templateService: "services/identity-template",
13532
+ templateDeployments: {
13533
+ staging: "industrious-cheetah-864",
13534
+ prod: "combative-beagle-879"
13535
+ }
13536
+ }
13537
+ };
13538
+ function isCopyableSeedRequirement(entry) {
13539
+ 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;
13540
+ }
13541
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
13542
+ {
13543
+ component: "kernel",
13544
+ table: "agentMessages",
13545
+ prepopulation: "runtime_data",
13546
+ copyMode: "none",
13547
+ description: "Agent coordination messages are session data, not template data."
13548
+ },
13549
+ {
13550
+ component: "kernel",
13551
+ table: "agentSessions",
13552
+ prepopulation: "runtime_data",
13553
+ copyMode: "none",
13554
+ description: "Agent coordination sessions are created by active clients."
13555
+ },
13556
+ {
13557
+ component: "kernel",
13558
+ table: "autofixJobs",
13559
+ prepopulation: "runtime_queue",
13560
+ copyMode: "none",
13561
+ description: "Autofix work items are runtime queue rows."
13562
+ },
13563
+ {
13564
+ component: "kernel",
13565
+ table: "backgroundJobRuns",
13566
+ prepopulation: "runtime_log",
13567
+ copyMode: "none",
13568
+ description: "Background job executions are runtime logs."
13569
+ },
13570
+ {
13571
+ component: "kernel",
13572
+ table: "backgroundJobSettings",
13573
+ prepopulation: "required_template",
13574
+ copyMode: "template_global",
13575
+ scope: "global",
13576
+ uniqueKey: ["jobKey"],
13577
+ description: "Default job enablement settings must come from the K template."
13578
+ },
13579
+ {
13580
+ component: "kernel",
13581
+ table: "beliefConfidence",
13582
+ prepopulation: "runtime_data",
13583
+ copyMode: "none",
13584
+ description: "Belief confidence rows are created with tenant graph facts."
13585
+ },
13586
+ {
13587
+ component: "kernel",
13588
+ table: "beliefEvidenceLinks",
13589
+ prepopulation: "runtime_data",
13590
+ copyMode: "none",
13591
+ description: "Belief-to-evidence links are tenant graph data."
13592
+ },
13593
+ {
13594
+ component: "kernel",
13595
+ table: "beliefHistory",
13596
+ prepopulation: "runtime_data",
13597
+ copyMode: "none",
13598
+ description: "Belief history is append-only tenant graph data."
13599
+ },
13600
+ {
13601
+ component: "kernel",
13602
+ table: "beliefScenarios",
13603
+ prepopulation: "runtime_data",
13604
+ copyMode: "none",
13605
+ description: "Scenario rows are tenant-authored reasoning data."
13606
+ },
13607
+ {
13608
+ component: "kernel",
13609
+ table: "beliefVotes",
13610
+ prepopulation: "runtime_data",
13611
+ copyMode: "none",
13612
+ description: "Decision belief votes are tenant-authored data."
13613
+ },
13614
+ {
13615
+ component: "kernel",
13616
+ table: "calibrationScores",
13617
+ prepopulation: "runtime_derived",
13618
+ copyMode: "none",
13619
+ description: "Calibration scores are computed from tenant outcomes."
13620
+ },
13621
+ {
13622
+ component: "kernel",
13623
+ table: "contractEvaluations",
13624
+ prepopulation: "runtime_log",
13625
+ copyMode: "none",
13626
+ description: "Contract evaluation rows are runtime computation logs."
13627
+ },
13628
+ {
13629
+ component: "kernel",
13630
+ table: "contradictions",
13631
+ prepopulation: "runtime_data",
13632
+ copyMode: "none",
13633
+ description: "Contradictions are tenant graph facts."
13634
+ },
13635
+ {
13636
+ component: "kernel",
13637
+ table: "crossProjectConnections",
13638
+ prepopulation: "runtime_data",
13639
+ copyMode: "none",
13640
+ description: "Cross-topic connections are tenant graph facts."
13641
+ },
13642
+ {
13643
+ component: "kernel",
13644
+ table: "decisionComputedSummaries",
13645
+ prepopulation: "runtime_derived",
13646
+ copyMode: "none",
13647
+ description: "Decision summaries are derived tenant outputs."
13648
+ },
13649
+ {
13650
+ component: "kernel",
13651
+ table: "decisionEvents",
13652
+ prepopulation: "runtime_data",
13653
+ copyMode: "none",
13654
+ description: "Decision events are lifecycle data."
13655
+ },
13656
+ {
13657
+ component: "kernel",
13658
+ table: "decisionParticipants",
13659
+ prepopulation: "runtime_data",
13660
+ copyMode: "none",
13661
+ description: "Decision participants are tenant-selected actors."
13662
+ },
13663
+ {
13664
+ component: "kernel",
13665
+ table: "decisionRiskLedger",
13666
+ prepopulation: "runtime_data",
13667
+ copyMode: "none",
13668
+ description: "Decision risk rows are tenant decision data."
13669
+ },
13670
+ {
13671
+ component: "kernel",
13672
+ table: "decisionSnapshots",
13673
+ prepopulation: "runtime_derived",
13674
+ copyMode: "none",
13675
+ description: "Decision snapshots are derived from tenant state."
13676
+ },
13677
+ {
13678
+ component: "kernel",
13679
+ table: "deliberationContributions",
13680
+ prepopulation: "runtime_data",
13681
+ copyMode: "none",
13682
+ description: "Deliberation contributions are tenant-authored data."
13683
+ },
13684
+ {
13685
+ component: "kernel",
13686
+ table: "deliberationSessions",
13687
+ prepopulation: "runtime_data",
13688
+ copyMode: "none",
13689
+ description: "Deliberation sessions are created by tenant workflows."
13690
+ },
13691
+ {
13692
+ component: "kernel",
13693
+ table: "epistemicAudit",
13694
+ prepopulation: "runtime_log",
13695
+ copyMode: "none",
13696
+ description: "Epistemic audit rows are append-only runtime audit data."
13697
+ },
13698
+ {
13699
+ component: "kernel",
13700
+ table: "epistemicContracts",
13701
+ prepopulation: "runtime_data",
13702
+ copyMode: "none",
13703
+ description: "Epistemic contracts are tenant-authored governance data."
13704
+ },
13705
+ {
13706
+ component: "kernel",
13707
+ table: "epistemicEdges",
13708
+ prepopulation: "runtime_data",
13709
+ copyMode: "none",
13710
+ description: "Edges are tenant reasoning graph data."
13711
+ },
13712
+ {
13713
+ component: "kernel",
13714
+ table: "epistemicNodeEmbeddings",
13715
+ prepopulation: "runtime_derived",
13716
+ copyMode: "none",
13717
+ description: "Embeddings are derived from tenant graph nodes."
13718
+ },
13719
+ {
13720
+ component: "kernel",
13721
+ table: "epistemicNodes",
13722
+ prepopulation: "runtime_data",
13723
+ copyMode: "none",
13724
+ description: "Nodes are tenant reasoning graph data."
13725
+ },
13726
+ {
13727
+ component: "kernel",
13728
+ table: "graphAnalysisCache",
13729
+ prepopulation: "runtime_derived",
13730
+ copyMode: "none",
13731
+ description: "Graph analysis cache rows are derived from tenant graph state."
13732
+ },
13733
+ {
13734
+ component: "kernel",
13735
+ table: "graphAnalysisResults",
13736
+ prepopulation: "runtime_derived",
13737
+ copyMode: "none",
13738
+ description: "Graph analysis result rows are derived tenant outputs."
13739
+ },
13740
+ {
13741
+ component: "kernel",
13742
+ table: "graphSuggestions",
13743
+ prepopulation: "runtime_derived",
13744
+ copyMode: "none",
13745
+ description: "Graph suggestions are derived recommendations."
13746
+ },
13747
+ {
13748
+ component: "kernel",
13749
+ table: "harnessReplays",
13750
+ prepopulation: "runtime_log",
13751
+ copyMode: "none",
13752
+ description: "Harness replay rows are runtime verification logs."
13753
+ },
13754
+ {
13755
+ component: "kernel",
13756
+ table: "harnessRuns",
13757
+ prepopulation: "runtime_log",
13758
+ copyMode: "none",
13759
+ description: "Harness run rows are runtime verification logs."
13760
+ },
13761
+ {
13762
+ component: "kernel",
13763
+ table: "idempotencyTokens",
13764
+ prepopulation: "runtime_log",
13765
+ copyMode: "none",
13766
+ description: "Idempotency tokens are request-scoped runtime guards."
13767
+ },
13768
+ {
13769
+ component: "kernel",
13770
+ table: "lenses",
13771
+ prepopulation: "optional_template",
13772
+ copyMode: "none",
13773
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
13774
+ },
13775
+ {
13776
+ component: "kernel",
13777
+ table: "lensTopicBindings",
13778
+ prepopulation: "runtime_data",
13779
+ copyMode: "none",
13780
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
13781
+ },
13782
+ {
13783
+ component: "kernel",
13784
+ table: "neo4jSyncQueue",
13785
+ prepopulation: "runtime_queue",
13786
+ copyMode: "none",
13787
+ description: "Neo4j sync queue rows are runtime work items."
13788
+ },
13789
+ {
13790
+ component: "kernel",
13791
+ table: "ontologyDefinitions",
13792
+ prepopulation: "required_template",
13793
+ copyMode: "template_global",
13794
+ scope: "global",
13795
+ uniqueKey: ["ontologyKey"],
13796
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
13797
+ },
13798
+ {
13799
+ component: "kernel",
13800
+ table: "ontologyVersions",
13801
+ prepopulation: "required_template",
13802
+ copyMode: "template_reference_remap",
13803
+ scope: "global",
13804
+ uniqueKey: ["ontologyKey", "version"],
13805
+ dependsOn: ["ontologyDefinitions"],
13806
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
13807
+ },
13808
+ {
13809
+ component: "kernel",
13810
+ table: "platformAgentRunPolicyDecisions",
13811
+ prepopulation: "runtime_log",
13812
+ copyMode: "none",
13813
+ description: "Agent-run policy decisions are audit logs."
13814
+ },
13815
+ {
13816
+ component: "kernel",
13817
+ table: "platformAgentRunPromptResolutions",
13818
+ prepopulation: "runtime_log",
13819
+ copyMode: "none",
13820
+ description: "Agent-run prompt resolution rows are runtime logs."
13821
+ },
13822
+ {
13823
+ component: "kernel",
13824
+ table: "platformAgentRuns",
13825
+ prepopulation: "runtime_log",
13826
+ copyMode: "none",
13827
+ description: "Agent runs are runtime execution records."
13828
+ },
13829
+ {
13830
+ component: "kernel",
13831
+ table: "platformAgentRunToolCalls",
13832
+ prepopulation: "runtime_log",
13833
+ copyMode: "none",
13834
+ description: "Agent-run tool calls are runtime execution records."
13835
+ },
13836
+ {
13837
+ component: "kernel",
13838
+ table: "platformHarnessShadowAudit",
13839
+ prepopulation: "runtime_log",
13840
+ copyMode: "none",
13841
+ description: "Harness shadow audit rows are runtime audit records."
13842
+ },
13843
+ {
13844
+ component: "kernel",
13845
+ table: "publicationRules",
13846
+ prepopulation: "required_template",
13847
+ copyMode: "template_tenant_rewrite",
13848
+ scope: "tenant",
13849
+ uniqueKey: ["tenantId", "workspaceId", "name"],
13850
+ description: "Default publication policy rules are rewritten into each tenant."
13851
+ },
13852
+ {
13853
+ component: "kernel",
13854
+ table: "questionEvidenceLinks",
13855
+ prepopulation: "runtime_data",
13856
+ copyMode: "none",
13857
+ description: "Question-to-evidence links are tenant graph data."
13858
+ },
13859
+ {
13860
+ component: "kernel",
13861
+ table: "researchJobs",
13862
+ prepopulation: "runtime_queue",
13863
+ copyMode: "none",
13864
+ description: "Research job rows are runtime queue items."
13865
+ },
13866
+ {
13867
+ component: "kernel",
13868
+ table: "schemaEnumConfig",
13869
+ prepopulation: "required_template",
13870
+ copyMode: "template_global",
13871
+ scope: "global",
13872
+ uniqueKey: ["category", "value"],
13873
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
13874
+ },
13875
+ {
13876
+ component: "kernel",
13877
+ table: "stakeholderGroups",
13878
+ prepopulation: "runtime_data",
13879
+ copyMode: "none",
13880
+ description: "Stakeholder groups are tenant decision data."
13881
+ },
13882
+ {
13883
+ component: "kernel",
13884
+ table: "systemLogs",
13885
+ prepopulation: "runtime_log",
13886
+ copyMode: "none",
13887
+ description: "System logs are runtime telemetry."
13888
+ },
13889
+ {
13890
+ component: "kernel",
13891
+ table: "tasks",
13892
+ prepopulation: "runtime_data",
13893
+ copyMode: "none",
13894
+ description: "Tasks are tenant-authored work items."
13895
+ },
13896
+ {
13897
+ component: "kernel",
13898
+ table: "topics",
13899
+ prepopulation: "runtime_bootstrap",
13900
+ copyMode: "none",
13901
+ description: "Default topics are created by tenant provisioning, not copied from templates."
13902
+ },
13903
+ {
13904
+ component: "kernel",
13905
+ table: "workflowDefinitions",
13906
+ prepopulation: "optional_template",
13907
+ copyMode: "none",
13908
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
13909
+ },
13910
+ {
13911
+ component: "kernel",
13912
+ table: "workflowPullRequests",
13913
+ prepopulation: "runtime_data",
13914
+ copyMode: "none",
13915
+ description: "Workflow pull requests are tenant workflow data."
13916
+ },
13917
+ {
13918
+ component: "kernel",
13919
+ table: "workflowStages",
13920
+ prepopulation: "optional_template",
13921
+ copyMode: "none",
13922
+ dependsOn: ["workflowDefinitions"],
13923
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
13924
+ },
13925
+ {
13926
+ component: "kernel",
13927
+ table: "worktreeBeliefCluster",
13928
+ prepopulation: "runtime_data",
13929
+ copyMode: "none",
13930
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
13931
+ },
13932
+ {
13933
+ component: "kernel",
13934
+ table: "worktrees",
13935
+ prepopulation: "runtime_data",
13936
+ copyMode: "none",
13937
+ description: "Worktrees are tenant/runtime planning data."
13938
+ },
13939
+ {
13940
+ component: "identity",
13941
+ table: "agents",
13942
+ prepopulation: "runtime_bootstrap",
13943
+ copyMode: "none",
13944
+ description: "Service agents are provisioned per tenant or service, not copied."
13945
+ },
13946
+ {
13947
+ component: "identity",
13948
+ table: "mcpWritePolicy",
13949
+ prepopulation: "required_template",
13950
+ copyMode: "template_global",
13951
+ scope: "global",
13952
+ uniqueKey: ["topicId", "role", "toolCategory"],
13953
+ description: "Global write policy defaults govern service and interactive MCP writes."
13954
+ },
13955
+ {
13956
+ component: "identity",
13957
+ table: "modelCallLogs",
13958
+ prepopulation: "runtime_log",
13959
+ copyMode: "none",
13960
+ description: "Model call logs are runtime telemetry."
13961
+ },
13962
+ {
13963
+ component: "identity",
13964
+ table: "modelFunctionSlots",
13965
+ prepopulation: "required_template",
13966
+ copyMode: "template_global",
13967
+ scope: "global",
13968
+ uniqueKey: ["slot"],
13969
+ description: "Function-to-model slots are required by model runtime resolution."
13970
+ },
13971
+ {
13972
+ component: "identity",
13973
+ table: "modelRegistry",
13974
+ prepopulation: "required_template",
13975
+ copyMode: "template_global",
13976
+ scope: "global",
13977
+ uniqueKey: ["key"],
13978
+ description: "Model catalog defaults are required by model runtime clients."
13979
+ },
13980
+ {
13981
+ component: "identity",
13982
+ table: "modelSlotConfigs",
13983
+ prepopulation: "required_template",
13984
+ copyMode: "template_global",
13985
+ scope: "global",
13986
+ uniqueKey: ["slot"],
13987
+ description: "Slot-level defaults are required before tenant overrides exist."
13988
+ },
13989
+ {
13990
+ component: "identity",
13991
+ table: "platformAudienceGrants",
13992
+ prepopulation: "runtime_data",
13993
+ copyMode: "none",
13994
+ description: "Audience grants are principal/group-specific access rows."
13995
+ },
13996
+ {
13997
+ component: "identity",
13998
+ table: "platformAudiences",
13999
+ prepopulation: "required_template",
14000
+ copyMode: "template_tenant_rewrite",
14001
+ scope: "tenant",
14002
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
14003
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
14004
+ },
14005
+ {
14006
+ component: "identity",
14007
+ table: "platformPolicyDecisionLogs",
14008
+ prepopulation: "runtime_log",
14009
+ copyMode: "none",
14010
+ description: "Policy decisions are runtime audit logs."
14011
+ },
14012
+ {
14013
+ component: "identity",
14014
+ table: "projectGrants",
14015
+ prepopulation: "runtime_data",
14016
+ copyMode: "none",
14017
+ description: "Project/topic grants are principal or group-specific access rows."
14018
+ },
14019
+ {
14020
+ component: "identity",
14021
+ table: "reasoningPermissions",
14022
+ prepopulation: "runtime_data",
14023
+ copyMode: "none",
14024
+ description: "Reasoning permissions are principal-specific policy rows."
14025
+ },
14026
+ {
14027
+ component: "identity",
14028
+ table: "tenantApiKeys",
14029
+ prepopulation: "runtime_secret",
14030
+ copyMode: "none",
14031
+ description: "API keys are tenant credentials and must never be copied."
14032
+ },
14033
+ {
14034
+ component: "identity",
14035
+ table: "tenantConfig",
14036
+ prepopulation: "required_template",
14037
+ copyMode: "template_tenant_rewrite",
14038
+ scope: "tenant",
14039
+ uniqueKey: ["tenantId"],
14040
+ description: "Tenant-local config defaults are rewritten during bootstrap."
14041
+ },
14042
+ {
14043
+ component: "identity",
14044
+ table: "tenantIntegrations",
14045
+ prepopulation: "required_template",
14046
+ copyMode: "template_tenant_rewrite",
14047
+ scope: "tenant",
14048
+ uniqueKey: ["tenantId", "integrationKey"],
14049
+ description: "Non-secret integration descriptors are rewritten into each tenant."
14050
+ },
14051
+ {
14052
+ component: "identity",
14053
+ table: "tenantModelSlotBindings",
14054
+ prepopulation: "runtime_secret",
14055
+ copyMode: "none",
14056
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
14057
+ },
14058
+ {
14059
+ component: "identity",
14060
+ table: "tenantPolicies",
14061
+ prepopulation: "required_template",
14062
+ copyMode: "template_tenant_rewrite",
14063
+ scope: "tenant",
14064
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
14065
+ description: "Default tenant policy roles are rewritten during bootstrap."
14066
+ },
14067
+ {
14068
+ component: "identity",
14069
+ table: "tenantProviderSecrets",
14070
+ prepopulation: "runtime_secret",
14071
+ copyMode: "none",
14072
+ description: "Provider secrets are credentials and must never be copied."
14073
+ },
14074
+ {
14075
+ component: "identity",
14076
+ table: "tenantProxyGatewayUsage",
14077
+ prepopulation: "runtime_log",
14078
+ copyMode: "none",
14079
+ description: "Proxy gateway usage rows are runtime telemetry."
14080
+ },
14081
+ {
14082
+ component: "identity",
14083
+ table: "tenantProxyTokenMints",
14084
+ prepopulation: "runtime_secret",
14085
+ copyMode: "none",
14086
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
14087
+ },
14088
+ {
14089
+ component: "identity",
14090
+ table: "tenantSandboxAuditEvents",
14091
+ prepopulation: "runtime_log",
14092
+ copyMode: "none",
14093
+ description: "Sandbox audit rows are runtime security logs."
14094
+ },
14095
+ {
14096
+ component: "identity",
14097
+ table: "tenantSecrets",
14098
+ prepopulation: "runtime_secret",
14099
+ copyMode: "none",
14100
+ description: "Tenant secrets are credentials and must never be copied."
14101
+ },
14102
+ {
14103
+ component: "identity",
14104
+ table: "toolAcls",
14105
+ prepopulation: "required_template",
14106
+ copyMode: "template_global",
14107
+ scope: "global",
14108
+ uniqueKey: ["role", "toolName"],
14109
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
14110
+ },
14111
+ {
14112
+ component: "identity",
14113
+ table: "toolRegistry",
14114
+ prepopulation: "required_template",
14115
+ copyMode: "template_global",
14116
+ scope: "global",
14117
+ uniqueKey: ["toolName"],
14118
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
14119
+ },
14120
+ {
14121
+ component: "identity",
14122
+ table: "users",
14123
+ prepopulation: "runtime_bootstrap",
14124
+ copyMode: "none",
14125
+ description: "Users are created from Clerk/MC principal resolution, not copied."
14126
+ }
14127
+ ];
14128
+ var TENANT_BOOTSTRAP_SEED_TABLES = TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14129
+ isCopyableSeedRequirement
14130
+ );
14131
+ var TENANT_BOOTSTRAP_FORBIDDEN_SEED_TABLES = TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
14132
+ (entry) => !isCopyableSeedRequirement(entry)
14133
+ ).map((entry) => entry.table);
14134
+ var TENANT_BOOTSTRAP_SEED_MANIFEST = {
14135
+ contractVersion: TENANT_BOOTSTRAP_SEED_CONTRACT_VERSION,
14136
+ authMetadataFields: TENANT_BOOTSTRAP_SEED_AUTH_METADATA_FIELDS,
14137
+ components: TENANT_BOOTSTRAP_SEED_COMPONENTS,
14138
+ tableRequirements: TENANT_BOOTSTRAP_TABLE_REQUIREMENTS,
14139
+ tables: TENANT_BOOTSTRAP_SEED_TABLES,
14140
+ forbiddenTables: TENANT_BOOTSTRAP_FORBIDDEN_SEED_TABLES
14141
+ };
14142
+ function findTenantBootstrapTableRequirement(table) {
14143
+ return TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.find(
14144
+ (entry) => entry.table === table
14145
+ );
14146
+ }
14147
+ function findTenantBootstrapSeedTable(table) {
14148
+ return TENANT_BOOTSTRAP_SEED_TABLES.find((entry) => entry.table === table);
14149
+ }
14150
+ function isTenantBootstrapSeedTable(table) {
14151
+ return Boolean(findTenantBootstrapSeedTable(table));
14152
+ }
14153
+ function isTenantBootstrapForbiddenSeedTable(table) {
14154
+ return TENANT_BOOTSTRAP_FORBIDDEN_SEED_TABLES.some((entry) => entry === table);
14155
+ }
14156
+ var TENANT_BOOTSTRAP_TEMPLATE_SEED_VERSION = "2026-04-30.1";
14157
+ var TENANT_BOOTSTRAP_TEMPLATE_TENANT_ID = "tenant_template";
14158
+ var TENANT_BOOTSTRAP_TEMPLATE_ACTOR = "system:lucern-template-seed";
14159
+ var DEFAULT_SEED_TIME = Date.UTC(2026, 3, 30);
14160
+ var ROLE_GRANTS = {
14161
+ viewer: ["viewer", "auditor", "editor", "workspace_admin", "tenant_admin", "platform_admin", "service_agent"],
14162
+ auditor: ["auditor", "tenant_admin", "platform_admin", "service_agent"],
14163
+ editor: ["editor", "workspace_admin", "tenant_admin", "platform_admin", "service_agent"],
14164
+ workspace_admin: ["workspace_admin", "tenant_admin", "platform_admin", "service_agent"],
14165
+ tenant_admin: ["tenant_admin", "platform_admin", "service_agent"],
14166
+ platform_admin: ["platform_admin", "service_agent"],
14167
+ service_agent: ["service_agent"]
14168
+ };
14169
+ var ENUM_VALUES = {
14170
+ topic_type: ["domain", "theme", "deal", "strategy", "constitution", "project", "portfolio", "architecture", "capability", "runtime", "interface", "governance", "operations", "security", "data"],
14171
+ branch_schema: ["pillar", "track", "dimension", "axis", "phase"],
14172
+ belief_type: ["belief", "hypothesis", "principle", "invariant", "assumption", "tenet", "prior", "preference", "goal", "forecast", "decision", "constraint", "tradeoff", "policy", "implementation_choice", "implementation_decision", "interface_contract", "migration_state", "code_pattern", "deprecation_notice"],
14173
+ edge_type: ["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"],
14174
+ worktree_type: ["belief_test", "lens", "existential", "contradiction", "refinement", "coverage", "discovery", "clarification", "confirmation"],
14175
+ worktree_phase: ["cluster_mapping", "hypothesis_formation", "question_generation", "evidence_collection", "synthesis", "decision", "retrospective"],
14176
+ activity_type: ["create", "update", "review", "merge", "archive", "comment", "status_change", "evidence_added", "question_added"],
14177
+ lens_perspective_type: ["investigation", "monitoring", "analysis", "comparison", "taxonomy"],
14178
+ node_type: ["belief", "question", "theme", "deal", "evidence", "claim", "synthesis", "source", "excerpt", "atomic_fact", "person", "company", "investor", "value_chain", "function", "decision"]
14179
+ };
14180
+ var MODEL_REGISTRY = [
14181
+ ["claude-sonnet-4", "Claude Sonnet 4", "claude-sonnet-4-20250514", "anthropic", 2e5, 64e3, 1, 3, 15],
14182
+ ["claude-sonnet-4.5", "Claude Sonnet 4.5", "claude-sonnet-4-5-20250929", "anthropic", 2e5, 64e3, 1, 3, 15],
14183
+ ["claude-opus-4", "Claude Opus 4", "claude-opus-4-20250514", "anthropic", 2e5, 32e3, 1, 15, 75],
14184
+ ["gpt-4o", "GPT-4o", "gpt-4o", "openai", 128e3, 16e3, 0.7, 5, 15],
14185
+ ["gpt-4o-mini", "GPT-4o Mini", "gpt-4o-mini", "openai", 128e3, 16e3, 0.7, 0.15, 0.6],
14186
+ ["gemini-2.5-pro", "Gemini 2.5 Pro", "gemini-2.5-pro", "google", 1e6, 32e3, 0.7, 1.25, 10],
14187
+ ["sonar-pro", "Sonar Pro", "sonar-pro", "perplexity", 128e3, 8e3, 0.3, 3, 15]
14188
+ ];
14189
+ var MODEL_SLOTS = [
14190
+ ["primer_default", "primers", "Default primer generation for general topics", "claude-sonnet-4", "agents/primer/system", 1, 4e3, ["text_generation", "reasoning"]],
14191
+ ["primer_technical", "primers", "Technical and engineering focused primers", "claude-sonnet-4", "agents/primer/system", 0.8, 4e3, ["text_generation", "reasoning", "code"]],
14192
+ ["primer_intelligence", "document_intelligence", "Extract evidence, beliefs, and questions from documents", "claude-sonnet-4", "agents/primer-intelligence", 0.3, 8e3, ["text_generation", "structured_output", "reasoning"]],
14193
+ ["fact_checker", "research", "Verify claims without web search", "claude-sonnet-4", "agents/internet-fact-checker", 0.3, 4e3, ["text_generation", "reasoning"]],
14194
+ ["fact_checker_web", "research", "Verify claims with web search", "sonar-pro", "agents/internet-fact-checker", 0.3, 4e3, ["web_search"]],
14195
+ ["deep_research", "research", "Deep research with extended analysis", "claude-opus-4", void 0, 0.7, 8e3, ["text_generation", "reasoning", "long_context"]],
14196
+ ["belief_classifier", "classification", "Classify beliefs by epistemic type", "claude-sonnet-4", "classification/belief-category", 0.2, 1e3, ["text_generation", "reasoning"]],
14197
+ ["evidence_classifier", "classification", "Classify evidence methodology and quality", "claude-sonnet-4", "classification/evidence-rules", 0.3, 1e3, ["text_generation", "reasoning"]],
14198
+ ["edge_classifier", "classification", "Classify edge reasoning method and temporal class", "claude-sonnet-4", "classification/epistemic-guidance", 0.3, 1e3, ["text_generation", "reasoning"]],
14199
+ ["entity_extractor", "extraction", "Extract entities from text", "claude-sonnet-4", void 0, 0.2, 2e3, ["text_generation", "structured_output"]],
14200
+ ["graph_intelligence_query", "graph_intelligence", "Analyze graph health, gaps, and structural risks", "claude-sonnet-4", "graph-intelligence/query", 0.5, 8e3, ["text_generation", "reasoning", "tool_use"]],
14201
+ ["graph_intelligence_suggestions", "graph_intelligence", "Extract actionable graph suggestions", "claude-sonnet-4", "graph-intelligence/suggestions-extraction", 0.2, 4e3, ["text_generation", "structured_output"]],
14202
+ ["text_to_cypher", "graph_intelligence", "Generate read-only Cypher from graph questions", "claude-sonnet-4", "graph-intelligence/text-to-cypher", 0.2, 2e3, ["text_generation", "code", "reasoning"]],
14203
+ ["contradiction_verifier", "epistemic", "Verify semantic contradiction candidates", "claude-sonnet-4", "lucern/verify-contradiction", 0.2, 500, ["text_generation", "reasoning"]],
14204
+ ["task_execution", "tasks", "Execute research tasks with structured analysis", "claude-sonnet-4", void 0, 0.3, 4e3, ["text_generation", "reasoning", "structured_output"]],
14205
+ ["sprint_unified", "sprints", "Unified worktree chat across all phases", "claude-opus-4", "worktrees/unified-system-prompt", 0.7, 8e3, ["text_generation", "reasoning", "tool_use"]],
14206
+ ["evidence_assessor", "sprints", "Assess evidence for belief valence and certainty", "claude-sonnet-4", "worktrees/scoring/evidence-assessor", 0.3, 4e3, ["text_generation", "reasoning", "structured_output"]],
14207
+ ["title_generator", "utility", "Generate concise titles", "gpt-4o-mini", void 0, 0.7, 100, ["text_generation", "fast", "cheap"]],
14208
+ ["help_desk_agent", "utility", "Help desk support agent for workflow guidance", "claude-sonnet-4", "agents/help-desk-agent", 0.4, 2e3, ["text_generation", "reasoning"]],
14209
+ ["bug_detective_agent", "utility", "Bug triage assistant for structured diagnosis", "claude-sonnet-4", "agents/bug-detective-agent", 0.3, 2e3, ["text_generation", "reasoning"]]
14210
+ ];
14211
+ function labelFor(value) {
14212
+ return value.split(/[_-]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
14213
+ }
14214
+ function seedContext(options) {
14215
+ return {
14216
+ now: options.now ?? DEFAULT_SEED_TIME,
14217
+ templateTenantId: options.templateTenantId ?? TENANT_BOOTSTRAP_TEMPLATE_TENANT_ID,
14218
+ actor: options.actorPrincipalId ?? TENANT_BOOTSTRAP_TEMPLATE_ACTOR,
14219
+ version: options.version ?? TENANT_BOOTSTRAP_TEMPLATE_SEED_VERSION
14220
+ };
14221
+ }
14222
+ function toolCategory(contract) {
14223
+ if (contract.surfaceIntent === "system") return "system";
14224
+ if (contract.effects.includes("admin")) return "admin";
14225
+ if (contract.effects.includes("write") || contract.kind !== "query") return "write";
14226
+ return "read";
14227
+ }
14228
+ function requiredRole(category) {
14229
+ if (category === "system") return "service_agent";
14230
+ if (category === "admin") return "tenant_admin";
14231
+ if (category === "write") return "editor";
14232
+ return "viewer";
14233
+ }
14234
+ function requiredAction(category) {
14235
+ if (category === "admin" || category === "system") return "admin";
14236
+ if (category === "write") return "mutate";
14237
+ return "read";
14238
+ }
14239
+ function enabledSurfaces(contract) {
14240
+ return [
14241
+ contract.surfaces.mcp !== "none" ? "mcp" : void 0,
14242
+ contract.surfaces.sdk !== "none" ? "sdk" : void 0,
14243
+ contract.surfaces.cli !== "none" ? "cli" : void 0,
14244
+ contract.surfaces.rest !== "none" ? "api" : void 0
14245
+ ].filter((value) => Boolean(value));
14246
+ }
14247
+ function buildToolRegistry(now, actor, version) {
14248
+ const rows = /* @__PURE__ */ new Map();
14249
+ for (const contract of ALL_FUNCTION_CONTRACTS) {
14250
+ const surfaces = enabledSurfaces(contract);
14251
+ if (surfaces.length === 0) continue;
14252
+ const category = toolCategory(contract);
14253
+ const readOnly = category === "read";
14254
+ const toolName = contract.mcp.toolName || contract.name;
14255
+ rows.set(toolName, {
14256
+ toolName,
14257
+ description: contract.openapi.summary,
14258
+ version,
14259
+ status: "active",
14260
+ requiredRole: requiredRole(category),
14261
+ requiredAction: requiredAction(category),
14262
+ surfaces,
14263
+ category,
14264
+ parameterSchema: { contract: contract.name, sdk: contract.sdk },
14265
+ handlerRef: contract.convex ? `${contract.convex.module}.${contract.convex.functionName}` : contract.name,
14266
+ executionAdapter: contract.convex?.kind === "action" ? "convex_action" : contract.convex?.kind === "mutation" ? "convex_mutation" : "mcp_tool",
14267
+ safetyMetadata: {
14268
+ readOnly,
14269
+ idempotent: readOnly || contract.idempotent === true || contract.idempotent === "required",
14270
+ sideEffectLevel: readOnly ? "none" : category === "admin" ? "high" : "low"
14271
+ },
14272
+ isCore: true,
14273
+ mcVersion: version,
14274
+ registeredBy: actor,
14275
+ registeredAt: now
14276
+ });
14277
+ }
14278
+ return [...rows.values()].sort(
14279
+ (a, b) => String(a.toolName).localeCompare(String(b.toolName))
14280
+ );
14281
+ }
14282
+ function buildToolAcls(tools, now, actor) {
14283
+ return tools.flatMap(
14284
+ (tool) => (ROLE_GRANTS[tool.requiredRole] ?? [tool.requiredRole]).map(
14285
+ (role) => ({ role, toolName: tool.toolName, createdBy: actor, createdAt: now })
14286
+ )
14287
+ );
14288
+ }
14289
+ function buildMcpWritePolicy(now, actor) {
14290
+ return [
14291
+ ...["viewer", "auditor"].map((role) => ({
14292
+ role,
14293
+ toolCategory: "write",
14294
+ permission: "deny",
14295
+ enabled: true,
14296
+ rationale: "Read-only roles cannot mutate the reasoning graph.",
14297
+ createdAt: now,
14298
+ updatedAt: now,
14299
+ createdBy: actor
14300
+ })),
14301
+ ...["editor", "workspace_admin", "tenant_admin", "platform_admin", "service_agent"].map((role) => ({
14302
+ role,
14303
+ toolCategory: "write",
14304
+ permission: "allow",
14305
+ maxWritesPerSession: role === "editor" ? 200 : void 0,
14306
+ enabled: true,
14307
+ rationale: "Default global write policy for trusted graph mutation roles.",
14308
+ createdAt: now,
14309
+ updatedAt: now,
14310
+ createdBy: actor
14311
+ }))
14312
+ ];
14313
+ }
14314
+ function buildTenantPolicies(tenantId, now, actor) {
14315
+ const rows = [
14316
+ ["viewer", "Read graph and runtime metadata.", [{ resource: "graph", actions: ["read"] }]],
14317
+ ["auditor", "Read graph, audit, and policy decisions.", [{ resource: "audit", actions: ["read", "export"] }]],
14318
+ ["editor", "Read and mutate tenant reasoning state.", [{ resource: "graph", actions: ["read", "create", "update", "mutate"] }]],
14319
+ ["workspace_admin", "Manage workspace-scoped reasoning operations.", [{ resource: "workspace", actions: ["read", "update", "admin"] }]],
14320
+ ["tenant_admin", "Manage tenant policy, tools, users, and publication.", [{ resource: "tenant", actions: ["read", "update", "admin"] }, { resource: "policy", actions: ["read", "create", "update", "admin"] }]],
14321
+ ["service_agent", "Service principal execution role for automation.", [{ resource: "runtime", actions: ["read", "create", "update"] }, { resource: "graph", actions: ["read", "create", "update", "mutate"] }]]
14322
+ ];
14323
+ return rows.map(([roleName, description, permissions]) => ({
14324
+ tenantId,
14325
+ roleName,
14326
+ description,
14327
+ permissions,
14328
+ groupBindings: [],
14329
+ createdAt: now,
14330
+ updatedAt: now,
14331
+ createdBy: actor,
14332
+ updatedBy: actor
14333
+ }));
14334
+ }
14335
+ function modelRegistryRows(now) {
14336
+ return MODEL_REGISTRY.map(([key, name, modelId, provider, contextWindow, maxOutputTokens, defaultTemperature, inputCostPer1M, outputCostPer1M]) => ({
14337
+ key,
14338
+ name,
14339
+ modelId,
14340
+ provider,
14341
+ capabilities: ["text_generation", "reasoning"],
14342
+ contextWindow,
14343
+ maxOutputTokens,
14344
+ defaultTemperature,
14345
+ inputCostPer1M,
14346
+ outputCostPer1M,
14347
+ recommended: true,
14348
+ enabled: true,
14349
+ createdAt: now,
14350
+ updatedAt: now
14351
+ }));
14352
+ }
14353
+ function modelFunctionSlotRows(now) {
14354
+ return MODEL_SLOTS.map(([slot, category, description, modelKey, promptName, temperature, maxTokens, requiredCapabilities]) => ({
14355
+ slot,
14356
+ category,
14357
+ description,
14358
+ modelKey,
14359
+ promptName,
14360
+ temperature,
14361
+ maxTokens,
14362
+ requiredCapabilities,
14363
+ enabled: true,
14364
+ isDefault: true,
14365
+ notes: `Seeded by ${TENANT_BOOTSTRAP_TEMPLATE_SEED_VERSION}.`,
14366
+ createdAt: now,
14367
+ updatedAt: now
14368
+ }));
14369
+ }
14370
+ function modelSlotConfigRows(now) {
14371
+ return MODEL_SLOTS.map(([slot, , , modelKey, , temperature, maxTokens]) => ({
14372
+ slot,
14373
+ modelKey,
14374
+ temperature,
14375
+ maxTokens,
14376
+ enabled: true,
14377
+ notes: `Default routing for ${slot}.`,
14378
+ createdAt: now,
14379
+ updatedAt: now
14380
+ }));
14381
+ }
14382
+ function schemaEnumRows(now) {
14383
+ return Object.entries(ENUM_VALUES).flatMap(
14384
+ ([category, values]) => values.map((value, index) => ({
14385
+ category,
14386
+ value,
14387
+ label: labelFor(value),
14388
+ description: `${labelFor(value)} ${category} value.`,
14389
+ tier: "platform",
14390
+ metadata: { seedVersion: TENANT_BOOTSTRAP_TEMPLATE_SEED_VERSION },
14391
+ isDefault: index === 0,
14392
+ sortOrder: index + 1,
14393
+ status: "active",
14394
+ createdAt: now,
14395
+ updatedAt: now
14396
+ }))
14397
+ );
14398
+ }
14399
+ function buildTenantBootstrapTemplateSeedRows(options = {}) {
14400
+ const ctx = seedContext(options);
14401
+ const toolRegistry2 = buildToolRegistry(ctx.now, ctx.actor, ctx.version);
14402
+ return {
14403
+ kernel: {
14404
+ backgroundJobSettings: [
14405
+ { jobKey: "neo4j_sync", enabled: false, notes: "Disabled until graph-sync credentials are configured.", updatedAt: ctx.now, updatedBy: ctx.actor },
14406
+ { jobKey: "calibration_rollups", enabled: true, notes: "Compute calibration rollups when calibration data exists.", updatedAt: ctx.now, updatedBy: ctx.actor }
14407
+ ],
14408
+ ontologyDefinitions: [
14409
+ { ontologyKey: "lucern-core", name: "Lucern Core", description: "Core Lucern reasoning taxonomy.", tier: "platform", status: "active", createdBy: ctx.actor, createdAt: ctx.now, updatedAt: ctx.now }
14410
+ ],
14411
+ ontologyVersions: [
14412
+ {
14413
+ ontologyId: "lucern-core",
14414
+ ontologyKey: "lucern-core",
14415
+ version: ctx.version,
14416
+ status: "published",
14417
+ entityTypes: ["belief", "question", "evidence", "answer", "decision", "task", "worktree", "topic", "source"].map((value) => ({ value, label: labelFor(value) })),
14418
+ edgeTypes: ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to"].map((value) => ({ value, label: labelFor(value) })),
14419
+ releaseNotes: "Initial platform ontology seed.",
14420
+ publishedBy: ctx.actor,
14421
+ publishedAt: ctx.now,
14422
+ createdAt: ctx.now
14423
+ }
14424
+ ],
14425
+ publicationRules: [
14426
+ { tenantId: ctx.templateTenantId, name: "publish-high-confidence-beliefs", description: "Publish high-confidence beliefs to tenant-level consumers.", conditionType: "confidence_threshold", conditions: { minConfidence: 0.85 }, enabled: true, priority: 100, createdBy: ctx.actor, createdAt: ctx.now, updatedAt: ctx.now }
14427
+ ],
14428
+ schemaEnumConfig: schemaEnumRows(ctx.now)
14429
+ },
14430
+ identity: {
14431
+ mcpWritePolicy: buildMcpWritePolicy(ctx.now, ctx.actor),
14432
+ modelFunctionSlots: modelFunctionSlotRows(ctx.now),
14433
+ modelRegistry: modelRegistryRows(ctx.now),
14434
+ modelSlotConfigs: modelSlotConfigRows(ctx.now),
14435
+ platformAudiences: [
14436
+ ["internal", "Internal", "internal"],
14437
+ ["lp", "Limited Partners", "restricted_external"],
14438
+ ["public", "Public", "public"]
14439
+ ].map(([audienceKey, audienceLabel, audienceClass]) => ({ tenantId: ctx.templateTenantId, audienceKey, audienceLabel, audienceClass, status: "active", metadata: { seedVersion: ctx.version }, createdBy: ctx.actor, createdAt: ctx.now, updatedAt: ctx.now })),
14440
+ tenantConfig: [
14441
+ { tenantId: ctx.templateTenantId, authPolicyMode: "open", defaultSessionTTL: 28800, defaultTopicVisibility: "tenant", featureFlags: { sdkBootstrapSeeds: true, interactiveRoleAuth: true }, maxWorkspaceCount: 25, defaultModelSlotOverrides: {}, updatedAt: ctx.now, updatedBy: ctx.actor }
14442
+ ],
14443
+ tenantIntegrations: [
14444
+ { tenantId: ctx.templateTenantId, integrationKey: "web-search", displayName: "Web Search", description: "Tenant-configurable search integration placeholder.", category: "search", capabilities: ["search", "deep_research", "summarize"], config: { apiBaseUrl: "https://example.invalid/lucern/search", authType: "none", timeout: 3e4 }, endpoints: { search: { path: "/search", method: "POST", queryParamName: "query", resultPath: "results" } }, status: "disabled", usageCount: 0, createdAt: ctx.now, updatedAt: ctx.now, createdBy: ctx.actor }
14445
+ ],
14446
+ tenantPolicies: buildTenantPolicies(ctx.templateTenantId, ctx.now, ctx.actor),
14447
+ toolAcls: buildToolAcls(toolRegistry2, ctx.now, ctx.actor),
14448
+ toolRegistry: toolRegistry2
14449
+ }
14450
+ };
14451
+ }
14452
+
10700
14453
  // src/v1/topics/v1.ts
10701
14454
  var ROOT_TOPIC_ID = "n17tm38rwet7wqgzrmwahyt1z582590y";
10702
14455
  function collectTopicNeighborhood(topics2, rootTopicId, maxDescendantDepth = 2) {
@@ -10884,7 +14637,7 @@ var CANONICAL_WORKFLOW_DEFINITIONS = [
10884
14637
  actionId: "run_integrity_checks",
10885
14638
  kind: "integrity_check",
10886
14639
  title: "Run integrity checks",
10887
- description: "Evaluate dependency references, blockers, execution bands, shaping coverage, and completed gates.",
14640
+ description: "Evaluate dependency references, blockers, campaign/lane placement, shaping coverage, and completed gates.",
10888
14641
  mutationTier: "read_only",
10889
14642
  produces: ["structured_payload"],
10890
14643
  idempotent: true,
@@ -10990,6 +14743,6 @@ var CANONICAL_WORKFLOW_DEFINITIONS = [
10990
14743
  }
10991
14744
  ];
10992
14745
 
10993
- export { BELIEF_STATUSES, BELIEF_TYPE_BONUS, BRANCH_STATUSES, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTEXT_PACK_SCHEMA_VERSION, CONTEXT_PACK_SECTION_KEYS, CONTEXT_RANKING_PROFILES, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_RANKING_PROFILE, DEFAULT_SECTION_LIMIT, DEFAULT_SEVERITY_SCORE, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_TOKEN_BUDGET, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, ENTITY_RANKING_WEIGHTS, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, INTEGRATION_EDGE_TYPES, JUDGMENT_TYPES, MAX_ENTITY_LIMIT, MAX_SECTION_LIMIT, MAX_TOKEN_BUDGET, MERGE_OUTCOMES, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, PRIORITY_SCORES, PULL_REQUEST_STATUSES, RANKING_WEIGHTS, REASONING_METHODS, RECENCY_HALF_LIFE_DAYS, RESOLVED_QUESTION_STATUSES, ROOT_TOPIC_ID, SECTION_BUDGET_RATIOS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SEVERITY_SCORES, TOKENS_PER_WORD, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, bigramTokenize, buildDomainEvent, collectTopicNeighborhood, compareEventCursor, dsl_exports as contractDsl, createEventId, decodeEventCursor, decodePrefixedId, emitDomainEvent, encodeEventCursor, encodePrefixedId, hasPrefixedIdPrefix, inferActorType, inferSessionPrincipalType, isAfterCursor, isLucernPrompt, jaccardSimilarity, lastDelegator, tool_contracts_exports as mcpToolsContract, normalizeDelegationChain, normalizeRetentionDays, prepareLexicalQuery, rankEntityConnections, rankEntityTypeMatches, rankWindowScore, requireActorPrincipalId, rerankLexicalWindow, schemas_exports as schemaContracts, scoreEntityConnection, scoreEntityTypeMatch, scoreLexicalSignal, scoreLexicalSignals, sdk_tools_contract_exports as sdkToolsContract, sortEventsByCursor, stemToken, tokenOverlapScore, tokenizeSearchText, wordOverlapScore, wordTokenize };
14746
+ export { BELIEF_STATUSES, BELIEF_TYPE_BONUS, BRANCH_STATUSES, CANONICAL_WORKFLOW_DEFINITIONS, COMPONENT_BOUNDARY_COMPONENT_LAYERS, COMPONENT_BOUNDARY_CONTRACT_VERSION, COMPONENT_BOUNDARY_DIRECT_DB_METHODS, COMPONENT_BOUNDARY_HIGH_RISK_TABLES, COMPONENT_BOUNDARY_HOST_SOURCE_ROOTS, COMPONENT_HOST_BOUNDARY_CONTRACT_VERSION, COMPONENT_HOST_DB_READ_OPERATIONS, COMPONENT_HOST_DB_WRITE_OPERATIONS, COMPONENT_HOST_PROTECTED_TABLES, COMPONENT_HOST_PROTECTED_TABLE_OWNERS, COMPONENT_HOST_WRITE_ALLOWED_EXCEPTIONS, COMPONENT_HOST_WRITE_AUDIT_ROOTS, CONFIDENCE_TRIGGERS, CONTEXT_PACK_SCHEMA_VERSION, CONTEXT_PACK_SECTION_KEYS, CONTEXT_RANKING_PROFILES, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, ComponentTableManifestSchema, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_RANKING_PROFILE, DEFAULT_SECTION_LIMIT, DEFAULT_SEVERITY_SCORE, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_TOKEN_BUDGET, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, ENTITY_RANKING_WEIGHTS, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, EdgePolicyEntrySchema, EdgePolicyManifestSchema, EpistemicNodeTypeSchema, FORK_REASONS, GRAPH_INTELLIGENCE_MODE_TOOL_NAMES, GRAPH_INTELLIGENCE_PUBLIC_TOOL_NAMES, GRAPH_INTELLIGENCE_QUERIES, GRAPH_INTELLIGENCE_QUERIES_WITH_TOOLS, GRAPH_INTELLIGENCE_QUERY_CATALOG_VERSION, GRAPH_INTELLIGENCE_QUERY_CATEGORIES, GRAPH_INTELLIGENCE_QUERY_MODES, GRAPH_INTELLIGENCE_QUICK_QUERIES, GRAPH_REF_NODE_TYPES, GraphRefSchema, INFISICAL_RUNTIME_BOOTSTRAP_ENV, INFISICAL_RUNTIME_CONTRACT_VERSION, INFISICAL_RUNTIME_DEFAULT_API_URL, INFISICAL_RUNTIME_DEFAULT_PROJECT_ID, INFISICAL_RUNTIME_DELIVERY_MODES, INFISICAL_RUNTIME_ENVIRONMENTS, INFISICAL_RUNTIME_MANIFEST, INFISICAL_RUNTIME_PATHS, INFISICAL_RUNTIME_SURFACES, INFISICAL_RUNTIME_SURFACE_IDS, INTEGRATION_EDGE_TYPES, InvariantManifestSchema, JUDGMENT_TYPES, MAX_ENTITY_LIMIT, MAX_SECTION_LIMIT, MAX_TOKEN_BUDGET, MERGE_OUTCOMES, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, PRIORITY_SCORES, PULL_REQUEST_STATUSES, RANKING_WEIGHTS, REASONING_METHODS, RECENCY_HALF_LIFE_DAYS, RESOLVED_QUESTION_STATUSES, ROOT_TOPIC_ID, SECTION_BUDGET_RATIOS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SEVERITY_SCORES, SLOpinionInputSchema, TENANT_BOOTSTRAP_FORBIDDEN_SEED_TABLES, TENANT_BOOTSTRAP_SEED_AUTH_METADATA_FIELDS, TENANT_BOOTSTRAP_SEED_COMPONENTS, TENANT_BOOTSTRAP_SEED_CONTRACT_VERSION, TENANT_BOOTSTRAP_SEED_MANIFEST, TENANT_BOOTSTRAP_SEED_TABLES, TENANT_BOOTSTRAP_TABLE_REQUIREMENTS, TENANT_BOOTSTRAP_TEMPLATE_ACTOR, TENANT_BOOTSTRAP_TEMPLATE_SEED_VERSION, TENANT_BOOTSTRAP_TEMPLATE_TENANT_ID, TENANT_CLIENT_AUTH_MODES, TENANT_CLIENT_CAPABILITIES, TENANT_CLIENT_COMPONENT_CONFIG_IMPORTS, TENANT_CLIENT_CONTRACT_VERSION, TENANT_CLIENT_FORBIDDEN_IMPORT_PATTERNS, TENANT_CLIENT_FORBIDDEN_INSTALL_TOKEN_INFISICAL_PATHS, TENANT_CLIENT_FORBIDDEN_SECRET_ENV, TENANT_CLIENT_FULL_SUITE_PACKAGE_NAMES, TENANT_CLIENT_INSTALLABLE_PACKAGES, TENANT_CLIENT_INSTALL_PROFILES, TENANT_CLIENT_INSTALL_TOKEN_ENV, TENANT_CLIENT_INSTALL_TOKEN_INFISICAL_PATH, TENANT_CLIENT_ISOLATION_RULES, TENANT_CLIENT_MANIFEST, TENANT_CLIENT_OPTIONAL_CONTEXT_FIELDS, TENANT_CLIENT_PRINCIPAL_TYPES, TENANT_CLIENT_PUBLIC_IMPORTS, TENANT_CLIENT_REQUIRED_CONTEXT_FIELDS, TENANT_CLIENT_REQUIRED_SDK_NAMESPACES, TOKENS_PER_WORD, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, assertEdgePolicyAllowed, assertTenantClientImportAllowed, bigramTokenize, buildDomainEvent, buildTenantBootstrapTemplateSeedRows, classifyTenantClientImport, collectTopicNeighborhood, compareEventCursor, dsl_exports as contractDsl, createEventId, createEvidenceProjection, decodeEventCursor, decodePrefixedId, defineProjection, edgePolicyManifest, emitDomainEvent, encodeEventCursor, encodePrefixedId, fillGraphIntelligencePromptTemplate, findEdgePolicy, findInfisicalRuntimePath, findInfisicalRuntimeSurface, findTenantBootstrapSeedTable, findTenantBootstrapTableRequirement, findTenantClientInstallablePackage, formatTenantClientImportViolation, getComponentBoundaryTableLayer, getGraphIntelligenceQuery, hasPrefixedIdPrefix, inferActorType, inferSessionPrincipalType, isAfterCursor, isComponentBoundaryComponentOwnedTable, isGraphIntelligenceQueryMode, isLucernPrompt, isTenantBootstrapForbiddenSeedTable, isTenantBootstrapSeedTable, isTenantClientAllowedImport, isTenantClientComponentConfigImport, isTenantClientInstallablePackage, isTenantClientPublicImport, jaccardSimilarity, lastDelegator, listBeliefsProjection, listGraphIntelligenceQueries, listTasksProjection, tool_contracts_exports as mcpToolsContract, modulateConfidenceProjection, normalizeDelegationChain, normalizeRetentionDays, prepareLexicalQuery, projections, rankEntityConnections, rankEntityTypeMatches, rankWindowScore, requireActorPrincipalId, rerankLexicalWindow, schemas_exports as schemaContracts, scoreEntityConnection, scoreEntityTypeMatch, scoreLexicalSignal, scoreLexicalSignals, sdk_tools_contract_exports as sdkToolsContract, sortEventsByCursor, stemToken, tokenOverlapScore, tokenizeSearchText, wordOverlapScore, wordTokenize };
10994
14747
  //# sourceMappingURL=index.js.map
10995
14748
  //# sourceMappingURL=index.js.map