modelrig 0.0.1 → 0.2.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/CHANGELOG.md +94 -0
- package/LICENSE +201 -0
- package/README.md +145 -8
- package/data/PROVENANCE.md +19 -0
- package/data/pricing-manual.json +22 -0
- package/data/pricing-map.json +46362 -0
- package/data/pricing-overlay.json +419 -0
- package/dist/adapters/anthropic.d.ts +90 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/anthropic.js +296 -0
- package/dist/adapters/build-adapters.d.ts +11 -0
- package/dist/adapters/build-adapters.d.ts.map +1 -0
- package/dist/adapters/build-adapters.js +45 -0
- package/dist/adapters/deepseek.d.ts +47 -0
- package/dist/adapters/deepseek.d.ts.map +1 -0
- package/dist/adapters/deepseek.js +216 -0
- package/dist/adapters/gemini.d.ts +44 -0
- package/dist/adapters/gemini.d.ts.map +1 -0
- package/dist/adapters/gemini.js +262 -0
- package/dist/adapters/grok.d.ts +53 -0
- package/dist/adapters/grok.d.ts.map +1 -0
- package/dist/adapters/grok.js +232 -0
- package/dist/adapters/openai-compat.d.ts +80 -0
- package/dist/adapters/openai-compat.d.ts.map +1 -0
- package/dist/adapters/openai-compat.js +244 -0
- package/dist/adapters/openai-stream.d.ts +58 -0
- package/dist/adapters/openai-stream.d.ts.map +1 -0
- package/dist/adapters/openai-stream.js +120 -0
- package/dist/adapters/openai.d.ts +55 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +281 -0
- package/dist/adapters/sampling.d.ts +28 -0
- package/dist/adapters/sampling.d.ts.map +1 -0
- package/dist/adapters/sampling.js +34 -0
- package/dist/adapters/tool-mapping.d.ts +92 -0
- package/dist/adapters/tool-mapping.d.ts.map +1 -0
- package/dist/adapters/tool-mapping.js +143 -0
- package/dist/artifacts/artifact.d.ts +137 -0
- package/dist/artifacts/artifact.d.ts.map +1 -0
- package/dist/artifacts/artifact.js +377 -0
- package/dist/artifacts/content-uploader.d.ts +87 -0
- package/dist/artifacts/content-uploader.d.ts.map +1 -0
- package/dist/artifacts/content-uploader.js +124 -0
- package/dist/artifacts/index.d.ts +63 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +80 -0
- package/dist/artifacts/run-context.d.ts +129 -0
- package/dist/artifacts/run-context.d.ts.map +1 -0
- package/dist/artifacts/run-context.js +208 -0
- package/dist/artifacts/scrub.d.ts +60 -0
- package/dist/artifacts/scrub.d.ts.map +1 -0
- package/dist/artifacts/scrub.js +139 -0
- package/dist/artifacts/step.d.ts +26 -0
- package/dist/artifacts/step.d.ts.map +1 -0
- package/dist/artifacts/step.js +37 -0
- package/dist/artifacts/taint.d.ts +63 -0
- package/dist/artifacts/taint.d.ts.map +1 -0
- package/dist/artifacts/taint.js +76 -0
- package/dist/bakeoff/cache-sim.d.ts +99 -0
- package/dist/bakeoff/cache-sim.d.ts.map +1 -0
- package/dist/bakeoff/cache-sim.js +126 -0
- package/dist/bakeoff/engine.d.ts +52 -0
- package/dist/bakeoff/engine.d.ts.map +1 -0
- package/dist/bakeoff/engine.js +163 -0
- package/dist/bakeoff/eval-cases.d.ts +96 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -0
- package/dist/bakeoff/eval-cases.js +105 -0
- package/dist/bakeoff/replay.d.ts +52 -0
- package/dist/bakeoff/replay.d.ts.map +1 -0
- package/dist/bakeoff/replay.js +94 -0
- package/dist/bakeoff/report.d.ts +41 -0
- package/dist/bakeoff/report.d.ts.map +1 -0
- package/dist/bakeoff/report.js +142 -0
- package/dist/bakeoff/samples.d.ts +77 -0
- package/dist/bakeoff/samples.d.ts.map +1 -0
- package/dist/bakeoff/samples.js +148 -0
- package/dist/bakeoff/stats.d.ts +13 -0
- package/dist/bakeoff/stats.d.ts.map +1 -0
- package/dist/bakeoff/stats.js +48 -0
- package/dist/bakeoff/types.d.ts +37 -0
- package/dist/bakeoff/types.d.ts.map +1 -0
- package/dist/bakeoff/types.js +10 -0
- package/dist/cli.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +590 -0
- package/dist/config.d.ts +204 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +252 -0
- package/dist/deprecations.d.ts +32 -0
- package/dist/deprecations.d.ts.map +1 -0
- package/dist/deprecations.js +59 -0
- package/dist/feedback/coverage.d.ts +32 -0
- package/dist/feedback/coverage.d.ts.map +1 -0
- package/dist/feedback/coverage.js +95 -0
- package/dist/feedback/feedback.d.ts +35 -0
- package/dist/feedback/feedback.d.ts.map +1 -0
- package/dist/feedback/feedback.js +39 -0
- package/dist/gateway/http-protocol.d.ts +175 -0
- package/dist/gateway/http-protocol.d.ts.map +1 -0
- package/dist/gateway/http-protocol.js +105 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +576 -0
- package/dist/init/finder.d.ts +94 -0
- package/dist/init/finder.d.ts.map +1 -0
- package/dist/init/finder.js +343 -0
- package/dist/init/init-cli.d.ts +10 -0
- package/dist/init/init-cli.d.ts.map +1 -0
- package/dist/init/init-cli.js +86 -0
- package/dist/init/observe-cli.d.ts +19 -0
- package/dist/init/observe-cli.d.ts.map +1 -0
- package/dist/init/observe-cli.js +73 -0
- package/dist/init/observe.d.ts +81 -0
- package/dist/init/observe.d.ts.map +1 -0
- package/dist/init/observe.js +245 -0
- package/dist/init/run.d.ts +99 -0
- package/dist/init/run.d.ts.map +1 -0
- package/dist/init/run.js +281 -0
- package/dist/init/signatures.d.ts +39 -0
- package/dist/init/signatures.d.ts.map +1 -0
- package/dist/init/signatures.js +116 -0
- package/dist/matrix/aggregate.d.ts +89 -0
- package/dist/matrix/aggregate.d.ts.map +1 -0
- package/dist/matrix/aggregate.js +186 -0
- package/dist/query/grammar.d.ts +35 -0
- package/dist/query/grammar.d.ts.map +1 -0
- package/dist/query/grammar.js +279 -0
- package/dist/query/run.d.ts +8 -0
- package/dist/query/run.d.ts.map +1 -0
- package/dist/query/run.js +21 -0
- package/dist/registry/build.d.ts +219 -0
- package/dist/registry/build.d.ts.map +1 -0
- package/dist/registry/build.js +313 -0
- package/dist/registry/cache-policy.d.ts +94 -0
- package/dist/registry/cache-policy.d.ts.map +1 -0
- package/dist/registry/cache-policy.js +238 -0
- package/dist/registry/call-notes.d.ts +11 -0
- package/dist/registry/call-notes.d.ts.map +1 -0
- package/dist/registry/call-notes.js +110 -0
- package/dist/registry/claims.d.ts +63 -0
- package/dist/registry/claims.d.ts.map +1 -0
- package/dist/registry/claims.js +107 -0
- package/dist/registry/effective-rate.d.ts +151 -0
- package/dist/registry/effective-rate.d.ts.map +1 -0
- package/dist/registry/effective-rate.js +156 -0
- package/dist/registry/facts.d.ts +32 -0
- package/dist/registry/facts.d.ts.map +1 -0
- package/dist/registry/facts.js +136 -0
- package/dist/registry/fingerprint.d.ts +20 -0
- package/dist/registry/fingerprint.d.ts.map +1 -0
- package/dist/registry/fingerprint.js +150 -0
- package/dist/registry/parity.d.ts +52 -0
- package/dist/registry/parity.d.ts.map +1 -0
- package/dist/registry/parity.js +82 -0
- package/dist/registry/pricing-shape.d.ts +113 -0
- package/dist/registry/pricing-shape.d.ts.map +1 -0
- package/dist/registry/pricing-shape.js +123 -0
- package/dist/registry/pricing.d.ts +43 -0
- package/dist/registry/pricing.d.ts.map +1 -0
- package/dist/registry/pricing.js +127 -0
- package/dist/registry/rows.d.ts +16 -0
- package/dist/registry/rows.d.ts.map +1 -0
- package/dist/registry/rows.js +57 -0
- package/dist/registry/seed.d.ts +43 -0
- package/dist/registry/seed.d.ts.map +1 -0
- package/dist/registry/seed.js +97 -0
- package/dist/registry/select.d.ts +68 -0
- package/dist/registry/select.d.ts.map +1 -0
- package/dist/registry/select.js +141 -0
- package/dist/registry/staleness.d.ts +18 -0
- package/dist/registry/staleness.d.ts.map +1 -0
- package/dist/registry/staleness.js +39 -0
- package/dist/rigindex/bootstrap.d.ts +36 -0
- package/dist/rigindex/bootstrap.d.ts.map +1 -0
- package/dist/rigindex/bootstrap.js +97 -0
- package/dist/rigindex/fit.d.ts +24 -0
- package/dist/rigindex/fit.d.ts.map +1 -0
- package/dist/rigindex/fit.js +76 -0
- package/dist/rigindex/gates.d.ts +52 -0
- package/dist/rigindex/gates.d.ts.map +1 -0
- package/dist/rigindex/gates.js +109 -0
- package/dist/rigindex/graph.d.ts +31 -0
- package/dist/rigindex/graph.d.ts.map +1 -0
- package/dist/rigindex/graph.js +120 -0
- package/dist/rigindex/index.d.ts +23 -0
- package/dist/rigindex/index.d.ts.map +1 -0
- package/dist/rigindex/index.js +112 -0
- package/dist/rigindex/types.d.ts +76 -0
- package/dist/rigindex/types.d.ts.map +1 -0
- package/dist/rigindex/types.js +8 -0
- package/dist/routes/cache-lint.d.ts +41 -0
- package/dist/routes/cache-lint.d.ts.map +1 -0
- package/dist/routes/cache-lint.js +81 -0
- package/dist/routes/draft.d.ts +83 -0
- package/dist/routes/draft.d.ts.map +1 -0
- package/dist/routes/draft.js +135 -0
- package/dist/routes/loader.d.ts +63 -0
- package/dist/routes/loader.d.ts.map +1 -0
- package/dist/routes/loader.js +574 -0
- package/dist/routes/manifest.d.ts +24 -0
- package/dist/routes/manifest.d.ts.map +1 -0
- package/dist/routes/manifest.js +118 -0
- package/dist/routes/resolved-bundle.d.ts +79 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -0
- package/dist/routes/resolved-bundle.js +148 -0
- package/dist/routes/sampling-config.d.ts +32 -0
- package/dist/routes/sampling-config.d.ts.map +1 -0
- package/dist/routes/sampling-config.js +91 -0
- package/dist/routes/serveability.d.ts +52 -0
- package/dist/routes/serveability.d.ts.map +1 -0
- package/dist/routes/serveability.js +73 -0
- package/dist/routes/template.d.ts +18 -0
- package/dist/routes/template.d.ts.map +1 -0
- package/dist/routes/template.js +94 -0
- package/dist/run/ajv.d.ts +22 -0
- package/dist/run/ajv.d.ts.map +1 -0
- package/dist/run/ajv.js +32 -0
- package/dist/run/cache-handle.d.ts +58 -0
- package/dist/run/cache-handle.d.ts.map +1 -0
- package/dist/run/cache-handle.js +54 -0
- package/dist/run/cache-stamp.d.ts +65 -0
- package/dist/run/cache-stamp.d.ts.map +1 -0
- package/dist/run/cache-stamp.js +0 -0
- package/dist/run/capture-write.d.ts +33 -0
- package/dist/run/capture-write.d.ts.map +1 -0
- package/dist/run/capture-write.js +55 -0
- package/dist/run/cost.d.ts +26 -0
- package/dist/run/cost.d.ts.map +1 -0
- package/dist/run/cost.js +41 -0
- package/dist/run/dispatch.d.ts +99 -0
- package/dist/run/dispatch.d.ts.map +1 -0
- package/dist/run/dispatch.js +191 -0
- package/dist/run/envelope.d.ts +21 -0
- package/dist/run/envelope.d.ts.map +1 -0
- package/dist/run/envelope.js +45 -0
- package/dist/run/grounding.d.ts +56 -0
- package/dist/run/grounding.d.ts.map +1 -0
- package/dist/run/grounding.js +89 -0
- package/dist/run/raw.d.ts +88 -0
- package/dist/run/raw.d.ts.map +1 -0
- package/dist/run/raw.js +286 -0
- package/dist/run/record-attempt.d.ts +40 -0
- package/dist/run/record-attempt.d.ts.map +1 -0
- package/dist/run/record-attempt.js +99 -0
- package/dist/run/repair.d.ts +36 -0
- package/dist/run/repair.d.ts.map +1 -0
- package/dist/run/repair.js +61 -0
- package/dist/run/resolve.d.ts +99 -0
- package/dist/run/resolve.d.ts.map +1 -0
- package/dist/run/resolve.js +203 -0
- package/dist/run/retry.d.ts +19 -0
- package/dist/run/retry.d.ts.map +1 -0
- package/dist/run/retry.js +50 -0
- package/dist/run/run.d.ts +55 -0
- package/dist/run/run.d.ts.map +1 -0
- package/dist/run/run.js +540 -0
- package/dist/run/stream.d.ts +49 -0
- package/dist/run/stream.d.ts.map +1 -0
- package/dist/run/stream.js +87 -0
- package/dist/run/validate.d.ts +15 -0
- package/dist/run/validate.d.ts.map +1 -0
- package/dist/run/validate.js +55 -0
- package/dist/savings/cache-ledger.d.ts +108 -0
- package/dist/savings/cache-ledger.d.ts.map +1 -0
- package/dist/savings/cache-ledger.js +174 -0
- package/dist/savings/cache-reconcile.d.ts +64 -0
- package/dist/savings/cache-reconcile.d.ts.map +1 -0
- package/dist/savings/cache-reconcile.js +59 -0
- package/dist/savings/cache-stats.d.ts +63 -0
- package/dist/savings/cache-stats.d.ts.map +1 -0
- package/dist/savings/cache-stats.js +108 -0
- package/dist/savings/emit.d.ts +38 -0
- package/dist/savings/emit.d.ts.map +1 -0
- package/dist/savings/emit.js +100 -0
- package/dist/savings/odometer.d.ts +32 -0
- package/dist/savings/odometer.d.ts.map +1 -0
- package/dist/savings/odometer.js +70 -0
- package/dist/savings/swap-execute.d.ts +58 -0
- package/dist/savings/swap-execute.d.ts.map +1 -0
- package/dist/savings/swap-execute.js +130 -0
- package/dist/savings/swaps-client.d.ts +55 -0
- package/dist/savings/swaps-client.d.ts.map +1 -0
- package/dist/savings/swaps-client.js +95 -0
- package/dist/settings/api-fetcher.d.ts +39 -0
- package/dist/settings/api-fetcher.d.ts.map +1 -0
- package/dist/settings/api-fetcher.js +92 -0
- package/dist/settings/index.d.ts +10 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +15 -0
- package/dist/settings/task-settings.d.ts +91 -0
- package/dist/settings/task-settings.d.ts.map +1 -0
- package/dist/settings/task-settings.js +116 -0
- package/dist/status.d.ts +77 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +113 -0
- package/dist/telemetry/artifact-store.d.ts +48 -0
- package/dist/telemetry/artifact-store.d.ts.map +1 -0
- package/dist/telemetry/artifact-store.js +189 -0
- package/dist/telemetry/cache-miss-streak.d.ts +79 -0
- package/dist/telemetry/cache-miss-streak.d.ts.map +1 -0
- package/dist/telemetry/cache-miss-streak.js +99 -0
- package/dist/telemetry/capture.d.ts +31 -0
- package/dist/telemetry/capture.d.ts.map +1 -0
- package/dist/telemetry/capture.js +81 -0
- package/dist/telemetry/exporter-setup.d.ts +28 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -0
- package/dist/telemetry/exporter-setup.js +34 -0
- package/dist/telemetry/exporter.d.ts +137 -0
- package/dist/telemetry/exporter.d.ts.map +1 -0
- package/dist/telemetry/exporter.js +510 -0
- package/dist/telemetry/health.d.ts +76 -0
- package/dist/telemetry/health.d.ts.map +1 -0
- package/dist/telemetry/health.js +92 -0
- package/dist/telemetry/ingest-protocol.d.ts +310 -0
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -0
- package/dist/telemetry/ingest-protocol.js +363 -0
- package/dist/telemetry/load-error-report.d.ts +24 -0
- package/dist/telemetry/load-error-report.d.ts.map +1 -0
- package/dist/telemetry/load-error-report.js +50 -0
- package/dist/telemetry/otel-map.d.ts +121 -0
- package/dist/telemetry/otel-map.d.ts.map +1 -0
- package/dist/telemetry/otel-map.js +224 -0
- package/dist/telemetry/otel-normalize.d.ts +104 -0
- package/dist/telemetry/otel-normalize.d.ts.map +1 -0
- package/dist/telemetry/otel-normalize.js +530 -0
- package/dist/telemetry/otlp-emitter.d.ts +52 -0
- package/dist/telemetry/otlp-emitter.d.ts.map +1 -0
- package/dist/telemetry/otlp-emitter.js +144 -0
- package/dist/telemetry/otlp-proto.d.ts +29 -0
- package/dist/telemetry/otlp-proto.d.ts.map +1 -0
- package/dist/telemetry/otlp-proto.js +266 -0
- package/dist/telemetry/sinks.d.ts +90 -0
- package/dist/telemetry/sinks.d.ts.map +1 -0
- package/dist/telemetry/sinks.js +180 -0
- package/dist/telemetry/store.d.ts +65 -0
- package/dist/telemetry/store.d.ts.map +1 -0
- package/dist/telemetry/store.js +547 -0
- package/dist/tenancy/api-key-format.d.ts +77 -0
- package/dist/tenancy/api-key-format.d.ts.map +1 -0
- package/dist/tenancy/api-key-format.js +110 -0
- package/dist/tenancy/constants.d.ts +23 -0
- package/dist/tenancy/constants.d.ts.map +1 -0
- package/dist/tenancy/constants.js +25 -0
- package/dist/tenancy/scrub.d.ts +47 -0
- package/dist/tenancy/scrub.d.ts.map +1 -0
- package/dist/tenancy/scrub.js +85 -0
- package/dist/types/config-teaching.d.ts +62 -0
- package/dist/types/config-teaching.d.ts.map +1 -0
- package/dist/types/config-teaching.js +183 -0
- package/dist/types/failures-teaching.d.ts +56 -0
- package/dist/types/failures-teaching.d.ts.map +1 -0
- package/dist/types/failures-teaching.js +177 -0
- package/dist/types/failures.d.ts +27 -0
- package/dist/types/failures.d.ts.map +1 -0
- package/dist/types/failures.js +41 -0
- package/dist/types/provider.d.ts +200 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +40 -0
- package/dist/types/route.d.ts +205 -0
- package/dist/types/route.d.ts.map +1 -0
- package/dist/types/route.js +6 -0
- package/dist/types/telemetry.d.ts +206 -0
- package/dist/types/telemetry.d.ts.map +1 -0
- package/dist/types/telemetry.js +6 -0
- package/dist/validate-cli.d.ts +12 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate-cli.js +57 -0
- package/dist/verify/capture.d.ts +66 -0
- package/dist/verify/capture.d.ts.map +1 -0
- package/dist/verify/capture.js +180 -0
- package/dist/verify/cli-run.d.ts +23 -0
- package/dist/verify/cli-run.d.ts.map +1 -0
- package/dist/verify/cli-run.js +57 -0
- package/dist/verify/diff.d.ts +48 -0
- package/dist/verify/diff.d.ts.map +1 -0
- package/dist/verify/diff.js +157 -0
- package/dist/verify/index.d.ts +17 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +24 -0
- package/dist/verify/report.d.ts +14 -0
- package/dist/verify/report.d.ts.map +1 -0
- package/dist/verify/report.js +88 -0
- package/dist/verify/types.d.ts +101 -0
- package/dist/verify/types.d.ts.map +1 -0
- package/dist/verify/types.js +17 -0
- package/dist/verify/verify.d.ts +29 -0
- package/dist/verify/verify.d.ts.map +1 -0
- package/dist/verify/verify.js +148 -0
- package/dist/watch/budget.d.ts +19 -0
- package/dist/watch/budget.d.ts.map +1 -0
- package/dist/watch/budget.js +35 -0
- package/dist/watch/evaluate.d.ts +225 -0
- package/dist/watch/evaluate.d.ts.map +1 -0
- package/dist/watch/evaluate.js +155 -0
- package/dist/watch/monitor.d.ts +116 -0
- package/dist/watch/monitor.d.ts.map +1 -0
- package/dist/watch/monitor.js +199 -0
- package/dist/watch/proposals.d.ts +89 -0
- package/dist/watch/proposals.d.ts.map +1 -0
- package/dist/watch/proposals.js +197 -0
- package/dist/watch/run-record.d.ts +64 -0
- package/dist/watch/run-record.d.ts.map +1 -0
- package/dist/watch/run-record.js +86 -0
- package/dist/watch/run-reported.d.ts +20 -0
- package/dist/watch/run-reported.d.ts.map +1 -0
- package/dist/watch/run-reported.js +53 -0
- package/dist/watch/run.d.ts +73 -0
- package/dist/watch/run.d.ts.map +1 -0
- package/dist/watch/run.js +83 -0
- package/dist/watch/state-store.d.ts +48 -0
- package/dist/watch/state-store.d.ts.map +1 -0
- package/dist/watch/state-store.js +86 -0
- package/dist/watch/state.d.ts +21 -0
- package/dist/watch/state.d.ts.map +1 -0
- package/dist/watch/state.js +93 -0
- package/package.json +56 -14
- package/registry/LICENSE +20 -0
- package/registry/leaderboard.json +3639 -0
- package/registry/registry.json +7263 -0
- package/index.js +0 -3
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route bundle contract — spec §3. Loaded from modelrig/routes/*.yaml by
|
|
3
|
+
* routes/loader.ts; frozen after load.
|
|
4
|
+
*/
|
|
5
|
+
import type { FailureClass } from "./failures";
|
|
6
|
+
import type { ProviderId, SamplingParams, ServiceTier, ToolCall, ToolChoice, ToolDefinition } from "./provider";
|
|
7
|
+
export interface CandidateSpec {
|
|
8
|
+
readonly provider: ProviderId;
|
|
9
|
+
readonly model: string;
|
|
10
|
+
}
|
|
11
|
+
export type Requirement = "schema_conformant" | "grounded" | "zero_retention" | "trace_visible";
|
|
12
|
+
export type Preference = "cost" | "latency";
|
|
13
|
+
export interface RoutePolicy {
|
|
14
|
+
/** Per-class retry budgets — non-fungible. Missing class => 0 retries. */
|
|
15
|
+
readonly retries: Partial<Record<FailureClass, number>>;
|
|
16
|
+
readonly timeoutMs: number;
|
|
17
|
+
readonly tier: ServiceTier;
|
|
18
|
+
readonly json: "native" | "json_mode";
|
|
19
|
+
/**
|
|
20
|
+
* Declared sampling (CE-6, spec §2) — `temperature`/`top_p`/`max_output_tokens`
|
|
21
|
+
* the original call used, parsed+validated at bundle load (config errors,
|
|
22
|
+
* fail-loud). Optional & additive (S3): ABSENT ⇒ every adapter behaves exactly
|
|
23
|
+
* as pre-CE-6 (gemini keeps its ported constants, the rest send nothing). The
|
|
24
|
+
* block is threaded onto `AdapterRequest.sampling` for the primary AND repair
|
|
25
|
+
* attempts (repair/extractor followups inherit the route's sampling — one knob
|
|
26
|
+
* per route, not per rung). */
|
|
27
|
+
readonly sampling?: SamplingParams;
|
|
28
|
+
}
|
|
29
|
+
/** Repair rung config (Phase 3 WS2, ladder rung 4). */
|
|
30
|
+
export interface RepairPolicy {
|
|
31
|
+
/** Total repair attempts on a schema-invalid output: attempt 1 re-asks the
|
|
32
|
+
* SAME model with the ajv error summary; attempt 2 (when maxRepairs ≥ 2 and
|
|
33
|
+
* repairModel is set) hands {invalid output, errors, schema} to the
|
|
34
|
+
* designated repair model. */
|
|
35
|
+
readonly maxRepairs: number;
|
|
36
|
+
/** Designated cheap repair model — must be one of the route's declared
|
|
37
|
+
* candidates (candidate-set invariant holds through repair). */
|
|
38
|
+
readonly repairModel?: CandidateSpec;
|
|
39
|
+
}
|
|
40
|
+
/** A named route variant (Phase 3 WS1, bundle format v2 — additive).
|
|
41
|
+
* Every field optional; an absent field inherits the route's base config. */
|
|
42
|
+
export interface RouteVariant {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
/** Candidate narrowing — MUST be a subset of the route's declared
|
|
45
|
+
* candidates (loader-enforced; the candidate-set invariant is unbreachable
|
|
46
|
+
* via variants). */
|
|
47
|
+
readonly candidates?: readonly CandidateSpec[];
|
|
48
|
+
/** Replaces the system template entirely (rendered with the same variables
|
|
49
|
+
* and capability conditionals). Mutually exclusive with promptAppend. */
|
|
50
|
+
readonly promptOverride?: string;
|
|
51
|
+
/** Appended to the rendered system prompt (after capability conditionals,
|
|
52
|
+
* before json coaching). */
|
|
53
|
+
readonly promptAppend?: string;
|
|
54
|
+
/** Reasoning scaffold (thinking directives; manual authoring this phase) —
|
|
55
|
+
* appended after promptAppend, before json coaching. */
|
|
56
|
+
readonly scaffold?: string;
|
|
57
|
+
/** JSON rung override for this variant. */
|
|
58
|
+
readonly json?: "native" | "json_mode";
|
|
59
|
+
readonly repair?: RepairPolicy;
|
|
60
|
+
}
|
|
61
|
+
export interface RouteBundle {
|
|
62
|
+
readonly route: string;
|
|
63
|
+
readonly version: number;
|
|
64
|
+
/** Resolved, parsed JSON Schema (null = unstructured route). */
|
|
65
|
+
readonly outputSchema: object | null;
|
|
66
|
+
readonly candidates: readonly CandidateSpec[];
|
|
67
|
+
readonly require: readonly Requirement[];
|
|
68
|
+
readonly prefer: readonly Preference[];
|
|
69
|
+
/** Raw template text with {{var}} and {{#if capability.X}} blocks. */
|
|
70
|
+
readonly systemTemplate: string;
|
|
71
|
+
readonly variables: readonly string[];
|
|
72
|
+
readonly policy: RoutePolicy;
|
|
73
|
+
/** Base-config repair rung (Phase 3 WS2) — variants may override. */
|
|
74
|
+
readonly repair?: RepairPolicy;
|
|
75
|
+
/** Named variants (Phase 3 WS1, bundle v2) — [] for v1 bundles. */
|
|
76
|
+
readonly variants: readonly RouteVariant[];
|
|
77
|
+
/** Local-only replay capture opt-in (Phase 3 WS4) — default false. */
|
|
78
|
+
readonly capture: boolean;
|
|
79
|
+
/** Request-path caching opt-in (cache-aware-routing WS-C, YAML `cache: auto`)
|
|
80
|
+
* — when true the run loop stamps `AdapterRequest.cache` (gated per provider
|
|
81
|
+
* cache policy) and the stable-prefix fingerprint onto telemetry. Optional &
|
|
82
|
+
* additive (S3): absent ⇒ false ⇒ pre-WS-C behavior (no cache stamping).
|
|
83
|
+
* Gemini candidates on a `cache: auto` route are excluded from request-path
|
|
84
|
+
* stamping and rely on implicit caching — enforced by the policy gate in
|
|
85
|
+
* cache-stamp.ts, not by prose. */
|
|
86
|
+
readonly cache?: boolean;
|
|
87
|
+
/** Grounding-inject search-query template (Phase 3 WS3) — rendered with
|
|
88
|
+
* the same variables as the system template; absent = the capped rendered
|
|
89
|
+
* prompt is used as the query (adequate only for short prompts). */
|
|
90
|
+
readonly groundingQuery?: string;
|
|
91
|
+
/** Schema-fingerprint cell key, computed at load from outputSchema
|
|
92
|
+
* (registry/fingerprint.ts); null for unstructured routes. */
|
|
93
|
+
readonly fingerprintCell: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface RunTags {
|
|
96
|
+
readonly run_id?: string;
|
|
97
|
+
readonly step?: string;
|
|
98
|
+
readonly [key: string]: string | undefined;
|
|
99
|
+
}
|
|
100
|
+
export interface RunOptions {
|
|
101
|
+
readonly input: Record<string, unknown>;
|
|
102
|
+
readonly tags: RunTags;
|
|
103
|
+
readonly budget?: {
|
|
104
|
+
readonly envelope: string;
|
|
105
|
+
/** Budget for this envelope when it is FIRST opened (open-or-get: the first
|
|
106
|
+
* opener's budget wins; a pre-existing envelope is never resized). Omitted →
|
|
107
|
+
* the rig's default `envelopeBudgetUsd`. The hosted gateway's mirror lane
|
|
108
|
+
* sets this to the per-org daily cap so a customer's MANAGED spend is bounded
|
|
109
|
+
* independently of the deployment's own daily envelope (spend-safety). */
|
|
110
|
+
readonly budgetUsd?: number;
|
|
111
|
+
};
|
|
112
|
+
/** Named variant to serve (Phase 3 WS1); omitted = the default variant
|
|
113
|
+
* (the route's base config). Unknown names are config errors. */
|
|
114
|
+
readonly variant?: string;
|
|
115
|
+
/** Per-run data-governance opt-in (G-3). `true` demands zero-retention
|
|
116
|
+
* routing for THIS run — `zero_retention` is unioned into the run's effective
|
|
117
|
+
* `require`, so it routes only to ZDR-designated endpoints (empty set →
|
|
118
|
+
* the existing no-eligible-candidate error, fail-closed). Additive only: a run
|
|
119
|
+
* may opt INTO the requirement, never opt OUT of a route's declared one
|
|
120
|
+
* (opting out would be a governance downgrade). Absent/false = the route's
|
|
121
|
+
* declared `require` stands. */
|
|
122
|
+
readonly zeroRetention?: boolean;
|
|
123
|
+
/** Per-run price ceiling (G-2). Drops any candidate whose blended in+out
|
|
124
|
+
* snapshot rate exceeds this — the SAME rate `prefer:[cost]` sorts on, so
|
|
125
|
+
* filter and sort agree. Unknown cost + a ceiling set → dropped (fail-closed,
|
|
126
|
+
* like the envelope). Distinct from the per-run envelope, which caps total
|
|
127
|
+
* spend across attempts; this narrows WHICH models are eligible. */
|
|
128
|
+
readonly maxPriceUsdPerMTok?: number;
|
|
129
|
+
/** Per-run provider allow/deny (G-2), applied before capability + ZDR. */
|
|
130
|
+
readonly providers?: {
|
|
131
|
+
readonly only?: readonly ProviderId[];
|
|
132
|
+
readonly ignore?: readonly ProviderId[];
|
|
133
|
+
};
|
|
134
|
+
/** Unified tool-calling (G-1/G-5 Phase A, spec §4.4) — tools the model may
|
|
135
|
+
* call this run. Passed through to the adapter; a tool-call turn is surfaced
|
|
136
|
+
* on `RunMeta.toolCalls` and is NOT schema-validated. ModelRig normalizes the
|
|
137
|
+
* protocol only — the caller executes the tool. */
|
|
138
|
+
readonly tools?: readonly ToolDefinition[];
|
|
139
|
+
readonly toolChoice?: ToolChoice;
|
|
140
|
+
/**
|
|
141
|
+
* Customer-managed cache handle pass-through (CE-1, spec §2). A provider-native
|
|
142
|
+
* cache identifier the CUSTOMER created and OWNS — gemini `cachedContents/<id>`,
|
|
143
|
+
* or a `prompt_cache_key` value for key-hint providers. It rides straight to
|
|
144
|
+
* `AdapterRequest.cache` for the matching-provider candidate; ModelRig passes
|
|
145
|
+
* it through verbatim and **never creates, refreshes, or deletes the underlying
|
|
146
|
+
* resource** — long jobs that outlive the provider's default TTL need the
|
|
147
|
+
* customer's OWN heartbeat (see modelrig.dev/docs/caching-lifecycle). This wins
|
|
148
|
+
* over the WS-C `cache: auto` generated stamp; absent, WS-C behavior stands
|
|
149
|
+
* byte-for-byte.
|
|
150
|
+
*/
|
|
151
|
+
readonly cache?: {
|
|
152
|
+
/** The provider-native cache identifier, forwarded unchanged. */
|
|
153
|
+
readonly key: string;
|
|
154
|
+
/** REQUIRED. The handle names a provider-scoped resource, so it is applied
|
|
155
|
+
* ONLY to candidates of this provider; other candidates (fallbacks) dispatch
|
|
156
|
+
* WITHOUT cache rather than with a handle their provider would reject. Note
|
|
157
|
+
* the model-version caveat: gemini caches bind to the exact model+version, so
|
|
158
|
+
* a same-provider fallback to a DIFFERENT gemini model may fail
|
|
159
|
+
* `cache_invalid` — the retry ladder then re-dispatches that candidate
|
|
160
|
+
* without the handle. */
|
|
161
|
+
readonly provider: ProviderId;
|
|
162
|
+
/** Optional TTL hint forwarded on `AdapterRequest.cache`; informational —
|
|
163
|
+
* the customer's own heartbeat governs the actual resource TTL. */
|
|
164
|
+
readonly ttlSeconds?: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export interface RunMeta {
|
|
168
|
+
/** Telemetry row id of the serving attempt — the handle rig.feedback()
|
|
169
|
+
* takes (Phase 4 WS2). */
|
|
170
|
+
readonly inferenceId: string;
|
|
171
|
+
readonly route: string;
|
|
172
|
+
readonly routeVersion: number;
|
|
173
|
+
readonly provider: ProviderId;
|
|
174
|
+
readonly model: string;
|
|
175
|
+
readonly requestedTier: ServiceTier;
|
|
176
|
+
readonly servedTier: ServiceTier;
|
|
177
|
+
readonly tokensIn: number;
|
|
178
|
+
readonly tokensOut: number;
|
|
179
|
+
readonly tokensCached: number;
|
|
180
|
+
readonly costEstimateUsd: number;
|
|
181
|
+
readonly latencyMs: number;
|
|
182
|
+
readonly validated: boolean;
|
|
183
|
+
readonly attemptsByClass: Partial<Record<FailureClass, number>>;
|
|
184
|
+
/** Variant that served this run — null = default variant (Phase 3 WS1). */
|
|
185
|
+
readonly servedVariant: string | null;
|
|
186
|
+
/** "provider/model" that repaired the output — null when unrepaired
|
|
187
|
+
* (Phase 3 WS2). */
|
|
188
|
+
readonly repairedBy: string | null;
|
|
189
|
+
/** Normalized url_citation annotations (Phase 3 WS3) — present when the
|
|
190
|
+
* grounding-inject rung served this run. */
|
|
191
|
+
readonly citations?: ReadonlyArray<{
|
|
192
|
+
readonly type: "url_citation";
|
|
193
|
+
readonly url: string;
|
|
194
|
+
readonly title?: string;
|
|
195
|
+
}>;
|
|
196
|
+
/** Normalized tool calls the model emitted (G-1/G-5 Phase A, spec §4.4) —
|
|
197
|
+
* present only on a tool-call turn, where `validated` is false and
|
|
198
|
+
* `RunResult.output` is null. The caller runs the tool(s) and continues. */
|
|
199
|
+
readonly toolCalls?: readonly ToolCall[];
|
|
200
|
+
}
|
|
201
|
+
export interface RunResult {
|
|
202
|
+
readonly output: unknown;
|
|
203
|
+
readonly meta: RunMeta;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/types/route.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,UAAU,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAChG,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IA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,CAAC,CAAC,CAAC;IAChE,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC;wBACoB;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC;gDAC4C;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;QACjC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;IACH;;gFAE4E;IAC5E,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry contracts — spec §5. SQLite-backed in Phase 1 (telemetry/store.ts);
|
|
3
|
+
* the interface exists so Phase 6 can add a remote control-plane sink.
|
|
4
|
+
*/
|
|
5
|
+
import type { FailureClass } from "./failures";
|
|
6
|
+
import type { RunTags } from "./route";
|
|
7
|
+
export interface TelemetryRow {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly ts: string;
|
|
10
|
+
readonly route: string;
|
|
11
|
+
readonly routeVersion: number;
|
|
12
|
+
readonly provider: string;
|
|
13
|
+
readonly model: string;
|
|
14
|
+
readonly requestedTier: string;
|
|
15
|
+
readonly servedTier: string;
|
|
16
|
+
/** Total input tokens. NORMALIZATION INVARIANT (WS-A / spec §2): INCLUDES
|
|
17
|
+
* `tokensCached` and `tokensCacheWrite` as subsets — mirrors
|
|
18
|
+
* {@link AdapterUsage.tokensIn}. */
|
|
19
|
+
readonly tokensIn: number;
|
|
20
|
+
readonly tokensOut: number;
|
|
21
|
+
/** Cache-READ input tokens (subset of `tokensIn`). */
|
|
22
|
+
readonly tokensCached: number;
|
|
23
|
+
/** Cache-CREATION (write) input tokens (subset of `tokensIn`) — WS-A. Mirrors
|
|
24
|
+
* {@link AdapterUsage.tokensCacheWrite}; 0 when the provider does not write
|
|
25
|
+
* cache or does not report it. Persisted to `inferences.tokens_cache_write`
|
|
26
|
+
* (migration 00049) and read back as 0 for rows recorded before it. OPTIONAL
|
|
27
|
+
* & additive: the store binds/reads `?? 0`, so a row that omits it is a
|
|
28
|
+
* zero-write row (the fail-closed default) — no construction site is forced
|
|
29
|
+
* to change. Every SDK write path (run loop, raw lane) sets it explicitly. */
|
|
30
|
+
readonly tokensCacheWrite?: number;
|
|
31
|
+
/** 1h-TTL portion of `tokensCacheWrite` (Anthropic; bills at the 2×
|
|
32
|
+
* multiplier). Subset of `tokensCacheWrite`; 0 = all 5m-tier. Optional/additive. */
|
|
33
|
+
readonly tokensCacheWrite1h?: number;
|
|
34
|
+
readonly costEstimateUsd: number;
|
|
35
|
+
readonly latencyMs: number;
|
|
36
|
+
/** Time to first body byte, ms (Phase 4 WS3) — null when nothing arrived
|
|
37
|
+
* or for rows recorded before the v6 migration. */
|
|
38
|
+
readonly ttfbMs: number | null;
|
|
39
|
+
readonly failureClass: FailureClass | null;
|
|
40
|
+
readonly attemptsJson: string;
|
|
41
|
+
readonly tagsJson: string;
|
|
42
|
+
/** Schema-fingerprint cell key (registry/fingerprint.ts) — null for
|
|
43
|
+
* unstructured routes and rows recorded before the v2 migration. */
|
|
44
|
+
readonly fingerprintCell: string | null;
|
|
45
|
+
/** Provider cache key / `prompt_cache_key` sent with the request, if any
|
|
46
|
+
* (WS-A substrate; the WS-C request-path opt-in fills it). null everywhere
|
|
47
|
+
* in WS-A — accounting ships dark, no request stamps a key yet. Optional &
|
|
48
|
+
* additive: the store binds/reads `?? null`. */
|
|
49
|
+
readonly cacheKey?: string | null;
|
|
50
|
+
/** Hash of the stable prompt prefix (WS-A substrate; WS-C fills it with
|
|
51
|
+
* `hash(route, template_version, toolschema_hash)`). null in WS-A. Optional. */
|
|
52
|
+
readonly prefixFingerprint?: string | null;
|
|
53
|
+
/** True when this attempt's model had no pricing entry (addendum A1):
|
|
54
|
+
* cost_estimate_usd stays 0 (no invented dollars) and any active envelope
|
|
55
|
+
* was charged the conservative unpriced rate instead. */
|
|
56
|
+
readonly pricingMissing: boolean;
|
|
57
|
+
/** Variant name this attempt served (Phase 3 WS1) — null = default variant
|
|
58
|
+
* and rows recorded before the v3 migration. */
|
|
59
|
+
readonly servedVariant: string | null;
|
|
60
|
+
/** "provider/model" of the repair model that produced this row's output
|
|
61
|
+
* (Phase 3 WS2) — null for unrepaired attempts. */
|
|
62
|
+
readonly repairedBy: string | null;
|
|
63
|
+
}
|
|
64
|
+
export interface EnvelopeRow {
|
|
65
|
+
readonly envelopeKey: string;
|
|
66
|
+
readonly budgetUsd: number;
|
|
67
|
+
readonly spentUsd: number;
|
|
68
|
+
readonly status: "open" | "exhausted";
|
|
69
|
+
}
|
|
70
|
+
/** One rig.feedback() judgment (Phase 4 WS2) — attached to a single
|
|
71
|
+
* inference OR an episode (= run-level key), or both. Local SQLite is the
|
|
72
|
+
* write path; the exporter mirrors (dual-store symmetry with inferences). */
|
|
73
|
+
export interface FeedbackRow {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly ts: string;
|
|
76
|
+
readonly inferenceId: string | null;
|
|
77
|
+
readonly episodeKey: string | null;
|
|
78
|
+
readonly verdict: "up" | "down";
|
|
79
|
+
readonly score: number | null;
|
|
80
|
+
readonly note: string | null;
|
|
81
|
+
readonly source: string;
|
|
82
|
+
/**
|
|
83
|
+
* The org this verdict belongs to — Phase 6 WS2, and the reason this field
|
|
84
|
+
* exists at all.
|
|
85
|
+
*
|
|
86
|
+
* A verdict recorded through OUR hosted server belongs to the org of the
|
|
87
|
+
* person who recorded it, and one SQLite store serves every org that reaches
|
|
88
|
+
* that server. Without a per-row org the exporter stamps its OWN, which
|
|
89
|
+
* files a customer's judgment into somebody else's corpus — unrecomputable
|
|
90
|
+
* evidence, silently wrong. WS1 shipped a 409 refusal rather than misfile;
|
|
91
|
+
* this column is what replaces the refusal with routing (QA-P6-010).
|
|
92
|
+
*
|
|
93
|
+
* NULL is the ordinary case and means "whatever org this exporter is": a
|
|
94
|
+
* self-hosted rig has exactly one, and `rig.feedback()` from application
|
|
95
|
+
* code has no notion of orgs at all.
|
|
96
|
+
*/
|
|
97
|
+
readonly orgId: string | null;
|
|
98
|
+
/** Authenticated user who recorded it (00017's `feedback.created_by`), or
|
|
99
|
+
* null for an SDK-recorded verdict — which is a fact about the row, not
|
|
100
|
+
* missing data, and is never backfilled. */
|
|
101
|
+
readonly createdBy: string | null;
|
|
102
|
+
}
|
|
103
|
+
/** One execution of a customer pipeline (Expansion E2 chunk A). Local SQLite is
|
|
104
|
+
* the write path (run.start/run.end); the exporter mirrors it to `public.runs`
|
|
105
|
+
* on its own watermark. A mutable projection: start → end. `source_id`/`org_id`
|
|
106
|
+
* are stamped at export from the principal, never held locally (one rig = one
|
|
107
|
+
* source). */
|
|
108
|
+
export interface RunRow {
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly pipeline: string;
|
|
111
|
+
readonly pipelineVersion: string | null;
|
|
112
|
+
readonly environment: string | null;
|
|
113
|
+
readonly episodeKey: string | null;
|
|
114
|
+
readonly startedAt: string;
|
|
115
|
+
readonly endedAt: string | null;
|
|
116
|
+
readonly status: "running" | "succeeded" | "failed" | "abandoned";
|
|
117
|
+
}
|
|
118
|
+
/** One ATTEMPT of one operation within a run (Expansion E2 chunk A, ruling c).
|
|
119
|
+
* A fact — one row per attempt, PK (run_id, step_key, attempt_no). Provenance is
|
|
120
|
+
* ground-truth (an inference reference) XOR attested (a foreign OTLP span);
|
|
121
|
+
* nothing writes attested rows this mission. */
|
|
122
|
+
export interface StepRow {
|
|
123
|
+
readonly runId: string;
|
|
124
|
+
readonly stepKey: string;
|
|
125
|
+
readonly attemptNo: number;
|
|
126
|
+
readonly task: string | null;
|
|
127
|
+
readonly provenance: "ground-truth" | "attested";
|
|
128
|
+
readonly inferenceId: string | null;
|
|
129
|
+
readonly spanTraceId: string | null;
|
|
130
|
+
readonly spanId: string | null;
|
|
131
|
+
readonly startedAt: string;
|
|
132
|
+
readonly endedAt: string | null;
|
|
133
|
+
readonly failureClass: string | null;
|
|
134
|
+
}
|
|
135
|
+
/** Artifact METADATA (Expansion E2 chunk B). Content is never held — contentRef
|
|
136
|
+
* is the customer's opaque URI, contentHash a sha256 of bytes hashed-then-
|
|
137
|
+
* discarded. A fact; local SQLite write path (artifact.save), exporter mirrors. */
|
|
138
|
+
export interface ArtifactRow {
|
|
139
|
+
readonly id: string;
|
|
140
|
+
readonly runId: string | null;
|
|
141
|
+
readonly stepKey: string | null;
|
|
142
|
+
readonly attemptNo: number | null;
|
|
143
|
+
readonly task: string | null;
|
|
144
|
+
readonly name: string;
|
|
145
|
+
readonly type: string;
|
|
146
|
+
readonly version: number;
|
|
147
|
+
readonly supersedesArtifactId: string | null;
|
|
148
|
+
readonly declaredSchema: unknown;
|
|
149
|
+
readonly fingerprintCell: string | null;
|
|
150
|
+
readonly contentRef: string | null;
|
|
151
|
+
readonly contentHash: string | null;
|
|
152
|
+
readonly contentBytes: number | null;
|
|
153
|
+
readonly dataClassification: string | null;
|
|
154
|
+
readonly expiresAt: string | null;
|
|
155
|
+
/** Per-row scrub findings (E4 chunk 0, migration 00039) — the `ScrubSummary`
|
|
156
|
+
* shape `{mode, blocked, findings:[{type,count}]}`, COUNTS never values.
|
|
157
|
+
* Absent/null ⇒ scrub did not run for this artifact (custody off, caller-
|
|
158
|
+
* supplied contentRef, or a pre-E4 row). Opaque here (T7). */
|
|
159
|
+
readonly scrub?: unknown;
|
|
160
|
+
}
|
|
161
|
+
/** A lineage edge between two artifacts (chunk B). */
|
|
162
|
+
export interface ArtifactEdgeRow {
|
|
163
|
+
readonly fromArtifactId: string;
|
|
164
|
+
readonly toArtifactId: string;
|
|
165
|
+
readonly kind: "consumed" | "derived_from";
|
|
166
|
+
}
|
|
167
|
+
/** An evaluation recorded against an artifact (chunk B). */
|
|
168
|
+
export interface ArtifactEvaluationRow {
|
|
169
|
+
readonly id: string;
|
|
170
|
+
/** The artifact subject — null when this evaluates a whole run (E5 chunk V). */
|
|
171
|
+
readonly artifactId: string | null;
|
|
172
|
+
/** The run subject (E5 chunk V) — null when this evaluates an artifact.
|
|
173
|
+
* Exactly one of artifactId / runId is set. */
|
|
174
|
+
readonly runId: string | null;
|
|
175
|
+
readonly evaluator: string;
|
|
176
|
+
readonly evaluatorKind: "deterministic" | "model-judge" | "human";
|
|
177
|
+
readonly score: number | null;
|
|
178
|
+
readonly passed: boolean | null;
|
|
179
|
+
readonly label: string | null;
|
|
180
|
+
readonly explanation: string | null;
|
|
181
|
+
readonly createdBy: string | null;
|
|
182
|
+
}
|
|
183
|
+
/** How a case entered the eval suite (E4 chunk A, migration 00040 CHECK). */
|
|
184
|
+
export type EvalCaseOrigin = "promoted-failure" | "human-corrected" | "manual";
|
|
185
|
+
/** A per-org regression/golden eval case (E4 chunk A). `correctedArtifactId`
|
|
186
|
+
* null ⇒ a failure-case; set ⇒ a golden-corrected pair. A fact on ingest
|
|
187
|
+
* (created via promote); edits/deletes are server-side, not on this stream. */
|
|
188
|
+
export interface EvalCaseRow {
|
|
189
|
+
readonly id: string;
|
|
190
|
+
readonly task: string;
|
|
191
|
+
readonly sourceArtifactId: string;
|
|
192
|
+
readonly correctedArtifactId: string | null;
|
|
193
|
+
readonly origin: EvalCaseOrigin;
|
|
194
|
+
readonly note: string | null;
|
|
195
|
+
readonly createdBy: string | null;
|
|
196
|
+
}
|
|
197
|
+
export interface TelemetryStore {
|
|
198
|
+
record(row: TelemetryRow): void;
|
|
199
|
+
recordFeedback(row: FeedbackRow): void;
|
|
200
|
+
queryByTag(tag: keyof RunTags & string, value: string): TelemetryRow[];
|
|
201
|
+
getEnvelope(key: string): EnvelopeRow | null;
|
|
202
|
+
accrue(key: string, usd: number): EnvelopeRow;
|
|
203
|
+
openEnvelope(key: string, budgetUsd: number): EnvelopeRow;
|
|
204
|
+
close(): void;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/types/telemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;wCAEoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;kFAM8E;IAC9E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;wFACoF;IACpF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;uDACmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC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AAM,GAAG,YAAY,EAAE,CAAC;IACvE,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9C,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAC1D,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `modelrig validate` (CE-6, spec §1, walkthrough §8.7a) — extracted from
|
|
3
|
+
* cli.ts to keep it under the 700-LOC cap. Structurally loads rig.yaml + every
|
|
4
|
+
* route bundle and reports per-route OK / config error, exiting nonzero on any
|
|
5
|
+
* failure. Requires NO provider key: this bypasses the serveable-candidate gate
|
|
6
|
+
* (which needs keys and stays fail-closed for SERVING) so a newbie can check
|
|
7
|
+
* their authoring before wiring credentials. A bare
|
|
8
|
+
* `createRig(loadConfigFromEnv())` fail-closes keyless with "no serveable
|
|
9
|
+
* candidate" — this is the dry structural check that doesn't.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runValidateCli(): number;
|
|
12
|
+
//# sourceMappingURL=validate-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-cli.d.ts","sourceRoot":"","sources":["../src/validate-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,wBAAgB,cAAc,IAAI,MAAM,CAmCvC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `modelrig validate` (CE-6, spec §1, walkthrough §8.7a) — extracted from
|
|
4
|
+
* cli.ts to keep it under the 700-LOC cap. Structurally loads rig.yaml + every
|
|
5
|
+
* route bundle and reports per-route OK / config error, exiting nonzero on any
|
|
6
|
+
* failure. Requires NO provider key: this bypasses the serveable-candidate gate
|
|
7
|
+
* (which needs keys and stays fail-closed for SERVING) so a newbie can check
|
|
8
|
+
* their authoring before wiring credentials. A bare
|
|
9
|
+
* `createRig(loadConfigFromEnv())` fail-closes keyless with "no serveable
|
|
10
|
+
* candidate" — this is the dry structural check that doesn't.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.runValidateCli = runValidateCli;
|
|
14
|
+
const node_path_1 = require("node:path");
|
|
15
|
+
const config_1 = require("./config");
|
|
16
|
+
const loader_1 = require("./routes/loader");
|
|
17
|
+
const manifest_1 = require("./routes/manifest");
|
|
18
|
+
function runValidateCli() {
|
|
19
|
+
const config = (0, config_1.loadConfigFromEnv)();
|
|
20
|
+
const rigDir = (0, node_path_1.dirname)(config.routesDir);
|
|
21
|
+
let failures = 0;
|
|
22
|
+
// rig.yaml (manifest) — absence is fine (never gates); a malformed one is a
|
|
23
|
+
// config error surfaced like any route.
|
|
24
|
+
try {
|
|
25
|
+
const manifest = (0, manifest_1.loadManifest)(rigDir);
|
|
26
|
+
console.log(manifest === null ? `— rig.yaml (none at ${rigDir})` : "OK rig.yaml");
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
failures += 1;
|
|
30
|
+
console.error(`FAIL rig.yaml: ${configErrorText(err)}`);
|
|
31
|
+
}
|
|
32
|
+
// Every route bundle — one bad file never hides the rest.
|
|
33
|
+
const results = (0, loader_1.validateRoutesDir)(config.routesDir);
|
|
34
|
+
if (results.length === 0) {
|
|
35
|
+
console.log(`(no route bundles in ${config.routesDir})`);
|
|
36
|
+
}
|
|
37
|
+
for (const r of results) {
|
|
38
|
+
if (r.ok) {
|
|
39
|
+
console.log(`OK ${r.route} (${r.file})`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
failures += 1;
|
|
43
|
+
console.error(`FAIL ${r.route ?? r.file}: ${r.problems.join("; ")}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (failures === 0) {
|
|
47
|
+
console.log(`\n${results.length} route(s) valid — no provider key required for this check.`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
console.error(`\n${failures} problem(s) found.`);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
function configErrorText(err) {
|
|
54
|
+
if (err instanceof loader_1.RouteConfigError && err.problems.length > 0)
|
|
55
|
+
return err.problems.join("; ");
|
|
56
|
+
return err instanceof Error ? err.message : String(err);
|
|
57
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The capture step — records N invocations of the ORIGINAL call site's
|
|
3
|
+
* inputs/outputs LOCALLY (spec §9 Tier-2 verify). Two surfaces:
|
|
4
|
+
*
|
|
5
|
+
* - `captureOriginal(site, originalFn, inputs)` — invoke the original call
|
|
6
|
+
* (a black-box function the skill/harness wraps around the customer's real
|
|
7
|
+
* call) once per input and record the I/O into a fixture. Honest refusal is
|
|
8
|
+
* built in: a streaming or dynamically-assembled-prompt call site is REFUSED
|
|
9
|
+
* up front (those are T0/T1 territory), and an input the original throws on
|
|
10
|
+
* is recorded as a per-input refusal, never a lost sample.
|
|
11
|
+
* - `openShadowCaptureStore(dbPath)` — a durable local SQLite buffer for the
|
|
12
|
+
* same captures, the same posture as telemetry/capture.ts: a plain
|
|
13
|
+
* better-sqlite3 handle with record/readAll/close and NO network or upload
|
|
14
|
+
* accessor. Captures stay in the SDK process; nothing here uploads.
|
|
15
|
+
*
|
|
16
|
+
* The portable `ShadowCaptureFixture` (JSON) is the hand-off the CLI reads and
|
|
17
|
+
* the skill embeds context from — the only thing that leaves this module, and
|
|
18
|
+
* only to local disk.
|
|
19
|
+
*/
|
|
20
|
+
import type { CandidateSpec } from "../types/route";
|
|
21
|
+
import type { ShadowCapture, ShadowCaptureFixture } from "./types";
|
|
22
|
+
/** A call site being captured. `streaming`/`dynamicPrompt` are the skill's
|
|
23
|
+
* honest declarations that this site cannot be captured/replayed as a
|
|
24
|
+
* task-shaped bundle — refusing is the correct output. */
|
|
25
|
+
export interface OriginalCallSite {
|
|
26
|
+
readonly callSiteId: string;
|
|
27
|
+
/** provider+model of the original call — the route must pin exactly this. */
|
|
28
|
+
readonly original: CandidateSpec;
|
|
29
|
+
readonly streaming?: boolean;
|
|
30
|
+
readonly dynamicPrompt?: boolean;
|
|
31
|
+
readonly nondeterministicPaths?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/** The original call, wrapped as a pure input→output-text function. */
|
|
34
|
+
export type OriginalCallFn = (input: Record<string, unknown>) => Promise<string>;
|
|
35
|
+
export interface CaptureOptions {
|
|
36
|
+
readonly now?: () => string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Capture N original invocations into a fixture. Streaming/dynamic sites are
|
|
40
|
+
* refused before any call; per-input failures become `uncapturable` refusals.
|
|
41
|
+
*/
|
|
42
|
+
export declare function captureOriginal(site: OriginalCallSite, originalFn: OriginalCallFn, inputs: readonly Record<string, unknown>[], opts?: CaptureOptions): Promise<ShadowCaptureFixture>;
|
|
43
|
+
export interface ShadowCaptureRecord {
|
|
44
|
+
readonly callSiteId: string;
|
|
45
|
+
readonly provider: string;
|
|
46
|
+
readonly model: string;
|
|
47
|
+
readonly input: Record<string, unknown>;
|
|
48
|
+
readonly output: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ShadowCaptureStore {
|
|
51
|
+
record(row: ShadowCaptureRecord): void;
|
|
52
|
+
/** Captures for a call site, in insertion order (the replay input set). */
|
|
53
|
+
readAll(callSiteId: string): ShadowCapture[];
|
|
54
|
+
close(): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A separate better-sqlite3 handle — deliberately NOT wired to any exporter or
|
|
58
|
+
* upload path. Shadow captures are original-call outputs used only to prove
|
|
59
|
+
* equivalence locally; nothing here ever leaves the machine (the SDK's
|
|
60
|
+
* export-isolation posture, extended to the verifier).
|
|
61
|
+
*/
|
|
62
|
+
export declare function openShadowCaptureStore(dbPath: string): ShadowCaptureStore;
|
|
63
|
+
export declare function serializeFixture(fixture: ShadowCaptureFixture): string;
|
|
64
|
+
/** Parse + shape-validate a fixture (errors teach — the CLI surfaces them). */
|
|
65
|
+
export declare function parseFixture(json: string): ShadowCaptureFixture;
|
|
66
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/verify/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAkB,aAAa,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEnF;;0DAE0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpD;AAED,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC1C,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAwC/B;AAwBD,MA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