@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
@@ -14,7 +14,7 @@ import * as zod from 'zod';
14
14
  * 2. Knowledge tools use epistemic verbs (create_belief, fork_belief, modulate_confidence)
15
15
  * 3. First sentence of description includes the git analog verb
16
16
  * 4. Description includes "Like `git X`" parenthetical
17
- * 5. Parameter names use domain terms (canonicalText, nodeId, confidence)
17
+ * 5. Parameter names use domain terms (canonicalText, nodeId, baseRate)
18
18
  */
19
19
  type McpToolContract = {
20
20
  /** Stable tool name — breaking change to rename */
@@ -115,11 +115,7 @@ declare const tasksContracts: readonly [{
115
115
  allowedPrincipalTypes: ("user" | "service" | "agent")[];
116
116
  };
117
117
  convex: FunctionConvexTarget | undefined;
118
- args: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, {
119
- [x: string]: any;
120
- }, {
121
- [x: string]: any;
122
- }>;
118
+ args: zod.ZodTypeAny;
123
119
  returns: zod.ZodTypeAny;
124
120
  input: zod.ZodTypeAny;
125
121
  output: zod.ZodTypeAny;
@@ -158,11 +154,7 @@ declare const tasksContracts: readonly [{
158
154
  allowedPrincipalTypes: ("user" | "service" | "agent")[];
159
155
  };
160
156
  convex: FunctionConvexTarget | undefined;
161
- args: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, {
162
- [x: string]: any;
163
- }, {
164
- [x: string]: any;
165
- }>;
157
+ args: zod.ZodTypeAny;
166
158
  returns: zod.ZodTypeAny;
167
159
  input: zod.ZodTypeAny;
168
160
  output: zod.ZodTypeAny;
@@ -201,11 +193,7 @@ declare const tasksContracts: readonly [{
201
193
  allowedPrincipalTypes: ("user" | "service" | "agent")[];
202
194
  };
203
195
  convex: FunctionConvexTarget | undefined;
204
- args: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, {
205
- [x: string]: any;
206
- }, {
207
- [x: string]: any;
208
- }>;
196
+ args: zod.ZodTypeAny;
209
197
  returns: zod.ZodTypeAny;
210
198
  input: zod.ZodTypeAny;
211
199
  output: zod.ZodTypeAny;
@@ -244,11 +232,7 @@ declare const tasksContracts: readonly [{
244
232
  allowedPrincipalTypes: ("user" | "service" | "agent")[];
245
233
  };
246
234
  convex: FunctionConvexTarget | undefined;
247
- args: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, {
248
- [x: string]: any;
249
- }, {
250
- [x: string]: any;
251
- }>;
235
+ args: zod.ZodTypeAny;
252
236
  returns: zod.ZodTypeAny;
253
237
  input: zod.ZodTypeAny;
254
238
  output: zod.ZodTypeAny;
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { v } from 'convex/values';
2
3
 
3
4
  // src/function-registry/helpers.ts
4
5
 
@@ -14,7 +15,7 @@ var LENS_PERSPECTIVE_TYPES = [
14
15
  // src/tool-contracts.ts
15
16
  var CREATE_BELIEF = {
16
17
  name: "create_belief",
17
- 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.",
18
+ 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.",
18
19
  parameters: {
19
20
  canonicalText: {
20
21
  type: "string",
@@ -26,7 +27,7 @@ var CREATE_BELIEF = {
26
27
  },
27
28
  baseRate: {
28
29
  type: "number",
29
- description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
30
+ description: "Prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time. Defaults to 0.5 when omitted."
30
31
  },
31
32
  beliefType: {
32
33
  type: "string",
@@ -37,7 +38,7 @@ var CREATE_BELIEF = {
37
38
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
38
39
  }
39
40
  },
40
- required: ["canonicalText", "baseRate"],
41
+ required: ["canonicalText"],
41
42
  response: {
42
43
  description: "The created canonical belief record",
43
44
  fields: {
@@ -100,7 +101,7 @@ var REFINE_BELIEF = {
100
101
  };
101
102
  var MODULATE_CONFIDENCE = {
102
103
  name: "modulate_confidence",
103
- 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.",
104
+ 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.",
104
105
  parameters: {
105
106
  nodeId: { type: "string", description: "The belief to score" },
106
107
  belief: {
@@ -119,9 +120,9 @@ var MODULATE_CONFIDENCE = {
119
120
  type: "number",
120
121
  description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
121
122
  },
122
- confidence: {
123
- type: "number",
124
- description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
123
+ worktreeId: {
124
+ type: "string",
125
+ description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
125
126
  },
126
127
  trigger: {
127
128
  type: "string",
@@ -136,17 +137,43 @@ var MODULATE_CONFIDENCE = {
136
137
  "worktree_completed",
137
138
  "fusion",
138
139
  "discount",
139
- "deduction",
140
- "manual",
141
- "decay"
140
+ "deduction"
142
141
  ]
143
142
  },
143
+ triggeringEvidenceId: {
144
+ type: "string",
145
+ description: "Evidence node that caused an evidence-triggered modulation"
146
+ },
147
+ triggeringQuestionId: {
148
+ type: "string",
149
+ description: "Answered question whose resolution supports this modulation"
150
+ },
151
+ triggeringAnswerId: {
152
+ type: "string",
153
+ description: "Answer node whose content supports this modulation"
154
+ },
155
+ triggeringContradictionId: {
156
+ type: "string",
157
+ description: "Contradiction record that caused a contradiction-triggered modulation"
158
+ },
159
+ triggeringWorktreeId: {
160
+ type: "string",
161
+ description: "Completed worktree whose outcome caused a worktree-triggered modulation"
162
+ },
144
163
  rationale: {
145
164
  type: "string",
146
165
  description: "Human-readable explanation of why confidence changed"
147
166
  }
148
167
  },
149
- required: ["nodeId", "trigger", "rationale"],
168
+ required: [
169
+ "nodeId",
170
+ "belief",
171
+ "disbelief",
172
+ "uncertainty",
173
+ "baseRate",
174
+ "trigger",
175
+ "rationale"
176
+ ],
150
177
  response: {
151
178
  description: "Confidence modulation result",
152
179
  fields: {
@@ -340,7 +367,7 @@ var ADD_EVIDENCE = {
340
367
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'], failedApproach: true } for coding intelligence)"
341
368
  }
342
369
  },
343
- required: ["canonicalText", "targetNodeId"],
370
+ required: ["canonicalText", "targetNodeId", "reasoning"],
344
371
  response: {
345
372
  description: "The created evidence node and its edge",
346
373
  fields: {
@@ -421,9 +448,21 @@ var ADD_WORKTREE = {
421
448
  type: "string",
422
449
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
423
450
  },
424
- executionOrder: {
451
+ campaign: {
425
452
  type: "number",
426
- description: "Global execution order for this worktree"
453
+ description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
454
+ },
455
+ lane: {
456
+ type: "string",
457
+ description: "GitButler-aligned workstream lane name inside the campaign."
458
+ },
459
+ laneOrderInCampaign: {
460
+ type: "number",
461
+ description: "Ordering for this lane within its campaign."
462
+ },
463
+ orderInLane: {
464
+ type: "number",
465
+ description: "Position of this worktree inside its lane."
427
466
  },
428
467
  dependsOn: {
429
468
  type: "array",
@@ -1081,6 +1120,10 @@ var CREATE_EVIDENCE = {
1081
1120
  type: "object",
1082
1121
  description: "Optional metadata merged into the canonical evidence node"
1083
1122
  },
1123
+ rationale: {
1124
+ type: "string",
1125
+ description: "Why this evidence should enter the reasoning graph"
1126
+ },
1084
1127
  title: { type: "string", description: "Optional short title" },
1085
1128
  content: { type: "string", description: "Optional long-form content" },
1086
1129
  contentType: {
@@ -1089,7 +1132,7 @@ var CREATE_EVIDENCE = {
1089
1132
  },
1090
1133
  kind: { type: "string", description: "Optional evidence kind" }
1091
1134
  },
1092
- required: ["text"],
1135
+ required: ["text", "rationale"],
1093
1136
  response: {
1094
1137
  description: "The created canonical evidence record",
1095
1138
  fields: {
@@ -1137,7 +1180,7 @@ var LIST_EVIDENCE = {
1137
1180
  limit: { type: "number", description: "Max results" },
1138
1181
  cursor: { type: "string", description: "Pagination cursor" }
1139
1182
  },
1140
- required: [],
1183
+ required: ["topicId"],
1141
1184
  response: {
1142
1185
  description: "Canonical evidence page",
1143
1186
  fields: {
@@ -1322,6 +1365,7 @@ var ANSWER_QUESTION = {
1322
1365
  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.",
1323
1366
  parameters: {
1324
1367
  id: { type: "string", description: "Canonical question ID" },
1368
+ topicId: { type: "string", description: "Topic scope for the answer" },
1325
1369
  text: { type: "string", description: "Answer text" },
1326
1370
  confidence: {
1327
1371
  type: "string",
@@ -1334,7 +1378,7 @@ var ANSWER_QUESTION = {
1334
1378
  },
1335
1379
  rationale: { type: "string", description: "Why this answer is credible" }
1336
1380
  },
1337
- required: ["id", "text"],
1381
+ required: ["id", "topicId", "text"],
1338
1382
  response: {
1339
1383
  description: "Answer result",
1340
1384
  fields: {
@@ -1553,6 +1597,10 @@ var LIST_BELIEFS = {
1553
1597
  minConfidence: {
1554
1598
  type: "number",
1555
1599
  description: "Minimum confidence threshold"
1600
+ },
1601
+ limit: {
1602
+ type: "number",
1603
+ description: "Maximum results"
1556
1604
  }
1557
1605
  },
1558
1606
  required: ["topicId"],
@@ -1569,20 +1617,37 @@ var LIST_BELIEFS = {
1569
1617
  };
1570
1618
  var LIST_WORKTREES = {
1571
1619
  name: "list_worktrees",
1572
- 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.",
1620
+ 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.",
1573
1621
  parameters: {
1574
1622
  topicId: { type: "string", description: "Topic scope" },
1575
1623
  status: {
1576
1624
  type: "string",
1577
1625
  description: "Filter: active, merged, abandoned",
1578
1626
  enum: ["active", "merged", "abandoned"]
1627
+ },
1628
+ groupBy: {
1629
+ type: "string",
1630
+ description: "Optional grouping mode for the response.",
1631
+ enum: ["campaign", "lane", "flat"]
1632
+ },
1633
+ lane: {
1634
+ type: "string",
1635
+ description: "Filter by GitButler-aligned lane name."
1636
+ },
1637
+ campaign: {
1638
+ type: "number",
1639
+ description: "Filter by top-level pipeline campaign number."
1640
+ },
1641
+ limit: {
1642
+ type: "number",
1643
+ description: "Maximum results to return."
1579
1644
  }
1580
1645
  },
1581
1646
  required: ["topicId"],
1582
1647
  response: {
1583
- description: "Worktrees with phase, status, belief count, and creation time",
1648
+ description: "Worktrees with lifecycle phase, campaign, lane, status, belief count, and creation time",
1584
1649
  fields: {
1585
- worktrees: "array \u2014 { worktreeId, title, phase, status, beliefCount, createdAt }"
1650
+ worktrees: "array \u2014 { worktreeId, title, phase, campaign, lane, laneOrderInCampaign, orderInLane, status, beliefCount, createdAt }"
1586
1651
  }
1587
1652
  },
1588
1653
  ownerModule: "workflow-engine",
@@ -1591,7 +1656,7 @@ var LIST_WORKTREES = {
1591
1656
  };
1592
1657
  var LIST_ALL_WORKTREES = {
1593
1658
  name: "list_all_worktrees",
1594
- 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.",
1659
+ 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.",
1595
1660
  parameters: {
1596
1661
  status: {
1597
1662
  type: "string",
@@ -1609,13 +1674,18 @@ var LIST_ALL_WORKTREES = {
1609
1674
  "dismissed"
1610
1675
  ]
1611
1676
  },
1612
- track: {
1677
+ lane: {
1613
1678
  type: "string",
1614
- description: "Filter by track name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1679
+ description: "Filter by lane name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1615
1680
  },
1616
- executionBand: {
1681
+ campaign: {
1617
1682
  type: "number",
1618
- description: "Filter by execution band number (e.g., 1, 2, 3). Returns only worktrees in that parallel execution group."
1683
+ description: "Filter by campaign number (e.g., 1, 2, 3). Returns only worktrees in that campaign."
1684
+ },
1685
+ groupBy: {
1686
+ type: "string",
1687
+ description: "Optional grouping mode for the response.",
1688
+ enum: ["campaign", "lane", "flat"]
1619
1689
  },
1620
1690
  limit: {
1621
1691
  type: "number",
@@ -1626,10 +1696,39 @@ var LIST_ALL_WORKTREES = {
1626
1696
  response: {
1627
1697
  description: "All worktrees across all topics with full pipeline metadata",
1628
1698
  fields: {
1629
- worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, track, trackPosition, executionBand, executionOrder, dependsOn, blocks, gate, createdAt }",
1699
+ worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, campaign, lane, laneOrderInCampaign, orderInLane, dependsOn, blocks, gate, createdAt }",
1630
1700
  total: "number \u2014 total count after filtering",
1631
- tracks: "object \u2014 { trackName: count } summary of worktrees per track",
1632
- bands: "object \u2014 { bandNumber: count } summary of worktrees per execution band"
1701
+ lanes: "object \u2014 { laneName: count } summary of worktrees per lane",
1702
+ campaigns: "object \u2014 { campaignNumber: count } summary of worktrees per campaign"
1703
+ }
1704
+ },
1705
+ ownerModule: "workflow-engine",
1706
+ ontologyPrimitive: "worktree",
1707
+ tier: "showcase"
1708
+ };
1709
+ var LIST_CAMPAIGNS = {
1710
+ name: "list_campaigns",
1711
+ 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.",
1712
+ parameters: {
1713
+ topicId: {
1714
+ type: "string",
1715
+ description: "Optional topic scope."
1716
+ },
1717
+ status: {
1718
+ type: "string",
1719
+ description: "Optional worktree status filter before grouping campaigns and lanes."
1720
+ },
1721
+ limit: {
1722
+ type: "number",
1723
+ description: "Maximum worktrees to scan before grouping."
1724
+ }
1725
+ },
1726
+ required: [],
1727
+ response: {
1728
+ description: "Pipeline campaigns with nested lane summaries.",
1729
+ fields: {
1730
+ campaigns: "array \u2014 { campaign, lanes: [{ lane, laneOrderInCampaign, worktreeCount, activeCount, readyCount, blockedCount, completedCount, nextWorktree }] }",
1731
+ totalWorktrees: "number \u2014 total worktrees scanned after filtering"
1633
1732
  }
1634
1733
  },
1635
1734
  ownerModule: "workflow-engine",
@@ -1692,16 +1791,28 @@ var UPDATE_WORKTREE_TARGETS = {
1692
1791
  };
1693
1792
  var UPDATE_WORKTREE_METADATA = {
1694
1793
  name: "update_worktree_metadata",
1695
- 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.",
1794
+ 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.",
1696
1795
  parameters: {
1697
1796
  worktreeId: { type: "string", description: "The worktree to update" },
1698
1797
  hypothesis: {
1699
1798
  type: "string",
1700
1799
  description: "Testable claim this worktree investigates"
1701
1800
  },
1702
- executionOrder: {
1801
+ campaign: {
1802
+ type: "number",
1803
+ description: "Top-level pipeline campaign number."
1804
+ },
1805
+ lane: {
1806
+ type: "string",
1807
+ description: "GitButler-aligned workstream lane name inside the campaign."
1808
+ },
1809
+ laneOrderInCampaign: {
1810
+ type: "number",
1811
+ description: "Ordering for this lane within the campaign."
1812
+ },
1813
+ orderInLane: {
1703
1814
  type: "number",
1704
- description: "Global execution order (1 = first, higher = later)"
1815
+ description: "Position of this worktree inside its lane."
1705
1816
  },
1706
1817
  dependsOn: {
1707
1818
  type: "array",
@@ -1739,18 +1850,6 @@ var UPDATE_WORKTREE_METADATA = {
1739
1850
  type: "object",
1740
1851
  description: "Calibrated auto-fix policy controlling dry-run vs safe execution, per-run action caps, and permitted mutation tiers."
1741
1852
  },
1742
- track: {
1743
- type: "string",
1744
- 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."
1745
- },
1746
- trackPosition: {
1747
- type: "number",
1748
- description: "Position within the track (1-indexed). E.g., TC-A=1, TC-B=2, TC-C=3 within the 'tc-scope' track."
1749
- },
1750
- executionBand: {
1751
- type: "number",
1752
- 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."
1753
- },
1754
1853
  status: {
1755
1854
  type: "string",
1756
1855
  description: "Override the worktree status. Use for lifecycle transitions like marking a worktree superseded, long-term, or as a raw idea.",
@@ -2120,6 +2219,10 @@ var LIST_TASKS = {
2120
2219
  type: "string",
2121
2220
  description: "Filter to tasks linked to this worktree"
2122
2221
  },
2222
+ worktreeId: {
2223
+ type: "string",
2224
+ description: "Alias for linkedWorktreeId"
2225
+ },
2123
2226
  status: {
2124
2227
  type: "string",
2125
2228
  description: "Filter by status: todo, in_progress, blocked, done",
@@ -2207,7 +2310,7 @@ var GET_TOPIC = {
2207
2310
  description: "Legacy alias for topicId"
2208
2311
  }
2209
2312
  },
2210
- required: [],
2313
+ required: ["topicId"],
2211
2314
  response: {
2212
2315
  description: "Single topic record",
2213
2316
  fields: {
@@ -2562,7 +2665,7 @@ var GET_ONTOLOGY = {
2562
2665
  description: "Tenant scope for key lookup. Omit for platform-level."
2563
2666
  }
2564
2667
  },
2565
- required: [],
2668
+ required: ["id"],
2566
2669
  response: {
2567
2670
  description: "Ontology definition with latest published version",
2568
2671
  fields: {
@@ -2629,7 +2732,7 @@ var MATCH_ENTITY_TYPE = {
2629
2732
  description: "Optional maximum number of ranked matches to return"
2630
2733
  }
2631
2734
  },
2632
- required: ["text"],
2735
+ required: ["text", "ontologyId"],
2633
2736
  response: {
2634
2737
  description: "Ranked ontology entity type matches",
2635
2738
  fields: {
@@ -2883,7 +2986,7 @@ var RECORD_SCOPE_LEARNING = {
2883
2986
  };
2884
2987
  var PIPELINE_SNAPSHOT = {
2885
2988
  name: "pipeline_snapshot",
2886
- 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.",
2989
+ 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.",
2887
2990
  parameters: {
2888
2991
  topicId: { type: "string", description: "Topic scope ID" }
2889
2992
  },
@@ -2893,14 +2996,14 @@ var PIPELINE_SNAPSHOT = {
2893
2996
  fields: {
2894
2997
  topicId: "string",
2895
2998
  topicName: "string",
2896
- currentBand: "number | null",
2897
- nextBand: "number | null",
2999
+ currentCampaign: "number | null",
3000
+ nextCampaign: "number | null",
2898
3001
  activeWorktrees: "array \u2014 current hinge worktree(s)",
2899
- nextWave: "array \u2014 worktrees in the next planned band",
3002
+ nextWave: "array \u2014 worktrees in the next planned campaign",
2900
3003
  readyNow: "array \u2014 planning worktrees with dependencies completed",
2901
3004
  blockedBy: "array \u2014 grouped blockers",
2902
3005
  criticalPath: "array \u2014 ordered incomplete worktree chain",
2903
- bands: "array \u2014 incomplete worktrees grouped by executionBand",
3006
+ campaigns: "array \u2014 incomplete worktrees grouped by campaign",
2904
3007
  superseded: "array \u2014 worktrees marked superseded or not for activation",
2905
3008
  graphHygiene: "object \u2014 untargeted and taskless worktree debt",
2906
3009
  riskQuestions: "array \u2014 critical/high open questions",
@@ -3489,6 +3592,7 @@ var MCP_TOOL_CONTRACTS = {
3489
3592
  list_beliefs: LIST_BELIEFS,
3490
3593
  list_worktrees: LIST_WORKTREES,
3491
3594
  list_all_worktrees: LIST_ALL_WORKTREES,
3595
+ list_campaigns: LIST_CAMPAIGNS,
3492
3596
  activate_worktree: ACTIVATE_WORKTREE,
3493
3597
  update_worktree_targets: UPDATE_WORKTREE_TARGETS,
3494
3598
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
@@ -3671,6 +3775,7 @@ var MCP_WORKFLOW_PLATFORM_OPERATION_NAMES = [
3671
3775
  "activate_worktree",
3672
3776
  "list_worktrees",
3673
3777
  "list_all_worktrees",
3778
+ "list_campaigns",
3674
3779
  "update_worktree_targets",
3675
3780
  "update_worktree_metadata",
3676
3781
  "create_task",
@@ -3878,6 +3983,7 @@ var LUCERN_OPERATION_MANIFEST = {
3878
3983
 
3879
3984
  // src/function-registry/helpers.ts
3880
3985
  var jsonObjectSchema = z.record(z.unknown());
3986
+ var sdkSessionIdSchema = z.string().optional();
3881
3987
  function mcpContractShape(contract) {
3882
3988
  const required = new Set(contract.required);
3883
3989
  return Object.fromEntries(
@@ -3912,10 +4018,40 @@ function argsSchemaFromMcpContract(contract) {
3912
4018
  return z.object(mcpContractShape(contract));
3913
4019
  }
3914
4020
  function inputSchemaFromMcpContract(contract) {
3915
- return argsSchemaFromMcpContract(contract).passthrough();
4021
+ return withInternalSurfaceFields(argsSchemaFromMcpContract(contract));
4022
+ }
4023
+ function withInternalSurfaceFields(schema) {
4024
+ return schema.extend({ __sdkSessionId: sdkSessionIdSchema }).strict();
4025
+ }
4026
+ function normalizeInputSchema(schema) {
4027
+ if (schema instanceof z.ZodObject) {
4028
+ return withInternalSurfaceFields(schema);
4029
+ }
4030
+ return schema;
4031
+ }
4032
+ function unwrapObjectSchema(schema) {
4033
+ let current = schema;
4034
+ while (true) {
4035
+ switch (current._def.typeName) {
4036
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4037
+ current = current._def.schema;
4038
+ continue;
4039
+ case z.ZodFirstPartyTypeKind.ZodBranded:
4040
+ current = current._def.type;
4041
+ continue;
4042
+ default:
4043
+ return current instanceof z.ZodObject ? current : void 0;
4044
+ }
4045
+ }
3916
4046
  }
3917
4047
  function getObjectShape(schema) {
3918
- const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
4048
+ const objectSchema = unwrapObjectSchema(schema);
4049
+ if (!objectSchema) {
4050
+ throw new Error(
4051
+ `Expected a Zod object schema, received ${schema._def.typeName}.`
4052
+ );
4053
+ }
4054
+ const shape = typeof objectSchema._def.shape === "function" ? objectSchema._def.shape() : objectSchema._def.shape;
3919
4055
  return shape;
3920
4056
  }
3921
4057
  function unwrapMcpParameterSchema(schema) {
@@ -3936,6 +4072,9 @@ function unwrapMcpParameterSchema(schema) {
3936
4072
  case z.ZodFirstPartyTypeKind.ZodBranded:
3937
4073
  current = current._def.type;
3938
4074
  continue;
4075
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4076
+ current = current._def.schema;
4077
+ continue;
3939
4078
  default:
3940
4079
  return { schema: current, required, description: description ?? current.description };
3941
4080
  }
@@ -3955,6 +4094,7 @@ function mcpParameterFromZod(fieldName, schema, contractName) {
3955
4094
  return { parameter: { type: "array", description }, required };
3956
4095
  case z.ZodFirstPartyTypeKind.ZodObject:
3957
4096
  case z.ZodFirstPartyTypeKind.ZodRecord:
4097
+ case z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
3958
4098
  return { parameter: { type: "object", description }, required };
3959
4099
  case z.ZodFirstPartyTypeKind.ZodEnum:
3960
4100
  return {
@@ -4001,6 +4141,11 @@ function mcpContractFromArgsSchema(base, args, contractName) {
4001
4141
  function defineFunctionContract(contract) {
4002
4142
  return contract;
4003
4143
  }
4144
+ function compactRecord(input) {
4145
+ return Object.fromEntries(
4146
+ Object.entries(input).filter(([, value]) => value !== void 0)
4147
+ );
4148
+ }
4004
4149
  function surfaceMcpContract(name) {
4005
4150
  const contract = MCP_TOOL_CONTRACTS[name];
4006
4151
  if (!contract) {
@@ -4045,7 +4190,9 @@ function surfaceContract(args) {
4045
4190
  const canonicalArgs = args.args ?? argsSchemaFromMcpContract(baseMcp);
4046
4191
  const mcp = args.args ? mcpContractFromArgsSchema(baseMcp, canonicalArgs, args.name) : baseMcp;
4047
4192
  const canonicalReturns = args.returns ?? jsonObjectSchema;
4048
- const input = args.input ?? inputSchemaFromMcpContract(mcp);
4193
+ const input = normalizeInputSchema(
4194
+ args.input ?? inputSchemaFromMcpContract(mcp)
4195
+ );
4049
4196
  const output = args.output ?? canonicalReturns;
4050
4197
  return defineFunctionContract({
4051
4198
  name: args.name,
@@ -4089,11 +4236,69 @@ function surfaceContract(args) {
4089
4236
  });
4090
4237
  }
4091
4238
 
4239
+ // src/projections/projection-dsl.ts
4240
+ function defineProjection(def) {
4241
+ return def;
4242
+ }
4243
+
4244
+ // src/projections/list-tasks.projection.ts
4245
+ var taskStatusSchema = z.enum(["todo", "in_progress", "blocked", "done"]).optional().describe("Filter by task status");
4246
+ var listTasksInputSchema = z.object({
4247
+ topicId: z.string().describe("Topic scope"),
4248
+ worktreeId: z.string().optional().describe("Alias for linkedWorktreeId"),
4249
+ linkedWorktreeId: z.string().optional().describe("Filter to tasks linked to this worktree"),
4250
+ status: taskStatusSchema,
4251
+ limit: z.number().optional().describe("Maximum results")
4252
+ });
4253
+ function compactRecord2(input) {
4254
+ return Object.fromEntries(
4255
+ Object.entries(input).filter(([, value]) => value !== void 0)
4256
+ );
4257
+ }
4258
+ var listTasksProjection = defineProjection({
4259
+ contractName: "list_tasks",
4260
+ inputSchema: listTasksInputSchema,
4261
+ project: (input) => compactRecord2({
4262
+ topicId: input.topicId,
4263
+ status: input.status,
4264
+ userId: void 0,
4265
+ limit: input.limit,
4266
+ linkedWorktreeId: input.linkedWorktreeId ?? input.worktreeId
4267
+ }),
4268
+ convexArgsValidator: v.object({
4269
+ topicId: v.string(),
4270
+ status: v.optional(
4271
+ v.union(
4272
+ v.literal("todo"),
4273
+ v.literal("in_progress"),
4274
+ v.literal("blocked"),
4275
+ v.literal("done")
4276
+ )
4277
+ ),
4278
+ limit: v.optional(v.number()),
4279
+ linkedWorktreeId: v.optional(v.string())
4280
+ })
4281
+ });
4282
+
4092
4283
  // src/function-registry/tasks.ts
4093
- var taskInput = (input) => ({
4284
+ var taskInput = (input) => compactRecord({
4094
4285
  ...input,
4095
4286
  taskId: input.taskId ?? input.id
4096
4287
  });
4288
+ var taskTopicInput = (input) => {
4289
+ const parsed = listTasksProjection.inputSchema.safeParse(input);
4290
+ if (!parsed.success) {
4291
+ throw new Error(
4292
+ `list_tasks projection input rejected: ${parsed.error.message}`
4293
+ );
4294
+ }
4295
+ return compactRecord(listTasksProjection.project(parsed.data));
4296
+ };
4297
+ var completeTaskInput = (input) => compactRecord({
4298
+ taskId: input.taskId ?? input.id,
4299
+ outputSummary: input.outputSummary ?? input.summary,
4300
+ userId: input.userId
4301
+ });
4097
4302
  var tasksContracts = [
4098
4303
  surfaceContract({
4099
4304
  name: "create_task",
@@ -4123,8 +4328,10 @@ var tasksContracts = [
4123
4328
  convex: {
4124
4329
  module: "tasks",
4125
4330
  functionName: "getByTopic",
4126
- kind: "query"
4127
- }
4331
+ kind: "query",
4332
+ inputProjection: taskTopicInput
4333
+ },
4334
+ args: listTasksInputSchema
4128
4335
  }),
4129
4336
  surfaceContract({
4130
4337
  name: "update_task",
@@ -4156,7 +4363,7 @@ var tasksContracts = [
4156
4363
  module: "tasks",
4157
4364
  functionName: "complete",
4158
4365
  kind: "mutation",
4159
- inputProjection: taskInput
4366
+ inputProjection: completeTaskInput
4160
4367
  }
4161
4368
  })
4162
4369
  ];