pi-smart-router 0.13.0 → 0.15.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/.pi/extensions/smart-router/command-formatters.ts +77 -1
- package/.pi/extensions/smart-router/commands.ts +31 -1
- package/.pi/extensions/smart-router/extension-setup.ts +1 -0
- package/.pi/extensions/smart-router/fleet-bootstrap.ts +51 -1
- package/.pi/extensions/smart-router/planning-delegate.ts +124 -4
- package/.pi/extensions/smart-router/types.ts +3 -0
- package/README.md +47 -0
- package/dist/config/defaults.d.ts +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +7 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/domain/pinning/heat-affinity.d.ts +70 -0
- package/dist/domain/pinning/heat-affinity.d.ts.map +1 -0
- package/dist/domain/pinning/heat-affinity.js +146 -0
- package/dist/domain/pinning/heat-affinity.js.map +1 -0
- package/dist/domain/pipeline/router-pipeline.d.ts +50 -0
- package/dist/domain/pipeline/router-pipeline.d.ts.map +1 -1
- package/dist/domain/pipeline/router-pipeline.js +197 -4
- package/dist/domain/pipeline/router-pipeline.js.map +1 -1
- package/dist/domain/pricing/quota-window-feed.d.ts +88 -0
- package/dist/domain/pricing/quota-window-feed.d.ts.map +1 -0
- package/dist/domain/pricing/quota-window-feed.js +159 -0
- package/dist/domain/pricing/quota-window-feed.js.map +1 -0
- package/dist/domain/routing/degraded-route-sandwich.d.ts +161 -0
- package/dist/domain/routing/degraded-route-sandwich.d.ts.map +1 -0
- package/dist/domain/routing/degraded-route-sandwich.js +309 -0
- package/dist/domain/routing/degraded-route-sandwich.js.map +1 -0
- package/dist/domain/routing/expected-cost.d.ts +25 -0
- package/dist/domain/routing/expected-cost.d.ts.map +1 -1
- package/dist/domain/routing/expected-cost.js +36 -3
- package/dist/domain/routing/expected-cost.js.map +1 -1
- package/dist/domain/routing/speculative-prewarm.d.ts +102 -0
- package/dist/domain/routing/speculative-prewarm.d.ts.map +1 -0
- package/dist/domain/routing/speculative-prewarm.js +177 -0
- package/dist/domain/routing/speculative-prewarm.js.map +1 -0
- package/dist/domain/routing/workload-heat.d.ts +158 -0
- package/dist/domain/routing/workload-heat.d.ts.map +1 -0
- package/dist/domain/routing/workload-heat.js +349 -0
- package/dist/domain/routing/workload-heat.js.map +1 -0
- package/dist/domain/types/entities.d.ts +52 -0
- package/dist/domain/types/entities.d.ts.map +1 -1
- package/dist/domain/types/index.d.ts +1 -1
- package/dist/domain/types/index.d.ts.map +1 -1
- package/dist/domain/types/schemas.d.ts +83 -2
- package/dist/domain/types/schemas.d.ts.map +1 -1
- package/dist/domain/types/schemas.js +121 -2
- package/dist/domain/types/schemas.js.map +1 -1
- package/dist/infrastructure/hardware/placement-plan.d.ts +141 -0
- package/dist/infrastructure/hardware/placement-plan.d.ts.map +1 -0
- package/dist/infrastructure/hardware/placement-plan.js +263 -0
- package/dist/infrastructure/hardware/placement-plan.js.map +1 -0
- package/dist/infrastructure/hardware/throughput-meter.d.ts +59 -4
- package/dist/infrastructure/hardware/throughput-meter.d.ts.map +1 -1
- package/dist/infrastructure/hardware/throughput-meter.js +77 -8
- package/dist/infrastructure/hardware/throughput-meter.js.map +1 -1
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts +20 -4
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts.map +1 -1
- package/dist/infrastructure/telemetry/routing-telemetry.js +41 -6
- package/dist/infrastructure/telemetry/routing-telemetry.js.map +1 -1
- package/dist/infrastructure/telemetry/workload-heat-store.d.ts +32 -0
- package/dist/infrastructure/telemetry/workload-heat-store.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/workload-heat-store.js +71 -0
- package/dist/infrastructure/telemetry/workload-heat-store.js.map +1 -0
- package/package.json +1 -1
- package/src/config/defaults.ts +10 -0
- package/src/domain/pinning/heat-affinity.ts +203 -0
- package/src/domain/pipeline/router-pipeline.ts +264 -8
- package/src/domain/pricing/quota-window-feed.ts +240 -0
- package/src/domain/routing/degraded-route-sandwich.ts +478 -0
- package/src/domain/routing/expected-cost.ts +61 -3
- package/src/domain/routing/speculative-prewarm.ts +252 -0
- package/src/domain/routing/workload-heat.ts +504 -0
- package/src/domain/types/entities.ts +53 -0
- package/src/domain/types/index.ts +1 -0
- package/src/domain/types/schemas.ts +137 -2
- package/src/infrastructure/hardware/placement-plan.ts +453 -0
- package/src/infrastructure/hardware/throughput-meter.ts +156 -13
- package/src/infrastructure/telemetry/routing-telemetry.ts +67 -3
- package/src/infrastructure/telemetry/workload-heat-store.ts +91 -0
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
DEFAULT_TELEMETRY_CONTRIB_EXPORT_LIMIT,
|
|
18
18
|
parseExportTelemetryContribArgs,
|
|
19
19
|
} from '../../../src/cli/smart-router-cli.js';
|
|
20
|
+
import type { PlacementPlanReport } from '../../../src/infrastructure/hardware/placement-plan.js';
|
|
20
21
|
import {
|
|
21
22
|
DEFAULT_DATASET_EXPORT_LIMIT,
|
|
22
23
|
MAX_DATASET_EXPORT_LIMIT,
|
|
@@ -146,12 +147,20 @@ export function parseExportLimit(tokens: string[]): number {
|
|
|
146
147
|
return limit;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
export function parseSmartRouterArgs(args: string):
|
|
150
|
+
export function parseSmartRouterArgs(args: string): ParsedSmartRouterCommand {
|
|
150
151
|
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
151
152
|
if (tokens.length === 0 || tokens[0] === 'status') {
|
|
152
153
|
return { command: 'status' };
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
if (tokens[0] === 'plan' && (tokens.length === 1 || (tokens.length === 2 && tokens[1] === '--json'))) {
|
|
157
|
+
return { command: 'plan', format: tokens[1] === '--json' ? 'json' : 'text' };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (tokens[0] === 'doctor' && tokens.length === 1) {
|
|
161
|
+
return { command: 'doctor' };
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
if (tokens[0] === 'history') {
|
|
156
165
|
return { command: 'history', limit: parseHistoryLimit(tokens[1]) };
|
|
157
166
|
}
|
|
@@ -339,3 +348,70 @@ export function buildStatsSnapshot(
|
|
|
339
348
|
}
|
|
340
349
|
|
|
341
350
|
export type { FleetMode };
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Read-only placement commands (SP-216, #116). Declared here instead of
|
|
354
|
+
* types.ts to keep the SmartRouterCommand union untouched.
|
|
355
|
+
*/
|
|
356
|
+
export type SmartRouterPlacementCommand =
|
|
357
|
+
| { command: 'plan'; format: 'text' | 'json' }
|
|
358
|
+
| { command: 'doctor' };
|
|
359
|
+
|
|
360
|
+
export type ParsedSmartRouterCommand = SmartRouterCommand | SmartRouterPlacementCommand;
|
|
361
|
+
|
|
362
|
+
function formatTps(value: number | null): string {
|
|
363
|
+
return value === null ? 'n/a' : `${value.toFixed(1)} tok/s`;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function formatGb(value: number | null): string {
|
|
367
|
+
return value === null ? 'unknown' : `${value.toFixed(1)} GiB`;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function formatPing(label: string, ping: PlacementPlanReport['localModel']['lmStudio']): string {
|
|
371
|
+
if (!ping.available) {
|
|
372
|
+
return ` ${label}: unreachable`;
|
|
373
|
+
}
|
|
374
|
+
return ` ${label}: up, model ${ping.hasLoadedModel ? 'loaded (warm)' : 'not loaded (cold)'}`;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Human-readable placement report for `/smart-router plan` (read-only). */
|
|
378
|
+
export function formatPlacementPlanMessage(report: PlacementPlanReport): string {
|
|
379
|
+
const lines = [
|
|
380
|
+
`Placement plan (read-only, schema v${report.schemaVersion}) — ${report.generatedAt}`,
|
|
381
|
+
`Recommendation: ${report.recommendation}`,
|
|
382
|
+
`Bottleneck guess: ${report.bottleneck.guess} — ${report.bottleneck.rationale}`,
|
|
383
|
+
`Encoder: ${report.encoder.resident ? 'resident' : 'not resident'} (${report.encoder.model}) at ${report.encoder.cachePath}`,
|
|
384
|
+
`Local model: ${report.localModel.warm ? 'warm' : report.localModel.coldStartExpected ? 'cold (load on first request)' : 'unavailable'}`,
|
|
385
|
+
formatPing('LM Studio', report.localModel.lmStudio),
|
|
386
|
+
formatPing('Ollama', report.localModel.ollama),
|
|
387
|
+
`Hardware: ${report.hardware.platform}/${report.hardware.arch}, total ${formatGb(report.hardware.totalMemoryGb)}, free ${formatGb(report.hardware.freeMemoryGb)}, probe=${report.hardware.probe}`,
|
|
388
|
+
`Disk (${report.disk.path}): free ${formatGb(report.disk.freeGb)}${report.disk.constrained ? ' [constrained]' : ''}`,
|
|
389
|
+
`Throughput: ${report.throughput.classification} | warm median ${formatTps(report.throughput.warmMedianTps)} (${report.throughput.warmSamples} samples) | cold median ${formatTps(report.throughput.coldMedianTps)} (${report.throughput.coldSamples} samples) | threshold ${report.throughput.thresholdTps} tok/s | viable=${report.throughput.viable}`,
|
|
390
|
+
`Policy: quality-preserving — on resource pressure: ${report.policy.onResourcePressure}`,
|
|
391
|
+
];
|
|
392
|
+
return lines.join('\n');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Checklist-style readiness verdict for `/smart-router doctor` (read-only). */
|
|
396
|
+
export function formatDoctorMessage(report: PlacementPlanReport): string {
|
|
397
|
+
const check = (ok: boolean, label: string): string => `${ok ? '✓' : '✗'} ${label}`;
|
|
398
|
+
const lines = [
|
|
399
|
+
'smart-router doctor (read-only)',
|
|
400
|
+
check(report.encoder.resident, `encoder resident (${report.encoder.model})`),
|
|
401
|
+
check(report.hardware.probe === 'full_local', `hardware probe: ${report.hardware.probe}`),
|
|
402
|
+
check(!report.disk.constrained, `disk: ${formatGb(report.disk.freeGb)} free${report.disk.constrained ? ' [constrained]' : ''}`),
|
|
403
|
+
check(
|
|
404
|
+
report.localModel.lmStudio.available || report.localModel.ollama.available,
|
|
405
|
+
'local runtime reachable (LM Studio / Ollama)',
|
|
406
|
+
),
|
|
407
|
+
check(report.localModel.warm, `local model ${report.localModel.warm ? 'warm' : 'cold/not loaded'}`),
|
|
408
|
+
check(
|
|
409
|
+
report.throughput.viable,
|
|
410
|
+
`throughput: ${report.throughput.classification}, viable=${report.throughput.viable}${report.throughput.classification === 'cold-only' ? ' (cold-only windows fail closed)' : ''}`,
|
|
411
|
+
),
|
|
412
|
+
`Bottleneck guess: ${report.bottleneck.guess} — ${report.bottleneck.rationale}`,
|
|
413
|
+
`Recommendation: ${report.recommendation}`,
|
|
414
|
+
'Policy: quality-preserving — under resource pressure local is reported unavailable and routing escalates safely; encoder fidelity is never weakened.',
|
|
415
|
+
];
|
|
416
|
+
return lines.join('\n');
|
|
417
|
+
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { join } from 'node:path';
|
|
2
3
|
|
|
3
4
|
import {
|
|
5
|
+
formatDoctorMessage,
|
|
4
6
|
formatHistoryMessage,
|
|
7
|
+
formatPlacementPlanMessage,
|
|
5
8
|
formatStatsMessage,
|
|
6
9
|
formatStatusMessage,
|
|
7
10
|
parseSmartRouterArgs,
|
|
8
11
|
} from './command-formatters.js';
|
|
9
12
|
import { exportDatasetToFile } from './dataset-export.js';
|
|
10
13
|
import { exportTelemetryContrib } from '../../../src/cli/smart-router-cli.js';
|
|
14
|
+
import { collectPlacementPlan } from '../../../src/infrastructure/hardware/placement-plan.js';
|
|
11
15
|
import { bindSharedModelRegistry, rebuildFleet } from './fleet-bootstrap.js';
|
|
12
16
|
import { refreshPricingCatalog } from './pricing-lifecycle.js';
|
|
13
17
|
import { FLEET_MODE_ENTRY_TYPE } from './session-lifecycle.js';
|
|
14
18
|
import type { SmartRouterRuntime } from './types.js';
|
|
15
19
|
|
|
16
20
|
export const SMART_ROUTER_USAGE =
|
|
17
|
-
'/smart-router [status] | history [limit] | stats [limit] | mode scoped|all | pricing refresh | export dataset [--limit N] | export telemetry-contrib [--limit N] | feedback good|bad | unpin';
|
|
21
|
+
'/smart-router [status] | history [limit] | stats [limit] | mode scoped|all | pricing refresh | export dataset [--limit N] | export telemetry-contrib [--limit N] | feedback good|bad | unpin | plan [--json] | doctor';
|
|
18
22
|
|
|
19
23
|
type CompletionItem = { value: string; label: string };
|
|
20
24
|
|
|
@@ -27,6 +31,8 @@ const TOP_LEVEL: CompletionItem[] = [
|
|
|
27
31
|
{ value: 'export', label: 'Export opt-in routing dataset' },
|
|
28
32
|
{ value: 'feedback', label: 'Label last routing outcome good or bad' },
|
|
29
33
|
{ value: 'unpin', label: 'Clear current session pin' },
|
|
34
|
+
{ value: 'plan', label: 'Read-only local placement report (warm/cold, bottleneck)' },
|
|
35
|
+
{ value: 'doctor', label: 'Read-only local readiness checklist' },
|
|
30
36
|
];
|
|
31
37
|
|
|
32
38
|
const MODE_COMPLETIONS: CompletionItem[] = [
|
|
@@ -66,6 +72,9 @@ export const SMART_ROUTER_FULL_INVOCATIONS = [
|
|
|
66
72
|
'feedback good',
|
|
67
73
|
'feedback bad',
|
|
68
74
|
'unpin',
|
|
75
|
+
'plan',
|
|
76
|
+
'plan --json',
|
|
77
|
+
'doctor',
|
|
69
78
|
] as const;
|
|
70
79
|
|
|
71
80
|
function filterByPrefix(items: CompletionItem[], prefix: string): CompletionItem[] {
|
|
@@ -267,6 +276,27 @@ export function registerSmartRouterCommand(
|
|
|
267
276
|
return;
|
|
268
277
|
}
|
|
269
278
|
|
|
279
|
+
if (parsed.command === 'plan' || parsed.command === 'doctor') {
|
|
280
|
+
throwIfCommandAborted(signal);
|
|
281
|
+
// Read-only: pings + fs stats only; never mutates route/pin/gates.
|
|
282
|
+
const report = await collectPlacementPlan({
|
|
283
|
+
encoderCachePath: join(ctx.cwd, '.pi-smart-router/models'),
|
|
284
|
+
diskPath: ctx.cwd,
|
|
285
|
+
});
|
|
286
|
+
throwIfCommandAborted(signal);
|
|
287
|
+
if (parsed.command === 'plan' && parsed.format === 'json') {
|
|
288
|
+
ctx.ui.notify(JSON.stringify(report, null, 2), 'info');
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
ctx.ui.notify(
|
|
292
|
+
parsed.command === 'doctor'
|
|
293
|
+
? formatDoctorMessage(report)
|
|
294
|
+
: formatPlacementPlanMessage(report),
|
|
295
|
+
'info',
|
|
296
|
+
);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
270
300
|
if (parsed.command === 'unpin') {
|
|
271
301
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
272
302
|
const sessionPinner = runtime.streamDeps.sessionPinner;
|
|
@@ -15,6 +15,13 @@ import {
|
|
|
15
15
|
createOnnxEmbeddingProvider,
|
|
16
16
|
} from '../../../src/domain/matching/hydra-matcher.js';
|
|
17
17
|
import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
|
|
18
|
+
import {
|
|
19
|
+
collectPoolModelIds,
|
|
20
|
+
resolveQuotaWindowEstimateConfigFromEnv,
|
|
21
|
+
resolveQuotaWindowPosition,
|
|
22
|
+
type QuotaWindowAdapter,
|
|
23
|
+
type QuotaWindowEstimateConfig,
|
|
24
|
+
} from '../../../src/domain/pricing/quota-window-feed.js';
|
|
18
25
|
import type { ModelProfile, PriceCatalog } from '../../../src/domain/types/index.js';
|
|
19
26
|
import type { QuotaWindowPosition } from '../../../src/domain/types/entities.js';
|
|
20
27
|
import type { OperatorConfig } from '../../../src/domain/types/schemas.js';
|
|
@@ -38,10 +45,51 @@ export interface CreateDispatchOptionsExtras {
|
|
|
38
45
|
readonly operatorConfig?: OperatorConfig;
|
|
39
46
|
/** Live price catalog when fleet discovery has loaded one. */
|
|
40
47
|
readonly priceCatalog?: PriceCatalog | null;
|
|
41
|
-
/** Rolling subscription quota position when available. */
|
|
48
|
+
/** Rolling subscription quota position when available (see resolveQuotaWindowFeedPosition, SP-214). */
|
|
42
49
|
readonly quotaWindowPosition?: QuotaWindowPosition;
|
|
43
50
|
}
|
|
44
51
|
|
|
52
|
+
/** Max telemetry rows scanned for the quota-window burn estimate (SP-214). */
|
|
53
|
+
const QUOTA_FEED_TELEMETRY_LIMIT = 5000;
|
|
54
|
+
|
|
55
|
+
export interface ResolveQuotaWindowFeedDeps {
|
|
56
|
+
/** Optional provider adapter (degrade chain step 1). */
|
|
57
|
+
readonly adapter?: QuotaWindowAdapter;
|
|
58
|
+
/** Estimate config override; defaults to env-resolved config. */
|
|
59
|
+
readonly estimateConfig?: QuotaWindowEstimateConfig;
|
|
60
|
+
readonly now?: Date;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the pool-level `QuotaWindowPosition` for the fleet via the SP-214
|
|
65
|
+
* degrade chain: adapter → telemetry burn estimate → omit. Returns `undefined`
|
|
66
|
+
* when the fleet has no subscription pool and no adapter, or when the feed is
|
|
67
|
+
* disabled — callers then fall back to flat virtual cost + SP-097 failover.
|
|
68
|
+
*/
|
|
69
|
+
export async function resolveQuotaWindowFeedPosition(
|
|
70
|
+
store: StorePort,
|
|
71
|
+
fleet: readonly ModelProfile[],
|
|
72
|
+
deps?: ResolveQuotaWindowFeedDeps,
|
|
73
|
+
): Promise<QuotaWindowPosition | undefined> {
|
|
74
|
+
const poolModelIds = collectPoolModelIds(fleet);
|
|
75
|
+
if (poolModelIds.size === 0 && !deps?.adapter) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const estimateConfig =
|
|
79
|
+
deps?.estimateConfig ?? resolveQuotaWindowEstimateConfigFromEnv();
|
|
80
|
+
const entries =
|
|
81
|
+
poolModelIds.size > 0
|
|
82
|
+
? await store.listTelemetry({ limit: QUOTA_FEED_TELEMETRY_LIMIT })
|
|
83
|
+
: [];
|
|
84
|
+
return resolveQuotaWindowPosition({
|
|
85
|
+
adapter: deps?.adapter,
|
|
86
|
+
entries,
|
|
87
|
+
poolModelIds,
|
|
88
|
+
estimateConfig,
|
|
89
|
+
...(deps?.now !== undefined ? { now: deps.now } : {}),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
45
93
|
/** Minimal settings surface used for scoped fleet discovery. */
|
|
46
94
|
export interface ScopedSettingsReader {
|
|
47
95
|
getEnabledModels(): string[] | null | undefined;
|
|
@@ -235,9 +283,11 @@ export async function rebuildFleet(
|
|
|
235
283
|
);
|
|
236
284
|
runtime.priceCatalog = catalog;
|
|
237
285
|
runtime.fleetScopeFingerprint = fingerprint;
|
|
286
|
+
const quotaWindowPosition = await resolveQuotaWindowFeedPosition(runtime.store, fleet);
|
|
238
287
|
const router = createRouterFromFleet(fleet, {
|
|
239
288
|
...createDispatchOptions(runtime.store, runtime.sessionPinner, runtime.hydraMatcher, {
|
|
240
289
|
priceCatalog: catalog,
|
|
290
|
+
...(quotaWindowPosition !== undefined ? { quotaWindowPosition } : {}),
|
|
241
291
|
}),
|
|
242
292
|
lifecycleHookState: runtime.lifecycleHookState,
|
|
243
293
|
});
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* on compressed context, inject the result as an observation, and keep primary
|
|
6
6
|
* inference on the pinned economical model. Falls back to direct frontier routing
|
|
7
7
|
* when sub-agent spawn is unavailable (pi has no native sub-agent API yet).
|
|
8
|
+
*
|
|
9
|
+
* SP-213 / #120: sub-calls are bounded by a global stage timeout and a per-call
|
|
10
|
+
* worker timeout (llm-use WORKER_GLOBAL_TIMEOUT / WORKER_CALL_TIMEOUT pattern).
|
|
11
|
+
* On timeout the worker is cancelled/abandoned, `planning_delegate_timeout` is
|
|
12
|
+
* recorded, and routing falls back to the direct frontier path — never a hang.
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
15
|
import {
|
|
@@ -22,10 +27,12 @@ import type {
|
|
|
22
27
|
PlanningDelegateObservability,
|
|
23
28
|
RoutingDecision,
|
|
24
29
|
} from '../../../src/domain/types/index.js';
|
|
30
|
+
import { DEFAULT_PLANNING_DELEGATE_CONFIG } from '../../../src/domain/types/schemas.js';
|
|
25
31
|
import {
|
|
26
32
|
createPlanningDelegateObservability,
|
|
27
33
|
enrichRoutingDecisionWithPlanningDelegate,
|
|
28
34
|
PLANNING_DELEGATE,
|
|
35
|
+
PLANNING_DELEGATE_TIMEOUT,
|
|
29
36
|
PLANNING_DELEGATE_UNAVAILABLE,
|
|
30
37
|
PLANNING_DIRECT_FRONTIER,
|
|
31
38
|
} from '../../../src/infrastructure/telemetry/routing-telemetry.js';
|
|
@@ -222,6 +229,65 @@ export interface PlanningDelegateResolution {
|
|
|
222
229
|
readonly usedDelegatePath: boolean;
|
|
223
230
|
}
|
|
224
231
|
|
|
232
|
+
/** Worker telemetry analogs for one planning turn (SP-213, #120). */
|
|
233
|
+
interface DelegateWorkerTelemetry {
|
|
234
|
+
readonly workers_spawned: number;
|
|
235
|
+
readonly workers_succeeded: number;
|
|
236
|
+
readonly worker_timeout_count: number;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Race a delegate sub-call against a bounded timeout (SP-213, #120).
|
|
241
|
+
*
|
|
242
|
+
* On expiry the worker is signalled for cancellation (AbortSignal forwarded to
|
|
243
|
+
* the sub-call options) and abandoned — the race resolves immediately so a
|
|
244
|
+
* stalled worker can never hang TTFT. An outer caller abort is forwarded to
|
|
245
|
+
* the worker as well. No retries and no queue: exactly one worker per call.
|
|
246
|
+
*/
|
|
247
|
+
async function spawnPlanningDelegateWithTimeout(
|
|
248
|
+
spawnFn: PlanningDelegateSpawnFn,
|
|
249
|
+
frontierModel: Model<Api>,
|
|
250
|
+
compressedContext: Context,
|
|
251
|
+
options: SimpleStreamOptions | undefined,
|
|
252
|
+
deps: StreamDelegationDeps,
|
|
253
|
+
timeoutMs: number,
|
|
254
|
+
): Promise<PlanningDelegateSpawnResult> {
|
|
255
|
+
const controller = new AbortController();
|
|
256
|
+
const outerSignal = options?.signal;
|
|
257
|
+
const forwardOuterAbort = (): void => controller.abort();
|
|
258
|
+
if (outerSignal) {
|
|
259
|
+
if (outerSignal.aborted) {
|
|
260
|
+
controller.abort();
|
|
261
|
+
} else {
|
|
262
|
+
outerSignal.addEventListener('abort', forwardOuterAbort, { once: true });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
267
|
+
try {
|
|
268
|
+
const spawnOptions: SimpleStreamOptions = {
|
|
269
|
+
...(options ?? {}),
|
|
270
|
+
signal: controller.signal,
|
|
271
|
+
};
|
|
272
|
+
const spawnPromise = spawnFn(frontierModel, compressedContext, spawnOptions, deps);
|
|
273
|
+
// Swallow late rejections from an abandoned worker so a timeout never
|
|
274
|
+
// surfaces as an unhandled rejection after the fallback already routed.
|
|
275
|
+
spawnPromise.catch(() => {});
|
|
276
|
+
const timeoutPromise = new Promise<PlanningDelegateSpawnResult>((resolve) => {
|
|
277
|
+
timer = setTimeout(() => {
|
|
278
|
+
controller.abort();
|
|
279
|
+
resolve({ ok: false, reason: PLANNING_DELEGATE_TIMEOUT });
|
|
280
|
+
}, timeoutMs);
|
|
281
|
+
});
|
|
282
|
+
return await Promise.race([spawnPromise, timeoutPromise]);
|
|
283
|
+
} finally {
|
|
284
|
+
if (timer) {
|
|
285
|
+
clearTimeout(timer);
|
|
286
|
+
}
|
|
287
|
+
outerSignal?.removeEventListener('abort', forwardOuterAbort);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
225
291
|
/**
|
|
226
292
|
* Resolve planning delegate path: sub-call + observation injection, or direct frontier fallback.
|
|
227
293
|
*/
|
|
@@ -237,6 +303,10 @@ export async function resolvePlanningDelegatePath(
|
|
|
237
303
|
const observability = decision.features!.planning_delegate!;
|
|
238
304
|
const delegateModelId = observability.delegate_model_id!;
|
|
239
305
|
const primaryModelId = decision.selected_model_id;
|
|
306
|
+
const delegateConfig =
|
|
307
|
+
deps.planningDelegateConfig ?? DEFAULT_PLANNING_DELEGATE_CONFIG;
|
|
308
|
+
// Global stage deadline: bounds compression + sub-call wall-clock (SP-213, #120).
|
|
309
|
+
const globalDeadlineMs = Date.now() + delegateConfig.global_timeout_ms;
|
|
240
310
|
|
|
241
311
|
const frontierProfile = findFleetProfile(deps.fleet, delegateModelId);
|
|
242
312
|
const frontierModel = frontierProfile
|
|
@@ -254,6 +324,7 @@ export async function resolvePlanningDelegatePath(
|
|
|
254
324
|
delegateModelId,
|
|
255
325
|
PLANNING_DELEGATE_UNAVAILABLE,
|
|
256
326
|
deps,
|
|
327
|
+
{ workers_spawned: 0, workers_succeeded: 0, worker_timeout_count: 0 },
|
|
257
328
|
);
|
|
258
329
|
}
|
|
259
330
|
|
|
@@ -262,20 +333,60 @@ export async function resolvePlanningDelegatePath(
|
|
|
262
333
|
observability.compressed_context,
|
|
263
334
|
);
|
|
264
335
|
throwIfAborted(options);
|
|
336
|
+
|
|
337
|
+
const remainingGlobalMs = globalDeadlineMs - Date.now();
|
|
338
|
+
if (remainingGlobalMs <= 0) {
|
|
339
|
+
console.warn(
|
|
340
|
+
'[smart-router] planning delegate global timeout exhausted before sub-call, falling back to direct frontier route',
|
|
341
|
+
delegateModelId,
|
|
342
|
+
);
|
|
343
|
+
return applyPlanningDelegateDirectFallback(
|
|
344
|
+
context,
|
|
345
|
+
decision,
|
|
346
|
+
delegateModelId,
|
|
347
|
+
PLANNING_DELEGATE_TIMEOUT,
|
|
348
|
+
deps,
|
|
349
|
+
{ workers_spawned: 0, workers_succeeded: 0, worker_timeout_count: 1 },
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
265
353
|
const spawnFn = deps.spawnPlanningDelegate ?? defaultSpawnPlanningDelegate;
|
|
266
|
-
|
|
354
|
+
// Per-call cap, further bounded by the remaining global budget.
|
|
355
|
+
const subCallTimeoutMs = Math.min(
|
|
356
|
+
delegateConfig.sub_call_timeout_ms,
|
|
357
|
+
remainingGlobalMs,
|
|
358
|
+
);
|
|
359
|
+
const spawnResult = await spawnPlanningDelegateWithTimeout(
|
|
360
|
+
spawnFn,
|
|
361
|
+
frontierModel,
|
|
362
|
+
compressedContext,
|
|
363
|
+
options,
|
|
364
|
+
deps,
|
|
365
|
+
subCallTimeoutMs,
|
|
366
|
+
);
|
|
267
367
|
|
|
268
368
|
if (!spawnResult.ok) {
|
|
369
|
+
const timedOut = spawnResult.reason === PLANNING_DELEGATE_TIMEOUT;
|
|
370
|
+
const fallbackReason = timedOut
|
|
371
|
+
? PLANNING_DELEGATE_TIMEOUT
|
|
372
|
+
: PLANNING_DELEGATE_UNAVAILABLE;
|
|
269
373
|
console.warn(
|
|
270
|
-
|
|
374
|
+
timedOut
|
|
375
|
+
? '[smart-router] planning delegate sub-call timed out, falling back to direct frontier route'
|
|
376
|
+
: '[smart-router] planning delegate sub-call failed, falling back to direct frontier route',
|
|
271
377
|
spawnResult.reason,
|
|
272
378
|
);
|
|
273
379
|
return applyPlanningDelegateDirectFallback(
|
|
274
380
|
context,
|
|
275
381
|
decision,
|
|
276
382
|
delegateModelId,
|
|
277
|
-
|
|
383
|
+
fallbackReason,
|
|
278
384
|
deps,
|
|
385
|
+
{
|
|
386
|
+
workers_spawned: 1,
|
|
387
|
+
workers_succeeded: 0,
|
|
388
|
+
worker_timeout_count: timedOut ? 1 : 0,
|
|
389
|
+
},
|
|
279
390
|
);
|
|
280
391
|
}
|
|
281
392
|
|
|
@@ -290,7 +401,12 @@ export async function resolvePlanningDelegatePath(
|
|
|
290
401
|
|
|
291
402
|
return {
|
|
292
403
|
context: injectPlanningDelegateObservation(context, spawnResult.observationText),
|
|
293
|
-
decision,
|
|
404
|
+
decision: enrichRoutingDecisionWithPlanningDelegate(decision, {
|
|
405
|
+
...observability,
|
|
406
|
+
workers_spawned: 1,
|
|
407
|
+
workers_succeeded: 1,
|
|
408
|
+
worker_timeout_count: 0,
|
|
409
|
+
}),
|
|
294
410
|
targetModelId: primaryModelId,
|
|
295
411
|
usedDelegatePath: true,
|
|
296
412
|
};
|
|
@@ -302,6 +418,7 @@ function applyPlanningDelegateDirectFallback(
|
|
|
302
418
|
delegateModelId: string,
|
|
303
419
|
fallbackReason: string,
|
|
304
420
|
deps: StreamDelegationDeps,
|
|
421
|
+
workerTelemetry?: DelegateWorkerTelemetry,
|
|
305
422
|
): PlanningDelegateResolution {
|
|
306
423
|
const profile = findFleetProfile(deps.fleet, delegateModelId);
|
|
307
424
|
const fallbackDecision = enrichRoutingDecisionWithPlanningDelegate(
|
|
@@ -316,6 +433,9 @@ function applyPlanningDelegateDirectFallback(
|
|
|
316
433
|
delegate_model_id: delegateModelId,
|
|
317
434
|
planning_delegate_reason_code: PLANNING_DIRECT_FRONTIER,
|
|
318
435
|
fallback_reason: fallbackReason,
|
|
436
|
+
workers_spawned: workerTelemetry?.workers_spawned ?? null,
|
|
437
|
+
workers_succeeded: workerTelemetry?.workers_succeeded ?? null,
|
|
438
|
+
worker_timeout_count: workerTelemetry?.worker_timeout_count ?? null,
|
|
319
439
|
}),
|
|
320
440
|
);
|
|
321
441
|
|
|
@@ -12,6 +12,7 @@ import { ExecutionLedger } from '../../../src/domain/delegation/execution-ledger
|
|
|
12
12
|
import { SessionPinner } from '../../../src/domain/pinning/session-pinner.js';
|
|
13
13
|
import type {
|
|
14
14
|
ModelProfile,
|
|
15
|
+
PlanningDelegateConfig,
|
|
15
16
|
PriceCatalog,
|
|
16
17
|
RoutingDecision,
|
|
17
18
|
} from '../../../src/domain/types/index.js';
|
|
@@ -60,6 +61,8 @@ export interface StreamDelegationDeps {
|
|
|
60
61
|
delegateStream?: DelegateStreamFn;
|
|
61
62
|
/** Injectable planning delegate sub-call; production uses frontier stream delegate. */
|
|
62
63
|
spawnPlanningDelegate?: PlanningDelegateSpawnFn;
|
|
64
|
+
/** Planning delegate knobs incl. global + per-call timeout bounds (SP-213, #120). */
|
|
65
|
+
readonly planningDelegateConfig?: PlanningDelegateConfig;
|
|
63
66
|
readonly lifecycleHookState?: LifecycleHookState;
|
|
64
67
|
readonly datasetRecorder?: DatasetRecorder;
|
|
65
68
|
readonly outcomeRecorder?: OutcomeRecorder;
|
package/README.md
CHANGED
|
@@ -225,9 +225,31 @@ Cursor models bill against your **Cursor Pro subscription quota**, not per-token
|
|
|
225
225
|
| `/smart-router export telemetry-contrib [--limit N]` | Export privacy-safe community telemetry JSON for calibration contributions |
|
|
226
226
|
| `/smart-router feedback good\|bad` | Label the last auto-routed request outcome (requires `SMART_ROUTER_DATASET=1`) |
|
|
227
227
|
| `/smart-router unpin` | Clear the current session pin (in-memory and SQLite) so the next request runs the full routing pipeline |
|
|
228
|
+
| `/smart-router plan [--json]` | **Read-only** local placement report: encoder resident status, local model warm/cold, RAM/disk constraints, cold vs warm TPS, and bottleneck guess. `--json` prints the schema-stable report for automation |
|
|
229
|
+
| `/smart-router doctor` | **Read-only** local readiness checklist (✓/✗) with bottleneck guess and recommendation — validate placement without starting a route |
|
|
228
230
|
|
|
229
231
|
Fleet mode persists in the session. Use `scoped` to respect your `/model` enable-list; use `all` when you want the router to consider every provider you have logged into.
|
|
230
232
|
|
|
233
|
+
### Local placement plan / doctor (read-only, #116)
|
|
234
|
+
|
|
235
|
+
`/smart-router plan` and `/smart-router doctor` report **local placement readiness without mutating anything** — no route, pin, or gate is touched. Inspired by Colibrì's `coli plan` / `coli doctor`.
|
|
236
|
+
|
|
237
|
+
The report covers:
|
|
238
|
+
|
|
239
|
+
- **Encoder** — whether HyDRA ONNX artifacts are resident in the cache (`.pi-smart-router/models/`) or will download on first route
|
|
240
|
+
- **Local model warm/cold** — LM Studio / Ollama reachability and whether a model is actually loaded (`warm`) vs reachable-but-unloaded (`cold-start expected`)
|
|
241
|
+
- **Hardware** — platform/arch, total/free RAM, hardware-probe verdict (`full_local` / `classification_only` / `disabled`), battery state
|
|
242
|
+
- **Disk** — free GiB; flagged constrained below 2 GiB
|
|
243
|
+
- **Throughput (cold vs warm TPS)** — see formula below
|
|
244
|
+
- **Bottleneck guess** — one of `none`, `unsupported-platform`, `battery`, `memory`, `disk`, `no-local-runtime`, `cold-start`, `cold-throughput`, `warm-throughput`, with a rationale string
|
|
245
|
+
- **Recommendation** — `local-ready`, `local-warmup-needed`, or `local-unavailable`
|
|
246
|
+
|
|
247
|
+
`/smart-router plan --json` prints the same report as schema-stable JSON (`schemaVersion: 1`, `kind: "smart-router-placement-plan"`; all keys always present, unknowns are `null`) for automation.
|
|
248
|
+
|
|
249
|
+
**Cold vs warm TPS formula.** Throughput samples are tagged by phase: `warm` samples measure steady-state generation after model load; `cold` samples include cold-start load cost and never count toward viability. `warmMedianTps = median(tps where phase='warm')`; viability is `warmSamples > 0 AND warmMedianTps >= threshold` (default 25 tok/s). **Cold-only windows fail closed**: when only cold samples exist, local viability is false by policy (`requireWarmSamples: true`) — cold-start cost must not masquerade as steady-state throughput.
|
|
250
|
+
|
|
251
|
+
**Quality-preserving resource policy.** Under RAM/disk/battery pressure the router prefers **"local unavailable / escalate safely"** to a cloud default over silently weakening encoder fidelity (no quantization flips, no cheaper cascades, no FrugalGPT-style downgrade chains). `plan`/`doctor` surface this policy verbatim in the report's `policy` block.
|
|
252
|
+
|
|
231
253
|
After typing `/smart-router ` (with a trailing space), press **TAB** to see subcommands. Continue TAB-completing after `mode` or `pricing` for sub-options (`scoped`/`all`, `refresh`).
|
|
232
254
|
|
|
233
255
|
### 5. Verify
|
|
@@ -368,6 +390,8 @@ Cluster IDs are stable reason-code prefixes (`cluster_low_stakes_general`, `clus
|
|
|
368
390
|
| `SMART_ROUTER_PLANNING_DELEGATE_MAX_MESSAGES` | `12` | Compressed-context message cap for frontier sub-call |
|
|
369
391
|
| `SMART_ROUTER_PLANNING_DELEGATE_MAX_TOKENS` | `16384` | Compressed-context token cap for frontier sub-call |
|
|
370
392
|
| `SMART_ROUTER_PLANNING_DELEGATE_EXCLUDE_EXECUTION_HISTORY` | `true` | Exclude tool execution history from delegate payload |
|
|
393
|
+
| `SMART_ROUTER_PLANNING_DELEGATE_GLOBAL_TIMEOUT_MS` | `120000` | Global cap (ms) on the whole planning-delegate stage per planning turn — bounds fan-out wall-clock so a stalled worker cannot hang TTFT ([#120](https://github.com/beettlle/pi-smart-router/issues/120)) |
|
|
394
|
+
| `SMART_ROUTER_PLANNING_DELEGATE_SUB_CALL_TIMEOUT_MS` | `30000` | Per-call cap (ms) on each delegate sub-call worker; on expiry the worker is cancelled/abandoned and routing falls back to direct frontier with `planning_delegate_timeout` ([#120](https://github.com/beettlle/pi-smart-router/issues/120)) |
|
|
371
395
|
| `SMART_ROUTER_PREFIX_CACHE_WEIGHT` | `0.20` | SAAR weight on warm prefix value in cache breakeven math (0–1; [#73](https://github.com/beettlle/pi-smart-router/issues/73)) |
|
|
372
396
|
| `SMART_ROUTER_IDLE_TIMEOUT_SECONDS` | `300` | SAAR idle seconds before pin reopens for full re-route |
|
|
373
397
|
| `SMART_ROUTER_SWITCH_THRESHOLD` | `0.5` | SAAR switch score gate (0–1) for tier upgrades during hard-lock |
|
|
@@ -442,6 +466,25 @@ When a **planning** turn would route primary inference to frontier while a warm
|
|
|
442
466
|
|
|
443
467
|
See [routing-roadmap.md](docs/routing-roadmap.md) §2 P0 and GitHub [#71](https://github.com/beettlle/pi-smart-router/issues/71) for acceptance criteria.
|
|
444
468
|
|
|
469
|
+
### Degraded neural failover sandwich (#119)
|
|
470
|
+
|
|
471
|
+
When the encoder/neural stage (HyDRA) **fails, is misconfigured, or exceeds its latency budget without a selection**, routing fails open through a cheap chain instead of crashing the host agent ([#119](https://github.com/beettlle/pi-smart-router/issues/119)):
|
|
472
|
+
|
|
473
|
+
1. **learned** — optional privacy-safe map keyed by requirement fingerprint (SHA-256 of the rounded requirement vector) or cluster id → preferred tier. **Raw prompt text is never stored.** Exact-key policy: fingerprint match first, cluster id second (no fuzzy matching). Writes are validated (bounded floats, snake_case cluster ids, tier enum) and capped (FIFO eviction) so confounder attacks cannot poison routing memory.
|
|
474
|
+
2. **heuristic** — optional operator **pattern pack** (router_rules-style regex overlay) for known-simple intents. Deny-by-default (no match → no decision) and **fail closed on invalid regex** (the rule is rejected at load and never applies).
|
|
475
|
+
3. **safe_default** — context-fit aware safe economical/frontier default (`degraded_safe_default`).
|
|
476
|
+
|
|
477
|
+
Explain/telemetry expose `route_path` (`neural` \| `learned` \| `heuristic` \| `safe_default`) plus `route_path_confidence` on every decision; degraded decisions carry reason codes `degraded_learned_route`, `degraded_pattern_<rule_id>`, or `degraded_safe_default`. A learned/pattern suggestion toward a cheaper tier is only honored when the cheap tool-use cue estimate is below `pattern_tool_use_ceiling` — a cheap overlay **never alone overrides a predicted capability shortfall**.
|
|
478
|
+
|
|
479
|
+
| Knob (`degraded_route` operator config) | Default | Effect |
|
|
480
|
+
|------|---------|--------|
|
|
481
|
+
| `enabled` | `true` | When `false`, neural failures use the legacy `safe_default` stage pass-through |
|
|
482
|
+
| `learned_min_confidence` | `0.6` | Minimum learned-entry confidence to honor a tier suggestion |
|
|
483
|
+
| `learned_max_entries` | `512` | Learned-map cap per key space (FIFO eviction) |
|
|
484
|
+
| `pattern_tool_use_ceiling` | `0.3` | Tool-use cue ceiling for honoring cheaper-tier learned/pattern suggestions |
|
|
485
|
+
|
|
486
|
+
Distinct from soft heat affinity (healthy-path bias): this is failover / skip-expensive-stage only. Routing remains **pre-generation** — no FrugalGPT-style cascades (see [routing-roadmap.md](docs/routing-roadmap.md) §1).
|
|
487
|
+
|
|
445
488
|
### Virtual cost v2 (v0.5.0 subscription economics)
|
|
446
489
|
|
|
447
490
|
**Virtual cost v2** extends SP-096 flat `quota_cost_per_1m` with deterministic subscription-window economics ([#78](https://github.com/beettlle/pi-smart-router/issues/78)). It inflates effective frontier cost late in a rolling quota window and credits warm prefix-cache value on active pins — without MDP or reinforcement-learning quota policy (SeqRoute HBR+CQL is deferred).
|
|
@@ -462,6 +505,10 @@ See [routing-roadmap.md](docs/routing-roadmap.md) §2 P0 and GitHub [#71](https:
|
|
|
462
505
|
|
|
463
506
|
Rolling-window position is supplied to the router pipeline as `quotaWindowPosition` (library API / telemetry integration). Use `remaining_window_fraction` in `[0, 1]` (1 = full budget). Optionally derive it from elapsed time and consumed quota via `deriveRemainingWindowFraction(elapsed_seconds, consumed_fraction)` in `virtual-cost-v2.ts` (defaults assume a Cursor-style **5h** window).
|
|
464
507
|
|
|
508
|
+
**Quota window feed (producer, [#125](https://github.com/beettlle/pi-smart-router/issues/125))**
|
|
509
|
+
|
|
510
|
+
There is no universal cross-provider "remaining quota" API, so `src/domain/pricing/quota-window-feed.ts` produces the position via an adapter + degrade chain: (1) a provider `QuotaWindowAdapter` when a trustworthy signal exists, (2) a telemetry-derived **pool-level** burn estimate over the rolling window (subscription-pool models = fleet entries with `quota_cost_per_1m`; enabled via `SMART_ROUTER_QUOTA_POOL_BUDGET_TOKENS` + `SMART_ROUTER_QUOTA_WINDOW_SECONDS`), (3) omit → flat virtual cost + SP-097 exhaustion failover. The smart-router extension resolves the feed at fleet rebuild and passes it through `createDispatchOptions` (SP-173 wiring gap closed). Soft bias only — no hard ban at any threshold; SP-097 reactive failover remains the safety net when the feed is missing or stale. Per-model fractions for shared pools are never invented.
|
|
511
|
+
|
|
465
512
|
When `quotaWindowPosition` is omitted, λ stays at 1 and quota premiums are zero — behavior matches SP-096 flat virtual cost.
|
|
466
513
|
|
|
467
514
|
**Operator knobs** (`VirtualCostV2Config` — wire through `RouterPipeline` options today; defaults in `DEFAULT_VIRTUAL_COST_V2_CONFIG`):
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Values sourced from specs/001-build-smart-router/data-model.md § Configuration (Operator).
|
|
4
4
|
*/
|
|
5
5
|
import { type OperatorConfig } from '../domain/types/schemas.js';
|
|
6
|
-
export { DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
6
|
+
export { DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, DEFAULT_SPECULATIVE_PREWARM_CONFIG, DEFAULT_WORKLOAD_HEAT_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
7
7
|
/** Merge operator env overrides onto defaults (SAAR and planning delegate sections). */
|
|
8
8
|
export declare function resolveOperatorConfigFromEnv(base?: OperatorConfig): OperatorConfig;
|
|
9
9
|
export declare const DEFAULT_OPERATOR_CONFIG: Readonly<OperatorConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EASL,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,kCAAkC,EAClC,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,wFAAwF;AACxF,wBAAgB,4BAA4B,CAC1C,IAAI,GAAE,cAAwC,GAC7C,cAAc,CAMhB;AAED,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,cAAc,CAqCnD,CAAC"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Operator configuration defaults (FR-021).
|
|
3
3
|
* Values sourced from specs/001-build-smart-router/data-model.md § Configuration (Operator).
|
|
4
4
|
*/
|
|
5
|
-
import { DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
5
|
+
import { DEFAULT_DEGRADED_ROUTE_CONFIG, DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, DEFAULT_SPECULATIVE_PREWARM_CONFIG, DEFAULT_WORKLOAD_HEAT_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
6
6
|
import { DEFAULT_LOW_INTENSITY_WEIGHTS } from '../domain/routing/tier-features.js';
|
|
7
|
-
export { DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
7
|
+
export { DEFAULT_LOCAL_ZERO_CONFIG, DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_SAAR_CONFIG, DEFAULT_SPECULATIVE_PREWARM_CONFIG, DEFAULT_WORKLOAD_HEAT_CONFIG, resolvePlanningDelegateConfigFromEnv, resolveSaarConfigFromEnv, } from '../domain/types/schemas.js';
|
|
8
8
|
/** Merge operator env overrides onto defaults (SAAR and planning delegate sections). */
|
|
9
9
|
export function resolveOperatorConfigFromEnv(base = DEFAULT_OPERATOR_CONFIG) {
|
|
10
10
|
return {
|
|
@@ -44,6 +44,11 @@ export const DEFAULT_OPERATOR_CONFIG = {
|
|
|
44
44
|
saar: DEFAULT_SAAR_CONFIG,
|
|
45
45
|
planning_delegate: DEFAULT_PLANNING_DELEGATE_CONFIG,
|
|
46
46
|
local_zero: DEFAULT_LOCAL_ZERO_CONFIG,
|
|
47
|
+
degraded_route: DEFAULT_DEGRADED_ROUTE_CONFIG,
|
|
48
|
+
/** Heat knobs only (SP-215) — no frugality default or absolute-gate flips. */
|
|
49
|
+
workload_heat: DEFAULT_WORKLOAD_HEAT_CONFIG,
|
|
50
|
+
/** Speculative prewarm (SP-217, #117): default OFF; opt-in via operator config. */
|
|
51
|
+
speculative_prewarm: DEFAULT_SPECULATIVE_PREWARM_CONFIG,
|
|
47
52
|
pin_only_fallback: false,
|
|
48
53
|
};
|
|
49
54
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,oCAAoC,EACpC,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,oCAAoC,EACpC,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,wFAAwF;AACxF,MAAM,UAAU,4BAA4B,CAC1C,OAAuB,uBAAuB;IAE9C,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;QACzC,iBAAiB,EAAE,oCAAoC,CAAC,IAAI,CAAC,iBAAiB,CAAC;KAChF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA6B;IAC/D,SAAS,EAAE;QACT,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,GAAG;QACnB,gBAAgB,EAAE,IAAI;KACvB;IACD,eAAe,EAAE;QACf,SAAS,EAAE,CAAC;KACb;IACD,OAAO,EAAE;QACP,cAAc,EAAE,EAAE;KACnB;IACD,KAAK,EAAE;QACL,kBAAkB,EAAE,EAAE;QACtB,4BAA4B,EAAE,CAAC;QAC/B,qBAAqB,EAAE,EAAE;KAC1B;IACD,KAAK,EAAE;QACL,mBAAmB,EAAE,0BAA0B;QAC/C,OAAO,EAAE,QAAQ;QACjB,WAAW,EAAE,oBAAoB;KAClC;IACD,aAAa,EAAE;QACb,OAAO,EAAE,6BAA6B;QACtC,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,GAAG;KACrB;IACD,IAAI,EAAE,mBAAmB;IACzB,iBAAiB,EAAE,gCAAgC;IACnD,UAAU,EAAE,yBAAyB;IACrC,iBAAiB,EAAE,KAAK;CAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,kCAAkC,EAClC,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,kCAAkC,EAClC,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,wFAAwF;AACxF,MAAM,UAAU,4BAA4B,CAC1C,OAAuB,uBAAuB;IAE9C,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;QACzC,iBAAiB,EAAE,oCAAoC,CAAC,IAAI,CAAC,iBAAiB,CAAC;KAChF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA6B;IAC/D,SAAS,EAAE;QACT,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,GAAG;QACnB,gBAAgB,EAAE,IAAI;KACvB;IACD,eAAe,EAAE;QACf,SAAS,EAAE,CAAC;KACb;IACD,OAAO,EAAE;QACP,cAAc,EAAE,EAAE;KACnB;IACD,KAAK,EAAE;QACL,kBAAkB,EAAE,EAAE;QACtB,4BAA4B,EAAE,CAAC;QAC/B,qBAAqB,EAAE,EAAE;KAC1B;IACD,KAAK,EAAE;QACL,mBAAmB,EAAE,0BAA0B;QAC/C,OAAO,EAAE,QAAQ;QACjB,WAAW,EAAE,oBAAoB;KAClC;IACD,aAAa,EAAE;QACb,OAAO,EAAE,6BAA6B;QACtC,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,GAAG;KACrB;IACD,IAAI,EAAE,mBAAmB;IACzB,iBAAiB,EAAE,gCAAgC;IACnD,UAAU,EAAE,yBAAyB;IACrC,cAAc,EAAE,6BAA6B;IAC7C,8EAA8E;IAC9E,aAAa,EAAE,4BAA4B;IAC3C,mFAAmF;IACnF,mBAAmB,EAAE,kCAAkC;IACvD,iBAAiB,EAAE,KAAK;CAChB,CAAC"}
|