@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
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z, ZodFirstPartyTypeKind } from 'zod';
2
+ import { v } from 'convex/values';
2
3
  export * from './function-registry/index.js';
3
4
 
4
5
  var __defProp = Object.defineProperty;
@@ -920,6 +921,9 @@ function convertSchemaInner(schema, state, path) {
920
921
  case ZodFirstPartyTypeKind.ZodBranded: {
921
922
  return convertSchema(schema._def.type, state, path);
922
923
  }
924
+ case ZodFirstPartyTypeKind.ZodEffects: {
925
+ return convertSchema(schema._def.schema, state, path);
926
+ }
923
927
  default:
924
928
  unsupported2(`Unsupported Zod schema kind ${schema._def.typeName}`, state, path);
925
929
  }
@@ -1177,11 +1181,13 @@ function zodToJsonSchema(schema, options = {}) {
1177
1181
  var schemas_exports = {};
1178
1182
  __export(schemas_exports, {
1179
1183
  ALL_TABLE_CONTRACTS: () => ALL_TABLE_CONTRACTS,
1184
+ ComponentTableManifestSchema: () => ComponentTableManifestSchema,
1180
1185
  EDGE_TYPE: () => EDGE_TYPE,
1181
1186
  IDENTITY_TABLE_CONTRACTS: () => IDENTITY_TABLE_CONTRACTS,
1182
1187
  KERNEL_TABLE_CONTRACTS: () => KERNEL_TABLE_CONTRACTS,
1183
1188
  MC_TABLE_CONTRACTS: () => MC_TABLE_CONTRACTS,
1184
1189
  NODE_TYPE: () => NODE_TYPE,
1190
+ SLOpinionInputSchema: () => SLOpinionInputSchema,
1185
1191
  TABLE_CONTRACTS_BY_COMPONENT: () => TABLE_CONTRACTS_BY_COMPONENT,
1186
1192
  TOPIC_STATUS: () => TOPIC_STATUS,
1187
1193
  TOPIC_VISIBILITY: () => TOPIC_VISIBILITY,
@@ -1573,6 +1579,28 @@ var autofixJobs = defineTable({
1573
1579
  { kind: "index", name: "by_createdAt", columns: ["createdAt"] }
1574
1580
  ]
1575
1581
  });
1582
+ var neo4jSyncQueue = defineTable({
1583
+ name: "neo4jSyncQueue",
1584
+ component: "kernel",
1585
+ category: "infra",
1586
+ shape: z.object({
1587
+ "entityType": z.enum(["node", "edge"]),
1588
+ "entityId": z.string(),
1589
+ "operation": z.enum(["upsert", "delete"]),
1590
+ "attempts": z.number(),
1591
+ "maxAttempts": z.number(),
1592
+ "lastAttemptAt": z.number().optional(),
1593
+ "lastError": z.string().optional(),
1594
+ "status": z.enum(["pending", "in_progress", "failed", "succeeded"]),
1595
+ "createdAt": z.number(),
1596
+ "updatedAt": z.number()
1597
+ }),
1598
+ indices: [
1599
+ { kind: "index", name: "by_status", columns: ["status"] },
1600
+ { kind: "index", name: "by_entity", columns: ["entityType", "entityId"] },
1601
+ { kind: "index", name: "by_status_attempts", columns: ["status", "attempts"] }
1602
+ ]
1603
+ });
1576
1604
  var backgroundJobRuns = defineTable({
1577
1605
  name: "backgroundJobRuns",
1578
1606
  component: "kernel",
@@ -1642,9 +1670,9 @@ var beliefConfidence = defineTable({
1642
1670
  category: "epistemic",
1643
1671
  shape: z.object({
1644
1672
  "beliefId": z.string(),
1645
- "belief": z.number().optional(),
1646
- "disbelief": z.number().optional(),
1647
- "uncertainty": z.number().optional(),
1673
+ "belief": z.number(),
1674
+ "disbelief": z.number(),
1675
+ "uncertainty": z.number(),
1648
1676
  "baseRate": z.number(),
1649
1677
  "slOperator": z.string().optional(),
1650
1678
  "confidence": z.number(),
@@ -1653,10 +1681,12 @@ var beliefConfidence = defineTable({
1653
1681
  "certainty": z.number().optional(),
1654
1682
  "assessedAt": z.number(),
1655
1683
  "assessedBy": z.string(),
1656
- "trigger": z.enum(["initial", "evidence_added", "evidence_removed", "contradiction_detected", "contradiction_resolved", "manual", "decay", "propagation", "agent_assessment", "worktree_outcome", "worktree_completed", "fusion", "discount", "deduction", "backfill_synthetic"]),
1684
+ "trigger": z.enum(["initial", "evidence_added", "evidence_removed", "contradiction_detected", "contradiction_resolved", "propagation", "agent_assessment", "worktree_outcome", "worktree_completed", "fusion", "discount", "deduction", "backfill_synthetic"]),
1657
1685
  "rationale": z.string().optional(),
1658
1686
  "triggeringEvidenceId": z.string().optional(),
1659
1687
  "triggeringEvidenceIds": z.array(z.string()).optional(),
1688
+ "triggeringQuestionId": z.string().optional(),
1689
+ "triggeringAnswerId": z.string().optional(),
1660
1690
  "triggeringContradictionId": idOf("contradictions").optional(),
1661
1691
  "triggeringWorktreeId": z.string().optional(),
1662
1692
  "triggeringAgentId": z.string().optional(),
@@ -2339,7 +2369,7 @@ var tenantDeploymentCredentials = defineTable({
2339
2369
  "credentialRef": z.string(),
2340
2370
  "tenantId": idOf("tenants"),
2341
2371
  "target": z.enum(["kernelDeployment", "appDeployment"]),
2342
- "environment": z.enum(["dev", "prod"]),
2372
+ "environment": z.enum(["dev", "staging", "prod"]),
2343
2373
  "encryptedDeployKey": z.string(),
2344
2374
  "encryptionVersion": z.string(),
2345
2375
  "keyFingerprint": z.string(),
@@ -5008,13 +5038,13 @@ var worktrees = defineTable({
5008
5038
  "rationale": z.string().optional(),
5009
5039
  "confidenceImpact": z.enum(["high", "medium", "low"]).optional(),
5010
5040
  "hypothesis": z.string().optional(),
5011
- "executionOrder": z.number().optional(),
5012
5041
  "dependsOn": z.array(idOf("worktrees")).optional(),
5013
5042
  "blocks": z.array(idOf("worktrees")).optional(),
5014
5043
  "gate": z.string().optional(),
5015
- "track": z.string().optional(),
5016
- "trackPosition": z.number().optional(),
5017
- "executionBand": z.number().optional(),
5044
+ "campaign": z.number().optional(),
5045
+ "lane": z.string().optional(),
5046
+ "laneOrderInCampaign": z.number().optional(),
5047
+ "orderInLane": z.number().optional(),
5018
5048
  "startDate": z.number(),
5019
5049
  "endDate": z.number(),
5020
5050
  "durationWeeks": z.number(),
@@ -5262,6 +5292,8 @@ var worktrees = defineTable({
5262
5292
  { kind: "index", name: "by_topicId_index", columns: ["topicId", "index"] },
5263
5293
  { kind: "index", name: "by_worktreeType", columns: ["topicId", "worktreeType"] },
5264
5294
  { kind: "index", name: "by_topicId_priority", columns: ["topicId", "priority"] },
5295
+ { kind: "index", name: "by_topicId_campaign_lane_order", columns: ["topicId", "campaign", "laneOrderInCampaign", "orderInLane"] },
5296
+ { kind: "index", name: "by_topicId_lane_order", columns: ["topicId", "lane", "orderInLane"] },
5265
5297
  { kind: "index", name: "by_topicId_branch", columns: ["topicId", "targetBranch"] },
5266
5298
  { kind: "index", name: "by_topicId_scope", columns: ["topicId", "worktreeScope"] }
5267
5299
  ]
@@ -5294,6 +5326,7 @@ var KERNEL_TABLE_CONTRACTS = [
5294
5326
  questionEvidenceLinks,
5295
5327
  idempotencyTokens,
5296
5328
  autofixJobs,
5329
+ neo4jSyncQueue,
5297
5330
  backgroundJobRuns,
5298
5331
  backgroundJobSettings,
5299
5332
  systemLogs,
@@ -5403,6 +5436,472 @@ function getTableContract(name, component) {
5403
5436
  (contract) => contract.name === name && (component ? contract.component === component : true)
5404
5437
  );
5405
5438
  }
5439
+ var ComponentTableManifestSchema = z.object({
5440
+ manifestVersion: z.string(),
5441
+ componentName: z.enum(["kernel", "identity"]),
5442
+ tier: z.enum(["K", "I"]),
5443
+ packageVersion: z.string(),
5444
+ tables: z.array(
5445
+ z.object({
5446
+ name: z.string(),
5447
+ fields: z.array(
5448
+ z.object({
5449
+ name: z.string(),
5450
+ type: z.string(),
5451
+ optional: z.boolean(),
5452
+ validator: z.string().optional()
5453
+ })
5454
+ )
5455
+ })
5456
+ )
5457
+ });
5458
+ var SL_EPSILON = 1e-9;
5459
+ var SLOpinionInputSchema = z.object({
5460
+ belief: z.number(),
5461
+ disbelief: z.number(),
5462
+ uncertainty: z.number(),
5463
+ baseRate: z.number()
5464
+ }).refine(
5465
+ (o) => Math.abs(o.belief + o.disbelief + o.uncertainty - 1) < SL_EPSILON,
5466
+ {
5467
+ message: "SL invariant b+d+u=1 violated at API boundary"
5468
+ }
5469
+ );
5470
+ var EpistemicNodeTypeSchema = z.enum([
5471
+ "belief",
5472
+ "evidence",
5473
+ "question",
5474
+ "answer",
5475
+ "topic",
5476
+ "edge",
5477
+ "ontology",
5478
+ "lens",
5479
+ "contradiction"
5480
+ ]);
5481
+ var GraphRefSchema = z.discriminatedUnion("kind", [
5482
+ z.object({
5483
+ kind: z.literal("epistemic_node"),
5484
+ nodeId: z.string(),
5485
+ nodeType: EpistemicNodeTypeSchema
5486
+ }),
5487
+ z.object({
5488
+ kind: z.literal("external_belief"),
5489
+ ref: z.object({
5490
+ tenantId: z.string(),
5491
+ beliefId: z.string()
5492
+ })
5493
+ })
5494
+ ]);
5495
+ var graphRefKind = z.enum(["epistemic_node", "external_belief"]);
5496
+ var EdgePolicyEntrySchema = z.object({
5497
+ edgeType: z.string(),
5498
+ fromKinds: z.array(graphRefKind),
5499
+ fromNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
5500
+ toKinds: z.array(graphRefKind),
5501
+ toNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),
5502
+ description: z.string()
5503
+ });
5504
+ var EdgePolicyManifestSchema = z.object({
5505
+ manifestVersion: z.literal("1.0.0"),
5506
+ policies: z.array(EdgePolicyEntrySchema)
5507
+ });
5508
+ function findEdgePolicy(manifest, edgeType) {
5509
+ return manifest.policies.find((policy) => policy.edgeType === edgeType);
5510
+ }
5511
+ function nodeTypeAllowed(allowed, ref) {
5512
+ return ref.kind !== "epistemic_node" || !allowed || allowed.includes(ref.nodeType);
5513
+ }
5514
+ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
5515
+ const policy = findEdgePolicy(manifest, edgeType);
5516
+ const allowed = Boolean(policy) && policy.fromKinds.includes(from.kind) && policy.toKinds.includes(to.kind) && nodeTypeAllowed(policy.fromNodeTypes, from) && nodeTypeAllowed(policy.toNodeTypes, to);
5517
+ if (!allowed) {
5518
+ const error = new Error(
5519
+ `Edge policy violation for ${edgeType}: ${from.kind} -> ${to.kind}`
5520
+ );
5521
+ error.code = "POLICY_VIOLATION";
5522
+ error.details = { code: "POLICY_VIOLATION", edgeType, from, to };
5523
+ throw error;
5524
+ }
5525
+ }
5526
+
5527
+ // src/manifests/edge-policy-manifest.data.ts
5528
+ var edgePolicyManifest = {
5529
+ manifestVersion: "1.0.0",
5530
+ policies: [
5531
+ {
5532
+ edgeType: "evidence_derived_from_evidence",
5533
+ fromKinds: ["epistemic_node"],
5534
+ fromNodeTypes: ["evidence"],
5535
+ toKinds: ["epistemic_node"],
5536
+ toNodeTypes: ["evidence"],
5537
+ description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
5538
+ },
5539
+ {
5540
+ edgeType: "evidence_supports_belief",
5541
+ fromKinds: ["epistemic_node"],
5542
+ fromNodeTypes: ["evidence"],
5543
+ toKinds: ["epistemic_node"],
5544
+ toNodeTypes: ["belief"],
5545
+ description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
5546
+ },
5547
+ {
5548
+ edgeType: "evidence_supports_question",
5549
+ fromKinds: ["epistemic_node"],
5550
+ fromNodeTypes: ["evidence"],
5551
+ toKinds: ["epistemic_node"],
5552
+ toNodeTypes: ["question"],
5553
+ description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
5554
+ }
5555
+ ]
5556
+ };
5557
+ var InvariantManifestSchema = z.object({
5558
+ manifestVersion: z.literal("1.0.0"),
5559
+ rules: z.array(
5560
+ z.object({
5561
+ invariant: z.string(),
5562
+ description: z.string(),
5563
+ checker: z.enum(["ast", "manifest", "runtime"]),
5564
+ severity: z.enum(["block_publish", "block_pr", "warn"])
5565
+ })
5566
+ )
5567
+ });
5568
+
5569
+ // src/projections/projection-dsl.ts
5570
+ function defineProjection(def) {
5571
+ return def;
5572
+ }
5573
+
5574
+ // src/projections/create-evidence.projection.ts
5575
+ var jsonRecordSchema = z.record(z.unknown());
5576
+ var createEvidenceInputSchemaBase = z.object({
5577
+ projectId: z.string().optional(),
5578
+ topicId: z.string().optional(),
5579
+ text: z.string().optional(),
5580
+ canonicalText: z.string().optional(),
5581
+ title: z.string().optional(),
5582
+ content: z.string().optional(),
5583
+ contentType: z.string().optional(),
5584
+ kind: z.string().optional(),
5585
+ tags: z.array(z.string()).optional(),
5586
+ source: z.string().optional(),
5587
+ sourceUrl: z.string().optional(),
5588
+ sourceType: z.string().optional(),
5589
+ externalSourceType: z.string().optional(),
5590
+ sourceQuestionId: z.string().optional(),
5591
+ methodology: z.string().optional(),
5592
+ informationAsymmetry: z.string().optional(),
5593
+ sourceDescription: z.string().optional(),
5594
+ targetId: z.string().optional(),
5595
+ targetNodeId: z.string().optional(),
5596
+ linkedBeliefNodeId: z.string().optional(),
5597
+ evidenceRelation: z.enum(["supports", "contradicts", "neutral"]).optional(),
5598
+ confidence: z.number().optional(),
5599
+ weight: z.number().optional(),
5600
+ reasoning: z.string().optional(),
5601
+ rationale: z.string(),
5602
+ metadata: jsonRecordSchema.optional(),
5603
+ trustedBypassAccessCheck: z.boolean().optional()
5604
+ }).passthrough();
5605
+ var createEvidenceInputSchema = createEvidenceInputSchemaBase.refine(
5606
+ (input) => Boolean(input.text ?? input.canonicalText),
5607
+ {
5608
+ message: "create_evidence requires text",
5609
+ path: ["text"]
5610
+ }
5611
+ );
5612
+ function compactRecord(input) {
5613
+ return Object.fromEntries(
5614
+ Object.entries(input).filter(([, value]) => value !== void 0)
5615
+ );
5616
+ }
5617
+ function recordValue(value) {
5618
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
5619
+ }
5620
+ var createEvidenceProjection = defineProjection({
5621
+ contractName: "create_evidence",
5622
+ inputSchema: createEvidenceInputSchema,
5623
+ project: (input) => {
5624
+ const text = input.text ?? input.canonicalText;
5625
+ const weight = typeof input.weight === "number" ? input.weight : void 0;
5626
+ return compactRecord({
5627
+ projectId: input.projectId,
5628
+ topicId: input.topicId,
5629
+ text,
5630
+ title: input.title ?? text,
5631
+ content: input.content ?? text,
5632
+ contentType: input.contentType,
5633
+ kind: input.kind,
5634
+ tags: input.tags,
5635
+ sourceType: input.sourceType,
5636
+ externalSourceType: input.externalSourceType,
5637
+ sourceUrl: input.sourceUrl ?? input.source,
5638
+ sourceQuestionId: input.sourceQuestionId,
5639
+ methodology: input.methodology,
5640
+ informationAsymmetry: input.informationAsymmetry,
5641
+ sourceDescription: input.sourceDescription,
5642
+ metadata: compactRecord({
5643
+ ...recordValue(input.metadata),
5644
+ source: input.source,
5645
+ targetId: input.targetId,
5646
+ targetNodeId: input.targetNodeId,
5647
+ weight,
5648
+ reasoning: input.reasoning,
5649
+ rationale: input.rationale
5650
+ }),
5651
+ linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
5652
+ evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
5653
+ confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
5654
+ rationale: input.rationale,
5655
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
5656
+ });
5657
+ },
5658
+ convexArgsValidator: v.object({
5659
+ projectId: v.optional(v.string()),
5660
+ topicId: v.optional(v.string()),
5661
+ text: v.string(),
5662
+ title: v.optional(v.string()),
5663
+ content: v.optional(v.string()),
5664
+ contentType: v.optional(v.string()),
5665
+ kind: v.optional(v.string()),
5666
+ tags: v.optional(v.array(v.string())),
5667
+ sourceType: v.optional(v.string()),
5668
+ externalSourceType: v.optional(v.string()),
5669
+ sourceUrl: v.optional(v.string()),
5670
+ sourceQuestionId: v.optional(v.string()),
5671
+ methodology: v.optional(v.string()),
5672
+ informationAsymmetry: v.optional(v.string()),
5673
+ sourceDescription: v.optional(v.string()),
5674
+ metadata: v.optional(v.record(v.string(), v.any())),
5675
+ linkedBeliefNodeId: v.optional(v.string()),
5676
+ evidenceRelation: v.optional(
5677
+ v.union(
5678
+ v.literal("supports"),
5679
+ v.literal("contradicts"),
5680
+ v.literal("neutral")
5681
+ )
5682
+ ),
5683
+ confidence: v.optional(v.number()),
5684
+ rationale: v.string(),
5685
+ trustedBypassAccessCheck: v.optional(v.boolean())
5686
+ })
5687
+ });
5688
+ var beliefStatusSchema = z.enum(["active", "superseded", "archived", "unscored", "scored"]).optional().describe("Filter by belief lifecycle or scoring status");
5689
+ var listBeliefsInputSchema = z.object({
5690
+ topicId: z.string().describe("Topic scope"),
5691
+ worktreeId: z.string().optional().describe("Filter to worktree scope"),
5692
+ status: beliefStatusSchema,
5693
+ minConfidence: z.number().optional().describe("Minimum confidence threshold"),
5694
+ limit: z.number().optional().describe("Maximum results"),
5695
+ includeEdgeAssociated: z.boolean().optional().describe("Include beliefs associated to the topic through edges")
5696
+ });
5697
+ function kernelStatus(status) {
5698
+ return status === "active" || status === "superseded" || status === "archived" ? status : void 0;
5699
+ }
5700
+ function compactRecord2(input) {
5701
+ return Object.fromEntries(
5702
+ Object.entries(input).filter(([, value]) => value !== void 0)
5703
+ );
5704
+ }
5705
+ var listBeliefsProjection = defineProjection({
5706
+ contractName: "list_beliefs",
5707
+ inputSchema: listBeliefsInputSchema,
5708
+ project: (input) => compactRecord2({
5709
+ topicId: input.topicId,
5710
+ status: kernelStatus(input.status),
5711
+ limit: input.limit,
5712
+ includeEdgeAssociated: input.includeEdgeAssociated
5713
+ }),
5714
+ convexArgsValidator: v.object({
5715
+ topicId: v.string(),
5716
+ status: v.optional(
5717
+ v.union(
5718
+ v.literal("active"),
5719
+ v.literal("superseded"),
5720
+ v.literal("archived")
5721
+ )
5722
+ ),
5723
+ limit: v.optional(v.number()),
5724
+ includeEdgeAssociated: v.optional(v.boolean())
5725
+ })
5726
+ });
5727
+ var taskStatusSchema = z.enum(["todo", "in_progress", "blocked", "done"]).optional().describe("Filter by task status");
5728
+ var listTasksInputSchema = z.object({
5729
+ topicId: z.string().describe("Topic scope"),
5730
+ worktreeId: z.string().optional().describe("Alias for linkedWorktreeId"),
5731
+ linkedWorktreeId: z.string().optional().describe("Filter to tasks linked to this worktree"),
5732
+ status: taskStatusSchema,
5733
+ limit: z.number().optional().describe("Maximum results")
5734
+ });
5735
+ function compactRecord3(input) {
5736
+ return Object.fromEntries(
5737
+ Object.entries(input).filter(([, value]) => value !== void 0)
5738
+ );
5739
+ }
5740
+ var listTasksProjection = defineProjection({
5741
+ contractName: "list_tasks",
5742
+ inputSchema: listTasksInputSchema,
5743
+ project: (input) => compactRecord3({
5744
+ topicId: input.topicId,
5745
+ status: input.status,
5746
+ userId: void 0,
5747
+ limit: input.limit,
5748
+ linkedWorktreeId: input.linkedWorktreeId ?? input.worktreeId
5749
+ }),
5750
+ convexArgsValidator: v.object({
5751
+ topicId: v.string(),
5752
+ status: v.optional(
5753
+ v.union(
5754
+ v.literal("todo"),
5755
+ v.literal("in_progress"),
5756
+ v.literal("blocked"),
5757
+ v.literal("done")
5758
+ )
5759
+ ),
5760
+ limit: v.optional(v.number()),
5761
+ linkedWorktreeId: v.optional(v.string())
5762
+ })
5763
+ });
5764
+ var confidenceTriggerSchema = z.enum([
5765
+ "evidence_added",
5766
+ "evidence_removed",
5767
+ "contradiction_resolved",
5768
+ "agent_assessment",
5769
+ "worktree_outcome",
5770
+ "worktree_completed",
5771
+ "contradiction_detected",
5772
+ "answer_recorded",
5773
+ "fusion",
5774
+ "discount",
5775
+ "deduction",
5776
+ "backfill_synthetic"
5777
+ ]);
5778
+ var provenanceSchema = z.object({
5779
+ evidence: z.string().optional(),
5780
+ question: z.string().optional(),
5781
+ answer: z.string().optional(),
5782
+ contradiction: z.string().optional(),
5783
+ worktree: z.string().optional()
5784
+ });
5785
+ var slOpinionProjectionSchema = z.object({
5786
+ belief: z.number(),
5787
+ disbelief: z.number(),
5788
+ uncertainty: z.number(),
5789
+ baseRate: z.number()
5790
+ });
5791
+ var modulateConfidenceInputObjectSchema = z.object({
5792
+ nodeId: z.string().optional(),
5793
+ beliefNodeId: z.string().optional(),
5794
+ worktreeId: z.string().optional(),
5795
+ opinion: slOpinionProjectionSchema.optional(),
5796
+ belief: z.number().optional(),
5797
+ disbelief: z.number().optional(),
5798
+ uncertainty: z.number().optional(),
5799
+ baseRate: z.number().optional(),
5800
+ trigger: confidenceTriggerSchema,
5801
+ provenance: provenanceSchema.optional(),
5802
+ triggeringEvidenceId: z.string().optional(),
5803
+ triggeringQuestionId: z.string().optional(),
5804
+ triggeringAnswerId: z.string().optional(),
5805
+ triggeringContradictionId: z.string().optional(),
5806
+ triggeringWorktreeId: z.string().optional(),
5807
+ rationale: z.string(),
5808
+ trustedBypassAccessCheck: z.boolean().optional()
5809
+ });
5810
+ var modulateConfidenceInputSchema = modulateConfidenceInputObjectSchema.superRefine((input, ctx) => {
5811
+ if (hasProvenance(input)) {
5812
+ return;
5813
+ }
5814
+ ctx.addIssue({
5815
+ code: z.ZodIssueCode.custom,
5816
+ message: "modulate_confidence requires evidence, question, answer, contradiction, or worktree provenance",
5817
+ path: ["provenance"]
5818
+ });
5819
+ });
5820
+ var modulateConfidenceProjection = defineProjection({
5821
+ contractName: "modulate_confidence",
5822
+ inputSchema: modulateConfidenceInputSchema,
5823
+ project: (input) => {
5824
+ const nodeId = input.beliefNodeId ?? input.nodeId;
5825
+ if (!nodeId) {
5826
+ throw new Error("modulate_confidence requires beliefNodeId or nodeId");
5827
+ }
5828
+ const opinion = input.opinion ?? {
5829
+ belief: requireNumber(input.belief, "belief"),
5830
+ disbelief: requireNumber(input.disbelief, "disbelief"),
5831
+ uncertainty: requireNumber(input.uncertainty, "uncertainty"),
5832
+ baseRate: requireNumber(input.baseRate, "baseRate")
5833
+ };
5834
+ assertProvenance(input);
5835
+ return {
5836
+ nodeId,
5837
+ worktreeId: input.worktreeId,
5838
+ belief: opinion.belief,
5839
+ disbelief: opinion.disbelief,
5840
+ uncertainty: opinion.uncertainty,
5841
+ baseRate: opinion.baseRate,
5842
+ trigger: input.trigger === "answer_recorded" ? "agent_assessment" : input.trigger,
5843
+ triggeringEvidenceId: input.provenance?.evidence ?? input.triggeringEvidenceId,
5844
+ triggeringQuestionId: input.provenance?.question ?? input.triggeringQuestionId,
5845
+ triggeringAnswerId: input.provenance?.answer ?? input.triggeringAnswerId,
5846
+ triggeringContradictionId: input.provenance?.contradiction ?? input.triggeringContradictionId,
5847
+ triggeringWorktreeId: input.provenance?.worktree ?? input.triggeringWorktreeId,
5848
+ rationale: input.rationale,
5849
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
5850
+ };
5851
+ },
5852
+ convexArgsValidator: v.object({
5853
+ nodeId: v.string(),
5854
+ worktreeId: v.optional(v.string()),
5855
+ belief: v.number(),
5856
+ disbelief: v.number(),
5857
+ uncertainty: v.number(),
5858
+ baseRate: v.number(),
5859
+ trigger: v.union(
5860
+ v.literal("evidence_added"),
5861
+ v.literal("evidence_removed"),
5862
+ v.literal("worktree_completed"),
5863
+ v.literal("contradiction_detected"),
5864
+ v.literal("contradiction_resolved"),
5865
+ v.literal("agent_assessment"),
5866
+ v.literal("worktree_outcome"),
5867
+ v.literal("fusion"),
5868
+ v.literal("discount"),
5869
+ v.literal("deduction"),
5870
+ v.literal("backfill_synthetic")
5871
+ ),
5872
+ triggeringEvidenceId: v.optional(v.string()),
5873
+ triggeringQuestionId: v.optional(v.string()),
5874
+ triggeringAnswerId: v.optional(v.string()),
5875
+ triggeringContradictionId: v.optional(v.string()),
5876
+ triggeringWorktreeId: v.optional(v.string()),
5877
+ rationale: v.string(),
5878
+ trustedBypassAccessCheck: v.optional(v.boolean())
5879
+ })
5880
+ });
5881
+ function requireNumber(value, field) {
5882
+ if (value === void 0) {
5883
+ throw new Error(`modulate_confidence requires ${field}`);
5884
+ }
5885
+ return value;
5886
+ }
5887
+ function assertProvenance(input) {
5888
+ if (!hasProvenance(input)) {
5889
+ throw new Error(
5890
+ "modulate_confidence requires evidence, question, answer, contradiction, or worktree provenance"
5891
+ );
5892
+ }
5893
+ }
5894
+ function hasProvenance(input) {
5895
+ return input.trigger === "backfill_synthetic" || Boolean(input.provenance && Object.values(input.provenance).some(Boolean)) || Boolean(input.triggeringEvidenceId) || Boolean(input.triggeringQuestionId) || Boolean(input.triggeringAnswerId) || Boolean(input.triggeringContradictionId) || Boolean(input.triggeringWorktreeId);
5896
+ }
5897
+
5898
+ // src/projections/index.ts
5899
+ var projections = {
5900
+ create_evidence: createEvidenceProjection,
5901
+ list_beliefs: listBeliefsProjection,
5902
+ list_tasks: listTasksProjection,
5903
+ modulate_confidence: modulateConfidenceProjection
5904
+ };
5406
5905
 
5407
5906
  // src/tool-contracts.ts
5408
5907
  var tool_contracts_exports = {};
@@ -5479,6 +5978,7 @@ __export(tool_contracts_exports, {
5479
5978
  LIST_ACTIVE_SESSIONS: () => LIST_ACTIVE_SESSIONS,
5480
5979
  LIST_ALL_WORKTREES: () => LIST_ALL_WORKTREES,
5481
5980
  LIST_BELIEFS: () => LIST_BELIEFS,
5981
+ LIST_CAMPAIGNS: () => LIST_CAMPAIGNS,
5482
5982
  LIST_EVIDENCE: () => LIST_EVIDENCE,
5483
5983
  LIST_LENSES: () => LIST_LENSES,
5484
5984
  LIST_ONTOLOGIES: () => LIST_ONTOLOGIES,
@@ -5532,7 +6032,7 @@ var LENS_PERSPECTIVE_TYPES = [
5532
6032
  // src/tool-contracts.ts
5533
6033
  var CREATE_BELIEF = {
5534
6034
  name: "create_belief",
5535
- description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a mandatory prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
6035
+ description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
5536
6036
  parameters: {
5537
6037
  canonicalText: {
5538
6038
  type: "string",
@@ -5544,7 +6044,7 @@ var CREATE_BELIEF = {
5544
6044
  },
5545
6045
  baseRate: {
5546
6046
  type: "number",
5547
- description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
6047
+ description: "Prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time. Defaults to 0.5 when omitted."
5548
6048
  },
5549
6049
  beliefType: {
5550
6050
  type: "string",
@@ -5555,7 +6055,7 @@ var CREATE_BELIEF = {
5555
6055
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
5556
6056
  }
5557
6057
  },
5558
- required: ["canonicalText", "baseRate"],
6058
+ required: ["canonicalText"],
5559
6059
  response: {
5560
6060
  description: "The created canonical belief record",
5561
6061
  fields: {
@@ -5618,7 +6118,7 @@ var REFINE_BELIEF = {
5618
6118
  };
5619
6119
  var MODULATE_CONFIDENCE = {
5620
6120
  name: "modulate_confidence",
5621
- description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction, manual, decay.",
6121
+ description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Every modulation must cite a truth-bearing artifact: triggeringEvidenceId, triggeringQuestionId, triggeringAnswerId, triggeringContradictionId, or triggeringWorktreeId. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction.",
5622
6122
  parameters: {
5623
6123
  nodeId: { type: "string", description: "The belief to score" },
5624
6124
  belief: {
@@ -5637,9 +6137,9 @@ var MODULATE_CONFIDENCE = {
5637
6137
  type: "number",
5638
6138
  description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
5639
6139
  },
5640
- confidence: {
5641
- type: "number",
5642
- description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
6140
+ worktreeId: {
6141
+ type: "string",
6142
+ description: "Completed worktree that tested this belief when confidence policy requires merge-backed scoring."
5643
6143
  },
5644
6144
  trigger: {
5645
6145
  type: "string",
@@ -5654,17 +6154,43 @@ var MODULATE_CONFIDENCE = {
5654
6154
  "worktree_completed",
5655
6155
  "fusion",
5656
6156
  "discount",
5657
- "deduction",
5658
- "manual",
5659
- "decay"
6157
+ "deduction"
5660
6158
  ]
5661
6159
  },
6160
+ triggeringEvidenceId: {
6161
+ type: "string",
6162
+ description: "Evidence node that caused an evidence-triggered modulation"
6163
+ },
6164
+ triggeringQuestionId: {
6165
+ type: "string",
6166
+ description: "Answered question whose resolution supports this modulation"
6167
+ },
6168
+ triggeringAnswerId: {
6169
+ type: "string",
6170
+ description: "Answer node whose content supports this modulation"
6171
+ },
6172
+ triggeringContradictionId: {
6173
+ type: "string",
6174
+ description: "Contradiction record that caused a contradiction-triggered modulation"
6175
+ },
6176
+ triggeringWorktreeId: {
6177
+ type: "string",
6178
+ description: "Completed worktree whose outcome caused a worktree-triggered modulation"
6179
+ },
5662
6180
  rationale: {
5663
6181
  type: "string",
5664
6182
  description: "Human-readable explanation of why confidence changed"
5665
6183
  }
5666
6184
  },
5667
- required: ["nodeId", "trigger", "rationale"],
6185
+ required: [
6186
+ "nodeId",
6187
+ "belief",
6188
+ "disbelief",
6189
+ "uncertainty",
6190
+ "baseRate",
6191
+ "trigger",
6192
+ "rationale"
6193
+ ],
5668
6194
  response: {
5669
6195
  description: "Confidence modulation result",
5670
6196
  fields: {
@@ -5858,7 +6384,7 @@ var ADD_EVIDENCE = {
5858
6384
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'], failedApproach: true } for coding intelligence)"
5859
6385
  }
5860
6386
  },
5861
- required: ["canonicalText", "targetNodeId"],
6387
+ required: ["canonicalText", "targetNodeId", "reasoning"],
5862
6388
  response: {
5863
6389
  description: "The created evidence node and its edge",
5864
6390
  fields: {
@@ -5939,9 +6465,21 @@ var ADD_WORKTREE = {
5939
6465
  type: "string",
5940
6466
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
5941
6467
  },
5942
- executionOrder: {
6468
+ campaign: {
5943
6469
  type: "number",
5944
- description: "Global execution order for this worktree"
6470
+ description: "Top-level pipeline campaign number. Campaigns define the outer execution slice."
6471
+ },
6472
+ lane: {
6473
+ type: "string",
6474
+ description: "GitButler-aligned workstream lane name inside the campaign."
6475
+ },
6476
+ laneOrderInCampaign: {
6477
+ type: "number",
6478
+ description: "Ordering for this lane within its campaign."
6479
+ },
6480
+ orderInLane: {
6481
+ type: "number",
6482
+ description: "Position of this worktree inside its lane."
5945
6483
  },
5946
6484
  dependsOn: {
5947
6485
  type: "array",
@@ -6599,6 +7137,10 @@ var CREATE_EVIDENCE = {
6599
7137
  type: "object",
6600
7138
  description: "Optional metadata merged into the canonical evidence node"
6601
7139
  },
7140
+ rationale: {
7141
+ type: "string",
7142
+ description: "Why this evidence should enter the reasoning graph"
7143
+ },
6602
7144
  title: { type: "string", description: "Optional short title" },
6603
7145
  content: { type: "string", description: "Optional long-form content" },
6604
7146
  contentType: {
@@ -6607,7 +7149,7 @@ var CREATE_EVIDENCE = {
6607
7149
  },
6608
7150
  kind: { type: "string", description: "Optional evidence kind" }
6609
7151
  },
6610
- required: ["text"],
7152
+ required: ["text", "rationale"],
6611
7153
  response: {
6612
7154
  description: "The created canonical evidence record",
6613
7155
  fields: {
@@ -6655,7 +7197,7 @@ var LIST_EVIDENCE = {
6655
7197
  limit: { type: "number", description: "Max results" },
6656
7198
  cursor: { type: "string", description: "Pagination cursor" }
6657
7199
  },
6658
- required: [],
7200
+ required: ["topicId"],
6659
7201
  response: {
6660
7202
  description: "Canonical evidence page",
6661
7203
  fields: {
@@ -6840,6 +7382,7 @@ var ANSWER_QUESTION = {
6840
7382
  description: "Answer a question with optional evidence links. Like `git commit` on the question thread \u2014 records the answer and closes the loop with a canonical answered state.",
6841
7383
  parameters: {
6842
7384
  id: { type: "string", description: "Canonical question ID" },
7385
+ topicId: { type: "string", description: "Topic scope for the answer" },
6843
7386
  text: { type: "string", description: "Answer text" },
6844
7387
  confidence: {
6845
7388
  type: "string",
@@ -6852,7 +7395,7 @@ var ANSWER_QUESTION = {
6852
7395
  },
6853
7396
  rationale: { type: "string", description: "Why this answer is credible" }
6854
7397
  },
6855
- required: ["id", "text"],
7398
+ required: ["id", "topicId", "text"],
6856
7399
  response: {
6857
7400
  description: "Answer result",
6858
7401
  fields: {
@@ -7071,6 +7614,10 @@ var LIST_BELIEFS = {
7071
7614
  minConfidence: {
7072
7615
  type: "number",
7073
7616
  description: "Minimum confidence threshold"
7617
+ },
7618
+ limit: {
7619
+ type: "number",
7620
+ description: "Maximum results"
7074
7621
  }
7075
7622
  },
7076
7623
  required: ["topicId"],
@@ -7087,20 +7634,37 @@ var LIST_BELIEFS = {
7087
7634
  };
7088
7635
  var LIST_WORKTREES = {
7089
7636
  name: "list_worktrees",
7090
- description: "List all worktrees for a topic. Like `git worktree list` \u2014 shows active and completed investigation branches with their phase, status, and belief counts.",
7637
+ description: "List all worktrees for a topic. Like `git worktree list` \u2014 shows active and completed investigation branches with lifecycle phase, pipeline campaign/lane, status, and belief counts.",
7091
7638
  parameters: {
7092
7639
  topicId: { type: "string", description: "Topic scope" },
7093
7640
  status: {
7094
7641
  type: "string",
7095
7642
  description: "Filter: active, merged, abandoned",
7096
7643
  enum: ["active", "merged", "abandoned"]
7644
+ },
7645
+ groupBy: {
7646
+ type: "string",
7647
+ description: "Optional grouping mode for the response.",
7648
+ enum: ["campaign", "lane", "flat"]
7649
+ },
7650
+ lane: {
7651
+ type: "string",
7652
+ description: "Filter by GitButler-aligned lane name."
7653
+ },
7654
+ campaign: {
7655
+ type: "number",
7656
+ description: "Filter by top-level pipeline campaign number."
7657
+ },
7658
+ limit: {
7659
+ type: "number",
7660
+ description: "Maximum results to return."
7097
7661
  }
7098
7662
  },
7099
7663
  required: ["topicId"],
7100
7664
  response: {
7101
- description: "Worktrees with phase, status, belief count, and creation time",
7665
+ description: "Worktrees with lifecycle phase, campaign, lane, status, belief count, and creation time",
7102
7666
  fields: {
7103
- worktrees: "array \u2014 { worktreeId, title, phase, status, beliefCount, createdAt }"
7667
+ worktrees: "array \u2014 { worktreeId, title, phase, campaign, lane, laneOrderInCampaign, orderInLane, status, beliefCount, createdAt }"
7104
7668
  }
7105
7669
  },
7106
7670
  ownerModule: "workflow-engine",
@@ -7109,7 +7673,7 @@ var LIST_WORKTREES = {
7109
7673
  };
7110
7674
  var LIST_ALL_WORKTREES = {
7111
7675
  name: "list_all_worktrees",
7112
- description: "List ALL worktrees across ALL topics in one query. No topic scope required. Like `git worktree list --all` \u2014 returns the complete pipeline inventory with track, trackPosition, executionBand, dependencies, and status. Supports filtering by status, track, and executionBand. This is the PM's primary pipeline query \u2014 one call, full picture.",
7676
+ description: "List ALL worktrees across ALL topics in one query. No topic scope required. Like `git worktree list --all` \u2014 returns the complete pipeline inventory with campaign, lane, lane order, dependencies, and status. Supports filtering by status, lane, and campaign. This is the PM's primary pipeline query \u2014 one call, full picture.",
7113
7677
  parameters: {
7114
7678
  status: {
7115
7679
  type: "string",
@@ -7127,13 +7691,18 @@ var LIST_ALL_WORKTREES = {
7127
7691
  "dismissed"
7128
7692
  ]
7129
7693
  },
7130
- track: {
7694
+ lane: {
7131
7695
  type: "string",
7132
- description: "Filter by track name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
7696
+ description: "Filter by lane name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity')"
7133
7697
  },
7134
- executionBand: {
7698
+ campaign: {
7135
7699
  type: "number",
7136
- description: "Filter by execution band number (e.g., 1, 2, 3). Returns only worktrees in that parallel execution group."
7700
+ description: "Filter by campaign number (e.g., 1, 2, 3). Returns only worktrees in that campaign."
7701
+ },
7702
+ groupBy: {
7703
+ type: "string",
7704
+ description: "Optional grouping mode for the response.",
7705
+ enum: ["campaign", "lane", "flat"]
7137
7706
  },
7138
7707
  limit: {
7139
7708
  type: "number",
@@ -7144,10 +7713,39 @@ var LIST_ALL_WORKTREES = {
7144
7713
  response: {
7145
7714
  description: "All worktrees across all topics with full pipeline metadata",
7146
7715
  fields: {
7147
- worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, track, trackPosition, executionBand, executionOrder, dependsOn, blocks, gate, createdAt }",
7716
+ worktrees: "array \u2014 { worktreeId, title, topicId, topicName, phase, status, hypothesis, campaign, lane, laneOrderInCampaign, orderInLane, dependsOn, blocks, gate, createdAt }",
7148
7717
  total: "number \u2014 total count after filtering",
7149
- tracks: "object \u2014 { trackName: count } summary of worktrees per track",
7150
- bands: "object \u2014 { bandNumber: count } summary of worktrees per execution band"
7718
+ lanes: "object \u2014 { laneName: count } summary of worktrees per lane",
7719
+ campaigns: "object \u2014 { campaignNumber: count } summary of worktrees per campaign"
7720
+ }
7721
+ },
7722
+ ownerModule: "workflow-engine",
7723
+ ontologyPrimitive: "worktree",
7724
+ tier: "showcase"
7725
+ };
7726
+ var LIST_CAMPAIGNS = {
7727
+ name: "list_campaigns",
7728
+ 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.",
7729
+ parameters: {
7730
+ topicId: {
7731
+ type: "string",
7732
+ description: "Optional topic scope."
7733
+ },
7734
+ status: {
7735
+ type: "string",
7736
+ description: "Optional worktree status filter before grouping campaigns and lanes."
7737
+ },
7738
+ limit: {
7739
+ type: "number",
7740
+ description: "Maximum worktrees to scan before grouping."
7741
+ }
7742
+ },
7743
+ required: [],
7744
+ response: {
7745
+ description: "Pipeline campaigns with nested lane summaries.",
7746
+ fields: {
7747
+ campaigns: "array \u2014 { campaign, lanes: [{ lane, laneOrderInCampaign, worktreeCount, activeCount, readyCount, blockedCount, completedCount, nextWorktree }] }",
7748
+ totalWorktrees: "number \u2014 total worktrees scanned after filtering"
7151
7749
  }
7152
7750
  },
7153
7751
  ownerModule: "workflow-engine",
@@ -7210,16 +7808,28 @@ var UPDATE_WORKTREE_TARGETS = {
7210
7808
  };
7211
7809
  var UPDATE_WORKTREE_METADATA = {
7212
7810
  name: "update_worktree_metadata",
7213
- description: "Update worktree sequencing metadata \u2014 execution order, dependencies, blocking relations, and gates. Like `git config` for a worktree \u2014 sets the scheduling and dependency metadata that determines when this worktree can activate relative to others. Use to backfill or correct sequencing data.",
7811
+ description: "Update worktree sequencing metadata \u2014 campaign, lane, dependencies, blocking relations, and gates. Like `git config` for a worktree \u2014 sets the scheduling and dependency metadata that determines when this worktree can activate relative to others. Use to backfill or correct sequencing data.",
7214
7812
  parameters: {
7215
7813
  worktreeId: { type: "string", description: "The worktree to update" },
7216
7814
  hypothesis: {
7217
7815
  type: "string",
7218
7816
  description: "Testable claim this worktree investigates"
7219
7817
  },
7220
- executionOrder: {
7818
+ campaign: {
7819
+ type: "number",
7820
+ description: "Top-level pipeline campaign number."
7821
+ },
7822
+ lane: {
7823
+ type: "string",
7824
+ description: "GitButler-aligned workstream lane name inside the campaign."
7825
+ },
7826
+ laneOrderInCampaign: {
7221
7827
  type: "number",
7222
- description: "Global execution order (1 = first, higher = later)"
7828
+ description: "Ordering for this lane within the campaign."
7829
+ },
7830
+ orderInLane: {
7831
+ type: "number",
7832
+ description: "Position of this worktree inside its lane."
7223
7833
  },
7224
7834
  dependsOn: {
7225
7835
  type: "array",
@@ -7257,18 +7867,6 @@ var UPDATE_WORKTREE_METADATA = {
7257
7867
  type: "object",
7258
7868
  description: "Calibrated auto-fix policy controlling dry-run vs safe execution, per-run action caps, and permitted mutation tiers."
7259
7869
  },
7260
- track: {
7261
- type: "string",
7262
- description: "Parallel workstream name (e.g., 'ontology', 'tc-scope', 'control-plane', 'dev-portal', 'mcp-sdk-parity', 'execution-program'). Groups worktrees into named lanes for pipeline visualization and PM analysis."
7263
- },
7264
- trackPosition: {
7265
- type: "number",
7266
- description: "Position within the track (1-indexed). E.g., TC-A=1, TC-B=2, TC-C=3 within the 'tc-scope' track."
7267
- },
7268
- executionBand: {
7269
- type: "number",
7270
- description: "Parallel execution band number. All worktrees in the same band can run simultaneously. Band 2 = OE-B + TC-A, Band 3 = TC-B + 11D-R + S2-13A, etc."
7271
- },
7272
7870
  status: {
7273
7871
  type: "string",
7274
7872
  description: "Override the worktree status. Use for lifecycle transitions like marking a worktree superseded, long-term, or as a raw idea.",
@@ -7638,6 +8236,10 @@ var LIST_TASKS = {
7638
8236
  type: "string",
7639
8237
  description: "Filter to tasks linked to this worktree"
7640
8238
  },
8239
+ worktreeId: {
8240
+ type: "string",
8241
+ description: "Alias for linkedWorktreeId"
8242
+ },
7641
8243
  status: {
7642
8244
  type: "string",
7643
8245
  description: "Filter by status: todo, in_progress, blocked, done",
@@ -7725,7 +8327,7 @@ var GET_TOPIC = {
7725
8327
  description: "Legacy alias for topicId"
7726
8328
  }
7727
8329
  },
7728
- required: [],
8330
+ required: ["topicId"],
7729
8331
  response: {
7730
8332
  description: "Single topic record",
7731
8333
  fields: {
@@ -8080,7 +8682,7 @@ var GET_ONTOLOGY = {
8080
8682
  description: "Tenant scope for key lookup. Omit for platform-level."
8081
8683
  }
8082
8684
  },
8083
- required: [],
8685
+ required: ["id"],
8084
8686
  response: {
8085
8687
  description: "Ontology definition with latest published version",
8086
8688
  fields: {
@@ -8147,7 +8749,7 @@ var MATCH_ENTITY_TYPE = {
8147
8749
  description: "Optional maximum number of ranked matches to return"
8148
8750
  }
8149
8751
  },
8150
- required: ["text"],
8752
+ required: ["text", "ontologyId"],
8151
8753
  response: {
8152
8754
  description: "Ranked ontology entity type matches",
8153
8755
  fields: {
@@ -8401,7 +9003,7 @@ var RECORD_SCOPE_LEARNING = {
8401
9003
  };
8402
9004
  var PIPELINE_SNAPSHOT = {
8403
9005
  name: "pipeline_snapshot",
8404
- description: "Summarize a topic's worktree pipeline in band-and-lane form. Like `git status --short` for Lucern execution \u2014 returns the hinge worktree, next planned wave, blockers, critical path, superseded work, and graph hygiene debt.",
9006
+ description: "Summarize a topic's worktree pipeline in campaign-and-lane form. Like `git status --short` for Lucern execution \u2014 returns the hinge worktree, next planned wave, blockers, critical path, superseded work, and graph hygiene debt.",
8405
9007
  parameters: {
8406
9008
  topicId: { type: "string", description: "Topic scope ID" }
8407
9009
  },
@@ -8411,14 +9013,14 @@ var PIPELINE_SNAPSHOT = {
8411
9013
  fields: {
8412
9014
  topicId: "string",
8413
9015
  topicName: "string",
8414
- currentBand: "number | null",
8415
- nextBand: "number | null",
9016
+ currentCampaign: "number | null",
9017
+ nextCampaign: "number | null",
8416
9018
  activeWorktrees: "array \u2014 current hinge worktree(s)",
8417
- nextWave: "array \u2014 worktrees in the next planned band",
9019
+ nextWave: "array \u2014 worktrees in the next planned campaign",
8418
9020
  readyNow: "array \u2014 planning worktrees with dependencies completed",
8419
9021
  blockedBy: "array \u2014 grouped blockers",
8420
9022
  criticalPath: "array \u2014 ordered incomplete worktree chain",
8421
- bands: "array \u2014 incomplete worktrees grouped by executionBand",
9023
+ campaigns: "array \u2014 incomplete worktrees grouped by campaign",
8422
9024
  superseded: "array \u2014 worktrees marked superseded or not for activation",
8423
9025
  graphHygiene: "object \u2014 untargeted and taskless worktree debt",
8424
9026
  riskQuestions: "array \u2014 critical/high open questions",
@@ -9007,6 +9609,7 @@ var MCP_TOOL_CONTRACTS = {
9007
9609
  list_beliefs: LIST_BELIEFS,
9008
9610
  list_worktrees: LIST_WORKTREES,
9009
9611
  list_all_worktrees: LIST_ALL_WORKTREES,
9612
+ list_campaigns: LIST_CAMPAIGNS,
9010
9613
  activate_worktree: ACTIVATE_WORKTREE,
9011
9614
  update_worktree_targets: UPDATE_WORKTREE_TARGETS,
9012
9615
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
@@ -10884,7 +11487,7 @@ var CANONICAL_WORKFLOW_DEFINITIONS = [
10884
11487
  actionId: "run_integrity_checks",
10885
11488
  kind: "integrity_check",
10886
11489
  title: "Run integrity checks",
10887
- description: "Evaluate dependency references, blockers, execution bands, shaping coverage, and completed gates.",
11490
+ description: "Evaluate dependency references, blockers, campaign/lane placement, shaping coverage, and completed gates.",
10888
11491
  mutationTier: "read_only",
10889
11492
  produces: ["structured_payload"],
10890
11493
  idempotent: true,
@@ -10990,6 +11593,6 @@ var CANONICAL_WORKFLOW_DEFINITIONS = [
10990
11593
  }
10991
11594
  ];
10992
11595
 
10993
- export { BELIEF_STATUSES, BELIEF_TYPE_BONUS, BRANCH_STATUSES, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTEXT_PACK_SCHEMA_VERSION, CONTEXT_PACK_SECTION_KEYS, CONTEXT_RANKING_PROFILES, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_RANKING_PROFILE, DEFAULT_SECTION_LIMIT, DEFAULT_SEVERITY_SCORE, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_TOKEN_BUDGET, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, ENTITY_RANKING_WEIGHTS, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, FORK_REASONS, INTEGRATION_EDGE_TYPES, JUDGMENT_TYPES, MAX_ENTITY_LIMIT, MAX_SECTION_LIMIT, MAX_TOKEN_BUDGET, MERGE_OUTCOMES, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, PRIORITY_SCORES, PULL_REQUEST_STATUSES, RANKING_WEIGHTS, REASONING_METHODS, RECENCY_HALF_LIFE_DAYS, RESOLVED_QUESTION_STATUSES, ROOT_TOPIC_ID, SECTION_BUDGET_RATIOS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SEVERITY_SCORES, TOKENS_PER_WORD, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, bigramTokenize, buildDomainEvent, collectTopicNeighborhood, compareEventCursor, dsl_exports as contractDsl, createEventId, decodeEventCursor, decodePrefixedId, emitDomainEvent, encodeEventCursor, encodePrefixedId, hasPrefixedIdPrefix, inferActorType, inferSessionPrincipalType, isAfterCursor, isLucernPrompt, jaccardSimilarity, lastDelegator, tool_contracts_exports as mcpToolsContract, normalizeDelegationChain, normalizeRetentionDays, prepareLexicalQuery, rankEntityConnections, rankEntityTypeMatches, rankWindowScore, requireActorPrincipalId, rerankLexicalWindow, schemas_exports as schemaContracts, scoreEntityConnection, scoreEntityTypeMatch, scoreLexicalSignal, scoreLexicalSignals, sdk_tools_contract_exports as sdkToolsContract, sortEventsByCursor, stemToken, tokenOverlapScore, tokenizeSearchText, wordOverlapScore, wordTokenize };
11596
+ export { BELIEF_STATUSES, BELIEF_TYPE_BONUS, BRANCH_STATUSES, CANONICAL_WORKFLOW_DEFINITIONS, CONFIDENCE_TRIGGERS, CONTEXT_PACK_SCHEMA_VERSION, CONTEXT_PACK_SECTION_KEYS, CONTEXT_RANKING_PROFILES, CONTRADICTION_SEVERITIES, CONTRADICTION_STATUSES, ComponentTableManifestSchema, DEFAULT_BELIEF_TYPE_BONUS, DEFAULT_COMPILATION_MODE, DEFAULT_ENTITY_LIMIT, DEFAULT_PRIORITY_SCORE, DEFAULT_RANKING_PROFILE, DEFAULT_SECTION_LIMIT, DEFAULT_SEVERITY_SCORE, DEFAULT_TIER_APPROVAL_MODE, DEFAULT_TOKEN_BUDGET, DEFAULT_WORKFLOW_AUTO_FIX_POLICY, DEFEAT_TYPES, DOMAIN_EVENT_TYPES, DOMAIN_EVENT_VERSION, ENTITY_RANKING_WEIGHTS, EPISTEMIC_LAYERS, EVENT_RETENTION_DEFAULT_DAYS, EdgePolicyEntrySchema, EdgePolicyManifestSchema, EpistemicNodeTypeSchema, FORK_REASONS, GraphRefSchema, INTEGRATION_EDGE_TYPES, InvariantManifestSchema, JUDGMENT_TYPES, MAX_ENTITY_LIMIT, MAX_SECTION_LIMIT, MAX_TOKEN_BUDGET, MERGE_OUTCOMES, MIN_CONTRADICTION_BUDGET, MIN_TOKEN_BUDGET, MIN_TOKEN_ESTIMATE, MORNING_BRIEF_WORKFLOW_ID, NIGHTLY_RECONCILIATION_WORKFLOW_ID, PRIORITY_SCORES, PULL_REQUEST_STATUSES, RANKING_WEIGHTS, REASONING_METHODS, RECENCY_HALF_LIFE_DAYS, RESOLVED_QUESTION_STATUSES, ROOT_TOPIC_ID, SECTION_BUDGET_RATIOS, SESSION_AUTH_MODES, SESSION_LIFECYCLE_STATUSES, SESSION_PRINCIPAL_TYPES, SEVERITY_SCORES, SLOpinionInputSchema, TOKENS_PER_WORD, WEBHOOK_MAX_ATTEMPTS, WEBHOOK_RETRY_DELAYS_MS, WORKFLOW_ACTION_KINDS, WORKFLOW_APPROVAL_MODES, WORKFLOW_AUTO_FIX_MODES, WORKFLOW_HOOK_EVENTS, WORKFLOW_INTEGRITY_CHECKS, WORKFLOW_MUTATION_TIERS, WORKFLOW_OUTPUT_KINDS, WORKFLOW_PROOF_ARTIFACT_KINDS, WORKFLOW_RUNTIME_SCHEMA_VERSION, WORKFLOW_RUN_STATUSES, WORKFLOW_STAFFING_HINTS, WORKFLOW_TRIGGER_KINDS, WORKTREE_PHASES, assertEdgePolicyAllowed, bigramTokenize, buildDomainEvent, collectTopicNeighborhood, compareEventCursor, dsl_exports as contractDsl, createEventId, createEvidenceProjection, decodeEventCursor, decodePrefixedId, defineProjection, edgePolicyManifest, emitDomainEvent, encodeEventCursor, encodePrefixedId, findEdgePolicy, hasPrefixedIdPrefix, inferActorType, inferSessionPrincipalType, isAfterCursor, isLucernPrompt, jaccardSimilarity, lastDelegator, listBeliefsProjection, listTasksProjection, tool_contracts_exports as mcpToolsContract, modulateConfidenceProjection, normalizeDelegationChain, normalizeRetentionDays, prepareLexicalQuery, projections, rankEntityConnections, rankEntityTypeMatches, rankWindowScore, requireActorPrincipalId, rerankLexicalWindow, schemas_exports as schemaContracts, scoreEntityConnection, scoreEntityTypeMatch, scoreLexicalSignal, scoreLexicalSignals, sdk_tools_contract_exports as sdkToolsContract, sortEventsByCursor, stemToken, tokenOverlapScore, tokenizeSearchText, wordOverlapScore, wordTokenize };
10994
11597
  //# sourceMappingURL=index.js.map
10995
11598
  //# sourceMappingURL=index.js.map