@lucern/mcp 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/README.md +12 -7
- package/bin/lucern-mcp.js +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +25423 -0
- package/dist/cli.js.map +1 -0
- package/dist/gateway.d.ts +123 -1
- package/dist/gateway.js +2314 -181
- package/dist/gateway.js.map +1 -1
- package/dist/hosted-route.js +6502 -2852
- package/dist/hosted-route.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +19487 -15193
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +2 -34
- package/dist/runtime.js +1555 -780
- package/dist/runtime.js.map +1 -1
- package/package.json +6 -6
package/dist/gateway.js
CHANGED
|
@@ -1890,6 +1890,40 @@ defineTable({
|
|
|
1890
1890
|
{ kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
|
|
1891
1891
|
]
|
|
1892
1892
|
});
|
|
1893
|
+
defineTable({
|
|
1894
|
+
name: "oauthDeviceCodes",
|
|
1895
|
+
component: "mc",
|
|
1896
|
+
category: "identity",
|
|
1897
|
+
shape: z.object({
|
|
1898
|
+
"deviceCodeHash": z.string(),
|
|
1899
|
+
"userCode": z.string(),
|
|
1900
|
+
"clientId": z.string(),
|
|
1901
|
+
"scope": z.string(),
|
|
1902
|
+
"status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
|
|
1903
|
+
"expiresAt": z.number(),
|
|
1904
|
+
"intervalSeconds": z.number(),
|
|
1905
|
+
"lastPolledAt": z.number().optional(),
|
|
1906
|
+
"slowDownCount": z.number().optional(),
|
|
1907
|
+
"clerkUserId": z.string().optional(),
|
|
1908
|
+
"tenantId": idOf("tenants").optional(),
|
|
1909
|
+
"workspaceId": z.string().optional(),
|
|
1910
|
+
"principalId": z.string().optional(),
|
|
1911
|
+
"role": z.string().optional(),
|
|
1912
|
+
"scopes": z.array(z.string()).optional(),
|
|
1913
|
+
"sessionId": z.string().optional(),
|
|
1914
|
+
"approvedAt": z.number().optional(),
|
|
1915
|
+
"deniedAt": z.number().optional(),
|
|
1916
|
+
"consumedAt": z.number().optional(),
|
|
1917
|
+
"createdAt": z.number(),
|
|
1918
|
+
"updatedAt": z.number()
|
|
1919
|
+
}),
|
|
1920
|
+
indices: [
|
|
1921
|
+
{ kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
|
|
1922
|
+
{ kind: "index", name: "by_userCode", columns: ["userCode"] },
|
|
1923
|
+
{ kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
|
|
1924
|
+
{ kind: "index", name: "by_sessionId", columns: ["sessionId"] }
|
|
1925
|
+
]
|
|
1926
|
+
});
|
|
1893
1927
|
defineTable({
|
|
1894
1928
|
name: "servicePrincipalKeys",
|
|
1895
1929
|
component: "mc",
|
|
@@ -3846,7 +3880,9 @@ defineTable({
|
|
|
3846
3880
|
"defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
|
|
3847
3881
|
"deployments": z.record(z.object({
|
|
3848
3882
|
"url": z.string(),
|
|
3849
|
-
"
|
|
3883
|
+
"target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
|
|
3884
|
+
"encryptedDeployKey": z.string().optional(),
|
|
3885
|
+
"credentialRef": z.string().optional()
|
|
3850
3886
|
})).optional(),
|
|
3851
3887
|
"metadata": z.record(z.any()).optional(),
|
|
3852
3888
|
"createdBy": z.string().optional(),
|
|
@@ -5043,6 +5079,14 @@ var ADD_WORKTREE = {
|
|
|
5043
5079
|
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.",
|
|
5044
5080
|
parameters: {
|
|
5045
5081
|
title: { type: "string", description: "Worktree name/objective" },
|
|
5082
|
+
name: {
|
|
5083
|
+
type: "string",
|
|
5084
|
+
description: "Optional storage-name alias for callers that already use backend naming"
|
|
5085
|
+
},
|
|
5086
|
+
projectId: {
|
|
5087
|
+
type: "string",
|
|
5088
|
+
description: "Legacy topicId alias"
|
|
5089
|
+
},
|
|
5046
5090
|
topicId: { type: "string", description: "Optional topic scope hint" },
|
|
5047
5091
|
branchId: {
|
|
5048
5092
|
type: "string",
|
|
@@ -5056,14 +5100,87 @@ var ADD_WORKTREE = {
|
|
|
5056
5100
|
type: "string",
|
|
5057
5101
|
description: "The testable claim this worktree investigates"
|
|
5058
5102
|
},
|
|
5103
|
+
rationale: {
|
|
5104
|
+
type: "string",
|
|
5105
|
+
description: "Why this worktree exists and why it belongs in the campaign"
|
|
5106
|
+
},
|
|
5107
|
+
worktreeType: {
|
|
5108
|
+
type: "string",
|
|
5109
|
+
description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
|
|
5110
|
+
},
|
|
5111
|
+
gate: {
|
|
5112
|
+
type: "string",
|
|
5113
|
+
description: "Exit gate name for this worktree"
|
|
5114
|
+
},
|
|
5115
|
+
startDate: {
|
|
5116
|
+
type: "number",
|
|
5117
|
+
description: "Planned start timestamp in milliseconds since epoch"
|
|
5118
|
+
},
|
|
5119
|
+
endDate: {
|
|
5120
|
+
type: "number",
|
|
5121
|
+
description: "Planned end timestamp in milliseconds since epoch"
|
|
5122
|
+
},
|
|
5123
|
+
durationWeeks: {
|
|
5124
|
+
type: "number",
|
|
5125
|
+
description: "Planned duration in weeks"
|
|
5126
|
+
},
|
|
5127
|
+
confidenceImpact: {
|
|
5128
|
+
type: "string",
|
|
5129
|
+
description: "Expected confidence impact if the worktree succeeds",
|
|
5130
|
+
enum: ["high", "medium", "low"]
|
|
5131
|
+
},
|
|
5132
|
+
beliefFocus: {
|
|
5133
|
+
type: "string",
|
|
5134
|
+
description: "Natural-language focus spanning the target belief neighborhood"
|
|
5135
|
+
},
|
|
5059
5136
|
beliefIds: {
|
|
5060
5137
|
type: "array",
|
|
5061
|
-
description: "
|
|
5138
|
+
description: "Legacy alias for targetBeliefIds"
|
|
5139
|
+
},
|
|
5140
|
+
beliefs: {
|
|
5141
|
+
type: "array",
|
|
5142
|
+
description: "Legacy alias for targetBeliefIds"
|
|
5143
|
+
},
|
|
5144
|
+
targetBeliefIds: {
|
|
5145
|
+
type: "array",
|
|
5146
|
+
description: "Belief node IDs this worktree is expected to test or update"
|
|
5147
|
+
},
|
|
5148
|
+
targetQuestionIds: {
|
|
5149
|
+
type: "array",
|
|
5150
|
+
description: "Question node IDs this worktree is expected to answer"
|
|
5151
|
+
},
|
|
5152
|
+
keyQuestions: {
|
|
5153
|
+
type: "array",
|
|
5154
|
+
description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
|
|
5155
|
+
},
|
|
5156
|
+
evidenceSignals: {
|
|
5157
|
+
type: "array",
|
|
5158
|
+
description: "Evidence signal objects with signal, optional collected state, progress, and notes"
|
|
5159
|
+
},
|
|
5160
|
+
decisionGate: {
|
|
5161
|
+
type: "object",
|
|
5162
|
+
description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
|
|
5163
|
+
},
|
|
5164
|
+
goCriteria: {
|
|
5165
|
+
type: "array",
|
|
5166
|
+
description: "Shorthand go criteria used to build decisionGate"
|
|
5167
|
+
},
|
|
5168
|
+
noGoSignals: {
|
|
5169
|
+
type: "array",
|
|
5170
|
+
description: "Shorthand no-go signals used to build decisionGate"
|
|
5171
|
+
},
|
|
5172
|
+
proofArtifacts: {
|
|
5173
|
+
type: "array",
|
|
5174
|
+
description: "Expected proof artifacts required to close the worktree"
|
|
5062
5175
|
},
|
|
5063
5176
|
autoShape: {
|
|
5064
5177
|
type: "boolean",
|
|
5065
5178
|
description: "Whether to invoke inquiry auto-shaping during worktree creation"
|
|
5066
5179
|
},
|
|
5180
|
+
autoFixPolicy: {
|
|
5181
|
+
type: "object",
|
|
5182
|
+
description: "Policy for permitted automatic remediation inside the worktree"
|
|
5183
|
+
},
|
|
5067
5184
|
domainPackId: {
|
|
5068
5185
|
type: "string",
|
|
5069
5186
|
description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
|
|
@@ -5092,9 +5209,17 @@ var ADD_WORKTREE = {
|
|
|
5092
5209
|
type: "array",
|
|
5093
5210
|
description: "Worktree IDs blocked by this worktree"
|
|
5094
5211
|
},
|
|
5095
|
-
|
|
5212
|
+
staffingHint: {
|
|
5096
5213
|
type: "string",
|
|
5097
|
-
description: "
|
|
5214
|
+
description: "Suggested staffing or agent allocation note"
|
|
5215
|
+
},
|
|
5216
|
+
lensId: {
|
|
5217
|
+
type: "string",
|
|
5218
|
+
description: "Lens that scopes this worktree when applicable"
|
|
5219
|
+
},
|
|
5220
|
+
lastReconciledAt: {
|
|
5221
|
+
type: "number",
|
|
5222
|
+
description: "Timestamp when worktree metadata was last reconciled"
|
|
5098
5223
|
}
|
|
5099
5224
|
},
|
|
5100
5225
|
required: ["title", "topicId"],
|
|
@@ -5124,7 +5249,7 @@ var MERGE = {
|
|
|
5124
5249
|
worktreeId: { type: "string", description: "The worktree to merge" },
|
|
5125
5250
|
outcomes: {
|
|
5126
5251
|
type: "array",
|
|
5127
|
-
description: "
|
|
5252
|
+
description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
|
|
5128
5253
|
},
|
|
5129
5254
|
summary: { type: "string", description: "Overall findings summary" }
|
|
5130
5255
|
},
|
|
@@ -8143,6 +8268,69 @@ var GENERATE_SESSION_HANDOFF = {
|
|
|
8143
8268
|
tier: "showcase",
|
|
8144
8269
|
internal: true
|
|
8145
8270
|
};
|
|
8271
|
+
var BEGIN_BUILD_SESSION = {
|
|
8272
|
+
name: "begin_build_session",
|
|
8273
|
+
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.",
|
|
8274
|
+
parameters: {
|
|
8275
|
+
worktreeId: {
|
|
8276
|
+
type: "string",
|
|
8277
|
+
description: "The Lucern worktree ID to bootstrap."
|
|
8278
|
+
},
|
|
8279
|
+
branch: {
|
|
8280
|
+
type: "string",
|
|
8281
|
+
description: "Optional git branch name. Auto-generated from the worktree name when omitted."
|
|
8282
|
+
},
|
|
8283
|
+
branchBase: {
|
|
8284
|
+
type: "string",
|
|
8285
|
+
description: 'Base branch for the feature branch. Default: "staging".'
|
|
8286
|
+
},
|
|
8287
|
+
prBase: {
|
|
8288
|
+
type: "string",
|
|
8289
|
+
description: 'Target branch for the PR. Default: "staging".'
|
|
8290
|
+
},
|
|
8291
|
+
sessionMode: {
|
|
8292
|
+
type: "string",
|
|
8293
|
+
description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
|
|
8294
|
+
enum: ["async", "interactive"]
|
|
8295
|
+
},
|
|
8296
|
+
activateIfPlanning: {
|
|
8297
|
+
type: "boolean",
|
|
8298
|
+
description: "When true, automatically activate a planning worktree during bootstrap."
|
|
8299
|
+
}
|
|
8300
|
+
},
|
|
8301
|
+
required: ["worktreeId"],
|
|
8302
|
+
response: {
|
|
8303
|
+
description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
|
|
8304
|
+
fields: {
|
|
8305
|
+
topicId: "string \u2014 canonical topic scope",
|
|
8306
|
+
topicName: "string \u2014 human-readable topic name",
|
|
8307
|
+
worktreeId: "string \u2014 worktree ID",
|
|
8308
|
+
worktreeName: "string \u2014 human-readable worktree name",
|
|
8309
|
+
branch: "string \u2014 git branch name",
|
|
8310
|
+
branchBase: "string \u2014 base branch",
|
|
8311
|
+
prBase: "string \u2014 PR target branch",
|
|
8312
|
+
campaign: "number | null \u2014 top-level pipeline campaign",
|
|
8313
|
+
lane: "string \u2014 campaign lane",
|
|
8314
|
+
gate: "string \u2014 exit gate",
|
|
8315
|
+
hypothesis: "string \u2014 worktree hypothesis",
|
|
8316
|
+
focus: "string \u2014 session focus",
|
|
8317
|
+
status: "string \u2014 worktree status after optional activation",
|
|
8318
|
+
sessionMode: "string \u2014 async | interactive",
|
|
8319
|
+
targetBeliefIds: "array \u2014 scoped belief IDs",
|
|
8320
|
+
targetQuestionIds: "array \u2014 scoped question IDs",
|
|
8321
|
+
topBeliefs: "array \u2014 highest-confidence scoped beliefs",
|
|
8322
|
+
openQuestions: "array \u2014 open scoped questions",
|
|
8323
|
+
resolvedDecisions: "array \u2014 answered questions summarized for the session",
|
|
8324
|
+
dependencies: "array \u2014 upstream worktrees",
|
|
8325
|
+
unblocks: "array \u2014 downstream worktrees",
|
|
8326
|
+
mergeOrderNotes: "string \u2014 merge ordering advisory"
|
|
8327
|
+
}
|
|
8328
|
+
},
|
|
8329
|
+
ownerModule: "bootstrap",
|
|
8330
|
+
ontologyPrimitive: "worktree",
|
|
8331
|
+
tier: "showcase",
|
|
8332
|
+
internal: true
|
|
8333
|
+
};
|
|
8146
8334
|
var MCP_TOOL_CONTRACTS = {
|
|
8147
8335
|
// Belief lifecycle (commit, amend, fork, archive)
|
|
8148
8336
|
create_belief: CREATE_BELIEF,
|
|
@@ -8236,6 +8424,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8236
8424
|
get_agent_inbox: GET_AGENT_INBOX,
|
|
8237
8425
|
claim_files: CLAIM_FILES,
|
|
8238
8426
|
generate_session_handoff: GENERATE_SESSION_HANDOFF,
|
|
8427
|
+
begin_build_session: BEGIN_BUILD_SESSION,
|
|
8239
8428
|
// Policy / ACL (workhorse)
|
|
8240
8429
|
check_permission: CHECK_PERMISSION,
|
|
8241
8430
|
filter_by_permission: FILTER_BY_PERMISSION,
|
|
@@ -8449,6 +8638,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
|
|
|
8449
8638
|
"get_change_history",
|
|
8450
8639
|
"get_failure_log",
|
|
8451
8640
|
"record_attempt",
|
|
8641
|
+
"begin_build_session",
|
|
8452
8642
|
"push",
|
|
8453
8643
|
"open_pull_request",
|
|
8454
8644
|
"record_judgment",
|
|
@@ -8503,7 +8693,6 @@ var SDK_ONLY_OPERATION_NAMES = [
|
|
|
8503
8693
|
"find_semantic_orphans"
|
|
8504
8694
|
];
|
|
8505
8695
|
var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
|
|
8506
|
-
"begin_build_session",
|
|
8507
8696
|
"evaluate_engineering_contract",
|
|
8508
8697
|
"evaluate_research_contract"
|
|
8509
8698
|
];
|
|
@@ -8889,8 +9078,31 @@ function assertSurfaceCoverage(contracts) {
|
|
|
8889
9078
|
}
|
|
8890
9079
|
}
|
|
8891
9080
|
}
|
|
8892
|
-
|
|
8893
|
-
|
|
9081
|
+
var jsonRecordSchema2 = z.record(z.unknown());
|
|
9082
|
+
var observationArgs = z.object({
|
|
9083
|
+
topicId: z.string().optional().describe("Topic scope for the observation."),
|
|
9084
|
+
summary: z.string().describe("Short observation summary."),
|
|
9085
|
+
text: z.string().optional().describe("Canonical observation text alias."),
|
|
9086
|
+
title: z.string().optional().describe("Optional observation title."),
|
|
9087
|
+
content: z.string().optional().describe("Optional rich observation content."),
|
|
9088
|
+
contentType: z.string().optional().describe("Observation content type."),
|
|
9089
|
+
kind: z.string().optional().describe("Evidence kind to store."),
|
|
9090
|
+
observationType: z.string().optional().describe("Observation type."),
|
|
9091
|
+
tags: z.array(z.string()).optional().describe("Observation tags."),
|
|
9092
|
+
source: z.string().optional().describe("Observation source label."),
|
|
9093
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
9094
|
+
externalSourceType: z.string().optional().describe("External source type for imported observations."),
|
|
9095
|
+
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
9096
|
+
confidence: z.number().optional().describe("Observation confidence."),
|
|
9097
|
+
metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
|
|
9098
|
+
rationale: z.string().optional().describe("Why this observation should be recorded.")
|
|
9099
|
+
});
|
|
9100
|
+
var observationContextArgs = z.object({
|
|
9101
|
+
topicId: z.string().describe("Topic scope."),
|
|
9102
|
+
query: z.string().optional().describe("Optional context query."),
|
|
9103
|
+
limit: z.number().optional().describe("Maximum observations to return."),
|
|
9104
|
+
status: z.string().optional().describe("Observation status filter.")
|
|
9105
|
+
});
|
|
8894
9106
|
var observationInput = (input, context) => withUserId(
|
|
8895
9107
|
compactRecord4({
|
|
8896
9108
|
projectId: input.projectId,
|
|
@@ -8949,7 +9161,8 @@ var contextContracts = [
|
|
|
8949
9161
|
observationId: output && typeof output === "object" ? output.nodeId : void 0,
|
|
8950
9162
|
observationType: input.observationType
|
|
8951
9163
|
})
|
|
8952
|
-
}
|
|
9164
|
+
},
|
|
9165
|
+
args: observationArgs
|
|
8953
9166
|
}),
|
|
8954
9167
|
surfaceContract({
|
|
8955
9168
|
name: "get_observation_context",
|
|
@@ -8970,7 +9183,8 @@ var contextContracts = [
|
|
|
8970
9183
|
status: input.status,
|
|
8971
9184
|
userId: input.userId
|
|
8972
9185
|
})
|
|
8973
|
-
}
|
|
9186
|
+
},
|
|
9187
|
+
args: observationContextArgs
|
|
8974
9188
|
})
|
|
8975
9189
|
];
|
|
8976
9190
|
|
|
@@ -9033,8 +9247,45 @@ var identityContracts = [
|
|
|
9033
9247
|
}
|
|
9034
9248
|
})
|
|
9035
9249
|
];
|
|
9036
|
-
|
|
9037
|
-
|
|
9250
|
+
var jsonRecordSchema3 = z.record(z.unknown());
|
|
9251
|
+
var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
|
|
9252
|
+
var reversibilitySchema = z.enum([
|
|
9253
|
+
"irreversible",
|
|
9254
|
+
"hard_to_reverse",
|
|
9255
|
+
"reversible",
|
|
9256
|
+
"trivial"
|
|
9257
|
+
]);
|
|
9258
|
+
var predictionMetaSchema = z.object({
|
|
9259
|
+
isPrediction: z.boolean().describe("Whether this belief is a prediction."),
|
|
9260
|
+
registeredAt: z.number().describe("Timestamp when the prediction was registered."),
|
|
9261
|
+
expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
|
|
9262
|
+
});
|
|
9263
|
+
var createBeliefArgs = z.object({
|
|
9264
|
+
canonicalText: z.string().describe("The belief statement the agent holds to be true."),
|
|
9265
|
+
topicId: z.string().optional().describe("Topic scope hint for the belief."),
|
|
9266
|
+
baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
|
|
9267
|
+
beliefType: z.string().optional().describe("Schema belief type."),
|
|
9268
|
+
metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
|
|
9269
|
+
rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
|
|
9270
|
+
pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
|
|
9271
|
+
worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
|
|
9272
|
+
sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
|
|
9273
|
+
sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
|
|
9274
|
+
reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
|
|
9275
|
+
predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
|
|
9276
|
+
});
|
|
9277
|
+
var forkBeliefArgs = z.object({
|
|
9278
|
+
nodeId: z.string().describe("The scored belief to fork from."),
|
|
9279
|
+
newFormulation: z.string().describe("The evolved belief statement."),
|
|
9280
|
+
forkReason: z.enum([
|
|
9281
|
+
"refinement",
|
|
9282
|
+
"contradiction_response",
|
|
9283
|
+
"scope_change",
|
|
9284
|
+
"confidence_collapse",
|
|
9285
|
+
"manual"
|
|
9286
|
+
]).describe("Why this fork was created."),
|
|
9287
|
+
rationale: z.string().optional().describe("Why the fork is warranted.")
|
|
9288
|
+
});
|
|
9038
9289
|
var beliefLookupInput = (input) => compactRecord4({
|
|
9039
9290
|
nodeId: input.nodeId ?? input.id ?? input.beliefId,
|
|
9040
9291
|
beliefId: input.beliefId
|
|
@@ -9109,7 +9360,8 @@ var beliefsContracts = [
|
|
|
9109
9360
|
functionName: "create",
|
|
9110
9361
|
kind: "mutation",
|
|
9111
9362
|
inputProjection: createBeliefInput
|
|
9112
|
-
}
|
|
9363
|
+
},
|
|
9364
|
+
args: createBeliefArgs
|
|
9113
9365
|
}),
|
|
9114
9366
|
surfaceContract({
|
|
9115
9367
|
name: "get_belief",
|
|
@@ -9200,7 +9452,8 @@ var beliefsContracts = [
|
|
|
9200
9452
|
functionName: "forkBelief",
|
|
9201
9453
|
kind: "mutation",
|
|
9202
9454
|
inputProjection: forkBeliefInput
|
|
9203
|
-
}
|
|
9455
|
+
},
|
|
9456
|
+
args: forkBeliefArgs
|
|
9204
9457
|
}),
|
|
9205
9458
|
surfaceContract({
|
|
9206
9459
|
name: "archive_belief",
|
|
@@ -9281,8 +9534,46 @@ var beliefsContracts = [
|
|
|
9281
9534
|
}
|
|
9282
9535
|
})
|
|
9283
9536
|
];
|
|
9284
|
-
|
|
9285
|
-
|
|
9537
|
+
var jsonRecordSchema4 = z.record(z.unknown());
|
|
9538
|
+
var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
|
|
9539
|
+
var createEvidenceArgs = z.object({
|
|
9540
|
+
topicId: z.string().optional().describe("Topic scope for the evidence."),
|
|
9541
|
+
text: z.string().describe("Canonical evidence text."),
|
|
9542
|
+
source: z.string().optional().describe("Source URL or source label."),
|
|
9543
|
+
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
9544
|
+
targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
|
|
9545
|
+
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
9546
|
+
evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
|
|
9547
|
+
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
9548
|
+
weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
|
|
9549
|
+
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
9550
|
+
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
9551
|
+
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
9552
|
+
title: z.string().optional().describe("Optional short title."),
|
|
9553
|
+
content: z.string().optional().describe("Optional long-form content."),
|
|
9554
|
+
contentType: z.string().optional().describe("Content format or MIME hint."),
|
|
9555
|
+
kind: z.string().optional().describe("Evidence kind."),
|
|
9556
|
+
tags: z.array(z.string()).optional().describe("Evidence tags."),
|
|
9557
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
9558
|
+
externalSourceType: z.string().optional().describe("External source type for imported evidence."),
|
|
9559
|
+
sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
|
|
9560
|
+
methodology: z.string().optional().describe("Collection methodology."),
|
|
9561
|
+
informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
|
|
9562
|
+
sourceDescription: z.string().optional().describe("Human-readable source description.")
|
|
9563
|
+
});
|
|
9564
|
+
var addEvidenceArgs = z.object({
|
|
9565
|
+
canonicalText: z.string().describe("The evidence statement."),
|
|
9566
|
+
text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
|
|
9567
|
+
topicId: z.string().optional().describe("Topic scope hint."),
|
|
9568
|
+
sourceUrl: z.string().optional().describe("URL of the source material."),
|
|
9569
|
+
targetNodeId: z.string().describe("The belief this evidence bears on."),
|
|
9570
|
+
weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
|
|
9571
|
+
reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
|
|
9572
|
+
title: z.string().optional().describe("Optional short title."),
|
|
9573
|
+
content: z.string().optional().describe("Optional long-form evidence content."),
|
|
9574
|
+
contentType: z.string().optional().describe("Content format or MIME hint."),
|
|
9575
|
+
metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
|
|
9576
|
+
});
|
|
9286
9577
|
var evidenceIdInput = (input) => compactRecord4({
|
|
9287
9578
|
evidenceId: input.evidenceId,
|
|
9288
9579
|
insightId: input.insightId,
|
|
@@ -9357,7 +9648,8 @@ var evidenceContracts = [
|
|
|
9357
9648
|
functionName: "create",
|
|
9358
9649
|
kind: "mutation",
|
|
9359
9650
|
inputProjection: createEvidenceInput
|
|
9360
|
-
}
|
|
9651
|
+
},
|
|
9652
|
+
args: createEvidenceArgs
|
|
9361
9653
|
}),
|
|
9362
9654
|
surfaceContract({
|
|
9363
9655
|
name: "add_evidence",
|
|
@@ -9393,7 +9685,8 @@ var evidenceContracts = [
|
|
|
9393
9685
|
context
|
|
9394
9686
|
);
|
|
9395
9687
|
}
|
|
9396
|
-
}
|
|
9688
|
+
},
|
|
9689
|
+
args: addEvidenceArgs
|
|
9397
9690
|
}),
|
|
9398
9691
|
surfaceContract({
|
|
9399
9692
|
name: "get_evidence",
|
|
@@ -9500,8 +9793,91 @@ var evidenceContracts = [
|
|
|
9500
9793
|
}
|
|
9501
9794
|
})
|
|
9502
9795
|
];
|
|
9503
|
-
|
|
9504
|
-
|
|
9796
|
+
var jsonRecordSchema5 = z.record(z.unknown());
|
|
9797
|
+
var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
|
|
9798
|
+
var kernelQuestionPrioritySchema = z.enum([
|
|
9799
|
+
"critical",
|
|
9800
|
+
"high",
|
|
9801
|
+
"medium",
|
|
9802
|
+
"low"
|
|
9803
|
+
]);
|
|
9804
|
+
var questionTypeSchema = z.enum([
|
|
9805
|
+
"validation",
|
|
9806
|
+
"falsification",
|
|
9807
|
+
"assumption_probe",
|
|
9808
|
+
"prediction_test",
|
|
9809
|
+
"counterfactual",
|
|
9810
|
+
"discovery",
|
|
9811
|
+
"clarification",
|
|
9812
|
+
"comparison",
|
|
9813
|
+
"causal",
|
|
9814
|
+
"mechanism",
|
|
9815
|
+
"general"
|
|
9816
|
+
]);
|
|
9817
|
+
var createQuestionArgs = z.object({
|
|
9818
|
+
text: z.string().describe("The question text."),
|
|
9819
|
+
question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
|
|
9820
|
+
topicId: z.string().optional().describe("Topic scope hint."),
|
|
9821
|
+
priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
|
|
9822
|
+
linkedBeliefId: z.string().optional().describe("Belief this question tests."),
|
|
9823
|
+
linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
|
|
9824
|
+
metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
|
|
9825
|
+
category: z.string().optional().describe("Question category."),
|
|
9826
|
+
source: z.string().optional().describe("Question source."),
|
|
9827
|
+
testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
|
|
9828
|
+
importance: z.number().optional().describe("Numeric importance score."),
|
|
9829
|
+
epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
|
|
9830
|
+
sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
|
|
9831
|
+
linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
|
|
9832
|
+
questionType: questionTypeSchema.optional().describe("Question type."),
|
|
9833
|
+
questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
|
|
9834
|
+
});
|
|
9835
|
+
var refineQuestionArgs = z.object({
|
|
9836
|
+
id: z.string().describe("The question to refine."),
|
|
9837
|
+
text: z.string().describe("Updated question text."),
|
|
9838
|
+
question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
|
|
9839
|
+
rationale: z.string().optional().describe("Why the question is refined."),
|
|
9840
|
+
category: z.string().optional().describe("Updated question category."),
|
|
9841
|
+
priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
|
|
9842
|
+
});
|
|
9843
|
+
var createAnswerArgs = z.object({
|
|
9844
|
+
questionNodeId: z.string().describe("The question node ID this answer responds to."),
|
|
9845
|
+
questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
|
|
9846
|
+
answerText: z.string().describe("The answer content."),
|
|
9847
|
+
topicId: z.string().optional().describe("Topic scope for the answer."),
|
|
9848
|
+
confidence: z.string().optional().describe("Answer confidence."),
|
|
9849
|
+
evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
|
|
9850
|
+
answerSource: z.string().optional().describe("How the answer was produced."),
|
|
9851
|
+
worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
|
|
9852
|
+
sprintId: z.string().optional().describe("Legacy sprint identifier.")
|
|
9853
|
+
});
|
|
9854
|
+
var answerQuestionArgs = z.object({
|
|
9855
|
+
id: z.string().describe("Canonical question ID."),
|
|
9856
|
+
topicId: z.string().describe("Topic scope for the answer."),
|
|
9857
|
+
text: z.string().describe("Answer text."),
|
|
9858
|
+
confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
|
|
9859
|
+
evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
|
|
9860
|
+
rationale: z.string().optional().describe("Why this answer is credible."),
|
|
9861
|
+
questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
|
|
9862
|
+
questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
|
|
9863
|
+
answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
|
|
9864
|
+
evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
|
|
9865
|
+
answerSource: z.string().optional().describe("How the answer was produced."),
|
|
9866
|
+
worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
|
|
9867
|
+
sprintId: z.string().optional().describe("Legacy sprint identifier.")
|
|
9868
|
+
});
|
|
9869
|
+
var missingQuestionsArgs = z.object({
|
|
9870
|
+
topicId: z.string().describe("Topic scope."),
|
|
9871
|
+
minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
|
|
9872
|
+
status: z.string().optional().describe("Question status filter."),
|
|
9873
|
+
limit: z.number().optional().describe("Maximum questions to inspect.")
|
|
9874
|
+
});
|
|
9875
|
+
var falsificationQuestionsArgs = z.object({
|
|
9876
|
+
topicId: z.string().describe("Topic scope."),
|
|
9877
|
+
beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
|
|
9878
|
+
status: z.string().optional().describe("Question status filter."),
|
|
9879
|
+
limit: z.number().optional().describe("Maximum questions to inspect.")
|
|
9880
|
+
});
|
|
9505
9881
|
var questionNodeInput = (input) => compactRecord4({
|
|
9506
9882
|
nodeId: input.nodeId ?? input.id ?? input.questionId,
|
|
9507
9883
|
questionId: input.questionId
|
|
@@ -9548,7 +9924,8 @@ var questionsContracts = [
|
|
|
9548
9924
|
functionName: "create",
|
|
9549
9925
|
kind: "mutation",
|
|
9550
9926
|
inputProjection: createQuestionInput
|
|
9551
|
-
}
|
|
9927
|
+
},
|
|
9928
|
+
args: createQuestionArgs
|
|
9552
9929
|
}),
|
|
9553
9930
|
surfaceContract({
|
|
9554
9931
|
name: "get_question",
|
|
@@ -9604,7 +9981,8 @@ var questionsContracts = [
|
|
|
9604
9981
|
category: input.category,
|
|
9605
9982
|
priority: input.priority
|
|
9606
9983
|
})
|
|
9607
|
-
}
|
|
9984
|
+
},
|
|
9985
|
+
args: refineQuestionArgs
|
|
9608
9986
|
}),
|
|
9609
9987
|
surfaceContract({
|
|
9610
9988
|
name: "update_question_status",
|
|
@@ -9680,7 +10058,8 @@ var questionsContracts = [
|
|
|
9680
10058
|
}),
|
|
9681
10059
|
context
|
|
9682
10060
|
)
|
|
9683
|
-
}
|
|
10061
|
+
},
|
|
10062
|
+
args: createAnswerArgs
|
|
9684
10063
|
}),
|
|
9685
10064
|
surfaceContract({
|
|
9686
10065
|
name: "answer_question",
|
|
@@ -9709,7 +10088,8 @@ var questionsContracts = [
|
|
|
9709
10088
|
}),
|
|
9710
10089
|
context
|
|
9711
10090
|
)
|
|
9712
|
-
}
|
|
10091
|
+
},
|
|
10092
|
+
args: answerQuestionArgs
|
|
9713
10093
|
}),
|
|
9714
10094
|
surfaceContract({
|
|
9715
10095
|
name: "get_answer",
|
|
@@ -9741,7 +10121,8 @@ var questionsContracts = [
|
|
|
9741
10121
|
functionName: "getByTopic",
|
|
9742
10122
|
kind: "query",
|
|
9743
10123
|
inputProjection: questionTopicInput
|
|
9744
|
-
}
|
|
10124
|
+
},
|
|
10125
|
+
args: missingQuestionsArgs
|
|
9745
10126
|
}),
|
|
9746
10127
|
surfaceContract({
|
|
9747
10128
|
name: "get_high_priority_questions",
|
|
@@ -9776,11 +10157,22 @@ var questionsContracts = [
|
|
|
9776
10157
|
functionName: "getByTopic",
|
|
9777
10158
|
kind: "query",
|
|
9778
10159
|
inputProjection: questionTopicInput
|
|
9779
|
-
}
|
|
10160
|
+
},
|
|
10161
|
+
args: falsificationQuestionsArgs
|
|
9780
10162
|
})
|
|
9781
10163
|
];
|
|
9782
|
-
|
|
9783
|
-
|
|
10164
|
+
var updateTopicArgs = z.object({
|
|
10165
|
+
id: z.string().describe("Topic ID."),
|
|
10166
|
+
topicId: z.string().optional().describe("Topic ID alias."),
|
|
10167
|
+
name: z.string().optional().describe("Topic name."),
|
|
10168
|
+
description: z.string().optional().describe("Topic description."),
|
|
10169
|
+
type: z.string().optional().describe("Topic type."),
|
|
10170
|
+
status: z.string().optional().describe("Topic status."),
|
|
10171
|
+
visibility: z.string().optional().describe("Topic visibility."),
|
|
10172
|
+
ontologyId: z.string().optional().describe("Ontology to bind."),
|
|
10173
|
+
clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
|
|
10174
|
+
metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
|
|
10175
|
+
});
|
|
9784
10176
|
var topicIdInput = (input) => compactRecord4({
|
|
9785
10177
|
id: input.id ?? input.topicId
|
|
9786
10178
|
});
|
|
@@ -9861,7 +10253,8 @@ var topicsContracts = [
|
|
|
9861
10253
|
functionName: "update",
|
|
9862
10254
|
kind: "mutation",
|
|
9863
10255
|
inputProjection: updateTopicInput
|
|
9864
|
-
}
|
|
10256
|
+
},
|
|
10257
|
+
args: updateTopicArgs
|
|
9865
10258
|
}),
|
|
9866
10259
|
surfaceContract({
|
|
9867
10260
|
name: "get_topic_tree",
|
|
@@ -9880,8 +10273,27 @@ var topicsContracts = [
|
|
|
9880
10273
|
}
|
|
9881
10274
|
})
|
|
9882
10275
|
];
|
|
9883
|
-
|
|
9884
|
-
|
|
10276
|
+
var lensPerspectiveSchema = z.enum([
|
|
10277
|
+
"investigation",
|
|
10278
|
+
"monitoring",
|
|
10279
|
+
"analysis",
|
|
10280
|
+
"comparison",
|
|
10281
|
+
"taxonomy"
|
|
10282
|
+
]);
|
|
10283
|
+
var jsonRecordSchema6 = z.record(z.unknown());
|
|
10284
|
+
var createLensArgs = z.object({
|
|
10285
|
+
name: z.string().describe("Lens name."),
|
|
10286
|
+
workspaceId: z.string().optional().describe("Workspace scope for the lens."),
|
|
10287
|
+
topicId: z.string().optional().describe("Originating topic scope."),
|
|
10288
|
+
description: z.string().optional().describe("What this lens investigates or monitors."),
|
|
10289
|
+
perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
|
|
10290
|
+
promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
|
|
10291
|
+
workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
|
|
10292
|
+
taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
|
|
10293
|
+
questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
|
|
10294
|
+
filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
|
|
10295
|
+
metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
|
|
10296
|
+
});
|
|
9885
10297
|
var createLensInput = (input, context) => compactRecord4({
|
|
9886
10298
|
name: input.name,
|
|
9887
10299
|
description: input.description,
|
|
@@ -9918,7 +10330,8 @@ var lensesContracts = [
|
|
|
9918
10330
|
functionName: "create",
|
|
9919
10331
|
kind: "mutation",
|
|
9920
10332
|
inputProjection: createLensInput
|
|
9921
|
-
}
|
|
10333
|
+
},
|
|
10334
|
+
args: createLensArgs
|
|
9922
10335
|
}),
|
|
9923
10336
|
surfaceContract({
|
|
9924
10337
|
name: "list_lenses",
|
|
@@ -9980,8 +10393,18 @@ var lensesContracts = [
|
|
|
9980
10393
|
}
|
|
9981
10394
|
})
|
|
9982
10395
|
];
|
|
9983
|
-
|
|
9984
|
-
|
|
10396
|
+
var updateOntologyArgs = z.object({
|
|
10397
|
+
id: z.string().describe("Ontology definition ID."),
|
|
10398
|
+
ontologyId: z.string().optional().describe("Ontology ID alias."),
|
|
10399
|
+
name: z.string().optional().describe("Ontology display name."),
|
|
10400
|
+
description: z.string().optional().describe("Ontology description."),
|
|
10401
|
+
status: z.string().optional().describe("Ontology lifecycle status.")
|
|
10402
|
+
});
|
|
10403
|
+
var ontologyVersionLifecycleArgs = z.object({
|
|
10404
|
+
id: z.string().describe("Ontology version ID."),
|
|
10405
|
+
versionId: z.string().optional().describe("Ontology version ID alias."),
|
|
10406
|
+
ontologyId: z.string().optional().describe("Ontology definition ID.")
|
|
10407
|
+
});
|
|
9985
10408
|
var ontologyIdInput = (input) => compactRecord4({
|
|
9986
10409
|
id: input.id ?? input.ontologyId
|
|
9987
10410
|
});
|
|
@@ -10060,11 +10483,11 @@ var ontologiesContracts = [
|
|
|
10060
10483
|
id: input.id ?? input.ontologyId,
|
|
10061
10484
|
name: input.name,
|
|
10062
10485
|
description: input.description,
|
|
10063
|
-
parentOntologyId: input.parentOntologyId,
|
|
10064
10486
|
status: input.status,
|
|
10065
10487
|
actorId: input.actorId
|
|
10066
10488
|
})
|
|
10067
|
-
}
|
|
10489
|
+
},
|
|
10490
|
+
args: updateOntologyArgs
|
|
10068
10491
|
}),
|
|
10069
10492
|
surfaceContract({
|
|
10070
10493
|
name: "archive_ontology",
|
|
@@ -10147,7 +10570,8 @@ var ontologiesContracts = [
|
|
|
10147
10570
|
functionName: "publishOntologyVersion",
|
|
10148
10571
|
kind: "mutation",
|
|
10149
10572
|
inputProjection: ontologyVersionIdInput
|
|
10150
|
-
}
|
|
10573
|
+
},
|
|
10574
|
+
args: ontologyVersionLifecycleArgs
|
|
10151
10575
|
}),
|
|
10152
10576
|
surfaceContract({
|
|
10153
10577
|
name: "deprecate_ontology_version",
|
|
@@ -10163,7 +10587,8 @@ var ontologiesContracts = [
|
|
|
10163
10587
|
functionName: "deprecateOntologyVersion",
|
|
10164
10588
|
kind: "mutation",
|
|
10165
10589
|
inputProjection: ontologyVersionIdInput
|
|
10166
|
-
}
|
|
10590
|
+
},
|
|
10591
|
+
args: ontologyVersionLifecycleArgs
|
|
10167
10592
|
}),
|
|
10168
10593
|
surfaceContract({
|
|
10169
10594
|
name: "resolve_effective_ontology",
|
|
@@ -10182,8 +10607,76 @@ var ontologiesContracts = [
|
|
|
10182
10607
|
}
|
|
10183
10608
|
})
|
|
10184
10609
|
];
|
|
10185
|
-
|
|
10186
|
-
|
|
10610
|
+
var autoFixPolicyInputSchema = z.object({
|
|
10611
|
+
enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
|
|
10612
|
+
mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
|
|
10613
|
+
maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
|
|
10614
|
+
reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
|
|
10615
|
+
maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
|
|
10616
|
+
permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
|
|
10617
|
+
requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
|
|
10618
|
+
escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
|
|
10619
|
+
}).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
|
|
10620
|
+
var worktreeKeyQuestionInputSchema = z.object({
|
|
10621
|
+
question: z.string().describe("Question the worktree must resolve."),
|
|
10622
|
+
status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
|
|
10623
|
+
answer: z.string().optional().describe("Captured answer when the key question is resolved."),
|
|
10624
|
+
answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
|
|
10625
|
+
linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
|
|
10626
|
+
}).passthrough().describe("Question contract embedded in the worktree plan.");
|
|
10627
|
+
var worktreeEvidenceSignalInputSchema = z.object({
|
|
10628
|
+
signal: z.string().describe("Evidence signal the worktree should collect."),
|
|
10629
|
+
collected: z.boolean().optional().describe("Whether the signal has already been collected."),
|
|
10630
|
+
progress: z.string().optional().describe("Collection progress note for the signal."),
|
|
10631
|
+
notes: z.string().optional().describe("Additional evidence collection notes.")
|
|
10632
|
+
}).passthrough().describe("Evidence signal embedded in the worktree plan.");
|
|
10633
|
+
var worktreeDecisionGateInputSchema = z.object({
|
|
10634
|
+
goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
|
|
10635
|
+
noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
|
|
10636
|
+
verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
|
|
10637
|
+
verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
|
|
10638
|
+
decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
|
|
10639
|
+
decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
|
|
10640
|
+
}).passthrough().describe("Decision gate contract for worktree activation or exit.");
|
|
10641
|
+
var addWorktreeArgs = z.object({
|
|
10642
|
+
title: z.string().optional().describe("Human-readable worktree name or objective."),
|
|
10643
|
+
name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
|
|
10644
|
+
topicId: z.string().describe("Primary topic scope for the worktree."),
|
|
10645
|
+
projectId: z.string().optional().describe("Legacy topicId alias."),
|
|
10646
|
+
branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
|
|
10647
|
+
objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
|
|
10648
|
+
hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
|
|
10649
|
+
rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
|
|
10650
|
+
worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
|
|
10651
|
+
gate: z.string().optional().describe("Exit gate for this worktree."),
|
|
10652
|
+
startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
|
|
10653
|
+
endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
|
|
10654
|
+
durationWeeks: z.number().optional().describe("Planned duration in weeks."),
|
|
10655
|
+
confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
|
|
10656
|
+
beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
|
|
10657
|
+
beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
|
|
10658
|
+
beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
|
|
10659
|
+
targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
|
|
10660
|
+
targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
|
|
10661
|
+
keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
|
|
10662
|
+
evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
|
|
10663
|
+
decisionGate: worktreeDecisionGateInputSchema.optional(),
|
|
10664
|
+
goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
|
|
10665
|
+
noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
|
|
10666
|
+
proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
|
|
10667
|
+
autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
|
|
10668
|
+
autoFixPolicy: autoFixPolicyInputSchema.optional(),
|
|
10669
|
+
domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
|
|
10670
|
+
campaign: z.number().optional().describe("Top-level pipeline campaign number."),
|
|
10671
|
+
lane: z.string().optional().describe("Campaign lane for the worktree."),
|
|
10672
|
+
laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
|
|
10673
|
+
orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
|
|
10674
|
+
dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
|
|
10675
|
+
blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
|
|
10676
|
+
staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
|
|
10677
|
+
lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
|
|
10678
|
+
lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
|
|
10679
|
+
});
|
|
10187
10680
|
var worktreeIdInput = (input) => compactRecord4({
|
|
10188
10681
|
worktreeId: input.worktreeId ?? input.id
|
|
10189
10682
|
});
|
|
@@ -10216,6 +10709,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
|
|
|
10216
10709
|
autoFixPolicy: input.autoFixPolicy,
|
|
10217
10710
|
lastReconciledAt: input.lastReconciledAt
|
|
10218
10711
|
});
|
|
10712
|
+
var worktreeMetadataArgs = z.object({
|
|
10713
|
+
worktreeId: z.string().describe("The worktree to update."),
|
|
10714
|
+
id: z.string().optional().describe("Worktree ID alias."),
|
|
10715
|
+
topicId: z.string().optional().describe("Primary topic scope."),
|
|
10716
|
+
additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
|
|
10717
|
+
status: z.string().optional().describe("Worktree lifecycle status."),
|
|
10718
|
+
campaign: z.number().optional().describe("Top-level pipeline campaign."),
|
|
10719
|
+
lane: z.string().optional().describe("Campaign lane."),
|
|
10720
|
+
laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
|
|
10721
|
+
orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
|
|
10722
|
+
gate: z.string().optional().describe("Exit gate for this worktree."),
|
|
10723
|
+
hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
|
|
10724
|
+
objective: z.string().optional().describe("Reasoning objective for the worktree."),
|
|
10725
|
+
rationale: z.string().optional().describe("Why this worktree is sequenced here."),
|
|
10726
|
+
proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
|
|
10727
|
+
staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
|
|
10728
|
+
blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
|
|
10729
|
+
dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
|
|
10730
|
+
lensId: z.string().optional().describe("Lens that scopes this worktree."),
|
|
10731
|
+
autoFixPolicy: autoFixPolicyInputSchema.optional(),
|
|
10732
|
+
lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
|
|
10733
|
+
});
|
|
10734
|
+
var pushArgs = worktreeMetadataArgs.extend({
|
|
10735
|
+
targetContext: z.string().describe("Where to push merged findings."),
|
|
10736
|
+
beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
|
|
10737
|
+
});
|
|
10738
|
+
var openPullRequestArgs = worktreeMetadataArgs.extend({
|
|
10739
|
+
reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
|
|
10740
|
+
summary: z.string().describe("Summary of findings and why they are ready for review.")
|
|
10741
|
+
});
|
|
10742
|
+
var mergeKeyFindingsInput = (input) => {
|
|
10743
|
+
if (Array.isArray(input.keyFindings)) {
|
|
10744
|
+
return input.keyFindings;
|
|
10745
|
+
}
|
|
10746
|
+
if (Array.isArray(input.outcomes)) {
|
|
10747
|
+
const findings = input.outcomes.filter(
|
|
10748
|
+
(outcome) => typeof outcome === "string" && outcome.trim().length > 0
|
|
10749
|
+
);
|
|
10750
|
+
if (findings.length > 0) {
|
|
10751
|
+
return findings;
|
|
10752
|
+
}
|
|
10753
|
+
}
|
|
10754
|
+
return [input.summary ?? "Merged worktree"];
|
|
10755
|
+
};
|
|
10219
10756
|
var listAllWorktreesInput = (input) => compactRecord4({
|
|
10220
10757
|
status: input.status,
|
|
10221
10758
|
lane: input.lane,
|
|
@@ -10223,6 +10760,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
|
|
|
10223
10760
|
limit: input.limit
|
|
10224
10761
|
});
|
|
10225
10762
|
var worktreesContracts = [
|
|
10763
|
+
surfaceContract({
|
|
10764
|
+
name: "begin_build_session",
|
|
10765
|
+
kind: "mutation",
|
|
10766
|
+
domain: "worktrees",
|
|
10767
|
+
surfaceClass: "platform_internal",
|
|
10768
|
+
path: "/mcp/build-session/begin",
|
|
10769
|
+
sdkNamespace: "worktrees",
|
|
10770
|
+
sdkMethod: "beginBuildSession",
|
|
10771
|
+
summary: "Begin a coding build session for a worktree."
|
|
10772
|
+
}),
|
|
10226
10773
|
surfaceContract({
|
|
10227
10774
|
name: "add_worktree",
|
|
10228
10775
|
kind: "mutation",
|
|
@@ -10239,13 +10786,12 @@ var worktreesContracts = [
|
|
|
10239
10786
|
inputProjection: (input, context) => withCreatedBy(
|
|
10240
10787
|
compactRecord4({
|
|
10241
10788
|
name: input.name ?? input.title,
|
|
10242
|
-
topicId: input.topicId,
|
|
10789
|
+
topicId: input.topicId ?? input.projectId,
|
|
10243
10790
|
worktreeType: input.worktreeType,
|
|
10244
10791
|
objective: input.objective,
|
|
10245
10792
|
gate: input.gate,
|
|
10246
10793
|
hypothesis: input.hypothesis,
|
|
10247
10794
|
rationale: input.rationale,
|
|
10248
|
-
signal: input.signal,
|
|
10249
10795
|
startDate: input.startDate,
|
|
10250
10796
|
endDate: input.endDate,
|
|
10251
10797
|
durationWeeks: input.durationWeeks,
|
|
@@ -10271,12 +10817,12 @@ var worktreesContracts = [
|
|
|
10271
10817
|
staffingHint: input.staffingHint,
|
|
10272
10818
|
domainPackId: input.domainPackId,
|
|
10273
10819
|
lensId: input.lensId,
|
|
10274
|
-
linkedQuestionId: input.linkedQuestionId,
|
|
10275
10820
|
lastReconciledAt: input.lastReconciledAt
|
|
10276
10821
|
}),
|
|
10277
10822
|
context
|
|
10278
10823
|
)
|
|
10279
|
-
}
|
|
10824
|
+
},
|
|
10825
|
+
args: addWorktreeArgs
|
|
10280
10826
|
}),
|
|
10281
10827
|
surfaceContract({
|
|
10282
10828
|
name: "activate_worktree",
|
|
@@ -10388,7 +10934,8 @@ var worktreesContracts = [
|
|
|
10388
10934
|
functionName: "updateMetadata",
|
|
10389
10935
|
kind: "mutation",
|
|
10390
10936
|
inputProjection: worktreeMetadataInput
|
|
10391
|
-
}
|
|
10937
|
+
},
|
|
10938
|
+
args: worktreeMetadataArgs
|
|
10392
10939
|
}),
|
|
10393
10940
|
surfaceContract({
|
|
10394
10941
|
name: "merge",
|
|
@@ -10406,9 +10953,7 @@ var worktreesContracts = [
|
|
|
10406
10953
|
inputProjection: (input, context) => withUserId(
|
|
10407
10954
|
{
|
|
10408
10955
|
...worktreeIdInput(input),
|
|
10409
|
-
keyFindings: input
|
|
10410
|
-
input.summary ?? "Merged worktree"
|
|
10411
|
-
],
|
|
10956
|
+
keyFindings: mergeKeyFindingsInput(input),
|
|
10412
10957
|
decisionsReached: input.decisionsReached ?? [],
|
|
10413
10958
|
nextSteps: input.nextSteps ?? []
|
|
10414
10959
|
},
|
|
@@ -10430,7 +10975,8 @@ var worktreesContracts = [
|
|
|
10430
10975
|
functionName: "updateMetadata",
|
|
10431
10976
|
kind: "mutation",
|
|
10432
10977
|
inputProjection: worktreeMetadataInput
|
|
10433
|
-
}
|
|
10978
|
+
},
|
|
10979
|
+
args: pushArgs
|
|
10434
10980
|
}),
|
|
10435
10981
|
surfaceContract({
|
|
10436
10982
|
name: "open_pull_request",
|
|
@@ -10446,7 +10992,8 @@ var worktreesContracts = [
|
|
|
10446
10992
|
functionName: "updateMetadata",
|
|
10447
10993
|
kind: "mutation",
|
|
10448
10994
|
inputProjection: worktreeMetadataInput
|
|
10449
|
-
}
|
|
10995
|
+
},
|
|
10996
|
+
args: openPullRequestArgs
|
|
10450
10997
|
})
|
|
10451
10998
|
];
|
|
10452
10999
|
|
|
@@ -10550,6 +11097,15 @@ var createEdgeArgs = z.object({
|
|
|
10550
11097
|
topicId: z.string().optional(),
|
|
10551
11098
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
10552
11099
|
});
|
|
11100
|
+
var queryLineageArgs = z.object({
|
|
11101
|
+
nodeId: z.string().describe("Starting node to trace from."),
|
|
11102
|
+
startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
|
|
11103
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11104
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11105
|
+
mode: z.string().optional().describe("Traversal mode."),
|
|
11106
|
+
minLayer: z.string().optional().describe("Minimum epistemic layer."),
|
|
11107
|
+
maxLayer: z.string().optional().describe("Maximum epistemic layer.")
|
|
11108
|
+
});
|
|
10553
11109
|
function graphRefNodeId(ref) {
|
|
10554
11110
|
if (ref.kind === "epistemic_node") {
|
|
10555
11111
|
return ref.nodeId;
|
|
@@ -10620,11 +11176,59 @@ var edgesContracts = [
|
|
|
10620
11176
|
minLayer: input.minLayer,
|
|
10621
11177
|
maxLayer: input.maxLayer
|
|
10622
11178
|
})
|
|
10623
|
-
}
|
|
11179
|
+
},
|
|
11180
|
+
args: queryLineageArgs
|
|
10624
11181
|
})
|
|
10625
11182
|
];
|
|
10626
|
-
|
|
10627
|
-
|
|
11183
|
+
var traversalLayerSchema = z.enum([
|
|
11184
|
+
"L4",
|
|
11185
|
+
"L3",
|
|
11186
|
+
"L2",
|
|
11187
|
+
"L1",
|
|
11188
|
+
"ontological",
|
|
11189
|
+
"organizational"
|
|
11190
|
+
]);
|
|
11191
|
+
var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
|
|
11192
|
+
var lineageAliasArgs = z.object({
|
|
11193
|
+
nodeId: z.string().optional().describe("Starting node to traverse from."),
|
|
11194
|
+
startNode: z.string().optional().describe("Starting node alias for traversal callers."),
|
|
11195
|
+
entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
|
|
11196
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11197
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11198
|
+
mode: traversalModeSchema.optional().describe("Traversal mode."),
|
|
11199
|
+
minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
|
|
11200
|
+
maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
|
|
11201
|
+
});
|
|
11202
|
+
var lineageArgs = lineageAliasArgs.extend({
|
|
11203
|
+
nodeId: z.string().describe("Starting node to traverse from.")
|
|
11204
|
+
});
|
|
11205
|
+
var traverseGraphArgs = lineageAliasArgs.extend({
|
|
11206
|
+
startNode: z.string().describe("Node to start traversal from."),
|
|
11207
|
+
direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
|
|
11208
|
+
});
|
|
11209
|
+
var graphNeighborhoodArgs = z.object({
|
|
11210
|
+
globalId: z.string().optional().describe("Single root global ID."),
|
|
11211
|
+
globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
|
|
11212
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11213
|
+
topicId: z.string().optional().describe("Topic scope for edge lookup."),
|
|
11214
|
+
limit: z.number().optional().describe("Maximum edges to return.")
|
|
11215
|
+
});
|
|
11216
|
+
var flagContradictionArgs = z.object({
|
|
11217
|
+
beliefA: z.string().describe("First belief in tension."),
|
|
11218
|
+
beliefB: z.string().describe("Second belief in tension."),
|
|
11219
|
+
topicId: z.string().optional().describe("Topic scope for the contradiction."),
|
|
11220
|
+
description: z.string().optional().describe("Human-readable contradiction."),
|
|
11221
|
+
severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
|
|
11222
|
+
defeatType: z.string().optional().describe("Defeat type annotation."),
|
|
11223
|
+
supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
|
|
11224
|
+
contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
|
|
11225
|
+
});
|
|
11226
|
+
var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
|
|
11227
|
+
nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
|
|
11228
|
+
topicId: z.string().optional().describe("Topic scope override."),
|
|
11229
|
+
minScore: z.number().optional().describe("Minimum match score."),
|
|
11230
|
+
limit: z.number().optional().describe("Maximum candidates to return.")
|
|
11231
|
+
});
|
|
10628
11232
|
var contradictionSeverity = (value) => {
|
|
10629
11233
|
switch (value) {
|
|
10630
11234
|
case "critical":
|
|
@@ -10679,7 +11283,8 @@ var graphContracts = [
|
|
|
10679
11283
|
functionName: "getLineage",
|
|
10680
11284
|
kind: "query",
|
|
10681
11285
|
inputProjection: lineageInput
|
|
10682
|
-
}
|
|
11286
|
+
},
|
|
11287
|
+
args: traverseGraphArgs
|
|
10683
11288
|
}),
|
|
10684
11289
|
surfaceContract({
|
|
10685
11290
|
name: "get_graph_neighborhood",
|
|
@@ -10695,7 +11300,8 @@ var graphContracts = [
|
|
|
10695
11300
|
functionName: "getByTopic",
|
|
10696
11301
|
kind: "query",
|
|
10697
11302
|
inputProjection: topicEdgesInput
|
|
10698
|
-
}
|
|
11303
|
+
},
|
|
11304
|
+
args: graphNeighborhoodArgs
|
|
10699
11305
|
}),
|
|
10700
11306
|
surfaceContract({
|
|
10701
11307
|
name: "get_graph_structure_analysis",
|
|
@@ -10744,7 +11350,8 @@ var graphContracts = [
|
|
|
10744
11350
|
functionName: "create",
|
|
10745
11351
|
kind: "mutation",
|
|
10746
11352
|
inputProjection: flagContradictionInput
|
|
10747
|
-
}
|
|
11353
|
+
},
|
|
11354
|
+
args: flagContradictionArgs
|
|
10748
11355
|
}),
|
|
10749
11356
|
surfaceContract({
|
|
10750
11357
|
name: "detect_confirmation_bias",
|
|
@@ -10835,7 +11442,8 @@ var graphContracts = [
|
|
|
10835
11442
|
functionName: "getLineage",
|
|
10836
11443
|
kind: "query",
|
|
10837
11444
|
inputProjection: lineageInput
|
|
10838
|
-
}
|
|
11445
|
+
},
|
|
11446
|
+
args: discoverEntityConnectionsArgs
|
|
10839
11447
|
}),
|
|
10840
11448
|
surfaceContract({
|
|
10841
11449
|
name: "trigger_belief_review",
|
|
@@ -10866,7 +11474,8 @@ var graphContracts = [
|
|
|
10866
11474
|
functionName: "getLineage",
|
|
10867
11475
|
kind: "query",
|
|
10868
11476
|
inputProjection: lineageInput
|
|
10869
|
-
}
|
|
11477
|
+
},
|
|
11478
|
+
args: lineageArgs
|
|
10870
11479
|
})
|
|
10871
11480
|
];
|
|
10872
11481
|
|
|
@@ -10918,8 +11527,16 @@ var contractsContracts = [
|
|
|
10918
11527
|
}
|
|
10919
11528
|
})
|
|
10920
11529
|
];
|
|
10921
|
-
|
|
10922
|
-
|
|
11530
|
+
var auditTrailArgs = z.object({
|
|
11531
|
+
nodeId: z.string().describe("The node to audit."),
|
|
11532
|
+
id: z.string().optional().describe("Node ID alias."),
|
|
11533
|
+
limit: z.number().optional().describe("Maximum entries to return."),
|
|
11534
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11535
|
+
maxDepth: z.number().optional().describe("Maximum lineage depth."),
|
|
11536
|
+
mode: z.string().optional().describe("Traversal mode."),
|
|
11537
|
+
minLayer: z.string().optional().describe("Minimum epistemic layer."),
|
|
11538
|
+
maxLayer: z.string().optional().describe("Maximum epistemic layer.")
|
|
11539
|
+
});
|
|
10923
11540
|
var judgmentsContracts = [
|
|
10924
11541
|
surfaceContract({
|
|
10925
11542
|
name: "record_judgment",
|
|
@@ -10974,7 +11591,8 @@ var judgmentsContracts = [
|
|
|
10974
11591
|
minLayer: input.minLayer,
|
|
10975
11592
|
maxLayer: input.maxLayer
|
|
10976
11593
|
})
|
|
10977
|
-
}
|
|
11594
|
+
},
|
|
11595
|
+
args: auditTrailArgs
|
|
10978
11596
|
})
|
|
10979
11597
|
];
|
|
10980
11598
|
|
|
@@ -11142,8 +11760,13 @@ var coordinationContracts = [
|
|
|
11142
11760
|
}
|
|
11143
11761
|
})
|
|
11144
11762
|
];
|
|
11145
|
-
|
|
11146
|
-
|
|
11763
|
+
var pipelineSnapshotArgs = z.object({
|
|
11764
|
+
topicId: z.string().describe("Topic scope ID."),
|
|
11765
|
+
status: z.string().optional().describe("Worktree status filter."),
|
|
11766
|
+
lane: z.string().optional().describe("Campaign lane filter."),
|
|
11767
|
+
campaign: z.number().optional().describe("Campaign number filter."),
|
|
11768
|
+
limit: z.number().optional().describe("Maximum worktrees to inspect.")
|
|
11769
|
+
});
|
|
11147
11770
|
var pipelineContracts = [
|
|
11148
11771
|
surfaceContract({
|
|
11149
11772
|
name: "pipeline_snapshot",
|
|
@@ -11164,7 +11787,8 @@ var pipelineContracts = [
|
|
|
11164
11787
|
campaign: input.campaign,
|
|
11165
11788
|
limit: input.limit
|
|
11166
11789
|
})
|
|
11167
|
-
}
|
|
11790
|
+
},
|
|
11791
|
+
args: pipelineSnapshotArgs
|
|
11168
11792
|
}),
|
|
11169
11793
|
surfaceContract({
|
|
11170
11794
|
name: "seed_belief_lattice",
|
|
@@ -11216,7 +11840,31 @@ var recordScopeLearningArgs = z.object({
|
|
|
11216
11840
|
rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
|
|
11217
11841
|
createQuestionText: z.string().optional().describe("Optional follow-up question text"),
|
|
11218
11842
|
createBeliefText: z.string().optional().describe("Optional new belief text"),
|
|
11219
|
-
beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
|
|
11843
|
+
beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
|
|
11844
|
+
text: z.string().optional().describe("Canonical learning text alias."),
|
|
11845
|
+
content: z.string().optional().describe("Canonical learning content alias."),
|
|
11846
|
+
kind: z.string().optional().describe("Evidence kind to store."),
|
|
11847
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
11848
|
+
externalSourceType: z.string().optional().describe("External source type alias."),
|
|
11849
|
+
metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
|
|
11850
|
+
});
|
|
11851
|
+
var codeContextArgs = z.object({
|
|
11852
|
+
topicId: z.string().optional().describe("Topic scope."),
|
|
11853
|
+
filePath: z.string().optional().describe("File path anchor."),
|
|
11854
|
+
includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
|
|
11855
|
+
limit: z.number().optional().describe("Maximum records to return."),
|
|
11856
|
+
status: z.string().optional().describe("Evidence status filter.")
|
|
11857
|
+
});
|
|
11858
|
+
var recordAttemptArgs = z.object({
|
|
11859
|
+
topicId: z.string().optional().describe("Topic scope."),
|
|
11860
|
+
description: z.string().describe("Attempt description."),
|
|
11861
|
+
errorMessage: z.string().optional().describe("Failure or error message."),
|
|
11862
|
+
filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
|
|
11863
|
+
filePath: z.string().optional().describe("Single file path alias."),
|
|
11864
|
+
linkedBeliefId: z.string().optional().describe("Linked belief ID."),
|
|
11865
|
+
metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
|
|
11866
|
+
rationale: z.string().optional().describe("Why this attempt should be recorded."),
|
|
11867
|
+
title: z.string().optional().describe("Attempt evidence title.")
|
|
11220
11868
|
});
|
|
11221
11869
|
var learningInput = (input, context) => {
|
|
11222
11870
|
const sourceKind = input.sourceKind ?? input.externalSourceType;
|
|
@@ -11333,7 +11981,8 @@ var codingContracts = [
|
|
|
11333
11981
|
status: input.status,
|
|
11334
11982
|
userId: input.userId
|
|
11335
11983
|
})
|
|
11336
|
-
}
|
|
11984
|
+
},
|
|
11985
|
+
args: codeContextArgs
|
|
11337
11986
|
}),
|
|
11338
11987
|
surfaceContract({
|
|
11339
11988
|
name: "get_change_history",
|
|
@@ -11370,7 +12019,8 @@ var codingContracts = [
|
|
|
11370
12019
|
functionName: "create",
|
|
11371
12020
|
kind: "mutation",
|
|
11372
12021
|
inputProjection: attemptInput
|
|
11373
|
-
}
|
|
12022
|
+
},
|
|
12023
|
+
args: recordAttemptArgs
|
|
11374
12024
|
}),
|
|
11375
12025
|
surfaceContract({
|
|
11376
12026
|
name: "get_failure_log",
|
|
@@ -11734,34 +12384,638 @@ function rankEntityTypeMatches(inputText, entityTypes, options) {
|
|
|
11734
12384
|
return matches;
|
|
11735
12385
|
}
|
|
11736
12386
|
|
|
11737
|
-
// ../contracts/src/
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
var
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
}
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
12387
|
+
// ../contracts/src/tenant-bootstrap-seed.contract.ts
|
|
12388
|
+
function isCopyableSeedRequirement(entry) {
|
|
12389
|
+
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;
|
|
12390
|
+
}
|
|
12391
|
+
var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
|
|
12392
|
+
{
|
|
12393
|
+
component: "kernel",
|
|
12394
|
+
table: "agentMessages",
|
|
12395
|
+
prepopulation: "runtime_data",
|
|
12396
|
+
copyMode: "none",
|
|
12397
|
+
description: "Agent coordination messages are session data, not template data."
|
|
12398
|
+
},
|
|
12399
|
+
{
|
|
12400
|
+
component: "kernel",
|
|
12401
|
+
table: "agentSessions",
|
|
12402
|
+
prepopulation: "runtime_data",
|
|
12403
|
+
copyMode: "none",
|
|
12404
|
+
description: "Agent coordination sessions are created by active clients."
|
|
12405
|
+
},
|
|
12406
|
+
{
|
|
12407
|
+
component: "kernel",
|
|
12408
|
+
table: "autofixJobs",
|
|
12409
|
+
prepopulation: "runtime_queue",
|
|
12410
|
+
copyMode: "none",
|
|
12411
|
+
description: "Autofix work items are runtime queue rows."
|
|
12412
|
+
},
|
|
12413
|
+
{
|
|
12414
|
+
component: "kernel",
|
|
12415
|
+
table: "backgroundJobRuns",
|
|
12416
|
+
prepopulation: "runtime_log",
|
|
12417
|
+
copyMode: "none",
|
|
12418
|
+
description: "Background job executions are runtime logs."
|
|
12419
|
+
},
|
|
12420
|
+
{
|
|
12421
|
+
component: "kernel",
|
|
12422
|
+
table: "backgroundJobSettings",
|
|
12423
|
+
prepopulation: "required_template",
|
|
12424
|
+
copyMode: "template_global",
|
|
12425
|
+
scope: "global",
|
|
12426
|
+
uniqueKey: ["jobKey"],
|
|
12427
|
+
description: "Default job enablement settings must come from the K template."
|
|
12428
|
+
},
|
|
12429
|
+
{
|
|
12430
|
+
component: "kernel",
|
|
12431
|
+
table: "beliefConfidence",
|
|
12432
|
+
prepopulation: "runtime_data",
|
|
12433
|
+
copyMode: "none",
|
|
12434
|
+
description: "Belief confidence rows are created with tenant graph facts."
|
|
12435
|
+
},
|
|
12436
|
+
{
|
|
12437
|
+
component: "kernel",
|
|
12438
|
+
table: "beliefEvidenceLinks",
|
|
12439
|
+
prepopulation: "runtime_data",
|
|
12440
|
+
copyMode: "none",
|
|
12441
|
+
description: "Belief-to-evidence links are tenant graph data."
|
|
12442
|
+
},
|
|
12443
|
+
{
|
|
12444
|
+
component: "kernel",
|
|
12445
|
+
table: "beliefHistory",
|
|
12446
|
+
prepopulation: "runtime_data",
|
|
12447
|
+
copyMode: "none",
|
|
12448
|
+
description: "Belief history is append-only tenant graph data."
|
|
12449
|
+
},
|
|
12450
|
+
{
|
|
12451
|
+
component: "kernel",
|
|
12452
|
+
table: "beliefScenarios",
|
|
12453
|
+
prepopulation: "runtime_data",
|
|
12454
|
+
copyMode: "none",
|
|
12455
|
+
description: "Scenario rows are tenant-authored reasoning data."
|
|
12456
|
+
},
|
|
12457
|
+
{
|
|
12458
|
+
component: "kernel",
|
|
12459
|
+
table: "beliefVotes",
|
|
12460
|
+
prepopulation: "runtime_data",
|
|
12461
|
+
copyMode: "none",
|
|
12462
|
+
description: "Decision belief votes are tenant-authored data."
|
|
12463
|
+
},
|
|
12464
|
+
{
|
|
12465
|
+
component: "kernel",
|
|
12466
|
+
table: "calibrationScores",
|
|
12467
|
+
prepopulation: "runtime_derived",
|
|
12468
|
+
copyMode: "none",
|
|
12469
|
+
description: "Calibration scores are computed from tenant outcomes."
|
|
12470
|
+
},
|
|
12471
|
+
{
|
|
12472
|
+
component: "kernel",
|
|
12473
|
+
table: "contractEvaluations",
|
|
12474
|
+
prepopulation: "runtime_log",
|
|
12475
|
+
copyMode: "none",
|
|
12476
|
+
description: "Contract evaluation rows are runtime computation logs."
|
|
12477
|
+
},
|
|
12478
|
+
{
|
|
12479
|
+
component: "kernel",
|
|
12480
|
+
table: "contradictions",
|
|
12481
|
+
prepopulation: "runtime_data",
|
|
12482
|
+
copyMode: "none",
|
|
12483
|
+
description: "Contradictions are tenant graph facts."
|
|
12484
|
+
},
|
|
12485
|
+
{
|
|
12486
|
+
component: "kernel",
|
|
12487
|
+
table: "crossProjectConnections",
|
|
12488
|
+
prepopulation: "runtime_data",
|
|
12489
|
+
copyMode: "none",
|
|
12490
|
+
description: "Cross-topic connections are tenant graph facts."
|
|
12491
|
+
},
|
|
12492
|
+
{
|
|
12493
|
+
component: "kernel",
|
|
12494
|
+
table: "decisionComputedSummaries",
|
|
12495
|
+
prepopulation: "runtime_derived",
|
|
12496
|
+
copyMode: "none",
|
|
12497
|
+
description: "Decision summaries are derived tenant outputs."
|
|
12498
|
+
},
|
|
12499
|
+
{
|
|
12500
|
+
component: "kernel",
|
|
12501
|
+
table: "decisionEvents",
|
|
12502
|
+
prepopulation: "runtime_data",
|
|
12503
|
+
copyMode: "none",
|
|
12504
|
+
description: "Decision events are lifecycle data."
|
|
12505
|
+
},
|
|
12506
|
+
{
|
|
12507
|
+
component: "kernel",
|
|
12508
|
+
table: "decisionParticipants",
|
|
12509
|
+
prepopulation: "runtime_data",
|
|
12510
|
+
copyMode: "none",
|
|
12511
|
+
description: "Decision participants are tenant-selected actors."
|
|
12512
|
+
},
|
|
12513
|
+
{
|
|
12514
|
+
component: "kernel",
|
|
12515
|
+
table: "decisionRiskLedger",
|
|
12516
|
+
prepopulation: "runtime_data",
|
|
12517
|
+
copyMode: "none",
|
|
12518
|
+
description: "Decision risk rows are tenant decision data."
|
|
12519
|
+
},
|
|
12520
|
+
{
|
|
12521
|
+
component: "kernel",
|
|
12522
|
+
table: "decisionSnapshots",
|
|
12523
|
+
prepopulation: "runtime_derived",
|
|
12524
|
+
copyMode: "none",
|
|
12525
|
+
description: "Decision snapshots are derived from tenant state."
|
|
12526
|
+
},
|
|
12527
|
+
{
|
|
12528
|
+
component: "kernel",
|
|
12529
|
+
table: "deliberationContributions",
|
|
12530
|
+
prepopulation: "runtime_data",
|
|
12531
|
+
copyMode: "none",
|
|
12532
|
+
description: "Deliberation contributions are tenant-authored data."
|
|
12533
|
+
},
|
|
12534
|
+
{
|
|
12535
|
+
component: "kernel",
|
|
12536
|
+
table: "deliberationSessions",
|
|
12537
|
+
prepopulation: "runtime_data",
|
|
12538
|
+
copyMode: "none",
|
|
12539
|
+
description: "Deliberation sessions are created by tenant workflows."
|
|
12540
|
+
},
|
|
12541
|
+
{
|
|
12542
|
+
component: "kernel",
|
|
12543
|
+
table: "epistemicAudit",
|
|
12544
|
+
prepopulation: "runtime_log",
|
|
12545
|
+
copyMode: "none",
|
|
12546
|
+
description: "Epistemic audit rows are append-only runtime audit data."
|
|
12547
|
+
},
|
|
12548
|
+
{
|
|
12549
|
+
component: "kernel",
|
|
12550
|
+
table: "epistemicContracts",
|
|
12551
|
+
prepopulation: "runtime_data",
|
|
12552
|
+
copyMode: "none",
|
|
12553
|
+
description: "Epistemic contracts are tenant-authored governance data."
|
|
12554
|
+
},
|
|
12555
|
+
{
|
|
12556
|
+
component: "kernel",
|
|
12557
|
+
table: "epistemicEdges",
|
|
12558
|
+
prepopulation: "runtime_data",
|
|
12559
|
+
copyMode: "none",
|
|
12560
|
+
description: "Edges are tenant reasoning graph data."
|
|
12561
|
+
},
|
|
12562
|
+
{
|
|
12563
|
+
component: "kernel",
|
|
12564
|
+
table: "epistemicNodeEmbeddings",
|
|
12565
|
+
prepopulation: "runtime_derived",
|
|
12566
|
+
copyMode: "none",
|
|
12567
|
+
description: "Embeddings are derived from tenant graph nodes."
|
|
12568
|
+
},
|
|
12569
|
+
{
|
|
12570
|
+
component: "kernel",
|
|
12571
|
+
table: "epistemicNodes",
|
|
12572
|
+
prepopulation: "runtime_data",
|
|
12573
|
+
copyMode: "none",
|
|
12574
|
+
description: "Nodes are tenant reasoning graph data."
|
|
12575
|
+
},
|
|
12576
|
+
{
|
|
12577
|
+
component: "kernel",
|
|
12578
|
+
table: "graphAnalysisCache",
|
|
12579
|
+
prepopulation: "runtime_derived",
|
|
12580
|
+
copyMode: "none",
|
|
12581
|
+
description: "Graph analysis cache rows are derived from tenant graph state."
|
|
12582
|
+
},
|
|
12583
|
+
{
|
|
12584
|
+
component: "kernel",
|
|
12585
|
+
table: "graphAnalysisResults",
|
|
12586
|
+
prepopulation: "runtime_derived",
|
|
12587
|
+
copyMode: "none",
|
|
12588
|
+
description: "Graph analysis result rows are derived tenant outputs."
|
|
12589
|
+
},
|
|
12590
|
+
{
|
|
12591
|
+
component: "kernel",
|
|
12592
|
+
table: "graphSuggestions",
|
|
12593
|
+
prepopulation: "runtime_derived",
|
|
12594
|
+
copyMode: "none",
|
|
12595
|
+
description: "Graph suggestions are derived recommendations."
|
|
12596
|
+
},
|
|
12597
|
+
{
|
|
12598
|
+
component: "kernel",
|
|
12599
|
+
table: "harnessReplays",
|
|
12600
|
+
prepopulation: "runtime_log",
|
|
12601
|
+
copyMode: "none",
|
|
12602
|
+
description: "Harness replay rows are runtime verification logs."
|
|
12603
|
+
},
|
|
12604
|
+
{
|
|
12605
|
+
component: "kernel",
|
|
12606
|
+
table: "harnessRuns",
|
|
12607
|
+
prepopulation: "runtime_log",
|
|
12608
|
+
copyMode: "none",
|
|
12609
|
+
description: "Harness run rows are runtime verification logs."
|
|
12610
|
+
},
|
|
12611
|
+
{
|
|
12612
|
+
component: "kernel",
|
|
12613
|
+
table: "idempotencyTokens",
|
|
12614
|
+
prepopulation: "runtime_log",
|
|
12615
|
+
copyMode: "none",
|
|
12616
|
+
description: "Idempotency tokens are request-scoped runtime guards."
|
|
12617
|
+
},
|
|
12618
|
+
{
|
|
12619
|
+
component: "kernel",
|
|
12620
|
+
table: "lenses",
|
|
12621
|
+
prepopulation: "optional_template",
|
|
12622
|
+
copyMode: "none",
|
|
12623
|
+
description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
|
|
12624
|
+
},
|
|
12625
|
+
{
|
|
12626
|
+
component: "kernel",
|
|
12627
|
+
table: "lensTopicBindings",
|
|
12628
|
+
prepopulation: "runtime_data",
|
|
12629
|
+
copyMode: "none",
|
|
12630
|
+
description: "Lens bindings attach runtime topics to runtime/workspace lenses."
|
|
12631
|
+
},
|
|
12632
|
+
{
|
|
12633
|
+
component: "kernel",
|
|
12634
|
+
table: "neo4jSyncQueue",
|
|
12635
|
+
prepopulation: "runtime_queue",
|
|
12636
|
+
copyMode: "none",
|
|
12637
|
+
description: "Neo4j sync queue rows are runtime work items."
|
|
12638
|
+
},
|
|
12639
|
+
{
|
|
12640
|
+
component: "kernel",
|
|
12641
|
+
table: "ontologyDefinitions",
|
|
12642
|
+
prepopulation: "required_template",
|
|
12643
|
+
copyMode: "template_global",
|
|
12644
|
+
scope: "global",
|
|
12645
|
+
uniqueKey: ["ontologyKey"],
|
|
12646
|
+
description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
|
|
12647
|
+
},
|
|
12648
|
+
{
|
|
12649
|
+
component: "kernel",
|
|
12650
|
+
table: "ontologyVersions",
|
|
12651
|
+
prepopulation: "required_template",
|
|
12652
|
+
copyMode: "template_reference_remap",
|
|
12653
|
+
scope: "global",
|
|
12654
|
+
uniqueKey: ["ontologyKey", "version"],
|
|
12655
|
+
dependsOn: ["ontologyDefinitions"],
|
|
12656
|
+
description: "Ontology versions must be copied with ontologyDefinition ID remapping."
|
|
12657
|
+
},
|
|
12658
|
+
{
|
|
12659
|
+
component: "kernel",
|
|
12660
|
+
table: "platformAgentRunPolicyDecisions",
|
|
12661
|
+
prepopulation: "runtime_log",
|
|
12662
|
+
copyMode: "none",
|
|
12663
|
+
description: "Agent-run policy decisions are audit logs."
|
|
12664
|
+
},
|
|
12665
|
+
{
|
|
12666
|
+
component: "kernel",
|
|
12667
|
+
table: "platformAgentRunPromptResolutions",
|
|
12668
|
+
prepopulation: "runtime_log",
|
|
12669
|
+
copyMode: "none",
|
|
12670
|
+
description: "Agent-run prompt resolution rows are runtime logs."
|
|
12671
|
+
},
|
|
12672
|
+
{
|
|
12673
|
+
component: "kernel",
|
|
12674
|
+
table: "platformAgentRuns",
|
|
12675
|
+
prepopulation: "runtime_log",
|
|
12676
|
+
copyMode: "none",
|
|
12677
|
+
description: "Agent runs are runtime execution records."
|
|
12678
|
+
},
|
|
12679
|
+
{
|
|
12680
|
+
component: "kernel",
|
|
12681
|
+
table: "platformAgentRunToolCalls",
|
|
12682
|
+
prepopulation: "runtime_log",
|
|
12683
|
+
copyMode: "none",
|
|
12684
|
+
description: "Agent-run tool calls are runtime execution records."
|
|
12685
|
+
},
|
|
12686
|
+
{
|
|
12687
|
+
component: "kernel",
|
|
12688
|
+
table: "platformHarnessShadowAudit",
|
|
12689
|
+
prepopulation: "runtime_log",
|
|
12690
|
+
copyMode: "none",
|
|
12691
|
+
description: "Harness shadow audit rows are runtime audit records."
|
|
12692
|
+
},
|
|
12693
|
+
{
|
|
12694
|
+
component: "kernel",
|
|
12695
|
+
table: "publicationRules",
|
|
12696
|
+
prepopulation: "required_template",
|
|
12697
|
+
copyMode: "template_tenant_rewrite",
|
|
12698
|
+
scope: "tenant",
|
|
12699
|
+
uniqueKey: ["tenantId", "workspaceId", "name"],
|
|
12700
|
+
description: "Default publication policy rules are rewritten into each tenant."
|
|
12701
|
+
},
|
|
12702
|
+
{
|
|
12703
|
+
component: "kernel",
|
|
12704
|
+
table: "questionEvidenceLinks",
|
|
12705
|
+
prepopulation: "runtime_data",
|
|
12706
|
+
copyMode: "none",
|
|
12707
|
+
description: "Question-to-evidence links are tenant graph data."
|
|
12708
|
+
},
|
|
12709
|
+
{
|
|
12710
|
+
component: "kernel",
|
|
12711
|
+
table: "researchJobs",
|
|
12712
|
+
prepopulation: "runtime_queue",
|
|
12713
|
+
copyMode: "none",
|
|
12714
|
+
description: "Research job rows are runtime queue items."
|
|
12715
|
+
},
|
|
12716
|
+
{
|
|
12717
|
+
component: "kernel",
|
|
12718
|
+
table: "schemaEnumConfig",
|
|
12719
|
+
prepopulation: "required_template",
|
|
12720
|
+
copyMode: "template_global",
|
|
12721
|
+
scope: "global",
|
|
12722
|
+
uniqueKey: ["category", "value"],
|
|
12723
|
+
description: "Runtime-extensible enum defaults required by SDK graph APIs."
|
|
12724
|
+
},
|
|
12725
|
+
{
|
|
12726
|
+
component: "kernel",
|
|
12727
|
+
table: "stakeholderGroups",
|
|
12728
|
+
prepopulation: "runtime_data",
|
|
12729
|
+
copyMode: "none",
|
|
12730
|
+
description: "Stakeholder groups are tenant decision data."
|
|
12731
|
+
},
|
|
12732
|
+
{
|
|
12733
|
+
component: "kernel",
|
|
12734
|
+
table: "systemLogs",
|
|
12735
|
+
prepopulation: "runtime_log",
|
|
12736
|
+
copyMode: "none",
|
|
12737
|
+
description: "System logs are runtime telemetry."
|
|
12738
|
+
},
|
|
12739
|
+
{
|
|
12740
|
+
component: "kernel",
|
|
12741
|
+
table: "tasks",
|
|
12742
|
+
prepopulation: "runtime_data",
|
|
12743
|
+
copyMode: "none",
|
|
12744
|
+
description: "Tasks are tenant-authored work items."
|
|
12745
|
+
},
|
|
12746
|
+
{
|
|
12747
|
+
component: "kernel",
|
|
12748
|
+
table: "topics",
|
|
12749
|
+
prepopulation: "runtime_bootstrap",
|
|
12750
|
+
copyMode: "none",
|
|
12751
|
+
description: "Default topics are created by tenant provisioning, not copied from templates."
|
|
12752
|
+
},
|
|
12753
|
+
{
|
|
12754
|
+
component: "kernel",
|
|
12755
|
+
table: "workflowDefinitions",
|
|
12756
|
+
prepopulation: "optional_template",
|
|
12757
|
+
copyMode: "none",
|
|
12758
|
+
description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
|
|
12759
|
+
},
|
|
12760
|
+
{
|
|
12761
|
+
component: "kernel",
|
|
12762
|
+
table: "workflowPullRequests",
|
|
12763
|
+
prepopulation: "runtime_data",
|
|
12764
|
+
copyMode: "none",
|
|
12765
|
+
description: "Workflow pull requests are tenant workflow data."
|
|
12766
|
+
},
|
|
12767
|
+
{
|
|
12768
|
+
component: "kernel",
|
|
12769
|
+
table: "workflowStages",
|
|
12770
|
+
prepopulation: "optional_template",
|
|
12771
|
+
copyMode: "none",
|
|
12772
|
+
dependsOn: ["workflowDefinitions"],
|
|
12773
|
+
description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
|
|
12774
|
+
},
|
|
12775
|
+
{
|
|
12776
|
+
component: "kernel",
|
|
12777
|
+
table: "worktreeBeliefCluster",
|
|
12778
|
+
prepopulation: "runtime_data",
|
|
12779
|
+
copyMode: "none",
|
|
12780
|
+
description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
|
|
12781
|
+
},
|
|
12782
|
+
{
|
|
12783
|
+
component: "kernel",
|
|
12784
|
+
table: "worktrees",
|
|
12785
|
+
prepopulation: "runtime_data",
|
|
12786
|
+
copyMode: "none",
|
|
12787
|
+
description: "Worktrees are tenant/runtime planning data."
|
|
12788
|
+
},
|
|
12789
|
+
{
|
|
12790
|
+
component: "identity",
|
|
12791
|
+
table: "agents",
|
|
12792
|
+
prepopulation: "runtime_bootstrap",
|
|
12793
|
+
copyMode: "none",
|
|
12794
|
+
description: "Service agents are provisioned per tenant or service, not copied."
|
|
12795
|
+
},
|
|
12796
|
+
{
|
|
12797
|
+
component: "identity",
|
|
12798
|
+
table: "mcpWritePolicy",
|
|
12799
|
+
prepopulation: "required_template",
|
|
12800
|
+
copyMode: "template_global",
|
|
12801
|
+
scope: "global",
|
|
12802
|
+
uniqueKey: ["topicId", "role", "toolCategory"],
|
|
12803
|
+
description: "Global write policy defaults govern service and interactive MCP writes."
|
|
12804
|
+
},
|
|
12805
|
+
{
|
|
12806
|
+
component: "identity",
|
|
12807
|
+
table: "modelCallLogs",
|
|
12808
|
+
prepopulation: "runtime_log",
|
|
12809
|
+
copyMode: "none",
|
|
12810
|
+
description: "Model call logs are runtime telemetry."
|
|
12811
|
+
},
|
|
12812
|
+
{
|
|
12813
|
+
component: "identity",
|
|
12814
|
+
table: "modelFunctionSlots",
|
|
12815
|
+
prepopulation: "required_template",
|
|
12816
|
+
copyMode: "template_global",
|
|
12817
|
+
scope: "global",
|
|
12818
|
+
uniqueKey: ["slot"],
|
|
12819
|
+
description: "Function-to-model slots are required by model runtime resolution."
|
|
12820
|
+
},
|
|
12821
|
+
{
|
|
12822
|
+
component: "identity",
|
|
12823
|
+
table: "modelRegistry",
|
|
12824
|
+
prepopulation: "required_template",
|
|
12825
|
+
copyMode: "template_global",
|
|
12826
|
+
scope: "global",
|
|
12827
|
+
uniqueKey: ["key"],
|
|
12828
|
+
description: "Model catalog defaults are required by model runtime clients."
|
|
12829
|
+
},
|
|
12830
|
+
{
|
|
12831
|
+
component: "identity",
|
|
12832
|
+
table: "modelSlotConfigs",
|
|
12833
|
+
prepopulation: "required_template",
|
|
12834
|
+
copyMode: "template_global",
|
|
12835
|
+
scope: "global",
|
|
12836
|
+
uniqueKey: ["slot"],
|
|
12837
|
+
description: "Slot-level defaults are required before tenant overrides exist."
|
|
12838
|
+
},
|
|
12839
|
+
{
|
|
12840
|
+
component: "identity",
|
|
12841
|
+
table: "platformAudienceGrants",
|
|
12842
|
+
prepopulation: "runtime_data",
|
|
12843
|
+
copyMode: "none",
|
|
12844
|
+
description: "Audience grants are principal/group-specific access rows."
|
|
12845
|
+
},
|
|
12846
|
+
{
|
|
12847
|
+
component: "identity",
|
|
12848
|
+
table: "platformAudiences",
|
|
12849
|
+
prepopulation: "required_template",
|
|
12850
|
+
copyMode: "template_tenant_rewrite",
|
|
12851
|
+
scope: "tenant",
|
|
12852
|
+
uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
|
|
12853
|
+
description: "Default tenant audience taxonomy rows are rewritten into each tenant."
|
|
12854
|
+
},
|
|
12855
|
+
{
|
|
12856
|
+
component: "identity",
|
|
12857
|
+
table: "platformPolicyDecisionLogs",
|
|
12858
|
+
prepopulation: "runtime_log",
|
|
12859
|
+
copyMode: "none",
|
|
12860
|
+
description: "Policy decisions are runtime audit logs."
|
|
12861
|
+
},
|
|
12862
|
+
{
|
|
12863
|
+
component: "identity",
|
|
12864
|
+
table: "projectGrants",
|
|
12865
|
+
prepopulation: "runtime_data",
|
|
12866
|
+
copyMode: "none",
|
|
12867
|
+
description: "Project/topic grants are principal or group-specific access rows."
|
|
12868
|
+
},
|
|
12869
|
+
{
|
|
12870
|
+
component: "identity",
|
|
12871
|
+
table: "reasoningPermissions",
|
|
12872
|
+
prepopulation: "runtime_data",
|
|
12873
|
+
copyMode: "none",
|
|
12874
|
+
description: "Reasoning permissions are principal-specific policy rows."
|
|
12875
|
+
},
|
|
12876
|
+
{
|
|
12877
|
+
component: "identity",
|
|
12878
|
+
table: "tenantApiKeys",
|
|
12879
|
+
prepopulation: "runtime_secret",
|
|
12880
|
+
copyMode: "none",
|
|
12881
|
+
description: "API keys are tenant credentials and must never be copied."
|
|
12882
|
+
},
|
|
12883
|
+
{
|
|
12884
|
+
component: "identity",
|
|
12885
|
+
table: "tenantConfig",
|
|
12886
|
+
prepopulation: "required_template",
|
|
12887
|
+
copyMode: "template_tenant_rewrite",
|
|
12888
|
+
scope: "tenant",
|
|
12889
|
+
uniqueKey: ["tenantId"],
|
|
12890
|
+
description: "Tenant-local config defaults are rewritten during bootstrap."
|
|
12891
|
+
},
|
|
12892
|
+
{
|
|
12893
|
+
component: "identity",
|
|
12894
|
+
table: "tenantIntegrations",
|
|
12895
|
+
prepopulation: "required_template",
|
|
12896
|
+
copyMode: "template_tenant_rewrite",
|
|
12897
|
+
scope: "tenant",
|
|
12898
|
+
uniqueKey: ["tenantId", "integrationKey"],
|
|
12899
|
+
description: "Non-secret integration descriptors are rewritten into each tenant."
|
|
12900
|
+
},
|
|
12901
|
+
{
|
|
12902
|
+
component: "identity",
|
|
12903
|
+
table: "tenantModelSlotBindings",
|
|
12904
|
+
prepopulation: "runtime_secret",
|
|
12905
|
+
copyMode: "none",
|
|
12906
|
+
description: "Tenant model slot bindings reference provider secrets and are runtime-only."
|
|
12907
|
+
},
|
|
12908
|
+
{
|
|
12909
|
+
component: "identity",
|
|
12910
|
+
table: "tenantPolicies",
|
|
12911
|
+
prepopulation: "required_template",
|
|
12912
|
+
copyMode: "template_tenant_rewrite",
|
|
12913
|
+
scope: "tenant",
|
|
12914
|
+
uniqueKey: ["tenantId", "workspaceId", "roleName"],
|
|
12915
|
+
description: "Default tenant policy roles are rewritten during bootstrap."
|
|
12916
|
+
},
|
|
12917
|
+
{
|
|
12918
|
+
component: "identity",
|
|
12919
|
+
table: "tenantProviderSecrets",
|
|
12920
|
+
prepopulation: "runtime_secret",
|
|
12921
|
+
copyMode: "none",
|
|
12922
|
+
description: "Provider secrets are credentials and must never be copied."
|
|
12923
|
+
},
|
|
12924
|
+
{
|
|
12925
|
+
component: "identity",
|
|
12926
|
+
table: "tenantProxyGatewayUsage",
|
|
12927
|
+
prepopulation: "runtime_log",
|
|
12928
|
+
copyMode: "none",
|
|
12929
|
+
description: "Proxy gateway usage rows are runtime telemetry."
|
|
12930
|
+
},
|
|
12931
|
+
{
|
|
12932
|
+
component: "identity",
|
|
12933
|
+
table: "tenantProxyTokenMints",
|
|
12934
|
+
prepopulation: "runtime_secret",
|
|
12935
|
+
copyMode: "none",
|
|
12936
|
+
description: "Proxy token mints are ephemeral secret-bearing runtime rows."
|
|
12937
|
+
},
|
|
12938
|
+
{
|
|
12939
|
+
component: "identity",
|
|
12940
|
+
table: "tenantSandboxAuditEvents",
|
|
12941
|
+
prepopulation: "runtime_log",
|
|
12942
|
+
copyMode: "none",
|
|
12943
|
+
description: "Sandbox audit rows are runtime security logs."
|
|
12944
|
+
},
|
|
12945
|
+
{
|
|
12946
|
+
component: "identity",
|
|
12947
|
+
table: "tenantSecrets",
|
|
12948
|
+
prepopulation: "runtime_secret",
|
|
12949
|
+
copyMode: "none",
|
|
12950
|
+
description: "Tenant secrets are credentials and must never be copied."
|
|
12951
|
+
},
|
|
12952
|
+
{
|
|
12953
|
+
component: "identity",
|
|
12954
|
+
table: "toolAcls",
|
|
12955
|
+
prepopulation: "required_template",
|
|
12956
|
+
copyMode: "template_global",
|
|
12957
|
+
scope: "global",
|
|
12958
|
+
uniqueKey: ["role", "toolName"],
|
|
12959
|
+
description: "Default role-to-tool grants are required for SDK/MCP tool access."
|
|
12960
|
+
},
|
|
12961
|
+
{
|
|
12962
|
+
component: "identity",
|
|
12963
|
+
table: "toolRegistry",
|
|
12964
|
+
prepopulation: "required_template",
|
|
12965
|
+
copyMode: "template_global",
|
|
12966
|
+
scope: "global",
|
|
12967
|
+
uniqueKey: ["toolName"],
|
|
12968
|
+
description: "Core tool catalog rows are required before pack or tenant tools exist."
|
|
12969
|
+
},
|
|
12970
|
+
{
|
|
12971
|
+
component: "identity",
|
|
12972
|
+
table: "users",
|
|
12973
|
+
prepopulation: "runtime_bootstrap",
|
|
12974
|
+
copyMode: "none",
|
|
12975
|
+
description: "Users are created from Clerk/MC principal resolution, not copied."
|
|
12976
|
+
}
|
|
12977
|
+
];
|
|
12978
|
+
TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
|
|
12979
|
+
isCopyableSeedRequirement
|
|
12980
|
+
);
|
|
12981
|
+
TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
|
|
12982
|
+
(entry) => !isCopyableSeedRequirement(entry)
|
|
12983
|
+
).map((entry) => entry.table);
|
|
12984
|
+
|
|
12985
|
+
// ../contracts/src/v1/topics/v1.ts
|
|
12986
|
+
var ROOT_TOPIC_ID = "n17tm38rwet7wqgzrmwahyt1z582590y";
|
|
12987
|
+
|
|
12988
|
+
// ../server-core/src/errors/server-errors.ts
|
|
12989
|
+
var ServerCoreError = class extends Error {
|
|
12990
|
+
constructor(status, code, message, options) {
|
|
12991
|
+
super(message);
|
|
12992
|
+
this.status = status;
|
|
12993
|
+
this.code = code;
|
|
12994
|
+
this.name = "ServerCoreError";
|
|
12995
|
+
this.details = options?.details;
|
|
12996
|
+
}
|
|
12997
|
+
status;
|
|
12998
|
+
code;
|
|
12999
|
+
details;
|
|
13000
|
+
};
|
|
13001
|
+
var GatewayAuthError = class extends ServerCoreError {
|
|
13002
|
+
constructor(status, code, message, options) {
|
|
13003
|
+
super(status, code, message, options);
|
|
13004
|
+
this.name = "GatewayAuthError";
|
|
13005
|
+
}
|
|
13006
|
+
};
|
|
13007
|
+
var VALID_CODES = /* @__PURE__ */ new Set([
|
|
13008
|
+
"AUTH_REQUIRED",
|
|
13009
|
+
"AUTHENTICATION_REQUIRED",
|
|
13010
|
+
"AUTH_TOKEN_MISSING",
|
|
13011
|
+
"INVALID_REQUEST",
|
|
13012
|
+
"IDEMPOTENCY_KEY_REQUIRED",
|
|
13013
|
+
"FORBIDDEN",
|
|
13014
|
+
"SCOPE_INSUFFICIENT",
|
|
13015
|
+
"ENVIRONMENT_MISMATCH",
|
|
13016
|
+
"KEY_EXPIRED",
|
|
13017
|
+
"KEY_REVOKED",
|
|
13018
|
+
"RATE_LIMIT_EXCEEDED",
|
|
11765
13019
|
"NOT_FOUND",
|
|
11766
13020
|
"CONFLICT",
|
|
11767
13021
|
"UPSTREAM_ERROR",
|
|
@@ -13334,11 +14588,32 @@ function pushTrace(trace, topic, score) {
|
|
|
13334
14588
|
score
|
|
13335
14589
|
});
|
|
13336
14590
|
}
|
|
14591
|
+
function pickBestTopic(topics2, input) {
|
|
14592
|
+
const ranked = topics2.filter((topic) => topic.status !== "archived").map((topic) => ({
|
|
14593
|
+
topic,
|
|
14594
|
+
score: scoreTopicMatch(topic, input)
|
|
14595
|
+
})).sort((left, right) => {
|
|
14596
|
+
if (right.score !== left.score) {
|
|
14597
|
+
return right.score - left.score;
|
|
14598
|
+
}
|
|
14599
|
+
const leftName = left.topic.name.trim().toLowerCase();
|
|
14600
|
+
const rightName = right.topic.name.trim().toLowerCase();
|
|
14601
|
+
return leftName.localeCompare(rightName);
|
|
14602
|
+
});
|
|
14603
|
+
return ranked[0]?.topic ?? null;
|
|
14604
|
+
}
|
|
14605
|
+
function pickFallbackRootTopic(topics2, input) {
|
|
14606
|
+
const parentless = topics2.filter((topic) => !topic.parentTopicId);
|
|
14607
|
+
return pickBestTopic(parentless, input) ?? pickBestTopic(topics2, input);
|
|
14608
|
+
}
|
|
13337
14609
|
async function loadTopicUniverse(ctx, input) {
|
|
13338
14610
|
const desiredTenantId = ctx.tenantId;
|
|
13339
14611
|
const desiredWorkspaceId = readString2(input.workspaceId) ?? ctx.workspaceId;
|
|
13340
14612
|
const rawTopics = await fetchTopicTree(ctx);
|
|
13341
|
-
const
|
|
14613
|
+
const scopedTopics = rawTopics.filter(
|
|
14614
|
+
(topic) => topicMatchesScope(topic, desiredTenantId, desiredWorkspaceId)
|
|
14615
|
+
);
|
|
14616
|
+
const root = rawTopics.find((topic) => topic.rawId === ROOT_TOPIC_ID) ?? await fetchTopicById(ctx, ROOT_TOPIC_ID) ?? pickFallbackRootTopic(scopedTopics, input) ?? null;
|
|
13342
14617
|
if (!root) {
|
|
13343
14618
|
throw new Error("[topic-resolver] Root topic not found.");
|
|
13344
14619
|
}
|
|
@@ -16244,6 +17519,56 @@ function readString12(value) {
|
|
|
16244
17519
|
function readNumber7(value) {
|
|
16245
17520
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
16246
17521
|
}
|
|
17522
|
+
function normalizeLimit(value, fallback, max) {
|
|
17523
|
+
const parsed = readNumber7(value);
|
|
17524
|
+
if (parsed === void 0) {
|
|
17525
|
+
return fallback;
|
|
17526
|
+
}
|
|
17527
|
+
return Math.max(1, Math.min(Math.floor(parsed), max));
|
|
17528
|
+
}
|
|
17529
|
+
function matchesOptionalString(actual, expected) {
|
|
17530
|
+
if (!expected) {
|
|
17531
|
+
return true;
|
|
17532
|
+
}
|
|
17533
|
+
return readString12(actual) === expected;
|
|
17534
|
+
}
|
|
17535
|
+
function normalizeGraphNode2(row) {
|
|
17536
|
+
const record = asRecord10(row);
|
|
17537
|
+
const nodeId = readString12(record.nodeId) ?? readString12(record._id);
|
|
17538
|
+
const globalId = readString12(record.globalId);
|
|
17539
|
+
const text = readString12(record.text) ?? readString12(record.canonicalText);
|
|
17540
|
+
return {
|
|
17541
|
+
...record,
|
|
17542
|
+
...nodeId ? { nodeId } : {},
|
|
17543
|
+
...globalId ? { globalId } : {},
|
|
17544
|
+
...text ? { text, canonicalText: text } : {}
|
|
17545
|
+
};
|
|
17546
|
+
}
|
|
17547
|
+
function normalizeGraphEdge2(row) {
|
|
17548
|
+
const record = asRecord10(row);
|
|
17549
|
+
const edgeId = readString12(record.edgeId) ?? readString12(record._id);
|
|
17550
|
+
return {
|
|
17551
|
+
...record,
|
|
17552
|
+
...edgeId ? { edgeId } : {},
|
|
17553
|
+
fromNodeId: readString12(record.fromNodeId) ?? readString12(record.sourceGlobalId),
|
|
17554
|
+
toNodeId: readString12(record.toNodeId) ?? readString12(record.targetGlobalId)
|
|
17555
|
+
};
|
|
17556
|
+
}
|
|
17557
|
+
async function fetchGraphNodeByIdentifier(authContext, input) {
|
|
17558
|
+
if (input.nodeId) {
|
|
17559
|
+
const node = await authContext.convex.query(api.epistemicNodes.get, {
|
|
17560
|
+
nodeId: input.nodeId
|
|
17561
|
+
});
|
|
17562
|
+
return node ? normalizeGraphNode2(node) : null;
|
|
17563
|
+
}
|
|
17564
|
+
if (input.globalId) {
|
|
17565
|
+
const node = await authContext.convex.query(api.epistemicNodes.getByGlobalId, {
|
|
17566
|
+
globalId: input.globalId
|
|
17567
|
+
});
|
|
17568
|
+
return node ? normalizeGraphNode2(node) : null;
|
|
17569
|
+
}
|
|
17570
|
+
return null;
|
|
17571
|
+
}
|
|
16247
17572
|
function inferRiskLevel(score, threshold) {
|
|
16248
17573
|
if (score >= Math.max(threshold + 0.2, 0.9)) {
|
|
16249
17574
|
return "critical";
|
|
@@ -16455,6 +17780,45 @@ function graphGapsFromGatewayAuth(authContext, input) {
|
|
|
16455
17780
|
function graphFalsifyFromGatewayAuth(authContext, input) {
|
|
16456
17781
|
return graphFalsify(createGatewayGraphPort(authContext), input);
|
|
16457
17782
|
}
|
|
17783
|
+
async function listGraphNodesFromGatewayAuth(authContext, input) {
|
|
17784
|
+
if (input.nodeId || input.globalId) {
|
|
17785
|
+
const node = await fetchGraphNodeByIdentifier(authContext, input);
|
|
17786
|
+
if (!node) {
|
|
17787
|
+
return { items: [], nodes: [], total: 0 };
|
|
17788
|
+
}
|
|
17789
|
+
if (input.topicId && readString12(node.topicId) !== input.topicId) {
|
|
17790
|
+
return { items: [], nodes: [], total: 0 };
|
|
17791
|
+
}
|
|
17792
|
+
if (!matchesOptionalString(node.nodeType, input.nodeType)) {
|
|
17793
|
+
return { items: [], nodes: [], total: 0 };
|
|
17794
|
+
}
|
|
17795
|
+
return { items: [node], nodes: [node], total: 1 };
|
|
17796
|
+
}
|
|
17797
|
+
const topicId = readString12(input.topicId) ?? readString12(input.projectId);
|
|
17798
|
+
if (!topicId) {
|
|
17799
|
+
throw new Error("[graph] topicId is required to list graph nodes.");
|
|
17800
|
+
}
|
|
17801
|
+
const rows = await authContext.convex.query(api.epistemicNodes.getByTopic, {
|
|
17802
|
+
topicId,
|
|
17803
|
+
userId: authContext.userId,
|
|
17804
|
+
limit: normalizeLimit(input.limit, 250, 1e3)
|
|
17805
|
+
});
|
|
17806
|
+
const nodes = asRecordArray2(rows).map(normalizeGraphNode2).filter((node) => matchesOptionalString(node.nodeType, input.nodeType));
|
|
17807
|
+
return { items: nodes, nodes, total: nodes.length };
|
|
17808
|
+
}
|
|
17809
|
+
async function listGraphEdgesFromGatewayAuth(authContext, input) {
|
|
17810
|
+
const topicId = readString12(input.topicId) ?? readString12(input.projectId);
|
|
17811
|
+
if (!topicId) {
|
|
17812
|
+
throw new Error("[graph] topicId is required to list graph edges.");
|
|
17813
|
+
}
|
|
17814
|
+
const rows = await authContext.convex.query(api.epistemicEdges.getByTopic, {
|
|
17815
|
+
topicId,
|
|
17816
|
+
userId: authContext.userId,
|
|
17817
|
+
limit: normalizeLimit(input.limit, 500, 2e3)
|
|
17818
|
+
});
|
|
17819
|
+
const edges = asRecordArray2(rows).map(normalizeGraphEdge2).filter((edge) => matchesOptionalString(edge.edgeId, input.edgeId)).filter((edge) => matchesOptionalString(edge.fromNodeId, input.fromNodeId)).filter((edge) => matchesOptionalString(edge.toNodeId, input.toNodeId)).filter((edge) => matchesOptionalString(edge.edgeType, input.edgeType));
|
|
17820
|
+
return { items: edges, edges, total: edges.length };
|
|
17821
|
+
}
|
|
16458
17822
|
|
|
16459
17823
|
// ../server-core/src/auth/gateway-claims.ts
|
|
16460
17824
|
function lastDelegator(delegationChain) {
|
|
@@ -16478,7 +17842,8 @@ function resolveGatewayClaims(authContext) {
|
|
|
16478
17842
|
principalType: "human",
|
|
16479
17843
|
tenantId: authContext.tenantId ?? authContext.servicePrincipalTenantId ?? "unknown",
|
|
16480
17844
|
workspaceId: authContext.workspaceId ?? authContext.servicePrincipalWorkspaceId,
|
|
16481
|
-
roles: [],
|
|
17845
|
+
roles: authContext.roles ?? [],
|
|
17846
|
+
membershipId: authContext.membershipId,
|
|
16482
17847
|
scopes: [...authContext.grantedScopes],
|
|
16483
17848
|
authMode: "interactive_user",
|
|
16484
17849
|
sessionId: authContext.sessionId,
|
|
@@ -16493,6 +17858,7 @@ function resolveGatewayClaims(authContext) {
|
|
|
16493
17858
|
tenantId: authContext.tenantId ?? authContext.servicePrincipalTenantId ?? "unknown",
|
|
16494
17859
|
workspaceId: authContext.workspaceId ?? authContext.servicePrincipalWorkspaceId,
|
|
16495
17860
|
roles: ["service_agent"],
|
|
17861
|
+
membershipId: authContext.membershipId,
|
|
16496
17862
|
scopes: [...authContext.grantedScopes],
|
|
16497
17863
|
authMode: "service_principal",
|
|
16498
17864
|
sessionId: authContext.sessionId,
|
|
@@ -16507,6 +17873,7 @@ function resolveGatewayClaims(authContext) {
|
|
|
16507
17873
|
tenantId: authContext.tenantId ?? authContext.servicePrincipalTenantId ?? "unknown",
|
|
16508
17874
|
workspaceId: authContext.workspaceId ?? authContext.servicePrincipalWorkspaceId,
|
|
16509
17875
|
roles: ["service_agent"],
|
|
17876
|
+
membershipId: authContext.membershipId,
|
|
16510
17877
|
scopes: [...authContext.grantedScopes],
|
|
16511
17878
|
authMode: "tenant_api_key",
|
|
16512
17879
|
sessionId: authContext.sessionId,
|
|
@@ -16521,6 +17888,7 @@ function resolveGatewayClaims(authContext) {
|
|
|
16521
17888
|
tenantId: authContext.tenantId ?? "unknown",
|
|
16522
17889
|
workspaceId: authContext.workspaceId,
|
|
16523
17890
|
roles: authContext.roles ?? [],
|
|
17891
|
+
membershipId: authContext.membershipId,
|
|
16524
17892
|
scopes: [...authContext.grantedScopes],
|
|
16525
17893
|
authMode: "session_token",
|
|
16526
17894
|
sessionId: authContext.sessionId,
|
|
@@ -18303,23 +19671,118 @@ function readStringArray9(value) {
|
|
|
18303
19671
|
const normalized = value.map((entry) => readString19(entry)).filter((entry) => Boolean(entry));
|
|
18304
19672
|
return normalized.length > 0 ? normalized : void 0;
|
|
18305
19673
|
}
|
|
18306
|
-
function
|
|
18307
|
-
|
|
18308
|
-
|
|
18309
|
-
function requireString3(value, field) {
|
|
18310
|
-
const normalized = readString19(value);
|
|
18311
|
-
if (!normalized) {
|
|
18312
|
-
throw createWorktreesError({
|
|
18313
|
-
message: `[worktrees] ${field} is required.`,
|
|
18314
|
-
status: 400,
|
|
18315
|
-
code: "INVALID_REQUEST",
|
|
18316
|
-
invariantCode: "request.valid_shape",
|
|
18317
|
-
suggestion: `Provide ${field} in the request payload.`
|
|
18318
|
-
});
|
|
19674
|
+
function normalizeKeyQuestions(keyQuestions) {
|
|
19675
|
+
if (!Array.isArray(keyQuestions)) {
|
|
19676
|
+
return void 0;
|
|
18319
19677
|
}
|
|
18320
|
-
|
|
19678
|
+
const normalized = keyQuestions.map((entry) => {
|
|
19679
|
+
const question = readString19(entry.question);
|
|
19680
|
+
if (!question) {
|
|
19681
|
+
return void 0;
|
|
19682
|
+
}
|
|
19683
|
+
return {
|
|
19684
|
+
question,
|
|
19685
|
+
...entry.status ? { status: entry.status } : {},
|
|
19686
|
+
...readString19(entry.answer) ? { answer: readString19(entry.answer) } : {},
|
|
19687
|
+
...entry.answerConfidence ? { answerConfidence: entry.answerConfidence } : {},
|
|
19688
|
+
...readString19(entry.linkedQuestionId) ? {
|
|
19689
|
+
linkedQuestionId: decodeExternalId9(
|
|
19690
|
+
readString19(entry.linkedQuestionId),
|
|
19691
|
+
"que",
|
|
19692
|
+
"keyQuestions.linkedQuestionId"
|
|
19693
|
+
)
|
|
19694
|
+
} : {}
|
|
19695
|
+
};
|
|
19696
|
+
}).filter((entry) => Boolean(entry));
|
|
19697
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
18321
19698
|
}
|
|
18322
|
-
function
|
|
19699
|
+
function normalizeEvidenceSignals(evidenceSignals) {
|
|
19700
|
+
if (!Array.isArray(evidenceSignals)) {
|
|
19701
|
+
return void 0;
|
|
19702
|
+
}
|
|
19703
|
+
const normalized = evidenceSignals.map((entry) => {
|
|
19704
|
+
const signal = readString19(entry.signal);
|
|
19705
|
+
if (!signal) {
|
|
19706
|
+
return void 0;
|
|
19707
|
+
}
|
|
19708
|
+
return {
|
|
19709
|
+
signal,
|
|
19710
|
+
...typeof entry.collected === "boolean" ? { collected: entry.collected } : {},
|
|
19711
|
+
...readString19(entry.progress) ? { progress: readString19(entry.progress) } : {},
|
|
19712
|
+
...readString19(entry.notes) ? { notes: readString19(entry.notes) } : {}
|
|
19713
|
+
};
|
|
19714
|
+
}).filter((entry) => Boolean(entry));
|
|
19715
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
19716
|
+
}
|
|
19717
|
+
function normalizeDecisionGate(input) {
|
|
19718
|
+
const source = input.decisionGate ?? (input.goCriteria || input.noGoSignals ? {
|
|
19719
|
+
goCriteria: input.goCriteria ?? [],
|
|
19720
|
+
noGoSignals: input.noGoSignals ?? []
|
|
19721
|
+
} : void 0);
|
|
19722
|
+
if (!source) {
|
|
19723
|
+
return void 0;
|
|
19724
|
+
}
|
|
19725
|
+
return {
|
|
19726
|
+
goCriteria: readStringArray9(source.goCriteria) ?? [],
|
|
19727
|
+
noGoSignals: readStringArray9(source.noGoSignals) ?? [],
|
|
19728
|
+
...source.verdict ? { verdict: source.verdict } : {},
|
|
19729
|
+
...readString19(source.verdictRationale) ? { verdictRationale: readString19(source.verdictRationale) } : {},
|
|
19730
|
+
...typeof source.decidedAt === "number" && Number.isFinite(source.decidedAt) ? { decidedAt: source.decidedAt } : {},
|
|
19731
|
+
...readString19(source.decidedBy) ? { decidedBy: readString19(source.decidedBy) } : {}
|
|
19732
|
+
};
|
|
19733
|
+
}
|
|
19734
|
+
function normalizeMergeOutcomes(outcomes) {
|
|
19735
|
+
const keyFindings = [];
|
|
19736
|
+
const scoringOutcomes = [];
|
|
19737
|
+
for (const outcome of outcomes) {
|
|
19738
|
+
const finding = readString19(outcome);
|
|
19739
|
+
if (finding) {
|
|
19740
|
+
keyFindings.push(finding);
|
|
19741
|
+
continue;
|
|
19742
|
+
}
|
|
19743
|
+
const record = asRecord15(outcome);
|
|
19744
|
+
if (!Object.keys(record).length) {
|
|
19745
|
+
throw createWorktreesError({
|
|
19746
|
+
message: "[worktrees] merge outcomes must be strings or { beliefId, confidence, rationale } objects.",
|
|
19747
|
+
status: 400,
|
|
19748
|
+
code: "INVALID_REQUEST",
|
|
19749
|
+
invariantCode: "request.valid_shape",
|
|
19750
|
+
suggestion: "Pass string outcomes for key findings, or scoring objects for belief confidence outcomes."
|
|
19751
|
+
});
|
|
19752
|
+
}
|
|
19753
|
+
scoringOutcomes.push({
|
|
19754
|
+
beliefId: requireString3(record.beliefId, "outcomes[].beliefId"),
|
|
19755
|
+
confidence: readNumber13(record.confidence) ?? (() => {
|
|
19756
|
+
throw createWorktreesError({
|
|
19757
|
+
message: "[worktrees] outcomes[].confidence must be a finite number.",
|
|
19758
|
+
status: 400,
|
|
19759
|
+
code: "INVALID_REQUEST",
|
|
19760
|
+
invariantCode: "request.valid_shape",
|
|
19761
|
+
suggestion: "Provide confidence as a number when scoring a belief outcome."
|
|
19762
|
+
});
|
|
19763
|
+
})(),
|
|
19764
|
+
rationale: requireString3(record.rationale, "outcomes[].rationale")
|
|
19765
|
+
});
|
|
19766
|
+
}
|
|
19767
|
+
return { keyFindings, scoringOutcomes };
|
|
19768
|
+
}
|
|
19769
|
+
function compareNullableNumber(left, right, fallback = 9999) {
|
|
19770
|
+
return (left ?? fallback) - (right ?? fallback);
|
|
19771
|
+
}
|
|
19772
|
+
function requireString3(value, field) {
|
|
19773
|
+
const normalized = readString19(value);
|
|
19774
|
+
if (!normalized) {
|
|
19775
|
+
throw createWorktreesError({
|
|
19776
|
+
message: `[worktrees] ${field} is required.`,
|
|
19777
|
+
status: 400,
|
|
19778
|
+
code: "INVALID_REQUEST",
|
|
19779
|
+
invariantCode: "request.valid_shape",
|
|
19780
|
+
suggestion: `Provide ${field} in the request payload.`
|
|
19781
|
+
});
|
|
19782
|
+
}
|
|
19783
|
+
return normalized;
|
|
19784
|
+
}
|
|
19785
|
+
function decodeExternalId9(id, prefix, field) {
|
|
18323
19786
|
const normalized = requireString3(id, field);
|
|
18324
19787
|
try {
|
|
18325
19788
|
const decoded = decodePrefixedId(normalized);
|
|
@@ -18547,14 +20010,33 @@ function buildWorktreeCampaignList(records) {
|
|
|
18547
20010
|
}
|
|
18548
20011
|
async function createWorktree(deps, input) {
|
|
18549
20012
|
const topicRawId = decodeExternalId9(input.topicId, "top", "topicId");
|
|
20013
|
+
const targetBeliefIds = input.targetBeliefIds ?? input.beliefIds;
|
|
18550
20014
|
const created = await deps.createWorktree({
|
|
18551
20015
|
title: requireString3(input.title, "title"),
|
|
18552
20016
|
topicRawId,
|
|
18553
20017
|
objective: readString19(input.objective),
|
|
18554
20018
|
hypothesis: readString19(input.hypothesis),
|
|
18555
|
-
|
|
20019
|
+
rationale: readString19(input.rationale),
|
|
20020
|
+
worktreeType: readString19(input.worktreeType),
|
|
20021
|
+
startDate: typeof input.startDate === "number" && Number.isFinite(input.startDate) ? input.startDate : void 0,
|
|
20022
|
+
endDate: typeof input.endDate === "number" && Number.isFinite(input.endDate) ? input.endDate : void 0,
|
|
20023
|
+
durationWeeks: typeof input.durationWeeks === "number" && Number.isFinite(input.durationWeeks) ? input.durationWeeks : void 0,
|
|
20024
|
+
confidenceImpact: input.confidenceImpact,
|
|
20025
|
+
beliefFocus: readString19(input.beliefFocus),
|
|
20026
|
+
beliefRawIds: targetBeliefIds?.map(
|
|
18556
20027
|
(id) => decodeExternalId9(id, "bel", "beliefIds")
|
|
18557
20028
|
),
|
|
20029
|
+
targetBeliefRawIds: input.targetBeliefIds?.map(
|
|
20030
|
+
(id) => decodeExternalId9(id, "bel", "targetBeliefIds")
|
|
20031
|
+
),
|
|
20032
|
+
targetQuestionRawIds: input.targetQuestionIds?.map(
|
|
20033
|
+
(id) => decodeExternalId9(id, "que", "targetQuestionIds")
|
|
20034
|
+
),
|
|
20035
|
+
keyQuestions: normalizeKeyQuestions(input.keyQuestions),
|
|
20036
|
+
evidenceSignals: normalizeEvidenceSignals(input.evidenceSignals),
|
|
20037
|
+
decisionGate: normalizeDecisionGate(input),
|
|
20038
|
+
goCriteria: readStringArray9(input.goCriteria),
|
|
20039
|
+
noGoSignals: readStringArray9(input.noGoSignals),
|
|
18558
20040
|
autoShape: typeof input.autoShape === "boolean" ? input.autoShape : void 0,
|
|
18559
20041
|
domainPackId: readString19(input.domainPackId),
|
|
18560
20042
|
campaign: typeof input.campaign === "number" && Number.isFinite(input.campaign) ? input.campaign : void 0,
|
|
@@ -18686,11 +20168,45 @@ async function updateWorktreeTargets(deps, input) {
|
|
|
18686
20168
|
}
|
|
18687
20169
|
async function mergeWorktree(deps, input) {
|
|
18688
20170
|
const rawId = decodeExternalId9(input.id, "wt", "id");
|
|
18689
|
-
const
|
|
18690
|
-
|
|
20171
|
+
const { keyFindings, scoringOutcomes } = normalizeMergeOutcomes(input.outcomes);
|
|
20172
|
+
const summary = readString19(input.summary) ?? keyFindings[0] ?? "Worktree merged.";
|
|
20173
|
+
const completeKeyFindings = keyFindings.length > 0 ? keyFindings : [summary];
|
|
20174
|
+
const worktree = await deps.fetchWorktree(rawId);
|
|
20175
|
+
if (!worktree) {
|
|
20176
|
+
throw createWorktreesError({
|
|
20177
|
+
message: `[worktrees] Worktree not found: ${rawId}.`,
|
|
20178
|
+
status: 404,
|
|
20179
|
+
code: "NOT_FOUND",
|
|
20180
|
+
invariantCode: "resource.exists"
|
|
20181
|
+
});
|
|
20182
|
+
}
|
|
20183
|
+
const worktreeStatus = readString19(asRecord15(worktree).status);
|
|
20184
|
+
if (worktreeStatus === "planning") {
|
|
20185
|
+
await deps.activateWorktree({ worktreeRawId: rawId });
|
|
20186
|
+
await deps.completeWorktree({
|
|
20187
|
+
worktreeRawId: rawId,
|
|
20188
|
+
summary,
|
|
20189
|
+
keyFindings: completeKeyFindings
|
|
20190
|
+
});
|
|
20191
|
+
} else if (!worktreeStatus || worktreeStatus === "active") {
|
|
20192
|
+
await deps.completeWorktree({
|
|
20193
|
+
worktreeRawId: rawId,
|
|
20194
|
+
summary,
|
|
20195
|
+
keyFindings: completeKeyFindings
|
|
20196
|
+
});
|
|
20197
|
+
} else if (worktreeStatus !== "completed" && worktreeStatus !== "merged") {
|
|
20198
|
+
throw createWorktreesError({
|
|
20199
|
+
message: `[worktrees] Cannot merge worktree in status "${worktreeStatus}".`,
|
|
20200
|
+
status: 409,
|
|
20201
|
+
code: "CONFLICT",
|
|
20202
|
+
invariantCode: "worktree.mergeable_status",
|
|
20203
|
+
suggestion: "Merge only planning, active, completed, or already-merged worktrees.",
|
|
20204
|
+
details: { worktreeId: encodeWorktreeId(rawId), status: worktreeStatus }
|
|
20205
|
+
});
|
|
20206
|
+
}
|
|
18691
20207
|
const failedBeliefs = [];
|
|
18692
20208
|
let beliefsScored = 0;
|
|
18693
|
-
for (const outcome of
|
|
20209
|
+
for (const outcome of scoringOutcomes) {
|
|
18694
20210
|
try {
|
|
18695
20211
|
await deps.scoreBeliefOutcome({
|
|
18696
20212
|
worktreeRawId: rawId,
|
|
@@ -18766,15 +20282,35 @@ function summarizeWorktreeCollection(rows) {
|
|
|
18766
20282
|
function buildCreateMutationArgs(input, userId) {
|
|
18767
20283
|
const objective = input.objective?.trim();
|
|
18768
20284
|
const hypothesis = input.hypothesis?.trim();
|
|
20285
|
+
const rationale = input.rationale?.trim();
|
|
20286
|
+
const worktreeType = input.worktreeType?.trim();
|
|
20287
|
+
const beliefFocus = input.beliefFocus?.trim();
|
|
18769
20288
|
const gate = input.gate?.trim();
|
|
18770
20289
|
const lensId = input.lensId?.trim();
|
|
20290
|
+
const targetBeliefIds = input.targetBeliefIds && input.targetBeliefIds.length > 0 ? input.targetBeliefIds : input.beliefIds;
|
|
18771
20291
|
return {
|
|
18772
20292
|
name: input.title,
|
|
18773
20293
|
topicId: input.topicId,
|
|
18774
20294
|
createdBy: userId,
|
|
18775
20295
|
...objective ? { objective } : {},
|
|
18776
20296
|
...hypothesis ? { hypothesis } : {},
|
|
18777
|
-
...
|
|
20297
|
+
...rationale ? { rationale } : {},
|
|
20298
|
+
...worktreeType ? { worktreeType } : {},
|
|
20299
|
+
...typeof input.startDate === "number" ? { startDate: input.startDate } : {},
|
|
20300
|
+
...typeof input.endDate === "number" ? { endDate: input.endDate } : {},
|
|
20301
|
+
...typeof input.durationWeeks === "number" ? { durationWeeks: input.durationWeeks } : {},
|
|
20302
|
+
...input.confidenceImpact ? { confidenceImpact: input.confidenceImpact } : {},
|
|
20303
|
+
...beliefFocus || objective || hypothesis ? { beliefFocus: beliefFocus ?? hypothesis ?? objective } : {},
|
|
20304
|
+
...Array.isArray(input.targetQuestionIds) && input.targetQuestionIds.length > 0 ? { targetQuestionIds: input.targetQuestionIds.map((id) => id) } : Array.isArray(input.questionRawIds) && input.questionRawIds.length > 0 ? { targetQuestionIds: input.questionRawIds.map((id) => id) } : {},
|
|
20305
|
+
...Array.isArray(targetBeliefIds) && targetBeliefIds.length > 0 ? { targetBeliefIds: targetBeliefIds.map((id) => id) } : {},
|
|
20306
|
+
...Array.isArray(input.keyQuestions) && input.keyQuestions.length > 0 ? { keyQuestions: input.keyQuestions } : {},
|
|
20307
|
+
...Array.isArray(input.evidenceSignals) && input.evidenceSignals.length > 0 ? { evidenceSignals: input.evidenceSignals } : {},
|
|
20308
|
+
...input.decisionGate ? { decisionGate: input.decisionGate } : input.goCriteria || input.noGoSignals ? {
|
|
20309
|
+
decisionGate: {
|
|
20310
|
+
goCriteria: input.goCriteria ?? [],
|
|
20311
|
+
noGoSignals: input.noGoSignals ?? []
|
|
20312
|
+
}
|
|
20313
|
+
} : {},
|
|
18778
20314
|
...typeof input.campaign === "number" ? { campaign: input.campaign } : {},
|
|
18779
20315
|
...input.lane ? { lane: input.lane } : {},
|
|
18780
20316
|
...typeof input.laneOrderInCampaign === "number" ? { laneOrderInCampaign: input.laneOrderInCampaign } : {},
|
|
@@ -18783,7 +20319,10 @@ function buildCreateMutationArgs(input, userId) {
|
|
|
18783
20319
|
...Array.isArray(input.blocks) && input.blocks.length > 0 ? { blocks: input.blocks.map((id) => id) } : {},
|
|
18784
20320
|
...gate ? { gate } : {},
|
|
18785
20321
|
...lensId ? { lensId } : {},
|
|
18786
|
-
...Array.isArray(input.
|
|
20322
|
+
...Array.isArray(input.proofArtifacts) ? { proofArtifacts: input.proofArtifacts } : {},
|
|
20323
|
+
...input.staffingHint?.trim() ? { staffingHint: input.staffingHint.trim() } : {},
|
|
20324
|
+
...typeof input.lastReconciledAt === "number" ? { lastReconciledAt: input.lastReconciledAt } : {},
|
|
20325
|
+
...input.autoFixPolicy ? { autoFixPolicy: input.autoFixPolicy } : {}
|
|
18787
20326
|
};
|
|
18788
20327
|
}
|
|
18789
20328
|
function readString20(value) {
|
|
@@ -18856,7 +20395,9 @@ function createGatewayWorktreesPort(authContext) {
|
|
|
18856
20395
|
...input,
|
|
18857
20396
|
topicId: input.topicRawId,
|
|
18858
20397
|
title: input.title,
|
|
18859
|
-
beliefIds: input.beliefRawIds
|
|
20398
|
+
beliefIds: input.beliefRawIds,
|
|
20399
|
+
targetBeliefIds: input.targetBeliefRawIds,
|
|
20400
|
+
targetQuestionIds: input.targetQuestionRawIds
|
|
18860
20401
|
},
|
|
18861
20402
|
authContext.userId
|
|
18862
20403
|
),
|
|
@@ -18871,7 +20412,9 @@ function createGatewayWorktreesPort(authContext) {
|
|
|
18871
20412
|
...input,
|
|
18872
20413
|
topicId: input.topicRawId,
|
|
18873
20414
|
title: input.title,
|
|
18874
|
-
beliefIds: input.beliefRawIds
|
|
20415
|
+
beliefIds: input.beliefRawIds,
|
|
20416
|
+
targetBeliefIds: input.targetBeliefRawIds,
|
|
20417
|
+
targetQuestionIds: input.targetQuestionRawIds
|
|
18875
20418
|
},
|
|
18876
20419
|
authContext.userId
|
|
18877
20420
|
));
|
|
@@ -18899,7 +20442,7 @@ function createGatewayWorktreesPort(authContext) {
|
|
|
18899
20442
|
completeWorktree(args) {
|
|
18900
20443
|
return authContext.convex.mutation(api.worktrees.complete, {
|
|
18901
20444
|
worktreeId: args.worktreeRawId,
|
|
18902
|
-
keyFindings: [args.summary],
|
|
20445
|
+
keyFindings: args.keyFindings?.length ? args.keyFindings : [args.summary],
|
|
18903
20446
|
decisionsReached: [],
|
|
18904
20447
|
nextSteps: [],
|
|
18905
20448
|
userId: authContext.userId
|
|
@@ -20454,6 +21997,44 @@ async function handleGraphNeighborhood(args) {
|
|
|
20454
21997
|
);
|
|
20455
21998
|
}
|
|
20456
21999
|
}
|
|
22000
|
+
async function handleGraphNodeList(args) {
|
|
22001
|
+
try {
|
|
22002
|
+
const payload = await listGraphNodesFromGatewayAuth(
|
|
22003
|
+
args.authContext,
|
|
22004
|
+
args.query
|
|
22005
|
+
);
|
|
22006
|
+
return successResponse(payload, {
|
|
22007
|
+
correlationId: args.correlationId,
|
|
22008
|
+
policyTraceId: args.policyTraceId
|
|
22009
|
+
});
|
|
22010
|
+
} catch (error) {
|
|
22011
|
+
return handleGraphError(
|
|
22012
|
+
error,
|
|
22013
|
+
"Failed to list graph nodes.",
|
|
22014
|
+
args.correlationId,
|
|
22015
|
+
args.policyTraceId
|
|
22016
|
+
);
|
|
22017
|
+
}
|
|
22018
|
+
}
|
|
22019
|
+
async function handleGraphEdgeList(args) {
|
|
22020
|
+
try {
|
|
22021
|
+
const payload = await listGraphEdgesFromGatewayAuth(
|
|
22022
|
+
args.authContext,
|
|
22023
|
+
args.query
|
|
22024
|
+
);
|
|
22025
|
+
return successResponse(payload, {
|
|
22026
|
+
correlationId: args.correlationId,
|
|
22027
|
+
policyTraceId: args.policyTraceId
|
|
22028
|
+
});
|
|
22029
|
+
} catch (error) {
|
|
22030
|
+
return handleGraphError(
|
|
22031
|
+
error,
|
|
22032
|
+
"Failed to list graph edges.",
|
|
22033
|
+
args.correlationId,
|
|
22034
|
+
args.policyTraceId
|
|
22035
|
+
);
|
|
22036
|
+
}
|
|
22037
|
+
}
|
|
20457
22038
|
async function handleGraphTraverse(args) {
|
|
20458
22039
|
const body = asRecord20(args.body);
|
|
20459
22040
|
if (!readString25(body.startNode)) {
|
|
@@ -20595,6 +22176,516 @@ async function handleGraphFalsify(args) {
|
|
|
20595
22176
|
}
|
|
20596
22177
|
}
|
|
20597
22178
|
|
|
22179
|
+
// ../server-core/src/graph-analysis.ts
|
|
22180
|
+
function cleanString(value) {
|
|
22181
|
+
if (typeof value !== "string") {
|
|
22182
|
+
return void 0;
|
|
22183
|
+
}
|
|
22184
|
+
const normalized = value.trim();
|
|
22185
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
22186
|
+
}
|
|
22187
|
+
function cleanNumber(value) {
|
|
22188
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
22189
|
+
}
|
|
22190
|
+
function cleanStringArray(value) {
|
|
22191
|
+
if (!Array.isArray(value)) {
|
|
22192
|
+
return void 0;
|
|
22193
|
+
}
|
|
22194
|
+
const normalized = value.map((entry) => cleanString(entry)).filter((entry) => Boolean(entry));
|
|
22195
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
22196
|
+
}
|
|
22197
|
+
function asRecord21(value) {
|
|
22198
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
22199
|
+
}
|
|
22200
|
+
function asRecordArray3(value) {
|
|
22201
|
+
return Array.isArray(value) ? value.filter(
|
|
22202
|
+
(entry) => Boolean(entry) && typeof entry === "object" && !Array.isArray(entry)
|
|
22203
|
+
) : [];
|
|
22204
|
+
}
|
|
22205
|
+
function requireString4(value, label) {
|
|
22206
|
+
const normalized = cleanString(value);
|
|
22207
|
+
if (!normalized) {
|
|
22208
|
+
throw new Error(`${label} is required`);
|
|
22209
|
+
}
|
|
22210
|
+
return normalized;
|
|
22211
|
+
}
|
|
22212
|
+
function requireMatchingTenantScope(authContext, input) {
|
|
22213
|
+
const tenantId = requireString4(input.tenantId, "tenantId");
|
|
22214
|
+
const workspaceId = requireString4(input.workspaceId, "workspaceId");
|
|
22215
|
+
if (authContext.tenantId && authContext.tenantId !== tenantId) {
|
|
22216
|
+
throw new GatewayAuthError(
|
|
22217
|
+
403,
|
|
22218
|
+
"FORBIDDEN",
|
|
22219
|
+
"Requested tenantId does not match the authenticated Lucern tenant context."
|
|
22220
|
+
);
|
|
22221
|
+
}
|
|
22222
|
+
if (authContext.workspaceId && authContext.workspaceId !== workspaceId) {
|
|
22223
|
+
throw new GatewayAuthError(
|
|
22224
|
+
403,
|
|
22225
|
+
"FORBIDDEN",
|
|
22226
|
+
"Requested workspaceId does not match the authenticated Lucern workspace context."
|
|
22227
|
+
);
|
|
22228
|
+
}
|
|
22229
|
+
return { tenantId, workspaceId };
|
|
22230
|
+
}
|
|
22231
|
+
function readLimit(value) {
|
|
22232
|
+
const parsed = cleanNumber(value);
|
|
22233
|
+
if (parsed === void 0) {
|
|
22234
|
+
return void 0;
|
|
22235
|
+
}
|
|
22236
|
+
return Math.max(1, Math.min(Math.floor(parsed), 200));
|
|
22237
|
+
}
|
|
22238
|
+
function publicSuggestionStatus(status) {
|
|
22239
|
+
const normalized = cleanString(status);
|
|
22240
|
+
if (normalized === "pending") {
|
|
22241
|
+
return "open";
|
|
22242
|
+
}
|
|
22243
|
+
if (normalized === "declined") {
|
|
22244
|
+
return "dismissed";
|
|
22245
|
+
}
|
|
22246
|
+
return normalized;
|
|
22247
|
+
}
|
|
22248
|
+
function normalizeSuggestion(row) {
|
|
22249
|
+
return {
|
|
22250
|
+
...row,
|
|
22251
|
+
suggestionId: cleanString(row.suggestionId) ?? cleanString(row.recommendationId),
|
|
22252
|
+
recommendationId: cleanString(row.recommendationId) ?? cleanString(row.suggestionId),
|
|
22253
|
+
status: publicSuggestionStatus(row.status)
|
|
22254
|
+
};
|
|
22255
|
+
}
|
|
22256
|
+
function normalizeRecommendation(row) {
|
|
22257
|
+
const suggestion = normalizeSuggestion(row);
|
|
22258
|
+
return {
|
|
22259
|
+
...suggestion,
|
|
22260
|
+
recommendationId: cleanString(suggestion.recommendationId) ?? cleanString(suggestion.suggestionId)
|
|
22261
|
+
};
|
|
22262
|
+
}
|
|
22263
|
+
function readChangeTimestamp(row) {
|
|
22264
|
+
return cleanNumber(row.updatedAt) ?? cleanNumber(row.actedAt) ?? cleanNumber(row.createdAt);
|
|
22265
|
+
}
|
|
22266
|
+
function includesAny(value, expected) {
|
|
22267
|
+
if (!expected || expected.length === 0) {
|
|
22268
|
+
return true;
|
|
22269
|
+
}
|
|
22270
|
+
if (Array.isArray(value)) {
|
|
22271
|
+
return value.some((entry) => expected.includes(String(entry)));
|
|
22272
|
+
}
|
|
22273
|
+
return typeof value === "string" && expected.includes(value);
|
|
22274
|
+
}
|
|
22275
|
+
function normalizeGraphChange(row, kind) {
|
|
22276
|
+
const metadata = asRecord21(row.metadata);
|
|
22277
|
+
const sourceNodeIds = cleanStringArray(row.sourceNodeIds) ?? cleanStringArray(row.targetNodeIds) ?? [
|
|
22278
|
+
cleanString(row.targetNodeId),
|
|
22279
|
+
cleanString(row.secondaryNodeId),
|
|
22280
|
+
cleanString(row.resultNodeId)
|
|
22281
|
+
].filter((value) => Boolean(value));
|
|
22282
|
+
const sourceEdgeIds = cleanStringArray(row.sourceEdgeIds) ?? [];
|
|
22283
|
+
return {
|
|
22284
|
+
changeId: cleanString(row.changeId) ?? cleanString(row.suggestionId) ?? cleanString(row.analysisId) ?? cleanString(row.recommendationId) ?? cleanString(row._id),
|
|
22285
|
+
analysisId: cleanString(row.analysisId) ?? cleanString(row.analysisResultId) ?? cleanString(row._id),
|
|
22286
|
+
suggestionId: cleanString(row.suggestionId),
|
|
22287
|
+
topicId: cleanString(row.topicId),
|
|
22288
|
+
workspaceId: cleanString(row.workspaceId),
|
|
22289
|
+
changeType: cleanString(row.changeType) ?? kind,
|
|
22290
|
+
nodeIds: sourceNodeIds,
|
|
22291
|
+
edgeIds: sourceEdgeIds,
|
|
22292
|
+
summary: cleanString(row.summary) ?? cleanString(row.title) ?? cleanString(row.analysisText) ?? cleanString(row.rationale),
|
|
22293
|
+
metadata,
|
|
22294
|
+
createdAt: readChangeTimestamp(row)
|
|
22295
|
+
};
|
|
22296
|
+
}
|
|
22297
|
+
function normalizeNodeResult(row, input) {
|
|
22298
|
+
const metadata = asRecord21(row.metadata);
|
|
22299
|
+
const confidence = cleanNumber(row.confidence) ?? cleanNumber(metadata.confidence) ?? cleanNumber(row.baseRate);
|
|
22300
|
+
return {
|
|
22301
|
+
nodeId: cleanString(row.globalId) ?? cleanString(row.nodeId) ?? String(row._id ?? ""),
|
|
22302
|
+
globalId: cleanString(row.globalId),
|
|
22303
|
+
topicId: cleanString(row.topicId),
|
|
22304
|
+
sourceWorkspaceId: cleanString(row.workspaceId) ?? cleanString(metadata.workspaceId) ?? cleanString(input.workspaceId),
|
|
22305
|
+
publishedAt: cleanNumber(metadata.publishedAt),
|
|
22306
|
+
publishedByPrincipalId: cleanString(metadata.publishedByPrincipalId),
|
|
22307
|
+
visibility: cleanString(metadata.visibility) ?? "workspace",
|
|
22308
|
+
confidence: confidence ?? null,
|
|
22309
|
+
confidenceHistory: Array.isArray(metadata.confidenceHistory) ? metadata.confidenceHistory : void 0,
|
|
22310
|
+
provenance: {
|
|
22311
|
+
scope: cleanString(input.provenanceScope) ?? "own_workspace",
|
|
22312
|
+
sourceWorkspaceId: cleanString(metadata.sourceWorkspaceId) ?? cleanString(input.workspaceId),
|
|
22313
|
+
publishedAt: cleanNumber(metadata.publishedAt),
|
|
22314
|
+
publishedByPrincipalId: cleanString(metadata.publishedByPrincipalId),
|
|
22315
|
+
metadata: metadata.provenance
|
|
22316
|
+
},
|
|
22317
|
+
nodeType: cleanString(row.nodeType),
|
|
22318
|
+
text: cleanString(row.canonicalText) ?? cleanString(row.text) ?? cleanString(row.title),
|
|
22319
|
+
title: cleanString(row.title),
|
|
22320
|
+
metadata
|
|
22321
|
+
};
|
|
22322
|
+
}
|
|
22323
|
+
function filterNodeResults(rows, input) {
|
|
22324
|
+
const nodeTypes = new Set(cleanStringArray(input.nodeTypes) ?? []);
|
|
22325
|
+
const minConfidence = cleanNumber(input.minConfidence);
|
|
22326
|
+
return rows.map((row) => normalizeNodeResult(row, input)).filter((row) => {
|
|
22327
|
+
const nodeType = cleanString(row.nodeType);
|
|
22328
|
+
if (nodeTypes.size > 0 && (!nodeType || !nodeTypes.has(nodeType))) {
|
|
22329
|
+
return false;
|
|
22330
|
+
}
|
|
22331
|
+
if (minConfidence !== void 0 && (typeof row.confidence !== "number" || row.confidence < minConfidence)) {
|
|
22332
|
+
return false;
|
|
22333
|
+
}
|
|
22334
|
+
return true;
|
|
22335
|
+
});
|
|
22336
|
+
}
|
|
22337
|
+
async function saveGraphAnalysisFromGatewayAuth(authContext, input) {
|
|
22338
|
+
return await authContext.convex.mutation(
|
|
22339
|
+
api.graphAnalysisResults.saveAnalysis,
|
|
22340
|
+
{
|
|
22341
|
+
...input,
|
|
22342
|
+
topicId: requireString4(input.topicId, "topicId"),
|
|
22343
|
+
workspaceId: requireString4(input.workspaceId, "workspaceId"),
|
|
22344
|
+
userId: authContext.userId
|
|
22345
|
+
}
|
|
22346
|
+
);
|
|
22347
|
+
}
|
|
22348
|
+
async function listGraphAnalysesFromGatewayAuth(authContext, input) {
|
|
22349
|
+
const analyses = await authContext.convex.query(
|
|
22350
|
+
api.graphAnalysisResults.listAnalyses,
|
|
22351
|
+
{
|
|
22352
|
+
topicId: requireString4(input.topicId, "topicId"),
|
|
22353
|
+
workspaceId: cleanString(input.workspaceId),
|
|
22354
|
+
analysisType: cleanString(input.analysisType),
|
|
22355
|
+
limit: readLimit(input.limit),
|
|
22356
|
+
userId: authContext.userId
|
|
22357
|
+
}
|
|
22358
|
+
);
|
|
22359
|
+
return { analyses: Array.isArray(analyses) ? analyses : [] };
|
|
22360
|
+
}
|
|
22361
|
+
async function getLatestGraphAnalysisFromGatewayAuth(authContext, input) {
|
|
22362
|
+
return await authContext.convex.query(
|
|
22363
|
+
api.graphAnalysisResults.getLatestAnalysis,
|
|
22364
|
+
{
|
|
22365
|
+
topicId: requireString4(input.topicId, "topicId"),
|
|
22366
|
+
workspaceId: cleanString(input.workspaceId),
|
|
22367
|
+
analysisType: cleanString(input.analysisType),
|
|
22368
|
+
userId: authContext.userId
|
|
22369
|
+
}
|
|
22370
|
+
);
|
|
22371
|
+
}
|
|
22372
|
+
async function saveGraphSuggestionsFromGatewayAuth(authContext, input) {
|
|
22373
|
+
const suggestions = await authContext.convex.mutation(
|
|
22374
|
+
api.graphAnalysisResults.saveSuggestions,
|
|
22375
|
+
{
|
|
22376
|
+
...input,
|
|
22377
|
+
topicId: requireString4(input.topicId, "topicId"),
|
|
22378
|
+
workspaceId: requireString4(input.workspaceId, "workspaceId"),
|
|
22379
|
+
userId: authContext.userId
|
|
22380
|
+
}
|
|
22381
|
+
);
|
|
22382
|
+
return {
|
|
22383
|
+
suggestions: Array.isArray(suggestions) ? suggestions.map((row) => normalizeSuggestion(asRecord21(row))) : []
|
|
22384
|
+
};
|
|
22385
|
+
}
|
|
22386
|
+
async function listGraphSuggestionsFromGatewayAuth(authContext, input) {
|
|
22387
|
+
const suggestions = await authContext.convex.query(
|
|
22388
|
+
api.graphAnalysisResults.listSuggestions,
|
|
22389
|
+
{
|
|
22390
|
+
topicId: requireString4(input.topicId, "topicId"),
|
|
22391
|
+
workspaceId: cleanString(input.workspaceId),
|
|
22392
|
+
analysisId: cleanString(input.analysisId),
|
|
22393
|
+
findingId: cleanString(input.findingId),
|
|
22394
|
+
status: cleanString(input.status),
|
|
22395
|
+
limit: readLimit(input.limit),
|
|
22396
|
+
userId: authContext.userId
|
|
22397
|
+
}
|
|
22398
|
+
);
|
|
22399
|
+
return {
|
|
22400
|
+
suggestions: Array.isArray(suggestions) ? suggestions.map((row) => normalizeSuggestion(asRecord21(row))) : []
|
|
22401
|
+
};
|
|
22402
|
+
}
|
|
22403
|
+
async function listGraphChangesFromGatewayAuth(authContext, input) {
|
|
22404
|
+
const minimumCreatedAt = cleanNumber(input.minimumCreatedAt) ?? cleanNumber(input.since) ?? cleanNumber(input.createdAt) ?? cleanNumber(input.analysisCreatedAt);
|
|
22405
|
+
if (minimumCreatedAt === void 0) {
|
|
22406
|
+
throw new Error("minimumCreatedAt is required");
|
|
22407
|
+
}
|
|
22408
|
+
const sourceNodeIds = cleanStringArray(input.sourceNodeIds) ?? (cleanString(input.nodeId) ? [cleanString(input.nodeId)] : void 0);
|
|
22409
|
+
const sourceEdgeIds = cleanStringArray(input.sourceEdgeIds) ?? (cleanString(input.edgeId) ? [cleanString(input.edgeId)] : void 0);
|
|
22410
|
+
const limit = readLimit(input.limit) ?? 100;
|
|
22411
|
+
const [{ analyses }, { suggestions }] = await Promise.all([
|
|
22412
|
+
listGraphAnalysesFromGatewayAuth(authContext, input),
|
|
22413
|
+
listGraphSuggestionsFromGatewayAuth(authContext, input)
|
|
22414
|
+
]);
|
|
22415
|
+
const analysisChanges = analyses.map((row) => normalizeGraphChange(asRecord21(row), "analysis_recorded")).filter((row) => {
|
|
22416
|
+
const createdAt = cleanNumber(row.createdAt);
|
|
22417
|
+
return createdAt !== void 0 && createdAt >= minimumCreatedAt && includesAny(row.nodeIds, sourceNodeIds) && includesAny(row.edgeIds, sourceEdgeIds);
|
|
22418
|
+
});
|
|
22419
|
+
const suggestionChanges = suggestions.map((row) => normalizeGraphChange(asRecord21(row), "suggestion_recorded")).filter((row) => {
|
|
22420
|
+
const createdAt = cleanNumber(row.createdAt);
|
|
22421
|
+
return createdAt !== void 0 && createdAt >= minimumCreatedAt && includesAny(row.nodeIds, sourceNodeIds) && includesAny(row.edgeIds, sourceEdgeIds);
|
|
22422
|
+
});
|
|
22423
|
+
const changes = [...analysisChanges, ...suggestionChanges].sort((left, right) => {
|
|
22424
|
+
const leftAt = cleanNumber(left.createdAt) ?? 0;
|
|
22425
|
+
const rightAt = cleanNumber(right.createdAt) ?? 0;
|
|
22426
|
+
return rightAt - leftAt;
|
|
22427
|
+
}).slice(0, limit);
|
|
22428
|
+
return {
|
|
22429
|
+
changes,
|
|
22430
|
+
items: changes,
|
|
22431
|
+
total: changes.length
|
|
22432
|
+
};
|
|
22433
|
+
}
|
|
22434
|
+
async function updateGraphSuggestionStatusFromGatewayAuth(authContext, input) {
|
|
22435
|
+
const suggestion = await authContext.convex.mutation(
|
|
22436
|
+
api.graphAnalysisResults.updateSuggestionStatus,
|
|
22437
|
+
{
|
|
22438
|
+
suggestionId: requireString4(input.suggestionId, "suggestionId"),
|
|
22439
|
+
status: requireString4(input.status, "status"),
|
|
22440
|
+
rationale: cleanString(input.rationale),
|
|
22441
|
+
metadata: input.metadata,
|
|
22442
|
+
userId: authContext.userId
|
|
22443
|
+
}
|
|
22444
|
+
);
|
|
22445
|
+
return normalizeSuggestion(asRecord21(suggestion));
|
|
22446
|
+
}
|
|
22447
|
+
async function computeOrRequestGraphAnalysisFromGatewayAuth(authContext, input) {
|
|
22448
|
+
const topicId = requireString4(input.topicId, "topicId");
|
|
22449
|
+
const analysisType = cleanString(input.analysisType) ?? "structure_analysis";
|
|
22450
|
+
const analysis = await graphAnalyzeFromGatewayAuth(authContext, {
|
|
22451
|
+
topicId,
|
|
22452
|
+
metric: analysisType
|
|
22453
|
+
});
|
|
22454
|
+
const payload = asRecord21(analysis.payload);
|
|
22455
|
+
return {
|
|
22456
|
+
analysisId: `computed:${topicId}:${analysisType}`,
|
|
22457
|
+
topicId,
|
|
22458
|
+
workspaceId: requireString4(input.workspaceId, "workspaceId"),
|
|
22459
|
+
analysisType,
|
|
22460
|
+
healthScore: cleanNumber(payload.healthScore),
|
|
22461
|
+
findings: asRecordArray3(payload.findings),
|
|
22462
|
+
suggestions: [],
|
|
22463
|
+
sourceNodeIds: cleanStringArray(input.sourceNodeIds) ?? [],
|
|
22464
|
+
sourceEdgeIds: cleanStringArray(input.sourceEdgeIds) ?? [],
|
|
22465
|
+
detectorVersions: asRecord21(input.detectorVersions),
|
|
22466
|
+
metadata: asRecord21(input.metadata),
|
|
22467
|
+
createdAt: Date.now()
|
|
22468
|
+
};
|
|
22469
|
+
}
|
|
22470
|
+
async function listGraphRecommendationsFromGatewayAuth(authContext, input) {
|
|
22471
|
+
const { suggestions } = await listGraphSuggestionsFromGatewayAuth(authContext, input);
|
|
22472
|
+
return {
|
|
22473
|
+
recommendations: suggestions.map((row) => normalizeRecommendation(row))
|
|
22474
|
+
};
|
|
22475
|
+
}
|
|
22476
|
+
async function getGraphRecommendationFromGatewayAuth(authContext, recommendationId) {
|
|
22477
|
+
const recommendation = await authContext.convex.query(
|
|
22478
|
+
api.graphAnalysisResults.getSuggestion,
|
|
22479
|
+
{
|
|
22480
|
+
suggestionId: recommendationId,
|
|
22481
|
+
userId: authContext.userId
|
|
22482
|
+
}
|
|
22483
|
+
);
|
|
22484
|
+
return normalizeRecommendation(asRecord21(recommendation));
|
|
22485
|
+
}
|
|
22486
|
+
async function markGraphRecommendationStatusFromGatewayAuth(authContext, input) {
|
|
22487
|
+
const updated = await updateGraphSuggestionStatusFromGatewayAuth(authContext, {
|
|
22488
|
+
suggestionId: requireString4(input.recommendationId, "recommendationId"),
|
|
22489
|
+
status: requireString4(input.status, "status"),
|
|
22490
|
+
rationale: cleanString(input.rationale),
|
|
22491
|
+
metadata: input.metadata
|
|
22492
|
+
});
|
|
22493
|
+
return normalizeRecommendation(updated);
|
|
22494
|
+
}
|
|
22495
|
+
async function searchOrgGraphFromGatewayAuth(authContext, input) {
|
|
22496
|
+
requireMatchingTenantScope(authContext, input);
|
|
22497
|
+
const query = requireString4(input.query, "query");
|
|
22498
|
+
const rows = await authContext.convex.query(api.nodes.search, {
|
|
22499
|
+
searchQuery: query,
|
|
22500
|
+
limit: readLimit(input.limit)
|
|
22501
|
+
});
|
|
22502
|
+
return {
|
|
22503
|
+
results: filterNodeResults(Array.isArray(rows) ? rows : [], input)
|
|
22504
|
+
};
|
|
22505
|
+
}
|
|
22506
|
+
async function getOrgGraphNodeFromGatewayAuth(authContext, input) {
|
|
22507
|
+
requireMatchingTenantScope(authContext, input);
|
|
22508
|
+
const nodeId = cleanString(input.nodeId);
|
|
22509
|
+
const globalId = cleanString(input.globalId) ?? nodeId;
|
|
22510
|
+
if (!globalId) {
|
|
22511
|
+
throw new Error("nodeId or globalId is required");
|
|
22512
|
+
}
|
|
22513
|
+
const node = await authContext.convex.query(api.nodes.getByGlobalId, {
|
|
22514
|
+
globalId
|
|
22515
|
+
});
|
|
22516
|
+
return normalizeNodeResult(asRecord21(node), input);
|
|
22517
|
+
}
|
|
22518
|
+
async function listOrgGraphByProvenanceFromGatewayAuth(authContext, input) {
|
|
22519
|
+
requireMatchingTenantScope(authContext, input);
|
|
22520
|
+
requireString4(input.provenanceScope, "provenanceScope");
|
|
22521
|
+
const rows = await authContext.convex.query(api.nodes.listAll, {
|
|
22522
|
+
limit: readLimit(input.limit)
|
|
22523
|
+
});
|
|
22524
|
+
return {
|
|
22525
|
+
results: filterNodeResults(Array.isArray(rows) ? rows : [], input)
|
|
22526
|
+
};
|
|
22527
|
+
}
|
|
22528
|
+
async function listPublishedOrgGraphFromGatewayAuth(authContext, input) {
|
|
22529
|
+
return listOrgGraphByProvenanceFromGatewayAuth(authContext, {
|
|
22530
|
+
...input,
|
|
22531
|
+
provenanceScope: "published"
|
|
22532
|
+
});
|
|
22533
|
+
}
|
|
22534
|
+
|
|
22535
|
+
// ../../apps/gateway/src/routes/graph-analysis.ts
|
|
22536
|
+
function asRecord22(value) {
|
|
22537
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
22538
|
+
}
|
|
22539
|
+
function routeError(error, fallbackMessage, correlationId, policyTraceId) {
|
|
22540
|
+
const resolved = resolveServerCoreError(error, fallbackMessage);
|
|
22541
|
+
return errorResponse({
|
|
22542
|
+
code: resolved.code,
|
|
22543
|
+
message: resolved.message,
|
|
22544
|
+
status: resolved.status,
|
|
22545
|
+
correlationId,
|
|
22546
|
+
policyTraceId,
|
|
22547
|
+
invariant: resolved.invariant,
|
|
22548
|
+
suggestion: resolved.suggestion,
|
|
22549
|
+
details: resolved.details
|
|
22550
|
+
});
|
|
22551
|
+
}
|
|
22552
|
+
async function withGraphRoute(args) {
|
|
22553
|
+
try {
|
|
22554
|
+
const payload = await args.run();
|
|
22555
|
+
return successResponse(payload, {
|
|
22556
|
+
correlationId: args.correlationId,
|
|
22557
|
+
policyTraceId: args.policyTraceId
|
|
22558
|
+
});
|
|
22559
|
+
} catch (error) {
|
|
22560
|
+
return routeError(
|
|
22561
|
+
error,
|
|
22562
|
+
args.fallbackMessage,
|
|
22563
|
+
args.correlationId,
|
|
22564
|
+
args.policyTraceId
|
|
22565
|
+
);
|
|
22566
|
+
}
|
|
22567
|
+
}
|
|
22568
|
+
async function handleGraphAnalysisSave(args) {
|
|
22569
|
+
return withGraphRoute({
|
|
22570
|
+
...args,
|
|
22571
|
+
fallbackMessage: "Failed to save graph analysis.",
|
|
22572
|
+
run: () => saveGraphAnalysisFromGatewayAuth(args.authContext, asRecord22(args.body))
|
|
22573
|
+
});
|
|
22574
|
+
}
|
|
22575
|
+
async function handleGraphAnalysisList(args) {
|
|
22576
|
+
return withGraphRoute({
|
|
22577
|
+
...args,
|
|
22578
|
+
fallbackMessage: "Failed to list graph analyses.",
|
|
22579
|
+
run: () => listGraphAnalysesFromGatewayAuth(args.authContext, args.query)
|
|
22580
|
+
});
|
|
22581
|
+
}
|
|
22582
|
+
async function handleGraphAnalysisLatest(args) {
|
|
22583
|
+
return withGraphRoute({
|
|
22584
|
+
...args,
|
|
22585
|
+
fallbackMessage: "Failed to fetch latest graph analysis.",
|
|
22586
|
+
run: () => getLatestGraphAnalysisFromGatewayAuth(args.authContext, args.query)
|
|
22587
|
+
});
|
|
22588
|
+
}
|
|
22589
|
+
async function handleGraphAnalysisSaveSuggestions(args) {
|
|
22590
|
+
return withGraphRoute({
|
|
22591
|
+
...args,
|
|
22592
|
+
fallbackMessage: "Failed to save graph suggestions.",
|
|
22593
|
+
run: () => saveGraphSuggestionsFromGatewayAuth(args.authContext, asRecord22(args.body))
|
|
22594
|
+
});
|
|
22595
|
+
}
|
|
22596
|
+
async function handleGraphAnalysisListSuggestions(args) {
|
|
22597
|
+
return withGraphRoute({
|
|
22598
|
+
...args,
|
|
22599
|
+
fallbackMessage: "Failed to list graph suggestions.",
|
|
22600
|
+
run: () => listGraphSuggestionsFromGatewayAuth(args.authContext, args.query)
|
|
22601
|
+
});
|
|
22602
|
+
}
|
|
22603
|
+
async function handleGraphAnalysisListChanges(args) {
|
|
22604
|
+
return withGraphRoute({
|
|
22605
|
+
...args,
|
|
22606
|
+
fallbackMessage: "Failed to list graph analysis changes.",
|
|
22607
|
+
run: () => listGraphChangesFromGatewayAuth(args.authContext, args.query)
|
|
22608
|
+
});
|
|
22609
|
+
}
|
|
22610
|
+
async function handleGraphAnalysisUpdateSuggestion(args) {
|
|
22611
|
+
return withGraphRoute({
|
|
22612
|
+
...args,
|
|
22613
|
+
fallbackMessage: "Failed to update graph suggestion.",
|
|
22614
|
+
run: () => updateGraphSuggestionStatusFromGatewayAuth(args.authContext, {
|
|
22615
|
+
...asRecord22(args.body),
|
|
22616
|
+
suggestionId: args.suggestionId
|
|
22617
|
+
})
|
|
22618
|
+
});
|
|
22619
|
+
}
|
|
22620
|
+
async function handleGraphAnalysisCompute(args) {
|
|
22621
|
+
return withGraphRoute({
|
|
22622
|
+
...args,
|
|
22623
|
+
fallbackMessage: "Failed to compute graph analysis.",
|
|
22624
|
+
run: () => computeOrRequestGraphAnalysisFromGatewayAuth(
|
|
22625
|
+
args.authContext,
|
|
22626
|
+
asRecord22(args.body)
|
|
22627
|
+
)
|
|
22628
|
+
});
|
|
22629
|
+
}
|
|
22630
|
+
async function handleGraphRecommendationsList(args) {
|
|
22631
|
+
return withGraphRoute({
|
|
22632
|
+
...args,
|
|
22633
|
+
fallbackMessage: "Failed to list graph recommendations.",
|
|
22634
|
+
run: () => listGraphRecommendationsFromGatewayAuth(args.authContext, args.query)
|
|
22635
|
+
});
|
|
22636
|
+
}
|
|
22637
|
+
async function handleGraphRecommendationGet(args) {
|
|
22638
|
+
return withGraphRoute({
|
|
22639
|
+
...args,
|
|
22640
|
+
fallbackMessage: "Failed to fetch graph recommendation.",
|
|
22641
|
+
run: () => getGraphRecommendationFromGatewayAuth(
|
|
22642
|
+
args.authContext,
|
|
22643
|
+
args.recommendationId
|
|
22644
|
+
)
|
|
22645
|
+
});
|
|
22646
|
+
}
|
|
22647
|
+
async function handleGraphRecommendationStatus(args) {
|
|
22648
|
+
return withGraphRoute({
|
|
22649
|
+
...args,
|
|
22650
|
+
fallbackMessage: "Failed to update graph recommendation.",
|
|
22651
|
+
run: () => markGraphRecommendationStatusFromGatewayAuth(args.authContext, {
|
|
22652
|
+
...asRecord22(args.body),
|
|
22653
|
+
recommendationId: args.recommendationId
|
|
22654
|
+
})
|
|
22655
|
+
});
|
|
22656
|
+
}
|
|
22657
|
+
async function handleOrgGraphSearch(args) {
|
|
22658
|
+
return withGraphRoute({
|
|
22659
|
+
...args,
|
|
22660
|
+
fallbackMessage: "Failed to search organization graph.",
|
|
22661
|
+
run: () => searchOrgGraphFromGatewayAuth(args.authContext, asRecord22(args.body))
|
|
22662
|
+
});
|
|
22663
|
+
}
|
|
22664
|
+
async function handleOrgGraphNodeGet(args) {
|
|
22665
|
+
return withGraphRoute({
|
|
22666
|
+
...args,
|
|
22667
|
+
fallbackMessage: "Failed to fetch organization graph node.",
|
|
22668
|
+
run: () => getOrgGraphNodeFromGatewayAuth(args.authContext, {
|
|
22669
|
+
...args.query,
|
|
22670
|
+
nodeId: args.nodeId
|
|
22671
|
+
})
|
|
22672
|
+
});
|
|
22673
|
+
}
|
|
22674
|
+
async function handleOrgGraphByProvenance(args) {
|
|
22675
|
+
return withGraphRoute({
|
|
22676
|
+
...args,
|
|
22677
|
+
fallbackMessage: "Failed to list organization graph by provenance.",
|
|
22678
|
+
run: () => listOrgGraphByProvenanceFromGatewayAuth(args.authContext, args.query)
|
|
22679
|
+
});
|
|
22680
|
+
}
|
|
22681
|
+
async function handleOrgGraphPublished(args) {
|
|
22682
|
+
return withGraphRoute({
|
|
22683
|
+
...args,
|
|
22684
|
+
fallbackMessage: "Failed to list published organization graph nodes.",
|
|
22685
|
+
run: () => listPublishedOrgGraphFromGatewayAuth(args.authContext, args.query)
|
|
22686
|
+
});
|
|
22687
|
+
}
|
|
22688
|
+
|
|
20598
22689
|
// ../../apps/gateway/src/routes/identity.ts
|
|
20599
22690
|
async function handleIdentityWhoami(args) {
|
|
20600
22691
|
try {
|
|
@@ -20622,7 +22713,7 @@ async function handleIdentityWhoami(args) {
|
|
|
20622
22713
|
}
|
|
20623
22714
|
|
|
20624
22715
|
// ../../apps/gateway/src/routes/ontologies.ts
|
|
20625
|
-
function
|
|
22716
|
+
function asRecord23(value) {
|
|
20626
22717
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
20627
22718
|
}
|
|
20628
22719
|
function readString26(value) {
|
|
@@ -20682,7 +22773,7 @@ async function handleOntologyGet(args) {
|
|
|
20682
22773
|
}
|
|
20683
22774
|
async function handleOntologyBind(args) {
|
|
20684
22775
|
try {
|
|
20685
|
-
const body =
|
|
22776
|
+
const body = asRecord23(args.body);
|
|
20686
22777
|
const payload = await bindOntologyFromGatewayAuth(args.authContext, {
|
|
20687
22778
|
ontologyId: args.ontologyId,
|
|
20688
22779
|
topicId: readString26(body.topicId) ?? ""
|
|
@@ -20702,7 +22793,7 @@ async function handleOntologyBind(args) {
|
|
|
20702
22793
|
}
|
|
20703
22794
|
async function handleOntologyMatch(args) {
|
|
20704
22795
|
try {
|
|
20705
|
-
const body =
|
|
22796
|
+
const body = asRecord23(args.body);
|
|
20706
22797
|
const payload = await matchOntologyFromGatewayAuth(args.authContext, {
|
|
20707
22798
|
text: readString26(body.text) ?? "",
|
|
20708
22799
|
topicId: readString26(body.topicId),
|
|
@@ -20725,7 +22816,7 @@ async function handleOntologyMatch(args) {
|
|
|
20725
22816
|
}
|
|
20726
22817
|
|
|
20727
22818
|
// ../../apps/gateway/src/routes/questions.ts
|
|
20728
|
-
function
|
|
22819
|
+
function asRecord24(value) {
|
|
20729
22820
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
20730
22821
|
}
|
|
20731
22822
|
function readString27(value) {
|
|
@@ -20747,13 +22838,13 @@ function readStringArray13(value) {
|
|
|
20747
22838
|
}
|
|
20748
22839
|
async function handleQuestionCreate(args) {
|
|
20749
22840
|
try {
|
|
20750
|
-
const body =
|
|
22841
|
+
const body = asRecord24(args.body);
|
|
20751
22842
|
const payload = await createQuestionFromGatewayAuth(args.authContext, {
|
|
20752
22843
|
topicId: readString27(body.topicId),
|
|
20753
22844
|
text: readString27(body.text) ?? "",
|
|
20754
22845
|
priority: readString27(body.priority),
|
|
20755
22846
|
linkedBeliefId: readString27(body.linkedBeliefId),
|
|
20756
|
-
metadata:
|
|
22847
|
+
metadata: asRecord24(body.metadata)
|
|
20757
22848
|
});
|
|
20758
22849
|
return successResponse(payload, {
|
|
20759
22850
|
status: 201,
|
|
@@ -20800,7 +22891,7 @@ async function handleQuestionGet(args) {
|
|
|
20800
22891
|
}
|
|
20801
22892
|
async function handleQuestionArchive(args) {
|
|
20802
22893
|
try {
|
|
20803
|
-
const body =
|
|
22894
|
+
const body = asRecord24(args.body);
|
|
20804
22895
|
const payload = await archiveQuestionFromGatewayAuth(args.authContext, {
|
|
20805
22896
|
id: args.questionId,
|
|
20806
22897
|
rationale: readString27(body.reason) ?? readString27(body.rationale)
|
|
@@ -20846,7 +22937,7 @@ async function handleQuestionList(args) {
|
|
|
20846
22937
|
}
|
|
20847
22938
|
async function handleQuestionAnswer(args) {
|
|
20848
22939
|
try {
|
|
20849
|
-
const body =
|
|
22940
|
+
const body = asRecord24(args.body);
|
|
20850
22941
|
const payload = await answerQuestionFromGatewayAuth(args.authContext, {
|
|
20851
22942
|
id: args.questionId,
|
|
20852
22943
|
text: readString27(body.text) ?? "",
|
|
@@ -20898,7 +22989,7 @@ async function handleQuestionGetAnswer(args) {
|
|
|
20898
22989
|
}
|
|
20899
22990
|
async function handleQuestionRefine(args) {
|
|
20900
22991
|
try {
|
|
20901
|
-
const body =
|
|
22992
|
+
const body = asRecord24(args.body);
|
|
20902
22993
|
const payload = await refineQuestionFromGatewayAuth(args.authContext, {
|
|
20903
22994
|
id: args.questionId,
|
|
20904
22995
|
text: readString27(body.text) ?? "",
|
|
@@ -20924,7 +23015,7 @@ async function handleQuestionRefine(args) {
|
|
|
20924
23015
|
}
|
|
20925
23016
|
async function handleQuestionUpdateStatus(args) {
|
|
20926
23017
|
try {
|
|
20927
|
-
const body =
|
|
23018
|
+
const body = asRecord24(args.body);
|
|
20928
23019
|
const payload = await updateQuestionStatusFromGatewayAuth(args.authContext, {
|
|
20929
23020
|
id: args.questionId,
|
|
20930
23021
|
status: readString27(body.status) ?? "",
|
|
@@ -20953,8 +23044,8 @@ async function handleQuestionUpdateStatus(args) {
|
|
|
20953
23044
|
}
|
|
20954
23045
|
async function handleQuestionBatchCreate(args) {
|
|
20955
23046
|
try {
|
|
20956
|
-
const body =
|
|
20957
|
-
const questions = Array.isArray(body.questions) ? body.questions.map((entry) =>
|
|
23047
|
+
const body = asRecord24(args.body);
|
|
23048
|
+
const questions = Array.isArray(body.questions) ? body.questions.map((entry) => asRecord24(entry)).map((entry) => ({
|
|
20958
23049
|
question: readString27(entry.question) ?? readString27(entry.text) ?? "",
|
|
20959
23050
|
category: readString27(entry.category),
|
|
20960
23051
|
priority: readString27(entry.priority),
|
|
@@ -20991,7 +23082,7 @@ async function handleQuestionBatchCreate(args) {
|
|
|
20991
23082
|
}
|
|
20992
23083
|
async function handleQuestionAdd(args) {
|
|
20993
23084
|
try {
|
|
20994
|
-
const body =
|
|
23085
|
+
const body = asRecord24(args.body);
|
|
20995
23086
|
const payload = await addQuestionFromGatewayAuth(args.authContext, {
|
|
20996
23087
|
topicId: readString27(body.topicId),
|
|
20997
23088
|
question: readString27(body.question) ?? readString27(body.text),
|
|
@@ -21003,7 +23094,7 @@ async function handleQuestionAdd(args) {
|
|
|
21003
23094
|
chatId: readString27(body.chatId),
|
|
21004
23095
|
importance: readNumber18(body.importance),
|
|
21005
23096
|
epistemicUnlock: readString27(body.epistemicUnlock),
|
|
21006
|
-
metadata:
|
|
23097
|
+
metadata: asRecord24(body.metadata),
|
|
21007
23098
|
questionType: readString27(body.questionType)
|
|
21008
23099
|
});
|
|
21009
23100
|
return successResponse(payload, {
|
|
@@ -21027,7 +23118,7 @@ async function handleQuestionAdd(args) {
|
|
|
21027
23118
|
}
|
|
21028
23119
|
async function handleQuestionUpdatePriority(args) {
|
|
21029
23120
|
try {
|
|
21030
|
-
const body =
|
|
23121
|
+
const body = asRecord24(args.body);
|
|
21031
23122
|
const payload = await updateQuestionPriorityFromGatewayAuth(
|
|
21032
23123
|
args.authContext,
|
|
21033
23124
|
{
|
|
@@ -21058,7 +23149,7 @@ async function handleQuestionUpdatePriority(args) {
|
|
|
21058
23149
|
}
|
|
21059
23150
|
async function handleQuestionAdvanceToConviction(args) {
|
|
21060
23151
|
try {
|
|
21061
|
-
const body =
|
|
23152
|
+
const body = asRecord24(args.body);
|
|
21062
23153
|
const payload = await advanceQuestionToConvictionFromGatewayAuth(
|
|
21063
23154
|
args.authContext,
|
|
21064
23155
|
{
|
|
@@ -21089,7 +23180,7 @@ async function handleQuestionAdvanceToConviction(args) {
|
|
|
21089
23180
|
}
|
|
21090
23181
|
async function handleQuestionUpdateConviction(args) {
|
|
21091
23182
|
try {
|
|
21092
|
-
const body =
|
|
23183
|
+
const body = asRecord24(args.body);
|
|
21093
23184
|
const payload = await updateQuestionConvictionFromGatewayAuth(
|
|
21094
23185
|
args.authContext,
|
|
21095
23186
|
{
|
|
@@ -21122,7 +23213,7 @@ async function handleQuestionUpdateConviction(args) {
|
|
|
21122
23213
|
}
|
|
21123
23214
|
async function handleQuestionFinalizeConviction(args) {
|
|
21124
23215
|
try {
|
|
21125
|
-
const body =
|
|
23216
|
+
const body = asRecord24(args.body);
|
|
21126
23217
|
const payload = await finalizeQuestionConvictionFromGatewayAuth(
|
|
21127
23218
|
args.authContext,
|
|
21128
23219
|
{
|
|
@@ -21157,7 +23248,7 @@ async function handleQuestionFinalizeConviction(args) {
|
|
|
21157
23248
|
}
|
|
21158
23249
|
async function handleQuestionUpdate(args) {
|
|
21159
23250
|
try {
|
|
21160
|
-
const body =
|
|
23251
|
+
const body = asRecord24(args.body);
|
|
21161
23252
|
const payload = await updateQuestionFromGatewayAuth(args.authContext, {
|
|
21162
23253
|
questionId: readString27(body.questionId) ?? readString27(body.id) ?? readString27(body.nodeId),
|
|
21163
23254
|
question: readString27(body.question) ?? readString27(body.text),
|
|
@@ -21184,7 +23275,7 @@ async function handleQuestionUpdate(args) {
|
|
|
21184
23275
|
}
|
|
21185
23276
|
async function handleQuestionDelete(args) {
|
|
21186
23277
|
try {
|
|
21187
|
-
const body =
|
|
23278
|
+
const body = asRecord24(args.body);
|
|
21188
23279
|
const payload = await deleteQuestionFromGatewayAuth(args.authContext, {
|
|
21189
23280
|
questionId: readString27(body.questionId) ?? readString27(body.id) ?? readString27(body.nodeId)
|
|
21190
23281
|
});
|
|
@@ -21208,7 +23299,7 @@ async function handleQuestionDelete(args) {
|
|
|
21208
23299
|
}
|
|
21209
23300
|
|
|
21210
23301
|
// ../../apps/gateway/src/routes/search.ts
|
|
21211
|
-
function
|
|
23302
|
+
function asRecord25(value) {
|
|
21212
23303
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21213
23304
|
}
|
|
21214
23305
|
function readString28(value) {
|
|
@@ -21229,7 +23320,7 @@ function readStringArray14(value) {
|
|
|
21229
23320
|
return items.length > 0 ? items : void 0;
|
|
21230
23321
|
}
|
|
21231
23322
|
async function handleSearchResources(args) {
|
|
21232
|
-
const body =
|
|
23323
|
+
const body = asRecord25(args.body);
|
|
21233
23324
|
const q = readString28(body.q) ?? readString28(body.query);
|
|
21234
23325
|
const topicId = readString28(body.topicId) ?? readString28(body.projectId);
|
|
21235
23326
|
if (!q) {
|
|
@@ -21280,7 +23371,7 @@ async function handleSearchResources(args) {
|
|
|
21280
23371
|
}
|
|
21281
23372
|
|
|
21282
23373
|
// ../../apps/gateway/src/routes/sources.ts
|
|
21283
|
-
function
|
|
23374
|
+
function asRecord26(value) {
|
|
21284
23375
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21285
23376
|
}
|
|
21286
23377
|
function readString29(value) {
|
|
@@ -21308,7 +23399,7 @@ function handleSourcesError(error, fallbackMessage, correlationId, policyTraceId
|
|
|
21308
23399
|
}
|
|
21309
23400
|
async function handleSourceUpsert(args) {
|
|
21310
23401
|
try {
|
|
21311
|
-
const body =
|
|
23402
|
+
const body = asRecord26(args.body);
|
|
21312
23403
|
const payload = await upsertSourceFromGatewayAuth(args.authContext, {
|
|
21313
23404
|
url: readString29(body.url),
|
|
21314
23405
|
sha: readString29(body.sha),
|
|
@@ -21316,7 +23407,7 @@ async function handleSourceUpsert(args) {
|
|
|
21316
23407
|
title: readString29(body.title),
|
|
21317
23408
|
capturedAt: readNumber20(body.capturedAt),
|
|
21318
23409
|
topicId: readString29(body.topicId),
|
|
21319
|
-
metadata:
|
|
23410
|
+
metadata: asRecord26(body.metadata)
|
|
21320
23411
|
});
|
|
21321
23412
|
return successResponse(payload, {
|
|
21322
23413
|
status: 201,
|
|
@@ -21350,7 +23441,7 @@ async function handleSourceGet(args) {
|
|
|
21350
23441
|
}
|
|
21351
23442
|
|
|
21352
23443
|
// ../../apps/gateway/src/routes/tasks.ts
|
|
21353
|
-
function
|
|
23444
|
+
function asRecord27(value) {
|
|
21354
23445
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21355
23446
|
}
|
|
21356
23447
|
function readString30(value) {
|
|
@@ -21375,7 +23466,7 @@ function handleTasksError(error, fallbackMessage, correlationId, policyTraceId)
|
|
|
21375
23466
|
}
|
|
21376
23467
|
async function handleTaskCreate(args) {
|
|
21377
23468
|
try {
|
|
21378
|
-
const body =
|
|
23469
|
+
const body = asRecord27(args.body);
|
|
21379
23470
|
const payload = await createTaskFromGatewayAuth(args.authContext, {
|
|
21380
23471
|
topicId: readString30(body.topicId),
|
|
21381
23472
|
title: readString30(body.title) ?? "",
|
|
@@ -21419,7 +23510,7 @@ async function handleTaskList(args) {
|
|
|
21419
23510
|
}
|
|
21420
23511
|
async function handleTaskUpdate(args) {
|
|
21421
23512
|
try {
|
|
21422
|
-
const body =
|
|
23513
|
+
const body = asRecord27(args.body);
|
|
21423
23514
|
const payload = await updateTaskFromGatewayAuth(args.authContext, {
|
|
21424
23515
|
id: args.taskId,
|
|
21425
23516
|
title: readString30(body.title),
|
|
@@ -21446,7 +23537,7 @@ async function handleTaskUpdate(args) {
|
|
|
21446
23537
|
}
|
|
21447
23538
|
async function handleTaskComplete(args) {
|
|
21448
23539
|
try {
|
|
21449
|
-
const body =
|
|
23540
|
+
const body = asRecord27(args.body);
|
|
21450
23541
|
const payload = await completeTaskFromGatewayAuth(args.authContext, {
|
|
21451
23542
|
id: args.taskId,
|
|
21452
23543
|
outputSummary: readString30(body.outputSummary)
|
|
@@ -21466,7 +23557,7 @@ async function handleTaskComplete(args) {
|
|
|
21466
23557
|
}
|
|
21467
23558
|
|
|
21468
23559
|
// ../../apps/gateway/src/routes/topics.ts
|
|
21469
|
-
function
|
|
23560
|
+
function asRecord28(value) {
|
|
21470
23561
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21471
23562
|
}
|
|
21472
23563
|
function readString31(value) {
|
|
@@ -21504,7 +23595,7 @@ function handleTopicsError(error, fallbackMessage, correlationId, policyTraceId)
|
|
|
21504
23595
|
}
|
|
21505
23596
|
async function handleTopicCreate(args) {
|
|
21506
23597
|
try {
|
|
21507
|
-
const body =
|
|
23598
|
+
const body = asRecord28(args.body);
|
|
21508
23599
|
const payload = await createTopicFromGatewayAuth(args.authContext, {
|
|
21509
23600
|
name: readString31(body.name) ?? "",
|
|
21510
23601
|
description: readString31(body.description),
|
|
@@ -21532,7 +23623,7 @@ async function handleTopicCreate(args) {
|
|
|
21532
23623
|
}
|
|
21533
23624
|
async function handleTopicUpdate(args) {
|
|
21534
23625
|
try {
|
|
21535
|
-
const body =
|
|
23626
|
+
const body = asRecord28(args.body);
|
|
21536
23627
|
const payload = await updateTopicFromGatewayAuth(args.authContext, {
|
|
21537
23628
|
id: args.topicId,
|
|
21538
23629
|
name: readString31(body.name),
|
|
@@ -21629,7 +23720,7 @@ async function handleTopicCoverage(args) {
|
|
|
21629
23720
|
}
|
|
21630
23721
|
async function handleTopicRemove(args) {
|
|
21631
23722
|
try {
|
|
21632
|
-
const body =
|
|
23723
|
+
const body = asRecord28(args.body);
|
|
21633
23724
|
const payload = await removeTopicFromGatewayAuth(args.authContext, {
|
|
21634
23725
|
id: readString31(body.id) ?? readString31(body.topicId) ?? ""
|
|
21635
23726
|
});
|
|
@@ -21648,8 +23739,8 @@ async function handleTopicRemove(args) {
|
|
|
21648
23739
|
}
|
|
21649
23740
|
async function handleTopicBulkCreate(args) {
|
|
21650
23741
|
try {
|
|
21651
|
-
const body =
|
|
21652
|
-
const topics2 = Array.isArray(body.topics) ? body.topics.map((entry) =>
|
|
23742
|
+
const body = asRecord28(args.body);
|
|
23743
|
+
const topics2 = Array.isArray(body.topics) ? body.topics.map((entry) => asRecord28(entry)).map((entry) => ({
|
|
21653
23744
|
globalId: readString31(entry.globalId) ?? "",
|
|
21654
23745
|
name: readString31(entry.name) ?? "",
|
|
21655
23746
|
description: readString31(entry.description),
|
|
@@ -21662,7 +23753,7 @@ async function handleTopicBulkCreate(args) {
|
|
|
21662
23753
|
graphScopeProjectId: readString31(entry.graphScopeProjectId),
|
|
21663
23754
|
status: readString31(entry.status) ?? "active",
|
|
21664
23755
|
visibility: readString31(entry.visibility),
|
|
21665
|
-
metadata:
|
|
23756
|
+
metadata: asRecord28(entry.metadata),
|
|
21666
23757
|
createdBy: readString31(entry.createdBy)
|
|
21667
23758
|
})) : [];
|
|
21668
23759
|
const payload = await bulkCreateTopicsFromGatewayAuth(args.authContext, {
|
|
@@ -21684,7 +23775,7 @@ async function handleTopicBulkCreate(args) {
|
|
|
21684
23775
|
}
|
|
21685
23776
|
|
|
21686
23777
|
// ../../apps/gateway/src/routes/webhooks.ts
|
|
21687
|
-
function
|
|
23778
|
+
function asRecord29(value) {
|
|
21688
23779
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21689
23780
|
}
|
|
21690
23781
|
function readString32(value) {
|
|
@@ -21719,7 +23810,7 @@ function handleWebhooksError(error, fallbackMessage, correlationId, policyTraceI
|
|
|
21719
23810
|
}
|
|
21720
23811
|
async function handleWebhookCreate(args) {
|
|
21721
23812
|
try {
|
|
21722
|
-
const body =
|
|
23813
|
+
const body = asRecord29(args.body);
|
|
21723
23814
|
const payload = await args.authContext.convex.mutation(
|
|
21724
23815
|
"events:createWebhook",
|
|
21725
23816
|
{
|
|
@@ -21789,7 +23880,7 @@ async function handleWebhookGet(args) {
|
|
|
21789
23880
|
}
|
|
21790
23881
|
async function handleWebhookUpdate(args) {
|
|
21791
23882
|
try {
|
|
21792
|
-
const body =
|
|
23883
|
+
const body = asRecord29(args.body);
|
|
21793
23884
|
const payload = await args.authContext.convex.mutation(
|
|
21794
23885
|
"events:updateWebhook",
|
|
21795
23886
|
{
|
|
@@ -21843,7 +23934,7 @@ async function handleWebhookDelete(args) {
|
|
|
21843
23934
|
}
|
|
21844
23935
|
async function handleWebhookTest(args) {
|
|
21845
23936
|
try {
|
|
21846
|
-
const body =
|
|
23937
|
+
const body = asRecord29(args.body);
|
|
21847
23938
|
const payload = await args.authContext.convex.action("events:testWebhook", {
|
|
21848
23939
|
webhookId: args.webhookId,
|
|
21849
23940
|
tenantId: args.authContext.tenantId,
|
|
@@ -21918,7 +24009,7 @@ async function handleWebhookHealth(args) {
|
|
|
21918
24009
|
}
|
|
21919
24010
|
|
|
21920
24011
|
// ../../apps/gateway/src/routes/worktrees.ts
|
|
21921
|
-
function
|
|
24012
|
+
function asRecord30(value) {
|
|
21922
24013
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
21923
24014
|
}
|
|
21924
24015
|
function readString33(value) {
|
|
@@ -21938,6 +24029,36 @@ function readStringArray17(value) {
|
|
|
21938
24029
|
const normalized = value.map((entry) => readString33(entry)).filter((entry) => Boolean(entry));
|
|
21939
24030
|
return normalized.length > 0 ? normalized : void 0;
|
|
21940
24031
|
}
|
|
24032
|
+
function readObjectArray(value) {
|
|
24033
|
+
if (!Array.isArray(value)) {
|
|
24034
|
+
return void 0;
|
|
24035
|
+
}
|
|
24036
|
+
const normalized = value.map((entry) => asRecord30(entry)).filter((entry) => Object.keys(entry).length > 0);
|
|
24037
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
24038
|
+
}
|
|
24039
|
+
function readConfidenceImpact(value) {
|
|
24040
|
+
return value === "high" || value === "medium" || value === "low" ? value : void 0;
|
|
24041
|
+
}
|
|
24042
|
+
function normalizeMergeOutcomes2(value) {
|
|
24043
|
+
if (!Array.isArray(value)) {
|
|
24044
|
+
return [];
|
|
24045
|
+
}
|
|
24046
|
+
return value.map((entry) => {
|
|
24047
|
+
const finding = readString33(entry);
|
|
24048
|
+
if (finding) {
|
|
24049
|
+
return finding;
|
|
24050
|
+
}
|
|
24051
|
+
const row = asRecord30(entry);
|
|
24052
|
+
if (!Object.keys(row).length) {
|
|
24053
|
+
return null;
|
|
24054
|
+
}
|
|
24055
|
+
return {
|
|
24056
|
+
beliefId: readString33(row.beliefId) ?? "",
|
|
24057
|
+
confidence: readNumber22(row.confidence) ?? Number.NaN,
|
|
24058
|
+
rationale: readString33(row.rationale) ?? ""
|
|
24059
|
+
};
|
|
24060
|
+
}).filter((entry) => entry !== null);
|
|
24061
|
+
}
|
|
21941
24062
|
function handleWorktreesError(error, fallbackMessage, correlationId, policyTraceId) {
|
|
21942
24063
|
const resolved = resolveServerCoreError(error, fallbackMessage);
|
|
21943
24064
|
return errorResponse({
|
|
@@ -21953,13 +24074,30 @@ function handleWorktreesError(error, fallbackMessage, correlationId, policyTrace
|
|
|
21953
24074
|
}
|
|
21954
24075
|
async function handleWorktreeCreate(args) {
|
|
21955
24076
|
try {
|
|
21956
|
-
const body =
|
|
24077
|
+
const body = asRecord30(args.body);
|
|
24078
|
+
const goCriteria = readStringArray17(body.goCriteria);
|
|
24079
|
+
const noGoSignals = readStringArray17(body.noGoSignals);
|
|
21957
24080
|
const payload = await createWorktreeFromGatewayAuth(args.authContext, {
|
|
21958
|
-
title: readString33(body.title) ?? "",
|
|
24081
|
+
title: readString33(body.title) ?? readString33(body.name) ?? "",
|
|
21959
24082
|
topicId: readString33(body.topicId ?? body.projectId) ?? "",
|
|
21960
24083
|
objective: readString33(body.objective),
|
|
21961
24084
|
hypothesis: readString33(body.hypothesis),
|
|
21962
|
-
|
|
24085
|
+
rationale: readString33(body.rationale),
|
|
24086
|
+
worktreeType: readString33(body.worktreeType),
|
|
24087
|
+
startDate: readNumber22(body.startDate),
|
|
24088
|
+
endDate: readNumber22(body.endDate),
|
|
24089
|
+
durationWeeks: readNumber22(body.durationWeeks),
|
|
24090
|
+
confidenceImpact: readConfidenceImpact(body.confidenceImpact),
|
|
24091
|
+
beliefFocus: readString33(body.beliefFocus),
|
|
24092
|
+
beliefIds: readStringArray17(body.targetBeliefIds) ?? readStringArray17(body.beliefIds) ?? readStringArray17(body.beliefs),
|
|
24093
|
+
targetBeliefIds: readStringArray17(body.targetBeliefIds),
|
|
24094
|
+
targetQuestionIds: readStringArray17(body.targetQuestionIds),
|
|
24095
|
+
keyQuestions: readObjectArray(body.keyQuestions),
|
|
24096
|
+
evidenceSignals: readObjectArray(body.evidenceSignals),
|
|
24097
|
+
decisionGate: body.decisionGate && typeof body.decisionGate === "object" && !Array.isArray(body.decisionGate) ? body.decisionGate : goCriteria || noGoSignals ? {
|
|
24098
|
+
goCriteria: goCriteria ?? [],
|
|
24099
|
+
noGoSignals: noGoSignals ?? []
|
|
24100
|
+
} : void 0,
|
|
21963
24101
|
autoShape: typeof body.autoShape === "boolean" ? body.autoShape : void 0,
|
|
21964
24102
|
domainPackId: readString33(body.domainPackId),
|
|
21965
24103
|
campaign: readNumber22(body.campaign),
|
|
@@ -22074,7 +24212,7 @@ async function handleWorktreeActivate(args) {
|
|
|
22074
24212
|
}
|
|
22075
24213
|
async function handleWorktreeUpdate(args) {
|
|
22076
24214
|
try {
|
|
22077
|
-
const body =
|
|
24215
|
+
const body = asRecord30(args.body);
|
|
22078
24216
|
const payload = await updateWorktreeFromGatewayAuth(args.authContext, {
|
|
22079
24217
|
id: args.worktreeId,
|
|
22080
24218
|
objective: readString33(body.objective),
|
|
@@ -22111,13 +24249,8 @@ async function handleWorktreeUpdate(args) {
|
|
|
22111
24249
|
}
|
|
22112
24250
|
async function handleWorktreeMerge(args) {
|
|
22113
24251
|
try {
|
|
22114
|
-
const body =
|
|
22115
|
-
const
|
|
22116
|
-
const outcomes = rawOutcomes.map((entry) => asRecord28(entry)).map((entry) => ({
|
|
22117
|
-
beliefId: readString33(entry.beliefId) ?? "",
|
|
22118
|
-
confidence: readNumber22(entry.confidence) ?? Number.NaN,
|
|
22119
|
-
rationale: readString33(entry.rationale) ?? ""
|
|
22120
|
-
}));
|
|
24252
|
+
const body = asRecord30(args.body);
|
|
24253
|
+
const outcomes = normalizeMergeOutcomes2(body.outcomes);
|
|
22121
24254
|
const payload = await mergeWorktreeFromGatewayAuth(args.authContext, {
|
|
22122
24255
|
id: args.worktreeId,
|
|
22123
24256
|
summary: readString33(body.summary),
|
|
@@ -22138,7 +24271,7 @@ async function handleWorktreeMerge(args) {
|
|
|
22138
24271
|
}
|
|
22139
24272
|
async function handleWorktreeUpdateTargets(args) {
|
|
22140
24273
|
try {
|
|
22141
|
-
const body =
|
|
24274
|
+
const body = asRecord30(args.body);
|
|
22142
24275
|
const payload = await updateWorktreeTargetsFromGatewayAuth(
|
|
22143
24276
|
args.authContext,
|
|
22144
24277
|
{
|
|
@@ -22164,7 +24297,7 @@ async function handleWorktreeUpdateTargets(args) {
|
|
|
22164
24297
|
}
|
|
22165
24298
|
async function handleWorktreeComplete(args) {
|
|
22166
24299
|
try {
|
|
22167
|
-
const body =
|
|
24300
|
+
const body = asRecord30(args.body);
|
|
22168
24301
|
const payload = await completeWorktreeRecordFromGatewayAuth(
|
|
22169
24302
|
args.authContext,
|
|
22170
24303
|
{
|
|
@@ -22189,7 +24322,7 @@ async function handleWorktreeComplete(args) {
|
|
|
22189
24322
|
}
|
|
22190
24323
|
async function handleWorktreeAdvancePhase(args) {
|
|
22191
24324
|
try {
|
|
22192
|
-
const body =
|
|
24325
|
+
const body = asRecord30(args.body);
|
|
22193
24326
|
const payload = await advanceWorktreePhaseFromGatewayAuth(args.authContext, {
|
|
22194
24327
|
worktreeId: readString33(body.worktreeId) ?? ""
|
|
22195
24328
|
});
|
|
@@ -22208,7 +24341,7 @@ async function handleWorktreeAdvancePhase(args) {
|
|
|
22208
24341
|
}
|
|
22209
24342
|
async function handleWorktreeSetPhase(args) {
|
|
22210
24343
|
try {
|
|
22211
|
-
const body =
|
|
24344
|
+
const body = asRecord30(args.body);
|
|
22212
24345
|
const payload = await setWorktreePhaseFromGatewayAuth(args.authContext, {
|
|
22213
24346
|
worktreeId: readString33(body.worktreeId) ?? "",
|
|
22214
24347
|
phase: readString33(body.phase) ?? ""
|
|
@@ -22228,12 +24361,12 @@ async function handleWorktreeSetPhase(args) {
|
|
|
22228
24361
|
}
|
|
22229
24362
|
async function handleWorktreePatchState(args) {
|
|
22230
24363
|
try {
|
|
22231
|
-
const body =
|
|
24364
|
+
const body = asRecord30(args.body);
|
|
22232
24365
|
const payload = await patchWorktreeStateFromGatewayAuth(
|
|
22233
24366
|
args.authContext,
|
|
22234
24367
|
{
|
|
22235
24368
|
worktreeId: readString33(body.worktreeId) ?? "",
|
|
22236
|
-
patch:
|
|
24369
|
+
patch: asRecord30(body.patch)
|
|
22237
24370
|
}
|
|
22238
24371
|
);
|
|
22239
24372
|
return successResponse(payload, {
|
|
@@ -22251,7 +24384,7 @@ async function handleWorktreePatchState(args) {
|
|
|
22251
24384
|
}
|
|
22252
24385
|
async function handleWorktreeBulkCreate(args) {
|
|
22253
24386
|
try {
|
|
22254
|
-
const body =
|
|
24387
|
+
const body = asRecord30(args.body);
|
|
22255
24388
|
const payload = await bulkCreateWorktreesFromGatewayAuth(args.authContext, {
|
|
22256
24389
|
worktrees: Array.isArray(body.worktrees) ? body.worktrees : []
|
|
22257
24390
|
});
|
|
@@ -22270,6 +24403,6 @@ async function handleWorktreeBulkCreate(args) {
|
|
|
22270
24403
|
}
|
|
22271
24404
|
}
|
|
22272
24405
|
|
|
22273
|
-
export { handleBeliefArchive, handleBeliefBatchUpdateCriticality, handleBeliefBisect, handleBeliefConfidenceHistory, handleBeliefCreate, handleBeliefCreateContract, handleBeliefFork, handleBeliefGet, handleBeliefLineage, handleBeliefLink, handleBeliefList, handleBeliefReassignTopic, handleBeliefRefine, handleBeliefRelationships, handleBeliefUnlinkEvidence, handleBeliefUpdateConfidence, handleBeliefUpdateCriticality, handleBeliefUpdateRationale, handleBeliefUpdateStatus, handleContradictionFlag, handleContradictionGet, handleContradictionList, handleEdgeBatchCreate, handleEdgeCreate, handleEdgeDelete, handleEdgeList, handleEdgeRemove, handleEdgeTraverse, handleEdgeUpdate, handleEdgesRemoveBetween, handleEventsList, handleEventsReplay, handleEvidenceClassify, handleEvidenceClassifyBatch, handleEvidenceCreate, handleEvidenceFlagIncorrect, handleEvidenceGet, handleEvidenceLink, handleEvidenceList, handleEvidenceRemove, handleEvidenceSearch, handleEvidenceUpdate, handleEvidenceUpdateStatus, handleEvidenceUpdateVerificationStatus, handleGraphAnalyze, handleGraphBias, handleGraphFalsify, handleGraphGaps, handleGraphNeighborhood, handleGraphTraverse, handleIdentityWhoami, handleOntologyBind, handleOntologyGet, handleOntologyList, handleOntologyMatch, handleQuestionAdd, handleQuestionAdvanceToConviction, handleQuestionAnswer, handleQuestionArchive, handleQuestionBatchCreate, handleQuestionCreate, handleQuestionDelete, handleQuestionFinalizeConviction, handleQuestionGet, handleQuestionGetAnswer, handleQuestionList, handleQuestionRefine, handleQuestionUpdate, handleQuestionUpdateConviction, handleQuestionUpdatePriority, handleQuestionUpdateStatus, handleSearchResources, handleSourceGet, handleSourceUpsert, handleTaskComplete, handleTaskCreate, handleTaskList, handleTaskUpdate, handleTopicBulkCreate, handleTopicCoverage, handleTopicCreate, handleTopicGet, handleTopicList, handleTopicRemove, handleTopicTree, handleTopicUpdate, handleWebhookCreate, handleWebhookDelete, handleWebhookDeliveries, handleWebhookGet, handleWebhookHealth, handleWebhookList, handleWebhookTest, handleWebhookUpdate, handleWorktreeActivate, handleWorktreeAdvancePhase, handleWorktreeBulkCreate, handleWorktreeComplete, handleWorktreeCreate, handleWorktreeList, handleWorktreeListAll, handleWorktreeListCampaigns, handleWorktreeMerge, handleWorktreePatchState, handleWorktreeSetPhase, handleWorktreeUpdate, handleWorktreeUpdateTargets };
|
|
24406
|
+
export { handleBeliefArchive, handleBeliefBatchUpdateCriticality, handleBeliefBisect, handleBeliefConfidenceHistory, handleBeliefCreate, handleBeliefCreateContract, handleBeliefFork, handleBeliefGet, handleBeliefLineage, handleBeliefLink, handleBeliefList, handleBeliefReassignTopic, handleBeliefRefine, handleBeliefRelationships, handleBeliefUnlinkEvidence, handleBeliefUpdateConfidence, handleBeliefUpdateCriticality, handleBeliefUpdateRationale, handleBeliefUpdateStatus, handleContradictionFlag, handleContradictionGet, handleContradictionList, handleEdgeBatchCreate, handleEdgeCreate, handleEdgeDelete, handleEdgeList, handleEdgeRemove, handleEdgeTraverse, handleEdgeUpdate, handleEdgesRemoveBetween, handleEventsList, handleEventsReplay, handleEvidenceClassify, handleEvidenceClassifyBatch, handleEvidenceCreate, handleEvidenceFlagIncorrect, handleEvidenceGet, handleEvidenceLink, handleEvidenceList, handleEvidenceRemove, handleEvidenceSearch, handleEvidenceUpdate, handleEvidenceUpdateStatus, handleEvidenceUpdateVerificationStatus, handleGraphAnalysisCompute, handleGraphAnalysisLatest, handleGraphAnalysisList, handleGraphAnalysisListChanges, handleGraphAnalysisListSuggestions, handleGraphAnalysisSave, handleGraphAnalysisSaveSuggestions, handleGraphAnalysisUpdateSuggestion, handleGraphAnalyze, handleGraphBias, handleGraphEdgeList, handleGraphFalsify, handleGraphGaps, handleGraphNeighborhood, handleGraphNodeList, handleGraphRecommendationGet, handleGraphRecommendationStatus, handleGraphRecommendationsList, handleGraphTraverse, handleIdentityWhoami, handleOntologyBind, handleOntologyGet, handleOntologyList, handleOntologyMatch, handleOrgGraphByProvenance, handleOrgGraphNodeGet, handleOrgGraphPublished, handleOrgGraphSearch, handleQuestionAdd, handleQuestionAdvanceToConviction, handleQuestionAnswer, handleQuestionArchive, handleQuestionBatchCreate, handleQuestionCreate, handleQuestionDelete, handleQuestionFinalizeConviction, handleQuestionGet, handleQuestionGetAnswer, handleQuestionList, handleQuestionRefine, handleQuestionUpdate, handleQuestionUpdateConviction, handleQuestionUpdatePriority, handleQuestionUpdateStatus, handleSearchResources, handleSourceGet, handleSourceUpsert, handleTaskComplete, handleTaskCreate, handleTaskList, handleTaskUpdate, handleTopicBulkCreate, handleTopicCoverage, handleTopicCreate, handleTopicGet, handleTopicList, handleTopicRemove, handleTopicTree, handleTopicUpdate, handleWebhookCreate, handleWebhookDelete, handleWebhookDeliveries, handleWebhookGet, handleWebhookHealth, handleWebhookList, handleWebhookTest, handleWebhookUpdate, handleWorktreeActivate, handleWorktreeAdvancePhase, handleWorktreeBulkCreate, handleWorktreeComplete, handleWorktreeCreate, handleWorktreeList, handleWorktreeListAll, handleWorktreeListCampaigns, handleWorktreeMerge, handleWorktreePatchState, handleWorktreeSetPhase, handleWorktreeUpdate, handleWorktreeUpdateTargets };
|
|
22274
24407
|
//# sourceMappingURL=gateway.js.map
|
|
22275
24408
|
//# sourceMappingURL=gateway.js.map
|