@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/index.js CHANGED
@@ -2004,6 +2004,40 @@ defineTable({
2004
2004
  { kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
2005
2005
  ]
2006
2006
  });
2007
+ defineTable({
2008
+ name: "oauthDeviceCodes",
2009
+ component: "mc",
2010
+ category: "identity",
2011
+ shape: z.object({
2012
+ "deviceCodeHash": z.string(),
2013
+ "userCode": z.string(),
2014
+ "clientId": z.string(),
2015
+ "scope": z.string(),
2016
+ "status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
2017
+ "expiresAt": z.number(),
2018
+ "intervalSeconds": z.number(),
2019
+ "lastPolledAt": z.number().optional(),
2020
+ "slowDownCount": z.number().optional(),
2021
+ "clerkUserId": z.string().optional(),
2022
+ "tenantId": idOf("tenants").optional(),
2023
+ "workspaceId": z.string().optional(),
2024
+ "principalId": z.string().optional(),
2025
+ "role": z.string().optional(),
2026
+ "scopes": z.array(z.string()).optional(),
2027
+ "sessionId": z.string().optional(),
2028
+ "approvedAt": z.number().optional(),
2029
+ "deniedAt": z.number().optional(),
2030
+ "consumedAt": z.number().optional(),
2031
+ "createdAt": z.number(),
2032
+ "updatedAt": z.number()
2033
+ }),
2034
+ indices: [
2035
+ { kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
2036
+ { kind: "index", name: "by_userCode", columns: ["userCode"] },
2037
+ { kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
2038
+ { kind: "index", name: "by_sessionId", columns: ["sessionId"] }
2039
+ ]
2040
+ });
2007
2041
  defineTable({
2008
2042
  name: "servicePrincipalKeys",
2009
2043
  component: "mc",
@@ -3960,7 +3994,9 @@ defineTable({
3960
3994
  "defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
3961
3995
  "deployments": z.record(z.object({
3962
3996
  "url": z.string(),
3963
- "encryptedDeployKey": z.string()
3997
+ "target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
3998
+ "encryptedDeployKey": z.string().optional(),
3999
+ "credentialRef": z.string().optional()
3964
4000
  })).optional(),
3965
4001
  "metadata": z.record(z.any()).optional(),
3966
4002
  "createdBy": z.string().optional(),
@@ -5157,6 +5193,14 @@ var ADD_WORKTREE = {
5157
5193
  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.",
5158
5194
  parameters: {
5159
5195
  title: { type: "string", description: "Worktree name/objective" },
5196
+ name: {
5197
+ type: "string",
5198
+ description: "Optional storage-name alias for callers that already use backend naming"
5199
+ },
5200
+ projectId: {
5201
+ type: "string",
5202
+ description: "Legacy topicId alias"
5203
+ },
5160
5204
  topicId: { type: "string", description: "Optional topic scope hint" },
5161
5205
  branchId: {
5162
5206
  type: "string",
@@ -5170,14 +5214,87 @@ var ADD_WORKTREE = {
5170
5214
  type: "string",
5171
5215
  description: "The testable claim this worktree investigates"
5172
5216
  },
5217
+ rationale: {
5218
+ type: "string",
5219
+ description: "Why this worktree exists and why it belongs in the campaign"
5220
+ },
5221
+ worktreeType: {
5222
+ type: "string",
5223
+ description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
5224
+ },
5225
+ gate: {
5226
+ type: "string",
5227
+ description: "Exit gate name for this worktree"
5228
+ },
5229
+ startDate: {
5230
+ type: "number",
5231
+ description: "Planned start timestamp in milliseconds since epoch"
5232
+ },
5233
+ endDate: {
5234
+ type: "number",
5235
+ description: "Planned end timestamp in milliseconds since epoch"
5236
+ },
5237
+ durationWeeks: {
5238
+ type: "number",
5239
+ description: "Planned duration in weeks"
5240
+ },
5241
+ confidenceImpact: {
5242
+ type: "string",
5243
+ description: "Expected confidence impact if the worktree succeeds",
5244
+ enum: ["high", "medium", "low"]
5245
+ },
5246
+ beliefFocus: {
5247
+ type: "string",
5248
+ description: "Natural-language focus spanning the target belief neighborhood"
5249
+ },
5173
5250
  beliefIds: {
5174
5251
  type: "array",
5175
- description: "Beliefs to test in this worktree"
5252
+ description: "Legacy alias for targetBeliefIds"
5253
+ },
5254
+ beliefs: {
5255
+ type: "array",
5256
+ description: "Legacy alias for targetBeliefIds"
5257
+ },
5258
+ targetBeliefIds: {
5259
+ type: "array",
5260
+ description: "Belief node IDs this worktree is expected to test or update"
5261
+ },
5262
+ targetQuestionIds: {
5263
+ type: "array",
5264
+ description: "Question node IDs this worktree is expected to answer"
5265
+ },
5266
+ keyQuestions: {
5267
+ type: "array",
5268
+ description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
5269
+ },
5270
+ evidenceSignals: {
5271
+ type: "array",
5272
+ description: "Evidence signal objects with signal, optional collected state, progress, and notes"
5273
+ },
5274
+ decisionGate: {
5275
+ type: "object",
5276
+ description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
5277
+ },
5278
+ goCriteria: {
5279
+ type: "array",
5280
+ description: "Shorthand go criteria used to build decisionGate"
5281
+ },
5282
+ noGoSignals: {
5283
+ type: "array",
5284
+ description: "Shorthand no-go signals used to build decisionGate"
5285
+ },
5286
+ proofArtifacts: {
5287
+ type: "array",
5288
+ description: "Expected proof artifacts required to close the worktree"
5176
5289
  },
5177
5290
  autoShape: {
5178
5291
  type: "boolean",
5179
5292
  description: "Whether to invoke inquiry auto-shaping during worktree creation"
5180
5293
  },
5294
+ autoFixPolicy: {
5295
+ type: "object",
5296
+ description: "Policy for permitted automatic remediation inside the worktree"
5297
+ },
5181
5298
  domainPackId: {
5182
5299
  type: "string",
5183
5300
  description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
@@ -5206,9 +5323,17 @@ var ADD_WORKTREE = {
5206
5323
  type: "array",
5207
5324
  description: "Worktree IDs blocked by this worktree"
5208
5325
  },
5209
- gate: {
5326
+ staffingHint: {
5210
5327
  type: "string",
5211
- description: "Exit gate name for this worktree"
5328
+ description: "Suggested staffing or agent allocation note"
5329
+ },
5330
+ lensId: {
5331
+ type: "string",
5332
+ description: "Lens that scopes this worktree when applicable"
5333
+ },
5334
+ lastReconciledAt: {
5335
+ type: "number",
5336
+ description: "Timestamp when worktree metadata was last reconciled"
5212
5337
  }
5213
5338
  },
5214
5339
  required: ["title", "topicId"],
@@ -5238,7 +5363,7 @@ var MERGE = {
5238
5363
  worktreeId: { type: "string", description: "The worktree to merge" },
5239
5364
  outcomes: {
5240
5365
  type: "array",
5241
- description: "Scoring outcomes for each belief: { beliefId, confidence, rationale }"
5366
+ description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
5242
5367
  },
5243
5368
  summary: { type: "string", description: "Overall findings summary" }
5244
5369
  },
@@ -8257,6 +8382,69 @@ var GENERATE_SESSION_HANDOFF = {
8257
8382
  tier: "showcase",
8258
8383
  internal: true
8259
8384
  };
8385
+ var BEGIN_BUILD_SESSION = {
8386
+ name: "begin_build_session",
8387
+ 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.",
8388
+ parameters: {
8389
+ worktreeId: {
8390
+ type: "string",
8391
+ description: "The Lucern worktree ID to bootstrap."
8392
+ },
8393
+ branch: {
8394
+ type: "string",
8395
+ description: "Optional git branch name. Auto-generated from the worktree name when omitted."
8396
+ },
8397
+ branchBase: {
8398
+ type: "string",
8399
+ description: 'Base branch for the feature branch. Default: "staging".'
8400
+ },
8401
+ prBase: {
8402
+ type: "string",
8403
+ description: 'Target branch for the PR. Default: "staging".'
8404
+ },
8405
+ sessionMode: {
8406
+ type: "string",
8407
+ description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
8408
+ enum: ["async", "interactive"]
8409
+ },
8410
+ activateIfPlanning: {
8411
+ type: "boolean",
8412
+ description: "When true, automatically activate a planning worktree during bootstrap."
8413
+ }
8414
+ },
8415
+ required: ["worktreeId"],
8416
+ response: {
8417
+ description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
8418
+ fields: {
8419
+ topicId: "string \u2014 canonical topic scope",
8420
+ topicName: "string \u2014 human-readable topic name",
8421
+ worktreeId: "string \u2014 worktree ID",
8422
+ worktreeName: "string \u2014 human-readable worktree name",
8423
+ branch: "string \u2014 git branch name",
8424
+ branchBase: "string \u2014 base branch",
8425
+ prBase: "string \u2014 PR target branch",
8426
+ campaign: "number | null \u2014 top-level pipeline campaign",
8427
+ lane: "string \u2014 campaign lane",
8428
+ gate: "string \u2014 exit gate",
8429
+ hypothesis: "string \u2014 worktree hypothesis",
8430
+ focus: "string \u2014 session focus",
8431
+ status: "string \u2014 worktree status after optional activation",
8432
+ sessionMode: "string \u2014 async | interactive",
8433
+ targetBeliefIds: "array \u2014 scoped belief IDs",
8434
+ targetQuestionIds: "array \u2014 scoped question IDs",
8435
+ topBeliefs: "array \u2014 highest-confidence scoped beliefs",
8436
+ openQuestions: "array \u2014 open scoped questions",
8437
+ resolvedDecisions: "array \u2014 answered questions summarized for the session",
8438
+ dependencies: "array \u2014 upstream worktrees",
8439
+ unblocks: "array \u2014 downstream worktrees",
8440
+ mergeOrderNotes: "string \u2014 merge ordering advisory"
8441
+ }
8442
+ },
8443
+ ownerModule: "bootstrap",
8444
+ ontologyPrimitive: "worktree",
8445
+ tier: "showcase",
8446
+ internal: true
8447
+ };
8260
8448
  var MCP_TOOL_CONTRACTS = {
8261
8449
  // Belief lifecycle (commit, amend, fork, archive)
8262
8450
  create_belief: CREATE_BELIEF,
@@ -8350,6 +8538,7 @@ var MCP_TOOL_CONTRACTS = {
8350
8538
  get_agent_inbox: GET_AGENT_INBOX,
8351
8539
  claim_files: CLAIM_FILES,
8352
8540
  generate_session_handoff: GENERATE_SESSION_HANDOFF,
8541
+ begin_build_session: BEGIN_BUILD_SESSION,
8353
8542
  // Policy / ACL (workhorse)
8354
8543
  check_permission: CHECK_PERMISSION,
8355
8544
  filter_by_permission: FILTER_BY_PERMISSION,
@@ -8563,6 +8752,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
8563
8752
  "get_change_history",
8564
8753
  "get_failure_log",
8565
8754
  "record_attempt",
8755
+ "begin_build_session",
8566
8756
  "push",
8567
8757
  "open_pull_request",
8568
8758
  "record_judgment",
@@ -8617,7 +8807,6 @@ var SDK_ONLY_OPERATION_NAMES = [
8617
8807
  "find_semantic_orphans"
8618
8808
  ];
8619
8809
  var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
8620
- "begin_build_session",
8621
8810
  "evaluate_engineering_contract",
8622
8811
  "evaluate_research_contract"
8623
8812
  ];
@@ -9003,8 +9192,31 @@ function assertSurfaceCoverage(contracts) {
9003
9192
  }
9004
9193
  }
9005
9194
  }
9006
-
9007
- // ../contracts/src/function-registry/context.ts
9195
+ var jsonRecordSchema2 = z.record(z.unknown());
9196
+ var observationArgs = z.object({
9197
+ topicId: z.string().optional().describe("Topic scope for the observation."),
9198
+ summary: z.string().describe("Short observation summary."),
9199
+ text: z.string().optional().describe("Canonical observation text alias."),
9200
+ title: z.string().optional().describe("Optional observation title."),
9201
+ content: z.string().optional().describe("Optional rich observation content."),
9202
+ contentType: z.string().optional().describe("Observation content type."),
9203
+ kind: z.string().optional().describe("Evidence kind to store."),
9204
+ observationType: z.string().optional().describe("Observation type."),
9205
+ tags: z.array(z.string()).optional().describe("Observation tags."),
9206
+ source: z.string().optional().describe("Observation source label."),
9207
+ sourceType: z.string().optional().describe("Evidence source type."),
9208
+ externalSourceType: z.string().optional().describe("External source type for imported observations."),
9209
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9210
+ confidence: z.number().optional().describe("Observation confidence."),
9211
+ metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
9212
+ rationale: z.string().optional().describe("Why this observation should be recorded.")
9213
+ });
9214
+ var observationContextArgs = z.object({
9215
+ topicId: z.string().describe("Topic scope."),
9216
+ query: z.string().optional().describe("Optional context query."),
9217
+ limit: z.number().optional().describe("Maximum observations to return."),
9218
+ status: z.string().optional().describe("Observation status filter.")
9219
+ });
9008
9220
  var observationInput = (input, context) => withUserId(
9009
9221
  compactRecord4({
9010
9222
  projectId: input.projectId,
@@ -9063,7 +9275,8 @@ var contextContracts = [
9063
9275
  observationId: output && typeof output === "object" ? output.nodeId : void 0,
9064
9276
  observationType: input.observationType
9065
9277
  })
9066
- }
9278
+ },
9279
+ args: observationArgs
9067
9280
  }),
9068
9281
  surfaceContract({
9069
9282
  name: "get_observation_context",
@@ -9084,7 +9297,8 @@ var contextContracts = [
9084
9297
  status: input.status,
9085
9298
  userId: input.userId
9086
9299
  })
9087
- }
9300
+ },
9301
+ args: observationContextArgs
9088
9302
  })
9089
9303
  ];
9090
9304
 
@@ -9147,8 +9361,45 @@ var identityContracts = [
9147
9361
  }
9148
9362
  })
9149
9363
  ];
9150
-
9151
- // ../contracts/src/function-registry/beliefs.ts
9364
+ var jsonRecordSchema3 = z.record(z.unknown());
9365
+ var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
9366
+ var reversibilitySchema = z.enum([
9367
+ "irreversible",
9368
+ "hard_to_reverse",
9369
+ "reversible",
9370
+ "trivial"
9371
+ ]);
9372
+ var predictionMetaSchema = z.object({
9373
+ isPrediction: z.boolean().describe("Whether this belief is a prediction."),
9374
+ registeredAt: z.number().describe("Timestamp when the prediction was registered."),
9375
+ expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
9376
+ });
9377
+ var createBeliefArgs = z.object({
9378
+ canonicalText: z.string().describe("The belief statement the agent holds to be true."),
9379
+ topicId: z.string().optional().describe("Topic scope hint for the belief."),
9380
+ baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
9381
+ beliefType: z.string().optional().describe("Schema belief type."),
9382
+ metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
9383
+ rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
9384
+ pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
9385
+ worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
9386
+ sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
9387
+ sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
9388
+ reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
9389
+ predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
9390
+ });
9391
+ var forkBeliefArgs = z.object({
9392
+ nodeId: z.string().describe("The scored belief to fork from."),
9393
+ newFormulation: z.string().describe("The evolved belief statement."),
9394
+ forkReason: z.enum([
9395
+ "refinement",
9396
+ "contradiction_response",
9397
+ "scope_change",
9398
+ "confidence_collapse",
9399
+ "manual"
9400
+ ]).describe("Why this fork was created."),
9401
+ rationale: z.string().optional().describe("Why the fork is warranted.")
9402
+ });
9152
9403
  var beliefLookupInput = (input) => compactRecord4({
9153
9404
  nodeId: input.nodeId ?? input.id ?? input.beliefId,
9154
9405
  beliefId: input.beliefId
@@ -9223,7 +9474,8 @@ var beliefsContracts = [
9223
9474
  functionName: "create",
9224
9475
  kind: "mutation",
9225
9476
  inputProjection: createBeliefInput
9226
- }
9477
+ },
9478
+ args: createBeliefArgs
9227
9479
  }),
9228
9480
  surfaceContract({
9229
9481
  name: "get_belief",
@@ -9314,7 +9566,8 @@ var beliefsContracts = [
9314
9566
  functionName: "forkBelief",
9315
9567
  kind: "mutation",
9316
9568
  inputProjection: forkBeliefInput
9317
- }
9569
+ },
9570
+ args: forkBeliefArgs
9318
9571
  }),
9319
9572
  surfaceContract({
9320
9573
  name: "archive_belief",
@@ -9395,8 +9648,46 @@ var beliefsContracts = [
9395
9648
  }
9396
9649
  })
9397
9650
  ];
9398
-
9399
- // ../contracts/src/function-registry/evidence.ts
9651
+ var jsonRecordSchema4 = z.record(z.unknown());
9652
+ var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
9653
+ var createEvidenceArgs = z.object({
9654
+ topicId: z.string().optional().describe("Topic scope for the evidence."),
9655
+ text: z.string().describe("Canonical evidence text."),
9656
+ source: z.string().optional().describe("Source URL or source label."),
9657
+ sourceUrl: z.string().optional().describe("Canonical source URL."),
9658
+ targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
9659
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
9660
+ evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
9661
+ confidence: z.number().optional().describe("Confidence in the evidence relation."),
9662
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
9663
+ metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
9664
+ rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
9665
+ reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
9666
+ title: z.string().optional().describe("Optional short title."),
9667
+ content: z.string().optional().describe("Optional long-form content."),
9668
+ contentType: z.string().optional().describe("Content format or MIME hint."),
9669
+ kind: z.string().optional().describe("Evidence kind."),
9670
+ tags: z.array(z.string()).optional().describe("Evidence tags."),
9671
+ sourceType: z.string().optional().describe("Evidence source type."),
9672
+ externalSourceType: z.string().optional().describe("External source type for imported evidence."),
9673
+ sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
9674
+ methodology: z.string().optional().describe("Collection methodology."),
9675
+ informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
9676
+ sourceDescription: z.string().optional().describe("Human-readable source description.")
9677
+ });
9678
+ var addEvidenceArgs = z.object({
9679
+ canonicalText: z.string().describe("The evidence statement."),
9680
+ text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
9681
+ topicId: z.string().optional().describe("Topic scope hint."),
9682
+ sourceUrl: z.string().optional().describe("URL of the source material."),
9683
+ targetNodeId: z.string().describe("The belief this evidence bears on."),
9684
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
9685
+ reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
9686
+ title: z.string().optional().describe("Optional short title."),
9687
+ content: z.string().optional().describe("Optional long-form evidence content."),
9688
+ contentType: z.string().optional().describe("Content format or MIME hint."),
9689
+ metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
9690
+ });
9400
9691
  var evidenceIdInput = (input) => compactRecord4({
9401
9692
  evidenceId: input.evidenceId,
9402
9693
  insightId: input.insightId,
@@ -9471,7 +9762,8 @@ var evidenceContracts = [
9471
9762
  functionName: "create",
9472
9763
  kind: "mutation",
9473
9764
  inputProjection: createEvidenceInput
9474
- }
9765
+ },
9766
+ args: createEvidenceArgs
9475
9767
  }),
9476
9768
  surfaceContract({
9477
9769
  name: "add_evidence",
@@ -9507,7 +9799,8 @@ var evidenceContracts = [
9507
9799
  context
9508
9800
  );
9509
9801
  }
9510
- }
9802
+ },
9803
+ args: addEvidenceArgs
9511
9804
  }),
9512
9805
  surfaceContract({
9513
9806
  name: "get_evidence",
@@ -9614,8 +9907,91 @@ var evidenceContracts = [
9614
9907
  }
9615
9908
  })
9616
9909
  ];
9617
-
9618
- // ../contracts/src/function-registry/questions.ts
9910
+ var jsonRecordSchema5 = z.record(z.unknown());
9911
+ var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
9912
+ var kernelQuestionPrioritySchema = z.enum([
9913
+ "critical",
9914
+ "high",
9915
+ "medium",
9916
+ "low"
9917
+ ]);
9918
+ var questionTypeSchema = z.enum([
9919
+ "validation",
9920
+ "falsification",
9921
+ "assumption_probe",
9922
+ "prediction_test",
9923
+ "counterfactual",
9924
+ "discovery",
9925
+ "clarification",
9926
+ "comparison",
9927
+ "causal",
9928
+ "mechanism",
9929
+ "general"
9930
+ ]);
9931
+ var createQuestionArgs = z.object({
9932
+ text: z.string().describe("The question text."),
9933
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
9934
+ topicId: z.string().optional().describe("Topic scope hint."),
9935
+ priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
9936
+ linkedBeliefId: z.string().optional().describe("Belief this question tests."),
9937
+ linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
9938
+ metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
9939
+ category: z.string().optional().describe("Question category."),
9940
+ source: z.string().optional().describe("Question source."),
9941
+ testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
9942
+ importance: z.number().optional().describe("Numeric importance score."),
9943
+ epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
9944
+ sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
9945
+ linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
9946
+ questionType: questionTypeSchema.optional().describe("Question type."),
9947
+ questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
9948
+ });
9949
+ var refineQuestionArgs = z.object({
9950
+ id: z.string().describe("The question to refine."),
9951
+ text: z.string().describe("Updated question text."),
9952
+ question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
9953
+ rationale: z.string().optional().describe("Why the question is refined."),
9954
+ category: z.string().optional().describe("Updated question category."),
9955
+ priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
9956
+ });
9957
+ var createAnswerArgs = z.object({
9958
+ questionNodeId: z.string().describe("The question node ID this answer responds to."),
9959
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
9960
+ answerText: z.string().describe("The answer content."),
9961
+ topicId: z.string().optional().describe("Topic scope for the answer."),
9962
+ confidence: z.string().optional().describe("Answer confidence."),
9963
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
9964
+ answerSource: z.string().optional().describe("How the answer was produced."),
9965
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
9966
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
9967
+ });
9968
+ var answerQuestionArgs = z.object({
9969
+ id: z.string().describe("Canonical question ID."),
9970
+ topicId: z.string().describe("Topic scope for the answer."),
9971
+ text: z.string().describe("Answer text."),
9972
+ confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
9973
+ evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
9974
+ rationale: z.string().optional().describe("Why this answer is credible."),
9975
+ questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
9976
+ questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
9977
+ answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
9978
+ evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
9979
+ answerSource: z.string().optional().describe("How the answer was produced."),
9980
+ worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
9981
+ sprintId: z.string().optional().describe("Legacy sprint identifier.")
9982
+ });
9983
+ var missingQuestionsArgs = z.object({
9984
+ topicId: z.string().describe("Topic scope."),
9985
+ minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
9986
+ status: z.string().optional().describe("Question status filter."),
9987
+ limit: z.number().optional().describe("Maximum questions to inspect.")
9988
+ });
9989
+ var falsificationQuestionsArgs = z.object({
9990
+ topicId: z.string().describe("Topic scope."),
9991
+ beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
9992
+ status: z.string().optional().describe("Question status filter."),
9993
+ limit: z.number().optional().describe("Maximum questions to inspect.")
9994
+ });
9619
9995
  var questionNodeInput = (input) => compactRecord4({
9620
9996
  nodeId: input.nodeId ?? input.id ?? input.questionId,
9621
9997
  questionId: input.questionId
@@ -9662,7 +10038,8 @@ var questionsContracts = [
9662
10038
  functionName: "create",
9663
10039
  kind: "mutation",
9664
10040
  inputProjection: createQuestionInput
9665
- }
10041
+ },
10042
+ args: createQuestionArgs
9666
10043
  }),
9667
10044
  surfaceContract({
9668
10045
  name: "get_question",
@@ -9718,7 +10095,8 @@ var questionsContracts = [
9718
10095
  category: input.category,
9719
10096
  priority: input.priority
9720
10097
  })
9721
- }
10098
+ },
10099
+ args: refineQuestionArgs
9722
10100
  }),
9723
10101
  surfaceContract({
9724
10102
  name: "update_question_status",
@@ -9794,7 +10172,8 @@ var questionsContracts = [
9794
10172
  }),
9795
10173
  context
9796
10174
  )
9797
- }
10175
+ },
10176
+ args: createAnswerArgs
9798
10177
  }),
9799
10178
  surfaceContract({
9800
10179
  name: "answer_question",
@@ -9823,7 +10202,8 @@ var questionsContracts = [
9823
10202
  }),
9824
10203
  context
9825
10204
  )
9826
- }
10205
+ },
10206
+ args: answerQuestionArgs
9827
10207
  }),
9828
10208
  surfaceContract({
9829
10209
  name: "get_answer",
@@ -9855,7 +10235,8 @@ var questionsContracts = [
9855
10235
  functionName: "getByTopic",
9856
10236
  kind: "query",
9857
10237
  inputProjection: questionTopicInput
9858
- }
10238
+ },
10239
+ args: missingQuestionsArgs
9859
10240
  }),
9860
10241
  surfaceContract({
9861
10242
  name: "get_high_priority_questions",
@@ -9890,11 +10271,22 @@ var questionsContracts = [
9890
10271
  functionName: "getByTopic",
9891
10272
  kind: "query",
9892
10273
  inputProjection: questionTopicInput
9893
- }
10274
+ },
10275
+ args: falsificationQuestionsArgs
9894
10276
  })
9895
10277
  ];
9896
-
9897
- // ../contracts/src/function-registry/topics.ts
10278
+ var updateTopicArgs = z.object({
10279
+ id: z.string().describe("Topic ID."),
10280
+ topicId: z.string().optional().describe("Topic ID alias."),
10281
+ name: z.string().optional().describe("Topic name."),
10282
+ description: z.string().optional().describe("Topic description."),
10283
+ type: z.string().optional().describe("Topic type."),
10284
+ status: z.string().optional().describe("Topic status."),
10285
+ visibility: z.string().optional().describe("Topic visibility."),
10286
+ ontologyId: z.string().optional().describe("Ontology to bind."),
10287
+ clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
10288
+ metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
10289
+ });
9898
10290
  var topicIdInput = (input) => compactRecord4({
9899
10291
  id: input.id ?? input.topicId
9900
10292
  });
@@ -9975,7 +10367,8 @@ var topicsContracts = [
9975
10367
  functionName: "update",
9976
10368
  kind: "mutation",
9977
10369
  inputProjection: updateTopicInput
9978
- }
10370
+ },
10371
+ args: updateTopicArgs
9979
10372
  }),
9980
10373
  surfaceContract({
9981
10374
  name: "get_topic_tree",
@@ -9994,8 +10387,27 @@ var topicsContracts = [
9994
10387
  }
9995
10388
  })
9996
10389
  ];
9997
-
9998
- // ../contracts/src/function-registry/lenses.ts
10390
+ var lensPerspectiveSchema = z.enum([
10391
+ "investigation",
10392
+ "monitoring",
10393
+ "analysis",
10394
+ "comparison",
10395
+ "taxonomy"
10396
+ ]);
10397
+ var jsonRecordSchema6 = z.record(z.unknown());
10398
+ var createLensArgs = z.object({
10399
+ name: z.string().describe("Lens name."),
10400
+ workspaceId: z.string().optional().describe("Workspace scope for the lens."),
10401
+ topicId: z.string().optional().describe("Originating topic scope."),
10402
+ description: z.string().optional().describe("What this lens investigates or monitors."),
10403
+ perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
10404
+ promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
10405
+ workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
10406
+ taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
10407
+ questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
10408
+ filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
10409
+ metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
10410
+ });
9999
10411
  var createLensInput = (input, context) => compactRecord4({
10000
10412
  name: input.name,
10001
10413
  description: input.description,
@@ -10032,7 +10444,8 @@ var lensesContracts = [
10032
10444
  functionName: "create",
10033
10445
  kind: "mutation",
10034
10446
  inputProjection: createLensInput
10035
- }
10447
+ },
10448
+ args: createLensArgs
10036
10449
  }),
10037
10450
  surfaceContract({
10038
10451
  name: "list_lenses",
@@ -10094,8 +10507,18 @@ var lensesContracts = [
10094
10507
  }
10095
10508
  })
10096
10509
  ];
10097
-
10098
- // ../contracts/src/function-registry/ontologies.ts
10510
+ var updateOntologyArgs = z.object({
10511
+ id: z.string().describe("Ontology definition ID."),
10512
+ ontologyId: z.string().optional().describe("Ontology ID alias."),
10513
+ name: z.string().optional().describe("Ontology display name."),
10514
+ description: z.string().optional().describe("Ontology description."),
10515
+ status: z.string().optional().describe("Ontology lifecycle status.")
10516
+ });
10517
+ var ontologyVersionLifecycleArgs = z.object({
10518
+ id: z.string().describe("Ontology version ID."),
10519
+ versionId: z.string().optional().describe("Ontology version ID alias."),
10520
+ ontologyId: z.string().optional().describe("Ontology definition ID.")
10521
+ });
10099
10522
  var ontologyIdInput = (input) => compactRecord4({
10100
10523
  id: input.id ?? input.ontologyId
10101
10524
  });
@@ -10174,11 +10597,11 @@ var ontologiesContracts = [
10174
10597
  id: input.id ?? input.ontologyId,
10175
10598
  name: input.name,
10176
10599
  description: input.description,
10177
- parentOntologyId: input.parentOntologyId,
10178
10600
  status: input.status,
10179
10601
  actorId: input.actorId
10180
10602
  })
10181
- }
10603
+ },
10604
+ args: updateOntologyArgs
10182
10605
  }),
10183
10606
  surfaceContract({
10184
10607
  name: "archive_ontology",
@@ -10261,7 +10684,8 @@ var ontologiesContracts = [
10261
10684
  functionName: "publishOntologyVersion",
10262
10685
  kind: "mutation",
10263
10686
  inputProjection: ontologyVersionIdInput
10264
- }
10687
+ },
10688
+ args: ontologyVersionLifecycleArgs
10265
10689
  }),
10266
10690
  surfaceContract({
10267
10691
  name: "deprecate_ontology_version",
@@ -10277,7 +10701,8 @@ var ontologiesContracts = [
10277
10701
  functionName: "deprecateOntologyVersion",
10278
10702
  kind: "mutation",
10279
10703
  inputProjection: ontologyVersionIdInput
10280
- }
10704
+ },
10705
+ args: ontologyVersionLifecycleArgs
10281
10706
  }),
10282
10707
  surfaceContract({
10283
10708
  name: "resolve_effective_ontology",
@@ -10296,8 +10721,76 @@ var ontologiesContracts = [
10296
10721
  }
10297
10722
  })
10298
10723
  ];
10299
-
10300
- // ../contracts/src/function-registry/worktrees.ts
10724
+ var autoFixPolicyInputSchema = z.object({
10725
+ enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
10726
+ mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
10727
+ maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
10728
+ reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
10729
+ maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
10730
+ permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
10731
+ requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
10732
+ escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
10733
+ }).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
10734
+ var worktreeKeyQuestionInputSchema = z.object({
10735
+ question: z.string().describe("Question the worktree must resolve."),
10736
+ status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
10737
+ answer: z.string().optional().describe("Captured answer when the key question is resolved."),
10738
+ answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
10739
+ linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
10740
+ }).passthrough().describe("Question contract embedded in the worktree plan.");
10741
+ var worktreeEvidenceSignalInputSchema = z.object({
10742
+ signal: z.string().describe("Evidence signal the worktree should collect."),
10743
+ collected: z.boolean().optional().describe("Whether the signal has already been collected."),
10744
+ progress: z.string().optional().describe("Collection progress note for the signal."),
10745
+ notes: z.string().optional().describe("Additional evidence collection notes.")
10746
+ }).passthrough().describe("Evidence signal embedded in the worktree plan.");
10747
+ var worktreeDecisionGateInputSchema = z.object({
10748
+ goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
10749
+ noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
10750
+ verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
10751
+ verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
10752
+ decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
10753
+ decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
10754
+ }).passthrough().describe("Decision gate contract for worktree activation or exit.");
10755
+ var addWorktreeArgs = z.object({
10756
+ title: z.string().optional().describe("Human-readable worktree name or objective."),
10757
+ name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
10758
+ topicId: z.string().describe("Primary topic scope for the worktree."),
10759
+ projectId: z.string().optional().describe("Legacy topicId alias."),
10760
+ branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
10761
+ objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
10762
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
10763
+ rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
10764
+ worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
10765
+ gate: z.string().optional().describe("Exit gate for this worktree."),
10766
+ startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
10767
+ endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
10768
+ durationWeeks: z.number().optional().describe("Planned duration in weeks."),
10769
+ confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
10770
+ beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
10771
+ beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
10772
+ beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
10773
+ targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
10774
+ targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
10775
+ keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
10776
+ evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
10777
+ decisionGate: worktreeDecisionGateInputSchema.optional(),
10778
+ goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
10779
+ noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
10780
+ proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
10781
+ autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
10782
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
10783
+ domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
10784
+ campaign: z.number().optional().describe("Top-level pipeline campaign number."),
10785
+ lane: z.string().optional().describe("Campaign lane for the worktree."),
10786
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
10787
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
10788
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
10789
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
10790
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
10791
+ lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
10792
+ lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
10793
+ });
10301
10794
  var worktreeIdInput = (input) => compactRecord4({
10302
10795
  worktreeId: input.worktreeId ?? input.id
10303
10796
  });
@@ -10330,6 +10823,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
10330
10823
  autoFixPolicy: input.autoFixPolicy,
10331
10824
  lastReconciledAt: input.lastReconciledAt
10332
10825
  });
10826
+ var worktreeMetadataArgs = z.object({
10827
+ worktreeId: z.string().describe("The worktree to update."),
10828
+ id: z.string().optional().describe("Worktree ID alias."),
10829
+ topicId: z.string().optional().describe("Primary topic scope."),
10830
+ additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
10831
+ status: z.string().optional().describe("Worktree lifecycle status."),
10832
+ campaign: z.number().optional().describe("Top-level pipeline campaign."),
10833
+ lane: z.string().optional().describe("Campaign lane."),
10834
+ laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
10835
+ orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
10836
+ gate: z.string().optional().describe("Exit gate for this worktree."),
10837
+ hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
10838
+ objective: z.string().optional().describe("Reasoning objective for the worktree."),
10839
+ rationale: z.string().optional().describe("Why this worktree is sequenced here."),
10840
+ proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
10841
+ staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
10842
+ blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
10843
+ dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
10844
+ lensId: z.string().optional().describe("Lens that scopes this worktree."),
10845
+ autoFixPolicy: autoFixPolicyInputSchema.optional(),
10846
+ lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
10847
+ });
10848
+ var pushArgs = worktreeMetadataArgs.extend({
10849
+ targetContext: z.string().describe("Where to push merged findings."),
10850
+ beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
10851
+ });
10852
+ var openPullRequestArgs = worktreeMetadataArgs.extend({
10853
+ reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
10854
+ summary: z.string().describe("Summary of findings and why they are ready for review.")
10855
+ });
10856
+ var mergeKeyFindingsInput = (input) => {
10857
+ if (Array.isArray(input.keyFindings)) {
10858
+ return input.keyFindings;
10859
+ }
10860
+ if (Array.isArray(input.outcomes)) {
10861
+ const findings = input.outcomes.filter(
10862
+ (outcome) => typeof outcome === "string" && outcome.trim().length > 0
10863
+ );
10864
+ if (findings.length > 0) {
10865
+ return findings;
10866
+ }
10867
+ }
10868
+ return [input.summary ?? "Merged worktree"];
10869
+ };
10333
10870
  var listAllWorktreesInput = (input) => compactRecord4({
10334
10871
  status: input.status,
10335
10872
  lane: input.lane,
@@ -10337,6 +10874,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
10337
10874
  limit: input.limit
10338
10875
  });
10339
10876
  var worktreesContracts = [
10877
+ surfaceContract({
10878
+ name: "begin_build_session",
10879
+ kind: "mutation",
10880
+ domain: "worktrees",
10881
+ surfaceClass: "platform_internal",
10882
+ path: "/mcp/build-session/begin",
10883
+ sdkNamespace: "worktrees",
10884
+ sdkMethod: "beginBuildSession",
10885
+ summary: "Begin a coding build session for a worktree."
10886
+ }),
10340
10887
  surfaceContract({
10341
10888
  name: "add_worktree",
10342
10889
  kind: "mutation",
@@ -10353,13 +10900,12 @@ var worktreesContracts = [
10353
10900
  inputProjection: (input, context) => withCreatedBy(
10354
10901
  compactRecord4({
10355
10902
  name: input.name ?? input.title,
10356
- topicId: input.topicId,
10903
+ topicId: input.topicId ?? input.projectId,
10357
10904
  worktreeType: input.worktreeType,
10358
10905
  objective: input.objective,
10359
10906
  gate: input.gate,
10360
10907
  hypothesis: input.hypothesis,
10361
10908
  rationale: input.rationale,
10362
- signal: input.signal,
10363
10909
  startDate: input.startDate,
10364
10910
  endDate: input.endDate,
10365
10911
  durationWeeks: input.durationWeeks,
@@ -10385,12 +10931,12 @@ var worktreesContracts = [
10385
10931
  staffingHint: input.staffingHint,
10386
10932
  domainPackId: input.domainPackId,
10387
10933
  lensId: input.lensId,
10388
- linkedQuestionId: input.linkedQuestionId,
10389
10934
  lastReconciledAt: input.lastReconciledAt
10390
10935
  }),
10391
10936
  context
10392
10937
  )
10393
- }
10938
+ },
10939
+ args: addWorktreeArgs
10394
10940
  }),
10395
10941
  surfaceContract({
10396
10942
  name: "activate_worktree",
@@ -10502,7 +11048,8 @@ var worktreesContracts = [
10502
11048
  functionName: "updateMetadata",
10503
11049
  kind: "mutation",
10504
11050
  inputProjection: worktreeMetadataInput
10505
- }
11051
+ },
11052
+ args: worktreeMetadataArgs
10506
11053
  }),
10507
11054
  surfaceContract({
10508
11055
  name: "merge",
@@ -10520,9 +11067,7 @@ var worktreesContracts = [
10520
11067
  inputProjection: (input, context) => withUserId(
10521
11068
  {
10522
11069
  ...worktreeIdInput(input),
10523
- keyFindings: input.keyFindings ?? [
10524
- input.summary ?? "Merged worktree"
10525
- ],
11070
+ keyFindings: mergeKeyFindingsInput(input),
10526
11071
  decisionsReached: input.decisionsReached ?? [],
10527
11072
  nextSteps: input.nextSteps ?? []
10528
11073
  },
@@ -10544,7 +11089,8 @@ var worktreesContracts = [
10544
11089
  functionName: "updateMetadata",
10545
11090
  kind: "mutation",
10546
11091
  inputProjection: worktreeMetadataInput
10547
- }
11092
+ },
11093
+ args: pushArgs
10548
11094
  }),
10549
11095
  surfaceContract({
10550
11096
  name: "open_pull_request",
@@ -10560,7 +11106,8 @@ var worktreesContracts = [
10560
11106
  functionName: "updateMetadata",
10561
11107
  kind: "mutation",
10562
11108
  inputProjection: worktreeMetadataInput
10563
- }
11109
+ },
11110
+ args: openPullRequestArgs
10564
11111
  })
10565
11112
  ];
10566
11113
 
@@ -10664,6 +11211,15 @@ var createEdgeArgs = z.object({
10664
11211
  topicId: z.string().optional(),
10665
11212
  trustedBypassAccessCheck: z.boolean().optional()
10666
11213
  });
11214
+ var queryLineageArgs = z.object({
11215
+ nodeId: z.string().describe("Starting node to trace from."),
11216
+ startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
11217
+ depth: z.number().optional().describe("Traversal depth alias."),
11218
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11219
+ mode: z.string().optional().describe("Traversal mode."),
11220
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11221
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11222
+ });
10667
11223
  function graphRefNodeId(ref) {
10668
11224
  if (ref.kind === "epistemic_node") {
10669
11225
  return ref.nodeId;
@@ -10734,11 +11290,59 @@ var edgesContracts = [
10734
11290
  minLayer: input.minLayer,
10735
11291
  maxLayer: input.maxLayer
10736
11292
  })
10737
- }
11293
+ },
11294
+ args: queryLineageArgs
10738
11295
  })
10739
11296
  ];
10740
-
10741
- // ../contracts/src/function-registry/graph.ts
11297
+ var traversalLayerSchema = z.enum([
11298
+ "L4",
11299
+ "L3",
11300
+ "L2",
11301
+ "L1",
11302
+ "ontological",
11303
+ "organizational"
11304
+ ]);
11305
+ var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
11306
+ var lineageAliasArgs = z.object({
11307
+ nodeId: z.string().optional().describe("Starting node to traverse from."),
11308
+ startNode: z.string().optional().describe("Starting node alias for traversal callers."),
11309
+ entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
11310
+ depth: z.number().optional().describe("Traversal depth alias."),
11311
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11312
+ mode: traversalModeSchema.optional().describe("Traversal mode."),
11313
+ minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
11314
+ maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
11315
+ });
11316
+ var lineageArgs = lineageAliasArgs.extend({
11317
+ nodeId: z.string().describe("Starting node to traverse from.")
11318
+ });
11319
+ var traverseGraphArgs = lineageAliasArgs.extend({
11320
+ startNode: z.string().describe("Node to start traversal from."),
11321
+ direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
11322
+ });
11323
+ var graphNeighborhoodArgs = z.object({
11324
+ globalId: z.string().optional().describe("Single root global ID."),
11325
+ globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
11326
+ maxDepth: z.number().optional().describe("Maximum traversal depth."),
11327
+ topicId: z.string().optional().describe("Topic scope for edge lookup."),
11328
+ limit: z.number().optional().describe("Maximum edges to return.")
11329
+ });
11330
+ var flagContradictionArgs = z.object({
11331
+ beliefA: z.string().describe("First belief in tension."),
11332
+ beliefB: z.string().describe("Second belief in tension."),
11333
+ topicId: z.string().optional().describe("Topic scope for the contradiction."),
11334
+ description: z.string().optional().describe("Human-readable contradiction."),
11335
+ severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
11336
+ defeatType: z.string().optional().describe("Defeat type annotation."),
11337
+ supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
11338
+ contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
11339
+ });
11340
+ var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
11341
+ nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
11342
+ topicId: z.string().optional().describe("Topic scope override."),
11343
+ minScore: z.number().optional().describe("Minimum match score."),
11344
+ limit: z.number().optional().describe("Maximum candidates to return.")
11345
+ });
10742
11346
  var contradictionSeverity = (value) => {
10743
11347
  switch (value) {
10744
11348
  case "critical":
@@ -10793,7 +11397,8 @@ var graphContracts = [
10793
11397
  functionName: "getLineage",
10794
11398
  kind: "query",
10795
11399
  inputProjection: lineageInput
10796
- }
11400
+ },
11401
+ args: traverseGraphArgs
10797
11402
  }),
10798
11403
  surfaceContract({
10799
11404
  name: "get_graph_neighborhood",
@@ -10809,7 +11414,8 @@ var graphContracts = [
10809
11414
  functionName: "getByTopic",
10810
11415
  kind: "query",
10811
11416
  inputProjection: topicEdgesInput
10812
- }
11417
+ },
11418
+ args: graphNeighborhoodArgs
10813
11419
  }),
10814
11420
  surfaceContract({
10815
11421
  name: "get_graph_structure_analysis",
@@ -10858,7 +11464,8 @@ var graphContracts = [
10858
11464
  functionName: "create",
10859
11465
  kind: "mutation",
10860
11466
  inputProjection: flagContradictionInput
10861
- }
11467
+ },
11468
+ args: flagContradictionArgs
10862
11469
  }),
10863
11470
  surfaceContract({
10864
11471
  name: "detect_confirmation_bias",
@@ -10949,7 +11556,8 @@ var graphContracts = [
10949
11556
  functionName: "getLineage",
10950
11557
  kind: "query",
10951
11558
  inputProjection: lineageInput
10952
- }
11559
+ },
11560
+ args: discoverEntityConnectionsArgs
10953
11561
  }),
10954
11562
  surfaceContract({
10955
11563
  name: "trigger_belief_review",
@@ -10980,7 +11588,8 @@ var graphContracts = [
10980
11588
  functionName: "getLineage",
10981
11589
  kind: "query",
10982
11590
  inputProjection: lineageInput
10983
- }
11591
+ },
11592
+ args: lineageArgs
10984
11593
  })
10985
11594
  ];
10986
11595
 
@@ -11032,8 +11641,16 @@ var contractsContracts = [
11032
11641
  }
11033
11642
  })
11034
11643
  ];
11035
-
11036
- // ../contracts/src/function-registry/judgments.ts
11644
+ var auditTrailArgs = z.object({
11645
+ nodeId: z.string().describe("The node to audit."),
11646
+ id: z.string().optional().describe("Node ID alias."),
11647
+ limit: z.number().optional().describe("Maximum entries to return."),
11648
+ depth: z.number().optional().describe("Traversal depth alias."),
11649
+ maxDepth: z.number().optional().describe("Maximum lineage depth."),
11650
+ mode: z.string().optional().describe("Traversal mode."),
11651
+ minLayer: z.string().optional().describe("Minimum epistemic layer."),
11652
+ maxLayer: z.string().optional().describe("Maximum epistemic layer.")
11653
+ });
11037
11654
  var judgmentsContracts = [
11038
11655
  surfaceContract({
11039
11656
  name: "record_judgment",
@@ -11088,7 +11705,8 @@ var judgmentsContracts = [
11088
11705
  minLayer: input.minLayer,
11089
11706
  maxLayer: input.maxLayer
11090
11707
  })
11091
- }
11708
+ },
11709
+ args: auditTrailArgs
11092
11710
  })
11093
11711
  ];
11094
11712
 
@@ -11256,8 +11874,13 @@ var coordinationContracts = [
11256
11874
  }
11257
11875
  })
11258
11876
  ];
11259
-
11260
- // ../contracts/src/function-registry/pipeline.ts
11877
+ var pipelineSnapshotArgs = z.object({
11878
+ topicId: z.string().describe("Topic scope ID."),
11879
+ status: z.string().optional().describe("Worktree status filter."),
11880
+ lane: z.string().optional().describe("Campaign lane filter."),
11881
+ campaign: z.number().optional().describe("Campaign number filter."),
11882
+ limit: z.number().optional().describe("Maximum worktrees to inspect.")
11883
+ });
11261
11884
  var pipelineContracts = [
11262
11885
  surfaceContract({
11263
11886
  name: "pipeline_snapshot",
@@ -11278,7 +11901,8 @@ var pipelineContracts = [
11278
11901
  campaign: input.campaign,
11279
11902
  limit: input.limit
11280
11903
  })
11281
- }
11904
+ },
11905
+ args: pipelineSnapshotArgs
11282
11906
  }),
11283
11907
  surfaceContract({
11284
11908
  name: "seed_belief_lattice",
@@ -11330,7 +11954,31 @@ var recordScopeLearningArgs = z.object({
11330
11954
  rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
11331
11955
  createQuestionText: z.string().optional().describe("Optional follow-up question text"),
11332
11956
  createBeliefText: z.string().optional().describe("Optional new belief text"),
11333
- beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
11957
+ beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
11958
+ text: z.string().optional().describe("Canonical learning text alias."),
11959
+ content: z.string().optional().describe("Canonical learning content alias."),
11960
+ kind: z.string().optional().describe("Evidence kind to store."),
11961
+ sourceType: z.string().optional().describe("Evidence source type."),
11962
+ externalSourceType: z.string().optional().describe("External source type alias."),
11963
+ metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
11964
+ });
11965
+ var codeContextArgs = z.object({
11966
+ topicId: z.string().optional().describe("Topic scope."),
11967
+ filePath: z.string().optional().describe("File path anchor."),
11968
+ includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
11969
+ limit: z.number().optional().describe("Maximum records to return."),
11970
+ status: z.string().optional().describe("Evidence status filter.")
11971
+ });
11972
+ var recordAttemptArgs = z.object({
11973
+ topicId: z.string().optional().describe("Topic scope."),
11974
+ description: z.string().describe("Attempt description."),
11975
+ errorMessage: z.string().optional().describe("Failure or error message."),
11976
+ filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
11977
+ filePath: z.string().optional().describe("Single file path alias."),
11978
+ linkedBeliefId: z.string().optional().describe("Linked belief ID."),
11979
+ metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
11980
+ rationale: z.string().optional().describe("Why this attempt should be recorded."),
11981
+ title: z.string().optional().describe("Attempt evidence title.")
11334
11982
  });
11335
11983
  var learningInput = (input, context) => {
11336
11984
  const sourceKind = input.sourceKind ?? input.externalSourceType;
@@ -11447,7 +12095,8 @@ var codingContracts = [
11447
12095
  status: input.status,
11448
12096
  userId: input.userId
11449
12097
  })
11450
- }
12098
+ },
12099
+ args: codeContextArgs
11451
12100
  }),
11452
12101
  surfaceContract({
11453
12102
  name: "get_change_history",
@@ -11484,7 +12133,8 @@ var codingContracts = [
11484
12133
  functionName: "create",
11485
12134
  kind: "mutation",
11486
12135
  inputProjection: attemptInput
11487
- }
12136
+ },
12137
+ args: recordAttemptArgs
11488
12138
  }),
11489
12139
  surfaceContract({
11490
12140
  name: "get_failure_log",
@@ -11559,6 +12209,604 @@ new Map(
11559
12209
  ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
11560
12210
  );
11561
12211
 
12212
+ // ../contracts/src/tenant-bootstrap-seed.contract.ts
12213
+ function isCopyableSeedRequirement(entry) {
12214
+ 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;
12215
+ }
12216
+ var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
12217
+ {
12218
+ component: "kernel",
12219
+ table: "agentMessages",
12220
+ prepopulation: "runtime_data",
12221
+ copyMode: "none",
12222
+ description: "Agent coordination messages are session data, not template data."
12223
+ },
12224
+ {
12225
+ component: "kernel",
12226
+ table: "agentSessions",
12227
+ prepopulation: "runtime_data",
12228
+ copyMode: "none",
12229
+ description: "Agent coordination sessions are created by active clients."
12230
+ },
12231
+ {
12232
+ component: "kernel",
12233
+ table: "autofixJobs",
12234
+ prepopulation: "runtime_queue",
12235
+ copyMode: "none",
12236
+ description: "Autofix work items are runtime queue rows."
12237
+ },
12238
+ {
12239
+ component: "kernel",
12240
+ table: "backgroundJobRuns",
12241
+ prepopulation: "runtime_log",
12242
+ copyMode: "none",
12243
+ description: "Background job executions are runtime logs."
12244
+ },
12245
+ {
12246
+ component: "kernel",
12247
+ table: "backgroundJobSettings",
12248
+ prepopulation: "required_template",
12249
+ copyMode: "template_global",
12250
+ scope: "global",
12251
+ uniqueKey: ["jobKey"],
12252
+ description: "Default job enablement settings must come from the K template."
12253
+ },
12254
+ {
12255
+ component: "kernel",
12256
+ table: "beliefConfidence",
12257
+ prepopulation: "runtime_data",
12258
+ copyMode: "none",
12259
+ description: "Belief confidence rows are created with tenant graph facts."
12260
+ },
12261
+ {
12262
+ component: "kernel",
12263
+ table: "beliefEvidenceLinks",
12264
+ prepopulation: "runtime_data",
12265
+ copyMode: "none",
12266
+ description: "Belief-to-evidence links are tenant graph data."
12267
+ },
12268
+ {
12269
+ component: "kernel",
12270
+ table: "beliefHistory",
12271
+ prepopulation: "runtime_data",
12272
+ copyMode: "none",
12273
+ description: "Belief history is append-only tenant graph data."
12274
+ },
12275
+ {
12276
+ component: "kernel",
12277
+ table: "beliefScenarios",
12278
+ prepopulation: "runtime_data",
12279
+ copyMode: "none",
12280
+ description: "Scenario rows are tenant-authored reasoning data."
12281
+ },
12282
+ {
12283
+ component: "kernel",
12284
+ table: "beliefVotes",
12285
+ prepopulation: "runtime_data",
12286
+ copyMode: "none",
12287
+ description: "Decision belief votes are tenant-authored data."
12288
+ },
12289
+ {
12290
+ component: "kernel",
12291
+ table: "calibrationScores",
12292
+ prepopulation: "runtime_derived",
12293
+ copyMode: "none",
12294
+ description: "Calibration scores are computed from tenant outcomes."
12295
+ },
12296
+ {
12297
+ component: "kernel",
12298
+ table: "contractEvaluations",
12299
+ prepopulation: "runtime_log",
12300
+ copyMode: "none",
12301
+ description: "Contract evaluation rows are runtime computation logs."
12302
+ },
12303
+ {
12304
+ component: "kernel",
12305
+ table: "contradictions",
12306
+ prepopulation: "runtime_data",
12307
+ copyMode: "none",
12308
+ description: "Contradictions are tenant graph facts."
12309
+ },
12310
+ {
12311
+ component: "kernel",
12312
+ table: "crossProjectConnections",
12313
+ prepopulation: "runtime_data",
12314
+ copyMode: "none",
12315
+ description: "Cross-topic connections are tenant graph facts."
12316
+ },
12317
+ {
12318
+ component: "kernel",
12319
+ table: "decisionComputedSummaries",
12320
+ prepopulation: "runtime_derived",
12321
+ copyMode: "none",
12322
+ description: "Decision summaries are derived tenant outputs."
12323
+ },
12324
+ {
12325
+ component: "kernel",
12326
+ table: "decisionEvents",
12327
+ prepopulation: "runtime_data",
12328
+ copyMode: "none",
12329
+ description: "Decision events are lifecycle data."
12330
+ },
12331
+ {
12332
+ component: "kernel",
12333
+ table: "decisionParticipants",
12334
+ prepopulation: "runtime_data",
12335
+ copyMode: "none",
12336
+ description: "Decision participants are tenant-selected actors."
12337
+ },
12338
+ {
12339
+ component: "kernel",
12340
+ table: "decisionRiskLedger",
12341
+ prepopulation: "runtime_data",
12342
+ copyMode: "none",
12343
+ description: "Decision risk rows are tenant decision data."
12344
+ },
12345
+ {
12346
+ component: "kernel",
12347
+ table: "decisionSnapshots",
12348
+ prepopulation: "runtime_derived",
12349
+ copyMode: "none",
12350
+ description: "Decision snapshots are derived from tenant state."
12351
+ },
12352
+ {
12353
+ component: "kernel",
12354
+ table: "deliberationContributions",
12355
+ prepopulation: "runtime_data",
12356
+ copyMode: "none",
12357
+ description: "Deliberation contributions are tenant-authored data."
12358
+ },
12359
+ {
12360
+ component: "kernel",
12361
+ table: "deliberationSessions",
12362
+ prepopulation: "runtime_data",
12363
+ copyMode: "none",
12364
+ description: "Deliberation sessions are created by tenant workflows."
12365
+ },
12366
+ {
12367
+ component: "kernel",
12368
+ table: "epistemicAudit",
12369
+ prepopulation: "runtime_log",
12370
+ copyMode: "none",
12371
+ description: "Epistemic audit rows are append-only runtime audit data."
12372
+ },
12373
+ {
12374
+ component: "kernel",
12375
+ table: "epistemicContracts",
12376
+ prepopulation: "runtime_data",
12377
+ copyMode: "none",
12378
+ description: "Epistemic contracts are tenant-authored governance data."
12379
+ },
12380
+ {
12381
+ component: "kernel",
12382
+ table: "epistemicEdges",
12383
+ prepopulation: "runtime_data",
12384
+ copyMode: "none",
12385
+ description: "Edges are tenant reasoning graph data."
12386
+ },
12387
+ {
12388
+ component: "kernel",
12389
+ table: "epistemicNodeEmbeddings",
12390
+ prepopulation: "runtime_derived",
12391
+ copyMode: "none",
12392
+ description: "Embeddings are derived from tenant graph nodes."
12393
+ },
12394
+ {
12395
+ component: "kernel",
12396
+ table: "epistemicNodes",
12397
+ prepopulation: "runtime_data",
12398
+ copyMode: "none",
12399
+ description: "Nodes are tenant reasoning graph data."
12400
+ },
12401
+ {
12402
+ component: "kernel",
12403
+ table: "graphAnalysisCache",
12404
+ prepopulation: "runtime_derived",
12405
+ copyMode: "none",
12406
+ description: "Graph analysis cache rows are derived from tenant graph state."
12407
+ },
12408
+ {
12409
+ component: "kernel",
12410
+ table: "graphAnalysisResults",
12411
+ prepopulation: "runtime_derived",
12412
+ copyMode: "none",
12413
+ description: "Graph analysis result rows are derived tenant outputs."
12414
+ },
12415
+ {
12416
+ component: "kernel",
12417
+ table: "graphSuggestions",
12418
+ prepopulation: "runtime_derived",
12419
+ copyMode: "none",
12420
+ description: "Graph suggestions are derived recommendations."
12421
+ },
12422
+ {
12423
+ component: "kernel",
12424
+ table: "harnessReplays",
12425
+ prepopulation: "runtime_log",
12426
+ copyMode: "none",
12427
+ description: "Harness replay rows are runtime verification logs."
12428
+ },
12429
+ {
12430
+ component: "kernel",
12431
+ table: "harnessRuns",
12432
+ prepopulation: "runtime_log",
12433
+ copyMode: "none",
12434
+ description: "Harness run rows are runtime verification logs."
12435
+ },
12436
+ {
12437
+ component: "kernel",
12438
+ table: "idempotencyTokens",
12439
+ prepopulation: "runtime_log",
12440
+ copyMode: "none",
12441
+ description: "Idempotency tokens are request-scoped runtime guards."
12442
+ },
12443
+ {
12444
+ component: "kernel",
12445
+ table: "lenses",
12446
+ prepopulation: "optional_template",
12447
+ copyMode: "none",
12448
+ description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
12449
+ },
12450
+ {
12451
+ component: "kernel",
12452
+ table: "lensTopicBindings",
12453
+ prepopulation: "runtime_data",
12454
+ copyMode: "none",
12455
+ description: "Lens bindings attach runtime topics to runtime/workspace lenses."
12456
+ },
12457
+ {
12458
+ component: "kernel",
12459
+ table: "neo4jSyncQueue",
12460
+ prepopulation: "runtime_queue",
12461
+ copyMode: "none",
12462
+ description: "Neo4j sync queue rows are runtime work items."
12463
+ },
12464
+ {
12465
+ component: "kernel",
12466
+ table: "ontologyDefinitions",
12467
+ prepopulation: "required_template",
12468
+ copyMode: "template_global",
12469
+ scope: "global",
12470
+ uniqueKey: ["ontologyKey"],
12471
+ description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
12472
+ },
12473
+ {
12474
+ component: "kernel",
12475
+ table: "ontologyVersions",
12476
+ prepopulation: "required_template",
12477
+ copyMode: "template_reference_remap",
12478
+ scope: "global",
12479
+ uniqueKey: ["ontologyKey", "version"],
12480
+ dependsOn: ["ontologyDefinitions"],
12481
+ description: "Ontology versions must be copied with ontologyDefinition ID remapping."
12482
+ },
12483
+ {
12484
+ component: "kernel",
12485
+ table: "platformAgentRunPolicyDecisions",
12486
+ prepopulation: "runtime_log",
12487
+ copyMode: "none",
12488
+ description: "Agent-run policy decisions are audit logs."
12489
+ },
12490
+ {
12491
+ component: "kernel",
12492
+ table: "platformAgentRunPromptResolutions",
12493
+ prepopulation: "runtime_log",
12494
+ copyMode: "none",
12495
+ description: "Agent-run prompt resolution rows are runtime logs."
12496
+ },
12497
+ {
12498
+ component: "kernel",
12499
+ table: "platformAgentRuns",
12500
+ prepopulation: "runtime_log",
12501
+ copyMode: "none",
12502
+ description: "Agent runs are runtime execution records."
12503
+ },
12504
+ {
12505
+ component: "kernel",
12506
+ table: "platformAgentRunToolCalls",
12507
+ prepopulation: "runtime_log",
12508
+ copyMode: "none",
12509
+ description: "Agent-run tool calls are runtime execution records."
12510
+ },
12511
+ {
12512
+ component: "kernel",
12513
+ table: "platformHarnessShadowAudit",
12514
+ prepopulation: "runtime_log",
12515
+ copyMode: "none",
12516
+ description: "Harness shadow audit rows are runtime audit records."
12517
+ },
12518
+ {
12519
+ component: "kernel",
12520
+ table: "publicationRules",
12521
+ prepopulation: "required_template",
12522
+ copyMode: "template_tenant_rewrite",
12523
+ scope: "tenant",
12524
+ uniqueKey: ["tenantId", "workspaceId", "name"],
12525
+ description: "Default publication policy rules are rewritten into each tenant."
12526
+ },
12527
+ {
12528
+ component: "kernel",
12529
+ table: "questionEvidenceLinks",
12530
+ prepopulation: "runtime_data",
12531
+ copyMode: "none",
12532
+ description: "Question-to-evidence links are tenant graph data."
12533
+ },
12534
+ {
12535
+ component: "kernel",
12536
+ table: "researchJobs",
12537
+ prepopulation: "runtime_queue",
12538
+ copyMode: "none",
12539
+ description: "Research job rows are runtime queue items."
12540
+ },
12541
+ {
12542
+ component: "kernel",
12543
+ table: "schemaEnumConfig",
12544
+ prepopulation: "required_template",
12545
+ copyMode: "template_global",
12546
+ scope: "global",
12547
+ uniqueKey: ["category", "value"],
12548
+ description: "Runtime-extensible enum defaults required by SDK graph APIs."
12549
+ },
12550
+ {
12551
+ component: "kernel",
12552
+ table: "stakeholderGroups",
12553
+ prepopulation: "runtime_data",
12554
+ copyMode: "none",
12555
+ description: "Stakeholder groups are tenant decision data."
12556
+ },
12557
+ {
12558
+ component: "kernel",
12559
+ table: "systemLogs",
12560
+ prepopulation: "runtime_log",
12561
+ copyMode: "none",
12562
+ description: "System logs are runtime telemetry."
12563
+ },
12564
+ {
12565
+ component: "kernel",
12566
+ table: "tasks",
12567
+ prepopulation: "runtime_data",
12568
+ copyMode: "none",
12569
+ description: "Tasks are tenant-authored work items."
12570
+ },
12571
+ {
12572
+ component: "kernel",
12573
+ table: "topics",
12574
+ prepopulation: "runtime_bootstrap",
12575
+ copyMode: "none",
12576
+ description: "Default topics are created by tenant provisioning, not copied from templates."
12577
+ },
12578
+ {
12579
+ component: "kernel",
12580
+ table: "workflowDefinitions",
12581
+ prepopulation: "optional_template",
12582
+ copyMode: "none",
12583
+ description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
12584
+ },
12585
+ {
12586
+ component: "kernel",
12587
+ table: "workflowPullRequests",
12588
+ prepopulation: "runtime_data",
12589
+ copyMode: "none",
12590
+ description: "Workflow pull requests are tenant workflow data."
12591
+ },
12592
+ {
12593
+ component: "kernel",
12594
+ table: "workflowStages",
12595
+ prepopulation: "optional_template",
12596
+ copyMode: "none",
12597
+ dependsOn: ["workflowDefinitions"],
12598
+ description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
12599
+ },
12600
+ {
12601
+ component: "kernel",
12602
+ table: "worktreeBeliefCluster",
12603
+ prepopulation: "runtime_data",
12604
+ copyMode: "none",
12605
+ description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
12606
+ },
12607
+ {
12608
+ component: "kernel",
12609
+ table: "worktrees",
12610
+ prepopulation: "runtime_data",
12611
+ copyMode: "none",
12612
+ description: "Worktrees are tenant/runtime planning data."
12613
+ },
12614
+ {
12615
+ component: "identity",
12616
+ table: "agents",
12617
+ prepopulation: "runtime_bootstrap",
12618
+ copyMode: "none",
12619
+ description: "Service agents are provisioned per tenant or service, not copied."
12620
+ },
12621
+ {
12622
+ component: "identity",
12623
+ table: "mcpWritePolicy",
12624
+ prepopulation: "required_template",
12625
+ copyMode: "template_global",
12626
+ scope: "global",
12627
+ uniqueKey: ["topicId", "role", "toolCategory"],
12628
+ description: "Global write policy defaults govern service and interactive MCP writes."
12629
+ },
12630
+ {
12631
+ component: "identity",
12632
+ table: "modelCallLogs",
12633
+ prepopulation: "runtime_log",
12634
+ copyMode: "none",
12635
+ description: "Model call logs are runtime telemetry."
12636
+ },
12637
+ {
12638
+ component: "identity",
12639
+ table: "modelFunctionSlots",
12640
+ prepopulation: "required_template",
12641
+ copyMode: "template_global",
12642
+ scope: "global",
12643
+ uniqueKey: ["slot"],
12644
+ description: "Function-to-model slots are required by model runtime resolution."
12645
+ },
12646
+ {
12647
+ component: "identity",
12648
+ table: "modelRegistry",
12649
+ prepopulation: "required_template",
12650
+ copyMode: "template_global",
12651
+ scope: "global",
12652
+ uniqueKey: ["key"],
12653
+ description: "Model catalog defaults are required by model runtime clients."
12654
+ },
12655
+ {
12656
+ component: "identity",
12657
+ table: "modelSlotConfigs",
12658
+ prepopulation: "required_template",
12659
+ copyMode: "template_global",
12660
+ scope: "global",
12661
+ uniqueKey: ["slot"],
12662
+ description: "Slot-level defaults are required before tenant overrides exist."
12663
+ },
12664
+ {
12665
+ component: "identity",
12666
+ table: "platformAudienceGrants",
12667
+ prepopulation: "runtime_data",
12668
+ copyMode: "none",
12669
+ description: "Audience grants are principal/group-specific access rows."
12670
+ },
12671
+ {
12672
+ component: "identity",
12673
+ table: "platformAudiences",
12674
+ prepopulation: "required_template",
12675
+ copyMode: "template_tenant_rewrite",
12676
+ scope: "tenant",
12677
+ uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
12678
+ description: "Default tenant audience taxonomy rows are rewritten into each tenant."
12679
+ },
12680
+ {
12681
+ component: "identity",
12682
+ table: "platformPolicyDecisionLogs",
12683
+ prepopulation: "runtime_log",
12684
+ copyMode: "none",
12685
+ description: "Policy decisions are runtime audit logs."
12686
+ },
12687
+ {
12688
+ component: "identity",
12689
+ table: "projectGrants",
12690
+ prepopulation: "runtime_data",
12691
+ copyMode: "none",
12692
+ description: "Project/topic grants are principal or group-specific access rows."
12693
+ },
12694
+ {
12695
+ component: "identity",
12696
+ table: "reasoningPermissions",
12697
+ prepopulation: "runtime_data",
12698
+ copyMode: "none",
12699
+ description: "Reasoning permissions are principal-specific policy rows."
12700
+ },
12701
+ {
12702
+ component: "identity",
12703
+ table: "tenantApiKeys",
12704
+ prepopulation: "runtime_secret",
12705
+ copyMode: "none",
12706
+ description: "API keys are tenant credentials and must never be copied."
12707
+ },
12708
+ {
12709
+ component: "identity",
12710
+ table: "tenantConfig",
12711
+ prepopulation: "required_template",
12712
+ copyMode: "template_tenant_rewrite",
12713
+ scope: "tenant",
12714
+ uniqueKey: ["tenantId"],
12715
+ description: "Tenant-local config defaults are rewritten during bootstrap."
12716
+ },
12717
+ {
12718
+ component: "identity",
12719
+ table: "tenantIntegrations",
12720
+ prepopulation: "required_template",
12721
+ copyMode: "template_tenant_rewrite",
12722
+ scope: "tenant",
12723
+ uniqueKey: ["tenantId", "integrationKey"],
12724
+ description: "Non-secret integration descriptors are rewritten into each tenant."
12725
+ },
12726
+ {
12727
+ component: "identity",
12728
+ table: "tenantModelSlotBindings",
12729
+ prepopulation: "runtime_secret",
12730
+ copyMode: "none",
12731
+ description: "Tenant model slot bindings reference provider secrets and are runtime-only."
12732
+ },
12733
+ {
12734
+ component: "identity",
12735
+ table: "tenantPolicies",
12736
+ prepopulation: "required_template",
12737
+ copyMode: "template_tenant_rewrite",
12738
+ scope: "tenant",
12739
+ uniqueKey: ["tenantId", "workspaceId", "roleName"],
12740
+ description: "Default tenant policy roles are rewritten during bootstrap."
12741
+ },
12742
+ {
12743
+ component: "identity",
12744
+ table: "tenantProviderSecrets",
12745
+ prepopulation: "runtime_secret",
12746
+ copyMode: "none",
12747
+ description: "Provider secrets are credentials and must never be copied."
12748
+ },
12749
+ {
12750
+ component: "identity",
12751
+ table: "tenantProxyGatewayUsage",
12752
+ prepopulation: "runtime_log",
12753
+ copyMode: "none",
12754
+ description: "Proxy gateway usage rows are runtime telemetry."
12755
+ },
12756
+ {
12757
+ component: "identity",
12758
+ table: "tenantProxyTokenMints",
12759
+ prepopulation: "runtime_secret",
12760
+ copyMode: "none",
12761
+ description: "Proxy token mints are ephemeral secret-bearing runtime rows."
12762
+ },
12763
+ {
12764
+ component: "identity",
12765
+ table: "tenantSandboxAuditEvents",
12766
+ prepopulation: "runtime_log",
12767
+ copyMode: "none",
12768
+ description: "Sandbox audit rows are runtime security logs."
12769
+ },
12770
+ {
12771
+ component: "identity",
12772
+ table: "tenantSecrets",
12773
+ prepopulation: "runtime_secret",
12774
+ copyMode: "none",
12775
+ description: "Tenant secrets are credentials and must never be copied."
12776
+ },
12777
+ {
12778
+ component: "identity",
12779
+ table: "toolAcls",
12780
+ prepopulation: "required_template",
12781
+ copyMode: "template_global",
12782
+ scope: "global",
12783
+ uniqueKey: ["role", "toolName"],
12784
+ description: "Default role-to-tool grants are required for SDK/MCP tool access."
12785
+ },
12786
+ {
12787
+ component: "identity",
12788
+ table: "toolRegistry",
12789
+ prepopulation: "required_template",
12790
+ copyMode: "template_global",
12791
+ scope: "global",
12792
+ uniqueKey: ["toolName"],
12793
+ description: "Core tool catalog rows are required before pack or tenant tools exist."
12794
+ },
12795
+ {
12796
+ component: "identity",
12797
+ table: "users",
12798
+ prepopulation: "runtime_bootstrap",
12799
+ copyMode: "none",
12800
+ description: "Users are created from Clerk/MC principal resolution, not copied."
12801
+ }
12802
+ ];
12803
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
12804
+ isCopyableSeedRequirement
12805
+ );
12806
+ TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
12807
+ (entry) => !isCopyableSeedRequirement(entry)
12808
+ ).map((entry) => entry.table);
12809
+
11562
12810
  // src/webhooks.ts
11563
12811
  var LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
11564
12812
  function normalizeUrl(url) {