@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/runtime.js
CHANGED
|
@@ -3,10 +3,6 @@ import * as path2 from 'path';
|
|
|
3
3
|
import { basename, extname } from 'path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { v } from 'convex/values';
|
|
6
|
-
import { internal, components, api as api$1 } from '@lucern/reasoning-kernel/adapters/convex';
|
|
7
|
-
import 'stream';
|
|
8
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
9
|
-
import { ConvexHttpClient } from 'convex/browser';
|
|
10
6
|
import 'crypto';
|
|
11
7
|
import * as os from 'os';
|
|
12
8
|
|
|
@@ -2054,6 +2050,40 @@ defineTable({
|
|
|
2054
2050
|
{ kind: "index", name: "by_tier_window_end", columns: ["tier", "windowEndMs"] }
|
|
2055
2051
|
]
|
|
2056
2052
|
});
|
|
2053
|
+
defineTable({
|
|
2054
|
+
name: "oauthDeviceCodes",
|
|
2055
|
+
component: "mc",
|
|
2056
|
+
category: "identity",
|
|
2057
|
+
shape: z.object({
|
|
2058
|
+
"deviceCodeHash": z.string(),
|
|
2059
|
+
"userCode": z.string(),
|
|
2060
|
+
"clientId": z.string(),
|
|
2061
|
+
"scope": z.string(),
|
|
2062
|
+
"status": z.enum(["pending", "approved", "denied", "expired", "consumed"]),
|
|
2063
|
+
"expiresAt": z.number(),
|
|
2064
|
+
"intervalSeconds": z.number(),
|
|
2065
|
+
"lastPolledAt": z.number().optional(),
|
|
2066
|
+
"slowDownCount": z.number().optional(),
|
|
2067
|
+
"clerkUserId": z.string().optional(),
|
|
2068
|
+
"tenantId": idOf("tenants").optional(),
|
|
2069
|
+
"workspaceId": z.string().optional(),
|
|
2070
|
+
"principalId": z.string().optional(),
|
|
2071
|
+
"role": z.string().optional(),
|
|
2072
|
+
"scopes": z.array(z.string()).optional(),
|
|
2073
|
+
"sessionId": z.string().optional(),
|
|
2074
|
+
"approvedAt": z.number().optional(),
|
|
2075
|
+
"deniedAt": z.number().optional(),
|
|
2076
|
+
"consumedAt": z.number().optional(),
|
|
2077
|
+
"createdAt": z.number(),
|
|
2078
|
+
"updatedAt": z.number()
|
|
2079
|
+
}),
|
|
2080
|
+
indices: [
|
|
2081
|
+
{ kind: "index", name: "by_deviceCodeHash", columns: ["deviceCodeHash"] },
|
|
2082
|
+
{ kind: "index", name: "by_userCode", columns: ["userCode"] },
|
|
2083
|
+
{ kind: "index", name: "by_status_expiresAt", columns: ["status", "expiresAt"] },
|
|
2084
|
+
{ kind: "index", name: "by_sessionId", columns: ["sessionId"] }
|
|
2085
|
+
]
|
|
2086
|
+
});
|
|
2057
2087
|
defineTable({
|
|
2058
2088
|
name: "servicePrincipalKeys",
|
|
2059
2089
|
component: "mc",
|
|
@@ -4010,7 +4040,9 @@ defineTable({
|
|
|
4010
4040
|
"defaultProjectVisibility": z.enum(["private", "team", "firm", "external", "public"]).optional(),
|
|
4011
4041
|
"deployments": z.record(z.object({
|
|
4012
4042
|
"url": z.string(),
|
|
4013
|
-
"
|
|
4043
|
+
"target": z.enum(["kernelDeployment", "appDeployment"]).optional(),
|
|
4044
|
+
"encryptedDeployKey": z.string().optional(),
|
|
4045
|
+
"credentialRef": z.string().optional()
|
|
4014
4046
|
})).optional(),
|
|
4015
4047
|
"metadata": z.record(z.any()).optional(),
|
|
4016
4048
|
"createdBy": z.string().optional(),
|
|
@@ -5275,6 +5307,14 @@ var ADD_WORKTREE = {
|
|
|
5275
5307
|
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.",
|
|
5276
5308
|
parameters: {
|
|
5277
5309
|
title: { type: "string", description: "Worktree name/objective" },
|
|
5310
|
+
name: {
|
|
5311
|
+
type: "string",
|
|
5312
|
+
description: "Optional storage-name alias for callers that already use backend naming"
|
|
5313
|
+
},
|
|
5314
|
+
projectId: {
|
|
5315
|
+
type: "string",
|
|
5316
|
+
description: "Legacy topicId alias"
|
|
5317
|
+
},
|
|
5278
5318
|
topicId: { type: "string", description: "Optional topic scope hint" },
|
|
5279
5319
|
branchId: {
|
|
5280
5320
|
type: "string",
|
|
@@ -5288,14 +5328,87 @@ var ADD_WORKTREE = {
|
|
|
5288
5328
|
type: "string",
|
|
5289
5329
|
description: "The testable claim this worktree investigates"
|
|
5290
5330
|
},
|
|
5331
|
+
rationale: {
|
|
5332
|
+
type: "string",
|
|
5333
|
+
description: "Why this worktree exists and why it belongs in the campaign"
|
|
5334
|
+
},
|
|
5335
|
+
worktreeType: {
|
|
5336
|
+
type: "string",
|
|
5337
|
+
description: "Schema-enum worktree type used by the kernel lifecycle and retrieval layers"
|
|
5338
|
+
},
|
|
5339
|
+
gate: {
|
|
5340
|
+
type: "string",
|
|
5341
|
+
description: "Exit gate name for this worktree"
|
|
5342
|
+
},
|
|
5343
|
+
startDate: {
|
|
5344
|
+
type: "number",
|
|
5345
|
+
description: "Planned start timestamp in milliseconds since epoch"
|
|
5346
|
+
},
|
|
5347
|
+
endDate: {
|
|
5348
|
+
type: "number",
|
|
5349
|
+
description: "Planned end timestamp in milliseconds since epoch"
|
|
5350
|
+
},
|
|
5351
|
+
durationWeeks: {
|
|
5352
|
+
type: "number",
|
|
5353
|
+
description: "Planned duration in weeks"
|
|
5354
|
+
},
|
|
5355
|
+
confidenceImpact: {
|
|
5356
|
+
type: "string",
|
|
5357
|
+
description: "Expected confidence impact if the worktree succeeds",
|
|
5358
|
+
enum: ["high", "medium", "low"]
|
|
5359
|
+
},
|
|
5360
|
+
beliefFocus: {
|
|
5361
|
+
type: "string",
|
|
5362
|
+
description: "Natural-language focus spanning the target belief neighborhood"
|
|
5363
|
+
},
|
|
5291
5364
|
beliefIds: {
|
|
5292
5365
|
type: "array",
|
|
5293
|
-
description: "
|
|
5366
|
+
description: "Legacy alias for targetBeliefIds"
|
|
5367
|
+
},
|
|
5368
|
+
beliefs: {
|
|
5369
|
+
type: "array",
|
|
5370
|
+
description: "Legacy alias for targetBeliefIds"
|
|
5371
|
+
},
|
|
5372
|
+
targetBeliefIds: {
|
|
5373
|
+
type: "array",
|
|
5374
|
+
description: "Belief node IDs this worktree is expected to test or update"
|
|
5375
|
+
},
|
|
5376
|
+
targetQuestionIds: {
|
|
5377
|
+
type: "array",
|
|
5378
|
+
description: "Question node IDs this worktree is expected to answer"
|
|
5379
|
+
},
|
|
5380
|
+
keyQuestions: {
|
|
5381
|
+
type: "array",
|
|
5382
|
+
description: "Inline key question objects with question, optional status, answer, answerConfidence, and linkedQuestionId"
|
|
5383
|
+
},
|
|
5384
|
+
evidenceSignals: {
|
|
5385
|
+
type: "array",
|
|
5386
|
+
description: "Evidence signal objects with signal, optional collected state, progress, and notes"
|
|
5387
|
+
},
|
|
5388
|
+
decisionGate: {
|
|
5389
|
+
type: "object",
|
|
5390
|
+
description: "Decision gate object with goCriteria, noGoSignals, optional verdict, rationale, decidedAt, and decidedBy"
|
|
5391
|
+
},
|
|
5392
|
+
goCriteria: {
|
|
5393
|
+
type: "array",
|
|
5394
|
+
description: "Shorthand go criteria used to build decisionGate"
|
|
5395
|
+
},
|
|
5396
|
+
noGoSignals: {
|
|
5397
|
+
type: "array",
|
|
5398
|
+
description: "Shorthand no-go signals used to build decisionGate"
|
|
5399
|
+
},
|
|
5400
|
+
proofArtifacts: {
|
|
5401
|
+
type: "array",
|
|
5402
|
+
description: "Expected proof artifacts required to close the worktree"
|
|
5294
5403
|
},
|
|
5295
5404
|
autoShape: {
|
|
5296
5405
|
type: "boolean",
|
|
5297
5406
|
description: "Whether to invoke inquiry auto-shaping during worktree creation"
|
|
5298
5407
|
},
|
|
5408
|
+
autoFixPolicy: {
|
|
5409
|
+
type: "object",
|
|
5410
|
+
description: "Policy for permitted automatic remediation inside the worktree"
|
|
5411
|
+
},
|
|
5299
5412
|
domainPackId: {
|
|
5300
5413
|
type: "string",
|
|
5301
5414
|
description: "Optional domain pack whose shaping hooks should influence generated questions and tasks"
|
|
@@ -5324,9 +5437,17 @@ var ADD_WORKTREE = {
|
|
|
5324
5437
|
type: "array",
|
|
5325
5438
|
description: "Worktree IDs blocked by this worktree"
|
|
5326
5439
|
},
|
|
5327
|
-
|
|
5440
|
+
staffingHint: {
|
|
5328
5441
|
type: "string",
|
|
5329
|
-
description: "
|
|
5442
|
+
description: "Suggested staffing or agent allocation note"
|
|
5443
|
+
},
|
|
5444
|
+
lensId: {
|
|
5445
|
+
type: "string",
|
|
5446
|
+
description: "Lens that scopes this worktree when applicable"
|
|
5447
|
+
},
|
|
5448
|
+
lastReconciledAt: {
|
|
5449
|
+
type: "number",
|
|
5450
|
+
description: "Timestamp when worktree metadata was last reconciled"
|
|
5330
5451
|
}
|
|
5331
5452
|
},
|
|
5332
5453
|
required: ["title", "topicId"],
|
|
@@ -5356,7 +5477,7 @@ var MERGE = {
|
|
|
5356
5477
|
worktreeId: { type: "string", description: "The worktree to merge" },
|
|
5357
5478
|
outcomes: {
|
|
5358
5479
|
type: "array",
|
|
5359
|
-
description: "
|
|
5480
|
+
description: "Merge outcomes as key-finding strings, or scoring outcomes for beliefs: { beliefId, confidence, rationale }"
|
|
5360
5481
|
},
|
|
5361
5482
|
summary: { type: "string", description: "Overall findings summary" }
|
|
5362
5483
|
},
|
|
@@ -8375,6 +8496,69 @@ var GENERATE_SESSION_HANDOFF = {
|
|
|
8375
8496
|
tier: "showcase",
|
|
8376
8497
|
internal: true
|
|
8377
8498
|
};
|
|
8499
|
+
var BEGIN_BUILD_SESSION = {
|
|
8500
|
+
name: "begin_build_session",
|
|
8501
|
+
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.",
|
|
8502
|
+
parameters: {
|
|
8503
|
+
worktreeId: {
|
|
8504
|
+
type: "string",
|
|
8505
|
+
description: "The Lucern worktree ID to bootstrap."
|
|
8506
|
+
},
|
|
8507
|
+
branch: {
|
|
8508
|
+
type: "string",
|
|
8509
|
+
description: "Optional git branch name. Auto-generated from the worktree name when omitted."
|
|
8510
|
+
},
|
|
8511
|
+
branchBase: {
|
|
8512
|
+
type: "string",
|
|
8513
|
+
description: 'Base branch for the feature branch. Default: "staging".'
|
|
8514
|
+
},
|
|
8515
|
+
prBase: {
|
|
8516
|
+
type: "string",
|
|
8517
|
+
description: 'Target branch for the PR. Default: "staging".'
|
|
8518
|
+
},
|
|
8519
|
+
sessionMode: {
|
|
8520
|
+
type: "string",
|
|
8521
|
+
description: 'Session mode: "async" for Codex/headless or "interactive" for live sessions.',
|
|
8522
|
+
enum: ["async", "interactive"]
|
|
8523
|
+
},
|
|
8524
|
+
activateIfPlanning: {
|
|
8525
|
+
type: "boolean",
|
|
8526
|
+
description: "When true, automatically activate a planning worktree during bootstrap."
|
|
8527
|
+
}
|
|
8528
|
+
},
|
|
8529
|
+
required: ["worktreeId"],
|
|
8530
|
+
response: {
|
|
8531
|
+
description: "A compact build-session packet with worktree metadata, graph anchors, questions, dependencies, and git defaults.",
|
|
8532
|
+
fields: {
|
|
8533
|
+
topicId: "string \u2014 canonical topic scope",
|
|
8534
|
+
topicName: "string \u2014 human-readable topic name",
|
|
8535
|
+
worktreeId: "string \u2014 worktree ID",
|
|
8536
|
+
worktreeName: "string \u2014 human-readable worktree name",
|
|
8537
|
+
branch: "string \u2014 git branch name",
|
|
8538
|
+
branchBase: "string \u2014 base branch",
|
|
8539
|
+
prBase: "string \u2014 PR target branch",
|
|
8540
|
+
campaign: "number | null \u2014 top-level pipeline campaign",
|
|
8541
|
+
lane: "string \u2014 campaign lane",
|
|
8542
|
+
gate: "string \u2014 exit gate",
|
|
8543
|
+
hypothesis: "string \u2014 worktree hypothesis",
|
|
8544
|
+
focus: "string \u2014 session focus",
|
|
8545
|
+
status: "string \u2014 worktree status after optional activation",
|
|
8546
|
+
sessionMode: "string \u2014 async | interactive",
|
|
8547
|
+
targetBeliefIds: "array \u2014 scoped belief IDs",
|
|
8548
|
+
targetQuestionIds: "array \u2014 scoped question IDs",
|
|
8549
|
+
topBeliefs: "array \u2014 highest-confidence scoped beliefs",
|
|
8550
|
+
openQuestions: "array \u2014 open scoped questions",
|
|
8551
|
+
resolvedDecisions: "array \u2014 answered questions summarized for the session",
|
|
8552
|
+
dependencies: "array \u2014 upstream worktrees",
|
|
8553
|
+
unblocks: "array \u2014 downstream worktrees",
|
|
8554
|
+
mergeOrderNotes: "string \u2014 merge ordering advisory"
|
|
8555
|
+
}
|
|
8556
|
+
},
|
|
8557
|
+
ownerModule: "bootstrap",
|
|
8558
|
+
ontologyPrimitive: "worktree",
|
|
8559
|
+
tier: "showcase",
|
|
8560
|
+
internal: true
|
|
8561
|
+
};
|
|
8378
8562
|
var MCP_TOOL_CONTRACTS = {
|
|
8379
8563
|
// Belief lifecycle (commit, amend, fork, archive)
|
|
8380
8564
|
create_belief: CREATE_BELIEF,
|
|
@@ -8468,6 +8652,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
8468
8652
|
get_agent_inbox: GET_AGENT_INBOX,
|
|
8469
8653
|
claim_files: CLAIM_FILES,
|
|
8470
8654
|
generate_session_handoff: GENERATE_SESSION_HANDOFF,
|
|
8655
|
+
begin_build_session: BEGIN_BUILD_SESSION,
|
|
8471
8656
|
// Policy / ACL (workhorse)
|
|
8472
8657
|
check_permission: CHECK_PERMISSION,
|
|
8473
8658
|
filter_by_permission: FILTER_BY_PERMISSION,
|
|
@@ -8681,6 +8866,7 @@ var PLATFORM_INTERNAL_OPERATION_NAMES = [
|
|
|
8681
8866
|
"get_change_history",
|
|
8682
8867
|
"get_failure_log",
|
|
8683
8868
|
"record_attempt",
|
|
8869
|
+
"begin_build_session",
|
|
8684
8870
|
"push",
|
|
8685
8871
|
"open_pull_request",
|
|
8686
8872
|
"record_judgment",
|
|
@@ -8735,7 +8921,6 @@ var SDK_ONLY_OPERATION_NAMES = [
|
|
|
8735
8921
|
"find_semantic_orphans"
|
|
8736
8922
|
];
|
|
8737
8923
|
var MCP_ONLY_INTERNAL_OPERATION_NAMES = [
|
|
8738
|
-
"begin_build_session",
|
|
8739
8924
|
"evaluate_engineering_contract",
|
|
8740
8925
|
"evaluate_research_contract"
|
|
8741
8926
|
];
|
|
@@ -9121,8 +9306,31 @@ function assertSurfaceCoverage(contracts) {
|
|
|
9121
9306
|
}
|
|
9122
9307
|
}
|
|
9123
9308
|
}
|
|
9124
|
-
|
|
9125
|
-
|
|
9309
|
+
var jsonRecordSchema2 = z.record(z.unknown());
|
|
9310
|
+
var observationArgs = z.object({
|
|
9311
|
+
topicId: z.string().optional().describe("Topic scope for the observation."),
|
|
9312
|
+
summary: z.string().describe("Short observation summary."),
|
|
9313
|
+
text: z.string().optional().describe("Canonical observation text alias."),
|
|
9314
|
+
title: z.string().optional().describe("Optional observation title."),
|
|
9315
|
+
content: z.string().optional().describe("Optional rich observation content."),
|
|
9316
|
+
contentType: z.string().optional().describe("Observation content type."),
|
|
9317
|
+
kind: z.string().optional().describe("Evidence kind to store."),
|
|
9318
|
+
observationType: z.string().optional().describe("Observation type."),
|
|
9319
|
+
tags: z.array(z.string()).optional().describe("Observation tags."),
|
|
9320
|
+
source: z.string().optional().describe("Observation source label."),
|
|
9321
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
9322
|
+
externalSourceType: z.string().optional().describe("External source type for imported observations."),
|
|
9323
|
+
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
9324
|
+
confidence: z.number().optional().describe("Observation confidence."),
|
|
9325
|
+
metadata: jsonRecordSchema2.optional().describe("Observation metadata."),
|
|
9326
|
+
rationale: z.string().optional().describe("Why this observation should be recorded.")
|
|
9327
|
+
});
|
|
9328
|
+
var observationContextArgs = z.object({
|
|
9329
|
+
topicId: z.string().describe("Topic scope."),
|
|
9330
|
+
query: z.string().optional().describe("Optional context query."),
|
|
9331
|
+
limit: z.number().optional().describe("Maximum observations to return."),
|
|
9332
|
+
status: z.string().optional().describe("Observation status filter.")
|
|
9333
|
+
});
|
|
9126
9334
|
var observationInput = (input, context) => withUserId(
|
|
9127
9335
|
compactRecord4({
|
|
9128
9336
|
projectId: input.projectId,
|
|
@@ -9181,7 +9389,8 @@ var contextContracts = [
|
|
|
9181
9389
|
observationId: output && typeof output === "object" ? output.nodeId : void 0,
|
|
9182
9390
|
observationType: input.observationType
|
|
9183
9391
|
})
|
|
9184
|
-
}
|
|
9392
|
+
},
|
|
9393
|
+
args: observationArgs
|
|
9185
9394
|
}),
|
|
9186
9395
|
surfaceContract({
|
|
9187
9396
|
name: "get_observation_context",
|
|
@@ -9202,7 +9411,8 @@ var contextContracts = [
|
|
|
9202
9411
|
status: input.status,
|
|
9203
9412
|
userId: input.userId
|
|
9204
9413
|
})
|
|
9205
|
-
}
|
|
9414
|
+
},
|
|
9415
|
+
args: observationContextArgs
|
|
9206
9416
|
})
|
|
9207
9417
|
];
|
|
9208
9418
|
|
|
@@ -9265,8 +9475,45 @@ var identityContracts = [
|
|
|
9265
9475
|
}
|
|
9266
9476
|
})
|
|
9267
9477
|
];
|
|
9268
|
-
|
|
9269
|
-
|
|
9478
|
+
var jsonRecordSchema3 = z.record(z.unknown());
|
|
9479
|
+
var sourceTypeSchema = z.enum(["human", "ai_extracted", "ai_generated"]);
|
|
9480
|
+
var reversibilitySchema = z.enum([
|
|
9481
|
+
"irreversible",
|
|
9482
|
+
"hard_to_reverse",
|
|
9483
|
+
"reversible",
|
|
9484
|
+
"trivial"
|
|
9485
|
+
]);
|
|
9486
|
+
var predictionMetaSchema = z.object({
|
|
9487
|
+
isPrediction: z.boolean().describe("Whether this belief is a prediction."),
|
|
9488
|
+
registeredAt: z.number().describe("Timestamp when the prediction was registered."),
|
|
9489
|
+
expectedBy: z.number().optional().describe("Timestamp when the prediction should be evaluated.")
|
|
9490
|
+
});
|
|
9491
|
+
var createBeliefArgs = z.object({
|
|
9492
|
+
canonicalText: z.string().describe("The belief statement the agent holds to be true."),
|
|
9493
|
+
topicId: z.string().optional().describe("Topic scope hint for the belief."),
|
|
9494
|
+
baseRate: z.number().optional().describe("Prior base rate used to seed the vacuous opinion."),
|
|
9495
|
+
beliefType: z.string().optional().describe("Schema belief type."),
|
|
9496
|
+
metadata: jsonRecordSchema3.optional().describe("Extra metadata merged into the belief node."),
|
|
9497
|
+
rationale: z.string().optional().describe("Why this belief should enter the reasoning graph."),
|
|
9498
|
+
pillar: z.string().optional().describe("Innovation pillar or product pillar associated with the belief."),
|
|
9499
|
+
worktreeId: z.string().optional().describe("Worktree responsible for creating or testing this belief."),
|
|
9500
|
+
sourceBeliefIds: z.array(z.string()).optional().describe("Source belief IDs this belief derives from."),
|
|
9501
|
+
sourceType: sourceTypeSchema.optional().describe("Actor/source class that produced the belief."),
|
|
9502
|
+
reversibility: reversibilitySchema.optional().describe("How reversible the belief's implied decision is."),
|
|
9503
|
+
predictionMeta: predictionMetaSchema.optional().describe("Prediction lifecycle metadata when this belief is a forecast.")
|
|
9504
|
+
});
|
|
9505
|
+
var forkBeliefArgs = z.object({
|
|
9506
|
+
nodeId: z.string().describe("The scored belief to fork from."),
|
|
9507
|
+
newFormulation: z.string().describe("The evolved belief statement."),
|
|
9508
|
+
forkReason: z.enum([
|
|
9509
|
+
"refinement",
|
|
9510
|
+
"contradiction_response",
|
|
9511
|
+
"scope_change",
|
|
9512
|
+
"confidence_collapse",
|
|
9513
|
+
"manual"
|
|
9514
|
+
]).describe("Why this fork was created."),
|
|
9515
|
+
rationale: z.string().optional().describe("Why the fork is warranted.")
|
|
9516
|
+
});
|
|
9270
9517
|
var beliefLookupInput = (input) => compactRecord4({
|
|
9271
9518
|
nodeId: input.nodeId ?? input.id ?? input.beliefId,
|
|
9272
9519
|
beliefId: input.beliefId
|
|
@@ -9341,7 +9588,8 @@ var beliefsContracts = [
|
|
|
9341
9588
|
functionName: "create",
|
|
9342
9589
|
kind: "mutation",
|
|
9343
9590
|
inputProjection: createBeliefInput
|
|
9344
|
-
}
|
|
9591
|
+
},
|
|
9592
|
+
args: createBeliefArgs
|
|
9345
9593
|
}),
|
|
9346
9594
|
surfaceContract({
|
|
9347
9595
|
name: "get_belief",
|
|
@@ -9432,7 +9680,8 @@ var beliefsContracts = [
|
|
|
9432
9680
|
functionName: "forkBelief",
|
|
9433
9681
|
kind: "mutation",
|
|
9434
9682
|
inputProjection: forkBeliefInput
|
|
9435
|
-
}
|
|
9683
|
+
},
|
|
9684
|
+
args: forkBeliefArgs
|
|
9436
9685
|
}),
|
|
9437
9686
|
surfaceContract({
|
|
9438
9687
|
name: "archive_belief",
|
|
@@ -9513,8 +9762,46 @@ var beliefsContracts = [
|
|
|
9513
9762
|
}
|
|
9514
9763
|
})
|
|
9515
9764
|
];
|
|
9516
|
-
|
|
9517
|
-
|
|
9765
|
+
var jsonRecordSchema4 = z.record(z.unknown());
|
|
9766
|
+
var evidenceRelationSchema = z.enum(["supports", "contradicts", "neutral"]);
|
|
9767
|
+
var createEvidenceArgs = z.object({
|
|
9768
|
+
topicId: z.string().optional().describe("Topic scope for the evidence."),
|
|
9769
|
+
text: z.string().describe("Canonical evidence text."),
|
|
9770
|
+
source: z.string().optional().describe("Source URL or source label."),
|
|
9771
|
+
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
9772
|
+
targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
|
|
9773
|
+
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
9774
|
+
evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
|
|
9775
|
+
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
9776
|
+
weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
|
|
9777
|
+
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
9778
|
+
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
9779
|
+
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
9780
|
+
title: z.string().optional().describe("Optional short title."),
|
|
9781
|
+
content: z.string().optional().describe("Optional long-form content."),
|
|
9782
|
+
contentType: z.string().optional().describe("Content format or MIME hint."),
|
|
9783
|
+
kind: z.string().optional().describe("Evidence kind."),
|
|
9784
|
+
tags: z.array(z.string()).optional().describe("Evidence tags."),
|
|
9785
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
9786
|
+
externalSourceType: z.string().optional().describe("External source type for imported evidence."),
|
|
9787
|
+
sourceQuestionId: z.string().optional().describe("Question that sourced this evidence."),
|
|
9788
|
+
methodology: z.string().optional().describe("Collection methodology."),
|
|
9789
|
+
informationAsymmetry: z.string().optional().describe("Information asymmetry class."),
|
|
9790
|
+
sourceDescription: z.string().optional().describe("Human-readable source description.")
|
|
9791
|
+
});
|
|
9792
|
+
var addEvidenceArgs = z.object({
|
|
9793
|
+
canonicalText: z.string().describe("The evidence statement."),
|
|
9794
|
+
text: z.string().optional().describe("Canonical evidence text alias used by newer callers."),
|
|
9795
|
+
topicId: z.string().optional().describe("Topic scope hint."),
|
|
9796
|
+
sourceUrl: z.string().optional().describe("URL of the source material."),
|
|
9797
|
+
targetNodeId: z.string().describe("The belief this evidence bears on."),
|
|
9798
|
+
weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
|
|
9799
|
+
reasoning: z.string().describe("Why this evidence is relevant to the target belief."),
|
|
9800
|
+
title: z.string().optional().describe("Optional short title."),
|
|
9801
|
+
content: z.string().optional().describe("Optional long-form evidence content."),
|
|
9802
|
+
contentType: z.string().optional().describe("Content format or MIME hint."),
|
|
9803
|
+
metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
|
|
9804
|
+
});
|
|
9518
9805
|
var evidenceIdInput = (input) => compactRecord4({
|
|
9519
9806
|
evidenceId: input.evidenceId,
|
|
9520
9807
|
insightId: input.insightId,
|
|
@@ -9589,7 +9876,8 @@ var evidenceContracts = [
|
|
|
9589
9876
|
functionName: "create",
|
|
9590
9877
|
kind: "mutation",
|
|
9591
9878
|
inputProjection: createEvidenceInput
|
|
9592
|
-
}
|
|
9879
|
+
},
|
|
9880
|
+
args: createEvidenceArgs
|
|
9593
9881
|
}),
|
|
9594
9882
|
surfaceContract({
|
|
9595
9883
|
name: "add_evidence",
|
|
@@ -9625,7 +9913,8 @@ var evidenceContracts = [
|
|
|
9625
9913
|
context
|
|
9626
9914
|
);
|
|
9627
9915
|
}
|
|
9628
|
-
}
|
|
9916
|
+
},
|
|
9917
|
+
args: addEvidenceArgs
|
|
9629
9918
|
}),
|
|
9630
9919
|
surfaceContract({
|
|
9631
9920
|
name: "get_evidence",
|
|
@@ -9732,8 +10021,91 @@ var evidenceContracts = [
|
|
|
9732
10021
|
}
|
|
9733
10022
|
})
|
|
9734
10023
|
];
|
|
9735
|
-
|
|
9736
|
-
|
|
10024
|
+
var jsonRecordSchema5 = z.record(z.unknown());
|
|
10025
|
+
var questionPrioritySchema = z.enum(["urgent", "high", "medium", "low"]);
|
|
10026
|
+
var kernelQuestionPrioritySchema = z.enum([
|
|
10027
|
+
"critical",
|
|
10028
|
+
"high",
|
|
10029
|
+
"medium",
|
|
10030
|
+
"low"
|
|
10031
|
+
]);
|
|
10032
|
+
var questionTypeSchema = z.enum([
|
|
10033
|
+
"validation",
|
|
10034
|
+
"falsification",
|
|
10035
|
+
"assumption_probe",
|
|
10036
|
+
"prediction_test",
|
|
10037
|
+
"counterfactual",
|
|
10038
|
+
"discovery",
|
|
10039
|
+
"clarification",
|
|
10040
|
+
"comparison",
|
|
10041
|
+
"causal",
|
|
10042
|
+
"mechanism",
|
|
10043
|
+
"general"
|
|
10044
|
+
]);
|
|
10045
|
+
var createQuestionArgs = z.object({
|
|
10046
|
+
text: z.string().describe("The question text."),
|
|
10047
|
+
question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
|
|
10048
|
+
topicId: z.string().optional().describe("Topic scope hint."),
|
|
10049
|
+
priority: questionPrioritySchema.optional().describe("Human-facing question priority."),
|
|
10050
|
+
linkedBeliefId: z.string().optional().describe("Belief this question tests."),
|
|
10051
|
+
linkedBeliefNodeId: z.string().optional().describe("Belief node this question tests."),
|
|
10052
|
+
metadata: jsonRecordSchema5.optional().describe("Optional metadata merged into the question record."),
|
|
10053
|
+
category: z.string().optional().describe("Question category."),
|
|
10054
|
+
source: z.string().optional().describe("Question source."),
|
|
10055
|
+
testType: z.enum(["validates", "invalidates", "clarifies"]).optional().describe("How this question tests its linked belief."),
|
|
10056
|
+
importance: z.number().optional().describe("Numeric importance score."),
|
|
10057
|
+
epistemicUnlock: z.string().optional().describe("What this question unlocks if answered."),
|
|
10058
|
+
sourceQuestionIds: z.array(z.string()).optional().describe("Question IDs this question derives from."),
|
|
10059
|
+
linkedWorktreeId: z.string().optional().describe("Worktree this question belongs to."),
|
|
10060
|
+
questionType: questionTypeSchema.optional().describe("Question type."),
|
|
10061
|
+
questionPriority: kernelQuestionPrioritySchema.optional().describe("Kernel-native question priority.")
|
|
10062
|
+
});
|
|
10063
|
+
var refineQuestionArgs = z.object({
|
|
10064
|
+
id: z.string().describe("The question to refine."),
|
|
10065
|
+
text: z.string().describe("Updated question text."),
|
|
10066
|
+
question: z.string().optional().describe("Backend question text alias for kernel-native callers."),
|
|
10067
|
+
rationale: z.string().optional().describe("Why the question is refined."),
|
|
10068
|
+
category: z.string().optional().describe("Updated question category."),
|
|
10069
|
+
priority: questionPrioritySchema.optional().describe("Updated human-facing priority.")
|
|
10070
|
+
});
|
|
10071
|
+
var createAnswerArgs = z.object({
|
|
10072
|
+
questionNodeId: z.string().describe("The question node ID this answer responds to."),
|
|
10073
|
+
questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
|
|
10074
|
+
answerText: z.string().describe("The answer content."),
|
|
10075
|
+
topicId: z.string().optional().describe("Topic scope for the answer."),
|
|
10076
|
+
confidence: z.string().optional().describe("Answer confidence."),
|
|
10077
|
+
evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node IDs supporting the answer."),
|
|
10078
|
+
answerSource: z.string().optional().describe("How the answer was produced."),
|
|
10079
|
+
worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
|
|
10080
|
+
sprintId: z.string().optional().describe("Legacy sprint identifier.")
|
|
10081
|
+
});
|
|
10082
|
+
var answerQuestionArgs = z.object({
|
|
10083
|
+
id: z.string().describe("Canonical question ID."),
|
|
10084
|
+
topicId: z.string().describe("Topic scope for the answer."),
|
|
10085
|
+
text: z.string().describe("Answer text."),
|
|
10086
|
+
confidence: z.enum(["weak", "medium", "strong"]).optional().describe("Optional answer confidence."),
|
|
10087
|
+
evidenceIds: z.array(z.string()).optional().describe("Canonical evidence IDs supporting the answer."),
|
|
10088
|
+
rationale: z.string().optional().describe("Why this answer is credible."),
|
|
10089
|
+
questionId: z.string().optional().describe("Question ID alias accepted by the projection."),
|
|
10090
|
+
questionNodeId: z.string().optional().describe("Question node ID alias accepted by the projection."),
|
|
10091
|
+
answerText: z.string().optional().describe("Canonical answer text alias accepted by newer callers."),
|
|
10092
|
+
evidenceNodeIds: z.array(z.string()).optional().describe("Evidence node ID alias accepted by newer callers."),
|
|
10093
|
+
answerSource: z.string().optional().describe("How the answer was produced."),
|
|
10094
|
+
worktreeId: z.string().optional().describe("Worktree whose outcome produced this answer."),
|
|
10095
|
+
sprintId: z.string().optional().describe("Legacy sprint identifier.")
|
|
10096
|
+
});
|
|
10097
|
+
var missingQuestionsArgs = z.object({
|
|
10098
|
+
topicId: z.string().describe("Topic scope."),
|
|
10099
|
+
minConfidence: z.number().optional().describe("Minimum confidence threshold for missing-question checks."),
|
|
10100
|
+
status: z.string().optional().describe("Question status filter."),
|
|
10101
|
+
limit: z.number().optional().describe("Maximum questions to inspect.")
|
|
10102
|
+
});
|
|
10103
|
+
var falsificationQuestionsArgs = z.object({
|
|
10104
|
+
topicId: z.string().describe("Topic scope."),
|
|
10105
|
+
beliefIds: z.array(z.string()).optional().describe("Beliefs to generate falsification questions for."),
|
|
10106
|
+
status: z.string().optional().describe("Question status filter."),
|
|
10107
|
+
limit: z.number().optional().describe("Maximum questions to inspect.")
|
|
10108
|
+
});
|
|
9737
10109
|
var questionNodeInput = (input) => compactRecord4({
|
|
9738
10110
|
nodeId: input.nodeId ?? input.id ?? input.questionId,
|
|
9739
10111
|
questionId: input.questionId
|
|
@@ -9780,7 +10152,8 @@ var questionsContracts = [
|
|
|
9780
10152
|
functionName: "create",
|
|
9781
10153
|
kind: "mutation",
|
|
9782
10154
|
inputProjection: createQuestionInput
|
|
9783
|
-
}
|
|
10155
|
+
},
|
|
10156
|
+
args: createQuestionArgs
|
|
9784
10157
|
}),
|
|
9785
10158
|
surfaceContract({
|
|
9786
10159
|
name: "get_question",
|
|
@@ -9836,7 +10209,8 @@ var questionsContracts = [
|
|
|
9836
10209
|
category: input.category,
|
|
9837
10210
|
priority: input.priority
|
|
9838
10211
|
})
|
|
9839
|
-
}
|
|
10212
|
+
},
|
|
10213
|
+
args: refineQuestionArgs
|
|
9840
10214
|
}),
|
|
9841
10215
|
surfaceContract({
|
|
9842
10216
|
name: "update_question_status",
|
|
@@ -9912,7 +10286,8 @@ var questionsContracts = [
|
|
|
9912
10286
|
}),
|
|
9913
10287
|
context
|
|
9914
10288
|
)
|
|
9915
|
-
}
|
|
10289
|
+
},
|
|
10290
|
+
args: createAnswerArgs
|
|
9916
10291
|
}),
|
|
9917
10292
|
surfaceContract({
|
|
9918
10293
|
name: "answer_question",
|
|
@@ -9941,7 +10316,8 @@ var questionsContracts = [
|
|
|
9941
10316
|
}),
|
|
9942
10317
|
context
|
|
9943
10318
|
)
|
|
9944
|
-
}
|
|
10319
|
+
},
|
|
10320
|
+
args: answerQuestionArgs
|
|
9945
10321
|
}),
|
|
9946
10322
|
surfaceContract({
|
|
9947
10323
|
name: "get_answer",
|
|
@@ -9973,7 +10349,8 @@ var questionsContracts = [
|
|
|
9973
10349
|
functionName: "getByTopic",
|
|
9974
10350
|
kind: "query",
|
|
9975
10351
|
inputProjection: questionTopicInput
|
|
9976
|
-
}
|
|
10352
|
+
},
|
|
10353
|
+
args: missingQuestionsArgs
|
|
9977
10354
|
}),
|
|
9978
10355
|
surfaceContract({
|
|
9979
10356
|
name: "get_high_priority_questions",
|
|
@@ -10008,11 +10385,22 @@ var questionsContracts = [
|
|
|
10008
10385
|
functionName: "getByTopic",
|
|
10009
10386
|
kind: "query",
|
|
10010
10387
|
inputProjection: questionTopicInput
|
|
10011
|
-
}
|
|
10388
|
+
},
|
|
10389
|
+
args: falsificationQuestionsArgs
|
|
10012
10390
|
})
|
|
10013
10391
|
];
|
|
10014
|
-
|
|
10015
|
-
|
|
10392
|
+
var updateTopicArgs = z.object({
|
|
10393
|
+
id: z.string().describe("Topic ID."),
|
|
10394
|
+
topicId: z.string().optional().describe("Topic ID alias."),
|
|
10395
|
+
name: z.string().optional().describe("Topic name."),
|
|
10396
|
+
description: z.string().optional().describe("Topic description."),
|
|
10397
|
+
type: z.string().optional().describe("Topic type."),
|
|
10398
|
+
status: z.string().optional().describe("Topic status."),
|
|
10399
|
+
visibility: z.string().optional().describe("Topic visibility."),
|
|
10400
|
+
ontologyId: z.string().optional().describe("Ontology to bind."),
|
|
10401
|
+
clearOntologyId: z.boolean().optional().describe("Whether to clear the ontology binding."),
|
|
10402
|
+
metadata: z.record(z.unknown()).optional().describe("Topic metadata.")
|
|
10403
|
+
});
|
|
10016
10404
|
var topicIdInput = (input) => compactRecord4({
|
|
10017
10405
|
id: input.id ?? input.topicId
|
|
10018
10406
|
});
|
|
@@ -10093,7 +10481,8 @@ var topicsContracts = [
|
|
|
10093
10481
|
functionName: "update",
|
|
10094
10482
|
kind: "mutation",
|
|
10095
10483
|
inputProjection: updateTopicInput
|
|
10096
|
-
}
|
|
10484
|
+
},
|
|
10485
|
+
args: updateTopicArgs
|
|
10097
10486
|
}),
|
|
10098
10487
|
surfaceContract({
|
|
10099
10488
|
name: "get_topic_tree",
|
|
@@ -10112,8 +10501,27 @@ var topicsContracts = [
|
|
|
10112
10501
|
}
|
|
10113
10502
|
})
|
|
10114
10503
|
];
|
|
10115
|
-
|
|
10116
|
-
|
|
10504
|
+
var lensPerspectiveSchema = z.enum([
|
|
10505
|
+
"investigation",
|
|
10506
|
+
"monitoring",
|
|
10507
|
+
"analysis",
|
|
10508
|
+
"comparison",
|
|
10509
|
+
"taxonomy"
|
|
10510
|
+
]);
|
|
10511
|
+
var jsonRecordSchema6 = z.record(z.unknown());
|
|
10512
|
+
var createLensArgs = z.object({
|
|
10513
|
+
name: z.string().describe("Lens name."),
|
|
10514
|
+
workspaceId: z.string().optional().describe("Workspace scope for the lens."),
|
|
10515
|
+
topicId: z.string().optional().describe("Originating topic scope."),
|
|
10516
|
+
description: z.string().optional().describe("What this lens investigates or monitors."),
|
|
10517
|
+
perspectiveType: lensPerspectiveSchema.describe("Perspective type."),
|
|
10518
|
+
promptTemplates: z.array(jsonRecordSchema6).optional().describe("Prompt templates used through this lens."),
|
|
10519
|
+
workflowTemplates: z.array(jsonRecordSchema6).optional().describe("Guided workflow templates."),
|
|
10520
|
+
taskTemplates: z.array(jsonRecordSchema6).optional().describe("Default task templates."),
|
|
10521
|
+
questionTemplates: z.array(jsonRecordSchema6).optional().describe("Default question templates."),
|
|
10522
|
+
filterCriteria: jsonRecordSchema6.optional().describe("Belief/evidence filtering criteria."),
|
|
10523
|
+
metadata: jsonRecordSchema6.optional().describe("Additional lens metadata.")
|
|
10524
|
+
});
|
|
10117
10525
|
var createLensInput = (input, context) => compactRecord4({
|
|
10118
10526
|
name: input.name,
|
|
10119
10527
|
description: input.description,
|
|
@@ -10150,7 +10558,8 @@ var lensesContracts = [
|
|
|
10150
10558
|
functionName: "create",
|
|
10151
10559
|
kind: "mutation",
|
|
10152
10560
|
inputProjection: createLensInput
|
|
10153
|
-
}
|
|
10561
|
+
},
|
|
10562
|
+
args: createLensArgs
|
|
10154
10563
|
}),
|
|
10155
10564
|
surfaceContract({
|
|
10156
10565
|
name: "list_lenses",
|
|
@@ -10212,8 +10621,18 @@ var lensesContracts = [
|
|
|
10212
10621
|
}
|
|
10213
10622
|
})
|
|
10214
10623
|
];
|
|
10215
|
-
|
|
10216
|
-
|
|
10624
|
+
var updateOntologyArgs = z.object({
|
|
10625
|
+
id: z.string().describe("Ontology definition ID."),
|
|
10626
|
+
ontologyId: z.string().optional().describe("Ontology ID alias."),
|
|
10627
|
+
name: z.string().optional().describe("Ontology display name."),
|
|
10628
|
+
description: z.string().optional().describe("Ontology description."),
|
|
10629
|
+
status: z.string().optional().describe("Ontology lifecycle status.")
|
|
10630
|
+
});
|
|
10631
|
+
var ontologyVersionLifecycleArgs = z.object({
|
|
10632
|
+
id: z.string().describe("Ontology version ID."),
|
|
10633
|
+
versionId: z.string().optional().describe("Ontology version ID alias."),
|
|
10634
|
+
ontologyId: z.string().optional().describe("Ontology definition ID.")
|
|
10635
|
+
});
|
|
10217
10636
|
var ontologyIdInput = (input) => compactRecord4({
|
|
10218
10637
|
id: input.id ?? input.ontologyId
|
|
10219
10638
|
});
|
|
@@ -10292,11 +10711,11 @@ var ontologiesContracts = [
|
|
|
10292
10711
|
id: input.id ?? input.ontologyId,
|
|
10293
10712
|
name: input.name,
|
|
10294
10713
|
description: input.description,
|
|
10295
|
-
parentOntologyId: input.parentOntologyId,
|
|
10296
10714
|
status: input.status,
|
|
10297
10715
|
actorId: input.actorId
|
|
10298
10716
|
})
|
|
10299
|
-
}
|
|
10717
|
+
},
|
|
10718
|
+
args: updateOntologyArgs
|
|
10300
10719
|
}),
|
|
10301
10720
|
surfaceContract({
|
|
10302
10721
|
name: "archive_ontology",
|
|
@@ -10379,7 +10798,8 @@ var ontologiesContracts = [
|
|
|
10379
10798
|
functionName: "publishOntologyVersion",
|
|
10380
10799
|
kind: "mutation",
|
|
10381
10800
|
inputProjection: ontologyVersionIdInput
|
|
10382
|
-
}
|
|
10801
|
+
},
|
|
10802
|
+
args: ontologyVersionLifecycleArgs
|
|
10383
10803
|
}),
|
|
10384
10804
|
surfaceContract({
|
|
10385
10805
|
name: "deprecate_ontology_version",
|
|
@@ -10395,7 +10815,8 @@ var ontologiesContracts = [
|
|
|
10395
10815
|
functionName: "deprecateOntologyVersion",
|
|
10396
10816
|
kind: "mutation",
|
|
10397
10817
|
inputProjection: ontologyVersionIdInput
|
|
10398
|
-
}
|
|
10818
|
+
},
|
|
10819
|
+
args: ontologyVersionLifecycleArgs
|
|
10399
10820
|
}),
|
|
10400
10821
|
surfaceContract({
|
|
10401
10822
|
name: "resolve_effective_ontology",
|
|
@@ -10414,8 +10835,76 @@ var ontologiesContracts = [
|
|
|
10414
10835
|
}
|
|
10415
10836
|
})
|
|
10416
10837
|
];
|
|
10417
|
-
|
|
10418
|
-
|
|
10838
|
+
var autoFixPolicyInputSchema = z.object({
|
|
10839
|
+
enabled: z.boolean().optional().describe("Whether automatic remediation is enabled."),
|
|
10840
|
+
mode: z.string().optional().describe("Automation mode for worktree auto-fixes."),
|
|
10841
|
+
maxAttempts: z.number().optional().describe("Maximum number of auto-fix attempts."),
|
|
10842
|
+
reviewer: z.string().optional().describe("Reviewer responsible for auto-fix oversight."),
|
|
10843
|
+
maxActionsPerRun: z.number().optional().describe("Maximum number of auto-fix actions per run."),
|
|
10844
|
+
permittedMutationTiers: z.array(z.enum(["read_only", "low_risk_write", "high_risk_write"])).optional().describe("Mutation tiers the auto-fix worker may execute."),
|
|
10845
|
+
requireAuditTrail: z.boolean().optional().describe("Whether auto-fix actions must write an audit trail."),
|
|
10846
|
+
escalationGate: z.string().optional().describe("Gate to trigger when auto-fix policy requires escalation.")
|
|
10847
|
+
}).passthrough().describe("Policy for permitted automatic remediation inside the worktree.");
|
|
10848
|
+
var worktreeKeyQuestionInputSchema = z.object({
|
|
10849
|
+
question: z.string().describe("Question the worktree must resolve."),
|
|
10850
|
+
status: z.enum(["open", "answered", "forked"]).optional().describe("Current disposition of the key question."),
|
|
10851
|
+
answer: z.string().optional().describe("Captured answer when the key question is resolved."),
|
|
10852
|
+
answerConfidence: z.enum(["high", "medium", "low"]).optional().describe("Confidence in the captured answer."),
|
|
10853
|
+
linkedQuestionId: z.string().optional().describe("Canonical question node linked to this key question.")
|
|
10854
|
+
}).passthrough().describe("Question contract embedded in the worktree plan.");
|
|
10855
|
+
var worktreeEvidenceSignalInputSchema = z.object({
|
|
10856
|
+
signal: z.string().describe("Evidence signal the worktree should collect."),
|
|
10857
|
+
collected: z.boolean().optional().describe("Whether the signal has already been collected."),
|
|
10858
|
+
progress: z.string().optional().describe("Collection progress note for the signal."),
|
|
10859
|
+
notes: z.string().optional().describe("Additional evidence collection notes.")
|
|
10860
|
+
}).passthrough().describe("Evidence signal embedded in the worktree plan.");
|
|
10861
|
+
var worktreeDecisionGateInputSchema = z.object({
|
|
10862
|
+
goCriteria: z.array(z.string()).describe("Criteria that must hold for the worktree to proceed."),
|
|
10863
|
+
noGoSignals: z.array(z.string()).describe("Signals that stop or redirect the worktree."),
|
|
10864
|
+
verdict: z.enum(["go", "no_go", "pivot", "pending"]).optional().describe("Current decision verdict for the worktree gate."),
|
|
10865
|
+
verdictRationale: z.string().optional().describe("Rationale supporting the current gate verdict."),
|
|
10866
|
+
decidedAt: z.number().optional().describe("Timestamp when the gate verdict was decided."),
|
|
10867
|
+
decidedBy: z.string().optional().describe("Actor that decided the gate verdict.")
|
|
10868
|
+
}).passthrough().describe("Decision gate contract for worktree activation or exit.");
|
|
10869
|
+
var addWorktreeArgs = z.object({
|
|
10870
|
+
title: z.string().optional().describe("Human-readable worktree name or objective."),
|
|
10871
|
+
name: z.string().optional().describe("Storage-name alias for callers that already use backend naming."),
|
|
10872
|
+
topicId: z.string().describe("Primary topic scope for the worktree."),
|
|
10873
|
+
projectId: z.string().optional().describe("Legacy topicId alias."),
|
|
10874
|
+
branchId: z.string().optional().describe("Legacy branch identifier for compatibility with workflow callers."),
|
|
10875
|
+
objective: z.string().optional().describe("Reasoning objective this worktree is intended to resolve."),
|
|
10876
|
+
hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
|
|
10877
|
+
rationale: z.string().optional().describe("Why this worktree exists and why it belongs in the campaign."),
|
|
10878
|
+
worktreeType: z.string().optional().describe("Schema-enum worktree type used for kernel lifecycle behavior."),
|
|
10879
|
+
gate: z.string().optional().describe("Exit gate for this worktree."),
|
|
10880
|
+
startDate: z.number().optional().describe("Planned start timestamp in milliseconds since epoch."),
|
|
10881
|
+
endDate: z.number().optional().describe("Planned end timestamp in milliseconds since epoch."),
|
|
10882
|
+
durationWeeks: z.number().optional().describe("Planned duration in weeks."),
|
|
10883
|
+
confidenceImpact: z.enum(["high", "medium", "low"]).optional().describe("Expected confidence impact if this worktree succeeds."),
|
|
10884
|
+
beliefFocus: z.string().optional().describe("Natural-language focus spanning the target belief neighborhood."),
|
|
10885
|
+
beliefIds: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
|
|
10886
|
+
beliefs: z.array(z.string()).optional().describe("Legacy alias for targetBeliefIds."),
|
|
10887
|
+
targetBeliefIds: z.array(z.string()).optional().describe("Belief node IDs this worktree is expected to test or update."),
|
|
10888
|
+
targetQuestionIds: z.array(z.string()).optional().describe("Question node IDs this worktree is expected to answer."),
|
|
10889
|
+
keyQuestions: z.array(worktreeKeyQuestionInputSchema).optional().describe("Inline key questions captured as part of the worktree plan."),
|
|
10890
|
+
evidenceSignals: z.array(worktreeEvidenceSignalInputSchema).optional().describe("Evidence signals the worktree needs to collect or validate."),
|
|
10891
|
+
decisionGate: worktreeDecisionGateInputSchema.optional(),
|
|
10892
|
+
goCriteria: z.array(z.string()).optional().describe("Shorthand go criteria used to build decisionGate."),
|
|
10893
|
+
noGoSignals: z.array(z.string()).optional().describe("Shorthand no-go signals used to build decisionGate."),
|
|
10894
|
+
proofArtifacts: z.array(z.unknown()).optional().describe("Expected proof artifacts required to close the worktree."),
|
|
10895
|
+
autoShape: z.boolean().optional().describe("Whether to invoke inquiry auto-shaping during creation."),
|
|
10896
|
+
autoFixPolicy: autoFixPolicyInputSchema.optional(),
|
|
10897
|
+
domainPackId: z.string().optional().describe("Domain pack whose shaping hooks should influence the worktree."),
|
|
10898
|
+
campaign: z.number().optional().describe("Top-level pipeline campaign number."),
|
|
10899
|
+
lane: z.string().optional().describe("Campaign lane for the worktree."),
|
|
10900
|
+
laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
|
|
10901
|
+
orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
|
|
10902
|
+
dependsOn: z.array(z.string()).optional().describe("Worktree IDs that must complete before this worktree."),
|
|
10903
|
+
blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
|
|
10904
|
+
staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
|
|
10905
|
+
lensId: z.string().optional().describe("Lens that scopes this worktree when applicable."),
|
|
10906
|
+
lastReconciledAt: z.number().optional().describe("Timestamp when worktree metadata was last reconciled.")
|
|
10907
|
+
});
|
|
10419
10908
|
var worktreeIdInput = (input) => compactRecord4({
|
|
10420
10909
|
worktreeId: input.worktreeId ?? input.id
|
|
10421
10910
|
});
|
|
@@ -10448,6 +10937,50 @@ var worktreeMetadataInput = (input) => compactRecord4({
|
|
|
10448
10937
|
autoFixPolicy: input.autoFixPolicy,
|
|
10449
10938
|
lastReconciledAt: input.lastReconciledAt
|
|
10450
10939
|
});
|
|
10940
|
+
var worktreeMetadataArgs = z.object({
|
|
10941
|
+
worktreeId: z.string().describe("The worktree to update."),
|
|
10942
|
+
id: z.string().optional().describe("Worktree ID alias."),
|
|
10943
|
+
topicId: z.string().optional().describe("Primary topic scope."),
|
|
10944
|
+
additionalTopicIds: z.array(z.string()).optional().describe("Additional topic scopes associated with this worktree."),
|
|
10945
|
+
status: z.string().optional().describe("Worktree lifecycle status."),
|
|
10946
|
+
campaign: z.number().optional().describe("Top-level pipeline campaign."),
|
|
10947
|
+
lane: z.string().optional().describe("Campaign lane."),
|
|
10948
|
+
laneOrderInCampaign: z.number().optional().describe("Ordering for this lane within its campaign."),
|
|
10949
|
+
orderInLane: z.number().optional().describe("Position of this worktree inside its lane."),
|
|
10950
|
+
gate: z.string().optional().describe("Exit gate for this worktree."),
|
|
10951
|
+
hypothesis: z.string().optional().describe("Testable claim this worktree investigates."),
|
|
10952
|
+
objective: z.string().optional().describe("Reasoning objective for the worktree."),
|
|
10953
|
+
rationale: z.string().optional().describe("Why this worktree is sequenced here."),
|
|
10954
|
+
proofArtifacts: z.array(z.unknown()).optional().describe("Proof artifacts required to close the worktree."),
|
|
10955
|
+
staffingHint: z.string().optional().describe("Suggested staffing or agent allocation note."),
|
|
10956
|
+
blocks: z.array(z.string()).optional().describe("Worktree IDs blocked by this worktree."),
|
|
10957
|
+
dependsOn: z.array(z.string()).optional().describe("Worktree IDs this worktree depends on."),
|
|
10958
|
+
lensId: z.string().optional().describe("Lens that scopes this worktree."),
|
|
10959
|
+
autoFixPolicy: autoFixPolicyInputSchema.optional(),
|
|
10960
|
+
lastReconciledAt: z.number().optional().describe("Timestamp of the last deterministic reconciliation pass.")
|
|
10961
|
+
});
|
|
10962
|
+
var pushArgs = worktreeMetadataArgs.extend({
|
|
10963
|
+
targetContext: z.string().describe("Where to push merged findings."),
|
|
10964
|
+
beliefIds: z.array(z.string()).optional().describe("Optional subset of beliefs to push.")
|
|
10965
|
+
});
|
|
10966
|
+
var openPullRequestArgs = worktreeMetadataArgs.extend({
|
|
10967
|
+
reviewers: z.array(z.string()).optional().describe("User IDs of requested reviewers."),
|
|
10968
|
+
summary: z.string().describe("Summary of findings and why they are ready for review.")
|
|
10969
|
+
});
|
|
10970
|
+
var mergeKeyFindingsInput = (input) => {
|
|
10971
|
+
if (Array.isArray(input.keyFindings)) {
|
|
10972
|
+
return input.keyFindings;
|
|
10973
|
+
}
|
|
10974
|
+
if (Array.isArray(input.outcomes)) {
|
|
10975
|
+
const findings = input.outcomes.filter(
|
|
10976
|
+
(outcome) => typeof outcome === "string" && outcome.trim().length > 0
|
|
10977
|
+
);
|
|
10978
|
+
if (findings.length > 0) {
|
|
10979
|
+
return findings;
|
|
10980
|
+
}
|
|
10981
|
+
}
|
|
10982
|
+
return [input.summary ?? "Merged worktree"];
|
|
10983
|
+
};
|
|
10451
10984
|
var listAllWorktreesInput = (input) => compactRecord4({
|
|
10452
10985
|
status: input.status,
|
|
10453
10986
|
lane: input.lane,
|
|
@@ -10455,6 +10988,16 @@ var listAllWorktreesInput = (input) => compactRecord4({
|
|
|
10455
10988
|
limit: input.limit
|
|
10456
10989
|
});
|
|
10457
10990
|
var worktreesContracts = [
|
|
10991
|
+
surfaceContract({
|
|
10992
|
+
name: "begin_build_session",
|
|
10993
|
+
kind: "mutation",
|
|
10994
|
+
domain: "worktrees",
|
|
10995
|
+
surfaceClass: "platform_internal",
|
|
10996
|
+
path: "/mcp/build-session/begin",
|
|
10997
|
+
sdkNamespace: "worktrees",
|
|
10998
|
+
sdkMethod: "beginBuildSession",
|
|
10999
|
+
summary: "Begin a coding build session for a worktree."
|
|
11000
|
+
}),
|
|
10458
11001
|
surfaceContract({
|
|
10459
11002
|
name: "add_worktree",
|
|
10460
11003
|
kind: "mutation",
|
|
@@ -10471,13 +11014,12 @@ var worktreesContracts = [
|
|
|
10471
11014
|
inputProjection: (input, context) => withCreatedBy(
|
|
10472
11015
|
compactRecord4({
|
|
10473
11016
|
name: input.name ?? input.title,
|
|
10474
|
-
topicId: input.topicId,
|
|
11017
|
+
topicId: input.topicId ?? input.projectId,
|
|
10475
11018
|
worktreeType: input.worktreeType,
|
|
10476
11019
|
objective: input.objective,
|
|
10477
11020
|
gate: input.gate,
|
|
10478
11021
|
hypothesis: input.hypothesis,
|
|
10479
11022
|
rationale: input.rationale,
|
|
10480
|
-
signal: input.signal,
|
|
10481
11023
|
startDate: input.startDate,
|
|
10482
11024
|
endDate: input.endDate,
|
|
10483
11025
|
durationWeeks: input.durationWeeks,
|
|
@@ -10503,12 +11045,12 @@ var worktreesContracts = [
|
|
|
10503
11045
|
staffingHint: input.staffingHint,
|
|
10504
11046
|
domainPackId: input.domainPackId,
|
|
10505
11047
|
lensId: input.lensId,
|
|
10506
|
-
linkedQuestionId: input.linkedQuestionId,
|
|
10507
11048
|
lastReconciledAt: input.lastReconciledAt
|
|
10508
11049
|
}),
|
|
10509
11050
|
context
|
|
10510
11051
|
)
|
|
10511
|
-
}
|
|
11052
|
+
},
|
|
11053
|
+
args: addWorktreeArgs
|
|
10512
11054
|
}),
|
|
10513
11055
|
surfaceContract({
|
|
10514
11056
|
name: "activate_worktree",
|
|
@@ -10620,7 +11162,8 @@ var worktreesContracts = [
|
|
|
10620
11162
|
functionName: "updateMetadata",
|
|
10621
11163
|
kind: "mutation",
|
|
10622
11164
|
inputProjection: worktreeMetadataInput
|
|
10623
|
-
}
|
|
11165
|
+
},
|
|
11166
|
+
args: worktreeMetadataArgs
|
|
10624
11167
|
}),
|
|
10625
11168
|
surfaceContract({
|
|
10626
11169
|
name: "merge",
|
|
@@ -10638,9 +11181,7 @@ var worktreesContracts = [
|
|
|
10638
11181
|
inputProjection: (input, context) => withUserId(
|
|
10639
11182
|
{
|
|
10640
11183
|
...worktreeIdInput(input),
|
|
10641
|
-
keyFindings: input
|
|
10642
|
-
input.summary ?? "Merged worktree"
|
|
10643
|
-
],
|
|
11184
|
+
keyFindings: mergeKeyFindingsInput(input),
|
|
10644
11185
|
decisionsReached: input.decisionsReached ?? [],
|
|
10645
11186
|
nextSteps: input.nextSteps ?? []
|
|
10646
11187
|
},
|
|
@@ -10662,7 +11203,8 @@ var worktreesContracts = [
|
|
|
10662
11203
|
functionName: "updateMetadata",
|
|
10663
11204
|
kind: "mutation",
|
|
10664
11205
|
inputProjection: worktreeMetadataInput
|
|
10665
|
-
}
|
|
11206
|
+
},
|
|
11207
|
+
args: pushArgs
|
|
10666
11208
|
}),
|
|
10667
11209
|
surfaceContract({
|
|
10668
11210
|
name: "open_pull_request",
|
|
@@ -10678,7 +11220,8 @@ var worktreesContracts = [
|
|
|
10678
11220
|
functionName: "updateMetadata",
|
|
10679
11221
|
kind: "mutation",
|
|
10680
11222
|
inputProjection: worktreeMetadataInput
|
|
10681
|
-
}
|
|
11223
|
+
},
|
|
11224
|
+
args: openPullRequestArgs
|
|
10682
11225
|
})
|
|
10683
11226
|
];
|
|
10684
11227
|
|
|
@@ -10782,6 +11325,15 @@ var createEdgeArgs = z.object({
|
|
|
10782
11325
|
topicId: z.string().optional(),
|
|
10783
11326
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
10784
11327
|
});
|
|
11328
|
+
var queryLineageArgs = z.object({
|
|
11329
|
+
nodeId: z.string().describe("Starting node to trace from."),
|
|
11330
|
+
startNode: z.string().optional().describe("Starting node alias accepted by traversal callers."),
|
|
11331
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11332
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11333
|
+
mode: z.string().optional().describe("Traversal mode."),
|
|
11334
|
+
minLayer: z.string().optional().describe("Minimum epistemic layer."),
|
|
11335
|
+
maxLayer: z.string().optional().describe("Maximum epistemic layer.")
|
|
11336
|
+
});
|
|
10785
11337
|
function graphRefNodeId(ref) {
|
|
10786
11338
|
if (ref.kind === "epistemic_node") {
|
|
10787
11339
|
return ref.nodeId;
|
|
@@ -10852,11 +11404,59 @@ var edgesContracts = [
|
|
|
10852
11404
|
minLayer: input.minLayer,
|
|
10853
11405
|
maxLayer: input.maxLayer
|
|
10854
11406
|
})
|
|
10855
|
-
}
|
|
11407
|
+
},
|
|
11408
|
+
args: queryLineageArgs
|
|
10856
11409
|
})
|
|
10857
11410
|
];
|
|
10858
|
-
|
|
10859
|
-
|
|
11411
|
+
var traversalLayerSchema = z.enum([
|
|
11412
|
+
"L4",
|
|
11413
|
+
"L3",
|
|
11414
|
+
"L2",
|
|
11415
|
+
"L1",
|
|
11416
|
+
"ontological",
|
|
11417
|
+
"organizational"
|
|
11418
|
+
]);
|
|
11419
|
+
var traversalModeSchema = z.enum(["low", "medium", "high", "extra_high"]);
|
|
11420
|
+
var lineageAliasArgs = z.object({
|
|
11421
|
+
nodeId: z.string().optional().describe("Starting node to traverse from."),
|
|
11422
|
+
startNode: z.string().optional().describe("Starting node alias for traversal callers."),
|
|
11423
|
+
entityId: z.string().optional().describe("Entity identifier alias for impact tracing."),
|
|
11424
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11425
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11426
|
+
mode: traversalModeSchema.optional().describe("Traversal mode."),
|
|
11427
|
+
minLayer: traversalLayerSchema.optional().describe("Minimum epistemic layer to include."),
|
|
11428
|
+
maxLayer: traversalLayerSchema.optional().describe("Maximum epistemic layer to include.")
|
|
11429
|
+
});
|
|
11430
|
+
var lineageArgs = lineageAliasArgs.extend({
|
|
11431
|
+
nodeId: z.string().describe("Starting node to traverse from.")
|
|
11432
|
+
});
|
|
11433
|
+
var traverseGraphArgs = lineageAliasArgs.extend({
|
|
11434
|
+
startNode: z.string().describe("Node to start traversal from."),
|
|
11435
|
+
direction: z.enum(["up", "down", "both"]).optional().describe("Traversal direction.")
|
|
11436
|
+
});
|
|
11437
|
+
var graphNeighborhoodArgs = z.object({
|
|
11438
|
+
globalId: z.string().optional().describe("Single root global ID."),
|
|
11439
|
+
globalIds: z.array(z.string()).optional().describe("Root global IDs for the neighborhood."),
|
|
11440
|
+
maxDepth: z.number().optional().describe("Maximum traversal depth."),
|
|
11441
|
+
topicId: z.string().optional().describe("Topic scope for edge lookup."),
|
|
11442
|
+
limit: z.number().optional().describe("Maximum edges to return.")
|
|
11443
|
+
});
|
|
11444
|
+
var flagContradictionArgs = z.object({
|
|
11445
|
+
beliefA: z.string().describe("First belief in tension."),
|
|
11446
|
+
beliefB: z.string().describe("Second belief in tension."),
|
|
11447
|
+
topicId: z.string().optional().describe("Topic scope for the contradiction."),
|
|
11448
|
+
description: z.string().optional().describe("Human-readable contradiction."),
|
|
11449
|
+
severity: z.enum(["critical", "high", "medium", "low"]).optional().describe("Contradiction severity."),
|
|
11450
|
+
defeatType: z.string().optional().describe("Defeat type annotation."),
|
|
11451
|
+
supportingInsightIds: z.array(z.string()).optional().describe("Evidence supporting the primary belief."),
|
|
11452
|
+
contradictingInsightIds: z.array(z.string()).optional().describe("Evidence or beliefs contradicting the primary belief.")
|
|
11453
|
+
});
|
|
11454
|
+
var discoverEntityConnectionsArgs = lineageAliasArgs.extend({
|
|
11455
|
+
nodeId: z.string().describe("Epistemic node ID to find entity connections for."),
|
|
11456
|
+
topicId: z.string().optional().describe("Topic scope override."),
|
|
11457
|
+
minScore: z.number().optional().describe("Minimum match score."),
|
|
11458
|
+
limit: z.number().optional().describe("Maximum candidates to return.")
|
|
11459
|
+
});
|
|
10860
11460
|
var contradictionSeverity = (value) => {
|
|
10861
11461
|
switch (value) {
|
|
10862
11462
|
case "critical":
|
|
@@ -10911,7 +11511,8 @@ var graphContracts = [
|
|
|
10911
11511
|
functionName: "getLineage",
|
|
10912
11512
|
kind: "query",
|
|
10913
11513
|
inputProjection: lineageInput
|
|
10914
|
-
}
|
|
11514
|
+
},
|
|
11515
|
+
args: traverseGraphArgs
|
|
10915
11516
|
}),
|
|
10916
11517
|
surfaceContract({
|
|
10917
11518
|
name: "get_graph_neighborhood",
|
|
@@ -10927,7 +11528,8 @@ var graphContracts = [
|
|
|
10927
11528
|
functionName: "getByTopic",
|
|
10928
11529
|
kind: "query",
|
|
10929
11530
|
inputProjection: topicEdgesInput
|
|
10930
|
-
}
|
|
11531
|
+
},
|
|
11532
|
+
args: graphNeighborhoodArgs
|
|
10931
11533
|
}),
|
|
10932
11534
|
surfaceContract({
|
|
10933
11535
|
name: "get_graph_structure_analysis",
|
|
@@ -10976,7 +11578,8 @@ var graphContracts = [
|
|
|
10976
11578
|
functionName: "create",
|
|
10977
11579
|
kind: "mutation",
|
|
10978
11580
|
inputProjection: flagContradictionInput
|
|
10979
|
-
}
|
|
11581
|
+
},
|
|
11582
|
+
args: flagContradictionArgs
|
|
10980
11583
|
}),
|
|
10981
11584
|
surfaceContract({
|
|
10982
11585
|
name: "detect_confirmation_bias",
|
|
@@ -11067,7 +11670,8 @@ var graphContracts = [
|
|
|
11067
11670
|
functionName: "getLineage",
|
|
11068
11671
|
kind: "query",
|
|
11069
11672
|
inputProjection: lineageInput
|
|
11070
|
-
}
|
|
11673
|
+
},
|
|
11674
|
+
args: discoverEntityConnectionsArgs
|
|
11071
11675
|
}),
|
|
11072
11676
|
surfaceContract({
|
|
11073
11677
|
name: "trigger_belief_review",
|
|
@@ -11098,7 +11702,8 @@ var graphContracts = [
|
|
|
11098
11702
|
functionName: "getLineage",
|
|
11099
11703
|
kind: "query",
|
|
11100
11704
|
inputProjection: lineageInput
|
|
11101
|
-
}
|
|
11705
|
+
},
|
|
11706
|
+
args: lineageArgs
|
|
11102
11707
|
})
|
|
11103
11708
|
];
|
|
11104
11709
|
|
|
@@ -11150,8 +11755,16 @@ var contractsContracts = [
|
|
|
11150
11755
|
}
|
|
11151
11756
|
})
|
|
11152
11757
|
];
|
|
11153
|
-
|
|
11154
|
-
|
|
11758
|
+
var auditTrailArgs = z.object({
|
|
11759
|
+
nodeId: z.string().describe("The node to audit."),
|
|
11760
|
+
id: z.string().optional().describe("Node ID alias."),
|
|
11761
|
+
limit: z.number().optional().describe("Maximum entries to return."),
|
|
11762
|
+
depth: z.number().optional().describe("Traversal depth alias."),
|
|
11763
|
+
maxDepth: z.number().optional().describe("Maximum lineage depth."),
|
|
11764
|
+
mode: z.string().optional().describe("Traversal mode."),
|
|
11765
|
+
minLayer: z.string().optional().describe("Minimum epistemic layer."),
|
|
11766
|
+
maxLayer: z.string().optional().describe("Maximum epistemic layer.")
|
|
11767
|
+
});
|
|
11155
11768
|
var judgmentsContracts = [
|
|
11156
11769
|
surfaceContract({
|
|
11157
11770
|
name: "record_judgment",
|
|
@@ -11206,7 +11819,8 @@ var judgmentsContracts = [
|
|
|
11206
11819
|
minLayer: input.minLayer,
|
|
11207
11820
|
maxLayer: input.maxLayer
|
|
11208
11821
|
})
|
|
11209
|
-
}
|
|
11822
|
+
},
|
|
11823
|
+
args: auditTrailArgs
|
|
11210
11824
|
})
|
|
11211
11825
|
];
|
|
11212
11826
|
|
|
@@ -11374,8 +11988,13 @@ var coordinationContracts = [
|
|
|
11374
11988
|
}
|
|
11375
11989
|
})
|
|
11376
11990
|
];
|
|
11377
|
-
|
|
11378
|
-
|
|
11991
|
+
var pipelineSnapshotArgs = z.object({
|
|
11992
|
+
topicId: z.string().describe("Topic scope ID."),
|
|
11993
|
+
status: z.string().optional().describe("Worktree status filter."),
|
|
11994
|
+
lane: z.string().optional().describe("Campaign lane filter."),
|
|
11995
|
+
campaign: z.number().optional().describe("Campaign number filter."),
|
|
11996
|
+
limit: z.number().optional().describe("Maximum worktrees to inspect.")
|
|
11997
|
+
});
|
|
11379
11998
|
var pipelineContracts = [
|
|
11380
11999
|
surfaceContract({
|
|
11381
12000
|
name: "pipeline_snapshot",
|
|
@@ -11396,7 +12015,8 @@ var pipelineContracts = [
|
|
|
11396
12015
|
campaign: input.campaign,
|
|
11397
12016
|
limit: input.limit
|
|
11398
12017
|
})
|
|
11399
|
-
}
|
|
12018
|
+
},
|
|
12019
|
+
args: pipelineSnapshotArgs
|
|
11400
12020
|
}),
|
|
11401
12021
|
surfaceContract({
|
|
11402
12022
|
name: "seed_belief_lattice",
|
|
@@ -11448,7 +12068,31 @@ var recordScopeLearningArgs = z.object({
|
|
|
11448
12068
|
rationale: z.string().optional().describe("Why this learning should enter the reasoning graph"),
|
|
11449
12069
|
createQuestionText: z.string().optional().describe("Optional follow-up question text"),
|
|
11450
12070
|
createBeliefText: z.string().optional().describe("Optional new belief text"),
|
|
11451
|
-
beliefType: z.string().optional().describe("Optional belief type for createBeliefText")
|
|
12071
|
+
beliefType: z.string().optional().describe("Optional belief type for createBeliefText"),
|
|
12072
|
+
text: z.string().optional().describe("Canonical learning text alias."),
|
|
12073
|
+
content: z.string().optional().describe("Canonical learning content alias."),
|
|
12074
|
+
kind: z.string().optional().describe("Evidence kind to store."),
|
|
12075
|
+
sourceType: z.string().optional().describe("Evidence source type."),
|
|
12076
|
+
externalSourceType: z.string().optional().describe("External source type alias."),
|
|
12077
|
+
metadata: z.record(z.unknown()).optional().describe("Learning metadata.")
|
|
12078
|
+
});
|
|
12079
|
+
var codeContextArgs = z.object({
|
|
12080
|
+
topicId: z.string().optional().describe("Topic scope."),
|
|
12081
|
+
filePath: z.string().optional().describe("File path anchor."),
|
|
12082
|
+
includeFailures: z.boolean().optional().describe("Whether to include failed attempts."),
|
|
12083
|
+
limit: z.number().optional().describe("Maximum records to return."),
|
|
12084
|
+
status: z.string().optional().describe("Evidence status filter.")
|
|
12085
|
+
});
|
|
12086
|
+
var recordAttemptArgs = z.object({
|
|
12087
|
+
topicId: z.string().optional().describe("Topic scope."),
|
|
12088
|
+
description: z.string().describe("Attempt description."),
|
|
12089
|
+
errorMessage: z.string().optional().describe("Failure or error message."),
|
|
12090
|
+
filePaths: z.array(z.string()).optional().describe("Files involved in the attempt."),
|
|
12091
|
+
filePath: z.string().optional().describe("Single file path alias."),
|
|
12092
|
+
linkedBeliefId: z.string().optional().describe("Linked belief ID."),
|
|
12093
|
+
metadata: z.record(z.unknown()).optional().describe("Attempt metadata."),
|
|
12094
|
+
rationale: z.string().optional().describe("Why this attempt should be recorded."),
|
|
12095
|
+
title: z.string().optional().describe("Attempt evidence title.")
|
|
11452
12096
|
});
|
|
11453
12097
|
var learningInput = (input, context) => {
|
|
11454
12098
|
const sourceKind = input.sourceKind ?? input.externalSourceType;
|
|
@@ -11565,7 +12209,8 @@ var codingContracts = [
|
|
|
11565
12209
|
status: input.status,
|
|
11566
12210
|
userId: input.userId
|
|
11567
12211
|
})
|
|
11568
|
-
}
|
|
12212
|
+
},
|
|
12213
|
+
args: codeContextArgs
|
|
11569
12214
|
}),
|
|
11570
12215
|
surfaceContract({
|
|
11571
12216
|
name: "get_change_history",
|
|
@@ -11602,7 +12247,8 @@ var codingContracts = [
|
|
|
11602
12247
|
functionName: "create",
|
|
11603
12248
|
kind: "mutation",
|
|
11604
12249
|
inputProjection: attemptInput
|
|
11605
|
-
}
|
|
12250
|
+
},
|
|
12251
|
+
args: recordAttemptArgs
|
|
11606
12252
|
}),
|
|
11607
12253
|
surfaceContract({
|
|
11608
12254
|
name: "get_failure_log",
|
|
@@ -11677,360 +12323,624 @@ new Map(
|
|
|
11677
12323
|
ALL_FUNCTION_CONTRACTS.map((contract) => [contract.name, contract])
|
|
11678
12324
|
);
|
|
11679
12325
|
|
|
11680
|
-
// ../contracts/src/
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
// ../server-core/src/kernelApi.ts
|
|
11684
|
-
var REQUIRED_KERNEL_API_REF_SUFFIXES = [
|
|
11685
|
-
"contradictions.create",
|
|
11686
|
-
"contradictions.getById",
|
|
11687
|
-
"contradictions.getByTopic",
|
|
11688
|
-
"epistemicAnswers.create",
|
|
11689
|
-
"epistemicAnswers.getLatestForQuestion",
|
|
11690
|
-
"epistemicBeliefs.archive",
|
|
11691
|
-
"epistemicBeliefs.batchUpdateCriticality",
|
|
11692
|
-
"epistemicBeliefs.create",
|
|
11693
|
-
"epistemicBeliefs.forkBelief",
|
|
11694
|
-
"epistemicBeliefs.getById",
|
|
11695
|
-
"epistemicBeliefs.getByTopic",
|
|
11696
|
-
"epistemicBeliefs.getConfidenceHistory",
|
|
11697
|
-
"epistemicBeliefs.getLineage",
|
|
11698
|
-
"epistemicBeliefs.getRelationships",
|
|
11699
|
-
"epistemicBeliefs.linkBeliefs",
|
|
11700
|
-
"epistemicBeliefs.linkEvidence",
|
|
11701
|
-
"epistemicBeliefs.modulateConfidence",
|
|
11702
|
-
"epistemicBeliefs.reassignBeliefsTopic",
|
|
11703
|
-
"epistemicBeliefs.refineBelief",
|
|
11704
|
-
"epistemicBeliefs.unlinkEvidence",
|
|
11705
|
-
"epistemicBeliefs.updateCriticality",
|
|
11706
|
-
"epistemicBeliefs.updateRationale",
|
|
11707
|
-
"epistemicBeliefs.updateStatus",
|
|
11708
|
-
"epistemicContracts.createEpistemicContract",
|
|
11709
|
-
"epistemicContracts.evaluateContract",
|
|
11710
|
-
"epistemicContracts.getContractStatus",
|
|
11711
|
-
"epistemicEdges.batchCreate",
|
|
11712
|
-
"epistemicEdges.create",
|
|
11713
|
-
"epistemicEdges.deleteEdges",
|
|
11714
|
-
"epistemicEdges.getBySourceNode",
|
|
11715
|
-
"epistemicEdges.getByTopicAndType",
|
|
11716
|
-
"epistemicEdges.remove",
|
|
11717
|
-
"epistemicEdges.removeBetween",
|
|
11718
|
-
"epistemicEdges.update",
|
|
11719
|
-
"epistemicEvidence.create",
|
|
11720
|
-
"epistemicEvidence.flagAsIncorrect",
|
|
11721
|
-
"epistemicEvidence.getById",
|
|
11722
|
-
"epistemicEvidence.getByTopic",
|
|
11723
|
-
"epistemicEvidence.getForBelief",
|
|
11724
|
-
"epistemicEvidence.remove",
|
|
11725
|
-
"epistemicEvidence.update",
|
|
11726
|
-
"epistemicEvidence.updateStatus",
|
|
11727
|
-
"epistemicEvidence.updateVerificationStatus",
|
|
11728
|
-
"epistemicNodes.get",
|
|
11729
|
-
"epistemicNodes.getByGlobalId",
|
|
11730
|
-
"epistemicQuestions.addQuestion",
|
|
11731
|
-
"epistemicQuestions.advanceToConviction",
|
|
11732
|
-
"epistemicQuestions.create",
|
|
11733
|
-
"epistemicQuestions.createBatch",
|
|
11734
|
-
"epistemicQuestions.deleteQuestion",
|
|
11735
|
-
"epistemicQuestions.finalizeConviction",
|
|
11736
|
-
"epistemicQuestions.getById",
|
|
11737
|
-
"epistemicQuestions.getByTopic",
|
|
11738
|
-
"epistemicQuestions.internalCreate",
|
|
11739
|
-
"epistemicQuestions.updateConviction",
|
|
11740
|
-
"epistemicQuestions.updatePriority",
|
|
11741
|
-
"epistemicQuestions.updateQuestion",
|
|
11742
|
-
"epistemicQuestions.updateStatus",
|
|
11743
|
-
"evidenceClassifier.classifyEvidence",
|
|
11744
|
-
"evidenceClassifier.classifyEvidenceBatch",
|
|
11745
|
-
"graphAnalysisCache.getCachedAnalysis",
|
|
11746
|
-
"graphIntelligence.analyzeProject",
|
|
11747
|
-
"neo4jEdgeAPI.getGraphNeighborhood",
|
|
11748
|
-
"neo4jQueries.getConfirmationBiasScore",
|
|
11749
|
-
"ontologyDefinitions.archiveOntologyDefinition",
|
|
11750
|
-
"ontologyDefinitions.createOntologyDefinition",
|
|
11751
|
-
"ontologyDefinitions.createOntologyVersion",
|
|
11752
|
-
"ontologyDefinitions.deprecateOntologyVersion",
|
|
11753
|
-
"ontologyDefinitions.getOntologyDefinition",
|
|
11754
|
-
"ontologyDefinitions.getOntologyDefinitionByKey",
|
|
11755
|
-
"ontologyDefinitions.getPublishedVersion",
|
|
11756
|
-
"ontologyDefinitions.listOntologyDefinitions",
|
|
11757
|
-
"ontologyDefinitions.publishOntologyVersion",
|
|
11758
|
-
"ontologyDefinitions.resolveEffectiveOntology",
|
|
11759
|
-
"ontologyDefinitions.updateOntologyDefinition",
|
|
11760
|
-
"policy.filterByPermission",
|
|
11761
|
-
"questionEvidenceLinks.create",
|
|
11762
|
-
"questionEvidenceLinks.getEvidenceWithDetails",
|
|
11763
|
-
"tasks.complete",
|
|
11764
|
-
"tasks.create",
|
|
11765
|
-
"tasks.get",
|
|
11766
|
-
"tasks.getByTopic",
|
|
11767
|
-
"tasks.getByWorktree",
|
|
11768
|
-
"tasks.update",
|
|
11769
|
-
"topics.bulkCreate",
|
|
11770
|
-
"topics.checkAccess",
|
|
11771
|
-
"topics.create",
|
|
11772
|
-
"topics.get",
|
|
11773
|
-
"topics.getTree",
|
|
11774
|
-
"topics.list",
|
|
11775
|
-
"topics.listByOntology",
|
|
11776
|
-
"topics.remove",
|
|
11777
|
-
"topics.resolveTopicOntology",
|
|
11778
|
-
"topics.update",
|
|
11779
|
-
"worktrees.activate",
|
|
11780
|
-
"worktrees.advancePhase",
|
|
11781
|
-
"worktrees.bulkCreate",
|
|
11782
|
-
"worktrees.complete",
|
|
11783
|
-
"worktrees.create",
|
|
11784
|
-
"worktrees.get",
|
|
11785
|
-
"worktrees.list",
|
|
11786
|
-
"worktrees.listAll",
|
|
11787
|
-
"worktrees.patchState",
|
|
11788
|
-
"worktrees.setPhase",
|
|
11789
|
-
"worktrees.updateMetadata",
|
|
11790
|
-
"worktrees.updateTargets"
|
|
11791
|
-
];
|
|
11792
|
-
var KERNEL_API_REF_MANIFEST = REQUIRED_KERNEL_API_REF_SUFFIXES.map((path3) => ({
|
|
11793
|
-
path: `api.${path3}`,
|
|
11794
|
-
componentPath: `components.lucern.${path3}`
|
|
11795
|
-
}));
|
|
11796
|
-
var GLOBAL_KEY = "__LUCERN_SERVER_CORE_KERNEL_API_BINDING__";
|
|
11797
|
-
function store() {
|
|
11798
|
-
return globalThis;
|
|
11799
|
-
}
|
|
11800
|
-
function registerKernelApi(nextBinding) {
|
|
11801
|
-
assertKernelApiBinding(nextBinding);
|
|
11802
|
-
store()[GLOBAL_KEY] = nextBinding;
|
|
11803
|
-
}
|
|
11804
|
-
function getBinding() {
|
|
11805
|
-
const current = store()[GLOBAL_KEY];
|
|
11806
|
-
if (!current) {
|
|
11807
|
-
throw new Error(
|
|
11808
|
-
"Server-core kernelApi not registered. Call registerKernelApi({api, components, internal}) at host boot."
|
|
11809
|
-
);
|
|
11810
|
-
}
|
|
11811
|
-
return current;
|
|
11812
|
-
}
|
|
11813
|
-
function readPath(root, path3) {
|
|
11814
|
-
let cursor = root;
|
|
11815
|
-
for (const part of path3) {
|
|
11816
|
-
if (cursor == null || typeof cursor !== "object") {
|
|
11817
|
-
return void 0;
|
|
11818
|
-
}
|
|
11819
|
-
cursor = cursor[part];
|
|
11820
|
-
}
|
|
11821
|
-
return cursor;
|
|
12326
|
+
// ../contracts/src/tenant-bootstrap-seed.contract.ts
|
|
12327
|
+
function isCopyableSeedRequirement(entry) {
|
|
12328
|
+
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;
|
|
11822
12329
|
}
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
}
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
12330
|
+
var TENANT_BOOTSTRAP_TABLE_REQUIREMENTS = [
|
|
12331
|
+
{
|
|
12332
|
+
component: "kernel",
|
|
12333
|
+
table: "agentMessages",
|
|
12334
|
+
prepopulation: "runtime_data",
|
|
12335
|
+
copyMode: "none",
|
|
12336
|
+
description: "Agent coordination messages are session data, not template data."
|
|
12337
|
+
},
|
|
12338
|
+
{
|
|
12339
|
+
component: "kernel",
|
|
12340
|
+
table: "agentSessions",
|
|
12341
|
+
prepopulation: "runtime_data",
|
|
12342
|
+
copyMode: "none",
|
|
12343
|
+
description: "Agent coordination sessions are created by active clients."
|
|
12344
|
+
},
|
|
12345
|
+
{
|
|
12346
|
+
component: "kernel",
|
|
12347
|
+
table: "autofixJobs",
|
|
12348
|
+
prepopulation: "runtime_queue",
|
|
12349
|
+
copyMode: "none",
|
|
12350
|
+
description: "Autofix work items are runtime queue rows."
|
|
12351
|
+
},
|
|
12352
|
+
{
|
|
12353
|
+
component: "kernel",
|
|
12354
|
+
table: "backgroundJobRuns",
|
|
12355
|
+
prepopulation: "runtime_log",
|
|
12356
|
+
copyMode: "none",
|
|
12357
|
+
description: "Background job executions are runtime logs."
|
|
12358
|
+
},
|
|
12359
|
+
{
|
|
12360
|
+
component: "kernel",
|
|
12361
|
+
table: "backgroundJobSettings",
|
|
12362
|
+
prepopulation: "required_template",
|
|
12363
|
+
copyMode: "template_global",
|
|
12364
|
+
scope: "global",
|
|
12365
|
+
uniqueKey: ["jobKey"],
|
|
12366
|
+
description: "Default job enablement settings must come from the K template."
|
|
12367
|
+
},
|
|
12368
|
+
{
|
|
12369
|
+
component: "kernel",
|
|
12370
|
+
table: "beliefConfidence",
|
|
12371
|
+
prepopulation: "runtime_data",
|
|
12372
|
+
copyMode: "none",
|
|
12373
|
+
description: "Belief confidence rows are created with tenant graph facts."
|
|
12374
|
+
},
|
|
12375
|
+
{
|
|
12376
|
+
component: "kernel",
|
|
12377
|
+
table: "beliefEvidenceLinks",
|
|
12378
|
+
prepopulation: "runtime_data",
|
|
12379
|
+
copyMode: "none",
|
|
12380
|
+
description: "Belief-to-evidence links are tenant graph data."
|
|
12381
|
+
},
|
|
12382
|
+
{
|
|
12383
|
+
component: "kernel",
|
|
12384
|
+
table: "beliefHistory",
|
|
12385
|
+
prepopulation: "runtime_data",
|
|
12386
|
+
copyMode: "none",
|
|
12387
|
+
description: "Belief history is append-only tenant graph data."
|
|
12388
|
+
},
|
|
12389
|
+
{
|
|
12390
|
+
component: "kernel",
|
|
12391
|
+
table: "beliefScenarios",
|
|
12392
|
+
prepopulation: "runtime_data",
|
|
12393
|
+
copyMode: "none",
|
|
12394
|
+
description: "Scenario rows are tenant-authored reasoning data."
|
|
12395
|
+
},
|
|
12396
|
+
{
|
|
12397
|
+
component: "kernel",
|
|
12398
|
+
table: "beliefVotes",
|
|
12399
|
+
prepopulation: "runtime_data",
|
|
12400
|
+
copyMode: "none",
|
|
12401
|
+
description: "Decision belief votes are tenant-authored data."
|
|
12402
|
+
},
|
|
12403
|
+
{
|
|
12404
|
+
component: "kernel",
|
|
12405
|
+
table: "calibrationScores",
|
|
12406
|
+
prepopulation: "runtime_derived",
|
|
12407
|
+
copyMode: "none",
|
|
12408
|
+
description: "Calibration scores are computed from tenant outcomes."
|
|
12409
|
+
},
|
|
12410
|
+
{
|
|
12411
|
+
component: "kernel",
|
|
12412
|
+
table: "contractEvaluations",
|
|
12413
|
+
prepopulation: "runtime_log",
|
|
12414
|
+
copyMode: "none",
|
|
12415
|
+
description: "Contract evaluation rows are runtime computation logs."
|
|
12416
|
+
},
|
|
12417
|
+
{
|
|
12418
|
+
component: "kernel",
|
|
12419
|
+
table: "contradictions",
|
|
12420
|
+
prepopulation: "runtime_data",
|
|
12421
|
+
copyMode: "none",
|
|
12422
|
+
description: "Contradictions are tenant graph facts."
|
|
12423
|
+
},
|
|
12424
|
+
{
|
|
12425
|
+
component: "kernel",
|
|
12426
|
+
table: "crossProjectConnections",
|
|
12427
|
+
prepopulation: "runtime_data",
|
|
12428
|
+
copyMode: "none",
|
|
12429
|
+
description: "Cross-topic connections are tenant graph facts."
|
|
12430
|
+
},
|
|
12431
|
+
{
|
|
12432
|
+
component: "kernel",
|
|
12433
|
+
table: "decisionComputedSummaries",
|
|
12434
|
+
prepopulation: "runtime_derived",
|
|
12435
|
+
copyMode: "none",
|
|
12436
|
+
description: "Decision summaries are derived tenant outputs."
|
|
12437
|
+
},
|
|
12438
|
+
{
|
|
12439
|
+
component: "kernel",
|
|
12440
|
+
table: "decisionEvents",
|
|
12441
|
+
prepopulation: "runtime_data",
|
|
12442
|
+
copyMode: "none",
|
|
12443
|
+
description: "Decision events are lifecycle data."
|
|
12444
|
+
},
|
|
12445
|
+
{
|
|
12446
|
+
component: "kernel",
|
|
12447
|
+
table: "decisionParticipants",
|
|
12448
|
+
prepopulation: "runtime_data",
|
|
12449
|
+
copyMode: "none",
|
|
12450
|
+
description: "Decision participants are tenant-selected actors."
|
|
12451
|
+
},
|
|
12452
|
+
{
|
|
12453
|
+
component: "kernel",
|
|
12454
|
+
table: "decisionRiskLedger",
|
|
12455
|
+
prepopulation: "runtime_data",
|
|
12456
|
+
copyMode: "none",
|
|
12457
|
+
description: "Decision risk rows are tenant decision data."
|
|
12458
|
+
},
|
|
12459
|
+
{
|
|
12460
|
+
component: "kernel",
|
|
12461
|
+
table: "decisionSnapshots",
|
|
12462
|
+
prepopulation: "runtime_derived",
|
|
12463
|
+
copyMode: "none",
|
|
12464
|
+
description: "Decision snapshots are derived from tenant state."
|
|
12465
|
+
},
|
|
12466
|
+
{
|
|
12467
|
+
component: "kernel",
|
|
12468
|
+
table: "deliberationContributions",
|
|
12469
|
+
prepopulation: "runtime_data",
|
|
12470
|
+
copyMode: "none",
|
|
12471
|
+
description: "Deliberation contributions are tenant-authored data."
|
|
12472
|
+
},
|
|
12473
|
+
{
|
|
12474
|
+
component: "kernel",
|
|
12475
|
+
table: "deliberationSessions",
|
|
12476
|
+
prepopulation: "runtime_data",
|
|
12477
|
+
copyMode: "none",
|
|
12478
|
+
description: "Deliberation sessions are created by tenant workflows."
|
|
12479
|
+
},
|
|
12480
|
+
{
|
|
12481
|
+
component: "kernel",
|
|
12482
|
+
table: "epistemicAudit",
|
|
12483
|
+
prepopulation: "runtime_log",
|
|
12484
|
+
copyMode: "none",
|
|
12485
|
+
description: "Epistemic audit rows are append-only runtime audit data."
|
|
12486
|
+
},
|
|
12487
|
+
{
|
|
12488
|
+
component: "kernel",
|
|
12489
|
+
table: "epistemicContracts",
|
|
12490
|
+
prepopulation: "runtime_data",
|
|
12491
|
+
copyMode: "none",
|
|
12492
|
+
description: "Epistemic contracts are tenant-authored governance data."
|
|
12493
|
+
},
|
|
12494
|
+
{
|
|
12495
|
+
component: "kernel",
|
|
12496
|
+
table: "epistemicEdges",
|
|
12497
|
+
prepopulation: "runtime_data",
|
|
12498
|
+
copyMode: "none",
|
|
12499
|
+
description: "Edges are tenant reasoning graph data."
|
|
12500
|
+
},
|
|
12501
|
+
{
|
|
12502
|
+
component: "kernel",
|
|
12503
|
+
table: "epistemicNodeEmbeddings",
|
|
12504
|
+
prepopulation: "runtime_derived",
|
|
12505
|
+
copyMode: "none",
|
|
12506
|
+
description: "Embeddings are derived from tenant graph nodes."
|
|
12507
|
+
},
|
|
12508
|
+
{
|
|
12509
|
+
component: "kernel",
|
|
12510
|
+
table: "epistemicNodes",
|
|
12511
|
+
prepopulation: "runtime_data",
|
|
12512
|
+
copyMode: "none",
|
|
12513
|
+
description: "Nodes are tenant reasoning graph data."
|
|
12514
|
+
},
|
|
12515
|
+
{
|
|
12516
|
+
component: "kernel",
|
|
12517
|
+
table: "graphAnalysisCache",
|
|
12518
|
+
prepopulation: "runtime_derived",
|
|
12519
|
+
copyMode: "none",
|
|
12520
|
+
description: "Graph analysis cache rows are derived from tenant graph state."
|
|
12521
|
+
},
|
|
12522
|
+
{
|
|
12523
|
+
component: "kernel",
|
|
12524
|
+
table: "graphAnalysisResults",
|
|
12525
|
+
prepopulation: "runtime_derived",
|
|
12526
|
+
copyMode: "none",
|
|
12527
|
+
description: "Graph analysis result rows are derived tenant outputs."
|
|
12528
|
+
},
|
|
12529
|
+
{
|
|
12530
|
+
component: "kernel",
|
|
12531
|
+
table: "graphSuggestions",
|
|
12532
|
+
prepopulation: "runtime_derived",
|
|
12533
|
+
copyMode: "none",
|
|
12534
|
+
description: "Graph suggestions are derived recommendations."
|
|
12535
|
+
},
|
|
12536
|
+
{
|
|
12537
|
+
component: "kernel",
|
|
12538
|
+
table: "harnessReplays",
|
|
12539
|
+
prepopulation: "runtime_log",
|
|
12540
|
+
copyMode: "none",
|
|
12541
|
+
description: "Harness replay rows are runtime verification logs."
|
|
12542
|
+
},
|
|
12543
|
+
{
|
|
12544
|
+
component: "kernel",
|
|
12545
|
+
table: "harnessRuns",
|
|
12546
|
+
prepopulation: "runtime_log",
|
|
12547
|
+
copyMode: "none",
|
|
12548
|
+
description: "Harness run rows are runtime verification logs."
|
|
12549
|
+
},
|
|
12550
|
+
{
|
|
12551
|
+
component: "kernel",
|
|
12552
|
+
table: "idempotencyTokens",
|
|
12553
|
+
prepopulation: "runtime_log",
|
|
12554
|
+
copyMode: "none",
|
|
12555
|
+
description: "Idempotency tokens are request-scoped runtime guards."
|
|
12556
|
+
},
|
|
12557
|
+
{
|
|
12558
|
+
component: "kernel",
|
|
12559
|
+
table: "lenses",
|
|
12560
|
+
prepopulation: "optional_template",
|
|
12561
|
+
copyMode: "none",
|
|
12562
|
+
description: "Reusable lens templates may live in K templates, but workspace-specific copies are not required for core SDK boot."
|
|
12563
|
+
},
|
|
12564
|
+
{
|
|
12565
|
+
component: "kernel",
|
|
12566
|
+
table: "lensTopicBindings",
|
|
12567
|
+
prepopulation: "runtime_data",
|
|
12568
|
+
copyMode: "none",
|
|
12569
|
+
description: "Lens bindings attach runtime topics to runtime/workspace lenses."
|
|
12570
|
+
},
|
|
12571
|
+
{
|
|
12572
|
+
component: "kernel",
|
|
12573
|
+
table: "neo4jSyncQueue",
|
|
12574
|
+
prepopulation: "runtime_queue",
|
|
12575
|
+
copyMode: "none",
|
|
12576
|
+
description: "Neo4j sync queue rows are runtime work items."
|
|
12577
|
+
},
|
|
12578
|
+
{
|
|
12579
|
+
component: "kernel",
|
|
12580
|
+
table: "ontologyDefinitions",
|
|
12581
|
+
prepopulation: "required_template",
|
|
12582
|
+
copyMode: "template_global",
|
|
12583
|
+
scope: "global",
|
|
12584
|
+
uniqueKey: ["ontologyKey"],
|
|
12585
|
+
description: "Platform ontology definitions power taxonomy reads and effective ontology resolution."
|
|
12586
|
+
},
|
|
12587
|
+
{
|
|
12588
|
+
component: "kernel",
|
|
12589
|
+
table: "ontologyVersions",
|
|
12590
|
+
prepopulation: "required_template",
|
|
12591
|
+
copyMode: "template_reference_remap",
|
|
12592
|
+
scope: "global",
|
|
12593
|
+
uniqueKey: ["ontologyKey", "version"],
|
|
12594
|
+
dependsOn: ["ontologyDefinitions"],
|
|
12595
|
+
description: "Ontology versions must be copied with ontologyDefinition ID remapping."
|
|
12596
|
+
},
|
|
12597
|
+
{
|
|
12598
|
+
component: "kernel",
|
|
12599
|
+
table: "platformAgentRunPolicyDecisions",
|
|
12600
|
+
prepopulation: "runtime_log",
|
|
12601
|
+
copyMode: "none",
|
|
12602
|
+
description: "Agent-run policy decisions are audit logs."
|
|
12603
|
+
},
|
|
12604
|
+
{
|
|
12605
|
+
component: "kernel",
|
|
12606
|
+
table: "platformAgentRunPromptResolutions",
|
|
12607
|
+
prepopulation: "runtime_log",
|
|
12608
|
+
copyMode: "none",
|
|
12609
|
+
description: "Agent-run prompt resolution rows are runtime logs."
|
|
12610
|
+
},
|
|
12611
|
+
{
|
|
12612
|
+
component: "kernel",
|
|
12613
|
+
table: "platformAgentRuns",
|
|
12614
|
+
prepopulation: "runtime_log",
|
|
12615
|
+
copyMode: "none",
|
|
12616
|
+
description: "Agent runs are runtime execution records."
|
|
12617
|
+
},
|
|
12618
|
+
{
|
|
12619
|
+
component: "kernel",
|
|
12620
|
+
table: "platformAgentRunToolCalls",
|
|
12621
|
+
prepopulation: "runtime_log",
|
|
12622
|
+
copyMode: "none",
|
|
12623
|
+
description: "Agent-run tool calls are runtime execution records."
|
|
12624
|
+
},
|
|
12625
|
+
{
|
|
12626
|
+
component: "kernel",
|
|
12627
|
+
table: "platformHarnessShadowAudit",
|
|
12628
|
+
prepopulation: "runtime_log",
|
|
12629
|
+
copyMode: "none",
|
|
12630
|
+
description: "Harness shadow audit rows are runtime audit records."
|
|
12631
|
+
},
|
|
12632
|
+
{
|
|
12633
|
+
component: "kernel",
|
|
12634
|
+
table: "publicationRules",
|
|
12635
|
+
prepopulation: "required_template",
|
|
12636
|
+
copyMode: "template_tenant_rewrite",
|
|
12637
|
+
scope: "tenant",
|
|
12638
|
+
uniqueKey: ["tenantId", "workspaceId", "name"],
|
|
12639
|
+
description: "Default publication policy rules are rewritten into each tenant."
|
|
12640
|
+
},
|
|
12641
|
+
{
|
|
12642
|
+
component: "kernel",
|
|
12643
|
+
table: "questionEvidenceLinks",
|
|
12644
|
+
prepopulation: "runtime_data",
|
|
12645
|
+
copyMode: "none",
|
|
12646
|
+
description: "Question-to-evidence links are tenant graph data."
|
|
12647
|
+
},
|
|
12648
|
+
{
|
|
12649
|
+
component: "kernel",
|
|
12650
|
+
table: "researchJobs",
|
|
12651
|
+
prepopulation: "runtime_queue",
|
|
12652
|
+
copyMode: "none",
|
|
12653
|
+
description: "Research job rows are runtime queue items."
|
|
12654
|
+
},
|
|
12655
|
+
{
|
|
12656
|
+
component: "kernel",
|
|
12657
|
+
table: "schemaEnumConfig",
|
|
12658
|
+
prepopulation: "required_template",
|
|
12659
|
+
copyMode: "template_global",
|
|
12660
|
+
scope: "global",
|
|
12661
|
+
uniqueKey: ["category", "value"],
|
|
12662
|
+
description: "Runtime-extensible enum defaults required by SDK graph APIs."
|
|
12663
|
+
},
|
|
12664
|
+
{
|
|
12665
|
+
component: "kernel",
|
|
12666
|
+
table: "stakeholderGroups",
|
|
12667
|
+
prepopulation: "runtime_data",
|
|
12668
|
+
copyMode: "none",
|
|
12669
|
+
description: "Stakeholder groups are tenant decision data."
|
|
12670
|
+
},
|
|
12671
|
+
{
|
|
12672
|
+
component: "kernel",
|
|
12673
|
+
table: "systemLogs",
|
|
12674
|
+
prepopulation: "runtime_log",
|
|
12675
|
+
copyMode: "none",
|
|
12676
|
+
description: "System logs are runtime telemetry."
|
|
12677
|
+
},
|
|
12678
|
+
{
|
|
12679
|
+
component: "kernel",
|
|
12680
|
+
table: "tasks",
|
|
12681
|
+
prepopulation: "runtime_data",
|
|
12682
|
+
copyMode: "none",
|
|
12683
|
+
description: "Tasks are tenant-authored work items."
|
|
12684
|
+
},
|
|
12685
|
+
{
|
|
12686
|
+
component: "kernel",
|
|
12687
|
+
table: "topics",
|
|
12688
|
+
prepopulation: "runtime_bootstrap",
|
|
12689
|
+
copyMode: "none",
|
|
12690
|
+
description: "Default topics are created by tenant provisioning, not copied from templates."
|
|
12691
|
+
},
|
|
12692
|
+
{
|
|
12693
|
+
component: "kernel",
|
|
12694
|
+
table: "workflowDefinitions",
|
|
12695
|
+
prepopulation: "optional_template",
|
|
12696
|
+
copyMode: "none",
|
|
12697
|
+
description: "Table-driven workflow definitions can be template data after the workflow engine leaves legacy mode."
|
|
12698
|
+
},
|
|
12699
|
+
{
|
|
12700
|
+
component: "kernel",
|
|
12701
|
+
table: "workflowPullRequests",
|
|
12702
|
+
prepopulation: "runtime_data",
|
|
12703
|
+
copyMode: "none",
|
|
12704
|
+
description: "Workflow pull requests are tenant workflow data."
|
|
12705
|
+
},
|
|
12706
|
+
{
|
|
12707
|
+
component: "kernel",
|
|
12708
|
+
table: "workflowStages",
|
|
12709
|
+
prepopulation: "optional_template",
|
|
12710
|
+
copyMode: "none",
|
|
12711
|
+
dependsOn: ["workflowDefinitions"],
|
|
12712
|
+
description: "Workflow stages can be template data after workflowDefinitions are enabled for bootstrap copying."
|
|
12713
|
+
},
|
|
12714
|
+
{
|
|
12715
|
+
component: "kernel",
|
|
12716
|
+
table: "worktreeBeliefCluster",
|
|
12717
|
+
prepopulation: "runtime_data",
|
|
12718
|
+
copyMode: "none",
|
|
12719
|
+
description: "Worktree cluster rows link runtime worktrees to runtime beliefs."
|
|
12720
|
+
},
|
|
12721
|
+
{
|
|
12722
|
+
component: "kernel",
|
|
12723
|
+
table: "worktrees",
|
|
12724
|
+
prepopulation: "runtime_data",
|
|
12725
|
+
copyMode: "none",
|
|
12726
|
+
description: "Worktrees are tenant/runtime planning data."
|
|
12727
|
+
},
|
|
12728
|
+
{
|
|
12729
|
+
component: "identity",
|
|
12730
|
+
table: "agents",
|
|
12731
|
+
prepopulation: "runtime_bootstrap",
|
|
12732
|
+
copyMode: "none",
|
|
12733
|
+
description: "Service agents are provisioned per tenant or service, not copied."
|
|
12734
|
+
},
|
|
12735
|
+
{
|
|
12736
|
+
component: "identity",
|
|
12737
|
+
table: "mcpWritePolicy",
|
|
12738
|
+
prepopulation: "required_template",
|
|
12739
|
+
copyMode: "template_global",
|
|
12740
|
+
scope: "global",
|
|
12741
|
+
uniqueKey: ["topicId", "role", "toolCategory"],
|
|
12742
|
+
description: "Global write policy defaults govern service and interactive MCP writes."
|
|
12743
|
+
},
|
|
12744
|
+
{
|
|
12745
|
+
component: "identity",
|
|
12746
|
+
table: "modelCallLogs",
|
|
12747
|
+
prepopulation: "runtime_log",
|
|
12748
|
+
copyMode: "none",
|
|
12749
|
+
description: "Model call logs are runtime telemetry."
|
|
12750
|
+
},
|
|
12751
|
+
{
|
|
12752
|
+
component: "identity",
|
|
12753
|
+
table: "modelFunctionSlots",
|
|
12754
|
+
prepopulation: "required_template",
|
|
12755
|
+
copyMode: "template_global",
|
|
12756
|
+
scope: "global",
|
|
12757
|
+
uniqueKey: ["slot"],
|
|
12758
|
+
description: "Function-to-model slots are required by model runtime resolution."
|
|
12759
|
+
},
|
|
12760
|
+
{
|
|
12761
|
+
component: "identity",
|
|
12762
|
+
table: "modelRegistry",
|
|
12763
|
+
prepopulation: "required_template",
|
|
12764
|
+
copyMode: "template_global",
|
|
12765
|
+
scope: "global",
|
|
12766
|
+
uniqueKey: ["key"],
|
|
12767
|
+
description: "Model catalog defaults are required by model runtime clients."
|
|
12768
|
+
},
|
|
12769
|
+
{
|
|
12770
|
+
component: "identity",
|
|
12771
|
+
table: "modelSlotConfigs",
|
|
12772
|
+
prepopulation: "required_template",
|
|
12773
|
+
copyMode: "template_global",
|
|
12774
|
+
scope: "global",
|
|
12775
|
+
uniqueKey: ["slot"],
|
|
12776
|
+
description: "Slot-level defaults are required before tenant overrides exist."
|
|
12777
|
+
},
|
|
12778
|
+
{
|
|
12779
|
+
component: "identity",
|
|
12780
|
+
table: "platformAudienceGrants",
|
|
12781
|
+
prepopulation: "runtime_data",
|
|
12782
|
+
copyMode: "none",
|
|
12783
|
+
description: "Audience grants are principal/group-specific access rows."
|
|
12784
|
+
},
|
|
12785
|
+
{
|
|
12786
|
+
component: "identity",
|
|
12787
|
+
table: "platformAudiences",
|
|
12788
|
+
prepopulation: "required_template",
|
|
12789
|
+
copyMode: "template_tenant_rewrite",
|
|
12790
|
+
scope: "tenant",
|
|
12791
|
+
uniqueKey: ["tenantId", "workspaceId", "audienceKey"],
|
|
12792
|
+
description: "Default tenant audience taxonomy rows are rewritten into each tenant."
|
|
12793
|
+
},
|
|
12794
|
+
{
|
|
12795
|
+
component: "identity",
|
|
12796
|
+
table: "platformPolicyDecisionLogs",
|
|
12797
|
+
prepopulation: "runtime_log",
|
|
12798
|
+
copyMode: "none",
|
|
12799
|
+
description: "Policy decisions are runtime audit logs."
|
|
12800
|
+
},
|
|
12801
|
+
{
|
|
12802
|
+
component: "identity",
|
|
12803
|
+
table: "projectGrants",
|
|
12804
|
+
prepopulation: "runtime_data",
|
|
12805
|
+
copyMode: "none",
|
|
12806
|
+
description: "Project/topic grants are principal or group-specific access rows."
|
|
12807
|
+
},
|
|
12808
|
+
{
|
|
12809
|
+
component: "identity",
|
|
12810
|
+
table: "reasoningPermissions",
|
|
12811
|
+
prepopulation: "runtime_data",
|
|
12812
|
+
copyMode: "none",
|
|
12813
|
+
description: "Reasoning permissions are principal-specific policy rows."
|
|
12814
|
+
},
|
|
12815
|
+
{
|
|
12816
|
+
component: "identity",
|
|
12817
|
+
table: "tenantApiKeys",
|
|
12818
|
+
prepopulation: "runtime_secret",
|
|
12819
|
+
copyMode: "none",
|
|
12820
|
+
description: "API keys are tenant credentials and must never be copied."
|
|
12821
|
+
},
|
|
12822
|
+
{
|
|
12823
|
+
component: "identity",
|
|
12824
|
+
table: "tenantConfig",
|
|
12825
|
+
prepopulation: "required_template",
|
|
12826
|
+
copyMode: "template_tenant_rewrite",
|
|
12827
|
+
scope: "tenant",
|
|
12828
|
+
uniqueKey: ["tenantId"],
|
|
12829
|
+
description: "Tenant-local config defaults are rewritten during bootstrap."
|
|
12830
|
+
},
|
|
12831
|
+
{
|
|
12832
|
+
component: "identity",
|
|
12833
|
+
table: "tenantIntegrations",
|
|
12834
|
+
prepopulation: "required_template",
|
|
12835
|
+
copyMode: "template_tenant_rewrite",
|
|
12836
|
+
scope: "tenant",
|
|
12837
|
+
uniqueKey: ["tenantId", "integrationKey"],
|
|
12838
|
+
description: "Non-secret integration descriptors are rewritten into each tenant."
|
|
12839
|
+
},
|
|
12840
|
+
{
|
|
12841
|
+
component: "identity",
|
|
12842
|
+
table: "tenantModelSlotBindings",
|
|
12843
|
+
prepopulation: "runtime_secret",
|
|
12844
|
+
copyMode: "none",
|
|
12845
|
+
description: "Tenant model slot bindings reference provider secrets and are runtime-only."
|
|
12846
|
+
},
|
|
12847
|
+
{
|
|
12848
|
+
component: "identity",
|
|
12849
|
+
table: "tenantPolicies",
|
|
12850
|
+
prepopulation: "required_template",
|
|
12851
|
+
copyMode: "template_tenant_rewrite",
|
|
12852
|
+
scope: "tenant",
|
|
12853
|
+
uniqueKey: ["tenantId", "workspaceId", "roleName"],
|
|
12854
|
+
description: "Default tenant policy roles are rewritten during bootstrap."
|
|
12855
|
+
},
|
|
12856
|
+
{
|
|
12857
|
+
component: "identity",
|
|
12858
|
+
table: "tenantProviderSecrets",
|
|
12859
|
+
prepopulation: "runtime_secret",
|
|
12860
|
+
copyMode: "none",
|
|
12861
|
+
description: "Provider secrets are credentials and must never be copied."
|
|
12862
|
+
},
|
|
12863
|
+
{
|
|
12864
|
+
component: "identity",
|
|
12865
|
+
table: "tenantProxyGatewayUsage",
|
|
12866
|
+
prepopulation: "runtime_log",
|
|
12867
|
+
copyMode: "none",
|
|
12868
|
+
description: "Proxy gateway usage rows are runtime telemetry."
|
|
12869
|
+
},
|
|
12870
|
+
{
|
|
12871
|
+
component: "identity",
|
|
12872
|
+
table: "tenantProxyTokenMints",
|
|
12873
|
+
prepopulation: "runtime_secret",
|
|
12874
|
+
copyMode: "none",
|
|
12875
|
+
description: "Proxy token mints are ephemeral secret-bearing runtime rows."
|
|
12876
|
+
},
|
|
12877
|
+
{
|
|
12878
|
+
component: "identity",
|
|
12879
|
+
table: "tenantSandboxAuditEvents",
|
|
12880
|
+
prepopulation: "runtime_log",
|
|
12881
|
+
copyMode: "none",
|
|
12882
|
+
description: "Sandbox audit rows are runtime security logs."
|
|
12883
|
+
},
|
|
12884
|
+
{
|
|
12885
|
+
component: "identity",
|
|
12886
|
+
table: "tenantSecrets",
|
|
12887
|
+
prepopulation: "runtime_secret",
|
|
12888
|
+
copyMode: "none",
|
|
12889
|
+
description: "Tenant secrets are credentials and must never be copied."
|
|
12890
|
+
},
|
|
12891
|
+
{
|
|
12892
|
+
component: "identity",
|
|
12893
|
+
table: "toolAcls",
|
|
12894
|
+
prepopulation: "required_template",
|
|
12895
|
+
copyMode: "template_global",
|
|
12896
|
+
scope: "global",
|
|
12897
|
+
uniqueKey: ["role", "toolName"],
|
|
12898
|
+
description: "Default role-to-tool grants are required for SDK/MCP tool access."
|
|
12899
|
+
},
|
|
12900
|
+
{
|
|
12901
|
+
component: "identity",
|
|
12902
|
+
table: "toolRegistry",
|
|
12903
|
+
prepopulation: "required_template",
|
|
12904
|
+
copyMode: "template_global",
|
|
12905
|
+
scope: "global",
|
|
12906
|
+
uniqueKey: ["toolName"],
|
|
12907
|
+
description: "Core tool catalog rows are required before pack or tenant tools exist."
|
|
12908
|
+
},
|
|
12909
|
+
{
|
|
12910
|
+
component: "identity",
|
|
12911
|
+
table: "users",
|
|
12912
|
+
prepopulation: "runtime_bootstrap",
|
|
12913
|
+
copyMode: "none",
|
|
12914
|
+
description: "Users are created from Clerk/MC principal resolution, not copied."
|
|
11851
12915
|
}
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
const nextPath = [...path3, prop];
|
|
11860
|
-
const resolved = resolveApiPath(getBinding(), which, nextPath);
|
|
11861
|
-
return resolved === void 0 ? makeProxy(which, nextPath) : resolved;
|
|
11862
|
-
}
|
|
11863
|
-
});
|
|
11864
|
-
}
|
|
11865
|
-
var api = makeProxy("api");
|
|
11866
|
-
makeProxy("components");
|
|
11867
|
-
makeProxy("internal");
|
|
12916
|
+
];
|
|
12917
|
+
TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
|
|
12918
|
+
isCopyableSeedRequirement
|
|
12919
|
+
);
|
|
12920
|
+
TENANT_BOOTSTRAP_TABLE_REQUIREMENTS.filter(
|
|
12921
|
+
(entry) => !isCopyableSeedRequirement(entry)
|
|
12922
|
+
).map((entry) => entry.table);
|
|
11868
12923
|
|
|
11869
|
-
//
|
|
11870
|
-
|
|
11871
|
-
api: api$1,
|
|
11872
|
-
components: components,
|
|
11873
|
-
internal: internal
|
|
11874
|
-
});
|
|
11875
|
-
var api2 = api$1;
|
|
11876
|
-
var components2 = components;
|
|
11877
|
-
function isQuietMcpBoot() {
|
|
11878
|
-
return process.env.LUCERN_MCP_QUIET === "1";
|
|
11879
|
-
}
|
|
11880
|
-
function logMcpInfo(message) {
|
|
11881
|
-
if (!isQuietMcpBoot()) {
|
|
11882
|
-
console.error(message);
|
|
11883
|
-
}
|
|
11884
|
-
}
|
|
12924
|
+
// ../contracts/src/v1/topics/v1.ts
|
|
12925
|
+
var ROOT_TOPIC_ID = "n17tm38rwet7wqgzrmwahyt1z582590y";
|
|
11885
12926
|
|
|
11886
|
-
// ../../apps/mcp-server/src/
|
|
11887
|
-
var
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
const client = new ConvexHttpClient(url);
|
|
11893
|
-
client.setAdminAuth(deployKey);
|
|
11894
|
-
return client;
|
|
11895
|
-
}
|
|
11896
|
-
var _lucernClient = null;
|
|
11897
|
-
function getLucernClient() {
|
|
11898
|
-
const scoped = _requestScopedClient.getStore();
|
|
11899
|
-
if (scoped) {
|
|
11900
|
-
return scoped;
|
|
11901
|
-
}
|
|
11902
|
-
if (_lucernClient) {
|
|
11903
|
-
return _lucernClient;
|
|
11904
|
-
}
|
|
11905
|
-
const url = process.env.LUCERN_CONVEX_URL;
|
|
11906
|
-
const key = process.env.LUCERN_DEPLOY_KEY;
|
|
11907
|
-
if (!url) {
|
|
11908
|
-
throw new Error(
|
|
11909
|
-
"LUCERN_CONVEX_URL is required. Ensure LUCERN_API_KEY is set in .env.lucern"
|
|
11910
|
-
);
|
|
11911
|
-
}
|
|
11912
|
-
if (!key) {
|
|
11913
|
-
throw new Error(
|
|
11914
|
-
"LUCERN_DEPLOY_KEY is required. Ensure LUCERN_API_KEY is set in .env.lucern"
|
|
11915
|
-
);
|
|
11916
|
-
}
|
|
11917
|
-
_lucernClient = new ConvexHttpClient(url);
|
|
11918
|
-
_lucernClient.setAdminAuth(key);
|
|
11919
|
-
logMcpInfo(`[lucern-graph] Lucern client initialized \u2192 ${url}`);
|
|
11920
|
-
return _lucernClient;
|
|
11921
|
-
}
|
|
11922
|
-
var MCP_META_KEYS = [
|
|
11923
|
-
"mcpSessionId",
|
|
11924
|
-
"mcpToolName",
|
|
11925
|
-
"runtimeToolName",
|
|
11926
|
-
"runtimePackKey",
|
|
11927
|
-
"runtimePackInstallScope"
|
|
11928
|
-
];
|
|
11929
|
-
var mutationRuntimeCache = /* @__PURE__ */ new Map();
|
|
11930
|
-
var packInstallScopeCache = /* @__PURE__ */ new Map();
|
|
11931
|
-
async function resolvePackInstallScope(packKey) {
|
|
11932
|
-
const normalizedPackKey = packKey.trim();
|
|
11933
|
-
if (!normalizedPackKey) {
|
|
11934
|
-
return;
|
|
11935
|
-
}
|
|
11936
|
-
let cached = packInstallScopeCache.get(normalizedPackKey);
|
|
11937
|
-
if (!cached) {
|
|
11938
|
-
cached = (async () => {
|
|
11939
|
-
const packDefinition = await mcAdminQuery(
|
|
11940
|
-
"packs:getPackDefinition",
|
|
11941
|
-
{
|
|
11942
|
-
packKey: normalizedPackKey
|
|
11943
|
-
}
|
|
11944
|
-
);
|
|
11945
|
-
const installScope = packDefinition?.installScope;
|
|
11946
|
-
if (installScope === "tenant" || installScope === "workspace") {
|
|
11947
|
-
return installScope;
|
|
11948
|
-
}
|
|
11949
|
-
throw new Error(
|
|
11950
|
-
`[mcp-runtime] Pack "${normalizedPackKey}" is missing a valid installScope`
|
|
11951
|
-
);
|
|
11952
|
-
})();
|
|
11953
|
-
packInstallScopeCache.set(normalizedPackKey, cached);
|
|
11954
|
-
}
|
|
11955
|
-
return await cached;
|
|
11956
|
-
}
|
|
11957
|
-
async function resolveMutationRuntimeFields(toolName) {
|
|
11958
|
-
if (typeof toolName !== "string" || toolName.trim().length === 0) {
|
|
11959
|
-
return null;
|
|
11960
|
-
}
|
|
11961
|
-
const normalizedToolName = toolName.trim();
|
|
11962
|
-
let cached = mutationRuntimeCache.get(normalizedToolName);
|
|
11963
|
-
if (!cached) {
|
|
11964
|
-
cached = (async () => {
|
|
11965
|
-
const tools = await adminQuery("toolAccess:listToolRegistry", {});
|
|
11966
|
-
const tool = tools.find(
|
|
11967
|
-
(candidate) => candidate?.toolName === normalizedToolName && candidate?.isActive !== false && candidate?.status !== "deprecated" && candidate?.status !== "disabled"
|
|
11968
|
-
);
|
|
11969
|
-
const packKey = typeof tool?.packKey === "string" ? tool.packKey.trim() : "";
|
|
11970
|
-
if (!packKey) {
|
|
11971
|
-
return { runtimeToolName: normalizedToolName };
|
|
11972
|
-
}
|
|
11973
|
-
return {
|
|
11974
|
-
runtimeToolName: normalizedToolName,
|
|
11975
|
-
runtimePackKey: packKey,
|
|
11976
|
-
runtimePackInstallScope: await resolvePackInstallScope(packKey)
|
|
11977
|
-
};
|
|
11978
|
-
})();
|
|
11979
|
-
mutationRuntimeCache.set(normalizedToolName, cached);
|
|
11980
|
-
}
|
|
11981
|
-
return await cached;
|
|
11982
|
-
}
|
|
11983
|
-
async function adminMutation(fn, args) {
|
|
11984
|
-
const cleanArgs = { ...args };
|
|
11985
|
-
if (cleanArgs.runtimeToolName === void 0 && cleanArgs.runtimePackKey === void 0 && cleanArgs.runtimePackInstallScope === void 0) {
|
|
11986
|
-
const runtimeFields = await resolveMutationRuntimeFields(args?.mcpToolName);
|
|
11987
|
-
if (runtimeFields) {
|
|
11988
|
-
Object.assign(cleanArgs, runtimeFields);
|
|
11989
|
-
}
|
|
11990
|
-
}
|
|
11991
|
-
for (const key of MCP_META_KEYS) {
|
|
11992
|
-
delete cleanArgs[key];
|
|
11993
|
-
}
|
|
11994
|
-
return getLucernClient().mutation(fn, cleanArgs);
|
|
11995
|
-
}
|
|
11996
|
-
async function adminQuery(fn, args) {
|
|
11997
|
-
return getLucernClient().query(fn, args);
|
|
11998
|
-
}
|
|
11999
|
-
var _mcClient = null;
|
|
12000
|
-
var _mcClientChecked = false;
|
|
12001
|
-
function getMcClient() {
|
|
12002
|
-
if (_mcClientChecked) {
|
|
12003
|
-
return _mcClient;
|
|
12004
|
-
}
|
|
12005
|
-
const url = process.env.MC_CONVEX_URL;
|
|
12006
|
-
const key = process.env.MC_DEPLOY_KEY;
|
|
12007
|
-
if (url && key) {
|
|
12008
|
-
_mcClient = new ConvexHttpClient(url);
|
|
12009
|
-
_mcClient.setAdminAuth(key);
|
|
12010
|
-
logMcpInfo(`[lucern-graph] Master Control client initialized \u2192 ${url}`);
|
|
12011
|
-
} else {
|
|
12012
|
-
logMcpInfo(
|
|
12013
|
-
"[lucern-graph] Master Control client not configured (no MC_CONVEX_URL). Methodology packs will use hardcoded fallback."
|
|
12014
|
-
);
|
|
12015
|
-
}
|
|
12016
|
-
_mcClientChecked = true;
|
|
12017
|
-
return _mcClient;
|
|
12018
|
-
}
|
|
12019
|
-
async function mcAdminQuery(fn, args) {
|
|
12020
|
-
const c = getMcClient();
|
|
12021
|
-
if (!c) {
|
|
12022
|
-
throw new Error(
|
|
12023
|
-
"Master Control client not configured (set MC_CONVEX_URL + MC_DEPLOY_KEY)"
|
|
12024
|
-
);
|
|
12025
|
-
}
|
|
12026
|
-
return c.query(fn, args);
|
|
12927
|
+
// ../../apps/mcp-server/src/runtime-context.ts
|
|
12928
|
+
var runtimeContext = Object.freeze({
|
|
12929
|
+
transportKind: "stdio"
|
|
12930
|
+
});
|
|
12931
|
+
function getMcpRuntimeContext() {
|
|
12932
|
+
return runtimeContext;
|
|
12027
12933
|
}
|
|
12028
|
-
process.env.LUCERN_AGENT_IDENTITY || "agent:claude-code";
|
|
12029
|
-
crypto.randomUUID();
|
|
12030
12934
|
|
|
12031
12935
|
// ../../apps/mcp-server/src/scope.ts
|
|
12032
12936
|
var defaultTopicId = null;
|
|
12033
12937
|
var PUBLIC_TOPIC_PREFIX = "top_";
|
|
12938
|
+
function encodePublicTopicId(topicId) {
|
|
12939
|
+
if (!isNonEmptyString(topicId)) {
|
|
12940
|
+
return void 0;
|
|
12941
|
+
}
|
|
12942
|
+
return topicId.startsWith(PUBLIC_TOPIC_PREFIX) ? topicId : `${PUBLIC_TOPIC_PREFIX}${topicId}`;
|
|
12943
|
+
}
|
|
12034
12944
|
function decodePublicTopicId(topicId) {
|
|
12035
12945
|
if (!isNonEmptyString(topicId)) {
|
|
12036
12946
|
return void 0;
|
|
@@ -12056,9 +12966,55 @@ function readLucernJson() {
|
|
|
12056
12966
|
return null;
|
|
12057
12967
|
}
|
|
12058
12968
|
}
|
|
12969
|
+
function writeLucernJson(context) {
|
|
12970
|
+
try {
|
|
12971
|
+
const previous = readLucernJson() ?? {};
|
|
12972
|
+
const topicId = encodePublicTopicId(context.topicId ?? previous.topicId);
|
|
12973
|
+
const topicName = context.topicName ?? previous.topicName;
|
|
12974
|
+
const normalized = {
|
|
12975
|
+
...previous,
|
|
12976
|
+
...context,
|
|
12977
|
+
...topicId ? { topicId, projectId: topicId } : {},
|
|
12978
|
+
...topicName ? { topicName, projectName: topicName } : {},
|
|
12979
|
+
lastUpdated: context.lastUpdated ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
12980
|
+
};
|
|
12981
|
+
fs.writeFileSync(
|
|
12982
|
+
LUCERN_JSON_PATH,
|
|
12983
|
+
`${JSON.stringify(normalized, null, 2)}
|
|
12984
|
+
`,
|
|
12985
|
+
"utf-8"
|
|
12986
|
+
);
|
|
12987
|
+
} catch {
|
|
12988
|
+
}
|
|
12989
|
+
}
|
|
12059
12990
|
function isNonEmptyString(value) {
|
|
12060
12991
|
return typeof value === "string" && value.trim().length > 0;
|
|
12061
12992
|
}
|
|
12993
|
+
function getLucernClient() {
|
|
12994
|
+
const client = getMcpRuntimeContext().lucernClient;
|
|
12995
|
+
if (!client) {
|
|
12996
|
+
throw new Error("[scope] Lucern SDK client is not initialized.");
|
|
12997
|
+
}
|
|
12998
|
+
return client;
|
|
12999
|
+
}
|
|
13000
|
+
function unwrapGatewayData(value) {
|
|
13001
|
+
if (!value || typeof value !== "object") {
|
|
13002
|
+
return null;
|
|
13003
|
+
}
|
|
13004
|
+
const record = value;
|
|
13005
|
+
const data = record.data;
|
|
13006
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
13007
|
+
return data;
|
|
13008
|
+
}
|
|
13009
|
+
return record;
|
|
13010
|
+
}
|
|
13011
|
+
function readRecordId(record) {
|
|
13012
|
+
if (!record) {
|
|
13013
|
+
return void 0;
|
|
13014
|
+
}
|
|
13015
|
+
const candidate = record._id ?? record.id ?? record.topicId ?? record.nodeId;
|
|
13016
|
+
return isNonEmptyString(candidate) ? candidate : void 0;
|
|
13017
|
+
}
|
|
12062
13018
|
function readTopicMappedProjectId(topic) {
|
|
12063
13019
|
const metadata = topic.metadata || {};
|
|
12064
13020
|
const candidate = metadata.legacyProjectId || metadata.projectId || metadata.scopeProjectId;
|
|
@@ -12070,27 +13026,23 @@ async function tryGetTopicById(topicId) {
|
|
|
12070
13026
|
return null;
|
|
12071
13027
|
}
|
|
12072
13028
|
try {
|
|
12073
|
-
|
|
12074
|
-
id: normalizedTopicId
|
|
12075
|
-
});
|
|
12076
|
-
return topic || null;
|
|
13029
|
+
return unwrapGatewayData(await getLucernClient().topics.get(normalizedTopicId));
|
|
12077
13030
|
} catch {
|
|
12078
13031
|
return null;
|
|
12079
13032
|
}
|
|
12080
13033
|
}
|
|
12081
13034
|
async function tryGetNodeById(nodeId) {
|
|
12082
13035
|
try {
|
|
12083
|
-
|
|
12084
|
-
nodeId
|
|
12085
|
-
});
|
|
12086
|
-
return node || null;
|
|
13036
|
+
return unwrapGatewayData(await getLucernClient().nodes.get({ nodeId }));
|
|
12087
13037
|
} catch {
|
|
12088
13038
|
return null;
|
|
12089
13039
|
}
|
|
12090
13040
|
}
|
|
12091
13041
|
async function findTopicByMappedProjectId(legacyScopeId) {
|
|
12092
13042
|
try {
|
|
12093
|
-
const
|
|
13043
|
+
const response = await getLucernClient().topics.list({});
|
|
13044
|
+
const data = unwrapGatewayData(response);
|
|
13045
|
+
const topics2 = Array.isArray(data?.topics) ? data.topics : Array.isArray(data?.items) ? data.items : [];
|
|
12094
13046
|
return topics2.find((topic) => readTopicMappedProjectId(topic) === legacyScopeId) || null;
|
|
12095
13047
|
} catch {
|
|
12096
13048
|
return null;
|
|
@@ -12124,7 +13076,7 @@ async function resolveTopicScopeId(scopeId, toolName) {
|
|
|
12124
13076
|
if (!resolved) {
|
|
12125
13077
|
const mappedTopic = normalizedScopeId ? await findTopicByMappedProjectId(normalizedScopeId) : null;
|
|
12126
13078
|
if (mappedTopic) {
|
|
12127
|
-
resolved =
|
|
13079
|
+
resolved = readRecordId(mappedTopic);
|
|
12128
13080
|
}
|
|
12129
13081
|
}
|
|
12130
13082
|
if (!resolved) {
|
|
@@ -12323,315 +13275,38 @@ var beliefHandlers = {
|
|
|
12323
13275
|
}
|
|
12324
13276
|
};
|
|
12325
13277
|
|
|
12326
|
-
// ../../apps/mcp-server/src/handlers/bootstrap
|
|
12327
|
-
function
|
|
12328
|
-
return
|
|
13278
|
+
// ../../apps/mcp-server/src/handlers/bootstrap.ts
|
|
13279
|
+
function readString2(value) {
|
|
13280
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
12329
13281
|
}
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
for (const nodeId of nodeIds) {
|
|
12333
|
-
try {
|
|
12334
|
-
const node = await adminQuery(api2.epistemicNodes.get, {
|
|
12335
|
-
nodeId
|
|
12336
|
-
});
|
|
12337
|
-
if (!node) {
|
|
12338
|
-
continue;
|
|
12339
|
-
}
|
|
12340
|
-
results.push({
|
|
12341
|
-
nodeId,
|
|
12342
|
-
text: String(node.canonicalText || "").slice(0, 200),
|
|
12343
|
-
confidence: typeof node.confidence === "number" ? node.confidence : null
|
|
12344
|
-
});
|
|
12345
|
-
} catch {
|
|
12346
|
-
}
|
|
12347
|
-
}
|
|
12348
|
-
return results;
|
|
13282
|
+
function readNullableNumber(value) {
|
|
13283
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
12349
13284
|
}
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
try {
|
|
12354
|
-
const node = await adminQuery(api2.epistemicNodes.get, {
|
|
12355
|
-
nodeId
|
|
12356
|
-
});
|
|
12357
|
-
if (!node) {
|
|
12358
|
-
continue;
|
|
12359
|
-
}
|
|
12360
|
-
const metadata = node.metadata || {};
|
|
12361
|
-
results.push({
|
|
12362
|
-
nodeId,
|
|
12363
|
-
text: String(node.canonicalText || "").slice(0, 200),
|
|
12364
|
-
status: String(metadata.questionStatus || node.status || "open"),
|
|
12365
|
-
priority: String(metadata.priority || "medium")
|
|
12366
|
-
});
|
|
12367
|
-
} catch {
|
|
12368
|
-
}
|
|
12369
|
-
}
|
|
12370
|
-
return results;
|
|
12371
|
-
}
|
|
12372
|
-
async function beginBuildSession(args) {
|
|
12373
|
-
const worktreeId = typeof args.worktreeId === "string" ? args.worktreeId : void 0;
|
|
12374
|
-
if (!worktreeId) {
|
|
12375
|
-
throw new Error("[begin_build_session] worktreeId is required");
|
|
12376
|
-
}
|
|
12377
|
-
const branch = typeof args.branch === "string" && args.branch.trim().length > 0 ? args.branch.trim() : void 0;
|
|
12378
|
-
const branchBase = typeof args.branchBase === "string" && args.branchBase.trim().length > 0 ? args.branchBase.trim() : "staging";
|
|
12379
|
-
const prBase = typeof args.prBase === "string" && args.prBase.trim().length > 0 ? args.prBase.trim() : "staging";
|
|
12380
|
-
const sessionMode = typeof args.sessionMode === "string" && args.sessionMode.trim().length > 0 ? args.sessionMode.trim() : "async";
|
|
12381
|
-
const activateIfPlanning = args.activateIfPlanning !== false;
|
|
12382
|
-
const worktree = await adminQuery(components2.lucern.worktrees.get, {
|
|
12383
|
-
worktreeId
|
|
12384
|
-
});
|
|
12385
|
-
if (!worktree) {
|
|
12386
|
-
throw new Error(`Worktree ${worktreeId} not found`);
|
|
12387
|
-
}
|
|
12388
|
-
const worktreeName = String(worktree.name || "Untitled");
|
|
12389
|
-
const topicId = String(worktree.topicId || "");
|
|
12390
|
-
const campaign = typeof worktree.campaign === "number" ? worktree.campaign : null;
|
|
12391
|
-
const lane = String(worktree.lane || "unlaned");
|
|
12392
|
-
const laneOrderInCampaign = typeof worktree.laneOrderInCampaign === "number" ? worktree.laneOrderInCampaign : null;
|
|
12393
|
-
const orderInLane = typeof worktree.orderInLane === "number" ? worktree.orderInLane : null;
|
|
12394
|
-
const gate = String(worktree.gate || "");
|
|
12395
|
-
const hypothesis = String(worktree.hypothesis || worktree.beliefFocus || "");
|
|
12396
|
-
let status = String(worktree.status || "planning");
|
|
12397
|
-
const dependsOn = worktree.dependsOn || [];
|
|
12398
|
-
const blocks = worktree.blocks || [];
|
|
12399
|
-
const targetBeliefIds = worktree.targetBeliefIds || [];
|
|
12400
|
-
const targetQuestionIds = worktree.targetQuestionIds || [];
|
|
12401
|
-
if (activateIfPlanning && status === "planning") {
|
|
12402
|
-
try {
|
|
12403
|
-
await adminMutation(components2.lucern.worktrees.activate, {
|
|
12404
|
-
worktreeId
|
|
12405
|
-
});
|
|
12406
|
-
status = "active";
|
|
12407
|
-
} catch {
|
|
12408
|
-
}
|
|
12409
|
-
}
|
|
12410
|
-
let topicName = "Unknown";
|
|
12411
|
-
try {
|
|
12412
|
-
const topic = await adminQuery(components2.lucern.topics.get, {
|
|
12413
|
-
id: topicId
|
|
12414
|
-
});
|
|
12415
|
-
if (topic) {
|
|
12416
|
-
topicName = String(topic.name || "Unknown");
|
|
12417
|
-
}
|
|
12418
|
-
} catch {
|
|
12419
|
-
}
|
|
12420
|
-
const allBeliefs = await resolveBeliefs(targetBeliefIds);
|
|
12421
|
-
const topBeliefs = allBeliefs.slice().sort((left, right) => (right.confidence ?? -1) - (left.confidence ?? -1)).slice(0, 8);
|
|
12422
|
-
const allQuestions = await resolveQuestions(targetQuestionIds);
|
|
12423
|
-
const openQuestions = [];
|
|
12424
|
-
const resolvedDecisions = [];
|
|
12425
|
-
for (const question of allQuestions) {
|
|
12426
|
-
const questionStatus = question.status.toLowerCase();
|
|
12427
|
-
if (questionStatus === "answered" || questionStatus === "resolved") {
|
|
12428
|
-
let decision = "(decision recorded \u2014 call get_answer for details)";
|
|
12429
|
-
try {
|
|
12430
|
-
const answer = await adminQuery(
|
|
12431
|
-
api2.epistemicAnswers.getLatestForQuestion,
|
|
12432
|
-
{
|
|
12433
|
-
questionNodeId: question.nodeId
|
|
12434
|
-
}
|
|
12435
|
-
);
|
|
12436
|
-
if (answer) {
|
|
12437
|
-
decision = String(
|
|
12438
|
-
answer.answerText || answer.canonicalText || decision
|
|
12439
|
-
).slice(0, 200);
|
|
12440
|
-
}
|
|
12441
|
-
} catch {
|
|
12442
|
-
try {
|
|
12443
|
-
const node = await adminQuery(api2.epistemicNodes.get, {
|
|
12444
|
-
nodeId: question.nodeId
|
|
12445
|
-
});
|
|
12446
|
-
if (node?._id) {
|
|
12447
|
-
const answer = await adminQuery(
|
|
12448
|
-
api2.epistemicAnswers.getLatestForQuestion,
|
|
12449
|
-
{
|
|
12450
|
-
questionNodeId: node._id
|
|
12451
|
-
}
|
|
12452
|
-
);
|
|
12453
|
-
if (answer) {
|
|
12454
|
-
decision = String(
|
|
12455
|
-
answer.answerText || answer.canonicalText || decision
|
|
12456
|
-
).slice(0, 200);
|
|
12457
|
-
}
|
|
12458
|
-
}
|
|
12459
|
-
} catch {
|
|
12460
|
-
}
|
|
12461
|
-
}
|
|
12462
|
-
resolvedDecisions.push({
|
|
12463
|
-
question: question.text.slice(0, 150),
|
|
12464
|
-
decision
|
|
12465
|
-
});
|
|
12466
|
-
continue;
|
|
12467
|
-
}
|
|
12468
|
-
openQuestions.push({
|
|
12469
|
-
nodeId: question.nodeId,
|
|
12470
|
-
text: question.text,
|
|
12471
|
-
priority: question.priority
|
|
12472
|
-
});
|
|
12473
|
-
}
|
|
12474
|
-
try {
|
|
12475
|
-
const topicQuestions = await adminQuery(api2.epistemicQuestions.getByTopic, {
|
|
12476
|
-
topicId,
|
|
12477
|
-
userId: "system",
|
|
12478
|
-
limit: 20
|
|
12479
|
-
}).catch(() => []);
|
|
12480
|
-
for (const question of Array.isArray(topicQuestions) ? topicQuestions : []) {
|
|
12481
|
-
const metadata = question.metadata || {};
|
|
12482
|
-
const questionStatus = String(
|
|
12483
|
-
metadata.questionStatus || question.status || "open"
|
|
12484
|
-
).toLowerCase();
|
|
12485
|
-
if ((questionStatus === "open" || questionStatus === "in_progress") && !targetQuestionIds.includes(String(question._id))) {
|
|
12486
|
-
openQuestions.push({
|
|
12487
|
-
nodeId: String(question._id),
|
|
12488
|
-
text: String(question.canonicalText || "").slice(0, 200),
|
|
12489
|
-
priority: String(metadata.priority || "medium")
|
|
12490
|
-
});
|
|
12491
|
-
}
|
|
12492
|
-
}
|
|
12493
|
-
} catch {
|
|
13285
|
+
function refreshLucernContextFromBuildSession(payload, args) {
|
|
13286
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
13287
|
+
return;
|
|
12494
13288
|
}
|
|
12495
|
-
const
|
|
12496
|
-
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
});
|
|
12501
|
-
dependencies.push({
|
|
12502
|
-
worktreeId: dependencyId,
|
|
12503
|
-
title: String(dependency?.name || "Unknown"),
|
|
12504
|
-
status: String(dependency?.status || "unknown")
|
|
12505
|
-
});
|
|
12506
|
-
} catch {
|
|
12507
|
-
dependencies.push({
|
|
12508
|
-
worktreeId: dependencyId,
|
|
12509
|
-
title: "Unknown",
|
|
12510
|
-
status: "unknown"
|
|
12511
|
-
});
|
|
12512
|
-
}
|
|
12513
|
-
}
|
|
12514
|
-
const unblocks = [];
|
|
12515
|
-
for (const blockedId of blocks.slice(0, 5)) {
|
|
12516
|
-
try {
|
|
12517
|
-
const blocked = await adminQuery(components2.lucern.worktrees.get, {
|
|
12518
|
-
worktreeId: blockedId
|
|
12519
|
-
});
|
|
12520
|
-
unblocks.push({
|
|
12521
|
-
worktreeId: blockedId,
|
|
12522
|
-
title: String(blocked?.name || "Unknown")
|
|
12523
|
-
});
|
|
12524
|
-
} catch {
|
|
12525
|
-
unblocks.push({
|
|
12526
|
-
worktreeId: blockedId,
|
|
12527
|
-
title: "Unknown"
|
|
12528
|
-
});
|
|
12529
|
-
}
|
|
12530
|
-
}
|
|
12531
|
-
const effectiveBranch = branch || `codex/${slugify(worktreeName)}`;
|
|
12532
|
-
const incompleteDependencies = dependencies.filter(
|
|
12533
|
-
(dependency) => dependency.status !== "completed" && dependency.status !== "merged"
|
|
12534
|
-
);
|
|
12535
|
-
const mergeOrderNotes = incompleteDependencies.length > 0 ? `Blocked by: ${incompleteDependencies.map((dependency) => dependency.title).join(", ")}` : "none";
|
|
12536
|
-
const requiredDocs = [
|
|
12537
|
-
"docs/api/EK-13-api-sdk-architecture.md",
|
|
12538
|
-
"docs/api/EK-13.1.5-repo-architecture-blueprint.md",
|
|
12539
|
-
"docs/api/EK-13.1-contract-authority.md",
|
|
12540
|
-
"docs/development/handoff-contract.md"
|
|
12541
|
-
];
|
|
12542
|
-
const focus = hypothesis ? `${hypothesis.split(".")[0]}.` : `Complete ${worktreeName}`;
|
|
12543
|
-
const exitCriteria = gate ? [`Gate: ${gate}`] : [];
|
|
12544
|
-
exitCriteria.push(
|
|
12545
|
-
"All namespace surfaces end-to-end: contract \u2192 domain \u2192 HTTP \u2192 SDK \u2192 MCP \u2192 test",
|
|
12546
|
-
"All code lands in target-state paths under lucern/",
|
|
12547
|
-
"PR targets staging, not main"
|
|
12548
|
-
);
|
|
12549
|
-
const keyFiles = [
|
|
12550
|
-
"app/api/platform/v1/_lib/gateway.ts",
|
|
12551
|
-
"modules/access-control/src/principalContext.ts",
|
|
12552
|
-
"lucern/packages/sdk/src/coreClient.ts",
|
|
12553
|
-
"lucern/packages/sdk/src/identityClient.ts",
|
|
12554
|
-
"lucern/contracts/src/sdk-methods.contract.ts",
|
|
12555
|
-
"app/api/platform/v1/identity/"
|
|
12556
|
-
];
|
|
12557
|
-
const pillarKeywords = [
|
|
12558
|
-
"Pillar 1",
|
|
12559
|
-
"Pillar 2",
|
|
12560
|
-
"Pillar 3",
|
|
12561
|
-
"Pillar 4",
|
|
12562
|
-
"Pillar 5",
|
|
12563
|
-
"Pillar 6",
|
|
12564
|
-
"Pillar 7",
|
|
12565
|
-
"Pillar 8",
|
|
12566
|
-
"8 innovation pillars"
|
|
12567
|
-
];
|
|
12568
|
-
const pillarBeliefs = [];
|
|
12569
|
-
for (const belief of allBeliefs) {
|
|
12570
|
-
for (const keyword of pillarKeywords) {
|
|
12571
|
-
if (!belief.text.includes(keyword)) {
|
|
12572
|
-
continue;
|
|
12573
|
-
}
|
|
12574
|
-
const pillarMatch = belief.text.match(/Pillar \d+ \([^)]+\)/);
|
|
12575
|
-
pillarBeliefs.push({
|
|
12576
|
-
pillar: pillarMatch ? pillarMatch[0] : keyword,
|
|
12577
|
-
text: belief.text.slice(0, 250),
|
|
12578
|
-
nodeId: belief.nodeId
|
|
12579
|
-
});
|
|
12580
|
-
break;
|
|
12581
|
-
}
|
|
13289
|
+
const record = payload;
|
|
13290
|
+
const topicId = readString2(record.topicId);
|
|
13291
|
+
const worktreeId = readString2(record.worktreeId) ?? readString2(args.worktreeId);
|
|
13292
|
+
if (!topicId || !worktreeId) {
|
|
13293
|
+
return;
|
|
12582
13294
|
}
|
|
12583
|
-
|
|
12584
|
-
{
|
|
12585
|
-
path: "docs/product/core-value-propositions.md",
|
|
12586
|
-
description: "8 innovation pillars through developer, marketing, and investor lenses"
|
|
12587
|
-
},
|
|
12588
|
-
{
|
|
12589
|
-
path: "docs/product/five-domains.md",
|
|
12590
|
-
description: "5 product domains: MC, Tenant, Developer, Reasoning Control, Reasoning"
|
|
12591
|
-
},
|
|
12592
|
-
{
|
|
12593
|
-
path: "docs/product/innovation-pillars.md",
|
|
12594
|
-
description: "The 8 pillars that define what makes Lucern unique"
|
|
12595
|
-
},
|
|
12596
|
-
{
|
|
12597
|
-
path: "docs/product/vision-to-roadmap-bridge.md",
|
|
12598
|
-
description: "Where each pillar is today vs. where it goes \u2014 the north star trajectory"
|
|
12599
|
-
}
|
|
12600
|
-
];
|
|
12601
|
-
return {
|
|
13295
|
+
writeLucernJson({
|
|
12602
13296
|
topicId,
|
|
12603
|
-
topicName,
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
focus,
|
|
12616
|
-
status,
|
|
12617
|
-
sessionMode,
|
|
12618
|
-
targetBeliefIds,
|
|
12619
|
-
targetQuestionIds,
|
|
12620
|
-
topBeliefs,
|
|
12621
|
-
openQuestions,
|
|
12622
|
-
resolvedDecisions,
|
|
12623
|
-
exitCriteria,
|
|
12624
|
-
requiredDocs,
|
|
12625
|
-
keyFiles,
|
|
12626
|
-
pillarBeliefs,
|
|
12627
|
-
visionDocs,
|
|
12628
|
-
dependencies,
|
|
12629
|
-
unblocks,
|
|
12630
|
-
mergeOrderNotes
|
|
12631
|
-
};
|
|
13297
|
+
topicName: readString2(record.topicName),
|
|
13298
|
+
activeWorktree: {
|
|
13299
|
+
worktreeId,
|
|
13300
|
+
title: readString2(record.worktreeName) ?? readString2(record.title) ?? readString2(record.name) ?? worktreeId,
|
|
13301
|
+
status: readString2(record.status) ?? "unknown",
|
|
13302
|
+
campaign: readNullableNumber(record.campaign),
|
|
13303
|
+
lane: readString2(record.lane) ?? null,
|
|
13304
|
+
orderInLane: readNullableNumber(record.orderInLane),
|
|
13305
|
+
gate: readString2(record.gate) ?? null,
|
|
13306
|
+
branch: readString2(record.branch) ?? readString2(args.branch) ?? null
|
|
13307
|
+
}
|
|
13308
|
+
});
|
|
12632
13309
|
}
|
|
12633
|
-
|
|
12634
|
-
// ../../apps/mcp-server/src/handlers/bootstrap.ts
|
|
12635
13310
|
var bootstrapHandlers = {
|
|
12636
13311
|
async generate_session_handoff(args, ctx) {
|
|
12637
13312
|
return formatSdkResult(
|
|
@@ -12639,7 +13314,11 @@ var bootstrapHandlers = {
|
|
|
12639
13314
|
);
|
|
12640
13315
|
},
|
|
12641
13316
|
async begin_build_session(args, ctx) {
|
|
12642
|
-
|
|
13317
|
+
const payload = formatSdkResult(
|
|
13318
|
+
await getSdkClient(ctx).mcp.beginBuildSession(args)
|
|
13319
|
+
);
|
|
13320
|
+
refreshLucernContextFromBuildSession(payload, args);
|
|
13321
|
+
return payload;
|
|
12643
13322
|
}
|
|
12644
13323
|
};
|
|
12645
13324
|
|
|
@@ -12995,19 +13674,16 @@ var engineeringVerificationHandlers = {
|
|
|
12995
13674
|
"evaluate_engineering_contract requires at least one verification payload."
|
|
12996
13675
|
);
|
|
12997
13676
|
}
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
{
|
|
13677
|
+
return formatSdkResult(
|
|
13678
|
+
await getSdkClient(ctx).mcp.evaluateEngineeringContract({
|
|
13001
13679
|
beliefNodeId: args.beliefNodeId,
|
|
13002
13680
|
trigger: args.trigger,
|
|
13003
13681
|
testOutput: args.testOutput,
|
|
13004
13682
|
tscOutput: args.tscOutput,
|
|
13005
13683
|
lintOutput: args.lintOutput,
|
|
13006
|
-
sentryData: args.sentryData
|
|
13007
|
-
|
|
13008
|
-
}
|
|
13684
|
+
sentryData: args.sentryData
|
|
13685
|
+
})
|
|
13009
13686
|
);
|
|
13010
|
-
return result;
|
|
13011
13687
|
}
|
|
13012
13688
|
};
|
|
13013
13689
|
|
|
@@ -13185,6 +13861,14 @@ var generatedFunctionSurfaceHandlers = {
|
|
|
13185
13861
|
)
|
|
13186
13862
|
);
|
|
13187
13863
|
},
|
|
13864
|
+
async begin_build_session(args, ctx) {
|
|
13865
|
+
return formatSdkResult(
|
|
13866
|
+
await getSdkClient(ctx).raw.functionSurface.beginBuildSession(
|
|
13867
|
+
stripInternalArgs(args),
|
|
13868
|
+
idempotencyKeyFrom(args)
|
|
13869
|
+
)
|
|
13870
|
+
);
|
|
13871
|
+
},
|
|
13188
13872
|
async bisect_confidence(args, ctx) {
|
|
13189
13873
|
return formatSdkResult(
|
|
13190
13874
|
await getSdkClient(ctx).raw.functionSurface.bisectConfidence(
|
|
@@ -13960,6 +14644,47 @@ var intelligenceHandlers = {
|
|
|
13960
14644
|
get_graph_structure_analysis: graphHandlers.get_graph_structure_analysis,
|
|
13961
14645
|
get_falsification_questions: graphHandlers.get_falsification_questions
|
|
13962
14646
|
};
|
|
14647
|
+
var GLOBAL_KEY = "__LUCERN_SERVER_CORE_KERNEL_API_BINDING__";
|
|
14648
|
+
function store() {
|
|
14649
|
+
return globalThis;
|
|
14650
|
+
}
|
|
14651
|
+
function getBinding() {
|
|
14652
|
+
const current = store()[GLOBAL_KEY];
|
|
14653
|
+
if (!current) {
|
|
14654
|
+
throw new Error(
|
|
14655
|
+
"Server-core kernelApi not registered. Call registerKernelApi({api, components, internal}) at host boot."
|
|
14656
|
+
);
|
|
14657
|
+
}
|
|
14658
|
+
return current;
|
|
14659
|
+
}
|
|
14660
|
+
function readPath(root, path3) {
|
|
14661
|
+
let cursor = root;
|
|
14662
|
+
for (const part of path3) {
|
|
14663
|
+
if (cursor == null || typeof cursor !== "object") {
|
|
14664
|
+
return void 0;
|
|
14665
|
+
}
|
|
14666
|
+
cursor = cursor[part];
|
|
14667
|
+
}
|
|
14668
|
+
return cursor;
|
|
14669
|
+
}
|
|
14670
|
+
function resolveApiPath(binding, which, path3) {
|
|
14671
|
+
return readPath(binding[which], path3);
|
|
14672
|
+
}
|
|
14673
|
+
function makeProxy(which, path3 = []) {
|
|
14674
|
+
return new Proxy({}, {
|
|
14675
|
+
get(_target, prop) {
|
|
14676
|
+
if (typeof prop !== "string") {
|
|
14677
|
+
return void 0;
|
|
14678
|
+
}
|
|
14679
|
+
const nextPath = [...path3, prop];
|
|
14680
|
+
const resolved = resolveApiPath(getBinding(), which, nextPath);
|
|
14681
|
+
return resolved === void 0 ? makeProxy(which, nextPath) : resolved;
|
|
14682
|
+
}
|
|
14683
|
+
});
|
|
14684
|
+
}
|
|
14685
|
+
var api = makeProxy("api");
|
|
14686
|
+
makeProxy("components");
|
|
14687
|
+
makeProxy("internal");
|
|
13963
14688
|
|
|
13964
14689
|
// ../server-core/src/mcp-context-tools.ts
|
|
13965
14690
|
function requireMcpConvex(authContext, label) {
|
|
@@ -14012,7 +14737,7 @@ function getConvex(ctx) {
|
|
|
14012
14737
|
}
|
|
14013
14738
|
return requireMcpConvex(ctx, "topic-resolver");
|
|
14014
14739
|
}
|
|
14015
|
-
function
|
|
14740
|
+
function readString3(value) {
|
|
14016
14741
|
if (typeof value !== "string") {
|
|
14017
14742
|
return void 0;
|
|
14018
14743
|
}
|
|
@@ -14023,13 +14748,13 @@ function readStringArray2(value) {
|
|
|
14023
14748
|
if (!Array.isArray(value)) {
|
|
14024
14749
|
return [];
|
|
14025
14750
|
}
|
|
14026
|
-
return value.map((entry) =>
|
|
14751
|
+
return value.map((entry) => readString3(entry)).filter((entry) => Boolean(entry));
|
|
14027
14752
|
}
|
|
14028
14753
|
function asRecord2(value) {
|
|
14029
14754
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
14030
14755
|
}
|
|
14031
14756
|
function normalizeTopicId(value) {
|
|
14032
|
-
const normalized =
|
|
14757
|
+
const normalized = readString3(value);
|
|
14033
14758
|
if (!normalized) {
|
|
14034
14759
|
return void 0;
|
|
14035
14760
|
}
|
|
@@ -14041,7 +14766,7 @@ function normalizeTopicId(value) {
|
|
|
14041
14766
|
}
|
|
14042
14767
|
}
|
|
14043
14768
|
function normalizeExternalId(value, prefix) {
|
|
14044
|
-
const normalized =
|
|
14769
|
+
const normalized = readString3(value);
|
|
14045
14770
|
if (!normalized) {
|
|
14046
14771
|
return void 0;
|
|
14047
14772
|
}
|
|
@@ -14063,7 +14788,7 @@ function normalizeToken(value) {
|
|
|
14063
14788
|
return normalized;
|
|
14064
14789
|
}
|
|
14065
14790
|
function tokenize(value) {
|
|
14066
|
-
const normalized =
|
|
14791
|
+
const normalized = readString3(value);
|
|
14067
14792
|
if (!normalized) {
|
|
14068
14793
|
return [];
|
|
14069
14794
|
}
|
|
@@ -14178,22 +14903,22 @@ function scoreTopicMatch(topic, input) {
|
|
|
14178
14903
|
}
|
|
14179
14904
|
function normalizeTopicCandidate(value) {
|
|
14180
14905
|
const record = asRecord2(value);
|
|
14181
|
-
const rawId =
|
|
14182
|
-
const name =
|
|
14906
|
+
const rawId = readString3(record._id) ?? readString3(record.id) ?? normalizeTopicId(readString3(record.topicId)) ?? normalizeTopicId(readString3(record.projectId));
|
|
14907
|
+
const name = readString3(record.name);
|
|
14183
14908
|
if (!rawId || !name) {
|
|
14184
14909
|
return null;
|
|
14185
14910
|
}
|
|
14186
14911
|
return {
|
|
14187
14912
|
rawId,
|
|
14188
14913
|
name,
|
|
14189
|
-
description:
|
|
14190
|
-
type:
|
|
14191
|
-
parentTopicId: normalizeTopicId(
|
|
14192
|
-
tenantId:
|
|
14193
|
-
workspaceId:
|
|
14194
|
-
status:
|
|
14914
|
+
description: readString3(record.description),
|
|
14915
|
+
type: readString3(record.type),
|
|
14916
|
+
parentTopicId: normalizeTopicId(readString3(record.parentTopicId)) ?? null,
|
|
14917
|
+
tenantId: readString3(record.tenantId),
|
|
14918
|
+
workspaceId: readString3(record.workspaceId),
|
|
14919
|
+
status: readString3(record.status),
|
|
14195
14920
|
metadata: asRecord2(record.metadata),
|
|
14196
|
-
globalId:
|
|
14921
|
+
globalId: readString3(record.globalId)
|
|
14197
14922
|
};
|
|
14198
14923
|
}
|
|
14199
14924
|
function topicMatchesScope(topic, tenantId, workspaceId) {
|
|
@@ -14221,7 +14946,7 @@ async function fetchTopicById(ctx, topicId) {
|
|
|
14221
14946
|
function readRecordTopicId(value) {
|
|
14222
14947
|
const record = asRecord2(value);
|
|
14223
14948
|
return normalizeTopicId(
|
|
14224
|
-
|
|
14949
|
+
readString3(record.topicId) ?? readString3(record.projectId) ?? readString3(asRecord2(record.metadata).topicId)
|
|
14225
14950
|
);
|
|
14226
14951
|
}
|
|
14227
14952
|
async function fetchRecordTopicId(ctx, reference, args) {
|
|
@@ -14240,7 +14965,7 @@ async function resolveBeliefTopicId(ctx, beliefId) {
|
|
|
14240
14965
|
}
|
|
14241
14966
|
async function resolveCommonBeliefTopicId(ctx, beliefIds) {
|
|
14242
14967
|
const normalizedBeliefIds = (beliefIds ?? []).filter(
|
|
14243
|
-
(beliefId) => Boolean(
|
|
14968
|
+
(beliefId) => Boolean(readString3(beliefId))
|
|
14244
14969
|
);
|
|
14245
14970
|
if (normalizedBeliefIds.length === 0) {
|
|
14246
14971
|
return void 0;
|
|
@@ -14302,7 +15027,7 @@ function compactWhitespace(value) {
|
|
|
14302
15027
|
return value.replace(/\s+/g, " ").trim();
|
|
14303
15028
|
}
|
|
14304
15029
|
function deriveTopicName(input, parentTopic) {
|
|
14305
|
-
const textualHint =
|
|
15030
|
+
const textualHint = readString3(input.topicHint);
|
|
14306
15031
|
if (textualHint && tokenize(textualHint).length > 0) {
|
|
14307
15032
|
return titleCase(compactWhitespace(textualHint)).slice(0, 60);
|
|
14308
15033
|
}
|
|
@@ -14318,7 +15043,7 @@ function deriveTopicName(input, parentTopic) {
|
|
|
14318
15043
|
if (summary.length > 0) {
|
|
14319
15044
|
return titleCase(summary.slice(0, 60));
|
|
14320
15045
|
}
|
|
14321
|
-
const sourceRef =
|
|
15046
|
+
const sourceRef = readString3(input.sourceRef);
|
|
14322
15047
|
if (sourceRef) {
|
|
14323
15048
|
return titleCase(compactWhitespace(sourceRef.replace(/[-_:/]+/g, " "))).slice(0, 60);
|
|
14324
15049
|
}
|
|
@@ -14327,7 +15052,7 @@ function deriveTopicName(input, parentTopic) {
|
|
|
14327
15052
|
async function createChildTopic(ctx, parentTopic, input) {
|
|
14328
15053
|
const convex = getConvex(ctx);
|
|
14329
15054
|
const desiredTenantId = ctx.tenantId;
|
|
14330
|
-
const desiredWorkspaceId =
|
|
15055
|
+
const desiredWorkspaceId = readString3(input.workspaceId) ?? ctx.workspaceId;
|
|
14331
15056
|
const createdBy = ctx.principalId ?? ctx.userId;
|
|
14332
15057
|
const created = await convex.mutation(api.topics.create, {
|
|
14333
15058
|
name: deriveTopicName(input, parentTopic),
|
|
@@ -14347,7 +15072,7 @@ async function createChildTopic(ctx, parentTopic, input) {
|
|
|
14347
15072
|
}
|
|
14348
15073
|
});
|
|
14349
15074
|
const createdRecord = asRecord2(created);
|
|
14350
|
-
const createdId =
|
|
15075
|
+
const createdId = readString3(createdRecord.id) ?? readString3(createdRecord.topicId) ?? readString3(createdRecord._id);
|
|
14351
15076
|
const hydrated = await fetchTopicById(ctx, createdId);
|
|
14352
15077
|
if (!hydrated) {
|
|
14353
15078
|
throw new Error("[topic-resolver] Auto-created topic could not be reloaded.");
|
|
@@ -14367,11 +15092,32 @@ function pushTrace(trace, topic, score) {
|
|
|
14367
15092
|
score
|
|
14368
15093
|
});
|
|
14369
15094
|
}
|
|
15095
|
+
function pickBestTopic(topics2, input) {
|
|
15096
|
+
const ranked = topics2.filter((topic) => topic.status !== "archived").map((topic) => ({
|
|
15097
|
+
topic,
|
|
15098
|
+
score: scoreTopicMatch(topic, input)
|
|
15099
|
+
})).sort((left, right) => {
|
|
15100
|
+
if (right.score !== left.score) {
|
|
15101
|
+
return right.score - left.score;
|
|
15102
|
+
}
|
|
15103
|
+
const leftName = left.topic.name.trim().toLowerCase();
|
|
15104
|
+
const rightName = right.topic.name.trim().toLowerCase();
|
|
15105
|
+
return leftName.localeCompare(rightName);
|
|
15106
|
+
});
|
|
15107
|
+
return ranked[0]?.topic ?? null;
|
|
15108
|
+
}
|
|
15109
|
+
function pickFallbackRootTopic(topics2, input) {
|
|
15110
|
+
const parentless = topics2.filter((topic) => !topic.parentTopicId);
|
|
15111
|
+
return pickBestTopic(parentless, input) ?? pickBestTopic(topics2, input);
|
|
15112
|
+
}
|
|
14370
15113
|
async function loadTopicUniverse(ctx, input) {
|
|
14371
15114
|
const desiredTenantId = ctx.tenantId;
|
|
14372
|
-
const desiredWorkspaceId =
|
|
15115
|
+
const desiredWorkspaceId = readString3(input.workspaceId) ?? ctx.workspaceId;
|
|
14373
15116
|
const rawTopics = await fetchTopicTree(ctx);
|
|
14374
|
-
const
|
|
15117
|
+
const scopedTopics = rawTopics.filter(
|
|
15118
|
+
(topic) => topicMatchesScope(topic, desiredTenantId, desiredWorkspaceId)
|
|
15119
|
+
);
|
|
15120
|
+
const root = rawTopics.find((topic) => topic.rawId === ROOT_TOPIC_ID) ?? await fetchTopicById(ctx, ROOT_TOPIC_ID) ?? pickFallbackRootTopic(scopedTopics, input) ?? null;
|
|
14375
15121
|
if (!root) {
|
|
14376
15122
|
throw new Error("[topic-resolver] Root topic not found.");
|
|
14377
15123
|
}
|
|
@@ -15025,16 +15771,16 @@ function buildInputData(args) {
|
|
|
15025
15771
|
var researchVerificationHandlers = {
|
|
15026
15772
|
async evaluate_research_contract(args, ctx) {
|
|
15027
15773
|
const inputData = buildInputData(args);
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
{
|
|
15774
|
+
return formatSdkResult(
|
|
15775
|
+
await getSdkClient(ctx).mcp.evaluateResearchContract({
|
|
15031
15776
|
beliefNodeId: args.beliefNodeId,
|
|
15032
15777
|
trigger: typeof args.trigger === "string" && args.trigger.length > 0 ? args.trigger : "event_driven",
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15778
|
+
metricData: inputData?.metricData,
|
|
15779
|
+
referenceCheckData: inputData?.referenceCheckData,
|
|
15780
|
+
marketIndexData: inputData?.marketIndexData,
|
|
15781
|
+
temporalData: inputData?.temporalData
|
|
15782
|
+
})
|
|
15036
15783
|
);
|
|
15037
|
-
return result;
|
|
15038
15784
|
}
|
|
15039
15785
|
};
|
|
15040
15786
|
|
|
@@ -15214,7 +15960,13 @@ var scopeContextHandlers = {
|
|
|
15214
15960
|
packWeightOverrides: Array.isArray(args.packWeightOverrides) ? args.packWeightOverrides : void 0
|
|
15215
15961
|
})
|
|
15216
15962
|
);
|
|
15217
|
-
|
|
15963
|
+
const publicContext = toPublicCompiledContext(compiled);
|
|
15964
|
+
writeLucernJson({
|
|
15965
|
+
topicId: publicContext.topicId ?? topicId,
|
|
15966
|
+
topicName: publicContext.topicName,
|
|
15967
|
+
activeWorktree: null
|
|
15968
|
+
});
|
|
15969
|
+
return publicContext;
|
|
15218
15970
|
},
|
|
15219
15971
|
async record_scope_learning(args, ctx) {
|
|
15220
15972
|
const explicitTopicId = readString(readTopicIdArg(args));
|
|
@@ -15409,20 +16161,27 @@ var worktreeHandlers = {
|
|
|
15409
16161
|
},
|
|
15410
16162
|
async merge(args, ctx) {
|
|
15411
16163
|
const record = asRecord(args);
|
|
15412
|
-
const outcomes = Array.isArray(record.outcomes) ? record.outcomes
|
|
16164
|
+
const outcomes = Array.isArray(record.outcomes) ? record.outcomes.map((entry) => {
|
|
16165
|
+
const finding = readString(entry);
|
|
16166
|
+
if (finding) {
|
|
16167
|
+
return finding;
|
|
16168
|
+
}
|
|
16169
|
+
const row = asRecord(entry);
|
|
16170
|
+
if (!Object.keys(row).length) {
|
|
16171
|
+
return null;
|
|
16172
|
+
}
|
|
16173
|
+
return {
|
|
16174
|
+
beliefId: readString(row.beliefId) ?? "",
|
|
16175
|
+
confidence: readNumber(row.confidence) ?? Number.NaN,
|
|
16176
|
+
rationale: readString(row.rationale) ?? ""
|
|
16177
|
+
};
|
|
16178
|
+
}).filter((entry) => entry !== null) : [];
|
|
15413
16179
|
return formatSdkResult(
|
|
15414
16180
|
await getSdkClient(ctx).worktrees.merge(
|
|
15415
16181
|
readString(record.worktreeId ?? record.id) ?? "",
|
|
15416
16182
|
{
|
|
15417
16183
|
summary: readString(record.summary),
|
|
15418
|
-
outcomes
|
|
15419
|
-
const row = asRecord(entry);
|
|
15420
|
-
return {
|
|
15421
|
-
beliefId: readString(row.beliefId) ?? "",
|
|
15422
|
-
confidence: readNumber(row.confidence) ?? Number.NaN,
|
|
15423
|
-
rationale: readString(row.rationale) ?? ""
|
|
15424
|
-
};
|
|
15425
|
-
})
|
|
16184
|
+
outcomes
|
|
15426
16185
|
}
|
|
15427
16186
|
)
|
|
15428
16187
|
);
|
|
@@ -15586,6 +16345,20 @@ function recordWrite(toolName, topicId, sessionId = "default") {
|
|
|
15586
16345
|
existing.push(record);
|
|
15587
16346
|
sessionWritesBySession.set(sessionId, existing);
|
|
15588
16347
|
}
|
|
16348
|
+
async function checkGatewayWritePolicy(args) {
|
|
16349
|
+
const client = args.authCtx.lucernClient;
|
|
16350
|
+
const checkWritePolicy2 = client?.mcp?.checkWritePolicy;
|
|
16351
|
+
if (!checkWritePolicy2) {
|
|
16352
|
+
throw new Error("Lucern SDK MCP write-policy client is not initialized.");
|
|
16353
|
+
}
|
|
16354
|
+
const response = await checkWritePolicy2({
|
|
16355
|
+
topicId: args.topicId,
|
|
16356
|
+
workspaceId: args.authCtx.workspaceId,
|
|
16357
|
+
role: args.authCtx.role,
|
|
16358
|
+
toolName: args.toolName
|
|
16359
|
+
});
|
|
16360
|
+
return response.data ?? null;
|
|
16361
|
+
}
|
|
15589
16362
|
function buildRateLimitExplanation(args) {
|
|
15590
16363
|
const summary = `Denied ${args.toolName}: session write limit ${args.currentCount}/${args.maxWritesPerSession} reached for the matched write policy.`;
|
|
15591
16364
|
return {
|
|
@@ -15623,10 +16396,10 @@ async function checkWritePolicy(toolName, topicId, authCtx) {
|
|
|
15623
16396
|
return { allowed: true, permission: "allow", reason: "read_only_tool" };
|
|
15624
16397
|
}
|
|
15625
16398
|
try {
|
|
15626
|
-
const result = await
|
|
16399
|
+
const result = await checkGatewayWritePolicy({
|
|
15627
16400
|
topicId: topicId ?? void 0,
|
|
15628
|
-
|
|
15629
|
-
|
|
16401
|
+
toolName,
|
|
16402
|
+
authCtx
|
|
15630
16403
|
});
|
|
15631
16404
|
if (!result) {
|
|
15632
16405
|
return {
|
|
@@ -15692,9 +16465,11 @@ async function checkWritePolicy(toolName, topicId, authCtx) {
|
|
|
15692
16465
|
};
|
|
15693
16466
|
}
|
|
15694
16467
|
}
|
|
16468
|
+
|
|
16469
|
+
// ../../apps/mcp-server/src/credentials.ts
|
|
15695
16470
|
var LUCERN_HOME = path2.join(os.homedir(), ".lucern");
|
|
15696
16471
|
path2.join(LUCERN_HOME, "credentials");
|
|
15697
16472
|
|
|
15698
|
-
export { buildHandlerMap, checkWritePolicy,
|
|
16473
|
+
export { buildHandlerMap, checkWritePolicy, isMutationTool, recordWrite };
|
|
15699
16474
|
//# sourceMappingURL=runtime.js.map
|
|
15700
16475
|
//# sourceMappingURL=runtime.js.map
|