@rhei-team/rhei 1.0.0-beta.0
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 +1048 -0
- package/bin/rhei-mcp.js +3 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +86366 -0
- package/dist/premium/contracts.d.ts +445 -0
- package/dist/premium/contracts.js +97 -0
- package/dist/vendor/rhei-core/briefs.js +1276 -0
- package/dist/vendor/rhei-core/codeAgent.js +615 -0
- package/dist/vendor/rhei-core/codeEditSession.js +293 -0
- package/dist/vendor/rhei-core/codeIntelligence.js +4287 -0
- package/dist/vendor/rhei-core/codeMarket.js +8946 -0
- package/dist/vendor/rhei-core/codeReviewIntelligence.js +5918 -0
- package/dist/vendor/rhei-core/codeSemantics.js +172427 -0
- package/dist/vendor/rhei-core/codeStory.js +667 -0
- package/dist/vendor/rhei-core/codeStrategyPlan.js +663 -0
- package/dist/vendor/rhei-core/codeTrail.js +2781 -0
- package/dist/vendor/rhei-core/codeWorkHandoff.js +281 -0
- package/dist/vendor/rhei-core/contextQuery.js +1119 -0
- package/dist/vendor/rhei-core/contextRouting.js +2052 -0
- package/dist/vendor/rhei-core/evidenceLedger.js +5336 -0
- package/dist/vendor/rhei-core/executionSafety.js +0 -0
- package/dist/vendor/rhei-core/goalIntelligence.js +2218 -0
- package/dist/vendor/rhei-core/model-lanes.js +75 -0
- package/dist/vendor/rhei-core/now.js +127 -0
- package/dist/vendor/rhei-core/package.json +29 -0
- package/dist/vendor/rhei-core/programPlan.js +3153 -0
- package/dist/vendor/rhei-core/search.js +196 -0
- package/dist/vendor/rhei-core/serviceIntelligence.js +1734 -0
- package/dist/vendor/rhei-core/workflowPlan.js +1660 -0
- package/package.json +41 -0
|
@@ -0,0 +1,2052 @@
|
|
|
1
|
+
// ../core/src/contextRouting/graphExecutionMode.ts
|
|
2
|
+
var GRAPH_EXECUTION_MODE_ROUTER_VERSION = 1;
|
|
3
|
+
var GRAPH_EXECUTION_MODES = [
|
|
4
|
+
"convex_local",
|
|
5
|
+
"connected_work_shallow",
|
|
6
|
+
"memgraph_depth3",
|
|
7
|
+
"memgraph_depth5",
|
|
8
|
+
"memgraph_depth5_plus_lite_llm"
|
|
9
|
+
];
|
|
10
|
+
var MODE_REQUIREMENTS = {
|
|
11
|
+
convex_local: { requiresNetwork: false, requiresProvider: false },
|
|
12
|
+
connected_work_shallow: { requiresNetwork: false, requiresProvider: false },
|
|
13
|
+
memgraph_depth3: { requiresNetwork: true, requiresProvider: false },
|
|
14
|
+
memgraph_depth5: { requiresNetwork: true, requiresProvider: false },
|
|
15
|
+
memgraph_depth5_plus_lite_llm: { requiresNetwork: true, requiresProvider: true }
|
|
16
|
+
};
|
|
17
|
+
var MODE_LIFT = {
|
|
18
|
+
convex_local: "baseline",
|
|
19
|
+
connected_work_shallow: "local_enrichment",
|
|
20
|
+
memgraph_depth3: "graph_expansion",
|
|
21
|
+
memgraph_depth5: "deep_graph_expansion",
|
|
22
|
+
memgraph_depth5_plus_lite_llm: "synthesis"
|
|
23
|
+
};
|
|
24
|
+
var MODE_COST = {
|
|
25
|
+
convex_local: "local",
|
|
26
|
+
connected_work_shallow: "connected_work_local",
|
|
27
|
+
memgraph_depth3: "network_graph",
|
|
28
|
+
memgraph_depth5: "network_graph",
|
|
29
|
+
memgraph_depth5_plus_lite_llm: "network_graph_provider"
|
|
30
|
+
};
|
|
31
|
+
function graphExecutionModePolicyMetadataFor(mode) {
|
|
32
|
+
const requirements = MODE_REQUIREMENTS[mode];
|
|
33
|
+
return {
|
|
34
|
+
version: GRAPH_EXECUTION_MODE_ROUTER_VERSION,
|
|
35
|
+
mode,
|
|
36
|
+
requiresNetwork: requirements.requiresNetwork,
|
|
37
|
+
requiresProvider: requirements.requiresProvider,
|
|
38
|
+
lift: MODE_LIFT[mode],
|
|
39
|
+
cost: MODE_COST[mode],
|
|
40
|
+
reportOnly: true
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function graphExecutionModePolicyMetadataList() {
|
|
44
|
+
return GRAPH_EXECUTION_MODES.map((mode) => graphExecutionModePolicyMetadataFor(mode));
|
|
45
|
+
}
|
|
46
|
+
function normalizeInput(input = {}) {
|
|
47
|
+
return {
|
|
48
|
+
intentConfidence: input.intentConfidence,
|
|
49
|
+
graphComplexity: input.graphComplexity,
|
|
50
|
+
localGraphConfidence: input.localGraphConfidence ?? null,
|
|
51
|
+
graphScaleTier: input.graphScaleTier,
|
|
52
|
+
highComplexityEvidenceScore: input.highComplexityEvidenceScore ?? null,
|
|
53
|
+
highComplexityScaleEvidencePresent: input.graphScaleTier !== undefined || input.highComplexityEvidenceScore !== undefined,
|
|
54
|
+
connectedWorkAvailable: input.connectedWorkAvailable ?? false,
|
|
55
|
+
memgraphAvailable: input.memgraphAvailable ?? false,
|
|
56
|
+
llmAvailable: input.llmAvailable ?? false,
|
|
57
|
+
noLiveMode: input.noLiveMode ?? true,
|
|
58
|
+
networkAllowed: input.networkAllowed ?? false,
|
|
59
|
+
providerCallsAllowed: input.providerCallsAllowed ?? false,
|
|
60
|
+
synthesisRequested: input.synthesisRequested ?? false
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function hasNoMeaningfulSignal(input) {
|
|
64
|
+
return input.intentConfidence === undefined && input.graphComplexity === undefined && input.localGraphConfidence === null && input.synthesisRequested === false;
|
|
65
|
+
}
|
|
66
|
+
function recommendGraphExecutionMode(input) {
|
|
67
|
+
if (hasNoMeaningfulSignal(input)) {
|
|
68
|
+
return { mode: "convex_local", reason: "default_convex_local" };
|
|
69
|
+
}
|
|
70
|
+
if (input.intentConfidence === "strong" && (input.graphComplexity === undefined || input.graphComplexity === "simple") && (input.localGraphConfidence === null || input.localGraphConfidence >= 0.8)) {
|
|
71
|
+
return { mode: "convex_local", reason: "strong_simple_local" };
|
|
72
|
+
}
|
|
73
|
+
if (input.graphComplexity === "shallow") {
|
|
74
|
+
return { mode: "connected_work_shallow", reason: "connected_work_enrichment" };
|
|
75
|
+
}
|
|
76
|
+
if (input.graphComplexity === "medium") {
|
|
77
|
+
return { mode: "memgraph_depth3", reason: "medium_graph_complexity" };
|
|
78
|
+
}
|
|
79
|
+
if (input.graphComplexity === "high") {
|
|
80
|
+
if (!input.highComplexityScaleEvidencePresent) {
|
|
81
|
+
return { mode: "memgraph_depth5", reason: "high_graph_complexity" };
|
|
82
|
+
}
|
|
83
|
+
if (input.graphScaleTier === "large_1500_3000" && input.highComplexityEvidenceScore !== null && input.highComplexityEvidenceScore >= 0.7) {
|
|
84
|
+
return { mode: "memgraph_depth5", reason: "high_graph_complexity" };
|
|
85
|
+
}
|
|
86
|
+
return { mode: "memgraph_depth3", reason: "high_graph_complexity_depth5_scale_gated" };
|
|
87
|
+
}
|
|
88
|
+
if (input.intentConfidence === "ambiguous" || input.synthesisRequested) {
|
|
89
|
+
return { mode: "memgraph_depth5_plus_lite_llm", reason: "ambiguous_synthesis" };
|
|
90
|
+
}
|
|
91
|
+
return { mode: "convex_local", reason: "default_convex_local" };
|
|
92
|
+
}
|
|
93
|
+
function blockersForMode(mode, input) {
|
|
94
|
+
switch (mode) {
|
|
95
|
+
case "convex_local":
|
|
96
|
+
return [];
|
|
97
|
+
case "connected_work_shallow":
|
|
98
|
+
return input.connectedWorkAvailable ? [] : ["connected_work_unavailable"];
|
|
99
|
+
case "memgraph_depth3":
|
|
100
|
+
case "memgraph_depth5": {
|
|
101
|
+
const blockers = [];
|
|
102
|
+
if (input.noLiveMode)
|
|
103
|
+
blockers.push("no_live_mode");
|
|
104
|
+
if (!input.networkAllowed)
|
|
105
|
+
blockers.push("network_disabled");
|
|
106
|
+
if (!input.memgraphAvailable)
|
|
107
|
+
blockers.push("memgraph_unavailable");
|
|
108
|
+
return blockers;
|
|
109
|
+
}
|
|
110
|
+
case "memgraph_depth5_plus_lite_llm": {
|
|
111
|
+
const blockers = [];
|
|
112
|
+
if (input.noLiveMode)
|
|
113
|
+
blockers.push("no_live_mode");
|
|
114
|
+
if (!input.networkAllowed)
|
|
115
|
+
blockers.push("network_disabled");
|
|
116
|
+
if (!input.memgraphAvailable)
|
|
117
|
+
blockers.push("memgraph_unavailable");
|
|
118
|
+
if (!input.providerCallsAllowed)
|
|
119
|
+
blockers.push("provider_calls_disabled");
|
|
120
|
+
if (!input.llmAvailable)
|
|
121
|
+
blockers.push("llm_unavailable");
|
|
122
|
+
return blockers;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function fallbackMode(input) {
|
|
127
|
+
return input.connectedWorkAvailable ? "connected_work_shallow" : "convex_local";
|
|
128
|
+
}
|
|
129
|
+
function fallbackReason(selectedMode) {
|
|
130
|
+
return selectedMode === "connected_work_shallow" ? "fallback_connected_work" : "fallback_convex_local";
|
|
131
|
+
}
|
|
132
|
+
function chooseGraphExecutionMode(input = {}) {
|
|
133
|
+
const normalized = normalizeInput(input);
|
|
134
|
+
const recommendation = recommendGraphExecutionMode(normalized);
|
|
135
|
+
const recommendedMode = recommendation.mode;
|
|
136
|
+
const blockers = blockersForMode(recommendedMode, normalized);
|
|
137
|
+
const fallbackUsed = blockers.length > 0;
|
|
138
|
+
const selectedMode = fallbackUsed ? fallbackMode(normalized) : recommendedMode;
|
|
139
|
+
const selectedRequirements = MODE_REQUIREMENTS[selectedMode];
|
|
140
|
+
const recommendedRequirements = MODE_REQUIREMENTS[recommendedMode];
|
|
141
|
+
return {
|
|
142
|
+
version: GRAPH_EXECUTION_MODE_ROUTER_VERSION,
|
|
143
|
+
reportOnly: true,
|
|
144
|
+
recommendedMode,
|
|
145
|
+
selectedMode,
|
|
146
|
+
reasons: fallbackUsed ? [recommendation.reason, fallbackReason(selectedMode)] : [recommendation.reason],
|
|
147
|
+
blockers,
|
|
148
|
+
fallbackUsed,
|
|
149
|
+
requiresNetwork: selectedRequirements.requiresNetwork,
|
|
150
|
+
requiresProvider: selectedRequirements.requiresProvider,
|
|
151
|
+
recommendedRequiresNetwork: recommendedRequirements.requiresNetwork,
|
|
152
|
+
recommendedRequiresProvider: recommendedRequirements.requiresProvider,
|
|
153
|
+
lift: {
|
|
154
|
+
recommended: MODE_LIFT[recommendedMode],
|
|
155
|
+
selected: MODE_LIFT[selectedMode]
|
|
156
|
+
},
|
|
157
|
+
cost: {
|
|
158
|
+
recommended: MODE_COST[recommendedMode],
|
|
159
|
+
selected: MODE_COST[selectedMode]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var DEFAULT_SCENARIOS = [
|
|
164
|
+
{
|
|
165
|
+
scenarioId: "baseline",
|
|
166
|
+
label: "Baseline conservative local graph",
|
|
167
|
+
policy: "Report-only no-live baseline; production default remains convex_local.",
|
|
168
|
+
input: {}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
scenarioId: "connected_work_enrichment",
|
|
172
|
+
label: "Connected work shallow enrichment",
|
|
173
|
+
policy: "Allow local connected-work enrichment when the graph is shallow and connected work is available.",
|
|
174
|
+
input: {
|
|
175
|
+
intentConfidence: "strong",
|
|
176
|
+
graphComplexity: "shallow",
|
|
177
|
+
connectedWorkAvailable: true
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
scenarioId: "memgraph_auto_escalation_depth3",
|
|
182
|
+
label: "Memgraph depth 3 auto-escalation",
|
|
183
|
+
policy: "Recommend Memgraph depth 3 for medium graph complexity, but keep conservative no-live fallback by default.",
|
|
184
|
+
input: {
|
|
185
|
+
intentConfidence: "strong",
|
|
186
|
+
graphComplexity: "medium",
|
|
187
|
+
connectedWorkAvailable: true
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
scenarioId: "memgraph_deep_depth5",
|
|
192
|
+
label: "Memgraph depth 5 deep graph expansion",
|
|
193
|
+
policy: "Recommend Memgraph depth 5 for high graph complexity, but keep conservative no-live fallback by default.",
|
|
194
|
+
input: {
|
|
195
|
+
intentConfidence: "strong",
|
|
196
|
+
graphComplexity: "high",
|
|
197
|
+
connectedWorkAvailable: true
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
scenarioId: "lite_llm_synthesis",
|
|
202
|
+
label: "Lite LLM synthesis",
|
|
203
|
+
policy: "Recommend depth 5 plus lite LLM for ambiguous synthesis, but keep conservative no-live fallback by default.",
|
|
204
|
+
input: {
|
|
205
|
+
intentConfidence: "ambiguous",
|
|
206
|
+
connectedWorkAvailable: true,
|
|
207
|
+
synthesisRequested: true
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
function buildGraphExecutionModeDefaultDecisions() {
|
|
212
|
+
return {
|
|
213
|
+
version: GRAPH_EXECUTION_MODE_ROUTER_VERSION,
|
|
214
|
+
reportOnly: true,
|
|
215
|
+
deterministic: true,
|
|
216
|
+
productionDefaultsChanged: false,
|
|
217
|
+
productionDefaultMode: "convex_local",
|
|
218
|
+
decisions: DEFAULT_SCENARIOS.map((scenario) => ({
|
|
219
|
+
scenarioId: scenario.scenarioId,
|
|
220
|
+
label: scenario.label,
|
|
221
|
+
policy: scenario.policy,
|
|
222
|
+
decision: chooseGraphExecutionMode(scenario.input)
|
|
223
|
+
}))
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
// ../core/src/contextRouting/graphRoutingPolicy.ts
|
|
227
|
+
var GRAPH_ROUTING_POLICY_VERSION = 1;
|
|
228
|
+
var GRAPH_ROUTING_MAX_NOISE_RATE_V1 = 0.2;
|
|
229
|
+
var GRAPH_ROUTING_MIN_SOURCE_GROUNDING_RATE_V1 = 0.95;
|
|
230
|
+
var GRAPH_ROUTING_DEPTH5_MIN_HIGH_COMPLEXITY_SCORE_V1 = 0.7;
|
|
231
|
+
var GRAPH_ROUTING_MIN_DEPTH5_LIFT_V1 = 0;
|
|
232
|
+
function isFiniteNumber(value) {
|
|
233
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
234
|
+
}
|
|
235
|
+
function isValidRate(value) {
|
|
236
|
+
return isFiniteNumber(value) && value >= 0 && value <= 1;
|
|
237
|
+
}
|
|
238
|
+
function normalizeRate(value) {
|
|
239
|
+
if (!isFiniteNumber(value))
|
|
240
|
+
return null;
|
|
241
|
+
return value >= 0 && value <= 1 ? value : null;
|
|
242
|
+
}
|
|
243
|
+
function normalizeLift(value) {
|
|
244
|
+
return isFiniteNumber(value) ? value : null;
|
|
245
|
+
}
|
|
246
|
+
function hasInvalidRateEvidence(value) {
|
|
247
|
+
return value !== null && value !== undefined && !isValidRate(value);
|
|
248
|
+
}
|
|
249
|
+
function hasInvalidLiftEvidence(value) {
|
|
250
|
+
return value !== null && value !== undefined && !isFiniteNumber(value);
|
|
251
|
+
}
|
|
252
|
+
function normalizePolicyInput(input) {
|
|
253
|
+
const rawHighComplexityEvidenceScore = input.highComplexityEvidenceScore;
|
|
254
|
+
const rawGraphExpansionNoiseRate = input.graphEvidence?.graphExpansionNoiseRate;
|
|
255
|
+
const rawSourceGroundingRate = input.graphEvidence?.sourceGroundingRate;
|
|
256
|
+
const rawDepth5LiftOverBestDepth3 = input.graphEvidence?.depth5LiftOverBestDepth3;
|
|
257
|
+
const rawDepth5NoiseRate = input.graphEvidence?.depth5NoiseRate;
|
|
258
|
+
return {
|
|
259
|
+
taskKind: input.taskKind,
|
|
260
|
+
changeShape: input.changeShape,
|
|
261
|
+
repoScaleTier: input.repoScaleTier,
|
|
262
|
+
highComplexityEvidenceScore: normalizeRate(rawHighComplexityEvidenceScore),
|
|
263
|
+
graphExpansionNoiseRate: normalizeRate(rawGraphExpansionNoiseRate),
|
|
264
|
+
sourceGroundingRate: normalizeRate(rawSourceGroundingRate),
|
|
265
|
+
depth5LiftOverBestDepth3: normalizeLift(rawDepth5LiftOverBestDepth3),
|
|
266
|
+
depth5NoiseRate: normalizeRate(rawDepth5NoiseRate),
|
|
267
|
+
depth5ThresholdEvidenceAvailable: input.graphEvidence?.depth5ThresholdEvidenceAvailable ?? false,
|
|
268
|
+
invalidGraphEvidence: hasInvalidRateEvidence(rawGraphExpansionNoiseRate) || hasInvalidRateEvidence(rawSourceGroundingRate),
|
|
269
|
+
invalidDepth5Evidence: hasInvalidRateEvidence(rawHighComplexityEvidenceScore) || hasInvalidLiftEvidence(rawDepth5LiftOverBestDepth3) || hasInvalidRateEvidence(rawDepth5NoiseRate),
|
|
270
|
+
connectedWorkAvailable: input.connectedWorkAvailable ?? false,
|
|
271
|
+
memgraphAvailable: input.memgraphAvailable ?? false,
|
|
272
|
+
llmAvailable: input.llmAvailable ?? false,
|
|
273
|
+
noLiveMode: input.noLiveMode ?? true,
|
|
274
|
+
networkAllowed: input.networkAllowed ?? false,
|
|
275
|
+
providerCallsAllowed: input.providerCallsAllowed ?? false
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function orderedUniqueBlockers(blockers) {
|
|
279
|
+
return Array.from(new Set(blockers));
|
|
280
|
+
}
|
|
281
|
+
function graphNoiseOverThreshold(input) {
|
|
282
|
+
if (input.invalidGraphEvidence)
|
|
283
|
+
return true;
|
|
284
|
+
if (input.graphExpansionNoiseRate !== null && input.graphExpansionNoiseRate > GRAPH_ROUTING_MAX_NOISE_RATE_V1)
|
|
285
|
+
return true;
|
|
286
|
+
if (input.sourceGroundingRate !== null && input.sourceGroundingRate < GRAPH_ROUTING_MIN_SOURCE_GROUNDING_RATE_V1)
|
|
287
|
+
return true;
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
function depth5PolicyBlockers(input) {
|
|
291
|
+
const blockers = [];
|
|
292
|
+
if (input.repoScaleTier !== "large_1500_3000")
|
|
293
|
+
blockers.push("depth5_requires_large_repo");
|
|
294
|
+
if (input.highComplexityEvidenceScore === null || input.highComplexityEvidenceScore < GRAPH_ROUTING_DEPTH5_MIN_HIGH_COMPLEXITY_SCORE_V1) {
|
|
295
|
+
blockers.push("depth5_requires_high_complexity_evidence");
|
|
296
|
+
}
|
|
297
|
+
if (input.depth5ThresholdEvidenceAvailable !== true || input.depth5LiftOverBestDepth3 === null || input.depth5NoiseRate === null || input.invalidDepth5Evidence) {
|
|
298
|
+
blockers.push("depth5_threshold_evidence_insufficient");
|
|
299
|
+
} else {
|
|
300
|
+
if (input.depth5LiftOverBestDepth3 <= GRAPH_ROUTING_MIN_DEPTH5_LIFT_V1)
|
|
301
|
+
blockers.push("depth5_requires_positive_lift");
|
|
302
|
+
if (input.depth5NoiseRate > GRAPH_ROUTING_MAX_NOISE_RATE_V1)
|
|
303
|
+
blockers.push("depth5_noise_over_threshold");
|
|
304
|
+
}
|
|
305
|
+
return blockers;
|
|
306
|
+
}
|
|
307
|
+
function depth5EligibilityReason(blockers) {
|
|
308
|
+
if (blockers.length === 0)
|
|
309
|
+
return "eligible_large_high_complexity_positive_lift_noise_ok";
|
|
310
|
+
if (blockers.includes("depth5_requires_large_repo"))
|
|
311
|
+
return "blocked_missing_large_repo";
|
|
312
|
+
if (blockers.includes("depth5_requires_high_complexity_evidence"))
|
|
313
|
+
return "blocked_missing_high_complexity";
|
|
314
|
+
if (blockers.includes("depth5_threshold_evidence_insufficient"))
|
|
315
|
+
return "blocked_threshold_evidence_insufficient";
|
|
316
|
+
if (blockers.includes("depth5_requires_positive_lift"))
|
|
317
|
+
return "blocked_missing_positive_lift";
|
|
318
|
+
if (blockers.includes("depth5_noise_over_threshold"))
|
|
319
|
+
return "blocked_noise_over_threshold";
|
|
320
|
+
return "not_requested";
|
|
321
|
+
}
|
|
322
|
+
function baseGraphInputForTask(input, depth5Eligible, noisyGraphEvidence) {
|
|
323
|
+
const commonSafetyInput = {
|
|
324
|
+
connectedWorkAvailable: input.connectedWorkAvailable,
|
|
325
|
+
memgraphAvailable: input.memgraphAvailable,
|
|
326
|
+
llmAvailable: input.llmAvailable,
|
|
327
|
+
noLiveMode: input.noLiveMode,
|
|
328
|
+
networkAllowed: input.networkAllowed,
|
|
329
|
+
providerCallsAllowed: input.providerCallsAllowed
|
|
330
|
+
};
|
|
331
|
+
if (noisyGraphEvidence) {
|
|
332
|
+
return {
|
|
333
|
+
...commonSafetyInput,
|
|
334
|
+
intentConfidence: "strong",
|
|
335
|
+
graphComplexity: "shallow"
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
switch (input.taskKind) {
|
|
339
|
+
case "local_symbol_lookup":
|
|
340
|
+
return {
|
|
341
|
+
...commonSafetyInput,
|
|
342
|
+
intentConfidence: "strong",
|
|
343
|
+
graphComplexity: "simple",
|
|
344
|
+
localGraphConfidence: 0.9
|
|
345
|
+
};
|
|
346
|
+
case "docs_code_alignment":
|
|
347
|
+
return {
|
|
348
|
+
...commonSafetyInput,
|
|
349
|
+
intentConfidence: "strong",
|
|
350
|
+
graphComplexity: "shallow"
|
|
351
|
+
};
|
|
352
|
+
case "deep_synthesis":
|
|
353
|
+
return {
|
|
354
|
+
...commonSafetyInput,
|
|
355
|
+
intentConfidence: "ambiguous",
|
|
356
|
+
graphScaleTier: input.repoScaleTier,
|
|
357
|
+
highComplexityEvidenceScore: input.highComplexityEvidenceScore,
|
|
358
|
+
synthesisRequested: true
|
|
359
|
+
};
|
|
360
|
+
case "execution_safety_impact":
|
|
361
|
+
return {
|
|
362
|
+
...commonSafetyInput,
|
|
363
|
+
intentConfidence: "strong",
|
|
364
|
+
graphComplexity: depth5Eligible ? "high" : "medium",
|
|
365
|
+
graphScaleTier: depth5Eligible ? "large_1500_3000" : input.repoScaleTier,
|
|
366
|
+
highComplexityEvidenceScore: input.highComplexityEvidenceScore
|
|
367
|
+
};
|
|
368
|
+
case "weak_search_recovery":
|
|
369
|
+
case "changed_file_impact":
|
|
370
|
+
case "shared_abstraction_review":
|
|
371
|
+
case "provider_integration_impact":
|
|
372
|
+
case "agent_handoff_planning":
|
|
373
|
+
return {
|
|
374
|
+
...commonSafetyInput,
|
|
375
|
+
intentConfidence: "strong",
|
|
376
|
+
graphComplexity: "medium",
|
|
377
|
+
graphScaleTier: input.repoScaleTier,
|
|
378
|
+
highComplexityEvidenceScore: input.highComplexityEvidenceScore
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function chooseGraphRoutingPolicyV1(input) {
|
|
383
|
+
const normalized = normalizePolicyInput(input);
|
|
384
|
+
const noisyGraphEvidence = graphNoiseOverThreshold(normalized);
|
|
385
|
+
const depth5Requested = normalized.taskKind === "execution_safety_impact" || normalized.taskKind === "deep_synthesis";
|
|
386
|
+
const depth5Blockers = orderedUniqueBlockers([
|
|
387
|
+
...depth5Requested ? depth5PolicyBlockers(normalized) : [],
|
|
388
|
+
...depth5Requested && noisyGraphEvidence ? ["depth5_noise_over_threshold"] : []
|
|
389
|
+
]);
|
|
390
|
+
const depth5Eligible = depth5Requested && !noisyGraphEvidence && depth5Blockers.length === 0;
|
|
391
|
+
const graphInput = baseGraphInputForTask(normalized, depth5Eligible, noisyGraphEvidence);
|
|
392
|
+
const decision = chooseGraphExecutionMode(graphInput);
|
|
393
|
+
const policyBlockers = orderedUniqueBlockers([
|
|
394
|
+
...noisyGraphEvidence ? ["graph_noise_over_threshold"] : [],
|
|
395
|
+
...depth5Blockers,
|
|
396
|
+
...decision.blockers
|
|
397
|
+
]);
|
|
398
|
+
return {
|
|
399
|
+
version: GRAPH_ROUTING_POLICY_VERSION,
|
|
400
|
+
reportOnly: true,
|
|
401
|
+
advisoryOnly: true,
|
|
402
|
+
noAuthority: true,
|
|
403
|
+
taskKind: normalized.taskKind,
|
|
404
|
+
changeShape: normalized.changeShape,
|
|
405
|
+
repoScaleTier: normalized.repoScaleTier,
|
|
406
|
+
recommendedMode: decision.recommendedMode,
|
|
407
|
+
selectedMode: decision.selectedMode,
|
|
408
|
+
decision,
|
|
409
|
+
policyBlockers,
|
|
410
|
+
evidenceSummary: {
|
|
411
|
+
graphExpansionNoiseRate: normalized.graphExpansionNoiseRate,
|
|
412
|
+
sourceGroundingRate: normalized.sourceGroundingRate,
|
|
413
|
+
highComplexityEvidenceScore: normalized.highComplexityEvidenceScore,
|
|
414
|
+
depth5LiftOverBestDepth3: normalized.depth5LiftOverBestDepth3,
|
|
415
|
+
depth5NoiseRate: normalized.depth5NoiseRate,
|
|
416
|
+
depth5ThresholdEvidenceAvailable: normalized.depth5ThresholdEvidenceAvailable
|
|
417
|
+
},
|
|
418
|
+
depthPolicy: {
|
|
419
|
+
depth3Allowed: true,
|
|
420
|
+
depth5Eligible,
|
|
421
|
+
depth5Default: false,
|
|
422
|
+
depth5EligibilityReason: depth5Requested ? depth5EligibilityReason(depth5Blockers) : "not_requested"
|
|
423
|
+
},
|
|
424
|
+
productionSafe: {
|
|
425
|
+
noLiveMode: normalized.noLiveMode,
|
|
426
|
+
networkAllowed: normalized.networkAllowed,
|
|
427
|
+
providerCallsAllowed: normalized.providerCallsAllowed,
|
|
428
|
+
requiresNetwork: decision.recommendedRequiresNetwork,
|
|
429
|
+
requiresProvider: decision.recommendedRequiresProvider,
|
|
430
|
+
selectedRequiresNetwork: decision.requiresNetwork,
|
|
431
|
+
selectedRequiresProvider: decision.requiresProvider
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
// ../core/src/contextRouting/plannerHandoffGraphAdvisory.ts
|
|
436
|
+
var PLANNER_HANDOFF_GRAPH_ADVISORY_SCHEMA_VERSION = 1;
|
|
437
|
+
var PLANNER_HANDOFF_GRAPH_ADVISORY_KIND = "planner_handoff_graph_advisory";
|
|
438
|
+
var PLANNER_HANDOFF_GRAPH_ADVISORY_REQUIRED_COPY = "Graph routing advisory explains context selection. It does not authorize graph mutation, provider synthesis, Memgraph execution, code writes, or Truth Gate promotion.";
|
|
439
|
+
var DEFAULT_SUMMARY = "Graph routing advisory is metadata-only and grants no execution authority.";
|
|
440
|
+
var DEFAULT_REASON_CODES = ["planner_graph_advisory:metadata_only", "planner_graph_advisory:no_authority"];
|
|
441
|
+
var VALID_SOURCES = new Set([
|
|
442
|
+
"local_code_context",
|
|
443
|
+
"code_market",
|
|
444
|
+
"mcp_input",
|
|
445
|
+
"task_brief",
|
|
446
|
+
"workroom_context_receipt",
|
|
447
|
+
"connected_work_packet",
|
|
448
|
+
"plan_contract",
|
|
449
|
+
"external"
|
|
450
|
+
]);
|
|
451
|
+
var VALID_BASES = new Set([
|
|
452
|
+
"graph_routing_policy_v1",
|
|
453
|
+
"explicit_metadata",
|
|
454
|
+
"default_no_live"
|
|
455
|
+
]);
|
|
456
|
+
var VALID_EVIDENCE_QUALITY = new Set(["none", "weak", "usable", "strong"]);
|
|
457
|
+
var VALID_GRAPH_NOISE_RISK = new Set(["unknown", "low", "medium", "high"]);
|
|
458
|
+
var VALID_MODES = new Set(GRAPH_EXECUTION_MODES);
|
|
459
|
+
var MAX_STRING_ITEMS = 24;
|
|
460
|
+
var MAX_METADATA_KEYS = 24;
|
|
461
|
+
var MAX_METADATA_STRING_LENGTH = 500;
|
|
462
|
+
function buildPlannerHandoffGraphAdvisoryV1(args = {}) {
|
|
463
|
+
const recommendedMode = cleanMode(args.recommendedGraphMode ?? args.recommendedMode) ?? "convex_local";
|
|
464
|
+
const selectedMode = cleanMode(args.selectedGraphMode ?? args.selectedMode) ?? "convex_local";
|
|
465
|
+
const policyBlockers = cleanStringArray(args.policyBlockers).slice(0, MAX_STRING_ITEMS);
|
|
466
|
+
const recommendedRequirements = requirementsForMode(recommendedMode);
|
|
467
|
+
const selectedRequirements = requirementsForMode(selectedMode);
|
|
468
|
+
const sourceRefs = cleanOptionalStringArray(args.sourceRefs);
|
|
469
|
+
const evidenceRefs = cleanOptionalStringArray(args.evidenceRefs);
|
|
470
|
+
const receiptRefs = cleanOptionalStringArray(args.receiptRefs);
|
|
471
|
+
const reasonCodes = cleanStringArray(args.reasonCodes).slice(0, MAX_STRING_ITEMS);
|
|
472
|
+
return {
|
|
473
|
+
schemaVersion: PLANNER_HANDOFF_GRAPH_ADVISORY_SCHEMA_VERSION,
|
|
474
|
+
kind: PLANNER_HANDOFF_GRAPH_ADVISORY_KIND,
|
|
475
|
+
generatedAt: finiteNumber(args.generatedAt) ?? Date.now(),
|
|
476
|
+
source: args.source ?? "external",
|
|
477
|
+
basis: args.basis ?? "explicit_metadata",
|
|
478
|
+
summary: cleanString(args.summary) ?? DEFAULT_SUMMARY,
|
|
479
|
+
taskKind: cleanString(args.taskKind),
|
|
480
|
+
repoScaleTier: cleanString(args.repoScaleTier),
|
|
481
|
+
selectedGraphMode: selectedMode,
|
|
482
|
+
recommendedGraphMode: recommendedMode,
|
|
483
|
+
selectedMode,
|
|
484
|
+
recommendedMode,
|
|
485
|
+
evidenceQuality: args.evidenceQuality ?? "none",
|
|
486
|
+
graphNoiseRisk: args.graphNoiseRisk ?? "unknown",
|
|
487
|
+
policyBlockers,
|
|
488
|
+
depthPolicy: {
|
|
489
|
+
depth3Allowed: args.depthPolicy?.depth3Allowed ?? true,
|
|
490
|
+
depth5Eligible: args.depthPolicy?.depth5Eligible ?? false,
|
|
491
|
+
depth5Default: false,
|
|
492
|
+
depth5Allowed: false,
|
|
493
|
+
depth5EligibilityReason: cleanString(args.depthPolicy?.depth5EligibilityReason)
|
|
494
|
+
},
|
|
495
|
+
executionPolicy: safeExecutionPolicy(),
|
|
496
|
+
productionSafe: {
|
|
497
|
+
productionDefaultMode: "convex_local",
|
|
498
|
+
recommendedRequiresNetwork: booleanOrDefault(args.productionSafe?.recommendedRequiresNetwork, recommendedRequirements.requiresNetwork),
|
|
499
|
+
recommendedRequiresProvider: booleanOrDefault(args.productionSafe?.recommendedRequiresProvider, recommendedRequirements.requiresProvider),
|
|
500
|
+
selectedRequiresNetwork: booleanOrDefault(args.productionSafe?.selectedRequiresNetwork, selectedRequirements.requiresNetwork),
|
|
501
|
+
selectedRequiresProvider: booleanOrDefault(args.productionSafe?.selectedRequiresProvider, selectedRequirements.requiresProvider)
|
|
502
|
+
},
|
|
503
|
+
reasonCodes: reasonCodes.length > 0 ? reasonCodes : DEFAULT_REASON_CODES,
|
|
504
|
+
sourceRefs,
|
|
505
|
+
evidenceRefs,
|
|
506
|
+
receiptRefs,
|
|
507
|
+
verificationCommand: cleanString(args.verificationCommand),
|
|
508
|
+
metadata: sanitizeMetadata(args.metadata),
|
|
509
|
+
memgraphAllowed: false,
|
|
510
|
+
depth5Allowed: false,
|
|
511
|
+
reportOnly: true,
|
|
512
|
+
advisoryOnly: true,
|
|
513
|
+
noAuthority: true
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function plannerHandoffGraphAdvisoryFromPolicyDecision(args) {
|
|
517
|
+
const decision = args.decision;
|
|
518
|
+
return buildPlannerHandoffGraphAdvisoryV1({
|
|
519
|
+
source: args.source ?? "local_code_context",
|
|
520
|
+
basis: "graph_routing_policy_v1",
|
|
521
|
+
generatedAt: args.generatedAt,
|
|
522
|
+
summary: args.summary ?? `Graph routing policy recommends ${decision.recommendedMode} and selected ${decision.selectedMode}; advisory only.`,
|
|
523
|
+
taskKind: decision.taskKind,
|
|
524
|
+
repoScaleTier: decision.repoScaleTier,
|
|
525
|
+
recommendedGraphMode: decision.recommendedMode,
|
|
526
|
+
selectedGraphMode: decision.selectedMode,
|
|
527
|
+
evidenceQuality: evidenceQualityFromPolicyDecision(decision),
|
|
528
|
+
graphNoiseRisk: graphNoiseRiskFromPolicyDecision(decision),
|
|
529
|
+
policyBlockers: decision.policyBlockers,
|
|
530
|
+
depthPolicy: {
|
|
531
|
+
depth3Allowed: decision.depthPolicy.depth3Allowed,
|
|
532
|
+
depth5Eligible: decision.depthPolicy.depth5Eligible,
|
|
533
|
+
depth5EligibilityReason: decision.depthPolicy.depth5EligibilityReason
|
|
534
|
+
},
|
|
535
|
+
productionSafe: {
|
|
536
|
+
recommendedRequiresNetwork: decision.productionSafe.requiresNetwork,
|
|
537
|
+
recommendedRequiresProvider: decision.productionSafe.requiresProvider,
|
|
538
|
+
selectedRequiresNetwork: decision.productionSafe.selectedRequiresNetwork,
|
|
539
|
+
selectedRequiresProvider: decision.productionSafe.selectedRequiresProvider
|
|
540
|
+
},
|
|
541
|
+
reasonCodes: ["graph_routing_policy_v1", ...decision.decision.reasons.map((reason) => `graph_routing:${reason}`)],
|
|
542
|
+
sourceRefs: args.sourceRefs,
|
|
543
|
+
evidenceRefs: args.evidenceRefs,
|
|
544
|
+
receiptRefs: args.receiptRefs,
|
|
545
|
+
verificationCommand: args.verificationCommand,
|
|
546
|
+
metadata: args.metadata
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
function normalizePlannerHandoffGraphAdvisoryV1(value, fallback = {}) {
|
|
550
|
+
if (!isRecord(value))
|
|
551
|
+
return;
|
|
552
|
+
const source = readSource(value["source"], fallback.source ?? "external");
|
|
553
|
+
const basis = readBasis(value["basis"], fallback.basis ?? "explicit_metadata");
|
|
554
|
+
const executionPolicy = isRecord(value["executionPolicy"]) ? value["executionPolicy"] : undefined;
|
|
555
|
+
const depthPolicy = isRecord(value["depthPolicy"]) ? value["depthPolicy"] : undefined;
|
|
556
|
+
const productionSafe = isRecord(value["productionSafe"]) ? value["productionSafe"] : undefined;
|
|
557
|
+
return buildPlannerHandoffGraphAdvisoryV1({
|
|
558
|
+
source,
|
|
559
|
+
basis,
|
|
560
|
+
generatedAt: finiteNumber(value["generatedAt"]) ?? fallback.generatedAt,
|
|
561
|
+
summary: cleanString(value["summary"]) ?? fallback.summary,
|
|
562
|
+
taskKind: cleanString(value["taskKind"]),
|
|
563
|
+
repoScaleTier: cleanString(value["repoScaleTier"]),
|
|
564
|
+
recommendedGraphMode: cleanMode(value["recommendedGraphMode"] ?? value["recommendedMode"]),
|
|
565
|
+
selectedGraphMode: cleanMode(value["selectedGraphMode"] ?? value["selectedMode"]),
|
|
566
|
+
evidenceQuality: readEvidenceQuality(value["evidenceQuality"]),
|
|
567
|
+
graphNoiseRisk: readGraphNoiseRisk(value["graphNoiseRisk"]),
|
|
568
|
+
policyBlockers: cleanStringArray(value["policyBlockers"]),
|
|
569
|
+
depthPolicy: {
|
|
570
|
+
depth3Allowed: booleanOrDefault(depthPolicy?.["depth3Allowed"], true),
|
|
571
|
+
depth5Eligible: booleanOrDefault(depthPolicy?.["depth5Eligible"], false),
|
|
572
|
+
depth5EligibilityReason: cleanString(depthPolicy?.["depth5EligibilityReason"])
|
|
573
|
+
},
|
|
574
|
+
productionSafe: {
|
|
575
|
+
recommendedRequiresNetwork: Boolean(productionSafe?.["recommendedRequiresNetwork"]),
|
|
576
|
+
recommendedRequiresProvider: Boolean(productionSafe?.["recommendedRequiresProvider"]),
|
|
577
|
+
selectedRequiresNetwork: Boolean(productionSafe?.["selectedRequiresNetwork"]),
|
|
578
|
+
selectedRequiresProvider: Boolean(productionSafe?.["selectedRequiresProvider"])
|
|
579
|
+
},
|
|
580
|
+
reasonCodes: uniqueStrings([
|
|
581
|
+
...cleanStringArray(value["reasonCodes"]),
|
|
582
|
+
executionPolicy?.["memgraphAllowed"] === true || value["memgraphAllowed"] === true ? "planner_graph_advisory:unsafe_input_sanitized" : undefined,
|
|
583
|
+
executionPolicy?.["providerCallsAllowed"] === true ? "planner_graph_advisory:provider_input_sanitized" : undefined,
|
|
584
|
+
executionPolicy?.["synapsePredictionInputAllowed"] === true ? "planner_graph_advisory:synapse_input_sanitized" : undefined,
|
|
585
|
+
depthPolicy?.["depth5Default"] === true || depthPolicy?.["depth5Allowed"] === true || value["depth5Allowed"] === true ? "planner_graph_advisory:depth5_input_sanitized" : undefined
|
|
586
|
+
]),
|
|
587
|
+
sourceRefs: cleanOptionalStringArray(value["sourceRefs"]),
|
|
588
|
+
evidenceRefs: cleanOptionalStringArray(value["evidenceRefs"]),
|
|
589
|
+
receiptRefs: cleanOptionalStringArray(value["receiptRefs"]),
|
|
590
|
+
verificationCommand: cleanString(value["verificationCommand"]),
|
|
591
|
+
metadata: sanitizeMetadata(isRecord(value["metadata"]) ? value["metadata"] : undefined)
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
function safeExecutionPolicy() {
|
|
595
|
+
return {
|
|
596
|
+
reportOnly: true,
|
|
597
|
+
advisoryOnly: true,
|
|
598
|
+
noAuthority: true,
|
|
599
|
+
noAutomaticExecution: true,
|
|
600
|
+
memgraphAllowed: false,
|
|
601
|
+
providerCallsAllowed: false,
|
|
602
|
+
synapsePredictionInputAllowed: false,
|
|
603
|
+
graphMutationAllowed: false,
|
|
604
|
+
codeWritesAllowed: false,
|
|
605
|
+
truthGatePromotionAllowed: false,
|
|
606
|
+
productionWritesAllowed: false,
|
|
607
|
+
routePersistenceAllowed: false,
|
|
608
|
+
uiSurfacingAllowed: false,
|
|
609
|
+
productionDefaultsChanged: false
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function requirementsForMode(mode) {
|
|
613
|
+
if (VALID_MODES.has(mode)) {
|
|
614
|
+
const metadata = graphExecutionModePolicyMetadataFor(mode);
|
|
615
|
+
return { requiresNetwork: metadata.requiresNetwork, requiresProvider: metadata.requiresProvider };
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
requiresNetwork: mode.includes("memgraph") || mode.includes("network"),
|
|
619
|
+
requiresProvider: mode.includes("provider") || mode.includes("llm")
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
function evidenceQualityFromPolicyDecision(decision) {
|
|
623
|
+
const sourceGrounding = decision.evidenceSummary.sourceGroundingRate;
|
|
624
|
+
const noise = decision.evidenceSummary.graphExpansionNoiseRate;
|
|
625
|
+
if (sourceGrounding === null && noise === null && decision.policyBlockers.length === 0)
|
|
626
|
+
return "none";
|
|
627
|
+
if (sourceGrounding !== null && sourceGrounding >= 0.98 && noise !== null && noise <= 0.1)
|
|
628
|
+
return "strong";
|
|
629
|
+
if (sourceGrounding !== null && sourceGrounding >= 0.95 && (noise === null || noise <= 0.2))
|
|
630
|
+
return "usable";
|
|
631
|
+
return "weak";
|
|
632
|
+
}
|
|
633
|
+
function graphNoiseRiskFromPolicyDecision(decision) {
|
|
634
|
+
const noise = decision.evidenceSummary.graphExpansionNoiseRate;
|
|
635
|
+
if (noise === null)
|
|
636
|
+
return decision.policyBlockers.includes("graph_noise_over_threshold") ? "high" : "unknown";
|
|
637
|
+
if (noise <= 0.1)
|
|
638
|
+
return "low";
|
|
639
|
+
if (noise <= 0.2)
|
|
640
|
+
return "medium";
|
|
641
|
+
return "high";
|
|
642
|
+
}
|
|
643
|
+
function readSource(value, fallback) {
|
|
644
|
+
return typeof value === "string" && VALID_SOURCES.has(value) ? value : fallback;
|
|
645
|
+
}
|
|
646
|
+
function readBasis(value, fallback) {
|
|
647
|
+
return typeof value === "string" && VALID_BASES.has(value) ? value : fallback;
|
|
648
|
+
}
|
|
649
|
+
function readEvidenceQuality(value) {
|
|
650
|
+
return typeof value === "string" && VALID_EVIDENCE_QUALITY.has(value) ? value : undefined;
|
|
651
|
+
}
|
|
652
|
+
function readGraphNoiseRisk(value) {
|
|
653
|
+
return typeof value === "string" && VALID_GRAPH_NOISE_RISK.has(value) ? value : undefined;
|
|
654
|
+
}
|
|
655
|
+
function cleanMode(value) {
|
|
656
|
+
const text = cleanString(value);
|
|
657
|
+
if (!text)
|
|
658
|
+
return;
|
|
659
|
+
return VALID_MODES.has(text) ? text : text;
|
|
660
|
+
}
|
|
661
|
+
function cleanOptionalStringArray(value) {
|
|
662
|
+
const output = cleanStringArray(value).slice(0, MAX_STRING_ITEMS);
|
|
663
|
+
return output.length > 0 ? output : undefined;
|
|
664
|
+
}
|
|
665
|
+
function cleanStringArray(value) {
|
|
666
|
+
if (!Array.isArray(value))
|
|
667
|
+
return [];
|
|
668
|
+
return uniqueStrings(value.map(cleanString)).slice(0, MAX_STRING_ITEMS);
|
|
669
|
+
}
|
|
670
|
+
function uniqueStrings(values) {
|
|
671
|
+
const seen = new Set;
|
|
672
|
+
const output = [];
|
|
673
|
+
for (const value of values) {
|
|
674
|
+
if (!value || seen.has(value))
|
|
675
|
+
continue;
|
|
676
|
+
seen.add(value);
|
|
677
|
+
output.push(value);
|
|
678
|
+
}
|
|
679
|
+
return output;
|
|
680
|
+
}
|
|
681
|
+
function sanitizeMetadata(value) {
|
|
682
|
+
if (!value)
|
|
683
|
+
return;
|
|
684
|
+
const output = {};
|
|
685
|
+
for (const [key, raw] of Object.entries(value).slice(0, MAX_METADATA_KEYS)) {
|
|
686
|
+
const cleanKey = cleanString(key);
|
|
687
|
+
if (!cleanKey)
|
|
688
|
+
continue;
|
|
689
|
+
const cleanValue = sanitizeMetadataValue(raw);
|
|
690
|
+
if (cleanValue !== undefined)
|
|
691
|
+
output[cleanKey] = cleanValue;
|
|
692
|
+
}
|
|
693
|
+
return Object.keys(output).length > 0 ? output : undefined;
|
|
694
|
+
}
|
|
695
|
+
function sanitizeMetadataValue(value) {
|
|
696
|
+
if (typeof value === "string")
|
|
697
|
+
return value.slice(0, MAX_METADATA_STRING_LENGTH);
|
|
698
|
+
if (typeof value === "number")
|
|
699
|
+
return Number.isFinite(value) ? value : undefined;
|
|
700
|
+
if (typeof value === "boolean" || value === null)
|
|
701
|
+
return value;
|
|
702
|
+
if (Array.isArray(value))
|
|
703
|
+
return value.map(sanitizeMetadataValue).filter((item) => item !== undefined).slice(0, MAX_STRING_ITEMS);
|
|
704
|
+
if (isRecord(value))
|
|
705
|
+
return sanitizeMetadata(value);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
function booleanOrDefault(value, fallback) {
|
|
709
|
+
return typeof value === "boolean" ? value : fallback;
|
|
710
|
+
}
|
|
711
|
+
function finiteNumber(value) {
|
|
712
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
713
|
+
}
|
|
714
|
+
function cleanString(value) {
|
|
715
|
+
if (typeof value !== "string")
|
|
716
|
+
return;
|
|
717
|
+
const text = value.trim();
|
|
718
|
+
return text.length > 0 ? text : undefined;
|
|
719
|
+
}
|
|
720
|
+
function isRecord(value) {
|
|
721
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
722
|
+
}
|
|
723
|
+
// ../core/src/contextRouting/surfacePolicies.ts
|
|
724
|
+
var CHANGE_SHAPES_V1 = [
|
|
725
|
+
"shared_abstraction",
|
|
726
|
+
"ui_behavior",
|
|
727
|
+
"ui_reuse_or_design_system",
|
|
728
|
+
"execution_safety",
|
|
729
|
+
"provider_integration",
|
|
730
|
+
"agent_handoff",
|
|
731
|
+
"docs_or_migration"
|
|
732
|
+
];
|
|
733
|
+
var CONNECTED_SURFACE_KINDS_V1 = [
|
|
734
|
+
"primary_code",
|
|
735
|
+
"targeted_tests",
|
|
736
|
+
"user_docs",
|
|
737
|
+
"config_policy",
|
|
738
|
+
"package_exports",
|
|
739
|
+
"runtime_enforcement",
|
|
740
|
+
"schema_persistence",
|
|
741
|
+
"ui_surface",
|
|
742
|
+
"design_system_or_shared_component",
|
|
743
|
+
"usage_sites",
|
|
744
|
+
"visual_snapshot_or_story",
|
|
745
|
+
"native_counterpart",
|
|
746
|
+
"receipt_audit",
|
|
747
|
+
"eval_report",
|
|
748
|
+
"migration_notes",
|
|
749
|
+
"provider_gateway",
|
|
750
|
+
"agent_handoff"
|
|
751
|
+
];
|
|
752
|
+
var COMMON_CODE_EVIDENCE = [
|
|
753
|
+
"primary_edit_file",
|
|
754
|
+
"context_slice",
|
|
755
|
+
"source_ref",
|
|
756
|
+
"evidence_ref"
|
|
757
|
+
];
|
|
758
|
+
var COMMON_SUPPORT_EVIDENCE = [
|
|
759
|
+
"context_slice",
|
|
760
|
+
"affected_test",
|
|
761
|
+
"affected_doc",
|
|
762
|
+
"config_file",
|
|
763
|
+
"source_ref",
|
|
764
|
+
"evidence_ref",
|
|
765
|
+
"receipt_ref"
|
|
766
|
+
];
|
|
767
|
+
function required(surfaceKind, minEvidenceCount, evidenceTypes, rationale) {
|
|
768
|
+
return { surfaceKind, level: "required", minEvidenceCount, evidenceTypes, rationale };
|
|
769
|
+
}
|
|
770
|
+
function optional(surfaceKind, minEvidenceCount, evidenceTypes, rationale) {
|
|
771
|
+
return { surfaceKind, level: "optional", minEvidenceCount, evidenceTypes, rationale };
|
|
772
|
+
}
|
|
773
|
+
var CONNECTED_SURFACE_POLICIES_V1 = {
|
|
774
|
+
shared_abstraction: {
|
|
775
|
+
version: 1,
|
|
776
|
+
changeShape: "shared_abstraction",
|
|
777
|
+
label: "Shared abstraction",
|
|
778
|
+
description: "Reusable code contracts need implementation, public contract/docs, and regression tests in the same bounded packet.",
|
|
779
|
+
recommendedEscalation: "memgraph_depth3",
|
|
780
|
+
graphInput: {
|
|
781
|
+
intentConfidence: "strong",
|
|
782
|
+
graphComplexity: "medium",
|
|
783
|
+
connectedWorkAvailable: true,
|
|
784
|
+
noLiveMode: true,
|
|
785
|
+
networkAllowed: false,
|
|
786
|
+
providerCallsAllowed: false
|
|
787
|
+
},
|
|
788
|
+
rules: [
|
|
789
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Primary implementation files must be represented."),
|
|
790
|
+
required("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Shared behavior changes need targeted regression tests."),
|
|
791
|
+
required("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "Public behavior should stay aligned with user-facing docs."),
|
|
792
|
+
optional("package_exports", 1, COMMON_SUPPORT_EVIDENCE, "Export/type surfaces often carry shared abstraction contracts."),
|
|
793
|
+
optional("runtime_enforcement", 1, COMMON_SUPPORT_EVIDENCE, "Runtime guards and helpers can constrain shared behavior."),
|
|
794
|
+
optional("receipt_audit", 1, COMMON_SUPPORT_EVIDENCE, "Existing receipts or reports help confirm prior behavior.")
|
|
795
|
+
]
|
|
796
|
+
},
|
|
797
|
+
ui_behavior: {
|
|
798
|
+
version: 1,
|
|
799
|
+
changeShape: "ui_behavior",
|
|
800
|
+
label: "UI behavior",
|
|
801
|
+
description: "UI behavior packets need render code and visible surface context, with tests/docs when available.",
|
|
802
|
+
recommendedEscalation: "connected_work_shallow",
|
|
803
|
+
graphInput: {
|
|
804
|
+
intentConfidence: "strong",
|
|
805
|
+
graphComplexity: "shallow",
|
|
806
|
+
connectedWorkAvailable: true,
|
|
807
|
+
noLiveMode: true,
|
|
808
|
+
networkAllowed: false,
|
|
809
|
+
providerCallsAllowed: false
|
|
810
|
+
},
|
|
811
|
+
rules: [
|
|
812
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Primary render/state code must be represented."),
|
|
813
|
+
required("ui_surface", 1, COMMON_SUPPORT_EVIDENCE, "Visible UI surface files must be present."),
|
|
814
|
+
optional("native_counterpart", 1, COMMON_SUPPORT_EVIDENCE, "Native or platform counterpart context prevents platform drift."),
|
|
815
|
+
optional("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "UI regression tests are useful when present."),
|
|
816
|
+
optional("receipt_audit", 1, COMMON_SUPPORT_EVIDENCE, "Trail/receipt display surfaces should remain auditable."),
|
|
817
|
+
optional("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "User-visible behavior may need docs or copy updates.")
|
|
818
|
+
]
|
|
819
|
+
},
|
|
820
|
+
ui_reuse_or_design_system: {
|
|
821
|
+
version: 1,
|
|
822
|
+
changeShape: "ui_reuse_or_design_system",
|
|
823
|
+
label: "UI reuse or design system",
|
|
824
|
+
description: "Reusable UI/design-system opportunities need shared component context, usage sites, package exports, and visible UI surfaces in the same bounded packet.",
|
|
825
|
+
recommendedEscalation: "connected_work_shallow",
|
|
826
|
+
graphInput: {
|
|
827
|
+
intentConfidence: "strong",
|
|
828
|
+
graphComplexity: "shallow",
|
|
829
|
+
connectedWorkAvailable: true,
|
|
830
|
+
noLiveMode: true,
|
|
831
|
+
networkAllowed: false,
|
|
832
|
+
providerCallsAllowed: false
|
|
833
|
+
},
|
|
834
|
+
rules: [
|
|
835
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Primary implementation files must be represented."),
|
|
836
|
+
required("ui_surface", 1, COMMON_SUPPORT_EVIDENCE, "Visible UI surface files must be present."),
|
|
837
|
+
required("design_system_or_shared_component", 1, COMMON_SUPPORT_EVIDENCE, "The shared UI primitive or design-system component must be represented."),
|
|
838
|
+
required("usage_sites", 1, COMMON_SUPPORT_EVIDENCE, "Representative call sites must show how the reusable behavior is consumed."),
|
|
839
|
+
required("package_exports", 1, COMMON_SUPPORT_EVIDENCE, "Package export surfaces must expose or bound the reusable UI contract."),
|
|
840
|
+
optional("native_counterpart", 1, COMMON_SUPPORT_EVIDENCE, "Native or platform counterpart context prevents platform drift."),
|
|
841
|
+
optional("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Reusable UI behavior should have targeted regression tests when available."),
|
|
842
|
+
optional("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "Shared UI behavior may need docs or usage guidance."),
|
|
843
|
+
optional("visual_snapshot_or_story", 1, COMMON_SUPPORT_EVIDENCE, "Visual snapshots or stories help validate reusable UI behavior."),
|
|
844
|
+
optional("migration_notes", 1, COMMON_SUPPORT_EVIDENCE, "Migration notes can bound adoption across usage sites."),
|
|
845
|
+
optional("receipt_audit", 1, COMMON_SUPPORT_EVIDENCE, "Existing reports or receipts help confirm prior UI behavior.")
|
|
846
|
+
]
|
|
847
|
+
},
|
|
848
|
+
execution_safety: {
|
|
849
|
+
version: 1,
|
|
850
|
+
changeShape: "execution_safety",
|
|
851
|
+
label: "Execution safety",
|
|
852
|
+
description: "Safety-sensitive changes need implementation, enforcement, tests, and audit/receipt surfaces.",
|
|
853
|
+
recommendedEscalation: "memgraph_depth5",
|
|
854
|
+
graphInput: {
|
|
855
|
+
intentConfidence: "strong",
|
|
856
|
+
graphComplexity: "high",
|
|
857
|
+
connectedWorkAvailable: true,
|
|
858
|
+
noLiveMode: true,
|
|
859
|
+
networkAllowed: false,
|
|
860
|
+
providerCallsAllowed: false
|
|
861
|
+
},
|
|
862
|
+
rules: [
|
|
863
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Safety behavior must include the primary implementation."),
|
|
864
|
+
required("runtime_enforcement", 1, COMMON_SUPPORT_EVIDENCE, "Policy/enforcement code must be represented."),
|
|
865
|
+
required("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Safety changes require targeted regression tests."),
|
|
866
|
+
optional("config_policy", 1, COMMON_SUPPORT_EVIDENCE, "Environment/config policy can change safety behavior."),
|
|
867
|
+
optional("receipt_audit", 1, COMMON_SUPPORT_EVIDENCE, "Receipt and audit surfaces support post-run proof."),
|
|
868
|
+
optional("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "Operator docs should reflect safety policy."),
|
|
869
|
+
optional("ui_surface", 1, COMMON_SUPPORT_EVIDENCE, "User-facing callbacks or flows can be affected by safety policy.")
|
|
870
|
+
]
|
|
871
|
+
},
|
|
872
|
+
provider_integration: {
|
|
873
|
+
version: 1,
|
|
874
|
+
changeShape: "provider_integration",
|
|
875
|
+
label: "Provider integration",
|
|
876
|
+
description: "Provider-routing changes need gateway/provider code, call-path code, docs, and targeted tests.",
|
|
877
|
+
recommendedEscalation: "memgraph_depth3",
|
|
878
|
+
graphInput: {
|
|
879
|
+
intentConfidence: "strong",
|
|
880
|
+
graphComplexity: "medium",
|
|
881
|
+
connectedWorkAvailable: true,
|
|
882
|
+
noLiveMode: true,
|
|
883
|
+
networkAllowed: false,
|
|
884
|
+
providerCallsAllowed: false
|
|
885
|
+
},
|
|
886
|
+
rules: [
|
|
887
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Provider integration must include primary call-path code."),
|
|
888
|
+
required("provider_gateway", 1, COMMON_SUPPORT_EVIDENCE, "Gateway/provider routing surfaces must be present."),
|
|
889
|
+
required("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Provider fallback behavior needs targeted tests."),
|
|
890
|
+
required("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "Provider integration contracts are user-facing."),
|
|
891
|
+
optional("package_exports", 1, COMMON_SUPPORT_EVIDENCE, "Exported provider contracts should be checked."),
|
|
892
|
+
optional("config_policy", 1, COMMON_SUPPORT_EVIDENCE, "Provider options/config can control routing."),
|
|
893
|
+
optional("runtime_enforcement", 1, COMMON_SUPPORT_EVIDENCE, "Retry/error wrappers enforce provider behavior.")
|
|
894
|
+
]
|
|
895
|
+
},
|
|
896
|
+
agent_handoff: {
|
|
897
|
+
version: 1,
|
|
898
|
+
changeShape: "agent_handoff",
|
|
899
|
+
label: "Agent handoff",
|
|
900
|
+
description: "Agent handoff work needs handoff contracts, docs/work packets, and preferably tests/eval reports.",
|
|
901
|
+
recommendedEscalation: "memgraph_depth3",
|
|
902
|
+
graphInput: {
|
|
903
|
+
intentConfidence: "strong",
|
|
904
|
+
graphComplexity: "medium",
|
|
905
|
+
connectedWorkAvailable: true,
|
|
906
|
+
noLiveMode: true,
|
|
907
|
+
networkAllowed: false,
|
|
908
|
+
providerCallsAllowed: false
|
|
909
|
+
},
|
|
910
|
+
rules: [
|
|
911
|
+
required("agent_handoff", 1, COMMON_SUPPORT_EVIDENCE, "The handoff contract or work packet must be represented."),
|
|
912
|
+
required("primary_code", 1, COMMON_CODE_EVIDENCE, "Primary handoff implementation/contract code must be present."),
|
|
913
|
+
required("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "Agent-facing docs or markdown guidance must be present."),
|
|
914
|
+
optional("eval_report", 1, COMMON_SUPPORT_EVIDENCE, "Eval reports help validate handoff usefulness."),
|
|
915
|
+
optional("receipt_audit", 1, COMMON_SUPPORT_EVIDENCE, "Receipts can prove agent handoff lineage."),
|
|
916
|
+
optional("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Handoff contracts should have targeted tests when available.")
|
|
917
|
+
]
|
|
918
|
+
},
|
|
919
|
+
docs_or_migration: {
|
|
920
|
+
version: 1,
|
|
921
|
+
changeShape: "docs_or_migration",
|
|
922
|
+
label: "Docs or migration",
|
|
923
|
+
description: "Documentation/migration work needs user docs and migration notes, with code/tests when applicable.",
|
|
924
|
+
recommendedEscalation: "connected_work_shallow",
|
|
925
|
+
graphInput: {
|
|
926
|
+
intentConfidence: "strong",
|
|
927
|
+
graphComplexity: "shallow",
|
|
928
|
+
connectedWorkAvailable: true,
|
|
929
|
+
noLiveMode: true,
|
|
930
|
+
networkAllowed: false,
|
|
931
|
+
providerCallsAllowed: false
|
|
932
|
+
},
|
|
933
|
+
rules: [
|
|
934
|
+
required("user_docs", 1, COMMON_SUPPORT_EVIDENCE, "User-facing docs must be represented."),
|
|
935
|
+
required("migration_notes", 1, COMMON_SUPPORT_EVIDENCE, "Migration notes or planning docs must be represented."),
|
|
936
|
+
optional("primary_code", 1, COMMON_CODE_EVIDENCE, "Related implementation code can anchor docs changes."),
|
|
937
|
+
optional("targeted_tests", 1, COMMON_SUPPORT_EVIDENCE, "Tests can validate migration guidance."),
|
|
938
|
+
optional("config_policy", 1, COMMON_SUPPORT_EVIDENCE, "Migration/config policy may be relevant.")
|
|
939
|
+
]
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
function connectedSurfacePolicyForChangeShape(changeShape) {
|
|
943
|
+
return CONNECTED_SURFACE_POLICIES_V1[changeShape];
|
|
944
|
+
}
|
|
945
|
+
// ../core/src/contextRouting/semanticSelectionSignals.ts
|
|
946
|
+
var SEMANTIC_SELECTION_SIGNAL_PREFIX_V1 = "semantic_label:v1";
|
|
947
|
+
var DEFAULT_MAX_SEMANTIC_SELECTION_SIGNALS = 48;
|
|
948
|
+
var CONNECTED_SURFACE_KIND_SET = new Set(CONNECTED_SURFACE_KINDS_V1);
|
|
949
|
+
var TEXT_SURFACE_PATTERNS = [
|
|
950
|
+
{ surfaceKind: "targeted_tests", patterns: [/\b(test|tests|qa|regression|assertion|fixture)\b/i] },
|
|
951
|
+
{ surfaceKind: "user_docs", patterns: [/\b(doc|docs|documentation|readme|guide|operator)\b/i] },
|
|
952
|
+
{ surfaceKind: "config_policy", patterns: [/\b(config|configuration|policy|env|environment|allowlist|setting|option)\b/i] },
|
|
953
|
+
{ surfaceKind: "package_exports", patterns: [/\b(export|exports|public api|barrel|contract|type contract|package)\b/i] },
|
|
954
|
+
{ surfaceKind: "runtime_enforcement", patterns: [/\b(runtime|guard|validation|enforce|safety|auth|redirect|retry|timeout|error|risk)\b/i] },
|
|
955
|
+
{ surfaceKind: "schema_persistence", patterns: [/\b(schema|persistence|database|db|migration|data integrity|storage)\b/i] },
|
|
956
|
+
{ surfaceKind: "ui_surface", patterns: [/\b(ui|render|component|screen|panel|message|style|design system|visible)\b/i] },
|
|
957
|
+
{ surfaceKind: "native_counterpart", patterns: [/\b(native|ios|android|expo|react native|mobile)\b/i] },
|
|
958
|
+
{ surfaceKind: "receipt_audit", patterns: [/\b(receipt|audit|trail|observability|provenance|report)\b/i] },
|
|
959
|
+
{ surfaceKind: "eval_report", patterns: [/\b(eval|evaluation|benchmark|report|fixture|coverage)\b/i] },
|
|
960
|
+
{ surfaceKind: "migration_notes", patterns: [/\b(migration|migrate|upgrade|release note|planning)\b/i] },
|
|
961
|
+
{ surfaceKind: "provider_gateway", patterns: [/\b(provider|gateway|model|routing|registry|fallback|llm)\b/i] },
|
|
962
|
+
{ surfaceKind: "agent_handoff", patterns: [/\b(agent|handoff|brief|work packet|workroom|context plan)\b/i] }
|
|
963
|
+
];
|
|
964
|
+
var CRITICAL_SURFACE_MAP = {
|
|
965
|
+
auth: ["runtime_enforcement", "config_policy"],
|
|
966
|
+
billing: ["runtime_enforcement", "config_policy"],
|
|
967
|
+
onboarding: ["ui_surface", "user_docs"],
|
|
968
|
+
search: ["primary_code"],
|
|
969
|
+
recommendations: ["primary_code"],
|
|
970
|
+
ai_context: ["agent_handoff", "primary_code"],
|
|
971
|
+
evals: ["eval_report", "targeted_tests"],
|
|
972
|
+
deployment: ["config_policy", "user_docs"],
|
|
973
|
+
data_integrity: ["schema_persistence", "runtime_enforcement"],
|
|
974
|
+
privacy: ["runtime_enforcement", "config_policy"],
|
|
975
|
+
observability: ["receipt_audit"],
|
|
976
|
+
design_system: ["ui_surface", "native_counterpart"],
|
|
977
|
+
agent_runtime: ["agent_handoff", "runtime_enforcement"],
|
|
978
|
+
docs_drift: ["user_docs", "migration_notes"],
|
|
979
|
+
code_graph: ["primary_code"]
|
|
980
|
+
};
|
|
981
|
+
function semanticSelectionSignalMappingsFromReadyLabels(labels, options = {}) {
|
|
982
|
+
const includeLabelSignals = options.includeLabelSignals ?? true;
|
|
983
|
+
return labels.filter((label) => label.status === "ready").slice().sort(compareSemanticLabelsForSignals).map((label) => {
|
|
984
|
+
const connectedSurfaceKinds = connectedSurfaceKindsForLabel(label);
|
|
985
|
+
const signals = uniqueStrings2([
|
|
986
|
+
...includeLabelSignals ? [labelSignal(label)] : [],
|
|
987
|
+
...connectedSurfaceKinds.map((surfaceKind) => connectedSurfaceSignal(label, surfaceKind))
|
|
988
|
+
]);
|
|
989
|
+
return {
|
|
990
|
+
labelIdentity: label.labelIdentity,
|
|
991
|
+
nodeId: label.nodeId,
|
|
992
|
+
nodeKey: label.nodeKey,
|
|
993
|
+
filePath: label.filePath,
|
|
994
|
+
source: label.source,
|
|
995
|
+
architectureAuthority: label.architectureAuthority,
|
|
996
|
+
namespace: label.namespace,
|
|
997
|
+
key: label.key,
|
|
998
|
+
normalizedValue: label.normalizedValue,
|
|
999
|
+
connectedSurfaceKinds,
|
|
1000
|
+
signals,
|
|
1001
|
+
reportOnly: true
|
|
1002
|
+
};
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
function semanticSelectionSignalsFromReadyLabels(labels, options = {}) {
|
|
1006
|
+
const maxSignals = options.maxSignals ?? DEFAULT_MAX_SEMANTIC_SELECTION_SIGNALS;
|
|
1007
|
+
return uniqueStrings2(semanticSelectionSignalMappingsFromReadyLabels(labels, options).flatMap((mapping) => mapping.signals)).slice(0, maxSignals);
|
|
1008
|
+
}
|
|
1009
|
+
function semanticSelectionSignalsByFilePath(labels, options = {}) {
|
|
1010
|
+
const byPath = new Map;
|
|
1011
|
+
for (const label of labels) {
|
|
1012
|
+
const path = label.filePath.trim();
|
|
1013
|
+
if (!path)
|
|
1014
|
+
continue;
|
|
1015
|
+
byPath.set(path, [...byPath.get(path) ?? [], label]);
|
|
1016
|
+
}
|
|
1017
|
+
return Object.fromEntries(Array.from(byPath.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([path, pathLabels]) => [path, semanticSelectionSignalsFromReadyLabels(pathLabels, options)]));
|
|
1018
|
+
}
|
|
1019
|
+
function connectedSurfaceKindsForSemanticLabel(label) {
|
|
1020
|
+
return connectedSurfaceKindsForLabel(label);
|
|
1021
|
+
}
|
|
1022
|
+
function connectedSurfaceKindsForLabel(label) {
|
|
1023
|
+
if (label.status !== "ready")
|
|
1024
|
+
return [];
|
|
1025
|
+
const normalizedValue = normalizeSignalPart(label.normalizedValue || label.value);
|
|
1026
|
+
const directSurface = surfaceKindFromValue(normalizedValue);
|
|
1027
|
+
const kinds = [];
|
|
1028
|
+
if (directSurface)
|
|
1029
|
+
kinds.push(directSurface);
|
|
1030
|
+
if (label.namespace === "connected_surface") {
|
|
1031
|
+
const fromValue = surfaceKindFromValue(label.normalizedValue) ?? surfaceKindFromValue(label.value);
|
|
1032
|
+
if (fromValue)
|
|
1033
|
+
kinds.push(fromValue);
|
|
1034
|
+
}
|
|
1035
|
+
if (label.namespace === "parser") {
|
|
1036
|
+
if (label.key === "node_type" || label.key === "language" || label.key === "import" || label.key === "call") {
|
|
1037
|
+
kinds.push("primary_code");
|
|
1038
|
+
}
|
|
1039
|
+
if (label.key === "is_exported" && normalizedValue === "true")
|
|
1040
|
+
kinds.push("package_exports");
|
|
1041
|
+
if (["has_parse_warnings", "has_parse_error", "has_fallback"].includes(label.key) && normalizedValue === "true") {
|
|
1042
|
+
kinds.push("runtime_enforcement");
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (label.namespace === "critical_surface") {
|
|
1046
|
+
kinds.push(...CRITICAL_SURFACE_MAP[normalizedValue] ?? []);
|
|
1047
|
+
}
|
|
1048
|
+
if (label.namespace === "code_role" || label.namespace === "architecture_layer") {
|
|
1049
|
+
kinds.push(...surfaceKindsFromText(`${label.key} ${label.value}`));
|
|
1050
|
+
}
|
|
1051
|
+
if (["focus_lens", "audience", "intent", "tag", "feature_label", "risk"].includes(label.namespace)) {
|
|
1052
|
+
kinds.push(...surfaceKindsFromText(`${label.namespace} ${label.key} ${label.value}`));
|
|
1053
|
+
}
|
|
1054
|
+
return uniqueSurfaceKinds(kinds);
|
|
1055
|
+
}
|
|
1056
|
+
function surfaceKindFromValue(value) {
|
|
1057
|
+
const normalized = normalizeSignalPart(value);
|
|
1058
|
+
if (CONNECTED_SURFACE_KIND_SET.has(normalized))
|
|
1059
|
+
return normalized;
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
function surfaceKindsFromText(text) {
|
|
1063
|
+
const kinds = [];
|
|
1064
|
+
for (const item of TEXT_SURFACE_PATTERNS) {
|
|
1065
|
+
if (item.patterns.some((pattern) => pattern.test(text)))
|
|
1066
|
+
kinds.push(item.surfaceKind);
|
|
1067
|
+
}
|
|
1068
|
+
return uniqueSurfaceKinds(kinds);
|
|
1069
|
+
}
|
|
1070
|
+
function labelSignal(label) {
|
|
1071
|
+
return [
|
|
1072
|
+
SEMANTIC_SELECTION_SIGNAL_PREFIX_V1,
|
|
1073
|
+
label.source,
|
|
1074
|
+
label.architectureAuthority,
|
|
1075
|
+
"label",
|
|
1076
|
+
signalToken(label.namespace),
|
|
1077
|
+
signalToken(label.key),
|
|
1078
|
+
signalToken(label.normalizedValue || label.value)
|
|
1079
|
+
].join(":");
|
|
1080
|
+
}
|
|
1081
|
+
function connectedSurfaceSignal(label, surfaceKind) {
|
|
1082
|
+
return [
|
|
1083
|
+
SEMANTIC_SELECTION_SIGNAL_PREFIX_V1,
|
|
1084
|
+
label.source,
|
|
1085
|
+
label.architectureAuthority,
|
|
1086
|
+
"connected_surface",
|
|
1087
|
+
surfaceKind
|
|
1088
|
+
].join(":");
|
|
1089
|
+
}
|
|
1090
|
+
function compareSemanticLabelsForSignals(left, right) {
|
|
1091
|
+
return left.filePath.localeCompare(right.filePath) || (left.startLine ?? 0) - (right.startLine ?? 0) || left.namespace.localeCompare(right.namespace) || left.key.localeCompare(right.key) || left.normalizedValue.localeCompare(right.normalizedValue) || left.source.localeCompare(right.source) || left.architectureAuthority.localeCompare(right.architectureAuthority) || left.labelIdentity.localeCompare(right.labelIdentity);
|
|
1092
|
+
}
|
|
1093
|
+
function signalToken(value) {
|
|
1094
|
+
return normalizeSignalPart(value).replace(/[^a-z0-9_.-]+/g, "_").replace(/^_+|_+$/g, "") || "unknown";
|
|
1095
|
+
}
|
|
1096
|
+
function normalizeSignalPart(value) {
|
|
1097
|
+
return value.trim().normalize("NFKC").replace(/\s+/g, "_").toLowerCase();
|
|
1098
|
+
}
|
|
1099
|
+
function uniqueSurfaceKinds(values) {
|
|
1100
|
+
const seen = new Set;
|
|
1101
|
+
const output = [];
|
|
1102
|
+
for (const surfaceKind of values) {
|
|
1103
|
+
if (seen.has(surfaceKind))
|
|
1104
|
+
continue;
|
|
1105
|
+
seen.add(surfaceKind);
|
|
1106
|
+
output.push(surfaceKind);
|
|
1107
|
+
}
|
|
1108
|
+
return output;
|
|
1109
|
+
}
|
|
1110
|
+
function uniqueStrings2(values) {
|
|
1111
|
+
const seen = new Set;
|
|
1112
|
+
const output = [];
|
|
1113
|
+
for (const value of values) {
|
|
1114
|
+
const trimmed = value.trim();
|
|
1115
|
+
if (!trimmed || seen.has(trimmed))
|
|
1116
|
+
continue;
|
|
1117
|
+
seen.add(trimmed);
|
|
1118
|
+
output.push(trimmed);
|
|
1119
|
+
}
|
|
1120
|
+
return output;
|
|
1121
|
+
}
|
|
1122
|
+
// ../core/src/contextRouting/semanticGraphRouting.ts
|
|
1123
|
+
var SEMANTIC_GRAPH_ROUTING_REPORT_VERSION = 1;
|
|
1124
|
+
var DEFAULT_MAX_TOP_PATHS = 6;
|
|
1125
|
+
var PUBLIC_SURFACES = new Set(["package_exports", "user_docs"]);
|
|
1126
|
+
var CRITICAL_SURFACES = new Set([
|
|
1127
|
+
"runtime_enforcement",
|
|
1128
|
+
"config_policy",
|
|
1129
|
+
"schema_persistence",
|
|
1130
|
+
"receipt_audit"
|
|
1131
|
+
]);
|
|
1132
|
+
var TOKEN_VALUE_NAMESPACES = new Set(["focus_lens", "audience", "intent", "tag", "feature_label", "risk", "context_packet"]);
|
|
1133
|
+
function buildGraphExecutionModeInputFromSemanticLabels(labels, options = {}) {
|
|
1134
|
+
return buildSemanticGraphRoutingReportFromLabels(labels, options).input;
|
|
1135
|
+
}
|
|
1136
|
+
function buildSemanticGraphRoutingReportFromLabels(labels, options = {}) {
|
|
1137
|
+
const sortedLabels = labels.slice().sort(compareLabels);
|
|
1138
|
+
const readyLabels = sortedLabels.filter((label) => label.status === "ready");
|
|
1139
|
+
const parserFactLabels = readyLabels.filter(isParserFactLabel);
|
|
1140
|
+
const advisoryLabels = readyLabels.filter((label) => !isParserFactLabel(label));
|
|
1141
|
+
const fanout = buildFanout(readyLabels);
|
|
1142
|
+
const surfaces = uniqueSurfaces(fanout.flatMap((item) => item.connectedSurfaceKinds));
|
|
1143
|
+
const surfaceCounts = countSurfaces(fanout);
|
|
1144
|
+
const signals = semanticGraphRoutingSignals({ labels: readyLabels, fanout, surfaces });
|
|
1145
|
+
const input = graphInputFromSignals({ readyLabels, parserFactLabels, advisoryLabels, surfaces, signals, fanout, options });
|
|
1146
|
+
const changeShape = changeShapeFromSemanticSignals({ signals, surfaces });
|
|
1147
|
+
const routingPolicy = chooseGraphRoutingPolicyV1({
|
|
1148
|
+
taskKind: graphRoutingTaskKindFromSemanticSignals({ parserFactLabels, signals, surfaces }),
|
|
1149
|
+
...changeShape ? { changeShape } : {},
|
|
1150
|
+
connectedWorkAvailable: input.connectedWorkAvailable ?? false,
|
|
1151
|
+
memgraphAvailable: input.memgraphAvailable ?? false,
|
|
1152
|
+
llmAvailable: input.llmAvailable ?? false,
|
|
1153
|
+
noLiveMode: input.noLiveMode ?? true,
|
|
1154
|
+
networkAllowed: input.networkAllowed ?? false,
|
|
1155
|
+
providerCallsAllowed: input.providerCallsAllowed ?? false
|
|
1156
|
+
});
|
|
1157
|
+
return {
|
|
1158
|
+
version: SEMANTIC_GRAPH_ROUTING_REPORT_VERSION,
|
|
1159
|
+
reportOnly: true,
|
|
1160
|
+
deterministic: true,
|
|
1161
|
+
input,
|
|
1162
|
+
routingPolicy,
|
|
1163
|
+
evidence: {
|
|
1164
|
+
version: SEMANTIC_GRAPH_ROUTING_REPORT_VERSION,
|
|
1165
|
+
reportOnly: true,
|
|
1166
|
+
deterministic: true,
|
|
1167
|
+
parserFactsAuthoritative: true,
|
|
1168
|
+
advisoryOnly: true,
|
|
1169
|
+
promotedAdvisoryLabelsToTruth: false,
|
|
1170
|
+
labelCount: labels.length,
|
|
1171
|
+
readyLabelCount: readyLabels.length,
|
|
1172
|
+
parserFactLabelCount: parserFactLabels.length,
|
|
1173
|
+
advisoryLabelCount: advisoryLabels.length,
|
|
1174
|
+
sourceCounts: countSources(sortedLabels),
|
|
1175
|
+
namespaceCounts: countNamespaces(sortedLabels),
|
|
1176
|
+
surfaceCounts,
|
|
1177
|
+
surfaces,
|
|
1178
|
+
signals,
|
|
1179
|
+
semanticFanout: {
|
|
1180
|
+
pathCount: fanout.length,
|
|
1181
|
+
maxReadyLabelsPerPath: max(fanout.map((item) => item.labels.length)),
|
|
1182
|
+
maxConnectedSurfacesPerPath: max(fanout.map((item) => item.connectedSurfaceKinds.length)),
|
|
1183
|
+
topPaths: fanout.slice(0, options.maxTopPaths ?? DEFAULT_MAX_TOP_PATHS).map((item) => ({
|
|
1184
|
+
path: item.path,
|
|
1185
|
+
readyLabelCount: item.labels.length,
|
|
1186
|
+
connectedSurfaceKinds: item.connectedSurfaceKinds
|
|
1187
|
+
}))
|
|
1188
|
+
},
|
|
1189
|
+
recommendationEvidence: recommendationEvidence({ parserFactLabels, advisoryLabels, surfaces, signals })
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
function graphRoutingTaskKindFromSemanticSignals(input) {
|
|
1194
|
+
if (input.signals.includes("token_value_surface") && input.parserFactLabels.length === 0)
|
|
1195
|
+
return "deep_synthesis";
|
|
1196
|
+
if (input.signals.includes("provider_surface") || input.surfaces.includes("provider_gateway"))
|
|
1197
|
+
return "provider_integration_impact";
|
|
1198
|
+
if (input.signals.includes("critical_surface") || input.signals.includes("receipt_surface") || input.signals.includes("schema_surface") || input.surfaces.includes("runtime_enforcement") || input.surfaces.includes("receipt_audit") || input.surfaces.includes("schema_persistence")) {
|
|
1199
|
+
return "execution_safety_impact";
|
|
1200
|
+
}
|
|
1201
|
+
if (input.surfaces.includes("agent_handoff"))
|
|
1202
|
+
return "agent_handoff_planning";
|
|
1203
|
+
if (input.signals.includes("public_surface") || input.surfaces.includes("user_docs"))
|
|
1204
|
+
return "docs_code_alignment";
|
|
1205
|
+
if (input.signals.includes("semantic_fanout") || input.surfaces.length >= 2)
|
|
1206
|
+
return "shared_abstraction_review";
|
|
1207
|
+
if (input.surfaces.length > 0)
|
|
1208
|
+
return "changed_file_impact";
|
|
1209
|
+
return "local_symbol_lookup";
|
|
1210
|
+
}
|
|
1211
|
+
function changeShapeFromSemanticSignals(input) {
|
|
1212
|
+
if (input.signals.includes("provider_surface") || input.surfaces.includes("provider_gateway"))
|
|
1213
|
+
return "provider_integration";
|
|
1214
|
+
if (input.signals.includes("critical_surface") || input.signals.includes("receipt_surface") || input.signals.includes("schema_surface") || input.surfaces.includes("runtime_enforcement") || input.surfaces.includes("receipt_audit") || input.surfaces.includes("schema_persistence")) {
|
|
1215
|
+
return "execution_safety";
|
|
1216
|
+
}
|
|
1217
|
+
if (input.surfaces.includes("agent_handoff"))
|
|
1218
|
+
return "agent_handoff";
|
|
1219
|
+
if (input.surfaces.includes("ui_surface"))
|
|
1220
|
+
return "ui_behavior";
|
|
1221
|
+
if (input.signals.includes("public_surface") || input.surfaces.includes("user_docs"))
|
|
1222
|
+
return "docs_or_migration";
|
|
1223
|
+
if (input.signals.includes("semantic_fanout") || input.surfaces.length >= 2)
|
|
1224
|
+
return "shared_abstraction";
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
function graphInputFromSignals(input) {
|
|
1228
|
+
const hasReadyLabels = input.readyLabels.length > 0;
|
|
1229
|
+
const hasParserFacts = input.parserFactLabels.length > 0;
|
|
1230
|
+
const hasAdvisoryTokenValue = input.signals.includes("token_value_surface");
|
|
1231
|
+
const graphComplexity = graphComplexityFromSignals(input);
|
|
1232
|
+
const intentConfidence = hasAdvisoryTokenValue && !hasParserFacts ? "ambiguous" : hasParserFacts ? "strong" : hasReadyLabels ? "weak" : undefined;
|
|
1233
|
+
const output = {
|
|
1234
|
+
localGraphConfidence: localGraphConfidence(input.parserFactLabels, input.advisoryLabels),
|
|
1235
|
+
connectedWorkAvailable: input.options.connectedWorkAvailable ?? (hasReadyLabels && input.surfaces.length > 0),
|
|
1236
|
+
memgraphAvailable: input.options.memgraphAvailable ?? false,
|
|
1237
|
+
llmAvailable: input.options.llmAvailable ?? false,
|
|
1238
|
+
noLiveMode: input.options.noLiveMode ?? true,
|
|
1239
|
+
networkAllowed: input.options.networkAllowed ?? false,
|
|
1240
|
+
providerCallsAllowed: input.options.providerCallsAllowed ?? false,
|
|
1241
|
+
synthesisRequested: hasAdvisoryTokenValue && !hasParserFacts
|
|
1242
|
+
};
|
|
1243
|
+
if (intentConfidence)
|
|
1244
|
+
output.intentConfidence = intentConfidence;
|
|
1245
|
+
if (graphComplexity)
|
|
1246
|
+
output.graphComplexity = graphComplexity;
|
|
1247
|
+
return output;
|
|
1248
|
+
}
|
|
1249
|
+
function graphComplexityFromSignals(input) {
|
|
1250
|
+
if (input.readyLabels.length === 0)
|
|
1251
|
+
return;
|
|
1252
|
+
if (input.signals.includes("critical_surface") && (input.signals.includes("receipt_surface") || input.signals.includes("schema_surface"))) {
|
|
1253
|
+
return "high";
|
|
1254
|
+
}
|
|
1255
|
+
if (input.signals.includes("provider_surface") && (input.signals.includes("schema_surface") || input.signals.includes("testability_surface"))) {
|
|
1256
|
+
return "high";
|
|
1257
|
+
}
|
|
1258
|
+
if (input.surfaces.length >= 6 || max(input.fanout.map((item) => item.connectedSurfaceKinds.length)) >= 5)
|
|
1259
|
+
return "high";
|
|
1260
|
+
if (input.signals.includes("semantic_fanout") || input.surfaces.length >= 3)
|
|
1261
|
+
return "medium";
|
|
1262
|
+
if (input.signals.includes("connected_surface") || input.signals.includes("public_surface"))
|
|
1263
|
+
return "shallow";
|
|
1264
|
+
return input.parserFactLabels.length > 0 ? "simple" : undefined;
|
|
1265
|
+
}
|
|
1266
|
+
function localGraphConfidence(parserFactLabels, advisoryLabels) {
|
|
1267
|
+
if (parserFactLabels.length > 0)
|
|
1268
|
+
return 0.9;
|
|
1269
|
+
if (advisoryLabels.length > 0)
|
|
1270
|
+
return 0.65;
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
function semanticGraphRoutingSignals(input) {
|
|
1274
|
+
const signals = [];
|
|
1275
|
+
const surfaceSet = new Set(input.surfaces);
|
|
1276
|
+
if (input.fanout.some((item) => item.labels.length >= 4 || item.connectedSurfaceKinds.length >= 3))
|
|
1277
|
+
signals.push("semantic_fanout");
|
|
1278
|
+
if (input.surfaces.some((surface) => PUBLIC_SURFACES.has(surface)))
|
|
1279
|
+
signals.push("public_surface");
|
|
1280
|
+
if (input.surfaces.some((surface) => CRITICAL_SURFACES.has(surface)) || hasRoutingFactNamespace(input.labels, "critical_surface"))
|
|
1281
|
+
signals.push("critical_surface");
|
|
1282
|
+
if (input.surfaces.length > 0 || hasRoutingFactNamespace(input.labels, "connected_surface"))
|
|
1283
|
+
signals.push("connected_surface");
|
|
1284
|
+
if (surfaceSet.has("provider_gateway"))
|
|
1285
|
+
signals.push("provider_surface");
|
|
1286
|
+
if (surfaceSet.has("schema_persistence"))
|
|
1287
|
+
signals.push("schema_surface");
|
|
1288
|
+
if (surfaceSet.has("receipt_audit"))
|
|
1289
|
+
signals.push("receipt_surface");
|
|
1290
|
+
if (surfaceSet.has("targeted_tests") || surfaceSet.has("eval_report"))
|
|
1291
|
+
signals.push("testability_surface");
|
|
1292
|
+
if (input.labels.some((label) => TOKEN_VALUE_NAMESPACES.has(label.namespace)))
|
|
1293
|
+
signals.push("token_value_surface");
|
|
1294
|
+
return signals;
|
|
1295
|
+
}
|
|
1296
|
+
function buildFanout(labels) {
|
|
1297
|
+
const byPath = new Map;
|
|
1298
|
+
for (const label of labels) {
|
|
1299
|
+
const path = label.filePath.trim();
|
|
1300
|
+
if (!path)
|
|
1301
|
+
continue;
|
|
1302
|
+
byPath.set(path, [...byPath.get(path) ?? [], label]);
|
|
1303
|
+
}
|
|
1304
|
+
return Array.from(byPath.entries()).map(([path, pathLabels]) => ({
|
|
1305
|
+
path,
|
|
1306
|
+
labels: pathLabels.sort(compareLabels),
|
|
1307
|
+
connectedSurfaceKinds: uniqueSurfaces(pathLabels.flatMap(connectedSurfaceKindsForRoutingLabel))
|
|
1308
|
+
})).sort((left, right) => right.connectedSurfaceKinds.length - left.connectedSurfaceKinds.length || right.labels.length - left.labels.length || compareStable(left.path, right.path));
|
|
1309
|
+
}
|
|
1310
|
+
function connectedSurfaceKindsForRoutingLabel(label) {
|
|
1311
|
+
if (label.source === "llm" && label.architectureAuthority === "advisory_only")
|
|
1312
|
+
return [];
|
|
1313
|
+
return connectedSurfaceKindsForSemanticLabel(label);
|
|
1314
|
+
}
|
|
1315
|
+
function recommendationEvidence(input) {
|
|
1316
|
+
return [
|
|
1317
|
+
`parser_fact_labels:${input.parserFactLabels.length}`,
|
|
1318
|
+
`advisory_labels:${input.advisoryLabels.length}`,
|
|
1319
|
+
...input.signals.map((signal) => `signal:${signal}`),
|
|
1320
|
+
...input.surfaces.map((surface) => `surface:${surface}`),
|
|
1321
|
+
`selection_signals:${semanticSelectionSignalsFromReadyLabels([...input.parserFactLabels, ...input.advisoryLabels]).length}`
|
|
1322
|
+
];
|
|
1323
|
+
}
|
|
1324
|
+
function countSources(labels) {
|
|
1325
|
+
return {
|
|
1326
|
+
parser: labels.filter((label) => label.source === "parser").length,
|
|
1327
|
+
heuristic: labels.filter((label) => label.source === "heuristic").length,
|
|
1328
|
+
llm: labels.filter((label) => label.source === "llm").length
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
function countNamespaces(labels) {
|
|
1332
|
+
const counts = new Map;
|
|
1333
|
+
for (const label of labels)
|
|
1334
|
+
counts.set(label.namespace, (counts.get(label.namespace) ?? 0) + 1);
|
|
1335
|
+
return Object.fromEntries(Array.from(counts.entries()).sort(([left], [right]) => compareStable(left, right)));
|
|
1336
|
+
}
|
|
1337
|
+
function countSurfaces(fanout) {
|
|
1338
|
+
const counts = new Map;
|
|
1339
|
+
for (const item of fanout) {
|
|
1340
|
+
for (const surface of item.connectedSurfaceKinds)
|
|
1341
|
+
counts.set(surface, (counts.get(surface) ?? 0) + 1);
|
|
1342
|
+
}
|
|
1343
|
+
return Object.fromEntries(Array.from(counts.entries()).sort(([left], [right]) => compareStable(left, right)));
|
|
1344
|
+
}
|
|
1345
|
+
function isParserFactLabel(label) {
|
|
1346
|
+
return label.source === "parser" && label.architectureAuthority === "parser_fact";
|
|
1347
|
+
}
|
|
1348
|
+
function hasRoutingFactNamespace(labels, namespace) {
|
|
1349
|
+
return labels.some((label) => label.namespace === namespace && (label.source !== "llm" || isParserFactLabel(label)));
|
|
1350
|
+
}
|
|
1351
|
+
function compareLabels(left, right) {
|
|
1352
|
+
return compareStable(left.filePath, right.filePath) || (left.startLine ?? 0) - (right.startLine ?? 0) || compareStable(left.namespace, right.namespace) || compareStable(left.key, right.key) || compareStable(left.normalizedValue, right.normalizedValue) || compareStable(left.source, right.source) || compareStable(left.architectureAuthority, right.architectureAuthority) || compareStable(left.labelIdentity, right.labelIdentity);
|
|
1353
|
+
}
|
|
1354
|
+
function compareStable(left, right) {
|
|
1355
|
+
if (left < right)
|
|
1356
|
+
return -1;
|
|
1357
|
+
if (left > right)
|
|
1358
|
+
return 1;
|
|
1359
|
+
return 0;
|
|
1360
|
+
}
|
|
1361
|
+
function max(values) {
|
|
1362
|
+
return values.reduce((highest, value) => Math.max(highest, value), 0);
|
|
1363
|
+
}
|
|
1364
|
+
function uniqueSurfaces(values) {
|
|
1365
|
+
return Array.from(new Set(values)).sort(compareStable);
|
|
1366
|
+
}
|
|
1367
|
+
// ../core/src/contextRouting/connectedSurfaceCoverage.ts
|
|
1368
|
+
var CONNECTED_SURFACE_COVERAGE_REPORT_VERSION = 1;
|
|
1369
|
+
var CHANGE_SHAPE_TIE_PRIORITY = [
|
|
1370
|
+
"provider_integration",
|
|
1371
|
+
"execution_safety",
|
|
1372
|
+
"agent_handoff",
|
|
1373
|
+
"ui_reuse_or_design_system",
|
|
1374
|
+
"ui_behavior",
|
|
1375
|
+
"shared_abstraction",
|
|
1376
|
+
"docs_or_migration"
|
|
1377
|
+
];
|
|
1378
|
+
var SURFACE_PAIR_DEFINITIONS = [
|
|
1379
|
+
{
|
|
1380
|
+
pairId: "runtime_enforcement__targeted_tests",
|
|
1381
|
+
left: "runtime_enforcement",
|
|
1382
|
+
right: "targeted_tests",
|
|
1383
|
+
repairHint: "Add targeted regression tests for the runtime enforcement surface.",
|
|
1384
|
+
suggestedPathPatterns: ["**/*test.ts", "convex-tests/**/*.test.ts", "test/**/*.ts"]
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
pairId: "provider_gateway__primary_code",
|
|
1388
|
+
left: "provider_gateway",
|
|
1389
|
+
right: "primary_code",
|
|
1390
|
+
repairHint: "Pair provider gateway files with the primary call-path code they route.",
|
|
1391
|
+
suggestedPathPatterns: ["**/provider*.ts", "**/gateway*.ts", "**/generate-text*.ts", "**/stream-text*.ts"]
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
pairId: "receipt_audit__runtime_enforcement",
|
|
1395
|
+
left: "receipt_audit",
|
|
1396
|
+
right: "runtime_enforcement",
|
|
1397
|
+
repairHint: "Pair receipt/audit evidence with the runtime enforcement path it proves.",
|
|
1398
|
+
suggestedPathPatterns: ["**/*receipt*.ts", "**/*trail*.ts", "prompt-exports/**/*.md"]
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
pairId: "ui_surface__native_counterpart",
|
|
1402
|
+
left: "ui_surface",
|
|
1403
|
+
right: "native_counterpart",
|
|
1404
|
+
repairHint: "Check whether a native counterpart is needed for the UI surface.",
|
|
1405
|
+
suggestedPathPatterns: ["**/*.native.tsx", "apps/expo/**/*.tsx", "packages/ui/**/*.native.tsx"]
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
pairId: "design_system_or_shared_component__usage_sites",
|
|
1409
|
+
left: "design_system_or_shared_component",
|
|
1410
|
+
right: "usage_sites",
|
|
1411
|
+
repairHint: "Pair the shared UI/design-system surface with representative usage sites.",
|
|
1412
|
+
suggestedPathPatterns: ["packages/ui/**/*.tsx", "apps/**/*.tsx", "**/*.stories.tsx"]
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
pairId: "agent_handoff__package_exports",
|
|
1416
|
+
left: "agent_handoff",
|
|
1417
|
+
right: "package_exports",
|
|
1418
|
+
repairHint: "Pair agent handoff guidance with exported contracts/types consumed by agents.",
|
|
1419
|
+
suggestedPathPatterns: ["**/index.ts", "packages/core/src/briefs/**/*.ts", "packages/core/src/contextRouting/**/*.ts"]
|
|
1420
|
+
}
|
|
1421
|
+
];
|
|
1422
|
+
var CASE_ID_PATTERNS = {
|
|
1423
|
+
provider_integration: [/provider/i, /gateway/i, /vercel-ai/i, /routing/i],
|
|
1424
|
+
execution_safety: [/auth/i, /redirect/i, /safety/i, /receipt/i, /validation/i],
|
|
1425
|
+
agent_handoff: [/agent/i, /handoff/i, /work-?brief/i, /context-?plan/i],
|
|
1426
|
+
ui_reuse_or_design_system: [/reuse/i, /design[-_ ]?system/i, /shared[-_ ]?ui/i, /component[-_ ]?reuse/i, /shared[-_ ]?component/i, /faded[-_ ]?disclosure/i, /package[-_ ]?export/i],
|
|
1427
|
+
ui_behavior: [/ui/i, /chat/i, /message/i, /panel/i, /runtime/i],
|
|
1428
|
+
shared_abstraction: [/shared/i, /abstraction/i, /retry/i, /ky/i, /core/i],
|
|
1429
|
+
docs_or_migration: [/docs/i, /migration/i, /markdown/i, /readme/i]
|
|
1430
|
+
};
|
|
1431
|
+
var INTENT_PATTERNS = {
|
|
1432
|
+
provider_integration: [/provider/i, /gateway/i, /routing/i, /fallback/i, /model/i],
|
|
1433
|
+
execution_safety: [/harden/i, /safe/i, /safety/i, /auth/i, /redirect/i, /receipt/i, /validation/i],
|
|
1434
|
+
agent_handoff: [/agent/i, /handoff/i, /brief/i, /context plan/i, /work packet/i],
|
|
1435
|
+
ui_reuse_or_design_system: [/faded disclosure/i, /fade/i, /gradient mask/i, /mask image/i, /shared ui/i, /component reuse/i, /duplicated UI behavior/i, /message bubble/i, /side panel/i, /spotlight/i, /thread list/i, /thinking indicator/i, /design system/i, /package export/i, /shared component/i],
|
|
1436
|
+
ui_behavior: [/ui/i, /render/i, /message/i, /panel/i, /runtime/i, /visible/i],
|
|
1437
|
+
shared_abstraction: [/shared/i, /contract/i, /retry/i, /behavior/i, /options/i, /hooks/i],
|
|
1438
|
+
docs_or_migration: [/docs/i, /documentation/i, /migration/i, /readme/i, /operator/i]
|
|
1439
|
+
};
|
|
1440
|
+
var PATH_PATTERNS = {
|
|
1441
|
+
provider_integration: [/provider/i, /gateway/i, /generate-text/i, /stream-text/i, /resolve-model/i, /registry/i, /model/i],
|
|
1442
|
+
execution_safety: [/auth/i, /redirect/i, /validation/i, /executionSafety/i, /receipt/i, /guard/i, /policy/i],
|
|
1443
|
+
agent_handoff: [/agent/i, /handoff/i, /workBrief/i, /work-brief/i, /contextPlan/i, /prompt-exports/i, /briefs/i],
|
|
1444
|
+
ui_reuse_or_design_system: [/packages\/ui/i, /design[-_ ]?system/i, /shared[-_ ]?component/i, /faded[-_ ]?disclosure/i, /stories?\./i, /visual[-_ ]?snapshot/i, /message[-_ ]?bubble/i, /side[-_ ]?panel/i, /thread[-_ ]?list/i, /thinking[-_ ]?indicator/i],
|
|
1445
|
+
ui_behavior: [/\.tsx$/i, /components/i, /ui/i, /expo/i, /native/i, /Message/i, /Panel/i, /styles/i],
|
|
1446
|
+
shared_abstraction: [/core/i, /types/i, /utils/i, /retry/i, /options/i, /hooks/i, /constants/i, /packages\/core/i],
|
|
1447
|
+
docs_or_migration: [/docs/i, /migration/i, /readme/i, /\.mdx?$/i, /prompt-exports/i]
|
|
1448
|
+
};
|
|
1449
|
+
function classifyConnectedSurfaceChangeShape(input) {
|
|
1450
|
+
const scores = zeroScores();
|
|
1451
|
+
const signals = [];
|
|
1452
|
+
const caseId = input.caseId ?? "";
|
|
1453
|
+
const intent = input.intent ?? input.packet.objective ?? "";
|
|
1454
|
+
const paths = packetPaths(input.packet);
|
|
1455
|
+
const selectionSignals = input.packet.contextSlices.flatMap((slice) => slice.selectionSignals ?? []);
|
|
1456
|
+
const roleContentSignals = input.packet.contextSlices.map((slice) => `${slice.role}:${slice.contentMode ?? "none"}:${slice.path}`);
|
|
1457
|
+
const refs = [...input.packet.sourceRefs, ...input.packet.evidenceRefs, ...input.packet.receiptRefs];
|
|
1458
|
+
addSignals(scores, signals, "case_id", caseId, 10, CASE_ID_PATTERNS);
|
|
1459
|
+
for (const value of selectionSignals)
|
|
1460
|
+
addSelectionSignal(scores, signals, value);
|
|
1461
|
+
addSignals(scores, signals, "intent_phrase", intent, 3, INTENT_PATTERNS);
|
|
1462
|
+
for (const path of paths)
|
|
1463
|
+
addSignals(scores, signals, "path_pattern", path, 2, PATH_PATTERNS);
|
|
1464
|
+
for (const value of roleContentSignals)
|
|
1465
|
+
addRoleContentSignal(scores, signals, value);
|
|
1466
|
+
for (const ref of refs)
|
|
1467
|
+
addSignals(scores, signals, "ref_signal", ref, 1, PATH_PATTERNS);
|
|
1468
|
+
const total = Object.values(scores).reduce((sum, score) => sum + score, 0);
|
|
1469
|
+
if (total === 0) {
|
|
1470
|
+
scores.shared_abstraction = 1;
|
|
1471
|
+
signals.push({ changeShape: "shared_abstraction", source: "fallback", weight: 1, value: "no_signal_shared_abstraction" });
|
|
1472
|
+
}
|
|
1473
|
+
const changeShape = CHANGE_SHAPE_TIE_PRIORITY.reduce((best, candidate) => {
|
|
1474
|
+
if (scores[candidate] > scores[best])
|
|
1475
|
+
return candidate;
|
|
1476
|
+
return best;
|
|
1477
|
+
}, CHANGE_SHAPE_TIE_PRIORITY[0]);
|
|
1478
|
+
const winningScore = scores[changeShape];
|
|
1479
|
+
const confidence = winningScore >= 10 ? "high" : winningScore >= 5 ? "medium" : "low";
|
|
1480
|
+
return { changeShape, confidence, scores, signals };
|
|
1481
|
+
}
|
|
1482
|
+
function scoreConnectedSurfaceCoverage(input) {
|
|
1483
|
+
const caseId = input.caseId ?? input.packet.packetId;
|
|
1484
|
+
const classification = classifyConnectedSurfaceChangeShape({
|
|
1485
|
+
caseId,
|
|
1486
|
+
intent: input.intent,
|
|
1487
|
+
packet: input.packet
|
|
1488
|
+
});
|
|
1489
|
+
const policy = connectedSurfacePolicyForChangeShape(classification.changeShape);
|
|
1490
|
+
const evidence = buildEvidenceIndex(input.packet);
|
|
1491
|
+
const allowedPaths = new Set((input.allowedPaths ?? evidence.map((item) => item.path)).filter(Boolean));
|
|
1492
|
+
const surfaceResults = policy.rules.map((rule) => scoreRule(rule, evidence));
|
|
1493
|
+
const requiredResults = surfaceResults.filter((result) => result.level === "required");
|
|
1494
|
+
const optionalResults = surfaceResults.filter((result) => result.level === "optional");
|
|
1495
|
+
const requiredCoverage = coverageCount(requiredResults.filter((result) => result.passed).length, requiredResults.length) ?? 1;
|
|
1496
|
+
const optionalCoverage = coverageCount(optionalResults.filter((result) => result.passed).length, optionalResults.length);
|
|
1497
|
+
const missingCriticalCount = requiredResults.filter((result) => !result.passed).length;
|
|
1498
|
+
const inventedPathCount = evidence.filter((item) => !allowedPaths.has(item.path)).length;
|
|
1499
|
+
const evidenceKinds = evidence.map((item) => evidenceSurfaceKinds(item));
|
|
1500
|
+
const lowValueEvidenceCount = evidenceKinds.filter((kinds) => kinds.length === 0).length;
|
|
1501
|
+
const coveredSurfaceKinds = new Set(surfaceResults.filter((result) => result.passed).map((result) => result.surfaceKind));
|
|
1502
|
+
const expectedSurfaceKinds = new Set(policy.rules.map((rule) => rule.surfaceKind));
|
|
1503
|
+
const observedSurfaceKinds = new Set(evidenceKinds.flat());
|
|
1504
|
+
const overIncludedSurfaceCount = Array.from(observedSurfaceKinds).filter((surfaceKind) => !expectedSurfaceKinds.has(surfaceKind)).length;
|
|
1505
|
+
const policyRelevantEvidenceCount = evidenceKinds.filter((kinds) => kinds.some((surfaceKind) => expectedSurfaceKinds.has(surfaceKind))).length;
|
|
1506
|
+
const surfacePrecision = evidence.length === 0 ? null : round3(policyRelevantEvidenceCount / evidence.length);
|
|
1507
|
+
const packetConfidence = average(evidence.map((item) => item.confidence ?? null));
|
|
1508
|
+
const estimatedTokens = input.packet.contentBudget?.estimatedTokens;
|
|
1509
|
+
const tokenRatio = typeof estimatedTokens === "number" && typeof input.repoPromptTokenEstimate === "number" && input.repoPromptTokenEstimate > 0 ? round3(estimatedTokens / input.repoPromptTokenEstimate) : null;
|
|
1510
|
+
const plannerSufficiency = typeof input.plannerSufficiency === "number" ? input.plannerSufficiency : null;
|
|
1511
|
+
const plannerSufficiencyWithSurfaceCoverage = plannerSufficiency === null ? null : round1(Math.min(3, plannerSufficiency * 0.65 + requiredCoverage * 3 * 0.35));
|
|
1512
|
+
const surfacePairCoverage = buildSurfacePairCoverage(coveredSurfaceKinds, surfaceResults);
|
|
1513
|
+
const readiness = deriveReadiness({
|
|
1514
|
+
requiredCoverage,
|
|
1515
|
+
missingCriticalCount,
|
|
1516
|
+
inventedPathCount,
|
|
1517
|
+
surfacePrecision,
|
|
1518
|
+
lowValueEvidenceCount
|
|
1519
|
+
});
|
|
1520
|
+
const productSurfaces = predictProductSurfaces({
|
|
1521
|
+
caseId,
|
|
1522
|
+
intent: input.intent ?? input.packet.objective,
|
|
1523
|
+
packet: input.packet
|
|
1524
|
+
});
|
|
1525
|
+
const decision = chooseGraphExecutionMode(policy.graphInput);
|
|
1526
|
+
const routingPolicy = chooseGraphRoutingPolicyV1({
|
|
1527
|
+
taskKind: graphRoutingTaskKindForChangeShape(classification.changeShape),
|
|
1528
|
+
changeShape: classification.changeShape,
|
|
1529
|
+
connectedWorkAvailable: true,
|
|
1530
|
+
noLiveMode: true,
|
|
1531
|
+
networkAllowed: false,
|
|
1532
|
+
providerCallsAllowed: false
|
|
1533
|
+
});
|
|
1534
|
+
return {
|
|
1535
|
+
reportKind: "connected_surface_coverage",
|
|
1536
|
+
version: CONNECTED_SURFACE_COVERAGE_REPORT_VERSION,
|
|
1537
|
+
caseId,
|
|
1538
|
+
packetId: input.packet.packetId,
|
|
1539
|
+
changeShape: classification,
|
|
1540
|
+
policy: {
|
|
1541
|
+
changeShape: policy.changeShape,
|
|
1542
|
+
label: policy.label,
|
|
1543
|
+
recommendedEscalation: policy.recommendedEscalation,
|
|
1544
|
+
requiredSurfaceKinds: policy.rules.filter((rule) => rule.level === "required").map((rule) => rule.surfaceKind),
|
|
1545
|
+
optionalSurfaceKinds: policy.rules.filter((rule) => rule.level === "optional").map((rule) => rule.surfaceKind)
|
|
1546
|
+
},
|
|
1547
|
+
graph: {
|
|
1548
|
+
recommendedEscalation: policy.recommendedEscalation,
|
|
1549
|
+
selectedMode: decision.selectedMode,
|
|
1550
|
+
decision,
|
|
1551
|
+
routingPolicy
|
|
1552
|
+
},
|
|
1553
|
+
surfaceResults,
|
|
1554
|
+
surfacePairCoverage,
|
|
1555
|
+
readiness,
|
|
1556
|
+
productSurfaces,
|
|
1557
|
+
evidence,
|
|
1558
|
+
metrics: {
|
|
1559
|
+
requiredCoverage,
|
|
1560
|
+
optionalCoverage,
|
|
1561
|
+
missingCriticalCount,
|
|
1562
|
+
inventedPathCount,
|
|
1563
|
+
surfacePrecision,
|
|
1564
|
+
overIncludedSurfaceCount,
|
|
1565
|
+
lowValueEvidenceCount,
|
|
1566
|
+
packetConfidence,
|
|
1567
|
+
tokenRatio,
|
|
1568
|
+
plannerSufficiency,
|
|
1569
|
+
plannerSufficiencyWithSurfaceCoverage
|
|
1570
|
+
},
|
|
1571
|
+
noLiveInvariants: {
|
|
1572
|
+
noNetwork: true,
|
|
1573
|
+
noProviderCalls: true,
|
|
1574
|
+
noConvexWrites: true,
|
|
1575
|
+
noProductionWrites: true,
|
|
1576
|
+
noMemgraph: true,
|
|
1577
|
+
noLiveSourceScans: true,
|
|
1578
|
+
noRepoPromptLiveCalls: true,
|
|
1579
|
+
allSatisfied: true
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
function buildConnectedSurfaceReadinessGateV1(report) {
|
|
1584
|
+
const missingResults = report.surfaceResults.filter((result) => result.level === "required" && !result.passed);
|
|
1585
|
+
const status = report.readiness === "needs_targeted_surface_repair" ? "block" : report.readiness === "needs_broader_context" || report.readiness === "ready_with_caveats" ? "warn" : "pass";
|
|
1586
|
+
return {
|
|
1587
|
+
schemaVersion: 1,
|
|
1588
|
+
kind: "connected_surface_readiness_gate",
|
|
1589
|
+
status,
|
|
1590
|
+
readiness: report.readiness,
|
|
1591
|
+
missingSurfaceKinds: missingResults.map((result) => result.surfaceKind),
|
|
1592
|
+
repairSearches: missingResults.map((result) => ({
|
|
1593
|
+
surfaceKind: result.surfaceKind,
|
|
1594
|
+
repairHint: result.repairHint ?? `Add evidence for ${result.surfaceKind}.`,
|
|
1595
|
+
suggestedPathPatterns: result.suggestedPathPatterns ?? []
|
|
1596
|
+
})),
|
|
1597
|
+
reportRef: `connected-surface:${report.packetId}:${report.caseId}`,
|
|
1598
|
+
reasonCodes: [
|
|
1599
|
+
`connected_surface:readiness_${report.readiness}`,
|
|
1600
|
+
`connected_surface:gate_${status}`,
|
|
1601
|
+
...missingResults.map((result) => `connected_surface:missing_${result.surfaceKind}`),
|
|
1602
|
+
"authority:report_only"
|
|
1603
|
+
],
|
|
1604
|
+
reportOnly: true,
|
|
1605
|
+
advisoryOnly: true,
|
|
1606
|
+
noAuthority: true
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function graphRoutingTaskKindForChangeShape(changeShape) {
|
|
1610
|
+
switch (changeShape) {
|
|
1611
|
+
case "shared_abstraction":
|
|
1612
|
+
case "ui_reuse_or_design_system":
|
|
1613
|
+
return "shared_abstraction_review";
|
|
1614
|
+
case "ui_behavior":
|
|
1615
|
+
return "changed_file_impact";
|
|
1616
|
+
case "execution_safety":
|
|
1617
|
+
return "execution_safety_impact";
|
|
1618
|
+
case "provider_integration":
|
|
1619
|
+
return "provider_integration_impact";
|
|
1620
|
+
case "agent_handoff":
|
|
1621
|
+
return "agent_handoff_planning";
|
|
1622
|
+
case "docs_or_migration":
|
|
1623
|
+
return "docs_code_alignment";
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
function zeroScores() {
|
|
1627
|
+
return {
|
|
1628
|
+
shared_abstraction: 0,
|
|
1629
|
+
ui_behavior: 0,
|
|
1630
|
+
ui_reuse_or_design_system: 0,
|
|
1631
|
+
execution_safety: 0,
|
|
1632
|
+
provider_integration: 0,
|
|
1633
|
+
agent_handoff: 0,
|
|
1634
|
+
docs_or_migration: 0
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function addSelectionSignal(scores, signals, value) {
|
|
1638
|
+
const surfaceKind = surfaceKindFromSelectionSignal(value);
|
|
1639
|
+
if (surfaceKind) {
|
|
1640
|
+
for (const changeShape of changeShapesForSurfaceKindSignal(surfaceKind)) {
|
|
1641
|
+
scores[changeShape] += 4;
|
|
1642
|
+
signals.push({ changeShape, source: "selection_signal", weight: 4, value });
|
|
1643
|
+
}
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
addSignals(scores, signals, "selection_signal", value, 4, INTENT_PATTERNS);
|
|
1647
|
+
}
|
|
1648
|
+
function surfaceKindFromSelectionSignal(value) {
|
|
1649
|
+
const lower = value.toLowerCase();
|
|
1650
|
+
const surfaceKinds = [
|
|
1651
|
+
"primary_code",
|
|
1652
|
+
"targeted_tests",
|
|
1653
|
+
"user_docs",
|
|
1654
|
+
"config_policy",
|
|
1655
|
+
"package_exports",
|
|
1656
|
+
"runtime_enforcement",
|
|
1657
|
+
"schema_persistence",
|
|
1658
|
+
"ui_surface",
|
|
1659
|
+
"design_system_or_shared_component",
|
|
1660
|
+
"usage_sites",
|
|
1661
|
+
"visual_snapshot_or_story",
|
|
1662
|
+
"native_counterpart",
|
|
1663
|
+
"receipt_audit",
|
|
1664
|
+
"eval_report",
|
|
1665
|
+
"migration_notes",
|
|
1666
|
+
"provider_gateway",
|
|
1667
|
+
"agent_handoff"
|
|
1668
|
+
];
|
|
1669
|
+
return surfaceKinds.find((surfaceKind) => lower === surfaceKind || lower.includes(`connected_surface:${surfaceKind}`) || lower.includes(`surface:${surfaceKind}`)) ?? null;
|
|
1670
|
+
}
|
|
1671
|
+
function changeShapesForSurfaceKindSignal(surfaceKind) {
|
|
1672
|
+
switch (surfaceKind) {
|
|
1673
|
+
case "ui_surface":
|
|
1674
|
+
case "native_counterpart":
|
|
1675
|
+
return ["ui_behavior"];
|
|
1676
|
+
case "design_system_or_shared_component":
|
|
1677
|
+
case "usage_sites":
|
|
1678
|
+
case "visual_snapshot_or_story":
|
|
1679
|
+
return ["ui_reuse_or_design_system"];
|
|
1680
|
+
case "runtime_enforcement":
|
|
1681
|
+
case "receipt_audit":
|
|
1682
|
+
case "config_policy":
|
|
1683
|
+
return ["execution_safety"];
|
|
1684
|
+
case "provider_gateway":
|
|
1685
|
+
return ["provider_integration"];
|
|
1686
|
+
case "agent_handoff":
|
|
1687
|
+
return ["agent_handoff"];
|
|
1688
|
+
case "user_docs":
|
|
1689
|
+
case "migration_notes":
|
|
1690
|
+
return ["docs_or_migration"];
|
|
1691
|
+
case "targeted_tests":
|
|
1692
|
+
return ["execution_safety", "shared_abstraction"];
|
|
1693
|
+
case "package_exports":
|
|
1694
|
+
case "schema_persistence":
|
|
1695
|
+
case "eval_report":
|
|
1696
|
+
return ["shared_abstraction"];
|
|
1697
|
+
case "primary_code":
|
|
1698
|
+
return [];
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
function addSignals(scores, signals, source, value, weight, patterns) {
|
|
1702
|
+
if (!value.trim())
|
|
1703
|
+
return;
|
|
1704
|
+
for (const changeShape of CHANGE_SHAPE_TIE_PRIORITY) {
|
|
1705
|
+
if (!patterns[changeShape].some((pattern) => pattern.test(value)))
|
|
1706
|
+
continue;
|
|
1707
|
+
scores[changeShape] += weight;
|
|
1708
|
+
signals.push({ changeShape, source, weight, value });
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function addRoleContentSignal(scores, signals, value) {
|
|
1712
|
+
const lower = value.toLowerCase();
|
|
1713
|
+
const matches = [];
|
|
1714
|
+
if (lower.includes("edit:full_file") || lower.includes("edit:multi_slice") || lower.includes("edit:symbol_slice"))
|
|
1715
|
+
matches.push("shared_abstraction");
|
|
1716
|
+
if (lower.includes("test:"))
|
|
1717
|
+
matches.push("execution_safety", "shared_abstraction");
|
|
1718
|
+
if (lower.includes("doc:"))
|
|
1719
|
+
matches.push("docs_or_migration");
|
|
1720
|
+
if (lower.includes("config:"))
|
|
1721
|
+
matches.push("execution_safety", "provider_integration");
|
|
1722
|
+
if (lower.includes(".tsx") || lower.includes("native") || lower.includes("styles"))
|
|
1723
|
+
matches.push("ui_behavior");
|
|
1724
|
+
if (lower.includes("gateway") || lower.includes("provider"))
|
|
1725
|
+
matches.push("provider_integration");
|
|
1726
|
+
if (lower.includes("handoff") || lower.includes("brief"))
|
|
1727
|
+
matches.push("agent_handoff");
|
|
1728
|
+
for (const changeShape of matches) {
|
|
1729
|
+
scores[changeShape] += 1;
|
|
1730
|
+
signals.push({ changeShape, source: "role_content", weight: 1, value });
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
function buildEvidenceIndex(packet) {
|
|
1734
|
+
const byPath = new Map;
|
|
1735
|
+
for (const file of packet.primaryEditFiles)
|
|
1736
|
+
addEvidence(byPath, file.path, "primary_edit_file", { confidence: file.confidence });
|
|
1737
|
+
for (const slice of packet.contextSlices) {
|
|
1738
|
+
addEvidence(byPath, slice.path, "context_slice", {
|
|
1739
|
+
role: slice.role,
|
|
1740
|
+
contentMode: slice.contentMode,
|
|
1741
|
+
selectionSignals: slice.selectionSignals,
|
|
1742
|
+
confidence: slice.confidence
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
for (const file of packet.affectedTests)
|
|
1746
|
+
addEvidence(byPath, file.path, "affected_test", { confidence: file.confidence });
|
|
1747
|
+
for (const file of packet.affectedDocs)
|
|
1748
|
+
addEvidence(byPath, file.path, "affected_doc", { confidence: file.confidence });
|
|
1749
|
+
for (const file of packet.configFiles)
|
|
1750
|
+
addEvidence(byPath, file.path, "config_file", { confidence: file.confidence });
|
|
1751
|
+
for (const path of packet.sourceRefs)
|
|
1752
|
+
addEvidence(byPath, path, "source_ref");
|
|
1753
|
+
for (const path of packet.evidenceRefs)
|
|
1754
|
+
addEvidence(byPath, path, "evidence_ref");
|
|
1755
|
+
for (const path of packet.receiptRefs)
|
|
1756
|
+
addEvidence(byPath, path, "receipt_ref");
|
|
1757
|
+
return Array.from(byPath.values()).map((item) => ({
|
|
1758
|
+
path: item.path,
|
|
1759
|
+
evidenceTypes: Array.from(item.evidenceTypes),
|
|
1760
|
+
role: item.role,
|
|
1761
|
+
contentMode: item.contentMode,
|
|
1762
|
+
selectionSignals: Array.from(item.selectionSignals),
|
|
1763
|
+
confidence: average(item.confidenceValues) ?? undefined
|
|
1764
|
+
}));
|
|
1765
|
+
}
|
|
1766
|
+
function addEvidence(byPath, path, evidenceType, options = {}) {
|
|
1767
|
+
const trimmed = path.trim();
|
|
1768
|
+
if (!trimmed)
|
|
1769
|
+
return;
|
|
1770
|
+
const existing = byPath.get(trimmed) ?? {
|
|
1771
|
+
path: trimmed,
|
|
1772
|
+
evidenceTypes: new Set,
|
|
1773
|
+
selectionSignals: new Set,
|
|
1774
|
+
confidenceValues: []
|
|
1775
|
+
};
|
|
1776
|
+
existing.evidenceTypes.add(evidenceType);
|
|
1777
|
+
existing.role = existing.role ?? options.role;
|
|
1778
|
+
existing.contentMode = existing.contentMode ?? options.contentMode;
|
|
1779
|
+
for (const signal of options.selectionSignals ?? [])
|
|
1780
|
+
existing.selectionSignals.add(signal);
|
|
1781
|
+
if (typeof options.confidence === "number" && Number.isFinite(options.confidence))
|
|
1782
|
+
existing.confidenceValues.push(options.confidence);
|
|
1783
|
+
byPath.set(trimmed, existing);
|
|
1784
|
+
}
|
|
1785
|
+
function scoreRule(rule, evidence) {
|
|
1786
|
+
const matchedPaths = evidence.filter((item) => item.evidenceTypes.some((type) => rule.evidenceTypes.includes(type))).filter((item) => pathMatchesSurfaceKind(item, rule.surfaceKind)).map((item) => item.path);
|
|
1787
|
+
const uniquePaths = Array.from(new Set(matchedPaths));
|
|
1788
|
+
const passed = uniquePaths.length >= rule.minEvidenceCount;
|
|
1789
|
+
const repair = repairForSurfaceKind(rule.surfaceKind);
|
|
1790
|
+
return {
|
|
1791
|
+
surfaceKind: rule.surfaceKind,
|
|
1792
|
+
level: rule.level,
|
|
1793
|
+
minEvidenceCount: rule.minEvidenceCount,
|
|
1794
|
+
matchedEvidenceCount: uniquePaths.length,
|
|
1795
|
+
matchedPaths: uniquePaths,
|
|
1796
|
+
passed,
|
|
1797
|
+
rationale: rule.rationale,
|
|
1798
|
+
repairHint: passed ? undefined : repair.repairHint,
|
|
1799
|
+
suggestedPathPatterns: passed ? undefined : repair.suggestedPathPatterns
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
function connectedSurfaceKindsForEvidenceItemV1(item) {
|
|
1803
|
+
return evidenceSurfaceKinds(item);
|
|
1804
|
+
}
|
|
1805
|
+
function evidenceSurfaceKinds(item) {
|
|
1806
|
+
return CONNECTED_SURFACE_KIND_MATCH_ORDER.filter((surfaceKind) => pathMatchesSurfaceKind(item, surfaceKind));
|
|
1807
|
+
}
|
|
1808
|
+
var CONNECTED_SURFACE_KIND_MATCH_ORDER = [
|
|
1809
|
+
"primary_code",
|
|
1810
|
+
"targeted_tests",
|
|
1811
|
+
"user_docs",
|
|
1812
|
+
"config_policy",
|
|
1813
|
+
"package_exports",
|
|
1814
|
+
"runtime_enforcement",
|
|
1815
|
+
"schema_persistence",
|
|
1816
|
+
"ui_surface",
|
|
1817
|
+
"design_system_or_shared_component",
|
|
1818
|
+
"usage_sites",
|
|
1819
|
+
"visual_snapshot_or_story",
|
|
1820
|
+
"native_counterpart",
|
|
1821
|
+
"receipt_audit",
|
|
1822
|
+
"eval_report",
|
|
1823
|
+
"migration_notes",
|
|
1824
|
+
"provider_gateway",
|
|
1825
|
+
"agent_handoff"
|
|
1826
|
+
];
|
|
1827
|
+
function pathMatchesSurfaceKind(item, surfaceKind) {
|
|
1828
|
+
if (selectionSignalsMatchSurfaceKind(item.selectionSignals, surfaceKind))
|
|
1829
|
+
return true;
|
|
1830
|
+
const path = item.path;
|
|
1831
|
+
const lower = path.toLowerCase();
|
|
1832
|
+
switch (surfaceKind) {
|
|
1833
|
+
case "primary_code":
|
|
1834
|
+
if (item.evidenceTypes.includes("primary_edit_file") || item.role === "edit")
|
|
1835
|
+
return true;
|
|
1836
|
+
if (item.role === "test" || item.role === "doc" || item.role === "config")
|
|
1837
|
+
return false;
|
|
1838
|
+
if (/(^|\/)(test|tests|convex-tests)\/|\.test\.|\.spec\.|config|env|policy/.test(lower))
|
|
1839
|
+
return false;
|
|
1840
|
+
return /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(lower);
|
|
1841
|
+
case "targeted_tests":
|
|
1842
|
+
return item.evidenceTypes.includes("affected_test") || item.role === "test" || /(^|\/)(test|tests|convex-tests)\//.test(lower) || /\.test\./.test(lower);
|
|
1843
|
+
case "user_docs":
|
|
1844
|
+
return item.evidenceTypes.includes("affected_doc") || item.role === "doc" || /(^|\/)docs\//.test(lower) || /readme|\.mdx?$/.test(lower);
|
|
1845
|
+
case "config_policy":
|
|
1846
|
+
return item.evidenceTypes.includes("config_file") || item.role === "config" || /config|env|policy|allowlist|options/.test(lower);
|
|
1847
|
+
case "package_exports":
|
|
1848
|
+
return /(^|\/)package\.json$|(^|\/)packages\/[^/]+\/src\/index\.ts$|(^|\/)(src|source)\/index\.ts$|exports?|types?|options|constants/.test(lower);
|
|
1849
|
+
case "runtime_enforcement":
|
|
1850
|
+
return /auth|redirect|validation|guard|enforce|runtime|safety|retry|timeout|error|receipt/.test(lower);
|
|
1851
|
+
case "schema_persistence":
|
|
1852
|
+
return /schema|migration|db|persistence|convex\/schema|types/.test(lower);
|
|
1853
|
+
case "ui_surface":
|
|
1854
|
+
return /\.tsx$|components|ui|expo|web|native|message|panel|styles/.test(lower);
|
|
1855
|
+
case "design_system_or_shared_component":
|
|
1856
|
+
return /design[-_ ]?system|shared[-_ ]?component|packages\/ui|@rhei\/ui|primitive|faded[-_ ]?disclosure/.test(lower);
|
|
1857
|
+
case "usage_sites":
|
|
1858
|
+
return /usage|call[-_ ]?site|consumer|message[-_ ]?bubble|side[-_ ]?panel|spotlight|thread[-_ ]?list|thinking[-_ ]?indicator/.test(lower);
|
|
1859
|
+
case "visual_snapshot_or_story":
|
|
1860
|
+
return /story|stories|storybook|snapshot|visual|screenshot|chromatic/.test(lower);
|
|
1861
|
+
case "native_counterpart":
|
|
1862
|
+
return /\.native\.|native|expo|ios|android/.test(lower);
|
|
1863
|
+
case "receipt_audit":
|
|
1864
|
+
return item.evidenceTypes.includes("receipt_ref") || /receipt|trail|audit|report|prompt-exports/.test(lower);
|
|
1865
|
+
case "eval_report":
|
|
1866
|
+
return /eval|test|report|prompt-exports|fixture/.test(lower);
|
|
1867
|
+
case "migration_notes":
|
|
1868
|
+
return /migration|migrate|docs|readme|prompt-exports|planning/.test(lower);
|
|
1869
|
+
case "provider_gateway":
|
|
1870
|
+
return /provider|gateway|model|generate-text|stream-text|registry|routing/.test(lower);
|
|
1871
|
+
case "agent_handoff":
|
|
1872
|
+
return /agent|handoff|brief|contextplan|context-plan|workroom|work-packet|prompt-exports/.test(lower);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
function selectionSignalsMatchSurfaceKind(signals, surfaceKind) {
|
|
1876
|
+
return signals.some((signal) => {
|
|
1877
|
+
const lower = signal.toLowerCase();
|
|
1878
|
+
return lower === surfaceKind || lower.includes(`connected_surface:${surfaceKind}`) || lower.includes(`surface:${surfaceKind}`) || lower.includes(`role:${surfaceKind}`);
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
function buildSurfacePairCoverage(coveredSurfaceKinds, surfaceResults) {
|
|
1882
|
+
const pathsFor = (surfaceKind) => surfaceResults.find((result) => result.surfaceKind === surfaceKind)?.matchedPaths ?? [];
|
|
1883
|
+
return SURFACE_PAIR_DEFINITIONS.map((definition) => {
|
|
1884
|
+
const leftCovered = coveredSurfaceKinds.has(definition.left);
|
|
1885
|
+
const rightCovered = coveredSurfaceKinds.has(definition.right);
|
|
1886
|
+
const covered = leftCovered && rightCovered;
|
|
1887
|
+
return {
|
|
1888
|
+
pairId: definition.pairId,
|
|
1889
|
+
left: definition.left,
|
|
1890
|
+
right: definition.right,
|
|
1891
|
+
covered,
|
|
1892
|
+
leftCovered,
|
|
1893
|
+
rightCovered,
|
|
1894
|
+
matchedPaths: Array.from(new Set([...pathsFor(definition.left), ...pathsFor(definition.right)])),
|
|
1895
|
+
repairHint: covered ? undefined : definition.repairHint,
|
|
1896
|
+
suggestedPathPatterns: covered ? undefined : definition.suggestedPathPatterns
|
|
1897
|
+
};
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
function deriveReadiness(input) {
|
|
1901
|
+
const precision = input.surfacePrecision ?? 1;
|
|
1902
|
+
if (input.inventedPathCount > 0 || input.requiredCoverage < 0.5)
|
|
1903
|
+
return "needs_broader_context";
|
|
1904
|
+
if (input.missingCriticalCount > 0 || input.requiredCoverage < 0.9)
|
|
1905
|
+
return "needs_targeted_surface_repair";
|
|
1906
|
+
if (precision < 0.75 || input.lowValueEvidenceCount > 2)
|
|
1907
|
+
return "ready_with_caveats";
|
|
1908
|
+
return "ready_without_search";
|
|
1909
|
+
}
|
|
1910
|
+
function predictProductSurfaces(input) {
|
|
1911
|
+
const scores = new Map;
|
|
1912
|
+
const add = (surface, score, signal) => {
|
|
1913
|
+
const current = scores.get(surface) ?? { score: 0, signals: new Set };
|
|
1914
|
+
current.score += score;
|
|
1915
|
+
current.signals.add(signal);
|
|
1916
|
+
scores.set(surface, current);
|
|
1917
|
+
};
|
|
1918
|
+
const values = [
|
|
1919
|
+
input.caseId,
|
|
1920
|
+
input.intent ?? "",
|
|
1921
|
+
...packetPaths(input.packet),
|
|
1922
|
+
...input.packet.contextSlices.flatMap((slice) => slice.selectionSignals ?? [])
|
|
1923
|
+
];
|
|
1924
|
+
for (const value of values) {
|
|
1925
|
+
const lower = value.toLowerCase();
|
|
1926
|
+
if (/canvas/.test(lower))
|
|
1927
|
+
add("canvas", 2, value);
|
|
1928
|
+
if (/chat|message|ai\/|agent_chat/.test(lower))
|
|
1929
|
+
add("agent_chat", 2, value);
|
|
1930
|
+
if (/code[_-]?map|code_layer|code-layer/.test(lower))
|
|
1931
|
+
add("code_map", 2, value);
|
|
1932
|
+
if (/workroom|work-?packet|brief|handoff/.test(lower))
|
|
1933
|
+
add("workroom", 2, value);
|
|
1934
|
+
if (/auth|redirect|session|callback/.test(lower))
|
|
1935
|
+
add("auth", 3, value);
|
|
1936
|
+
if (/receipt|trail|audit|execution[-_]?safety/.test(lower))
|
|
1937
|
+
add("execution_receipts", 3, value);
|
|
1938
|
+
if (/provider|gateway|routing|model/.test(lower))
|
|
1939
|
+
add("provider_routing", 3, value);
|
|
1940
|
+
if (/docs|readme|\.mdx?$|documentation/.test(lower))
|
|
1941
|
+
add("docs", 2, value);
|
|
1942
|
+
}
|
|
1943
|
+
return Array.from(scores.entries()).map(([surface, value]) => ({
|
|
1944
|
+
surface,
|
|
1945
|
+
confidence: Math.min(1, round3(value.score / 10)),
|
|
1946
|
+
signals: Array.from(value.signals).slice(0, 6)
|
|
1947
|
+
})).filter((item) => item.confidence > 0).sort((left, right) => right.confidence - left.confidence || left.surface.localeCompare(right.surface));
|
|
1948
|
+
}
|
|
1949
|
+
function repairForSurfaceKind(surfaceKind) {
|
|
1950
|
+
switch (surfaceKind) {
|
|
1951
|
+
case "primary_code":
|
|
1952
|
+
return { repairHint: "Add the primary implementation file or focused source slice.", suggestedPathPatterns: ["packages/**/*.ts", "convex/**/*.ts", "source/**/*.ts"] };
|
|
1953
|
+
case "targeted_tests":
|
|
1954
|
+
return { repairHint: "Add targeted regression tests for this surface.", suggestedPathPatterns: ["**/*.test.ts", "convex-tests/**/*.test.ts", "test/**/*.ts"] };
|
|
1955
|
+
case "user_docs":
|
|
1956
|
+
return { repairHint: "Add user-facing docs or README coverage.", suggestedPathPatterns: ["docs/**/*.md", "**/readme.md", "content/docs/**/*.mdx"] };
|
|
1957
|
+
case "config_policy":
|
|
1958
|
+
return { repairHint: "Add config, environment, or policy files that control this behavior.", suggestedPathPatterns: ["**/*config*.ts", "**/*Env*.ts", "**/*policy*.ts"] };
|
|
1959
|
+
case "package_exports":
|
|
1960
|
+
return { repairHint: "Add export barrel or public type files.", suggestedPathPatterns: ["**/index.ts", "**/types.ts", "package.json"] };
|
|
1961
|
+
case "runtime_enforcement":
|
|
1962
|
+
return { repairHint: "Add runtime guard/enforcement/error handling code.", suggestedPathPatterns: ["**/*validation*.ts", "**/*guard*.ts", "**/*error*.ts"] };
|
|
1963
|
+
case "schema_persistence":
|
|
1964
|
+
return { repairHint: "Add schema or persistence contract files.", suggestedPathPatterns: ["**/schema*.ts", "**/*migration*.ts", "convex/schema/**/*.ts"] };
|
|
1965
|
+
case "ui_surface":
|
|
1966
|
+
return { repairHint: "Add the visible UI component/style surface.", suggestedPathPatterns: ["**/*.tsx", "**/*.styles.ts", "packages/ui/**/*.tsx"] };
|
|
1967
|
+
case "design_system_or_shared_component":
|
|
1968
|
+
return { repairHint: "Add the shared UI primitive or design-system component surface.", suggestedPathPatterns: ["packages/ui/**/*.tsx", "packages/theme/**/*.ts", "**/*design-system*.tsx"] };
|
|
1969
|
+
case "usage_sites":
|
|
1970
|
+
return { repairHint: "Add representative UI usage sites for the shared behavior.", suggestedPathPatterns: ["apps/**/*.tsx", "**/*Message*.tsx", "**/*Panel*.tsx"] };
|
|
1971
|
+
case "visual_snapshot_or_story":
|
|
1972
|
+
return { repairHint: "Add a visual snapshot, story, or fixture for the UI behavior.", suggestedPathPatterns: ["**/*.stories.tsx", "**/*snapshot*", "tests/browser/snapshots/**/*"] };
|
|
1973
|
+
case "native_counterpart":
|
|
1974
|
+
return { repairHint: "Add native counterpart context or document why none is needed.", suggestedPathPatterns: ["**/*.native.tsx", "apps/expo/**/*.tsx"] };
|
|
1975
|
+
case "receipt_audit":
|
|
1976
|
+
return { repairHint: "Add receipt, trail, audit, or report evidence.", suggestedPathPatterns: ["**/*receipt*.ts", "**/*trail*.ts", "prompt-exports/**/*.md"] };
|
|
1977
|
+
case "eval_report":
|
|
1978
|
+
return { repairHint: "Add eval/report fixture coverage.", suggestedPathPatterns: ["convex-tests/evals/**/*.test.ts", "convex-tests/evals/lib/**/*.ts"] };
|
|
1979
|
+
case "migration_notes":
|
|
1980
|
+
return { repairHint: "Add migration notes or planning docs.", suggestedPathPatterns: ["docs/**/*.md", "prompt-exports/**/*.md"] };
|
|
1981
|
+
case "provider_gateway":
|
|
1982
|
+
return { repairHint: "Add provider/gateway routing files.", suggestedPathPatterns: ["**/*provider*.ts", "**/*gateway*.ts", "**/*routing*.ts"] };
|
|
1983
|
+
case "agent_handoff":
|
|
1984
|
+
return { repairHint: "Add agent handoff brief/work-packet context.", suggestedPathPatterns: ["**/*brief*.ts", "**/*handoff*.ts", "prompt-exports/**/*.md"] };
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
function packetPaths(packet) {
|
|
1988
|
+
return Array.from(new Set([
|
|
1989
|
+
...packet.primaryEditFiles.map((file) => file.path),
|
|
1990
|
+
...packet.contextSlices.map((slice) => slice.path),
|
|
1991
|
+
...packet.affectedTests.map((file) => file.path),
|
|
1992
|
+
...packet.affectedDocs.map((file) => file.path),
|
|
1993
|
+
...packet.configFiles.map((file) => file.path),
|
|
1994
|
+
...packet.sourceRefs,
|
|
1995
|
+
...packet.evidenceRefs,
|
|
1996
|
+
...packet.receiptRefs
|
|
1997
|
+
].filter(Boolean)));
|
|
1998
|
+
}
|
|
1999
|
+
function coverageCount(passed, total) {
|
|
2000
|
+
if (total === 0)
|
|
2001
|
+
return null;
|
|
2002
|
+
return passed / total;
|
|
2003
|
+
}
|
|
2004
|
+
function average(values) {
|
|
2005
|
+
const numbers = values.filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
2006
|
+
if (numbers.length === 0)
|
|
2007
|
+
return null;
|
|
2008
|
+
return round3(numbers.reduce((sum, value) => sum + value, 0) / numbers.length);
|
|
2009
|
+
}
|
|
2010
|
+
function round1(value) {
|
|
2011
|
+
return Math.round(value * 10) / 10;
|
|
2012
|
+
}
|
|
2013
|
+
function round3(value) {
|
|
2014
|
+
return Math.round(value * 1000) / 1000;
|
|
2015
|
+
}
|
|
2016
|
+
export {
|
|
2017
|
+
semanticSelectionSignalsFromReadyLabels,
|
|
2018
|
+
semanticSelectionSignalsByFilePath,
|
|
2019
|
+
semanticSelectionSignalMappingsFromReadyLabels,
|
|
2020
|
+
scoreConnectedSurfaceCoverage,
|
|
2021
|
+
plannerHandoffGraphAdvisoryFromPolicyDecision,
|
|
2022
|
+
normalizePlannerHandoffGraphAdvisoryV1,
|
|
2023
|
+
graphExecutionModePolicyMetadataList,
|
|
2024
|
+
graphExecutionModePolicyMetadataFor,
|
|
2025
|
+
connectedSurfacePolicyForChangeShape,
|
|
2026
|
+
connectedSurfaceKindsForSemanticLabel,
|
|
2027
|
+
connectedSurfaceKindsForEvidenceItemV1,
|
|
2028
|
+
classifyConnectedSurfaceChangeShape,
|
|
2029
|
+
chooseGraphRoutingPolicyV1,
|
|
2030
|
+
chooseGraphExecutionMode,
|
|
2031
|
+
buildSemanticGraphRoutingReportFromLabels,
|
|
2032
|
+
buildPlannerHandoffGraphAdvisoryV1,
|
|
2033
|
+
buildGraphExecutionModeInputFromSemanticLabels,
|
|
2034
|
+
buildGraphExecutionModeDefaultDecisions,
|
|
2035
|
+
buildConnectedSurfaceReadinessGateV1,
|
|
2036
|
+
SEMANTIC_SELECTION_SIGNAL_PREFIX_V1,
|
|
2037
|
+
SEMANTIC_GRAPH_ROUTING_REPORT_VERSION,
|
|
2038
|
+
PLANNER_HANDOFF_GRAPH_ADVISORY_SCHEMA_VERSION,
|
|
2039
|
+
PLANNER_HANDOFF_GRAPH_ADVISORY_REQUIRED_COPY,
|
|
2040
|
+
PLANNER_HANDOFF_GRAPH_ADVISORY_KIND,
|
|
2041
|
+
GRAPH_ROUTING_POLICY_VERSION,
|
|
2042
|
+
GRAPH_ROUTING_MIN_SOURCE_GROUNDING_RATE_V1,
|
|
2043
|
+
GRAPH_ROUTING_MIN_DEPTH5_LIFT_V1,
|
|
2044
|
+
GRAPH_ROUTING_MAX_NOISE_RATE_V1,
|
|
2045
|
+
GRAPH_ROUTING_DEPTH5_MIN_HIGH_COMPLEXITY_SCORE_V1,
|
|
2046
|
+
GRAPH_EXECUTION_MODE_ROUTER_VERSION,
|
|
2047
|
+
GRAPH_EXECUTION_MODES,
|
|
2048
|
+
CONNECTED_SURFACE_POLICIES_V1,
|
|
2049
|
+
CONNECTED_SURFACE_KINDS_V1,
|
|
2050
|
+
CONNECTED_SURFACE_COVERAGE_REPORT_VERSION,
|
|
2051
|
+
CHANGE_SHAPES_V1
|
|
2052
|
+
};
|