@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 { z } from 'zod';
2
2
 
3
- // src/function-registry/helpers.ts
3
+ // src/function-registry/edges.ts
4
4
 
5
5
  // src/lens-workflow.contract.ts
6
6
  var LENS_PERSPECTIVE_TYPES = [
@@ -14,7 +14,7 @@ var LENS_PERSPECTIVE_TYPES = [
14
14
  // src/tool-contracts.ts
15
15
  var CREATE_BELIEF = {
16
16
  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.",
17
+ 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
18
  parameters: {
19
19
  canonicalText: {
20
20
  type: "string",
@@ -26,7 +26,7 @@ var CREATE_BELIEF = {
26
26
  },
27
27
  baseRate: {
28
28
  type: "number",
29
- description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
29
+ description: "Prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time. Defaults to 0.5 when omitted."
30
30
  },
31
31
  beliefType: {
32
32
  type: "string",
@@ -37,7 +37,7 @@ var CREATE_BELIEF = {
37
37
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
38
38
  }
39
39
  },
40
- required: ["canonicalText", "baseRate"],
40
+ required: ["canonicalText"],
41
41
  response: {
42
42
  description: "The created canonical belief record",
43
43
  fields: {
@@ -100,7 +100,7 @@ var REFINE_BELIEF = {
100
100
  };
101
101
  var MODULATE_CONFIDENCE = {
102
102
  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.",
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. 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
104
  parameters: {
105
105
  nodeId: { type: "string", description: "The belief to score" },
106
106
  belief: {
@@ -119,9 +119,9 @@ var MODULATE_CONFIDENCE = {
119
119
  type: "number",
120
120
  description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
121
121
  },
122
- confidence: {
123
- type: "number",
124
- description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
122
+ worktreeId: {
123
+ type: "string",
124
+ description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
125
125
  },
126
126
  trigger: {
127
127
  type: "string",
@@ -136,17 +136,43 @@ var MODULATE_CONFIDENCE = {
136
136
  "worktree_completed",
137
137
  "fusion",
138
138
  "discount",
139
- "deduction",
140
- "manual",
141
- "decay"
139
+ "deduction"
142
140
  ]
143
141
  },
142
+ triggeringEvidenceId: {
143
+ type: "string",
144
+ description: "Evidence node that caused an evidence-triggered modulation"
145
+ },
146
+ triggeringQuestionId: {
147
+ type: "string",
148
+ description: "Answered question whose resolution supports this modulation"
149
+ },
150
+ triggeringAnswerId: {
151
+ type: "string",
152
+ description: "Answer node whose content supports this modulation"
153
+ },
154
+ triggeringContradictionId: {
155
+ type: "string",
156
+ description: "Contradiction record that caused a contradiction-triggered modulation"
157
+ },
158
+ triggeringWorktreeId: {
159
+ type: "string",
160
+ description: "Completed worktree whose outcome caused a worktree-triggered modulation"
161
+ },
144
162
  rationale: {
145
163
  type: "string",
146
164
  description: "Human-readable explanation of why confidence changed"
147
165
  }
148
166
  },
149
- required: ["nodeId", "trigger", "rationale"],
167
+ required: [
168
+ "nodeId",
169
+ "belief",
170
+ "disbelief",
171
+ "uncertainty",
172
+ "baseRate",
173
+ "trigger",
174
+ "rationale"
175
+ ],
150
176
  response: {
151
177
  description: "Confidence modulation result",
152
178
  fields: {
@@ -340,7 +366,7 @@ var ADD_EVIDENCE = {
340
366
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'], failedApproach: true } for coding intelligence)"
341
367
  }
342
368
  },
343
- required: ["canonicalText", "targetNodeId"],
369
+ required: ["canonicalText", "targetNodeId", "reasoning"],
344
370
  response: {
345
371
  description: "The created evidence node and its edge",
346
372
  fields: {
@@ -421,9 +447,21 @@ var ADD_WORKTREE = {
421
447
  type: "string",
422
448
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
423
449
  },
424
- executionOrder: {
450
+ campaign: {
451
+ type: "number",
452
+ description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
453
+ },
454
+ lane: {
455
+ type: "string",
456
+ description: "GitButler-aligned workstream lane name inside the campaign."
457
+ },
458
+ laneOrderInCampaign: {
459
+ type: "number",
460
+ description: "Ordering for this lane within its campaign."
461
+ },
462
+ orderInLane: {
425
463
  type: "number",
426
- description: "Global execution order for this worktree"
464
+ description: "Position of this worktree inside its lane."
427
465
  },
428
466
  dependsOn: {
429
467
  type: "array",
@@ -1081,6 +1119,10 @@ var CREATE_EVIDENCE = {
1081
1119
  type: "object",
1082
1120
  description: "Optional metadata merged into the canonical evidence node"
1083
1121
  },
1122
+ rationale: {
1123
+ type: "string",
1124
+ description: "Why this evidence should enter the reasoning graph"
1125
+ },
1084
1126
  title: { type: "string", description: "Optional short title" },
1085
1127
  content: { type: "string", description: "Optional long-form content" },
1086
1128
  contentType: {
@@ -1089,7 +1131,7 @@ var CREATE_EVIDENCE = {
1089
1131
  },
1090
1132
  kind: { type: "string", description: "Optional evidence kind" }
1091
1133
  },
1092
- required: ["text"],
1134
+ required: ["text", "rationale"],
1093
1135
  response: {
1094
1136
  description: "The created canonical evidence record",
1095
1137
  fields: {
@@ -1137,7 +1179,7 @@ var LIST_EVIDENCE = {
1137
1179
  limit: { type: "number", description: "Max results" },
1138
1180
  cursor: { type: "string", description: "Pagination cursor" }
1139
1181
  },
1140
- required: [],
1182
+ required: ["topicId"],
1141
1183
  response: {
1142
1184
  description: "Canonical evidence page",
1143
1185
  fields: {
@@ -1322,6 +1364,7 @@ var ANSWER_QUESTION = {
1322
1364
  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
1365
  parameters: {
1324
1366
  id: { type: "string", description: "Canonical question ID" },
1367
+ topicId: { type: "string", description: "Topic scope for the answer" },
1325
1368
  text: { type: "string", description: "Answer text" },
1326
1369
  confidence: {
1327
1370
  type: "string",
@@ -1334,7 +1377,7 @@ var ANSWER_QUESTION = {
1334
1377
  },
1335
1378
  rationale: { type: "string", description: "Why this answer is credible" }
1336
1379
  },
1337
- required: ["id", "text"],
1380
+ required: ["id", "topicId", "text"],
1338
1381
  response: {
1339
1382
  description: "Answer result",
1340
1383
  fields: {
@@ -1553,6 +1596,10 @@ var LIST_BELIEFS = {
1553
1596
  minConfidence: {
1554
1597
  type: "number",
1555
1598
  description: "Minimum confidence threshold"
1599
+ },
1600
+ limit: {
1601
+ type: "number",
1602
+ description: "Maximum results"
1556
1603
  }
1557
1604
  },
1558
1605
  required: ["topicId"],
@@ -1569,20 +1616,37 @@ var LIST_BELIEFS = {
1569
1616
  };
1570
1617
  var LIST_WORKTREES = {
1571
1618
  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.",
1619
+ 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
1620
  parameters: {
1574
1621
  topicId: { type: "string", description: "Topic scope" },
1575
1622
  status: {
1576
1623
  type: "string",
1577
1624
  description: "Filter: active, merged, abandoned",
1578
1625
  enum: ["active", "merged", "abandoned"]
1626
+ },
1627
+ groupBy: {
1628
+ type: "string",
1629
+ description: "Optional grouping mode for the response.",
1630
+ enum: ["campaign", "lane", "flat"]
1631
+ },
1632
+ lane: {
1633
+ type: "string",
1634
+ description: "Filter by GitButler-aligned lane name."
1635
+ },
1636
+ campaign: {
1637
+ type: "number",
1638
+ description: "Filter by top-level pipeline campaign number."
1639
+ },
1640
+ limit: {
1641
+ type: "number",
1642
+ description: "Maximum results to return."
1579
1643
  }
1580
1644
  },
1581
1645
  required: ["topicId"],
1582
1646
  response: {
1583
- description: "Worktrees with phase, status, belief count, and creation time",
1647
+ description: "Worktrees with lifecycle phase, campaign, lane, status, belief count, and creation time",
1584
1648
  fields: {
1585
- worktrees: "array \u2014 { worktreeId, title, phase, status, beliefCount, createdAt }"
1649
+ worktrees: "array \u2014 { worktreeId, title, phase, campaign, lane, laneOrderInCampaign, orderInLane, status, beliefCount, createdAt }"
1586
1650
  }
1587
1651
  },
1588
1652
  ownerModule: "workflow-engine",
@@ -1591,7 +1655,7 @@ var LIST_WORKTREES = {
1591
1655
  };
1592
1656
  var LIST_ALL_WORKTREES = {
1593
1657
  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.",
1658
+ 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
1659
  parameters: {
1596
1660
  status: {
1597
1661
  type: "string",
@@ -1609,13 +1673,18 @@ var LIST_ALL_WORKTREES = {
1609
1673
  "dismissed"
1610
1674
  ]
1611
1675
  },
1612
- track: {
1676
+ lane: {
1613
1677
  type: "string",
1614
- description: "Filter by track name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1678
+ description: "Filter by lane name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
1615
1679
  },
1616
- executionBand: {
1680
+ campaign: {
1617
1681
  type: "number",
1618
- description: "Filter by execution band number (e.g., 1, 2, 3). Returns only worktrees in that parallel execution group."
1682
+ description: "Filter by campaign number (e.g., 1, 2, 3). Returns only worktrees in that campaign."
1683
+ },
1684
+ groupBy: {
1685
+ type: "string",
1686
+ description: "Optional grouping mode for the response.",
1687
+ enum: ["campaign", "lane", "flat"]
1619
1688
  },
1620
1689
  limit: {
1621
1690
  type: "number",
@@ -1626,10 +1695,39 @@ var LIST_ALL_WORKTREES = {
1626
1695
  response: {
1627
1696
  description: "All worktrees across all topics with full pipeline metadata",
1628
1697
  fields: {
1629
- worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, track, trackPosition, executionBand, executionOrder, dependsOn, blocks, gate, createdAt }",
1698
+ worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, campaign, lane, laneOrderInCampaign, orderInLane, dependsOn, blocks, gate, createdAt }",
1630
1699
  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"
1700
+ lanes: "object \u2014 { laneName: count } summary of worktrees per lane",
1701
+ campaigns: "object \u2014 { campaignNumber: count } summary of worktrees per campaign"
1702
+ }
1703
+ },
1704
+ ownerModule: "workflow-engine",
1705
+ ontologyPrimitive: "worktree",
1706
+ tier: "showcase"
1707
+ };
1708
+ var LIST_CAMPAIGNS = {
1709
+ name: "list_campaigns",
1710
+ 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.",
1711
+ parameters: {
1712
+ topicId: {
1713
+ type: "string",
1714
+ description: "Optional topic scope."
1715
+ },
1716
+ status: {
1717
+ type: "string",
1718
+ description: "Optional worktree status filter before grouping campaigns and lanes."
1719
+ },
1720
+ limit: {
1721
+ type: "number",
1722
+ description: "Maximum worktrees to scan before grouping."
1723
+ }
1724
+ },
1725
+ required: [],
1726
+ response: {
1727
+ description: "Pipeline campaigns with nested lane summaries.",
1728
+ fields: {
1729
+ campaigns: "array \u2014 { campaign, lanes: [{ lane, laneOrderInCampaign, worktreeCount, activeCount, readyCount, blockedCount, completedCount, nextWorktree }] }",
1730
+ totalWorktrees: "number \u2014 total worktrees scanned after filtering"
1633
1731
  }
1634
1732
  },
1635
1733
  ownerModule: "workflow-engine",
@@ -1692,16 +1790,28 @@ var UPDATE_WORKTREE_TARGETS = {
1692
1790
  };
1693
1791
  var UPDATE_WORKTREE_METADATA = {
1694
1792
  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.",
1793
+ 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
1794
  parameters: {
1697
1795
  worktreeId: { type: "string", description: "The worktree to update" },
1698
1796
  hypothesis: {
1699
1797
  type: "string",
1700
1798
  description: "Testable claim this worktree investigates"
1701
1799
  },
1702
- executionOrder: {
1800
+ campaign: {
1801
+ type: "number",
1802
+ description: "Top-level pipeline campaign number."
1803
+ },
1804
+ lane: {
1805
+ type: "string",
1806
+ description: "GitButler-aligned workstream lane name inside the campaign."
1807
+ },
1808
+ laneOrderInCampaign: {
1809
+ type: "number",
1810
+ description: "Ordering for this lane within the campaign."
1811
+ },
1812
+ orderInLane: {
1703
1813
  type: "number",
1704
- description: "Global execution order (1 = first, higher = later)"
1814
+ description: "Position of this worktree inside its lane."
1705
1815
  },
1706
1816
  dependsOn: {
1707
1817
  type: "array",
@@ -1739,18 +1849,6 @@ var UPDATE_WORKTREE_METADATA = {
1739
1849
  type: "object",
1740
1850
  description: "Calibrated auto-fix policy controlling dry-run vs safe execution, per-run action caps, and permitted mutation tiers."
1741
1851
  },
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
1852
  status: {
1755
1853
  type: "string",
1756
1854
  description: "Override the worktree status. Use for lifecycle transitions like marking a worktree superseded, long-term, or as a raw idea.",
@@ -2120,6 +2218,10 @@ var LIST_TASKS = {
2120
2218
  type: "string",
2121
2219
  description: "Filter to tasks linked to this worktree"
2122
2220
  },
2221
+ worktreeId: {
2222
+ type: "string",
2223
+ description: "Alias for linkedWorktreeId"
2224
+ },
2123
2225
  status: {
2124
2226
  type: "string",
2125
2227
  description: "Filter by status: todo, in_progress, blocked, done",
@@ -2207,7 +2309,7 @@ var GET_TOPIC = {
2207
2309
  description: "Legacy alias for topicId"
2208
2310
  }
2209
2311
  },
2210
- required: [],
2312
+ required: ["topicId"],
2211
2313
  response: {
2212
2314
  description: "Single topic record",
2213
2315
  fields: {
@@ -2562,7 +2664,7 @@ var GET_ONTOLOGY = {
2562
2664
  description: "Tenant scope for key lookup. Omit for platform-level."
2563
2665
  }
2564
2666
  },
2565
- required: [],
2667
+ required: ["id"],
2566
2668
  response: {
2567
2669
  description: "Ontology definition with latest published version",
2568
2670
  fields: {
@@ -2629,7 +2731,7 @@ var MATCH_ENTITY_TYPE = {
2629
2731
  description: "Optional maximum number of ranked matches to return"
2630
2732
  }
2631
2733
  },
2632
- required: ["text"],
2734
+ required: ["text", "ontologyId"],
2633
2735
  response: {
2634
2736
  description: "Ranked ontology entity type matches",
2635
2737
  fields: {
@@ -2883,7 +2985,7 @@ var RECORD_SCOPE_LEARNING = {
2883
2985
  };
2884
2986
  var PIPELINE_SNAPSHOT = {
2885
2987
  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.",
2988
+ 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
2989
  parameters: {
2888
2990
  topicId: { type: "string", description: "Topic scope ID" }
2889
2991
  },
@@ -2893,14 +2995,14 @@ var PIPELINE_SNAPSHOT = {
2893
2995
  fields: {
2894
2996
  topicId: "string",
2895
2997
  topicName: "string",
2896
- currentBand: "number | null",
2897
- nextBand: "number | null",
2998
+ currentCampaign: "number | null",
2999
+ nextCampaign: "number | null",
2898
3000
  activeWorktrees: "array \u2014 current hinge worktree(s)",
2899
- nextWave: "array \u2014 worktrees in the next planned band",
3001
+ nextWave: "array \u2014 worktrees in the next planned campaign",
2900
3002
  readyNow: "array \u2014 planning worktrees with dependencies completed",
2901
3003
  blockedBy: "array \u2014 grouped blockers",
2902
3004
  criticalPath: "array \u2014 ordered incomplete worktree chain",
2903
- bands: "array \u2014 incomplete worktrees grouped by executionBand",
3005
+ campaigns: "array \u2014 incomplete worktrees grouped by campaign",
2904
3006
  superseded: "array \u2014 worktrees marked superseded or not for activation",
2905
3007
  graphHygiene: "object \u2014 untargeted and taskless worktree debt",
2906
3008
  riskQuestions: "array \u2014 critical/high open questions",
@@ -3489,6 +3591,7 @@ var MCP_TOOL_CONTRACTS = {
3489
3591
  list_beliefs: LIST_BELIEFS,
3490
3592
  list_worktrees: LIST_WORKTREES,
3491
3593
  list_all_worktrees: LIST_ALL_WORKTREES,
3594
+ list_campaigns: LIST_CAMPAIGNS,
3492
3595
  activate_worktree: ACTIVATE_WORKTREE,
3493
3596
  update_worktree_targets: UPDATE_WORKTREE_TARGETS,
3494
3597
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
@@ -3671,6 +3774,7 @@ var MCP_WORKFLOW_PLATFORM_OPERATION_NAMES = [
3671
3774
  "activate_worktree",
3672
3775
  "list_worktrees",
3673
3776
  "list_all_worktrees",
3777
+ "list_campaigns",
3674
3778
  "update_worktree_targets",
3675
3779
  "update_worktree_metadata",
3676
3780
  "create_task",
@@ -3878,6 +3982,7 @@ var LUCERN_OPERATION_MANIFEST = {
3878
3982
 
3879
3983
  // src/function-registry/helpers.ts
3880
3984
  var jsonObjectSchema = z.record(z.unknown());
3985
+ var sdkSessionIdSchema = z.string().optional();
3881
3986
  function mcpContractShape(contract) {
3882
3987
  const required = new Set(contract.required);
3883
3988
  return Object.fromEntries(
@@ -3912,10 +4017,40 @@ function argsSchemaFromMcpContract(contract) {
3912
4017
  return z.object(mcpContractShape(contract));
3913
4018
  }
3914
4019
  function inputSchemaFromMcpContract(contract) {
3915
- return argsSchemaFromMcpContract(contract).passthrough();
4020
+ return withInternalSurfaceFields(argsSchemaFromMcpContract(contract));
4021
+ }
4022
+ function withInternalSurfaceFields(schema) {
4023
+ return schema.extend({ __sdkSessionId: sdkSessionIdSchema }).strict();
4024
+ }
4025
+ function normalizeInputSchema(schema) {
4026
+ if (schema instanceof z.ZodObject) {
4027
+ return withInternalSurfaceFields(schema);
4028
+ }
4029
+ return schema;
4030
+ }
4031
+ function unwrapObjectSchema(schema) {
4032
+ let current = schema;
4033
+ while (true) {
4034
+ switch (current._def.typeName) {
4035
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4036
+ current = current._def.schema;
4037
+ continue;
4038
+ case z.ZodFirstPartyTypeKind.ZodBranded:
4039
+ current = current._def.type;
4040
+ continue;
4041
+ default:
4042
+ return current instanceof z.ZodObject ? current : void 0;
4043
+ }
4044
+ }
3916
4045
  }
3917
4046
  function getObjectShape(schema) {
3918
- const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
4047
+ const objectSchema = unwrapObjectSchema(schema);
4048
+ if (!objectSchema) {
4049
+ throw new Error(
4050
+ `Expected a Zod object schema, received ${schema._def.typeName}.`
4051
+ );
4052
+ }
4053
+ const shape = typeof objectSchema._def.shape === "function" ? objectSchema._def.shape() : objectSchema._def.shape;
3919
4054
  return shape;
3920
4055
  }
3921
4056
  function unwrapMcpParameterSchema(schema) {
@@ -3936,6 +4071,9 @@ function unwrapMcpParameterSchema(schema) {
3936
4071
  case z.ZodFirstPartyTypeKind.ZodBranded:
3937
4072
  current = current._def.type;
3938
4073
  continue;
4074
+ case z.ZodFirstPartyTypeKind.ZodEffects:
4075
+ current = current._def.schema;
4076
+ continue;
3939
4077
  default:
3940
4078
  return { schema: current, required, description: description ?? current.description };
3941
4079
  }
@@ -3955,6 +4093,7 @@ function mcpParameterFromZod(fieldName, schema, contractName) {
3955
4093
  return { parameter: { type: "array", description }, required };
3956
4094
  case z.ZodFirstPartyTypeKind.ZodObject:
3957
4095
  case z.ZodFirstPartyTypeKind.ZodRecord:
4096
+ case z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
3958
4097
  return { parameter: { type: "object", description }, required };
3959
4098
  case z.ZodFirstPartyTypeKind.ZodEnum:
3960
4099
  return {
@@ -4010,6 +4149,11 @@ function withCreatedBy(input, context) {
4010
4149
  createdBy: typeof input.createdBy === "string" ? input.createdBy : authUserId(context)
4011
4150
  };
4012
4151
  }
4152
+ function compactRecord(input) {
4153
+ return Object.fromEntries(
4154
+ Object.entries(input).filter(([, value]) => value !== void 0)
4155
+ );
4156
+ }
4013
4157
  function surfaceMcpContract(name) {
4014
4158
  const contract = MCP_TOOL_CONTRACTS[name];
4015
4159
  if (!contract) {
@@ -4054,7 +4198,9 @@ function surfaceContract(args) {
4054
4198
  const canonicalArgs = args.args ?? argsSchemaFromMcpContract(baseMcp);
4055
4199
  const mcp = args.args ? mcpContractFromArgsSchema(baseMcp, canonicalArgs, args.name) : baseMcp;
4056
4200
  const canonicalReturns = args.returns ?? jsonObjectSchema;
4057
- const input = args.input ?? inputSchemaFromMcpContract(mcp);
4201
+ const input = normalizeInputSchema(
4202
+ args.input ?? inputSchemaFromMcpContract(mcp)
4203
+ );
4058
4204
  const output = args.output ?? canonicalReturns;
4059
4205
  return defineFunctionContract({
4060
4206
  name: args.name,
@@ -4097,8 +4243,115 @@ function surfaceContract(args) {
4097
4243
  }
4098
4244
  });
4099
4245
  }
4246
+ var EpistemicNodeTypeSchema = z.enum([
4247
+ "belief",
4248
+ "evidence",
4249
+ "question",
4250
+ "answer",
4251
+ "topic",
4252
+ "edge",
4253
+ "ontology",
4254
+ "lens",
4255
+ "contradiction"
4256
+ ]);
4257
+ var GraphRefSchema = z.discriminatedUnion("kind", [
4258
+ z.object({
4259
+ kind: z.literal("epistemic_node"),
4260
+ nodeId: z.string(),
4261
+ nodeType: EpistemicNodeTypeSchema
4262
+ }),
4263
+ z.object({
4264
+ kind: z.literal("external_belief"),
4265
+ ref: z.object({
4266
+ tenantId: z.string(),
4267
+ beliefId: z.string()
4268
+ })
4269
+ })
4270
+ ]);
4271
+
4272
+ // src/manifests/edge-policy-manifest.ts
4273
+ var graphRefKind = z.enum(["epistemic_node", "external_belief"]);
4274
+ var EdgePolicyEntrySchema = z.object({
4275
+ edgeType: z.string(),
4276
+ fromKinds: z.array(graphRefKind),
4277
+ fromNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
4278
+ toKinds: z.array(graphRefKind),
4279
+ toNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
4280
+ description: z.string()
4281
+ });
4282
+ z.object({
4283
+ manifestVersion: z.literal("1.0.0"),
4284
+ policies: z.array(EdgePolicyEntrySchema)
4285
+ });
4286
+ function findEdgePolicy(manifest, edgeType) {
4287
+ return manifest.policies.find((policy) => policy.edgeType === edgeType);
4288
+ }
4289
+ function nodeTypeAllowed(allowed, ref) {
4290
+ return ref.kind !== "epistemic_node" || !allowed || allowed.includes(ref.nodeType);
4291
+ }
4292
+ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4293
+ const policy = findEdgePolicy(manifest, edgeType);
4294
+ const allowed = Boolean(policy) && policy.fromKinds.includes(from.kind) && policy.toKinds.includes(to.kind) && nodeTypeAllowed(policy.fromNodeTypes, from) && nodeTypeAllowed(policy.toNodeTypes, to);
4295
+ if (!allowed) {
4296
+ const error = new Error(
4297
+ `Edge policy violation for ${edgeType}: ${from.kind} -> ${to.kind}`
4298
+ );
4299
+ error.code = "POLICY_VIOLATION";
4300
+ error.details = { code: "POLICY_VIOLATION", edgeType, from, to };
4301
+ throw error;
4302
+ }
4303
+ }
4304
+
4305
+ // src/manifests/edge-policy-manifest.data.ts
4306
+ var edgePolicyManifest = {
4307
+ policies: [
4308
+ {
4309
+ edgeType: "evidence_derived_from_evidence",
4310
+ fromKinds: ["epistemic_node"],
4311
+ fromNodeTypes: ["evidence"],
4312
+ toKinds: ["epistemic_node"],
4313
+ toNodeTypes: ["evidence"],
4314
+ description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4315
+ },
4316
+ {
4317
+ edgeType: "evidence_supports_belief",
4318
+ fromKinds: ["epistemic_node"],
4319
+ fromNodeTypes: ["evidence"],
4320
+ toKinds: ["epistemic_node"],
4321
+ toNodeTypes: ["belief"],
4322
+ description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4323
+ },
4324
+ {
4325
+ edgeType: "evidence_supports_question",
4326
+ fromKinds: ["epistemic_node"],
4327
+ fromNodeTypes: ["evidence"],
4328
+ toKinds: ["epistemic_node"],
4329
+ toNodeTypes: ["question"],
4330
+ description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4331
+ }
4332
+ ]
4333
+ };
4100
4334
 
4101
4335
  // src/function-registry/edges.ts
4336
+ var createEdgeArgs = z.object({
4337
+ from: GraphRefSchema,
4338
+ to: GraphRefSchema,
4339
+ edgeType: z.string(),
4340
+ globalId: z.string().optional(),
4341
+ weight: z.number().optional(),
4342
+ confidence: z.number().optional(),
4343
+ context: z.string().optional(),
4344
+ reasoning: z.string().optional(),
4345
+ derivationType: z.string().optional(),
4346
+ topicId: z.string().optional(),
4347
+ trustedBypassAccessCheck: z.boolean().optional()
4348
+ });
4349
+ function graphRefNodeId(ref) {
4350
+ if (ref.kind === "epistemic_node") {
4351
+ return ref.nodeId;
4352
+ }
4353
+ return `external_belief:${ref.ref.tenantId}:${ref.ref.beliefId}`;
4354
+ }
4102
4355
  var edgesContracts = [
4103
4356
  surfaceContract({
4104
4357
  name: "create_edge",
@@ -4113,16 +4366,35 @@ var edgesContracts = [
4113
4366
  module: "edges",
4114
4367
  functionName: "create",
4115
4368
  kind: "mutation",
4116
- inputProjection: (input, context) => withCreatedBy(
4117
- {
4118
- ...input,
4119
- fromNodeId: input.fromNodeId ?? input.sourceId,
4120
- toNodeId: input.toNodeId ?? input.targetId,
4121
- context: input.context ?? input.reasoning
4122
- },
4123
- context
4124
- )
4125
- }
4369
+ inputProjection: (input, context) => {
4370
+ const parsed = createEdgeArgs.parse(input);
4371
+ assertEdgePolicyAllowed(
4372
+ edgePolicyManifest,
4373
+ parsed.edgeType,
4374
+ parsed.from,
4375
+ parsed.to
4376
+ );
4377
+ const fromNodeId = graphRefNodeId(parsed.from);
4378
+ const toNodeId = graphRefNodeId(parsed.to);
4379
+ return withCreatedBy(
4380
+ compactRecord({
4381
+ fromNodeId,
4382
+ toNodeId,
4383
+ edgeType: parsed.edgeType,
4384
+ globalId: parsed.globalId ?? `edge:${fromNodeId}:${toNodeId}:${parsed.edgeType}`,
4385
+ weight: parsed.weight,
4386
+ confidence: parsed.confidence,
4387
+ context: parsed.context ?? parsed.reasoning,
4388
+ derivationType: parsed.derivationType,
4389
+ skipLayerValidation: true,
4390
+ topicId: parsed.topicId,
4391
+ trustedBypassAccessCheck: parsed.trustedBypassAccessCheck
4392
+ }),
4393
+ context
4394
+ );
4395
+ }
4396
+ },
4397
+ args: createEdgeArgs
4126
4398
  }),
4127
4399
  surfaceContract({
4128
4400
  name: "query_lineage",
@@ -4137,9 +4409,12 @@ var edgesContracts = [
4137
4409
  module: "edges",
4138
4410
  functionName: "getLineage",
4139
4411
  kind: "query",
4140
- inputProjection: (input) => ({
4141
- ...input,
4142
- maxDepth: input.maxDepth ?? input.depth
4412
+ inputProjection: (input) => compactRecord({
4413
+ nodeId: input.nodeId ?? input.startNode,
4414
+ maxDepth: input.maxDepth ?? input.depth,
4415
+ mode: input.mode,
4416
+ minLayer: input.minLayer,
4417
+ maxLayer: input.maxLayer
4143
4418
  })
4144
4419
  }
4145
4420
  })