pi-smart-router 0.1.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 +167 -0
- package/.pi/extensions/smart-router/commands.ts +242 -0
- package/.pi/extensions/smart-router/dataset-export.ts +142 -0
- package/.pi/extensions/smart-router/delegate-stream.ts +105 -0
- package/.pi/extensions/smart-router/delegation-runtime.ts +355 -0
- package/.pi/extensions/smart-router/extension-setup.ts +115 -0
- package/.pi/extensions/smart-router/fleet-bootstrap.ts +244 -0
- package/.pi/extensions/smart-router/index.ts +115 -0
- package/.pi/extensions/smart-router/package.json +3 -0
- package/.pi/extensions/smart-router/pi-model-scope.ts +55 -0
- package/.pi/extensions/smart-router/pricing-lifecycle.ts +43 -0
- package/.pi/extensions/smart-router/route-and-delegate.ts +562 -0
- package/.pi/extensions/smart-router/routing-context.ts +171 -0
- package/.pi/extensions/smart-router/routing-outcomes.ts +44 -0
- package/.pi/extensions/smart-router/session-lifecycle.ts +140 -0
- package/.pi/extensions/smart-router/stream-delegation.ts +75 -0
- package/.pi/extensions/smart-router/types.ts +90 -0
- package/.pi/extensions/smart-router/utils.ts +58 -0
- package/README.md +593 -0
- package/bin/pi-smart-router.mjs +79 -0
- package/config/.gitkeep +0 -0
- package/config/hydra-projection-weights.json.example +1169 -0
- package/config/models.yaml.example +58 -0
- package/config/p-success-weights.json.example +19 -0
- package/config/routing-calibration.json.example +1605 -0
- package/config/routing-centroids.json.example +1570 -0
- package/config/routing-clusters.yaml.example +41 -0
- package/data/contrib/example.json +25 -0
- package/dist/api/explain/router-explain.d.ts +47 -0
- package/dist/api/explain/router-explain.d.ts.map +1 -0
- package/dist/api/explain/router-explain.js +101 -0
- package/dist/api/explain/router-explain.js.map +1 -0
- package/dist/api/middleware/pi-router-middleware.d.ts +86 -0
- package/dist/api/middleware/pi-router-middleware.d.ts.map +1 -0
- package/dist/api/middleware/pi-router-middleware.js +83 -0
- package/dist/api/middleware/pi-router-middleware.js.map +1 -0
- package/dist/cli/smart-router-cli.d.ts +85 -0
- package/dist/cli/smart-router-cli.d.ts.map +1 -0
- package/dist/cli/smart-router-cli.js +293 -0
- package/dist/cli/smart-router-cli.js.map +1 -0
- package/dist/config/defaults.d.ts +7 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +33 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/models-loader.d.ts +22 -0
- package/dist/config/models-loader.d.ts.map +1 -0
- package/dist/config/models-loader.js +51 -0
- package/dist/config/models-loader.js.map +1 -0
- package/dist/config/pi-model-mapper.d.ts +40 -0
- package/dist/config/pi-model-mapper.d.ts.map +1 -0
- package/dist/config/pi-model-mapper.js +216 -0
- package/dist/config/pi-model-mapper.js.map +1 -0
- package/dist/config/routing-clusters-loader.d.ts +35 -0
- package/dist/config/routing-clusters-loader.d.ts.map +1 -0
- package/dist/config/routing-clusters-loader.js +100 -0
- package/dist/config/routing-clusters-loader.js.map +1 -0
- package/dist/domain/delegation/delegation-context.d.ts +23 -0
- package/dist/domain/delegation/delegation-context.d.ts.map +1 -0
- package/dist/domain/delegation/delegation-context.js +73 -0
- package/dist/domain/delegation/delegation-context.js.map +1 -0
- package/dist/domain/delegation/execution-ledger.d.ts +19 -0
- package/dist/domain/delegation/execution-ledger.d.ts.map +1 -0
- package/dist/domain/delegation/execution-ledger.js +23 -0
- package/dist/domain/delegation/execution-ledger.js.map +1 -0
- package/dist/domain/delegation/output-headroom.d.ts +39 -0
- package/dist/domain/delegation/output-headroom.d.ts.map +1 -0
- package/dist/domain/delegation/output-headroom.js +78 -0
- package/dist/domain/delegation/output-headroom.js.map +1 -0
- package/dist/domain/matching/cluster-matcher.d.ts +69 -0
- package/dist/domain/matching/cluster-matcher.d.ts.map +1 -0
- package/dist/domain/matching/cluster-matcher.js +294 -0
- package/dist/domain/matching/cluster-matcher.js.map +1 -0
- package/dist/domain/matching/embedding-provider.d.ts +21 -0
- package/dist/domain/matching/embedding-provider.d.ts.map +1 -0
- package/dist/domain/matching/embedding-provider.js +42 -0
- package/dist/domain/matching/embedding-provider.js.map +1 -0
- package/dist/domain/matching/hydra-input.d.ts +18 -0
- package/dist/domain/matching/hydra-input.d.ts.map +1 -0
- package/dist/domain/matching/hydra-input.js +40 -0
- package/dist/domain/matching/hydra-input.js.map +1 -0
- package/dist/domain/matching/hydra-matcher.d.ts +103 -0
- package/dist/domain/matching/hydra-matcher.d.ts.map +1 -0
- package/dist/domain/matching/hydra-matcher.js +275 -0
- package/dist/domain/matching/hydra-matcher.js.map +1 -0
- package/dist/domain/pinning/cache-economics.d.ts +53 -0
- package/dist/domain/pinning/cache-economics.d.ts.map +1 -0
- package/dist/domain/pinning/cache-economics.js +72 -0
- package/dist/domain/pinning/cache-economics.js.map +1 -0
- package/dist/domain/pinning/loop-escalation.d.ts +41 -0
- package/dist/domain/pinning/loop-escalation.d.ts.map +1 -0
- package/dist/domain/pinning/loop-escalation.js +137 -0
- package/dist/domain/pinning/loop-escalation.js.map +1 -0
- package/dist/domain/pinning/session-pinner.d.ts +81 -0
- package/dist/domain/pinning/session-pinner.d.ts.map +1 -0
- package/dist/domain/pinning/session-pinner.js +237 -0
- package/dist/domain/pinning/session-pinner.js.map +1 -0
- package/dist/domain/pinning/sub-route-policy.d.ts +41 -0
- package/dist/domain/pinning/sub-route-policy.d.ts.map +1 -0
- package/dist/domain/pinning/sub-route-policy.js +72 -0
- package/dist/domain/pinning/sub-route-policy.js.map +1 -0
- package/dist/domain/pipeline/router-pipeline.d.ts +180 -0
- package/dist/domain/pipeline/router-pipeline.d.ts.map +1 -0
- package/dist/domain/pipeline/router-pipeline.js +807 -0
- package/dist/domain/pipeline/router-pipeline.js.map +1 -0
- package/dist/domain/pipeline/safe-default.d.ts +25 -0
- package/dist/domain/pipeline/safe-default.d.ts.map +1 -0
- package/dist/domain/pipeline/safe-default.js +41 -0
- package/dist/domain/pipeline/safe-default.js.map +1 -0
- package/dist/domain/refactor-guardrails.d.ts +48 -0
- package/dist/domain/refactor-guardrails.d.ts.map +1 -0
- package/dist/domain/refactor-guardrails.js +129 -0
- package/dist/domain/refactor-guardrails.js.map +1 -0
- package/dist/domain/routing/context-fit.d.ts +53 -0
- package/dist/domain/routing/context-fit.d.ts.map +1 -0
- package/dist/domain/routing/context-fit.js +142 -0
- package/dist/domain/routing/context-fit.js.map +1 -0
- package/dist/domain/routing/expected-cost.d.ts +63 -0
- package/dist/domain/routing/expected-cost.d.ts.map +1 -0
- package/dist/domain/routing/expected-cost.js +177 -0
- package/dist/domain/routing/expected-cost.js.map +1 -0
- package/dist/domain/routing/p-success-classifier.d.ts +130 -0
- package/dist/domain/routing/p-success-classifier.d.ts.map +1 -0
- package/dist/domain/routing/p-success-classifier.js +350 -0
- package/dist/domain/routing/p-success-classifier.js.map +1 -0
- package/dist/domain/routing/tier-features.d.ts +70 -0
- package/dist/domain/routing/tier-features.d.ts.map +1 -0
- package/dist/domain/routing/tier-features.js +174 -0
- package/dist/domain/routing/tier-features.js.map +1 -0
- package/dist/domain/routing/tool-history-guard.d.ts +32 -0
- package/dist/domain/routing/tool-history-guard.d.ts.map +1 -0
- package/dist/domain/routing/tool-history-guard.js +110 -0
- package/dist/domain/routing/tool-history-guard.js.map +1 -0
- package/dist/domain/scoring/multi-objective.d.ts +48 -0
- package/dist/domain/scoring/multi-objective.d.ts.map +1 -0
- package/dist/domain/scoring/multi-objective.js +116 -0
- package/dist/domain/scoring/multi-objective.js.map +1 -0
- package/dist/domain/triage/triage-engine.d.ts +43 -0
- package/dist/domain/triage/triage-engine.d.ts.map +1 -0
- package/dist/domain/triage/triage-engine.js +317 -0
- package/dist/domain/triage/triage-engine.js.map +1 -0
- package/dist/domain/triage/turn-envelope.d.ts +17 -0
- package/dist/domain/triage/turn-envelope.d.ts.map +1 -0
- package/dist/domain/triage/turn-envelope.js +81 -0
- package/dist/domain/triage/turn-envelope.js.map +1 -0
- package/dist/domain/types/entities.d.ts +303 -0
- package/dist/domain/types/entities.d.ts.map +1 -0
- package/dist/domain/types/entities.js +6 -0
- package/dist/domain/types/entities.js.map +1 -0
- package/dist/domain/types/index.d.ts +4 -0
- package/dist/domain/types/index.d.ts.map +1 -0
- package/dist/domain/types/index.js +2 -0
- package/dist/domain/types/index.js.map +1 -0
- package/dist/domain/types/schemas.d.ts +346 -0
- package/dist/domain/types/schemas.d.ts.map +1 -0
- package/dist/domain/types/schemas.js +241 -0
- package/dist/domain/types/schemas.js.map +1 -0
- package/dist/domain/types/store-port.d.ts +44 -0
- package/dist/domain/types/store-port.d.ts.map +1 -0
- package/dist/domain/types/store-port.js +6 -0
- package/dist/domain/types/store-port.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/infra/gemini-provider.d.ts +28 -0
- package/dist/infra/gemini-provider.d.ts.map +1 -0
- package/dist/infra/gemini-provider.js +112 -0
- package/dist/infra/gemini-provider.js.map +1 -0
- package/dist/infra/telemetry.d.ts +51 -0
- package/dist/infra/telemetry.d.ts.map +1 -0
- package/dist/infra/telemetry.js +100 -0
- package/dist/infra/telemetry.js.map +1 -0
- package/dist/infrastructure/delegation/provider-error.d.ts +44 -0
- package/dist/infrastructure/delegation/provider-error.d.ts.map +1 -0
- package/dist/infrastructure/delegation/provider-error.js +179 -0
- package/dist/infrastructure/delegation/provider-error.js.map +1 -0
- package/dist/infrastructure/gateway/circuit-breaker.d.ts +68 -0
- package/dist/infrastructure/gateway/circuit-breaker.d.ts.map +1 -0
- package/dist/infrastructure/gateway/circuit-breaker.js +150 -0
- package/dist/infrastructure/gateway/circuit-breaker.js.map +1 -0
- package/dist/infrastructure/gateway/gateway-dispatch.d.ts +138 -0
- package/dist/infrastructure/gateway/gateway-dispatch.d.ts.map +1 -0
- package/dist/infrastructure/gateway/gateway-dispatch.js +308 -0
- package/dist/infrastructure/gateway/gateway-dispatch.js.map +1 -0
- package/dist/infrastructure/hardware/hardware-probe.d.ts +32 -0
- package/dist/infrastructure/hardware/hardware-probe.d.ts.map +1 -0
- package/dist/infrastructure/hardware/hardware-probe.js +199 -0
- package/dist/infrastructure/hardware/hardware-probe.js.map +1 -0
- package/dist/infrastructure/local/local-zero-tier.d.ts +47 -0
- package/dist/infrastructure/local/local-zero-tier.d.ts.map +1 -0
- package/dist/infrastructure/local/local-zero-tier.js +92 -0
- package/dist/infrastructure/local/local-zero-tier.js.map +1 -0
- package/dist/infrastructure/persistence/memory-store.d.ts +31 -0
- package/dist/infrastructure/persistence/memory-store.d.ts.map +1 -0
- package/dist/infrastructure/persistence/memory-store.js +87 -0
- package/dist/infrastructure/persistence/memory-store.js.map +1 -0
- package/dist/infrastructure/persistence/sqlite-store.d.ts +81 -0
- package/dist/infrastructure/persistence/sqlite-store.d.ts.map +1 -0
- package/dist/infrastructure/persistence/sqlite-store.js +658 -0
- package/dist/infrastructure/persistence/sqlite-store.js.map +1 -0
- package/dist/infrastructure/pricing/litellm-fetch.d.ts +46 -0
- package/dist/infrastructure/pricing/litellm-fetch.d.ts.map +1 -0
- package/dist/infrastructure/pricing/litellm-fetch.js +145 -0
- package/dist/infrastructure/pricing/litellm-fetch.js.map +1 -0
- package/dist/infrastructure/pricing/price-broker.d.ts +56 -0
- package/dist/infrastructure/pricing/price-broker.d.ts.map +1 -0
- package/dist/infrastructure/pricing/price-broker.js +133 -0
- package/dist/infrastructure/pricing/price-broker.js.map +1 -0
- package/dist/infrastructure/pricing/pricing-monitor.d.ts +27 -0
- package/dist/infrastructure/pricing/pricing-monitor.d.ts.map +1 -0
- package/dist/infrastructure/pricing/pricing-monitor.js +46 -0
- package/dist/infrastructure/pricing/pricing-monitor.js.map +1 -0
- package/dist/infrastructure/telemetry/dataset-limits.d.ts +13 -0
- package/dist/infrastructure/telemetry/dataset-limits.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/dataset-limits.js +28 -0
- package/dist/infrastructure/telemetry/dataset-limits.js.map +1 -0
- package/dist/infrastructure/telemetry/dataset-recorder.d.ts +48 -0
- package/dist/infrastructure/telemetry/dataset-recorder.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/dataset-recorder.js +154 -0
- package/dist/infrastructure/telemetry/dataset-recorder.js.map +1 -0
- package/dist/infrastructure/telemetry/outcome-limits.d.ts +12 -0
- package/dist/infrastructure/telemetry/outcome-limits.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/outcome-limits.js +28 -0
- package/dist/infrastructure/telemetry/outcome-limits.js.map +1 -0
- package/dist/infrastructure/telemetry/outcome-recorder.d.ts +29 -0
- package/dist/infrastructure/telemetry/outcome-recorder.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/outcome-recorder.js +49 -0
- package/dist/infrastructure/telemetry/outcome-recorder.js.map +1 -0
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts +115 -0
- package/dist/infrastructure/telemetry/routing-telemetry.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/routing-telemetry.js +529 -0
- package/dist/infrastructure/telemetry/routing-telemetry.js.map +1 -0
- package/dist/infrastructure/telemetry/telemetry-limits.d.ts +16 -0
- package/dist/infrastructure/telemetry/telemetry-limits.d.ts.map +1 -0
- package/dist/infrastructure/telemetry/telemetry-limits.js +35 -0
- package/dist/infrastructure/telemetry/telemetry-limits.js.map +1 -0
- package/package.json +110 -0
- package/skills/router-backlog-orchestrator/SKILL.md +183 -0
- package/skills/router-backlog-orchestrator/references/github-router-issue-template.md +78 -0
- package/skills/router-backlog-orchestrator/references/packet-from-issue.md +99 -0
- package/skills/router-backlog-orchestrator/references/prioritization-rubric.md +65 -0
- package/skills/router-backlog-orchestrator/scripts/collect-backlog.sh +44 -0
- package/specs/001-build-smart-router/contracts/telemetry-contrib.schema.json +151 -0
- package/src/api/explain/.gitkeep +0 -0
- package/src/api/explain/router-explain.ts +146 -0
- package/src/api/middleware/.gitkeep +0 -0
- package/src/api/middleware/pi-router-middleware.ts +169 -0
- package/src/cli/smart-router-cli.ts +436 -0
- package/src/config/.gitkeep +0 -0
- package/src/config/defaults.ts +35 -0
- package/src/config/models-loader.ts +68 -0
- package/src/config/pi-model-mapper.ts +285 -0
- package/src/config/routing-clusters-loader.ts +148 -0
- package/src/domain/delegation/delegation-context.ts +111 -0
- package/src/domain/delegation/execution-ledger.ts +34 -0
- package/src/domain/delegation/output-headroom.ts +131 -0
- package/src/domain/matching/.gitkeep +0 -0
- package/src/domain/matching/cluster-matcher.ts +474 -0
- package/src/domain/matching/embedding-provider.ts +79 -0
- package/src/domain/matching/hydra-input.ts +53 -0
- package/src/domain/matching/hydra-matcher.ts +454 -0
- package/src/domain/pinning/.gitkeep +0 -0
- package/src/domain/pinning/cache-economics.ts +128 -0
- package/src/domain/pinning/loop-escalation.ts +181 -0
- package/src/domain/pinning/session-pinner.ts +388 -0
- package/src/domain/pinning/sub-route-policy.ts +119 -0
- package/src/domain/pipeline/.gitkeep +0 -0
- package/src/domain/pipeline/router-pipeline.ts +1139 -0
- package/src/domain/pipeline/safe-default.ts +70 -0
- package/src/domain/refactor-guardrails.ts +202 -0
- package/src/domain/routing/context-fit.ts +221 -0
- package/src/domain/routing/expected-cost.ts +320 -0
- package/src/domain/routing/p-success-classifier.ts +511 -0
- package/src/domain/routing/tier-features.ts +290 -0
- package/src/domain/routing/tool-history-guard.ts +159 -0
- package/src/domain/scoring/.gitkeep +0 -0
- package/src/domain/scoring/multi-objective.ts +175 -0
- package/src/domain/triage/.gitkeep +0 -0
- package/src/domain/triage/triage-engine.ts +373 -0
- package/src/domain/triage/turn-envelope.ts +104 -0
- package/src/domain/types/.gitkeep +0 -0
- package/src/domain/types/entities.ts +384 -0
- package/src/domain/types/index.ts +41 -0
- package/src/domain/types/schemas.ts +289 -0
- package/src/domain/types/store-port.ts +59 -0
- package/src/index.ts +103 -0
- package/src/infra/gemini-provider.ts +142 -0
- package/src/infra/telemetry.ts +169 -0
- package/src/infrastructure/delegation/provider-error.ts +251 -0
- package/src/infrastructure/gateway/.gitkeep +0 -0
- package/src/infrastructure/gateway/circuit-breaker.ts +196 -0
- package/src/infrastructure/gateway/gateway-dispatch.ts +444 -0
- package/src/infrastructure/hardware/.gitkeep +0 -0
- package/src/infrastructure/hardware/hardware-probe.ts +276 -0
- package/src/infrastructure/local/.gitkeep +0 -0
- package/src/infrastructure/local/local-zero-tier.ts +151 -0
- package/src/infrastructure/persistence/.gitkeep +0 -0
- package/src/infrastructure/persistence/memory-store.ts +122 -0
- package/src/infrastructure/persistence/sqlite-store.ts +900 -0
- package/src/infrastructure/pricing/.gitkeep +0 -0
- package/src/infrastructure/pricing/litellm-fetch.ts +215 -0
- package/src/infrastructure/pricing/price-broker.ts +183 -0
- package/src/infrastructure/pricing/pricing-monitor.ts +65 -0
- package/src/infrastructure/telemetry/.gitkeep +0 -0
- package/src/infrastructure/telemetry/dataset-limits.ts +39 -0
- package/src/infrastructure/telemetry/dataset-recorder.ts +215 -0
- package/src/infrastructure/telemetry/outcome-limits.ts +42 -0
- package/src/infrastructure/telemetry/outcome-recorder.ts +118 -0
- package/src/infrastructure/telemetry/routing-telemetry.ts +824 -0
- package/src/infrastructure/telemetry/telemetry-limits.ts +50 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privacy-safe routing dataset recorder (SP-058).
|
|
3
|
+
*
|
|
4
|
+
* Maps routing decisions and feature sidecars to RoutingDatasetRecord when
|
|
5
|
+
* SMART_ROUTER_DATASET=1. Never stores prompt text, messages, or tool arguments.
|
|
6
|
+
*
|
|
7
|
+
* Optional install-local prompt fingerprints (SP-061) when
|
|
8
|
+
* SMART_ROUTER_DATASET_FINGERPRINT=1.
|
|
9
|
+
*/
|
|
10
|
+
import { createHmac, randomBytes } from 'node:crypto';
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { dirname, join } from 'node:path';
|
|
13
|
+
import { buildContextFitObservability, buildTierSelectionObservability, } from './routing-telemetry.js';
|
|
14
|
+
export const DATASET_ENABLED_NOTIFY_MESSAGE = 'Smart Router dataset mode is enabled. Recording routing metadata and feature fields only — prompt text, messages, and tool arguments are never stored.';
|
|
15
|
+
export const DATASET_STATE_DIR = '.pi-smart-router';
|
|
16
|
+
export const DATASET_PEPPER_FILENAME = '.dataset-key';
|
|
17
|
+
const DATASET_PEPPER_BYTES = 32;
|
|
18
|
+
export function isDatasetRecordingEnabled() {
|
|
19
|
+
return process.env.SMART_ROUTER_DATASET === '1';
|
|
20
|
+
}
|
|
21
|
+
export function isDatasetFingerprintEnabled() {
|
|
22
|
+
return (isDatasetRecordingEnabled() &&
|
|
23
|
+
process.env.SMART_ROUTER_DATASET_FINGERPRINT === '1');
|
|
24
|
+
}
|
|
25
|
+
export function getDatasetPepperPath(cwd = process.cwd()) {
|
|
26
|
+
return join(cwd, DATASET_STATE_DIR, DATASET_PEPPER_FILENAME);
|
|
27
|
+
}
|
|
28
|
+
/** Load or create the install-local dataset pepper (never exported). */
|
|
29
|
+
export function loadOrCreateDatasetPepper(cwd = process.cwd()) {
|
|
30
|
+
const pepperPath = getDatasetPepperPath(cwd);
|
|
31
|
+
mkdirSync(dirname(pepperPath), { recursive: true });
|
|
32
|
+
if (existsSync(pepperPath)) {
|
|
33
|
+
const raw = readFileSync(pepperPath, 'utf8').trim();
|
|
34
|
+
return Buffer.from(raw, 'hex');
|
|
35
|
+
}
|
|
36
|
+
const pepper = randomBytes(DATASET_PEPPER_BYTES);
|
|
37
|
+
writeFileSync(pepperPath, pepper.toString('hex'), { mode: 0o600 });
|
|
38
|
+
return pepper;
|
|
39
|
+
}
|
|
40
|
+
/** Collapse whitespace and trim for stable duplicate detection. */
|
|
41
|
+
export function normalizePromptForFingerprint(prompt) {
|
|
42
|
+
return prompt.trim().replace(/\s+/g, ' ');
|
|
43
|
+
}
|
|
44
|
+
export function computePromptFingerprint(pepper, prompt) {
|
|
45
|
+
return createHmac('sha256', pepper)
|
|
46
|
+
.update(normalizePromptForFingerprint(prompt))
|
|
47
|
+
.digest('hex');
|
|
48
|
+
}
|
|
49
|
+
function hasToolContext(request) {
|
|
50
|
+
if (request.turn_type === 'tool_result') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return request.messages?.some((message) => message.role === 'tool') ?? false;
|
|
54
|
+
}
|
|
55
|
+
function serializeCandidates(decision) {
|
|
56
|
+
const candidates = decision.features?.candidates ?? decision.candidates;
|
|
57
|
+
if (!candidates || candidates.length === 0) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return JSON.stringify(candidates);
|
|
61
|
+
}
|
|
62
|
+
/** Map a completed routing decision to a privacy-safe dataset row. */
|
|
63
|
+
export function buildDatasetRecord(request, decision, timestamp, promptFingerprint = null, tierScalars, contextFitInput) {
|
|
64
|
+
const triage = decision.features?.triage ?? null;
|
|
65
|
+
const requirements = decision.features?.requirements ?? null;
|
|
66
|
+
const contextFit = buildContextFitObservability({
|
|
67
|
+
request,
|
|
68
|
+
decision,
|
|
69
|
+
...contextFitInput,
|
|
70
|
+
});
|
|
71
|
+
const tierSelection = buildTierSelectionObservability({ decision });
|
|
72
|
+
return {
|
|
73
|
+
request_id: decision.request_id,
|
|
74
|
+
timestamp,
|
|
75
|
+
turn_type: request.turn_type ?? 'unknown',
|
|
76
|
+
stage: decision.stage,
|
|
77
|
+
reason_code: decision.reason_code,
|
|
78
|
+
selected_model_id: decision.selected_model_id,
|
|
79
|
+
tier: decision.tier,
|
|
80
|
+
candidates_json: serializeCandidates(decision),
|
|
81
|
+
prompt_length_chars: request.prompt_text.length,
|
|
82
|
+
estimated_input_tokens: request.estimated_input_tokens ?? null,
|
|
83
|
+
message_count: request.messages?.length ?? 0,
|
|
84
|
+
has_tool_context: hasToolContext(request),
|
|
85
|
+
compaction_flag: request.compaction_flag ?? false,
|
|
86
|
+
triage_verdict: triage?.verdict ?? null,
|
|
87
|
+
triage_reason_code: triage?.reason_code ?? null,
|
|
88
|
+
triage_cyclomatic_score: triage?.cyclomatic_score ?? null,
|
|
89
|
+
triage_trivial_hits: tierScalars?.triage_trivial_hits ?? null,
|
|
90
|
+
triage_complex_hits: tierScalars?.triage_complex_hits ?? null,
|
|
91
|
+
triage_sanitized_length_delta: tierScalars?.triage_sanitized_length_delta ?? null,
|
|
92
|
+
requirement_reasoning: requirements?.reasoning ?? null,
|
|
93
|
+
requirement_code_gen: requirements?.code_gen ?? null,
|
|
94
|
+
requirement_tool_use: requirements?.tool_use ?? null,
|
|
95
|
+
routing_latency_ms: decision.routing_latency_ms,
|
|
96
|
+
estimated_cost_usd: decision.estimated_cost_usd ?? null,
|
|
97
|
+
prompt_fingerprint: promptFingerprint,
|
|
98
|
+
estimated_input_tokens_gate: contextFit?.estimated_input_tokens ?? null,
|
|
99
|
+
context_fit_viable_count: contextFit?.context_fit_viable_count ?? null,
|
|
100
|
+
context_fit_rejected_json: contextFit?.context_fit_rejected_json ?? null,
|
|
101
|
+
context_overflow_pin_break: contextFit?.context_overflow_pin_break ?? false,
|
|
102
|
+
selected_model_max_input_tokens: contextFit?.selected_model_max_input_tokens ?? null,
|
|
103
|
+
context_fit_reason_code: contextFit?.context_fit_reason_code ?? null,
|
|
104
|
+
cluster_id: tierSelection?.cluster_id ?? null,
|
|
105
|
+
cluster_similarity: tierSelection?.cluster_similarity ?? null,
|
|
106
|
+
cluster_margin: tierSelection?.cluster_margin ?? null,
|
|
107
|
+
low_intensity_score: tierSelection?.low_intensity_score ?? null,
|
|
108
|
+
tier_hint: tierSelection?.tier_hint ?? null,
|
|
109
|
+
p_success_cheap: tierSelection?.p_success_cheap ?? null,
|
|
110
|
+
local_eligible_reason: tierSelection?.local_eligible_reason ?? null,
|
|
111
|
+
tier_selection_reason_code: tierSelection?.tier_selection_reason_code ?? null,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export class DatasetRecorder {
|
|
115
|
+
clock;
|
|
116
|
+
onRecord;
|
|
117
|
+
onFirstEnable;
|
|
118
|
+
cwd;
|
|
119
|
+
loadPepper;
|
|
120
|
+
contextFitInput;
|
|
121
|
+
enabledNotified = false;
|
|
122
|
+
pepper = null;
|
|
123
|
+
constructor(options) {
|
|
124
|
+
this.clock = options?.clock ?? (() => new Date().toISOString());
|
|
125
|
+
this.onRecord = options?.onRecord;
|
|
126
|
+
this.onFirstEnable = options?.onFirstEnable;
|
|
127
|
+
this.cwd = options?.cwd ?? process.cwd();
|
|
128
|
+
this.loadPepper = options?.loadPepper ?? loadOrCreateDatasetPepper;
|
|
129
|
+
this.contextFitInput = options?.contextFitInput;
|
|
130
|
+
}
|
|
131
|
+
getPepper() {
|
|
132
|
+
if (!this.pepper) {
|
|
133
|
+
this.pepper = this.loadPepper(this.cwd);
|
|
134
|
+
}
|
|
135
|
+
return this.pepper;
|
|
136
|
+
}
|
|
137
|
+
/** Record a routing decision when dataset mode is enabled; no-op when off. */
|
|
138
|
+
record(request, decision) {
|
|
139
|
+
if (!isDatasetRecordingEnabled()) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (!this.enabledNotified) {
|
|
143
|
+
this.enabledNotified = true;
|
|
144
|
+
this.onFirstEnable?.();
|
|
145
|
+
}
|
|
146
|
+
const promptFingerprint = isDatasetFingerprintEnabled()
|
|
147
|
+
? computePromptFingerprint(this.getPepper(), request.prompt_text)
|
|
148
|
+
: null;
|
|
149
|
+
const record = buildDatasetRecord(request, decision, this.clock(), promptFingerprint, undefined, this.contextFitInput);
|
|
150
|
+
this.onRecord?.(record);
|
|
151
|
+
return record;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=dataset-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset-recorder.js","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/dataset-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EA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C,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared retention bounds for routing outcome labels (in-memory and SQLite).
|
|
3
|
+
* Aligns with dataset retention (30 days / 10k rows).
|
|
4
|
+
*/
|
|
5
|
+
import type { RoutingOutcomeRecord } from '../../domain/types/index.js';
|
|
6
|
+
export declare const OUTCOME_MAX_ENTRIES = 10000;
|
|
7
|
+
export declare const OUTCOME_WINDOW_MS: number;
|
|
8
|
+
/** Remove outcome entries older than the rolling window. */
|
|
9
|
+
export declare function evictExpiredOutcomeEntries(entries: RoutingOutcomeRecord[], windowMs?: number): void;
|
|
10
|
+
/** Make room for one more outcome entry before append. */
|
|
11
|
+
export declare function makeOutcomeRoom(entries: RoutingOutcomeRecord[], maxEntries?: number, windowMs?: number): void;
|
|
12
|
+
//# sourceMappingURL=outcome-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-limits.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/outcome-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,eAAO,MAAM,mBAAmB,QAAsB,CAAC;AACvD,eAAO,MAAM,iBAAiB,QAAoB,CAAC;AAEnD,4DAA4D;AAC5D,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,oBAAoB,EAAE,EAC/B,QAAQ,GAAE,MAA0B,GACnC,IAAI,CAWN;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAC7B,OAAO,EAAE,oBAAoB,EAAE,EAC/B,UAAU,GAAE,MAA4B,EACxC,QAAQ,GAAE,MAA0B,GACnC,IAAI,CAKN"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared retention bounds for routing outcome labels (in-memory and SQLite).
|
|
3
|
+
* Aligns with dataset retention (30 days / 10k rows).
|
|
4
|
+
*/
|
|
5
|
+
import { DATASET_MAX_ENTRIES, DATASET_WINDOW_MS, } from './dataset-limits.js';
|
|
6
|
+
export const OUTCOME_MAX_ENTRIES = DATASET_MAX_ENTRIES;
|
|
7
|
+
export const OUTCOME_WINDOW_MS = DATASET_WINDOW_MS;
|
|
8
|
+
/** Remove outcome entries older than the rolling window. */
|
|
9
|
+
export function evictExpiredOutcomeEntries(entries, windowMs = OUTCOME_WINDOW_MS) {
|
|
10
|
+
const cutoff = Date.now() - windowMs;
|
|
11
|
+
while (entries.length > 0) {
|
|
12
|
+
const oldest = entries[0];
|
|
13
|
+
if (new Date(oldest.timestamp).getTime() < cutoff) {
|
|
14
|
+
entries.shift();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Make room for one more outcome entry before append. */
|
|
22
|
+
export function makeOutcomeRoom(entries, maxEntries = OUTCOME_MAX_ENTRIES, windowMs = OUTCOME_WINDOW_MS) {
|
|
23
|
+
evictExpiredOutcomeEntries(entries, windowMs);
|
|
24
|
+
while (entries.length >= maxEntries) {
|
|
25
|
+
entries.shift();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=outcome-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-limits.js","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/outcome-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD,4DAA4D;AAC5D,MAAM,UAAU,0BAA0B,CACxC,OAA+B,EAC/B,WAAmB,iBAAiB;IAEpC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IAErC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;QAC3B,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;YAClD,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAC7B,OAA+B,EAC/B,aAAqB,mBAAmB,EACxC,WAAmB,iBAAiB;IAEpC,0BAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACpC,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral outcome label recorder (SP-062).
|
|
3
|
+
*
|
|
4
|
+
* Captures model override, compaction pin break, and user feedback when
|
|
5
|
+
* SMART_ROUTER_DATASET=1. Never stores prompt text.
|
|
6
|
+
*/
|
|
7
|
+
import type { OutcomeSignalType, RoutingOutcomeRecord } from '../../domain/types/index.js';
|
|
8
|
+
export interface OutcomeRecorderOptions {
|
|
9
|
+
readonly clock?: () => string;
|
|
10
|
+
readonly onRecord?: (record: RoutingOutcomeRecord) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionRoutingSnapshot {
|
|
13
|
+
readonly lastRequestId: string;
|
|
14
|
+
readonly lastSelectedModelId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildOutcomeRecord(requestId: string, sessionId: string, signalType: OutcomeSignalType, timestamp: string, options?: {
|
|
17
|
+
readonly routedModelId?: string | null;
|
|
18
|
+
readonly overrideModelId?: string | null;
|
|
19
|
+
}): RoutingOutcomeRecord;
|
|
20
|
+
export declare class OutcomeRecorder {
|
|
21
|
+
private readonly clock;
|
|
22
|
+
private readonly onRecord;
|
|
23
|
+
constructor(options?: OutcomeRecorderOptions);
|
|
24
|
+
private recordIfEnabled;
|
|
25
|
+
recordModelOverride(snapshot: SessionRoutingSnapshot, sessionId: string, overrideModelId: string): RoutingOutcomeRecord | null;
|
|
26
|
+
recordCompactionPinBreak(snapshot: SessionRoutingSnapshot, sessionId: string): RoutingOutcomeRecord | null;
|
|
27
|
+
recordFeedback(snapshot: SessionRoutingSnapshot, sessionId: string, rating: 'good' | 'bad'): RoutingOutcomeRecord | null;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=outcome-recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-recorder.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/outcome-recorder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,GACA,oBAAoB,CAStB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuD;gBAEpE,OAAO,CAAC,EAAE,sBAAsB;IAK5C,OAAO,CAAC,eAAe;IASvB,mBAAmB,CACjB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,oBAAoB,GAAG,IAAI;IAmB9B,wBAAwB,CACtB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,GAChB,oBAAoB,GAAG,IAAI;IAY9B,cAAc,CACZ,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,KAAK,GACrB,oBAAoB,GAAG,IAAI;CAc/B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral outcome label recorder (SP-062).
|
|
3
|
+
*
|
|
4
|
+
* Captures model override, compaction pin break, and user feedback when
|
|
5
|
+
* SMART_ROUTER_DATASET=1. Never stores prompt text.
|
|
6
|
+
*/
|
|
7
|
+
import { isDatasetRecordingEnabled } from './dataset-recorder.js';
|
|
8
|
+
export function buildOutcomeRecord(requestId, sessionId, signalType, timestamp, options) {
|
|
9
|
+
return {
|
|
10
|
+
request_id: requestId,
|
|
11
|
+
session_id: sessionId,
|
|
12
|
+
timestamp,
|
|
13
|
+
signal_type: signalType,
|
|
14
|
+
routed_model_id: options?.routedModelId ?? null,
|
|
15
|
+
override_model_id: options?.overrideModelId ?? null,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export class OutcomeRecorder {
|
|
19
|
+
clock;
|
|
20
|
+
onRecord;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.clock = options?.clock ?? (() => new Date().toISOString());
|
|
23
|
+
this.onRecord = options?.onRecord;
|
|
24
|
+
}
|
|
25
|
+
recordIfEnabled(record) {
|
|
26
|
+
if (!isDatasetRecordingEnabled()) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
this.onRecord?.(record);
|
|
30
|
+
return record;
|
|
31
|
+
}
|
|
32
|
+
recordModelOverride(snapshot, sessionId, overrideModelId) {
|
|
33
|
+
if (overrideModelId === snapshot.lastSelectedModelId) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return this.recordIfEnabled(buildOutcomeRecord(snapshot.lastRequestId, sessionId, 'model_override', this.clock(), {
|
|
37
|
+
routedModelId: snapshot.lastSelectedModelId,
|
|
38
|
+
overrideModelId,
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
recordCompactionPinBreak(snapshot, sessionId) {
|
|
42
|
+
return this.recordIfEnabled(buildOutcomeRecord(snapshot.lastRequestId, sessionId, 'compaction_pin_break', this.clock(), { routedModelId: snapshot.lastSelectedModelId }));
|
|
43
|
+
}
|
|
44
|
+
recordFeedback(snapshot, sessionId, rating) {
|
|
45
|
+
const signalType = rating === 'good' ? 'feedback_good' : 'feedback_bad';
|
|
46
|
+
return this.recordIfEnabled(buildOutcomeRecord(snapshot.lastRequestId, sessionId, signalType, this.clock(), { routedModelId: snapshot.lastSelectedModelId }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=outcome-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-recorder.js","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/outcome-recorder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAYlE,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,SAAiB,EACjB,UAA6B,EAC7B,SAAiB,EACjB,OAGC;IAED,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,UAAU,EAA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AC;IACJ,CAAC;IAED,cAAc,CACZ,QAAgC,EAChC,SAAiB,EACjB,MAAsB;QAEtB,MAAM,UAAU,GACd,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC;QAEvD,OAAO,IAAI,CAAC,eAAe,CACzB,kBAAkB,CAChB,QAAQ,CAAC,aAAa,EACtB,SAAS,EACT,UAAU,EACV,IAAI,CAAC,KAAK,EAAE,EACZ,EAAE,aAAa,EAAE,QAAQ,CAAC,mBAAmB,EAAE,CAChD,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing telemetry emitter — T039.
|
|
3
|
+
*
|
|
4
|
+
* Maintains an append-only rolling window of routing decisions for
|
|
5
|
+
* observability and audit. Window bounds: 168 hours (7 days), max 1111 entries.
|
|
6
|
+
*/
|
|
7
|
+
import { type ContextFitConfig } from '../../domain/routing/context-fit.js';
|
|
8
|
+
import type { ClusterMatcher } from '../../domain/matching/cluster-matcher.js';
|
|
9
|
+
import type { ClusterMatchTableEntry, ContextFitObservability, ModelProfile, PriceCatalog, RoutingDecision, RoutingRequest, RoutingTelemetry, TierSelectionObservability } from '../../domain/types/index.js';
|
|
10
|
+
export declare const CONTEXT_FIT_PASS: "context_fit_pass";
|
|
11
|
+
export declare const CONTEXT_FIT_REJECTED_ALL: "context_fit_rejected_all";
|
|
12
|
+
export declare const CONTEXT_OVERFLOW_PIN_BREAK: "context_overflow_pin_break";
|
|
13
|
+
export declare const LOW_INTENSITY_STRUCTURAL: "low_intensity_structural";
|
|
14
|
+
export declare const HIGH_INTENSITY_STRUCTURAL: "high_intensity_structural";
|
|
15
|
+
export declare const P_SUCCESS_CHEAP: "p_success_cheap";
|
|
16
|
+
export declare const P_SUCCESS_UNCERTAIN: "p_success_uncertain";
|
|
17
|
+
/**
|
|
18
|
+
* Estimate per-request routing cost in USD from resolved model pricing (SP-085).
|
|
19
|
+
* Uses estimated_input_tokens when present, otherwise prompt_text length as a token proxy.
|
|
20
|
+
*/
|
|
21
|
+
export declare function estimateRoutingCost(model: ModelProfile, request: RoutingRequest, catalog: PriceCatalog | null): number;
|
|
22
|
+
export { DEFAULT_HISTORY_LIMIT, MAX_HISTORY_LIMIT, TELEMETRY_MAX_ENTRIES, TELEMETRY_WINDOW_HOURS, TELEMETRY_WINDOW_MS, } from './telemetry-limits.js';
|
|
23
|
+
export interface TelemetryEmitterOptions {
|
|
24
|
+
readonly maxEntries?: number;
|
|
25
|
+
readonly windowMs?: number;
|
|
26
|
+
readonly clock?: () => string;
|
|
27
|
+
readonly onRecord?: (record: RoutingTelemetry) => void;
|
|
28
|
+
readonly fleet?: readonly ModelProfile[];
|
|
29
|
+
readonly contextFitConfig?: ContextFitConfig;
|
|
30
|
+
}
|
|
31
|
+
export interface ContextFitObservabilityInput {
|
|
32
|
+
readonly request: RoutingRequest;
|
|
33
|
+
readonly decision: RoutingDecision;
|
|
34
|
+
readonly fleet?: readonly ModelProfile[] | undefined;
|
|
35
|
+
readonly contextFitConfig?: ContextFitConfig | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Build privacy-safe context-fit observability from a routing decision (SP-110). */
|
|
38
|
+
export declare function buildContextFitObservability(input: ContextFitObservabilityInput): ContextFitObservability | null;
|
|
39
|
+
/** Normalize tier-selection reason codes for telemetry and explain (SP-113). */
|
|
40
|
+
export declare function resolveTierSelectionReasonCode(features: RoutingDecision['features']): string | null;
|
|
41
|
+
/** Infer why local_zero did not dispatch when another stage won (SP-113). */
|
|
42
|
+
export declare function buildLocalZeroSkipReasons(decision: RoutingDecision, features: RoutingDecision['features']): readonly string[];
|
|
43
|
+
export interface TierSelectionObservabilityInput {
|
|
44
|
+
readonly decision: RoutingDecision;
|
|
45
|
+
readonly clusterMatchTable?: readonly ClusterMatchTableEntry[] | null;
|
|
46
|
+
}
|
|
47
|
+
/** Build privacy-safe tier/cluster observability from routing decision features (SP-113). */
|
|
48
|
+
export declare function buildTierSelectionObservability(input: TierSelectionObservabilityInput): TierSelectionObservability | null;
|
|
49
|
+
/** Attach tier-selection observability to a routing decision features sidecar (SP-113). */
|
|
50
|
+
export declare function enrichRoutingDecisionWithTierSelection(decision: RoutingDecision, clusterMatchTable?: readonly ClusterMatchTableEntry[] | null): RoutingDecision;
|
|
51
|
+
export interface ExplainEnrichmentOptions {
|
|
52
|
+
readonly fleet?: readonly ModelProfile[];
|
|
53
|
+
readonly contextFitConfig?: ContextFitConfig;
|
|
54
|
+
readonly clusterMatcher?: ClusterMatcher;
|
|
55
|
+
}
|
|
56
|
+
/** Attach context-fit and tier-selection observability for explain responses (SP-110, SP-113). */
|
|
57
|
+
export declare function enrichRoutingDecisionForExplain(request: RoutingRequest, decision: RoutingDecision, options?: ExplainEnrichmentOptions): Promise<RoutingDecision>;
|
|
58
|
+
/** Attach context-fit observability to a routing decision features sidecar (SP-110). */
|
|
59
|
+
export declare function enrichRoutingDecisionWithContextFit(request: RoutingRequest, decision: RoutingDecision, fleet?: readonly ModelProfile[], contextFitConfig?: ContextFitConfig): RoutingDecision;
|
|
60
|
+
export interface RoutingDecisionLogDelegate {
|
|
61
|
+
readonly provider: string;
|
|
62
|
+
readonly modelId: string;
|
|
63
|
+
readonly api: string;
|
|
64
|
+
}
|
|
65
|
+
/** JSON payload for SMART_ROUTER_LOG_ROUTING=1 stderr lines (SP-110). */
|
|
66
|
+
export declare function buildRoutingDecisionLogPayload(request: RoutingRequest, decision: RoutingDecision, delegate?: RoutingDecisionLogDelegate, fleet?: readonly ModelProfile[], contextFitConfig?: ContextFitConfig): Record<string, unknown>;
|
|
67
|
+
/** Default context-fit telemetry scalars for tests and legacy store reads. */
|
|
68
|
+
export declare const DEFAULT_CONTEXT_FIT_TELEMETRY_FIELDS: Pick<RoutingTelemetry, "estimated_input_tokens" | "context_overflow_pin_break" | "context_fit_viable_count" | "context_fit_rejected_json" | "selected_model_max_input_tokens" | "context_fit_reason_code">;
|
|
69
|
+
/** Default tier-selection telemetry scalars for tests and legacy store reads. */
|
|
70
|
+
export declare const DEFAULT_TIER_SELECTION_TELEMETRY_FIELDS: Pick<RoutingTelemetry, "cluster_id" | "p_success_cheap" | "tier_hint" | "local_eligible_reason" | "cluster_similarity" | "cluster_margin" | "low_intensity_score" | "tier_selection_reason_code">;
|
|
71
|
+
/** Default context-fit dataset scalars for tests and legacy store reads. */
|
|
72
|
+
export declare const DEFAULT_CONTEXT_FIT_DATASET_FIELDS: {
|
|
73
|
+
readonly estimated_input_tokens_gate: null;
|
|
74
|
+
readonly context_fit_viable_count: null;
|
|
75
|
+
readonly context_fit_rejected_json: null;
|
|
76
|
+
readonly context_overflow_pin_break: false;
|
|
77
|
+
readonly selected_model_max_input_tokens: null;
|
|
78
|
+
readonly context_fit_reason_code: null;
|
|
79
|
+
};
|
|
80
|
+
/** Default tier-selection dataset scalars for tests and legacy store reads. */
|
|
81
|
+
export declare const DEFAULT_TIER_SELECTION_DATASET_FIELDS: {
|
|
82
|
+
readonly cluster_id: null;
|
|
83
|
+
readonly cluster_similarity: null;
|
|
84
|
+
readonly cluster_margin: null;
|
|
85
|
+
readonly low_intensity_score: null;
|
|
86
|
+
readonly tier_hint: null;
|
|
87
|
+
readonly p_success_cheap: null;
|
|
88
|
+
readonly local_eligible_reason: null;
|
|
89
|
+
readonly tier_selection_reason_code: null;
|
|
90
|
+
};
|
|
91
|
+
export declare class RoutingTelemetryEmitter {
|
|
92
|
+
private readonly entries;
|
|
93
|
+
private readonly maxEntries;
|
|
94
|
+
private readonly windowMs;
|
|
95
|
+
private readonly clock;
|
|
96
|
+
private readonly onRecord;
|
|
97
|
+
private readonly fleet;
|
|
98
|
+
private readonly contextFitConfig;
|
|
99
|
+
constructor(options?: TelemetryEmitterOptions);
|
|
100
|
+
/**
|
|
101
|
+
* Emit a telemetry record from a completed routing decision.
|
|
102
|
+
* Enforces the rolling window (time + count) before appending.
|
|
103
|
+
*/
|
|
104
|
+
emit(request: RoutingRequest, decision: RoutingDecision): RoutingTelemetry;
|
|
105
|
+
/**
|
|
106
|
+
* Emit telemetry when a pipeline stage throws and routing degrades to safe default.
|
|
107
|
+
*/
|
|
108
|
+
emitPipelineError(request: RoutingRequest, failedStage: string, fallback: RoutingDecision): RoutingTelemetry;
|
|
109
|
+
private appendRecord;
|
|
110
|
+
/** Current number of retained entries. */
|
|
111
|
+
get size(): number;
|
|
112
|
+
/** Snapshot of all retained entries (newest last). */
|
|
113
|
+
snapshot(): readonly RoutingTelemetry[];
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=routing-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing-telemetry.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/telemetry/routing-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAOL,KAAK,gBAAgB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EAGvB,YAAY,EACZ,YAAY,EAEZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAEhB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AASrC,eAAO,MAAM,gBAAgB,EAAG,kBAA2B,CAAC;AAC5D,eAAO,MAAM,wBAAwB,EAAG,0BAAmC,CAAC;AAC5E,eAAO,MAAM,0BAA0B,EAAG,4BAAqC,CAAC;AAEhF,eAAO,MAAM,wBAAwB,EAAG,0BAAmC,CAAC;AAC5E,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAC9E,eAAO,MAAM,eAAe,EAAG,iBAA0B,CAAC;AAC1D,eAAO,MAAM,mBAAmB,EAAG,qBAA8B,CAAC;AAclE;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,YAAY,GAAG,IAA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