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

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 (117) hide show
  1. package/dist/dsl.js +3 -0
  2. package/dist/dsl.js.map +1 -1
  3. package/dist/function-registry/beliefs.d.ts +11 -51
  4. package/dist/function-registry/beliefs.js +445 -94
  5. package/dist/function-registry/beliefs.js.map +1 -1
  6. package/dist/function-registry/coding.d.ts +7 -31
  7. package/dist/function-registry/coding.js +264 -81
  8. package/dist/function-registry/coding.js.map +1 -1
  9. package/dist/function-registry/context.d.ts +4 -16
  10. package/dist/function-registry/context.js +223 -62
  11. package/dist/function-registry/context.js.map +1 -1
  12. package/dist/function-registry/contracts.d.ts +4 -16
  13. package/dist/function-registry/contracts.js +195 -54
  14. package/dist/function-registry/contracts.js.map +1 -1
  15. package/dist/function-registry/coordination.d.ts +10 -46
  16. package/dist/function-registry/coordination.js +208 -57
  17. package/dist/function-registry/coordination.js.map +1 -1
  18. package/dist/function-registry/edges.d.ts +10 -18
  19. package/dist/function-registry/edges.js +343 -68
  20. package/dist/function-registry/edges.js.map +1 -1
  21. package/dist/function-registry/evidence.d.ts +17 -49
  22. package/dist/function-registry/evidence.js +395 -99
  23. package/dist/function-registry/evidence.js.map +1 -1
  24. package/dist/function-registry/graph.d.ts +14 -66
  25. package/dist/function-registry/graph.js +225 -65
  26. package/dist/function-registry/graph.js.map +1 -1
  27. package/dist/function-registry/helpers.d.ts +6 -8
  28. package/dist/function-registry/helpers.js +204 -55
  29. package/dist/function-registry/helpers.js.map +1 -1
  30. package/dist/function-registry/identity.d.ts +4 -16
  31. package/dist/function-registry/identity.js +195 -54
  32. package/dist/function-registry/identity.js.map +1 -1
  33. package/dist/function-registry/index.d.ts +2 -2
  34. package/dist/function-registry/index.js +204 -55
  35. package/dist/function-registry/index.js.map +1 -1
  36. package/dist/function-registry/judgments.d.ts +5 -13
  37. package/dist/function-registry/judgments.js +214 -63
  38. package/dist/function-registry/judgments.js.map +1 -1
  39. package/dist/function-registry/legacy.d.ts +2 -6
  40. package/dist/function-registry/legacy.js +195 -54
  41. package/dist/function-registry/legacy.js.map +1 -1
  42. package/dist/function-registry/lenses.d.ts +5 -21
  43. package/dist/function-registry/lenses.js +241 -58
  44. package/dist/function-registry/lenses.js.map +1 -1
  45. package/dist/function-registry/manifest.d.ts +3 -3
  46. package/dist/function-registry/manifest.js +1 -0
  47. package/dist/function-registry/manifest.js.map +1 -1
  48. package/dist/function-registry/ontologies.d.ts +12 -56
  49. package/dist/function-registry/ontologies.js +227 -77
  50. package/dist/function-registry/ontologies.js.map +1 -1
  51. package/dist/function-registry/pipeline.d.ts +4 -16
  52. package/dist/function-registry/pipeline.js +207 -55
  53. package/dist/function-registry/pipeline.js.map +1 -1
  54. package/dist/function-registry/questions.d.ts +13 -61
  55. package/dist/function-registry/questions.js +281 -82
  56. package/dist/function-registry/questions.js.map +1 -1
  57. package/dist/function-registry/tasks.d.ts +5 -21
  58. package/dist/function-registry/tasks.js +265 -58
  59. package/dist/function-registry/tasks.js.map +1 -1
  60. package/dist/function-registry/topics.d.ts +6 -26
  61. package/dist/function-registry/topics.js +214 -57
  62. package/dist/function-registry/topics.js.map +1 -1
  63. package/dist/function-registry/types.d.ts +2 -2
  64. package/dist/function-registry/worktrees.d.ts +49 -46
  65. package/dist/function-registry/worktrees.js +326 -81
  66. package/dist/function-registry/worktrees.js.map +1 -1
  67. package/dist/generated/convexSchemas.js +4 -3
  68. package/dist/generated/convexSchemas.js.map +1 -1
  69. package/dist/generated/schema-manifest.json +55 -3
  70. package/dist/generated/tableOwnership.d.ts +2 -1
  71. package/dist/generated/tableOwnership.js +2 -0
  72. package/dist/generated/tableOwnership.js.map +1 -1
  73. package/dist/generated/tier-expectations.json +6 -3
  74. package/dist/index-CV-0_VWJ.d.ts +25 -0
  75. package/dist/index.d.ts +414 -4
  76. package/dist/index.js +665 -62
  77. package/dist/index.js.map +1 -1
  78. package/dist/schema-helpers/validators.d.ts +1 -1
  79. package/dist/schema-helpers/validators.js +1 -1
  80. package/dist/schema-helpers/validators.js.map +1 -1
  81. package/dist/schemas/component-table-manifest.d.ts +74 -0
  82. package/dist/schemas/component-table-manifest.js +26 -0
  83. package/dist/schemas/component-table-manifest.js.map +1 -0
  84. package/dist/schemas/index.d.ts +2 -0
  85. package/dist/schemas/index.js +68 -10
  86. package/dist/schemas/index.js.map +1 -1
  87. package/dist/schemas/manifest.d.ts +110 -45
  88. package/dist/schemas/manifest.js +36 -9
  89. package/dist/schemas/manifest.js.map +1 -1
  90. package/dist/schemas/sl-opinion.d.ts +31 -0
  91. package/dist/schemas/sl-opinion.js +19 -0
  92. package/dist/schemas/sl-opinion.js.map +1 -0
  93. package/dist/schemas/tables/kernel/epistemic.d.ts +6 -4
  94. package/dist/schemas/tables/kernel/epistemic.js +6 -4
  95. package/dist/schemas/tables/kernel/epistemic.js.map +1 -1
  96. package/dist/schemas/tables/kernel/infra.d.ts +13 -1
  97. package/dist/schemas/tables/kernel/infra.js +23 -1
  98. package/dist/schemas/tables/kernel/infra.js.map +1 -1
  99. package/dist/schemas/tables/kernel/worktree.d.ts +4 -4
  100. package/dist/schemas/tables/kernel/worktree.js +6 -4
  101. package/dist/schemas/tables/kernel/worktree.js.map +1 -1
  102. package/dist/schemas/tables/mc/runtime.d.ts +1 -1
  103. package/dist/schemas/tables/mc/runtime.js +1 -1
  104. package/dist/schemas/tables/mc/runtime.js.map +1 -1
  105. package/dist/sdk-methods.contract.d.ts +5 -2
  106. package/dist/{sdk-tools.contract-C2kQN_Xk.d.ts → sdk-tools.contract-S4ia0TTo.d.ts} +1 -1
  107. package/dist/sdk-tools.contract.d.ts +2 -2
  108. package/dist/sdk-tools.contract.js +154 -51
  109. package/dist/sdk-tools.contract.js.map +1 -1
  110. package/dist/{tool-contracts-WCnuE9DW.d.ts → tool-contracts-C92-9ueT.d.ts} +5 -3
  111. package/dist/tool-contracts.d.ts +1 -1
  112. package/dist/tool-contracts.js +155 -52
  113. package/dist/tool-contracts.js.map +1 -1
  114. package/dist/workflow-runtime.contract.js +1 -1
  115. package/dist/workflow-runtime.contract.js.map +1 -1
  116. package/package.json +19 -1
  117. package/dist/index-DoDXl8KS.d.ts +0 -19
@@ -1,6 +1,6 @@
1
1
  import { FunctionContract } from './types.js';
2
2
  export { ContractInputProjection, ContractOutputProjection, ContractProjectionContext, FunctionConvexTarget, FunctionIdempotency, FunctionKind, FunctionMcpContract, FunctionPrincipalType, FunctionSurfaceIntent, FunctionSurfaceMap, SurfaceClass, SurfaceExposure } from './types.js';
3
- export { argsSchemaFromMcpContract, assertSurfaceCoverage, authUserId, classifyContract, defineFunctionContract, inputSchemaFromMcpContract, jsonObjectSchema, surfaceContract, surfaceMcpContract, withCreatedBy, withUserId } from './helpers.js';
3
+ export { argsSchemaFromMcpContract, assertSurfaceCoverage, authUserId, classifyContract, compactRecord, defineFunctionContract, inputSchemaFromMcpContract, jsonObjectSchema, recordValue, surfaceContract, surfaceMcpContract, withCreatedBy, withUserId } from './helpers.js';
4
4
  export { DUPLICATE_OPERATION_NAMES, FORBIDDEN_APPLICATION_OPERATION_NAMES, LEGACY_COMPAT_OPERATION_NAMES, LUCERN_OPERATION_MANIFEST, LucernOperationManifestEntry, LucernOperationName, MCP_ANALYSIS_PLATFORM_OPERATION_NAMES, MCP_ANALYSIS_TENANT_OPERATION_NAMES, MCP_AUTOMATION_OPERATION_NAMES, MCP_CORE_OPERATION_NAMES, MCP_GOVERNANCE_PLATFORM_OPERATION_NAMES, MCP_GOVERNANCE_TENANT_OPERATION_NAMES, MCP_ONLY_INTERNAL_OPERATION_NAMES, MCP_WORKFLOW_PLATFORM_OPERATION_NAMES, MCP_WORKFLOW_TENANT_OPERATION_NAMES, PLATFORM_INTERNAL_OPERATION_NAMES, PLATFORM_PUBLIC_OPERATION_NAMES, SDK_ONLY_OPERATION_NAMES, TENANT_PUBLIC_OPERATION_NAMES, surfaceEnabled, surfaceIntentGateViolations } from './manifest.js';
5
5
  export { contextContracts } from './context.js';
6
6
  export { identityContracts } from './identity.js';
@@ -22,7 +22,7 @@ export { codingContracts } from './coding.js';
22
22
  export { legacyContracts } from './legacy.js';
23
23
  import 'zod';
24
24
  import '../defineFunction-DO97DKs4.js';
25
- import '../tool-contracts-WCnuE9DW.js';
25
+ import '../tool-contracts-C92-9ueT.js';
26
26
 
27
27
  declare const ALL_FUNCTION_CONTRACTS: readonly FunctionContract[];
28
28
  declare const FUNCTION_SURFACE_CONTRACTS: readonly FunctionContract[];
@@ -50,7 +50,7 @@ var LENS_PERSPECTIVE_TYPES = [
50
50
  // src/tool-contracts.ts
51
51
  var CREATE_BELIEF = {
52
52
  name: "create_belief",
53
- 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.",
53
+ 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.",
54
54
  parameters: {
55
55
  canonicalText: {
56
56
  type: "string",
@@ -62,7 +62,7 @@ var CREATE_BELIEF = {
62
62
  },
63
63
  baseRate: {
64
64
  type: "number",
65
- description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
65
+ description: "Prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time. Defaults to 0.5 when omitted."
66
66
  },
67
67
  beliefType: {
68
68
  type: "string",
@@ -73,7 +73,7 @@ var CREATE_BELIEF = {
73
73
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
74
74
  }
75
75
  },
76
- required: ["canonicalText", "baseRate"],
76
+ required: ["canonicalText"],
77
77
  response: {
78
78
  description: "The created canonical belief record",
79
79
  fields: {
@@ -136,7 +136,7 @@ var REFINE_BELIEF = {
136
136
  };
137
137
  var MODULATE_CONFIDENCE = {
138
138
  name: "modulate_confidence",
139
- 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.",
139
+ 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.",
140
140
  parameters: {
141
141
  nodeId: { type: "string", description: "The belief to score" },
142
142
  belief: {
@@ -155,9 +155,9 @@ var MODULATE_CONFIDENCE = {
155
155
  type: "number",
156
156
  description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
157
157
  },
158
- confidence: {
159
- type: "number",
160
- description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
158
+ worktreeId: {
159
+ type: "string",
160
+ description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
161
161
  },
162
162
  trigger: {
163
163
  type: "string",
@@ -172,17 +172,43 @@ var MODULATE_CONFIDENCE = {
172
172
  "worktree_completed",
173
173
  "fusion",
174
174
  "discount",
175
- "deduction",
176
- "manual",
177
- "decay"
175
+ "deduction"
178
176
  ]
179
177
  },
178
+ triggeringEvidenceId: {
179
+ type: "string",
180
+ description: "Evidence node that caused an evidence-triggered modulation"
181
+ },
182
+ triggeringQuestionId: {
183
+ type: "string",
184
+ description: "Answered question whose resolution supports this modulation"
185
+ },
186
+ triggeringAnswerId: {
187
+ type: "string",
188
+ description: "Answer node whose content supports this modulation"
189
+ },
190
+ triggeringContradictionId: {
191
+ type: "string",
192
+ description: "Contradiction record that caused a contradiction-triggered modulation"
193
+ },
194
+ triggeringWorktreeId: {
195
+ type: "string",
196
+ description: "Completed worktree whose outcome caused a worktree-triggered modulation"
197
+ },
180
198
  rationale: {
181
199
  type: "string",
182
200
  description: "Human-readable explanation of why confidence changed"
183
201
  }
184
202
  },
185
- required: ["nodeId", "trigger", "rationale"],
203
+ required: [
204
+ "nodeId",
205
+ "belief",
206
+ "disbelief",
207
+ "uncertainty",
208
+ "baseRate",
209
+ "trigger",
210
+ "rationale"
211
+ ],
186
212
  response: {
187
213
  description: "Confidence modulation result",
188
214
  fields: {
@@ -376,7 +402,7 @@ var ADD_EVIDENCE = {
376
402
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'], failedApproach: true } for coding intelligence)"
377
403
  }
378
404
  },
379
- required: ["canonicalText", "targetNodeId"],
405
+ required: ["canonicalText", "targetNodeId", "reasoning"],
380
406
  response: {
381
407
  description: "The created evidence node and its edge",
382
408
  fields: {
@@ -457,9 +483,21 @@ var ADD_WORKTREE = {
457
483
  type: "string",
458
484
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
459
485
  },
460
- executionOrder: {
486
+ campaign: {
461
487
  type: "number",
462
- description: "Global execution order for this worktree"
488
+ description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
489
+ },
490
+ lane: {
491
+ type: "string",
492
+ description: "GitButler-aligned workstream lane name inside the campaign."
493
+ },
494
+ laneOrderInCampaign: {
495
+ type: "number",
496
+ description: "Ordering for this lane within its campaign."
497
+ },
498
+ orderInLane: {
499
+ type: "number",
500
+ description: "Position of this worktree inside its lane."
463
501
  },
464
502
  dependsOn: {
465
503
  type: "array",
@@ -1117,6 +1155,10 @@ var CREATE_EVIDENCE = {
1117
1155
  type: "object",
1118
1156
  description: "Optional metadata merged into the canonical evidence node"
1119
1157
  },
1158
+ rationale: {
1159
+ type: "string",
1160
+ description: "Why this evidence should enter the reasoning graph"
1161
+ },
1120
1162
  title: { type: "string", description: "Optional short title" },
1121
1163
  content: { type: "string", description: "Optional long-form content" },
1122
1164
  contentType: {
@@ -1125,7 +1167,7 @@ var CREATE_EVIDENCE = {
1125
1167
  },
1126
1168
  kind: { type: "string", description: "Optional evidence kind" }
1127
1169
  },
1128
- required: ["text"],
1170
+ required: ["text", "rationale"],
1129
1171
  response: {
1130
1172
  description: "The created canonical evidence record",
1131
1173
  fields: {
@@ -1173,7 +1215,7 @@ var LIST_EVIDENCE = {
1173
1215
  limit: { type: "number", description: "Max results" },
1174
1216
  cursor: { type: "string", description: "Pagination cursor" }
1175
1217
  },
1176
- required: [],
1218
+ required: ["topicId"],
1177
1219
  response: {
1178
1220
  description: "Canonical evidence page",
1179
1221
  fields: {
@@ -1358,6 +1400,7 @@ var ANSWER_QUESTION = {
1358
1400
  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.",
1359
1401
  parameters: {
1360
1402
  id: { type: "string", description: "Canonical question ID" },
1403
+ topicId: { type: "string", description: "Topic scope for the answer" },
1361
1404
  text: { type: "string", description: "Answer text" },
1362
1405
  confidence: {
1363
1406
  type: "string",
@@ -1370,7 +1413,7 @@ var ANSWER_QUESTION = {
1370
1413
  },
1371
1414
  rationale: { type: "string", description: "Why this answer is credible" }
1372
1415
  },
1373
- required: ["id", "text"],
1416
+ required: ["id", "topicId", "text"],
1374
1417
  response: {
1375
1418
  description: "Answer result",
1376
1419
  fields: {
@@ -1589,6 +1632,10 @@ var LIST_BELIEFS = {
1589
1632
  minConfidence: {
1590
1633
  type: "number",
1591
1634
  description: "Minimum confidence threshold"
1635
+ },
1636
+ limit: {
1637
+ type: "number",
1638
+ description: "Maximum results"
1592
1639
  }
1593
1640
  },
1594
1641
  required: ["topicId"],
@@ -1605,20 +1652,37 @@ var LIST_BELIEFS = {
1605
1652
  };
1606
1653
  var LIST_WORKTREES = {
1607
1654
  name: "list_worktrees",
1608
- 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.",
1655
+ 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.",
1609
1656
  parameters: {
1610
1657
  topicId: { type: "string", description: "Topic scope" },
1611
1658
  status: {
1612
1659
  type: "string",
1613
1660
  description: "Filter: active, merged, abandoned",
1614
1661
  enum: ["active", "merged", "abandoned"]
1662
+ },
1663
+ groupBy: {
1664
+ type: "string",
1665
+ description: "Optional grouping mode for the response.",
1666
+ enum: ["campaign", "lane", "flat"]
1667
+ },
1668
+ lane: {
1669
+ type: "string",
1670
+ description: "Filter by GitButler-aligned lane name."
1671
+ },
1672
+ campaign: {
1673
+ type: "number",
1674
+ description: "Filter by top-level pipeline campaign number."
1675
+ },
1676
+ limit: {
1677
+ type: "number",
1678
+ description: "Maximum results to return."
1615
1679
  }
1616
1680
  },
1617
1681
  required: ["topicId"],
1618
1682
  response: {
1619
- description: "Worktrees with phase, status, belief count, and creation time",
1683
+ description: "Worktrees with lifecycle phase, campaign, lane, status, belief count, and creation time",
1620
1684
  fields: {
1621
- worktrees: "array \u2014 { worktreeId, title, phase, status, beliefCount, createdAt }"
1685
+ worktrees: "array \u2014 { worktreeId, title, phase, campaign, lane, laneOrderInCampaign, orderInLane, status, beliefCount, createdAt }"
1622
1686
  }
1623
1687
  },
1624
1688
  ownerModule: "workflow-engine",
@@ -1627,7 +1691,7 @@ var LIST_WORKTREES = {
1627
1691
  };
1628
1692
  var LIST_ALL_WORKTREES = {
1629
1693
  name: "list_all_worktrees",
1630
- 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.",
1694
+ 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.",
1631
1695
  parameters: {
1632
1696
  status: {
1633
1697
  type: "string",
@@ -1645,13 +1709,18 @@ var LIST_ALL_WORKTREES = {
1645
1709
  "dismissed"
1646
1710
  ]
1647
1711
  },
1648
- track: {
1712
+ lane: {
1649
1713
  type: "string",
1650
- description: "Filter by track name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1714
+ description: "Filter by lane name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1651
1715
  },
1652
- executionBand: {
1716
+ campaign: {
1653
1717
  type: "number",
1654
- description: "Filter by execution band number (e.g., 1, 2, 3). Returns only worktrees in that parallel execution group."
1718
+ description: "Filter by campaign number (e.g., 1, 2, 3). Returns only worktrees in that campaign."
1719
+ },
1720
+ groupBy: {
1721
+ type: "string",
1722
+ description: "Optional grouping mode for the response.",
1723
+ enum: ["campaign", "lane", "flat"]
1655
1724
  },
1656
1725
  limit: {
1657
1726
  type: "number",
@@ -1662,10 +1731,39 @@ var LIST_ALL_WORKTREES = {
1662
1731
  response: {
1663
1732
  description: "All worktrees across all topics with full pipeline metadata",
1664
1733
  fields: {
1665
- worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, track, trackPosition, executionBand, executionOrder, dependsOn, blocks, gate, createdAt }",
1734
+ worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, campaign, lane, laneOrderInCampaign, orderInLane, dependsOn, blocks, gate, createdAt }",
1666
1735
  total: "number \u2014 total count after filtering",
1667
- tracks: "object \u2014 { trackName: count } summary of worktrees per track",
1668
- bands: "object \u2014 { bandNumber: count } summary of worktrees per execution band"
1736
+ lanes: "object \u2014 { laneName: count } summary of worktrees per lane",
1737
+ campaigns: "object \u2014 { campaignNumber: count } summary of worktrees per campaign"
1738
+ }
1739
+ },
1740
+ ownerModule: "workflow-engine",
1741
+ ontologyPrimitive: "worktree",
1742
+ tier: "showcase"
1743
+ };
1744
+ var LIST_CAMPAIGNS = {
1745
+ name: "list_campaigns",
1746
+ 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.",
1747
+ parameters: {
1748
+ topicId: {
1749
+ type: "string",
1750
+ description: "Optional topic scope."
1751
+ },
1752
+ status: {
1753
+ type: "string",
1754
+ description: "Optional worktree status filter before grouping campaigns and lanes."
1755
+ },
1756
+ limit: {
1757
+ type: "number",
1758
+ description: "Maximum worktrees to scan before grouping."
1759
+ }
1760
+ },
1761
+ required: [],
1762
+ response: {
1763
+ description: "Pipeline campaigns with nested lane summaries.",
1764
+ fields: {
1765
+ campaigns: "array \u2014 { campaign, lanes: [{ lane, laneOrderInCampaign, worktreeCount, activeCount, readyCount, blockedCount, completedCount, nextWorktree }] }",
1766
+ totalWorktrees: "number \u2014 total worktrees scanned after filtering"
1669
1767
  }
1670
1768
  },
1671
1769
  ownerModule: "workflow-engine",
@@ -1728,16 +1826,28 @@ var UPDATE_WORKTREE_TARGETS = {
1728
1826
  };
1729
1827
  var UPDATE_WORKTREE_METADATA = {
1730
1828
  name: "update_worktree_metadata",
1731
- 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.",
1829
+ 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.",
1732
1830
  parameters: {
1733
1831
  worktreeId: { type: "string", description: "The worktree to update" },
1734
1832
  hypothesis: {
1735
1833
  type: "string",
1736
1834
  description: "Testable claim this worktree investigates"
1737
1835
  },
1738
- executionOrder: {
1836
+ campaign: {
1837
+ type: "number",
1838
+ description: "Top-level pipeline campaign number."
1839
+ },
1840
+ lane: {
1841
+ type: "string",
1842
+ description: "GitButler-aligned workstream lane name inside the campaign."
1843
+ },
1844
+ laneOrderInCampaign: {
1739
1845
  type: "number",
1740
- description: "Global execution order (1 = first, higher = later)"
1846
+ description: "Ordering for this lane within the campaign."
1847
+ },
1848
+ orderInLane: {
1849
+ type: "number",
1850
+ description: "Position of this worktree inside its lane."
1741
1851
  },
1742
1852
  dependsOn: {
1743
1853
  type: "array",
@@ -1775,18 +1885,6 @@ var UPDATE_WORKTREE_METADATA = {
1775
1885
  type: "object",
1776
1886
  description: "Calibrated auto-fix policy controlling dry-run vs safe execution, per-run action caps, and permitted mutation tiers."
1777
1887
  },
1778
- track: {
1779
- type: "string",
1780
- 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."
1781
- },
1782
- trackPosition: {
1783
- type: "number",
1784
- description: "Position within the track (1-indexed). E.g., TC-A=1, TC-B=2, TC-C=3 within the 'tc-scope' track."
1785
- },
1786
- executionBand: {
1787
- type: "number",
1788
- 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."
1789
- },
1790
1888
  status: {
1791
1889
  type: "string",
1792
1890
  description: "Override the worktree status. Use for lifecycle transitions like marking a worktree superseded, long-term, or as a raw idea.",
@@ -2156,6 +2254,10 @@ var LIST_TASKS = {
2156
2254
  type: "string",
2157
2255
  description: "Filter to tasks linked to this worktree"
2158
2256
  },
2257
+ worktreeId: {
2258
+ type: "string",
2259
+ description: "Alias for linkedWorktreeId"
2260
+ },
2159
2261
  status: {
2160
2262
  type: "string",
2161
2263
  description: "Filter by status: todo, in_progress, blocked, done",
@@ -2243,7 +2345,7 @@ var GET_TOPIC = {
2243
2345
  description: "Legacy alias for topicId"
2244
2346
  }
2245
2347
  },
2246
- required: [],
2348
+ required: ["topicId"],
2247
2349
  response: {
2248
2350
  description: "Single topic record",
2249
2351
  fields: {
@@ -2598,7 +2700,7 @@ var GET_ONTOLOGY = {
2598
2700
  description: "Tenant scope for key lookup. Omit for platform-level."
2599
2701
  }
2600
2702
  },
2601
- required: [],
2703
+ required: ["id"],
2602
2704
  response: {
2603
2705
  description: "Ontology definition with latest published version",
2604
2706
  fields: {
@@ -2665,7 +2767,7 @@ var MATCH_ENTITY_TYPE = {
2665
2767
  description: "Optional maximum number of ranked matches to return"
2666
2768
  }
2667
2769
  },
2668
- required: ["text"],
2770
+ required: ["text", "ontologyId"],
2669
2771
  response: {
2670
2772
  description: "Ranked ontology entity type matches",
2671
2773
  fields: {
@@ -2919,7 +3021,7 @@ var RECORD_SCOPE_LEARNING = {
2919
3021
  };
2920
3022
  var PIPELINE_SNAPSHOT = {
2921
3023
  name: "pipeline_snapshot",
2922
- 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.",
3024
+ 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.",
2923
3025
  parameters: {
2924
3026
  topicId: { type: "string", description: "Topic scope ID" }
2925
3027
  },
@@ -2929,14 +3031,14 @@ var PIPELINE_SNAPSHOT = {
2929
3031
  fields: {
2930
3032
  topicId: "string",
2931
3033
  topicName: "string",
2932
- currentBand: "number | null",
2933
- nextBand: "number | null",
3034
+ currentCampaign: "number | null",
3035
+ nextCampaign: "number | null",
2934
3036
  activeWorktrees: "array \u2014 current hinge worktree(s)",
2935
- nextWave: "array \u2014 worktrees in the next planned band",
3037
+ nextWave: "array \u2014 worktrees in the next planned campaign",
2936
3038
  readyNow: "array \u2014 planning worktrees with dependencies completed",
2937
3039
  blockedBy: "array \u2014 grouped blockers",
2938
3040
  criticalPath: "array \u2014 ordered incomplete worktree chain",
2939
- bands: "array \u2014 incomplete worktrees grouped by executionBand",
3041
+ campaigns: "array \u2014 incomplete worktrees grouped by campaign",
2940
3042
  superseded: "array \u2014 worktrees marked superseded or not for activation",
2941
3043
  graphHygiene: "object \u2014 untargeted and taskless worktree debt",
2942
3044
  riskQuestions: "array \u2014 critical/high open questions",
@@ -3525,6 +3627,7 @@ var MCP_TOOL_CONTRACTS = {
3525
3627
  list_beliefs: LIST_BELIEFS,
3526
3628
  list_worktrees: LIST_WORKTREES,
3527
3629
  list_all_worktrees: LIST_ALL_WORKTREES,
3630
+ list_campaigns: LIST_CAMPAIGNS,
3528
3631
  activate_worktree: ACTIVATE_WORKTREE,
3529
3632
  update_worktree_targets: UPDATE_WORKTREE_TARGETS,
3530
3633
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
@@ -3707,6 +3810,7 @@ var MCP_WORKFLOW_PLATFORM_OPERATION_NAMES = [
3707
3810
  "activate_worktree",
3708
3811
  "list_worktrees",
3709
3812
  "list_all_worktrees",
3813
+ "list_campaigns",
3710
3814
  "update_worktree_targets",
3711
3815
  "update_worktree_metadata",
3712
3816
  "create_task",
@@ -3954,6 +4058,7 @@ function surfaceIntentGateViolations(entry) {
3954
4058
 
3955
4059
  // src/function-registry/helpers.ts
3956
4060
  var jsonObjectSchema = z.record(z.unknown());
4061
+ var sdkSessionIdSchema = z.string().optional();
3957
4062
  function mcpContractShape(contract) {
3958
4063
  const required = new Set(contract.required);
3959
4064
  return Object.fromEntries(
@@ -3988,10 +4093,40 @@ function argsSchemaFromMcpContract(contract) {
3988
4093
  return z.object(mcpContractShape(contract));
3989
4094
  }
3990
4095
  function inputSchemaFromMcpContract(contract) {
3991
- return argsSchemaFromMcpContract(contract).passthrough();
4096
+ return withInternalSurfaceFields(argsSchemaFromMcpContract(contract));
4097
+ }
4098
+ function withInternalSurfaceFields(schema) {
4099
+ return schema.extend({ __sdkSessionId: sdkSessionIdSchema }).strict();
4100
+ }
4101
+ function normalizeInputSchema(schema) {
4102
+ if (schema instanceof z.ZodObject) {
4103
+ return withInternalSurfaceFields(schema);
4104
+ }
4105
+ return schema;
4106
+ }
4107
+ function unwrapObjectSchema(schema) {
4108
+ let current = schema;
4109
+ while (true) {
4110
+ switch (current._def.typeName) {
4111
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4112
+ current = current._def.schema;
4113
+ continue;
4114
+ case z.ZodFirstPartyTypeKind.ZodBranded:
4115
+ current = current._def.type;
4116
+ continue;
4117
+ default:
4118
+ return current instanceof z.ZodObject ? current : void 0;
4119
+ }
4120
+ }
3992
4121
  }
3993
4122
  function getObjectShape(schema) {
3994
- const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
4123
+ const objectSchema = unwrapObjectSchema(schema);
4124
+ if (!objectSchema) {
4125
+ throw new Error(
4126
+ `Expected a Zod object schema, received ${schema._def.typeName}.`
4127
+ );
4128
+ }
4129
+ const shape = typeof objectSchema._def.shape === "function" ? objectSchema._def.shape() : objectSchema._def.shape;
3995
4130
  return shape;
3996
4131
  }
3997
4132
  function unwrapMcpParameterSchema(schema) {
@@ -4012,6 +4147,9 @@ function unwrapMcpParameterSchema(schema) {
4012
4147
  case z.ZodFirstPartyTypeKind.ZodBranded:
4013
4148
  current = current._def.type;
4014
4149
  continue;
4150
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4151
+ current = current._def.schema;
4152
+ continue;
4015
4153
  default:
4016
4154
  return { schema: current, required, description: description ?? current.description };
4017
4155
  }
@@ -4031,6 +4169,7 @@ function mcpParameterFromZod(fieldName, schema, contractName) {
4031
4169
  return { parameter: { type: "array", description }, required };
4032
4170
  case z.ZodFirstPartyTypeKind.ZodObject:
4033
4171
  case z.ZodFirstPartyTypeKind.ZodRecord:
4172
+ case z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
4034
4173
  return { parameter: { type: "object", description }, required };
4035
4174
  case z.ZodFirstPartyTypeKind.ZodEnum:
4036
4175
  return {
@@ -4098,6 +4237,14 @@ function withCreatedBy(input, context) {
4098
4237
  createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context)
4099
4238
  };
4100
4239
  }
4240
+ function compactRecord(input) {
4241
+ return Object.fromEntries(
4242
+ Object.entries(input).filter(([, value]) => value !== void 0)
4243
+ );
4244
+ }
4245
+ function recordValue(value) {
4246
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
4247
+ }
4101
4248
  function surfaceMcpContract(name) {
4102
4249
  const contract = MCP_TOOL_CONTRACTS[name];
4103
4250
  if (!contract) {
@@ -4142,7 +4289,9 @@ function surfaceContract(args) {
4142
4289
  const canonicalArgs = args.args ?? argsSchemaFromMcpContract(baseMcp);
4143
4290
  const mcp = args.args ? mcpContractFromArgsSchema(baseMcp, canonicalArgs, args.name) : baseMcp;
4144
4291
  const canonicalReturns = args.returns ?? jsonObjectSchema;
4145
- const input = args.input ?? inputSchemaFromMcpContract(mcp);
4292
+ const input = normalizeInputSchema(
4293
+ args.input ?? inputSchemaFromMcpContract(mcp)
4294
+ );
4146
4295
  const output = args.output ?? canonicalReturns;
4147
4296
  return defineFunctionContract({
4148
4297
  name: args.name,
@@ -4230,6 +4379,6 @@ function getFunctionContract(name) {
4230
4379
  return FUNCTION_CONTRACTS_BY_NAME.get(name);
4231
4380
  }
4232
4381
 
4233
- export { ALL_FUNCTION_CONTRACTS, DUPLICATE_OPERATION_NAMES, FORBIDDEN_APPLICATION_OPERATION_NAMES, FUNCTION_CONTRACTS_BY_NAME, FUNCTION_SURFACE_CONTRACTS, LEGACY_COMPAT_OPERATION_NAMES, LUCERN_OPERATION_MANIFEST, MCP_ANALYSIS_PLATFORM_OPERATION_NAMES, MCP_ANALYSIS_TENANT_OPERATION_NAMES, MCP_AUTOMATION_OPERATION_NAMES, MCP_CORE_OPERATION_NAMES, MCP_GOVERNANCE_PLATFORM_OPERATION_NAMES, MCP_GOVERNANCE_TENANT_OPERATION_NAMES, MCP_ONLY_INTERNAL_OPERATION_NAMES, MCP_WORKFLOW_PLATFORM_OPERATION_NAMES, MCP_WORKFLOW_TENANT_OPERATION_NAMES, PLATFORM_INTERNAL_OPERATION_NAMES, PLATFORM_PUBLIC_OPERATION_NAMES, SDK_ONLY_OPERATION_NAMES, TENANT_PUBLIC_OPERATION_NAMES, argsSchemaFromMcpContract, assertSurfaceCoverage, authUserId, classifyContract, defineFunctionContract, getFunctionContract, inputSchemaFromMcpContract, jsonObjectSchema, surfaceContract, surfaceEnabled, surfaceIntentGateViolations, surfaceMcpContract, withCreatedBy, withUserId };
4382
+ export { ALL_FUNCTION_CONTRACTS, DUPLICATE_OPERATION_NAMES, FORBIDDEN_APPLICATION_OPERATION_NAMES, FUNCTION_CONTRACTS_BY_NAME, FUNCTION_SURFACE_CONTRACTS, LEGACY_COMPAT_OPERATION_NAMES, LUCERN_OPERATION_MANIFEST, MCP_ANALYSIS_PLATFORM_OPERATION_NAMES, MCP_ANALYSIS_TENANT_OPERATION_NAMES, MCP_AUTOMATION_OPERATION_NAMES, MCP_CORE_OPERATION_NAMES, MCP_GOVERNANCE_PLATFORM_OPERATION_NAMES, MCP_GOVERNANCE_TENANT_OPERATION_NAMES, MCP_ONLY_INTERNAL_OPERATION_NAMES, MCP_WORKFLOW_PLATFORM_OPERATION_NAMES, MCP_WORKFLOW_TENANT_OPERATION_NAMES, PLATFORM_INTERNAL_OPERATION_NAMES, PLATFORM_PUBLIC_OPERATION_NAMES, SDK_ONLY_OPERATION_NAMES, TENANT_PUBLIC_OPERATION_NAMES, argsSchemaFromMcpContract, assertSurfaceCoverage, authUserId, classifyContract, compactRecord, defineFunctionContract, getFunctionContract, inputSchemaFromMcpContract, jsonObjectSchema, recordValue, surfaceContract, surfaceEnabled, surfaceIntentGateViolations, surfaceMcpContract, withCreatedBy, withUserId };
4234
4383
  //# sourceMappingURL=index.js.map
4235
4384
  //# sourceMappingURL=index.js.map