@lucern/events 0.3.0-alpha.2 → 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
@@ -1849,6 +1849,40 @@ defineTable({
1849
1849
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
1850
1850
  ]
1851
1851
  });
1852
+ defineTable({
1853
+ name: "oauthDeviceCodes",
1854
+ component: "mc",
1855
+ category: "identity",
1856
+ shape: z.object({
1857
+ "deviceCodeHash": z.string(),
1858
+ "userCode": z.string(),
1859
+ "clientId": z.string(),
1860
+ "scope": z.string(),
1861
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
1862
+ "expiresAt": z.number(),
1863
+ "intervalSeconds": z.number(),
1864
+ "lastPolledAt": z.number().optional(),
1865
+ "slowDownCount": z.number().optional(),
1866
+ "clerkUserId": z.string().optional(),
1867
+ "tenantId": idOf("tenants").optional(),
1868
+ "workspaceId": z.string().optional(),
1869
+ "principalId": z.string().optional(),
1870
+ "role": z.string().optional(),
1871
+ "scopes": z.array(z.string()).optional(),
1872
+ "sessionId": z.string().optional(),
1873
+ "approvedAt": z.number().optional(),
1874
+ "deniedAt": z.number().optional(),
1875
+ "consumedAt": z.number().optional(),
1876
+ "createdAt": z.number(),
1877
+ "updatedAt": z.number()
1878
+ }),
1879
+ indices: [
1880
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
1881
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
1882
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
1883
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
1884
+ ]
1885
+ });
1852
1886
  defineTable({
1853
1887
  name: "servicePrincipalKeys",
1854
1888
  component: "mc",
@@ -3805,7 +3839,9 @@ defineTable({
3805
3839
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3806
3840
  "deployments": z.record(z.object({
3807
3841
  "url": z.string(),
3808
- "encryptedDeployKey": z.string()
3842
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
3843
+ "encryptedDeployKey": z.string().optional(),
3844
+ "credentialRef": z.string().optional()
3809
3845
  })).optional(),
3810
3846
  "metadata": z.record(z.any()).optional(),
3811
3847
  "createdBy": z.string().optional(),
@@ -5002,6 +5038,14 @@ var ADD_WORKTREE = {
5002
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.",
5003
5039
  parameters: {
5004
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
+ },
5005
5049
  topicId: { type: "string", description: "Optional topic scope hint" },
5006
5050
  branchId: {
5007
5051
  type: "string",
@@ -5015,14 +5059,87 @@ var ADD_WORKTREE = {
5015
5059
  type: "string",
5016
5060
  description: "The testable claim this worktree investigates"
5017
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
+ },
5018
5095
  beliefIds: {
5019
5096
  type: "array",
5020
- 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"
5021
5134
  },
5022
5135
  autoShape: {
5023
5136
  type: "boolean",
5024
5137
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5025
5138
  },
5139
+ autoFixPolicy: {
5140
+ type: "object",
5141
+ description: "Policy for permitted automatic remediation inside the worktree"
5142
+ },
5026
5143
  domainPackId: {
5027
5144
  type: "string",
5028
5145
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
@@ -5051,9 +5168,17 @@ var ADD_WORKTREE = {
5051
5168
  type: "array",
5052
5169
  description: "Worktree IDs blocked by this worktree"
5053
5170
  },
5054
- gate: {
5171
+ staffingHint: {
5055
5172
  type: "string",
5056
- 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"
5057
5182
  }
5058
5183
  },
5059
5184
  required: ["title", "topicId"],
@@ -5083,7 +5208,7 @@ var MERGE = {
5083
5208
  worktreeId: { type: "string", description: "The worktree to merge" },
5084
5209
  outcomes: {
5085
5210
  type: "array",
5086
- 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 }"
5087
5212
  },
5088
5213
  summary: { type: "string", description: "Overall findings summary" }
5089
5214
  },
@@ -8102,6 +8227,69 @@ var GENERATE_SESSION_HANDOFF = {
8102
8227
  tier: "showcase",
8103
8228
  internal: true
8104
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
+ };
8105
8293
  var MCP_TOOL_CONTRACTS = {
8106
8294
  // Belief lifecycle (commit, amend, fork, archive)
8107
8295
  create_belief: CREATE_BELIEF,
@@ -8195,6 +8383,7 @@ var MCP_TOOL_CONTRACTS = {
8195
8383
  get_agent_inbox: GET_AGENT_INBOX,
8196
8384
  claim_files: CLAIM_FILES,
8197
8385
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
8386
+ begin_build_session: BEGIN_BUILD_SESSION,
8198
8387
  // Policy / ACL (workhorse)
8199
8388
  check_permission: CHECK_PERMISSION,
8200
8389
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8408,6 +8597,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8408
8597
  "get_change_history",
8409
8598
  "get_failure_log",
8410
8599
  "record_attempt",
8600
+ "begin_build_session",
8411
8601
  "push",
8412
8602
  "open_pull_request",
8413
8603
  "record_judgment",
@@ -8462,7 +8652,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8462
8652
  "find_semantic_orphans"
8463
8653
  ];
8464
8654
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8465
- "begin_build_session",
8466
8655
  "evaluate_engineering_contract",
8467
8656
  "evaluate_research_contract"
8468
8657
  ];
@@ -8848,8 +9037,31 @@ function assertSurfaceCoverage(contracts) {
8848
9037
  }
8849
9038
  }
8850
9039
  }
8851
-
8852
- // ../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
+ });
8853
9065
  var observationInput = (input, context) => withUserId(
8854
9066
  compactRecord4({
8855
9067
  projectId: input.projectId,
@@ -8908,7 +9120,8 @@ var contextContracts = [
8908
9120
  observationId: output && typeof output === "object" ? output.nodeId : void 0,
8909
9121
  observationType: input.observationType
8910
9122
  })
8911
- }
9123
+ },
9124
+ args: observationArgs
8912
9125
  }),
8913
9126
  surfaceContract({
8914
9127
  name: "get_observation_context",
@@ -8929,7 +9142,8 @@ var contextContracts = [
8929
9142
  status: input.status,
8930
9143
  userId: input.userId
8931
9144
  })
8932
- }
9145
+ },
9146
+ args: observationContextArgs
8933
9147
  })
8934
9148
  ];
8935
9149
 
@@ -8992,8 +9206,45 @@ var identityContracts = [
8992
9206
  }
8993
9207
  })
8994
9208
  ];
8995
-
8996
- // ../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
+ });
8997
9248
  var beliefLookupInput = (input) => compactRecord4({
8998
9249
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
8999
9250
  beliefId: input.beliefId
@@ -9068,7 +9319,8 @@ var beliefsContracts = [
9068
9319
  functionName: "create",
9069
9320
  kind: "mutation",
9070
9321
  inputProjection: createBeliefInput
9071
- }
9322
+ },
9323
+ args: createBeliefArgs
9072
9324
  }),
9073
9325
  surfaceContract({
9074
9326
  name: "get_belief",
@@ -9159,7 +9411,8 @@ var beliefsContracts = [
9159
9411
  functionName: "forkBelief",
9160
9412
  kind: "mutation",
9161
9413
  inputProjection: forkBeliefInput
9162
- }
9414
+ },
9415
+ args: forkBeliefArgs
9163
9416
  }),
9164
9417
  surfaceContract({
9165
9418
  name: "archive_belief",
@@ -9240,8 +9493,46 @@ var beliefsContracts = [
9240
9493
  }
9241
9494
  })
9242
9495
  ];
9243
-
9244
- // ../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
+ });
9245
9536
  var evidenceIdInput = (input) => compactRecord4({
9246
9537
  evidenceId: input.evidenceId,
9247
9538
  insightId: input.insightId,
@@ -9316,7 +9607,8 @@ var evidenceContracts = [
9316
9607
  functionName: "create",
9317
9608
  kind: "mutation",
9318
9609
  inputProjection: createEvidenceInput
9319
- }
9610
+ },
9611
+ args: createEvidenceArgs
9320
9612
  }),
9321
9613
  surfaceContract({
9322
9614
  name: "add_evidence",
@@ -9352,7 +9644,8 @@ var evidenceContracts = [
9352
9644
  context
9353
9645
  );
9354
9646
  }
9355
- }
9647
+ },
9648
+ args: addEvidenceArgs
9356
9649
  }),
9357
9650
  surfaceContract({
9358
9651
  name: "get_evidence",
@@ -9459,8 +9752,91 @@ var evidenceContracts = [
9459
9752
  }
9460
9753
  })
9461
9754
  ];
9462
-
9463
- // ../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
+ });
9464
9840
  var questionNodeInput = (input) => compactRecord4({
9465
9841
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9466
9842
  questionId: input.questionId
@@ -9507,7 +9883,8 @@ var questionsContracts = [
9507
9883
  functionName: "create",
9508
9884
  kind: "mutation",
9509
9885
  inputProjection: createQuestionInput
9510
- }
9886
+ },
9887
+ args: createQuestionArgs
9511
9888
  }),
9512
9889
  surfaceContract({
9513
9890
  name: "get_question",
@@ -9563,7 +9940,8 @@ var questionsContracts = [
9563
9940
  category: input.category,
9564
9941
  priority: input.priority
9565
9942
  })
9566
- }
9943
+ },
9944
+ args: refineQuestionArgs
9567
9945
  }),
9568
9946
  surfaceContract({
9569
9947
  name: "update_question_status",
@@ -9639,7 +10017,8 @@ var questionsContracts = [
9639
10017
  }),
9640
10018
  context
9641
10019
  )
9642
- }
10020
+ },
10021
+ args: createAnswerArgs
9643
10022
  }),
9644
10023
  surfaceContract({
9645
10024
  name: "answer_question",
@@ -9668,7 +10047,8 @@ var questionsContracts = [
9668
10047
  }),
9669
10048
  context
9670
10049
  )
9671
- }
10050
+ },
10051
+ args: answerQuestionArgs
9672
10052
  }),
9673
10053
  surfaceContract({
9674
10054
  name: "get_answer",
@@ -9700,7 +10080,8 @@ var questionsContracts = [
9700
10080
  functionName: "getByTopic",
9701
10081
  kind: "query",
9702
10082
  inputProjection: questionTopicInput
9703
- }
10083
+ },
10084
+ args: missingQuestionsArgs
9704
10085
  }),
9705
10086
  surfaceContract({
9706
10087
  name: "get_high_priority_questions",
@@ -9735,11 +10116,22 @@ var questionsContracts = [
9735
10116
  functionName: "getByTopic",
9736
10117
  kind: "query",
9737
10118
  inputProjection: questionTopicInput
9738
- }
10119
+ },
10120
+ args: falsificationQuestionsArgs
9739
10121
  })
9740
10122
  ];
9741
-
9742
- // ../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
+ });
9743
10135
  var topicIdInput = (input) => compactRecord4({
9744
10136
  id: input.id ?? input.topicId
9745
10137
  });
@@ -9820,7 +10212,8 @@ var topicsContracts = [
9820
10212
  functionName: "update",
9821
10213
  kind: "mutation",
9822
10214
  inputProjection: updateTopicInput
9823
- }
10215
+ },
10216
+ args: updateTopicArgs
9824
10217
  }),
9825
10218
  surfaceContract({
9826
10219
  name: "get_topic_tree",
@@ -9839,8 +10232,27 @@ var topicsContracts = [
9839
10232
  }
9840
10233
  })
9841
10234
  ];
9842
-
9843
- // ../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
+ });
9844
10256
  var createLensInput = (input, context) => compactRecord4({
9845
10257
  name: input.name,
9846
10258
  description: input.description,
@@ -9877,7 +10289,8 @@ var lensesContracts = [
9877
10289
  functionName: "create",
9878
10290
  kind: "mutation",
9879
10291
  inputProjection: createLensInput
9880
- }
10292
+ },
10293
+ args: createLensArgs
9881
10294
  }),
9882
10295
  surfaceContract({
9883
10296
  name: "list_lenses",
@@ -9939,8 +10352,18 @@ var lensesContracts = [
9939
10352
  }
9940
10353
  })
9941
10354
  ];
9942
-
9943
- // ../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
+ });
9944
10367
  var ontologyIdInput = (input) => compactRecord4({
9945
10368
  id: input.id ?? input.ontologyId
9946
10369
  });
@@ -10019,11 +10442,11 @@ var ontologiesContracts = [
10019
10442
  id: input.id ?? input.ontologyId,
10020
10443
  name: input.name,
10021
10444
  description: input.description,
10022
- parentOntologyId: input.parentOntologyId,
10023
10445
  status: input.status,
10024
10446
  actorId: input.actorId
10025
10447
  })
10026
- }
10448
+ },
10449
+ args: updateOntologyArgs
10027
10450
  }),
10028
10451
  surfaceContract({
10029
10452
  name: "archive_ontology",
@@ -10106,7 +10529,8 @@ var ontologiesContracts = [
10106
10529
  functionName: "publishOntologyVersion",
10107
10530
  kind: "mutation",
10108
10531
  inputProjection: ontologyVersionIdInput
10109
- }
10532
+ },
10533
+ args: ontologyVersionLifecycleArgs
10110
10534
  }),
10111
10535
  surfaceContract({
10112
10536
  name: "deprecate_ontology_version",
@@ -10122,7 +10546,8 @@ var ontologiesContracts = [
10122
10546
  functionName: "deprecateOntologyVersion",
10123
10547
  kind: "mutation",
10124
10548
  inputProjection: ontologyVersionIdInput
10125
- }
10549
+ },
10550
+ args: ontologyVersionLifecycleArgs
10126
10551
  }),
10127
10552
  surfaceContract({
10128
10553
  name: "resolve_effective_ontology",
@@ -10141,8 +10566,76 @@ var ontologiesContracts = [
10141
10566
  }
10142
10567
  })
10143
10568
  ];
10144
-
10145
- // ../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
+ });
10146
10639
  var worktreeIdInput = (input) => compactRecord4({
10147
10640
  worktreeId: input.worktreeId ?? input.id
10148
10641
  });
@@ -10175,6 +10668,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10175
10668
  autoFixPolicy: input.autoFixPolicy,
10176
10669
  lastReconciledAt: input.lastReconciledAt
10177
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
+ };
10178
10715
  var listAllWorktreesInput = (input) => compactRecord4({
10179
10716
  status: input.status,
10180
10717
  lane: input.lane,
@@ -10182,6 +10719,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10182
10719
  limit: input.limit
10183
10720
  });
10184
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
+ }),
10185
10732
  surfaceContract({
10186
10733
  name: "add_worktree",
10187
10734
  kind: "mutation",
@@ -10198,13 +10745,12 @@ var worktreesContracts = [
10198
10745
  inputProjection: (input, context) => withCreatedBy(
10199
10746
  compactRecord4({
10200
10747
  name: input.name ?? input.title,
10201
- topicId: input.topicId,
10748
+ topicId: input.topicId ?? input.projectId,
10202
10749
  worktreeType: input.worktreeType,
10203
10750
  objective: input.objective,
10204
10751
  gate: input.gate,
10205
10752
  hypothesis: input.hypothesis,
10206
10753
  rationale: input.rationale,
10207
- signal: input.signal,
10208
10754
  startDate: input.startDate,
10209
10755
  endDate: input.endDate,
10210
10756
  durationWeeks: input.durationWeeks,
@@ -10230,12 +10776,12 @@ var worktreesContracts = [
10230
10776
  staffingHint: input.staffingHint,
10231
10777
  domainPackId: input.domainPackId,
10232
10778
  lensId: input.lensId,
10233
- linkedQuestionId: input.linkedQuestionId,
10234
10779
  lastReconciledAt: input.lastReconciledAt
10235
10780
  }),
10236
10781
  context
10237
10782
  )
10238
- }
10783
+ },
10784
+ args: addWorktreeArgs
10239
10785
  }),
10240
10786
  surfaceContract({
10241
10787
  name: "activate_worktree",
@@ -10347,7 +10893,8 @@ var worktreesContracts = [
10347
10893
  functionName: "updateMetadata",
10348
10894
  kind: "mutation",
10349
10895
  inputProjection: worktreeMetadataInput
10350
- }
10896
+ },
10897
+ args: worktreeMetadataArgs
10351
10898
  }),
10352
10899
  surfaceContract({
10353
10900
  name: "merge",
@@ -10365,9 +10912,7 @@ var worktreesContracts = [
10365
10912
  inputProjection: (input, context) => withUserId(
10366
10913
  {
10367
10914
  ...worktreeIdInput(input),
10368
- keyFindings: input.keyFindings ?? [
10369
- input.summary ?? "Merged worktree"
10370
- ],
10915
+ keyFindings: mergeKeyFindingsInput(input),
10371
10916
  decisionsReached: input.decisionsReached ?? [],
10372
10917
  nextSteps: input.nextSteps ?? []
10373
10918
  },
@@ -10389,7 +10934,8 @@ var worktreesContracts = [
10389
10934
  functionName: "updateMetadata",
10390
10935
  kind: "mutation",
10391
10936
  inputProjection: worktreeMetadataInput
10392
- }
10937
+ },
10938
+ args: pushArgs
10393
10939
  }),
10394
10940
  surfaceContract({
10395
10941
  name: "open_pull_request",
@@ -10405,7 +10951,8 @@ var worktreesContracts = [
10405
10951
  functionName: "updateMetadata",
10406
10952
  kind: "mutation",
10407
10953
  inputProjection: worktreeMetadataInput
10408
- }
10954
+ },
10955
+ args: openPullRequestArgs
10409
10956
  })
10410
10957
  ];
10411
10958
 
@@ -10509,6 +11056,15 @@ var createEdgeArgs = z.object({
10509
11056
  topicId: z.string().optional(),
10510
11057
  trustedBypassAccessCheck: z.boolean().optional()
10511
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
+ });
10512
11068
  function graphRefNodeId(ref) {
10513
11069
  if (ref.kind === "epistemic_node") {
10514
11070
  return ref.nodeId;
@@ -10579,11 +11135,59 @@ var edgesContracts = [
10579
11135
  minLayer: input.minLayer,
10580
11136
  maxLayer: input.maxLayer
10581
11137
  })
10582
- }
11138
+ },
11139
+ args: queryLineageArgs
10583
11140
  })
10584
11141
  ];
10585
-
10586
- // ../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
+ });
10587
11191
  var contradictionSeverity = (value) => {
10588
11192
  switch (value) {
10589
11193
  case "critical":
@@ -10638,7 +11242,8 @@ var graphContracts = [
10638
11242
  functionName: "getLineage",
10639
11243
  kind: "query",
10640
11244
  inputProjection: lineageInput
10641
- }
11245
+ },
11246
+ args: traverseGraphArgs
10642
11247
  }),
10643
11248
  surfaceContract({
10644
11249
  name: "get_graph_neighborhood",
@@ -10654,7 +11259,8 @@ var graphContracts = [
10654
11259
  functionName: "getByTopic",
10655
11260
  kind: "query",
10656
11261
  inputProjection: topicEdgesInput
10657
- }
11262
+ },
11263
+ args: graphNeighborhoodArgs
10658
11264
  }),
10659
11265
  surfaceContract({
10660
11266
  name: "get_graph_structure_analysis",
@@ -10703,7 +11309,8 @@ var graphContracts = [
10703
11309
  functionName: "create",
10704
11310
  kind: "mutation",
10705
11311
  inputProjection: flagContradictionInput
10706
- }
11312
+ },
11313
+ args: flagContradictionArgs
10707
11314
  }),
10708
11315
  surfaceContract({
10709
11316
  name: "detect_confirmation_bias",
@@ -10794,7 +11401,8 @@ var graphContracts = [
10794
11401
  functionName: "getLineage",
10795
11402
  kind: "query",
10796
11403
  inputProjection: lineageInput
10797
- }
11404
+ },
11405
+ args: discoverEntityConnectionsArgs
10798
11406
  }),
10799
11407
  surfaceContract({
10800
11408
  name: "trigger_belief_review",
@@ -10825,7 +11433,8 @@ var graphContracts = [
10825
11433
  functionName: "getLineage",
10826
11434
  kind: "query",
10827
11435
  inputProjection: lineageInput
10828
- }
11436
+ },
11437
+ args: lineageArgs
10829
11438
  })
10830
11439
  ];
10831
11440
 
@@ -10877,8 +11486,16 @@ var contractsContracts = [
10877
11486
  }
10878
11487
  })
10879
11488
  ];
10880
-
10881
- // ../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
+ });
10882
11499
  var judgmentsContracts = [
10883
11500
  surfaceContract({
10884
11501
  name: "record_judgment",
@@ -10933,7 +11550,8 @@ var judgmentsContracts = [
10933
11550
  minLayer: input.minLayer,
10934
11551
  maxLayer: input.maxLayer
10935
11552
  })
10936
- }
11553
+ },
11554
+ args: auditTrailArgs
10937
11555
  })
10938
11556
  ];
10939
11557
 
@@ -11101,8 +11719,13 @@ var coordinationContracts = [
11101
11719
  }
11102
11720
  })
11103
11721
  ];
11104
-
11105
- // ../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
+ });
11106
11729
  var pipelineContracts = [
11107
11730
  surfaceContract({
11108
11731
  name: "pipeline_snapshot",
@@ -11123,7 +11746,8 @@ var pipelineContracts = [
11123
11746
  campaign: input.campaign,
11124
11747
  limit: input.limit
11125
11748
  })
11126
- }
11749
+ },
11750
+ args: pipelineSnapshotArgs
11127
11751
  }),
11128
11752
  surfaceContract({
11129
11753
  name: "seed_belief_lattice",
@@ -11175,7 +11799,31 @@ var recordScopeLearningArgs = z.object({
11175
11799
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11176
11800
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11177
11801
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11178
- 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.")
11179
11827
  });
11180
11828
  var learningInput = (input, context) => {
11181
11829
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11292,7 +11940,8 @@ var codingContracts = [
11292
11940
  status: input.status,
11293
11941
  userId: input.userId
11294
11942
  })
11295
- }
11943
+ },
11944
+ args: codeContextArgs
11296
11945
  }),
11297
11946
  surfaceContract({
11298
11947
  name: "get_change_history",
@@ -11329,7 +11978,8 @@ var codingContracts = [
11329
11978
  functionName: "create",
11330
11979
  kind: "mutation",
11331
11980
  inputProjection: attemptInput
11332
- }
11981
+ },
11982
+ args: recordAttemptArgs
11333
11983
  }),
11334
11984
  surfaceContract({
11335
11985
  name: "get_failure_log",
@@ -11404,6 +12054,604 @@ new Map(
11404
12054
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11405
12055
  );
11406
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
+
11407
12655
  // src/webhooks.ts
11408
12656
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
11409
12657
  function normalizeUrl(url) {