@lucern/events 0.3.0-alpha.3 → 0.3.0-alpha.4

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.
package/dist/webhooks.js CHANGED
@@ -3839,7 +3839,9 @@ defineTable({
3839
3839
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3840
3840
  "deployments": z.record(z.object({
3841
3841
  "url": z.string(),
3842
- "encryptedDeployKey": z.string()
3842
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
3843
+ "encryptedDeployKey": z.string().optional(),
3844
+ "credentialRef": z.string().optional()
3843
3845
  })).optional(),
3844
3846
  "metadata": z.record(z.any()).optional(),
3845
3847
  "createdBy": z.string().optional(),
@@ -5036,6 +5038,14 @@ var ADD_WORKTREE = {
5036
5038
  description: "Check out a branch into an active worktree for investigation. Like `git worktree add <branch>` \u2014 creates independent working state on a thematic branch. Beliefs committed within the worktree can be freely amended (draft code on a feature branch). When investigation is complete, `merge` integrates findings into main.",
5037
5039
  parameters: {
5038
5040
  title: { type: "string", description: "Worktree name/objective" },
5041
+ name: {
5042
+ type: "string",
5043
+ description: "Optional storage-name alias for callers that already use backend naming"
5044
+ },
5045
+ projectId: {
5046
+ type: "string",
5047
+ description: "Legacy topicId alias"
5048
+ },
5039
5049
  topicId: { type: "string", description: "Optional topic scope hint" },
5040
5050
  branchId: {
5041
5051
  type: "string",
@@ -5049,14 +5059,87 @@ var ADD_WORKTREE = {
5049
5059
  type: "string",
5050
5060
  description: "The testable claim this worktree investigates"
5051
5061
  },
5062
+ rationale: {
5063
+ type: "string",
5064
+ description: "Why this worktree exists and why it belongs in the campaign"
5065
+ },
5066
+ worktreeType: {
5067
+ type: "string",
5068
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5069
+ },
5070
+ gate: {
5071
+ type: "string",
5072
+ description: "Exit gate name for this worktree"
5073
+ },
5074
+ startDate: {
5075
+ type: "number",
5076
+ description: "Planned start timestamp in milliseconds since epoch"
5077
+ },
5078
+ endDate: {
5079
+ type: "number",
5080
+ description: "Planned end timestamp in milliseconds since epoch"
5081
+ },
5082
+ durationWeeks: {
5083
+ type: "number",
5084
+ description: "Planned duration in weeks"
5085
+ },
5086
+ confidenceImpact: {
5087
+ type: "string",
5088
+ description: "Expected confidence impact if the worktree succeeds",
5089
+ enum: ["high", "medium", "low"]
5090
+ },
5091
+ beliefFocus: {
5092
+ type: "string",
5093
+ description: "Natural-language focus spanning the target belief neighborhood"
5094
+ },
5052
5095
  beliefIds: {
5053
5096
  type: "array",
5054
- description: "Beliefs to test in this worktree"
5097
+ description: "Legacy alias for targetBeliefIds"
5098
+ },
5099
+ beliefs: {
5100
+ type: "array",
5101
+ description: "Legacy alias for targetBeliefIds"
5102
+ },
5103
+ targetBeliefIds: {
5104
+ type: "array",
5105
+ description: "Belief node IDs this worktree is expected to test or update"
5106
+ },
5107
+ targetQuestionIds: {
5108
+ type: "array",
5109
+ description: "Question node IDs this worktree is expected to answer"
5110
+ },
5111
+ keyQuestions: {
5112
+ type: "array",
5113
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5114
+ },
5115
+ evidenceSignals: {
5116
+ type: "array",
5117
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5118
+ },
5119
+ decisionGate: {
5120
+ type: "object",
5121
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5122
+ },
5123
+ goCriteria: {
5124
+ type: "array",
5125
+ description: "Shorthand go criteria used to build decisionGate"
5126
+ },
5127
+ noGoSignals: {
5128
+ type: "array",
5129
+ description: "Shorthand no-go signals used to build decisionGate"
5130
+ },
5131
+ proofArtifacts: {
5132
+ type: "array",
5133
+ description: "Expected proof artifacts required to close the worktree"
5055
5134
  },
5056
5135
  autoShape: {
5057
5136
  type: "boolean",
5058
5137
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5059
5138
  },
5139
+ autoFixPolicy: {
5140
+ type: "object",
5141
+ description: "Policy for permitted automatic remediation inside the worktree"
5142
+ },
5060
5143
  domainPackId: {
5061
5144
  type: "string",
5062
5145
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
@@ -5085,9 +5168,17 @@ var ADD_WORKTREE = {
5085
5168
  type: "array",
5086
5169
  description: "Worktree IDs blocked by this worktree"
5087
5170
  },
5088
- gate: {
5171
+ staffingHint: {
5089
5172
  type: "string",
5090
- description: "Exit gate name for this worktree"
5173
+ description: "Suggested staffing or agent allocation note"
5174
+ },
5175
+ lensId: {
5176
+ type: "string",
5177
+ description: "Lens that scopes this worktree when applicable"
5178
+ },
5179
+ lastReconciledAt: {
5180
+ type: "number",
5181
+ description: "Timestamp when worktree metadata was last reconciled"
5091
5182
  }
5092
5183
  },
5093
5184
  required: ["title", "topicId"],
@@ -5117,7 +5208,7 @@ var MERGE = {
5117
5208
  worktreeId: { type: "string", description: "The worktree to merge" },
5118
5209
  outcomes: {
5119
5210
  type: "array",
5120
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5211
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5121
5212
  },
5122
5213
  summary: { type: "string", description: "Overall findings summary" }
5123
5214
  },
@@ -8136,6 +8227,69 @@ var GENERATE_SESSION_HANDOFF = {
8136
8227
  tier: "showcase",
8137
8228
  internal: true
8138
8229
  };
8230
+ var BEGIN_BUILD_SESSION = {
8231
+ name: "begin_build_session",
8232
+ description: "Bootstrap a coding build session for a Lucern worktree. Like `git worktree add` plus `git status` \u2014 returns the compact context packet an agent needs before editing.",
8233
+ parameters: {
8234
+ worktreeId: {
8235
+ type: "string",
8236
+ description: "The Lucern worktree ID to bootstrap."
8237
+ },
8238
+ branch: {
8239
+ type: "string",
8240
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
8241
+ },
8242
+ branchBase: {
8243
+ type: "string",
8244
+ description: 'Base branch for the feature branch. Default: "staging".'
8245
+ },
8246
+ prBase: {
8247
+ type: "string",
8248
+ description: 'Target branch for the PR. Default: "staging".'
8249
+ },
8250
+ sessionMode: {
8251
+ type: "string",
8252
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
8253
+ enum: ["async", "interactive"]
8254
+ },
8255
+ activateIfPlanning: {
8256
+ type: "boolean",
8257
+ description: "When true, automatically activate a planning worktree during bootstrap."
8258
+ }
8259
+ },
8260
+ required: ["worktreeId"],
8261
+ response: {
8262
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
8263
+ fields: {
8264
+ topicId: "string \u2014 canonical topic scope",
8265
+ topicName: "string \u2014 human-readable topic name",
8266
+ worktreeId: "string \u2014 worktree ID",
8267
+ worktreeName: "string \u2014 human-readable worktree name",
8268
+ branch: "string \u2014 git branch name",
8269
+ branchBase: "string \u2014 base branch",
8270
+ prBase: "string \u2014 PR target branch",
8271
+ campaign: "number | null \u2014 top-level pipeline campaign",
8272
+ lane: "string \u2014 campaign lane",
8273
+ gate: "string \u2014 exit gate",
8274
+ hypothesis: "string \u2014 worktree hypothesis",
8275
+ focus: "string \u2014 session focus",
8276
+ status: "string \u2014 worktree status after optional activation",
8277
+ sessionMode: "string \u2014 async | interactive",
8278
+ targetBeliefIds: "array \u2014 scoped belief IDs",
8279
+ targetQuestionIds: "array \u2014 scoped question IDs",
8280
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
8281
+ openQuestions: "array \u2014 open scoped questions",
8282
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
8283
+ dependencies: "array \u2014 upstream worktrees",
8284
+ unblocks: "array \u2014 downstream worktrees",
8285
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
8286
+ }
8287
+ },
8288
+ ownerModule: "bootstrap",
8289
+ ontologyPrimitive: "worktree",
8290
+ tier: "showcase",
8291
+ internal: true
8292
+ };
8139
8293
  var MCP_TOOL_CONTRACTS = {
8140
8294
  // Belief lifecycle (commit, amend, fork, archive)
8141
8295
  create_belief: CREATE_BELIEF,
@@ -8229,6 +8383,7 @@ var MCP_TOOL_CONTRACTS = {
8229
8383
  get_agent_inbox: GET_AGENT_INBOX,
8230
8384
  claim_files: CLAIM_FILES,
8231
8385
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
8386
+ begin_build_session: BEGIN_BUILD_SESSION,
8232
8387
  // Policy / ACL (workhorse)
8233
8388
  check_permission: CHECK_PERMISSION,
8234
8389
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8442,6 +8597,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8442
8597
  "get_change_history",
8443
8598
  "get_failure_log",
8444
8599
  "record_attempt",
8600
+ "begin_build_session",
8445
8601
  "push",
8446
8602
  "open_pull_request",
8447
8603
  "record_judgment",
@@ -8496,7 +8652,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8496
8652
  "find_semantic_orphans"
8497
8653
  ];
8498
8654
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8499
- "begin_build_session",
8500
8655
  "evaluate_engineering_contract",
8501
8656
  "evaluate_research_contract"
8502
8657
  ];
@@ -8882,8 +9037,31 @@ function assertSurfaceCoverage(contracts) {
8882
9037
  }
8883
9038
  }
8884
9039
  }
8885
-
8886
- // ../contracts/src/function-registry/context.ts
9040
+ var jsonRecordSchema2 = z.record(z.unknown());
9041
+ var observationArgs = z.object({
9042
+ topicId: z.string().optional().describe("Topic scope for the observation."),
9043
+ summary: z.string().describe("Short observation summary."),
9044
+ text: z.string().optional().describe("Canonical observation text alias."),
9045
+ title: z.string().optional().describe("Optional observation title."),
9046
+ content: z.string().optional().describe("Optional rich observation content."),
9047
+ contentType: z.string().optional().describe("Observation content type."),
9048
+ kind: z.string().optional().describe("Evidence kind to store."),
9049
+ observationType: z.string().optional().describe("Observation type."),
9050
+ tags: z.array(z.string()).optional().describe("Observation tags."),
9051
+ source: z.string().optional().describe("Observation source label."),
9052
+ sourceType: z.string().optional().describe("Evidence source type."),
9053
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
9054
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9055
+ confidence: z.number().optional().describe("Observation confidence."),
9056
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
9057
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
9058
+ });
9059
+ var observationContextArgs = z.object({
9060
+ topicId: z.string().describe("Topic scope."),
9061
+ query: z.string().optional().describe("Optional context query."),
9062
+ limit: z.number().optional().describe("Maximum observations to return."),
9063
+ status: z.string().optional().describe("Observation status filter.")
9064
+ });
8887
9065
  var observationInput = (input, context) => withUserId(
8888
9066
  compactRecord4({
8889
9067
  projectId: input.projectId,
@@ -8942,7 +9120,8 @@ var contextContracts = [
8942
9120
  observationId: output && typeof output === "object" ? output.nodeId : void 0,
8943
9121
  observationType: input.observationType
8944
9122
  })
8945
- }
9123
+ },
9124
+ args: observationArgs
8946
9125
  }),
8947
9126
  surfaceContract({
8948
9127
  name: "get_observation_context",
@@ -8963,7 +9142,8 @@ var contextContracts = [
8963
9142
  status: input.status,
8964
9143
  userId: input.userId
8965
9144
  })
8966
- }
9145
+ },
9146
+ args: observationContextArgs
8967
9147
  })
8968
9148
  ];
8969
9149
 
@@ -9026,8 +9206,45 @@ var identityContracts = [
9026
9206
  }
9027
9207
  })
9028
9208
  ];
9029
-
9030
- // ../contracts/src/function-registry/beliefs.ts
9209
+ var jsonRecordSchema3 = z.record(z.unknown());
9210
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
9211
+ var reversibilitySchema = z.enum([
9212
+ "irreversible",
9213
+ "hard_to_reverse",
9214
+ "reversible",
9215
+ "trivial"
9216
+ ]);
9217
+ var predictionMetaSchema = z.object({
9218
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
9219
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
9220
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
9221
+ });
9222
+ var createBeliefArgs = z.object({
9223
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
9224
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
9225
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
9226
+ beliefType: z.string().optional().describe("Schema belief type."),
9227
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
9228
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
9229
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
9230
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
9231
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
9232
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
9233
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
9234
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
9235
+ });
9236
+ var forkBeliefArgs = z.object({
9237
+ nodeId: z.string().describe("The scored belief to fork from."),
9238
+ newFormulation: z.string().describe("The evolved belief statement."),
9239
+ forkReason: z.enum([
9240
+ "refinement",
9241
+ "contradiction_response",
9242
+ "scope_change",
9243
+ "confidence_collapse",
9244
+ "manual"
9245
+ ]).describe("Why this fork was created."),
9246
+ rationale: z.string().optional().describe("Why the fork is warranted.")
9247
+ });
9031
9248
  var beliefLookupInput = (input) => compactRecord4({
9032
9249
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9033
9250
  beliefId: input.beliefId
@@ -9102,7 +9319,8 @@ var beliefsContracts = [
9102
9319
  functionName: "create",
9103
9320
  kind: "mutation",
9104
9321
  inputProjection: createBeliefInput
9105
- }
9322
+ },
9323
+ args: createBeliefArgs
9106
9324
  }),
9107
9325
  surfaceContract({
9108
9326
  name: "get_belief",
@@ -9193,7 +9411,8 @@ var beliefsContracts = [
9193
9411
  functionName: "forkBelief",
9194
9412
  kind: "mutation",
9195
9413
  inputProjection: forkBeliefInput
9196
- }
9414
+ },
9415
+ args: forkBeliefArgs
9197
9416
  }),
9198
9417
  surfaceContract({
9199
9418
  name: "archive_belief",
@@ -9274,8 +9493,46 @@ var beliefsContracts = [
9274
9493
  }
9275
9494
  })
9276
9495
  ];
9277
-
9278
- // ../contracts/src/function-registry/evidence.ts
9496
+ var jsonRecordSchema4 = z.record(z.unknown());
9497
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
9498
+ var createEvidenceArgs = z.object({
9499
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
9500
+ text: z.string().describe("Canonical evidence text."),
9501
+ source: z.string().optional().describe("Source URL or source label."),
9502
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9503
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
9504
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
9505
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
9506
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
9507
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
9508
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
9509
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
9510
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
9511
+ title: z.string().optional().describe("Optional short title."),
9512
+ content: z.string().optional().describe("Optional long-form content."),
9513
+ contentType: z.string().optional().describe("Content format or MIME hint."),
9514
+ kind: z.string().optional().describe("Evidence kind."),
9515
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
9516
+ sourceType: z.string().optional().describe("Evidence source type."),
9517
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
9518
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
9519
+ methodology: z.string().optional().describe("Collection methodology."),
9520
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
9521
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
9522
+ });
9523
+ var addEvidenceArgs = z.object({
9524
+ canonicalText: z.string().describe("The evidence statement."),
9525
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
9526
+ topicId: z.string().optional().describe("Topic scope hint."),
9527
+ sourceUrl: z.string().optional().describe("URL of the source material."),
9528
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
9529
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
9530
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
9531
+ title: z.string().optional().describe("Optional short title."),
9532
+ content: z.string().optional().describe("Optional long-form evidence content."),
9533
+ contentType: z.string().optional().describe("Content format or MIME hint."),
9534
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
9535
+ });
9279
9536
  var evidenceIdInput = (input) => compactRecord4({
9280
9537
  evidenceId: input.evidenceId,
9281
9538
  insightId: input.insightId,
@@ -9350,7 +9607,8 @@ var evidenceContracts = [
9350
9607
  functionName: "create",
9351
9608
  kind: "mutation",
9352
9609
  inputProjection: createEvidenceInput
9353
- }
9610
+ },
9611
+ args: createEvidenceArgs
9354
9612
  }),
9355
9613
  surfaceContract({
9356
9614
  name: "add_evidence",
@@ -9386,7 +9644,8 @@ var evidenceContracts = [
9386
9644
  context
9387
9645
  );
9388
9646
  }
9389
- }
9647
+ },
9648
+ args: addEvidenceArgs
9390
9649
  }),
9391
9650
  surfaceContract({
9392
9651
  name: "get_evidence",
@@ -9493,8 +9752,91 @@ var evidenceContracts = [
9493
9752
  }
9494
9753
  })
9495
9754
  ];
9496
-
9497
- // ../contracts/src/function-registry/questions.ts
9755
+ var jsonRecordSchema5 = z.record(z.unknown());
9756
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
9757
+ var kernelQuestionPrioritySchema = z.enum([
9758
+ "critical",
9759
+ "high",
9760
+ "medium",
9761
+ "low"
9762
+ ]);
9763
+ var questionTypeSchema = z.enum([
9764
+ "validation",
9765
+ "falsification",
9766
+ "assumption_probe",
9767
+ "prediction_test",
9768
+ "counterfactual",
9769
+ "discovery",
9770
+ "clarification",
9771
+ "comparison",
9772
+ "causal",
9773
+ "mechanism",
9774
+ "general"
9775
+ ]);
9776
+ var createQuestionArgs = z.object({
9777
+ text: z.string().describe("The question text."),
9778
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
9779
+ topicId: z.string().optional().describe("Topic scope hint."),
9780
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
9781
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
9782
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
9783
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
9784
+ category: z.string().optional().describe("Question category."),
9785
+ source: z.string().optional().describe("Question source."),
9786
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
9787
+ importance: z.number().optional().describe("Numeric importance score."),
9788
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
9789
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
9790
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
9791
+ questionType: questionTypeSchema.optional().describe("Question type."),
9792
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
9793
+ });
9794
+ var refineQuestionArgs = z.object({
9795
+ id: z.string().describe("The question to refine."),
9796
+ text: z.string().describe("Updated question text."),
9797
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
9798
+ rationale: z.string().optional().describe("Why the question is refined."),
9799
+ category: z.string().optional().describe("Updated question category."),
9800
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
9801
+ });
9802
+ var createAnswerArgs = z.object({
9803
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
9804
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
9805
+ answerText: z.string().describe("The answer content."),
9806
+ topicId: z.string().optional().describe("Topic scope for the answer."),
9807
+ confidence: z.string().optional().describe("Answer confidence."),
9808
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
9809
+ answerSource: z.string().optional().describe("How the answer was produced."),
9810
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
9811
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
9812
+ });
9813
+ var answerQuestionArgs = z.object({
9814
+ id: z.string().describe("Canonical question ID."),
9815
+ topicId: z.string().describe("Topic scope for the answer."),
9816
+ text: z.string().describe("Answer text."),
9817
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
9818
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
9819
+ rationale: z.string().optional().describe("Why this answer is credible."),
9820
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
9821
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
9822
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
9823
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
9824
+ answerSource: z.string().optional().describe("How the answer was produced."),
9825
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
9826
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
9827
+ });
9828
+ var missingQuestionsArgs = z.object({
9829
+ topicId: z.string().describe("Topic scope."),
9830
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
9831
+ status: z.string().optional().describe("Question status filter."),
9832
+ limit: z.number().optional().describe("Maximum questions to inspect.")
9833
+ });
9834
+ var falsificationQuestionsArgs = z.object({
9835
+ topicId: z.string().describe("Topic scope."),
9836
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
9837
+ status: z.string().optional().describe("Question status filter."),
9838
+ limit: z.number().optional().describe("Maximum questions to inspect.")
9839
+ });
9498
9840
  var questionNodeInput = (input) => compactRecord4({
9499
9841
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9500
9842
  questionId: input.questionId
@@ -9541,7 +9883,8 @@ var questionsContracts = [
9541
9883
  functionName: "create",
9542
9884
  kind: "mutation",
9543
9885
  inputProjection: createQuestionInput
9544
- }
9886
+ },
9887
+ args: createQuestionArgs
9545
9888
  }),
9546
9889
  surfaceContract({
9547
9890
  name: "get_question",
@@ -9597,7 +9940,8 @@ var questionsContracts = [
9597
9940
  category: input.category,
9598
9941
  priority: input.priority
9599
9942
  })
9600
- }
9943
+ },
9944
+ args: refineQuestionArgs
9601
9945
  }),
9602
9946
  surfaceContract({
9603
9947
  name: "update_question_status",
@@ -9673,7 +10017,8 @@ var questionsContracts = [
9673
10017
  }),
9674
10018
  context
9675
10019
  )
9676
- }
10020
+ },
10021
+ args: createAnswerArgs
9677
10022
  }),
9678
10023
  surfaceContract({
9679
10024
  name: "answer_question",
@@ -9702,7 +10047,8 @@ var questionsContracts = [
9702
10047
  }),
9703
10048
  context
9704
10049
  )
9705
- }
10050
+ },
10051
+ args: answerQuestionArgs
9706
10052
  }),
9707
10053
  surfaceContract({
9708
10054
  name: "get_answer",
@@ -9734,7 +10080,8 @@ var questionsContracts = [
9734
10080
  functionName: "getByTopic",
9735
10081
  kind: "query",
9736
10082
  inputProjection: questionTopicInput
9737
- }
10083
+ },
10084
+ args: missingQuestionsArgs
9738
10085
  }),
9739
10086
  surfaceContract({
9740
10087
  name: "get_high_priority_questions",
@@ -9769,11 +10116,22 @@ var questionsContracts = [
9769
10116
  functionName: "getByTopic",
9770
10117
  kind: "query",
9771
10118
  inputProjection: questionTopicInput
9772
- }
10119
+ },
10120
+ args: falsificationQuestionsArgs
9773
10121
  })
9774
10122
  ];
9775
-
9776
- // ../contracts/src/function-registry/topics.ts
10123
+ var updateTopicArgs = z.object({
10124
+ id: z.string().describe("Topic ID."),
10125
+ topicId: z.string().optional().describe("Topic ID alias."),
10126
+ name: z.string().optional().describe("Topic name."),
10127
+ description: z.string().optional().describe("Topic description."),
10128
+ type: z.string().optional().describe("Topic type."),
10129
+ status: z.string().optional().describe("Topic status."),
10130
+ visibility: z.string().optional().describe("Topic visibility."),
10131
+ ontologyId: z.string().optional().describe("Ontology to bind."),
10132
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
10133
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
10134
+ });
9777
10135
  var topicIdInput = (input) => compactRecord4({
9778
10136
  id: input.id ?? input.topicId
9779
10137
  });
@@ -9854,7 +10212,8 @@ var topicsContracts = [
9854
10212
  functionName: "update",
9855
10213
  kind: "mutation",
9856
10214
  inputProjection: updateTopicInput
9857
- }
10215
+ },
10216
+ args: updateTopicArgs
9858
10217
  }),
9859
10218
  surfaceContract({
9860
10219
  name: "get_topic_tree",
@@ -9873,8 +10232,27 @@ var topicsContracts = [
9873
10232
  }
9874
10233
  })
9875
10234
  ];
9876
-
9877
- // ../contracts/src/function-registry/lenses.ts
10235
+ var lensPerspectiveSchema = z.enum([
10236
+ "investigation",
10237
+ "monitoring",
10238
+ "analysis",
10239
+ "comparison",
10240
+ "taxonomy"
10241
+ ]);
10242
+ var jsonRecordSchema6 = z.record(z.unknown());
10243
+ var createLensArgs = z.object({
10244
+ name: z.string().describe("Lens name."),
10245
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
10246
+ topicId: z.string().optional().describe("Originating topic scope."),
10247
+ description: z.string().optional().describe("What this lens investigates or monitors."),
10248
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
10249
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
10250
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
10251
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
10252
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
10253
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
10254
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
10255
+ });
9878
10256
  var createLensInput = (input, context) => compactRecord4({
9879
10257
  name: input.name,
9880
10258
  description: input.description,
@@ -9911,7 +10289,8 @@ var lensesContracts = [
9911
10289
  functionName: "create",
9912
10290
  kind: "mutation",
9913
10291
  inputProjection: createLensInput
9914
- }
10292
+ },
10293
+ args: createLensArgs
9915
10294
  }),
9916
10295
  surfaceContract({
9917
10296
  name: "list_lenses",
@@ -9973,8 +10352,18 @@ var lensesContracts = [
9973
10352
  }
9974
10353
  })
9975
10354
  ];
9976
-
9977
- // ../contracts/src/function-registry/ontologies.ts
10355
+ var updateOntologyArgs = z.object({
10356
+ id: z.string().describe("Ontology definition ID."),
10357
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
10358
+ name: z.string().optional().describe("Ontology display name."),
10359
+ description: z.string().optional().describe("Ontology description."),
10360
+ status: z.string().optional().describe("Ontology lifecycle status.")
10361
+ });
10362
+ var ontologyVersionLifecycleArgs = z.object({
10363
+ id: z.string().describe("Ontology version ID."),
10364
+ versionId: z.string().optional().describe("Ontology version ID alias."),
10365
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
10366
+ });
9978
10367
  var ontologyIdInput = (input) => compactRecord4({
9979
10368
  id: input.id ?? input.ontologyId
9980
10369
  });
@@ -10053,11 +10442,11 @@ var ontologiesContracts = [
10053
10442
  id: input.id ?? input.ontologyId,
10054
10443
  name: input.name,
10055
10444
  description: input.description,
10056
- parentOntologyId: input.parentOntologyId,
10057
10445
  status: input.status,
10058
10446
  actorId: input.actorId
10059
10447
  })
10060
- }
10448
+ },
10449
+ args: updateOntologyArgs
10061
10450
  }),
10062
10451
  surfaceContract({
10063
10452
  name: "archive_ontology",
@@ -10140,7 +10529,8 @@ var ontologiesContracts = [
10140
10529
  functionName: "publishOntologyVersion",
10141
10530
  kind: "mutation",
10142
10531
  inputProjection: ontologyVersionIdInput
10143
- }
10532
+ },
10533
+ args: ontologyVersionLifecycleArgs
10144
10534
  }),
10145
10535
  surfaceContract({
10146
10536
  name: "deprecate_ontology_version",
@@ -10156,7 +10546,8 @@ var ontologiesContracts = [
10156
10546
  functionName: "deprecateOntologyVersion",
10157
10547
  kind: "mutation",
10158
10548
  inputProjection: ontologyVersionIdInput
10159
- }
10549
+ },
10550
+ args: ontologyVersionLifecycleArgs
10160
10551
  }),
10161
10552
  surfaceContract({
10162
10553
  name: "resolve_effective_ontology",
@@ -10175,8 +10566,76 @@ var ontologiesContracts = [
10175
10566
  }
10176
10567
  })
10177
10568
  ];
10178
-
10179
- // ../contracts/src/function-registry/worktrees.ts
10569
+ var autoFixPolicyInputSchema = z.object({
10570
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
10571
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
10572
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
10573
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
10574
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
10575
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
10576
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
10577
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
10578
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
10579
+ var worktreeKeyQuestionInputSchema = z.object({
10580
+ question: z.string().describe("Question the worktree must resolve."),
10581
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
10582
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
10583
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
10584
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
10585
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
10586
+ var worktreeEvidenceSignalInputSchema = z.object({
10587
+ signal: z.string().describe("Evidence signal the worktree should collect."),
10588
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
10589
+ progress: z.string().optional().describe("Collection progress note for the signal."),
10590
+ notes: z.string().optional().describe("Additional evidence collection notes.")
10591
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
10592
+ var worktreeDecisionGateInputSchema = z.object({
10593
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
10594
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
10595
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
10596
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
10597
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
10598
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
10599
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
10600
+ var addWorktreeArgs = z.object({
10601
+ title: z.string().optional().describe("Human-readable worktree name or objective."),
10602
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
10603
+ topicId: z.string().describe("Primary topic scope for the worktree."),
10604
+ projectId: z.string().optional().describe("Legacy topicId alias."),
10605
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
10606
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
10607
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
10608
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
10609
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
10610
+ gate: z.string().optional().describe("Exit gate for this worktree."),
10611
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
10612
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
10613
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
10614
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
10615
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
10616
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
10617
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
10618
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
10619
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
10620
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
10621
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
10622
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
10623
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
10624
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
10625
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
10626
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
10627
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
10628
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
10629
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
10630
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
10631
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
10632
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
10633
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
10634
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
10635
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
10636
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
10637
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
10638
+ });
10180
10639
  var worktreeIdInput = (input) => compactRecord4({
10181
10640
  worktreeId: input.worktreeId ?? input.id
10182
10641
  });
@@ -10209,6 +10668,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10209
10668
  autoFixPolicy: input.autoFixPolicy,
10210
10669
  lastReconciledAt: input.lastReconciledAt
10211
10670
  });
10671
+ var worktreeMetadataArgs = z.object({
10672
+ worktreeId: z.string().describe("The worktree to update."),
10673
+ id: z.string().optional().describe("Worktree ID alias."),
10674
+ topicId: z.string().optional().describe("Primary topic scope."),
10675
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
10676
+ status: z.string().optional().describe("Worktree lifecycle status."),
10677
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
10678
+ lane: z.string().optional().describe("Campaign lane."),
10679
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
10680
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
10681
+ gate: z.string().optional().describe("Exit gate for this worktree."),
10682
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
10683
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
10684
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
10685
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
10686
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
10687
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
10688
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
10689
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
10690
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
10691
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
10692
+ });
10693
+ var pushArgs = worktreeMetadataArgs.extend({
10694
+ targetContext: z.string().describe("Where to push merged findings."),
10695
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
10696
+ });
10697
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
10698
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
10699
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
10700
+ });
10701
+ var mergeKeyFindingsInput = (input) => {
10702
+ if (Array.isArray(input.keyFindings)) {
10703
+ return input.keyFindings;
10704
+ }
10705
+ if (Array.isArray(input.outcomes)) {
10706
+ const findings = input.outcomes.filter(
10707
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
10708
+ );
10709
+ if (findings.length > 0) {
10710
+ return findings;
10711
+ }
10712
+ }
10713
+ return [input.summary ?? "Merged worktree"];
10714
+ };
10212
10715
  var listAllWorktreesInput = (input) => compactRecord4({
10213
10716
  status: input.status,
10214
10717
  lane: input.lane,
@@ -10216,6 +10719,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10216
10719
  limit: input.limit
10217
10720
  });
10218
10721
  var worktreesContracts = [
10722
+ surfaceContract({
10723
+ name: "begin_build_session",
10724
+ kind: "mutation",
10725
+ domain: "worktrees",
10726
+ surfaceClass: "platform_internal",
10727
+ path: "/mcp/build-session/begin",
10728
+ sdkNamespace: "worktrees",
10729
+ sdkMethod: "beginBuildSession",
10730
+ summary: "Begin a coding build session for a worktree."
10731
+ }),
10219
10732
  surfaceContract({
10220
10733
  name: "add_worktree",
10221
10734
  kind: "mutation",
@@ -10232,13 +10745,12 @@ var worktreesContracts = [
10232
10745
  inputProjection: (input, context) => withCreatedBy(
10233
10746
  compactRecord4({
10234
10747
  name: input.name ?? input.title,
10235
- topicId: input.topicId,
10748
+ topicId: input.topicId ?? input.projectId,
10236
10749
  worktreeType: input.worktreeType,
10237
10750
  objective: input.objective,
10238
10751
  gate: input.gate,
10239
10752
  hypothesis: input.hypothesis,
10240
10753
  rationale: input.rationale,
10241
- signal: input.signal,
10242
10754
  startDate: input.startDate,
10243
10755
  endDate: input.endDate,
10244
10756
  durationWeeks: input.durationWeeks,
@@ -10264,12 +10776,12 @@ var worktreesContracts = [
10264
10776
  staffingHint: input.staffingHint,
10265
10777
  domainPackId: input.domainPackId,
10266
10778
  lensId: input.lensId,
10267
- linkedQuestionId: input.linkedQuestionId,
10268
10779
  lastReconciledAt: input.lastReconciledAt
10269
10780
  }),
10270
10781
  context
10271
10782
  )
10272
- }
10783
+ },
10784
+ args: addWorktreeArgs
10273
10785
  }),
10274
10786
  surfaceContract({
10275
10787
  name: "activate_worktree",
@@ -10381,7 +10893,8 @@ var worktreesContracts = [
10381
10893
  functionName: "updateMetadata",
10382
10894
  kind: "mutation",
10383
10895
  inputProjection: worktreeMetadataInput
10384
- }
10896
+ },
10897
+ args: worktreeMetadataArgs
10385
10898
  }),
10386
10899
  surfaceContract({
10387
10900
  name: "merge",
@@ -10399,9 +10912,7 @@ var worktreesContracts = [
10399
10912
  inputProjection: (input, context) => withUserId(
10400
10913
  {
10401
10914
  ...worktreeIdInput(input),
10402
- keyFindings: input.keyFindings ?? [
10403
- input.summary ?? "Merged worktree"
10404
- ],
10915
+ keyFindings: mergeKeyFindingsInput(input),
10405
10916
  decisionsReached: input.decisionsReached ?? [],
10406
10917
  nextSteps: input.nextSteps ?? []
10407
10918
  },
@@ -10423,7 +10934,8 @@ var worktreesContracts = [
10423
10934
  functionName: "updateMetadata",
10424
10935
  kind: "mutation",
10425
10936
  inputProjection: worktreeMetadataInput
10426
- }
10937
+ },
10938
+ args: pushArgs
10427
10939
  }),
10428
10940
  surfaceContract({
10429
10941
  name: "open_pull_request",
@@ -10439,7 +10951,8 @@ var worktreesContracts = [
10439
10951
  functionName: "updateMetadata",
10440
10952
  kind: "mutation",
10441
10953
  inputProjection: worktreeMetadataInput
10442
- }
10954
+ },
10955
+ args: openPullRequestArgs
10443
10956
  })
10444
10957
  ];
10445
10958
 
@@ -10543,6 +11056,15 @@ var createEdgeArgs = z.object({
10543
11056
  topicId: z.string().optional(),
10544
11057
  trustedBypassAccessCheck: z.boolean().optional()
10545
11058
  });
11059
+ var queryLineageArgs = z.object({
11060
+ nodeId: z.string().describe("Starting node to trace from."),
11061
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
11062
+ depth: z.number().optional().describe("Traversal depth alias."),
11063
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11064
+ mode: z.string().optional().describe("Traversal mode."),
11065
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11066
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11067
+ });
10546
11068
  function graphRefNodeId(ref) {
10547
11069
  if (ref.kind === "epistemic_node") {
10548
11070
  return ref.nodeId;
@@ -10613,11 +11135,59 @@ var edgesContracts = [
10613
11135
  minLayer: input.minLayer,
10614
11136
  maxLayer: input.maxLayer
10615
11137
  })
10616
- }
11138
+ },
11139
+ args: queryLineageArgs
10617
11140
  })
10618
11141
  ];
10619
-
10620
- // ../contracts/src/function-registry/graph.ts
11142
+ var traversalLayerSchema = z.enum([
11143
+ "L4",
11144
+ "L3",
11145
+ "L2",
11146
+ "L1",
11147
+ "ontological",
11148
+ "organizational"
11149
+ ]);
11150
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
11151
+ var lineageAliasArgs = z.object({
11152
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
11153
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
11154
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
11155
+ depth: z.number().optional().describe("Traversal depth alias."),
11156
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11157
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
11158
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
11159
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
11160
+ });
11161
+ var lineageArgs = lineageAliasArgs.extend({
11162
+ nodeId: z.string().describe("Starting node to traverse from.")
11163
+ });
11164
+ var traverseGraphArgs = lineageAliasArgs.extend({
11165
+ startNode: z.string().describe("Node to start traversal from."),
11166
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
11167
+ });
11168
+ var graphNeighborhoodArgs = z.object({
11169
+ globalId: z.string().optional().describe("Single root global ID."),
11170
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
11171
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11172
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
11173
+ limit: z.number().optional().describe("Maximum edges to return.")
11174
+ });
11175
+ var flagContradictionArgs = z.object({
11176
+ beliefA: z.string().describe("First belief in tension."),
11177
+ beliefB: z.string().describe("Second belief in tension."),
11178
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
11179
+ description: z.string().optional().describe("Human-readable contradiction."),
11180
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
11181
+ defeatType: z.string().optional().describe("Defeat type annotation."),
11182
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
11183
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
11184
+ });
11185
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
11186
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
11187
+ topicId: z.string().optional().describe("Topic scope override."),
11188
+ minScore: z.number().optional().describe("Minimum match score."),
11189
+ limit: z.number().optional().describe("Maximum candidates to return.")
11190
+ });
10621
11191
  var contradictionSeverity = (value) => {
10622
11192
  switch (value) {
10623
11193
  case "critical":
@@ -10672,7 +11242,8 @@ var graphContracts = [
10672
11242
  functionName: "getLineage",
10673
11243
  kind: "query",
10674
11244
  inputProjection: lineageInput
10675
- }
11245
+ },
11246
+ args: traverseGraphArgs
10676
11247
  }),
10677
11248
  surfaceContract({
10678
11249
  name: "get_graph_neighborhood",
@@ -10688,7 +11259,8 @@ var graphContracts = [
10688
11259
  functionName: "getByTopic",
10689
11260
  kind: "query",
10690
11261
  inputProjection: topicEdgesInput
10691
- }
11262
+ },
11263
+ args: graphNeighborhoodArgs
10692
11264
  }),
10693
11265
  surfaceContract({
10694
11266
  name: "get_graph_structure_analysis",
@@ -10737,7 +11309,8 @@ var graphContracts = [
10737
11309
  functionName: "create",
10738
11310
  kind: "mutation",
10739
11311
  inputProjection: flagContradictionInput
10740
- }
11312
+ },
11313
+ args: flagContradictionArgs
10741
11314
  }),
10742
11315
  surfaceContract({
10743
11316
  name: "detect_confirmation_bias",
@@ -10828,7 +11401,8 @@ var graphContracts = [
10828
11401
  functionName: "getLineage",
10829
11402
  kind: "query",
10830
11403
  inputProjection: lineageInput
10831
- }
11404
+ },
11405
+ args: discoverEntityConnectionsArgs
10832
11406
  }),
10833
11407
  surfaceContract({
10834
11408
  name: "trigger_belief_review",
@@ -10859,7 +11433,8 @@ var graphContracts = [
10859
11433
  functionName: "getLineage",
10860
11434
  kind: "query",
10861
11435
  inputProjection: lineageInput
10862
- }
11436
+ },
11437
+ args: lineageArgs
10863
11438
  })
10864
11439
  ];
10865
11440
 
@@ -10911,8 +11486,16 @@ var contractsContracts = [
10911
11486
  }
10912
11487
  })
10913
11488
  ];
10914
-
10915
- // ../contracts/src/function-registry/judgments.ts
11489
+ var auditTrailArgs = z.object({
11490
+ nodeId: z.string().describe("The node to audit."),
11491
+ id: z.string().optional().describe("Node ID alias."),
11492
+ limit: z.number().optional().describe("Maximum entries to return."),
11493
+ depth: z.number().optional().describe("Traversal depth alias."),
11494
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
11495
+ mode: z.string().optional().describe("Traversal mode."),
11496
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11497
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11498
+ });
10916
11499
  var judgmentsContracts = [
10917
11500
  surfaceContract({
10918
11501
  name: "record_judgment",
@@ -10967,7 +11550,8 @@ var judgmentsContracts = [
10967
11550
  minLayer: input.minLayer,
10968
11551
  maxLayer: input.maxLayer
10969
11552
  })
10970
- }
11553
+ },
11554
+ args: auditTrailArgs
10971
11555
  })
10972
11556
  ];
10973
11557
 
@@ -11135,8 +11719,13 @@ var coordinationContracts = [
11135
11719
  }
11136
11720
  })
11137
11721
  ];
11138
-
11139
- // ../contracts/src/function-registry/pipeline.ts
11722
+ var pipelineSnapshotArgs = z.object({
11723
+ topicId: z.string().describe("Topic scope ID."),
11724
+ status: z.string().optional().describe("Worktree status filter."),
11725
+ lane: z.string().optional().describe("Campaign lane filter."),
11726
+ campaign: z.number().optional().describe("Campaign number filter."),
11727
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
11728
+ });
11140
11729
  var pipelineContracts = [
11141
11730
  surfaceContract({
11142
11731
  name: "pipeline_snapshot",
@@ -11157,7 +11746,8 @@ var pipelineContracts = [
11157
11746
  campaign: input.campaign,
11158
11747
  limit: input.limit
11159
11748
  })
11160
- }
11749
+ },
11750
+ args: pipelineSnapshotArgs
11161
11751
  }),
11162
11752
  surfaceContract({
11163
11753
  name: "seed_belief_lattice",
@@ -11209,7 +11799,31 @@ var recordScopeLearningArgs = z.object({
11209
11799
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11210
11800
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11211
11801
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11212
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
11802
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
11803
+ text: z.string().optional().describe("Canonical learning text alias."),
11804
+ content: z.string().optional().describe("Canonical learning content alias."),
11805
+ kind: z.string().optional().describe("Evidence kind to store."),
11806
+ sourceType: z.string().optional().describe("Evidence source type."),
11807
+ externalSourceType: z.string().optional().describe("External source type alias."),
11808
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
11809
+ });
11810
+ var codeContextArgs = z.object({
11811
+ topicId: z.string().optional().describe("Topic scope."),
11812
+ filePath: z.string().optional().describe("File path anchor."),
11813
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
11814
+ limit: z.number().optional().describe("Maximum records to return."),
11815
+ status: z.string().optional().describe("Evidence status filter.")
11816
+ });
11817
+ var recordAttemptArgs = z.object({
11818
+ topicId: z.string().optional().describe("Topic scope."),
11819
+ description: z.string().describe("Attempt description."),
11820
+ errorMessage: z.string().optional().describe("Failure or error message."),
11821
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
11822
+ filePath: z.string().optional().describe("Single file path alias."),
11823
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
11824
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
11825
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
11826
+ title: z.string().optional().describe("Attempt evidence title.")
11213
11827
  });
11214
11828
  var learningInput = (input, context) => {
11215
11829
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11326,7 +11940,8 @@ var codingContracts = [
11326
11940
  status: input.status,
11327
11941
  userId: input.userId
11328
11942
  })
11329
- }
11943
+ },
11944
+ args: codeContextArgs
11330
11945
  }),
11331
11946
  surfaceContract({
11332
11947
  name: "get_change_history",
@@ -11363,7 +11978,8 @@ var codingContracts = [
11363
11978
  functionName: "create",
11364
11979
  kind: "mutation",
11365
11980
  inputProjection: attemptInput
11366
- }
11981
+ },
11982
+ args: recordAttemptArgs
11367
11983
  }),
11368
11984
  surfaceContract({
11369
11985
  name: "get_failure_log",
@@ -11438,6 +12054,604 @@ new Map(
11438
12054
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11439
12055
  );
11440
12056
 
12057
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
12058
+ function isCopyableSeedRequirement(entry) {
12059
+ return (entry.copyMode === "template_global" || entry.copyMode === "template_tenant_rewrite" || entry.copyMode === "template_reference_remap") && Boolean(entry.scope) && Array.isArray(entry.uniqueKey) && entry.uniqueKey.length > 0;
12060
+ }
12061
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
12062
+ {
12063
+ component: "kernel",
12064
+ table: "agentMessages",
12065
+ prepopulation: "runtime_data",
12066
+ copyMode: "none",
12067
+ description: "Agent coordination messages are session data, not template data."
12068
+ },
12069
+ {
12070
+ component: "kernel",
12071
+ table: "agentSessions",
12072
+ prepopulation: "runtime_data",
12073
+ copyMode: "none",
12074
+ description: "Agent coordination sessions are created by active clients."
12075
+ },
12076
+ {
12077
+ component: "kernel",
12078
+ table: "autofixJobs",
12079
+ prepopulation: "runtime_queue",
12080
+ copyMode: "none",
12081
+ description: "Autofix work items are runtime queue rows."
12082
+ },
12083
+ {
12084
+ component: "kernel",
12085
+ table: "backgroundJobRuns",
12086
+ prepopulation: "runtime_log",
12087
+ copyMode: "none",
12088
+ description: "Background job executions are runtime logs."
12089
+ },
12090
+ {
12091
+ component: "kernel",
12092
+ table: "backgroundJobSettings",
12093
+ prepopulation: "required_template",
12094
+ copyMode: "template_global",
12095
+ scope: "global",
12096
+ uniqueKey: ["jobKey"],
12097
+ description: "Default job enablement settings must come from the K template."
12098
+ },
12099
+ {
12100
+ component: "kernel",
12101
+ table: "beliefConfidence",
12102
+ prepopulation: "runtime_data",
12103
+ copyMode: "none",
12104
+ description: "Belief confidence rows are created with tenant graph facts."
12105
+ },
12106
+ {
12107
+ component: "kernel",
12108
+ table: "beliefEvidenceLinks",
12109
+ prepopulation: "runtime_data",
12110
+ copyMode: "none",
12111
+ description: "Belief-to-evidence links are tenant graph data."
12112
+ },
12113
+ {
12114
+ component: "kernel",
12115
+ table: "beliefHistory",
12116
+ prepopulation: "runtime_data",
12117
+ copyMode: "none",
12118
+ description: "Belief history is append-only tenant graph data."
12119
+ },
12120
+ {
12121
+ component: "kernel",
12122
+ table: "beliefScenarios",
12123
+ prepopulation: "runtime_data",
12124
+ copyMode: "none",
12125
+ description: "Scenario rows are tenant-authored reasoning data."
12126
+ },
12127
+ {
12128
+ component: "kernel",
12129
+ table: "beliefVotes",
12130
+ prepopulation: "runtime_data",
12131
+ copyMode: "none",
12132
+ description: "Decision belief votes are tenant-authored data."
12133
+ },
12134
+ {
12135
+ component: "kernel",
12136
+ table: "calibrationScores",
12137
+ prepopulation: "runtime_derived",
12138
+ copyMode: "none",
12139
+ description: "Calibration scores are computed from tenant outcomes."
12140
+ },
12141
+ {
12142
+ component: "kernel",
12143
+ table: "contractEvaluations",
12144
+ prepopulation: "runtime_log",
12145
+ copyMode: "none",
12146
+ description: "Contract evaluation rows are runtime computation logs."
12147
+ },
12148
+ {
12149
+ component: "kernel",
12150
+ table: "contradictions",
12151
+ prepopulation: "runtime_data",
12152
+ copyMode: "none",
12153
+ description: "Contradictions are tenant graph facts."
12154
+ },
12155
+ {
12156
+ component: "kernel",
12157
+ table: "crossProjectConnections",
12158
+ prepopulation: "runtime_data",
12159
+ copyMode: "none",
12160
+ description: "Cross-topic connections are tenant graph facts."
12161
+ },
12162
+ {
12163
+ component: "kernel",
12164
+ table: "decisionComputedSummaries",
12165
+ prepopulation: "runtime_derived",
12166
+ copyMode: "none",
12167
+ description: "Decision summaries are derived tenant outputs."
12168
+ },
12169
+ {
12170
+ component: "kernel",
12171
+ table: "decisionEvents",
12172
+ prepopulation: "runtime_data",
12173
+ copyMode: "none",
12174
+ description: "Decision events are lifecycle data."
12175
+ },
12176
+ {
12177
+ component: "kernel",
12178
+ table: "decisionParticipants",
12179
+ prepopulation: "runtime_data",
12180
+ copyMode: "none",
12181
+ description: "Decision participants are tenant-selected actors."
12182
+ },
12183
+ {
12184
+ component: "kernel",
12185
+ table: "decisionRiskLedger",
12186
+ prepopulation: "runtime_data",
12187
+ copyMode: "none",
12188
+ description: "Decision risk rows are tenant decision data."
12189
+ },
12190
+ {
12191
+ component: "kernel",
12192
+ table: "decisionSnapshots",
12193
+ prepopulation: "runtime_derived",
12194
+ copyMode: "none",
12195
+ description: "Decision snapshots are derived from tenant state."
12196
+ },
12197
+ {
12198
+ component: "kernel",
12199
+ table: "deliberationContributions",
12200
+ prepopulation: "runtime_data",
12201
+ copyMode: "none",
12202
+ description: "Deliberation contributions are tenant-authored data."
12203
+ },
12204
+ {
12205
+ component: "kernel",
12206
+ table: "deliberationSessions",
12207
+ prepopulation: "runtime_data",
12208
+ copyMode: "none",
12209
+ description: "Deliberation sessions are created by tenant workflows."
12210
+ },
12211
+ {
12212
+ component: "kernel",
12213
+ table: "epistemicAudit",
12214
+ prepopulation: "runtime_log",
12215
+ copyMode: "none",
12216
+ description: "Epistemic audit rows are append-only runtime audit data."
12217
+ },
12218
+ {
12219
+ component: "kernel",
12220
+ table: "epistemicContracts",
12221
+ prepopulation: "runtime_data",
12222
+ copyMode: "none",
12223
+ description: "Epistemic contracts are tenant-authored governance data."
12224
+ },
12225
+ {
12226
+ component: "kernel",
12227
+ table: "epistemicEdges",
12228
+ prepopulation: "runtime_data",
12229
+ copyMode: "none",
12230
+ description: "Edges are tenant reasoning graph data."
12231
+ },
12232
+ {
12233
+ component: "kernel",
12234
+ table: "epistemicNodeEmbeddings",
12235
+ prepopulation: "runtime_derived",
12236
+ copyMode: "none",
12237
+ description: "Embeddings are derived from tenant graph nodes."
12238
+ },
12239
+ {
12240
+ component: "kernel",
12241
+ table: "epistemicNodes",
12242
+ prepopulation: "runtime_data",
12243
+ copyMode: "none",
12244
+ description: "Nodes are tenant reasoning graph data."
12245
+ },
12246
+ {
12247
+ component: "kernel",
12248
+ table: "graphAnalysisCache",
12249
+ prepopulation: "runtime_derived",
12250
+ copyMode: "none",
12251
+ description: "Graph analysis cache rows are derived from tenant graph state."
12252
+ },
12253
+ {
12254
+ component: "kernel",
12255
+ table: "graphAnalysisResults",
12256
+ prepopulation: "runtime_derived",
12257
+ copyMode: "none",
12258
+ description: "Graph analysis result rows are derived tenant outputs."
12259
+ },
12260
+ {
12261
+ component: "kernel",
12262
+ table: "graphSuggestions",
12263
+ prepopulation: "runtime_derived",
12264
+ copyMode: "none",
12265
+ description: "Graph suggestions are derived recommendations."
12266
+ },
12267
+ {
12268
+ component: "kernel",
12269
+ table: "harnessReplays",
12270
+ prepopulation: "runtime_log",
12271
+ copyMode: "none",
12272
+ description: "Harness replay rows are runtime verification logs."
12273
+ },
12274
+ {
12275
+ component: "kernel",
12276
+ table: "harnessRuns",
12277
+ prepopulation: "runtime_log",
12278
+ copyMode: "none",
12279
+ description: "Harness run rows are runtime verification logs."
12280
+ },
12281
+ {
12282
+ component: "kernel",
12283
+ table: "idempotencyTokens",
12284
+ prepopulation: "runtime_log",
12285
+ copyMode: "none",
12286
+ description: "Idempotency tokens are request-scoped runtime guards."
12287
+ },
12288
+ {
12289
+ component: "kernel",
12290
+ table: "lenses",
12291
+ prepopulation: "optional_template",
12292
+ copyMode: "none",
12293
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
12294
+ },
12295
+ {
12296
+ component: "kernel",
12297
+ table: "lensTopicBindings",
12298
+ prepopulation: "runtime_data",
12299
+ copyMode: "none",
12300
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
12301
+ },
12302
+ {
12303
+ component: "kernel",
12304
+ table: "neo4jSyncQueue",
12305
+ prepopulation: "runtime_queue",
12306
+ copyMode: "none",
12307
+ description: "Neo4j sync queue rows are runtime work items."
12308
+ },
12309
+ {
12310
+ component: "kernel",
12311
+ table: "ontologyDefinitions",
12312
+ prepopulation: "required_template",
12313
+ copyMode: "template_global",
12314
+ scope: "global",
12315
+ uniqueKey: ["ontologyKey"],
12316
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
12317
+ },
12318
+ {
12319
+ component: "kernel",
12320
+ table: "ontologyVersions",
12321
+ prepopulation: "required_template",
12322
+ copyMode: "template_reference_remap",
12323
+ scope: "global",
12324
+ uniqueKey: ["ontologyKey", "version"],
12325
+ dependsOn: ["ontologyDefinitions"],
12326
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
12327
+ },
12328
+ {
12329
+ component: "kernel",
12330
+ table: "platformAgentRunPolicyDecisions",
12331
+ prepopulation: "runtime_log",
12332
+ copyMode: "none",
12333
+ description: "Agent-run policy decisions are audit logs."
12334
+ },
12335
+ {
12336
+ component: "kernel",
12337
+ table: "platformAgentRunPromptResolutions",
12338
+ prepopulation: "runtime_log",
12339
+ copyMode: "none",
12340
+ description: "Agent-run prompt resolution rows are runtime logs."
12341
+ },
12342
+ {
12343
+ component: "kernel",
12344
+ table: "platformAgentRuns",
12345
+ prepopulation: "runtime_log",
12346
+ copyMode: "none",
12347
+ description: "Agent runs are runtime execution records."
12348
+ },
12349
+ {
12350
+ component: "kernel",
12351
+ table: "platformAgentRunToolCalls",
12352
+ prepopulation: "runtime_log",
12353
+ copyMode: "none",
12354
+ description: "Agent-run tool calls are runtime execution records."
12355
+ },
12356
+ {
12357
+ component: "kernel",
12358
+ table: "platformHarnessShadowAudit",
12359
+ prepopulation: "runtime_log",
12360
+ copyMode: "none",
12361
+ description: "Harness shadow audit rows are runtime audit records."
12362
+ },
12363
+ {
12364
+ component: "kernel",
12365
+ table: "publicationRules",
12366
+ prepopulation: "required_template",
12367
+ copyMode: "template_tenant_rewrite",
12368
+ scope: "tenant",
12369
+ uniqueKey: ["tenantId", "workspaceId", "name"],
12370
+ description: "Default publication policy rules are rewritten into each tenant."
12371
+ },
12372
+ {
12373
+ component: "kernel",
12374
+ table: "questionEvidenceLinks",
12375
+ prepopulation: "runtime_data",
12376
+ copyMode: "none",
12377
+ description: "Question-to-evidence links are tenant graph data."
12378
+ },
12379
+ {
12380
+ component: "kernel",
12381
+ table: "researchJobs",
12382
+ prepopulation: "runtime_queue",
12383
+ copyMode: "none",
12384
+ description: "Research job rows are runtime queue items."
12385
+ },
12386
+ {
12387
+ component: "kernel",
12388
+ table: "schemaEnumConfig",
12389
+ prepopulation: "required_template",
12390
+ copyMode: "template_global",
12391
+ scope: "global",
12392
+ uniqueKey: ["category", "value"],
12393
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
12394
+ },
12395
+ {
12396
+ component: "kernel",
12397
+ table: "stakeholderGroups",
12398
+ prepopulation: "runtime_data",
12399
+ copyMode: "none",
12400
+ description: "Stakeholder groups are tenant decision data."
12401
+ },
12402
+ {
12403
+ component: "kernel",
12404
+ table: "systemLogs",
12405
+ prepopulation: "runtime_log",
12406
+ copyMode: "none",
12407
+ description: "System logs are runtime telemetry."
12408
+ },
12409
+ {
12410
+ component: "kernel",
12411
+ table: "tasks",
12412
+ prepopulation: "runtime_data",
12413
+ copyMode: "none",
12414
+ description: "Tasks are tenant-authored work items."
12415
+ },
12416
+ {
12417
+ component: "kernel",
12418
+ table: "topics",
12419
+ prepopulation: "runtime_bootstrap",
12420
+ copyMode: "none",
12421
+ description: "Default topics are created by tenant provisioning, not copied from templates."
12422
+ },
12423
+ {
12424
+ component: "kernel",
12425
+ table: "workflowDefinitions",
12426
+ prepopulation: "optional_template",
12427
+ copyMode: "none",
12428
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
12429
+ },
12430
+ {
12431
+ component: "kernel",
12432
+ table: "workflowPullRequests",
12433
+ prepopulation: "runtime_data",
12434
+ copyMode: "none",
12435
+ description: "Workflow pull requests are tenant workflow data."
12436
+ },
12437
+ {
12438
+ component: "kernel",
12439
+ table: "workflowStages",
12440
+ prepopulation: "optional_template",
12441
+ copyMode: "none",
12442
+ dependsOn: ["workflowDefinitions"],
12443
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
12444
+ },
12445
+ {
12446
+ component: "kernel",
12447
+ table: "worktreeBeliefCluster",
12448
+ prepopulation: "runtime_data",
12449
+ copyMode: "none",
12450
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
12451
+ },
12452
+ {
12453
+ component: "kernel",
12454
+ table: "worktrees",
12455
+ prepopulation: "runtime_data",
12456
+ copyMode: "none",
12457
+ description: "Worktrees are tenant/runtime planning data."
12458
+ },
12459
+ {
12460
+ component: "identity",
12461
+ table: "agents",
12462
+ prepopulation: "runtime_bootstrap",
12463
+ copyMode: "none",
12464
+ description: "Service agents are provisioned per tenant or service, not copied."
12465
+ },
12466
+ {
12467
+ component: "identity",
12468
+ table: "mcpWritePolicy",
12469
+ prepopulation: "required_template",
12470
+ copyMode: "template_global",
12471
+ scope: "global",
12472
+ uniqueKey: ["topicId", "role", "toolCategory"],
12473
+ description: "Global write policy defaults govern service and interactive MCP writes."
12474
+ },
12475
+ {
12476
+ component: "identity",
12477
+ table: "modelCallLogs",
12478
+ prepopulation: "runtime_log",
12479
+ copyMode: "none",
12480
+ description: "Model call logs are runtime telemetry."
12481
+ },
12482
+ {
12483
+ component: "identity",
12484
+ table: "modelFunctionSlots",
12485
+ prepopulation: "required_template",
12486
+ copyMode: "template_global",
12487
+ scope: "global",
12488
+ uniqueKey: ["slot"],
12489
+ description: "Function-to-model slots are required by model runtime resolution."
12490
+ },
12491
+ {
12492
+ component: "identity",
12493
+ table: "modelRegistry",
12494
+ prepopulation: "required_template",
12495
+ copyMode: "template_global",
12496
+ scope: "global",
12497
+ uniqueKey: ["key"],
12498
+ description: "Model catalog defaults are required by model runtime clients."
12499
+ },
12500
+ {
12501
+ component: "identity",
12502
+ table: "modelSlotConfigs",
12503
+ prepopulation: "required_template",
12504
+ copyMode: "template_global",
12505
+ scope: "global",
12506
+ uniqueKey: ["slot"],
12507
+ description: "Slot-level defaults are required before tenant overrides exist."
12508
+ },
12509
+ {
12510
+ component: "identity",
12511
+ table: "platformAudienceGrants",
12512
+ prepopulation: "runtime_data",
12513
+ copyMode: "none",
12514
+ description: "Audience grants are principal/group-specific access rows."
12515
+ },
12516
+ {
12517
+ component: "identity",
12518
+ table: "platformAudiences",
12519
+ prepopulation: "required_template",
12520
+ copyMode: "template_tenant_rewrite",
12521
+ scope: "tenant",
12522
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
12523
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
12524
+ },
12525
+ {
12526
+ component: "identity",
12527
+ table: "platformPolicyDecisionLogs",
12528
+ prepopulation: "runtime_log",
12529
+ copyMode: "none",
12530
+ description: "Policy decisions are runtime audit logs."
12531
+ },
12532
+ {
12533
+ component: "identity",
12534
+ table: "projectGrants",
12535
+ prepopulation: "runtime_data",
12536
+ copyMode: "none",
12537
+ description: "Project/topic grants are principal or group-specific access rows."
12538
+ },
12539
+ {
12540
+ component: "identity",
12541
+ table: "reasoningPermissions",
12542
+ prepopulation: "runtime_data",
12543
+ copyMode: "none",
12544
+ description: "Reasoning permissions are principal-specific policy rows."
12545
+ },
12546
+ {
12547
+ component: "identity",
12548
+ table: "tenantApiKeys",
12549
+ prepopulation: "runtime_secret",
12550
+ copyMode: "none",
12551
+ description: "API keys are tenant credentials and must never be copied."
12552
+ },
12553
+ {
12554
+ component: "identity",
12555
+ table: "tenantConfig",
12556
+ prepopulation: "required_template",
12557
+ copyMode: "template_tenant_rewrite",
12558
+ scope: "tenant",
12559
+ uniqueKey: ["tenantId"],
12560
+ description: "Tenant-local config defaults are rewritten during bootstrap."
12561
+ },
12562
+ {
12563
+ component: "identity",
12564
+ table: "tenantIntegrations",
12565
+ prepopulation: "required_template",
12566
+ copyMode: "template_tenant_rewrite",
12567
+ scope: "tenant",
12568
+ uniqueKey: ["tenantId", "integrationKey"],
12569
+ description: "Non-secret integration descriptors are rewritten into each tenant."
12570
+ },
12571
+ {
12572
+ component: "identity",
12573
+ table: "tenantModelSlotBindings",
12574
+ prepopulation: "runtime_secret",
12575
+ copyMode: "none",
12576
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
12577
+ },
12578
+ {
12579
+ component: "identity",
12580
+ table: "tenantPolicies",
12581
+ prepopulation: "required_template",
12582
+ copyMode: "template_tenant_rewrite",
12583
+ scope: "tenant",
12584
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
12585
+ description: "Default tenant policy roles are rewritten during bootstrap."
12586
+ },
12587
+ {
12588
+ component: "identity",
12589
+ table: "tenantProviderSecrets",
12590
+ prepopulation: "runtime_secret",
12591
+ copyMode: "none",
12592
+ description: "Provider secrets are credentials and must never be copied."
12593
+ },
12594
+ {
12595
+ component: "identity",
12596
+ table: "tenantProxyGatewayUsage",
12597
+ prepopulation: "runtime_log",
12598
+ copyMode: "none",
12599
+ description: "Proxy gateway usage rows are runtime telemetry."
12600
+ },
12601
+ {
12602
+ component: "identity",
12603
+ table: "tenantProxyTokenMints",
12604
+ prepopulation: "runtime_secret",
12605
+ copyMode: "none",
12606
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
12607
+ },
12608
+ {
12609
+ component: "identity",
12610
+ table: "tenantSandboxAuditEvents",
12611
+ prepopulation: "runtime_log",
12612
+ copyMode: "none",
12613
+ description: "Sandbox audit rows are runtime security logs."
12614
+ },
12615
+ {
12616
+ component: "identity",
12617
+ table: "tenantSecrets",
12618
+ prepopulation: "runtime_secret",
12619
+ copyMode: "none",
12620
+ description: "Tenant secrets are credentials and must never be copied."
12621
+ },
12622
+ {
12623
+ component: "identity",
12624
+ table: "toolAcls",
12625
+ prepopulation: "required_template",
12626
+ copyMode: "template_global",
12627
+ scope: "global",
12628
+ uniqueKey: ["role", "toolName"],
12629
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
12630
+ },
12631
+ {
12632
+ component: "identity",
12633
+ table: "toolRegistry",
12634
+ prepopulation: "required_template",
12635
+ copyMode: "template_global",
12636
+ scope: "global",
12637
+ uniqueKey: ["toolName"],
12638
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
12639
+ },
12640
+ {
12641
+ component: "identity",
12642
+ table: "users",
12643
+ prepopulation: "runtime_bootstrap",
12644
+ copyMode: "none",
12645
+ description: "Users are created from Clerk/MC principal resolution, not copied."
12646
+ }
12647
+ ];
12648
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
12649
+ isCopyableSeedRequirement
12650
+ );
12651
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
12652
+ (entry) => !isCopyableSeedRequirement(entry)
12653
+ ).map((entry) => entry.table);
12654
+
11441
12655
  // src/webhooks.ts
11442
12656
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
11443
12657
  function normalizeUrl(url) {