modelrig 0.9.0 → 0.10.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 +179 -0
- package/README.md +51 -27
- package/data/PROVENANCE.md +14 -0
- package/data/pricing-map.json +26 -0
- package/dist/adapters/attempt-meta-map.d.ts +8 -1
- package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
- package/dist/adapters/attempt-meta-map.js +4 -0
- package/dist/adapters/build-adapters.js +2 -2
- package/dist/adapters/gemini.d.ts +28 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +38 -9
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +53 -4
- package/dist/adapters/openai-compat.d.ts +8 -2
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +8 -1
- package/dist/adapters/openai-stream.d.ts +10 -2
- package/dist/adapters/openai-stream.d.ts.map +1 -1
- package/dist/adapters/openai-stream.js +5 -1
- package/dist/adapters/openai.d.ts +10 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +57 -7
- package/dist/adapters/responses-api.d.ts +61 -0
- package/dist/adapters/responses-api.d.ts.map +1 -0
- package/dist/adapters/responses-api.js +124 -0
- package/dist/artifacts/artifact.d.ts +20 -0
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +207 -171
- package/dist/artifacts/index.d.ts +3 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +8 -1
- package/dist/bakeoff/groundedness.d.ts +58 -0
- package/dist/bakeoff/groundedness.d.ts.map +1 -0
- package/dist/bakeoff/groundedness.js +165 -0
- package/dist/bakeoff/quality.d.ts +14 -1
- package/dist/bakeoff/quality.d.ts.map +1 -1
- package/dist/bakeoff/quality.js +10 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -0
- package/dist/doctor-cli.d.ts +7 -0
- package/dist/doctor-cli.d.ts.map +1 -0
- package/dist/doctor-cli.js +67 -0
- package/dist/doctor-preflight.d.ts +52 -0
- package/dist/doctor-preflight.d.ts.map +1 -0
- package/dist/doctor-preflight.js +112 -0
- package/dist/feedback/grade.d.ts +8 -1
- package/dist/feedback/grade.d.ts.map +1 -1
- package/dist/feedback/grade.js +4 -0
- package/dist/gateway/http-protocol.d.ts +19 -0
- package/dist/gateway/http-protocol.d.ts.map +1 -1
- package/dist/gateway/serve-client.d.ts +99 -0
- package/dist/gateway/serve-client.d.ts.map +1 -0
- package/dist/gateway/serve-client.js +360 -0
- package/dist/index.d.ts +25 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -8
- package/dist/prompts/manifest.d.ts +128 -0
- package/dist/prompts/manifest.d.ts.map +1 -0
- package/dist/prompts/manifest.js +214 -0
- package/dist/prompts/prompt-fetch.d.ts +84 -0
- package/dist/prompts/prompt-fetch.d.ts.map +1 -0
- package/dist/prompts/prompt-fetch.js +120 -0
- package/dist/prompts/prompt-resolve.d.ts +76 -0
- package/dist/prompts/prompt-resolve.d.ts.map +1 -0
- package/dist/prompts/prompt-resolve.js +93 -0
- package/dist/prompts/slot-resolver.d.ts +91 -0
- package/dist/prompts/slot-resolver.d.ts.map +1 -0
- package/dist/prompts/slot-resolver.js +135 -0
- package/dist/prompts/tools-register.d.ts +60 -0
- package/dist/prompts/tools-register.d.ts.map +1 -0
- package/dist/prompts/tools-register.js +48 -0
- package/dist/prompts/version-hash.d.ts +29 -0
- package/dist/prompts/version-hash.d.ts.map +1 -0
- package/dist/prompts/version-hash.js +54 -0
- package/dist/prompts-export-cli.d.ts +21 -0
- package/dist/prompts-export-cli.d.ts.map +1 -0
- package/dist/prompts-export-cli.js +130 -0
- package/dist/registry/cache-policy.d.ts.map +1 -1
- package/dist/registry/cache-policy.js +22 -0
- package/dist/registry/pricing-shape.d.ts +38 -8
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +40 -12
- package/dist/registry/pricing.d.ts +6 -5
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +9 -5
- package/dist/routes/destination-loader.d.ts +16 -0
- package/dist/routes/destination-loader.d.ts.map +1 -0
- package/dist/routes/destination-loader.js +29 -0
- package/dist/routes/draft.d.ts +7 -0
- package/dist/routes/draft.d.ts.map +1 -1
- package/dist/routes/draft.js +12 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +27 -54
- package/dist/routes/output-loader.d.ts +42 -0
- package/dist/routes/output-loader.d.ts.map +1 -0
- package/dist/routes/output-loader.js +112 -0
- package/dist/routes/prompt-loader.d.ts +49 -0
- package/dist/routes/prompt-loader.d.ts.map +1 -0
- package/dist/routes/prompt-loader.js +113 -0
- package/dist/routes/resolved-bundle.d.ts +19 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +24 -0
- package/dist/routes/screen-loader.d.ts +1 -1
- package/dist/routes/screen-loader.d.ts.map +1 -1
- package/dist/routes/screen-loader.js +8 -1
- package/dist/run/accept.d.ts +3 -0
- package/dist/run/accept.d.ts.map +1 -1
- package/dist/run/accept.js +1 -0
- package/dist/run/cost.d.ts +31 -2
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +57 -2
- package/dist/run/destination.d.ts +39 -0
- package/dist/run/destination.d.ts.map +1 -0
- package/dist/run/destination.js +45 -0
- package/dist/run/dispatch.d.ts +25 -3
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +26 -4
- package/dist/run/raw-defaults.d.ts.map +1 -1
- package/dist/run/raw-defaults.js +6 -1
- package/dist/run/raw-finalize.d.ts +50 -0
- package/dist/run/raw-finalize.d.ts.map +1 -0
- package/dist/run/raw-finalize.js +266 -0
- package/dist/run/raw-knobs.d.ts +36 -0
- package/dist/run/raw-knobs.d.ts.map +1 -0
- package/dist/run/raw-knobs.js +99 -0
- package/dist/run/raw-request.d.ts +24 -0
- package/dist/run/raw-request.d.ts.map +1 -0
- package/dist/run/raw-request.js +69 -0
- package/dist/run/raw-schema.d.ts +76 -0
- package/dist/run/raw-schema.d.ts.map +1 -0
- package/dist/run/raw-schema.js +166 -0
- package/dist/run/raw-search-cost.d.ts +48 -0
- package/dist/run/raw-search-cost.d.ts.map +1 -0
- package/dist/run/raw-search-cost.js +78 -0
- package/dist/run/raw-support.d.ts +64 -6
- package/dist/run/raw-support.d.ts.map +1 -1
- package/dist/run/raw-support.js +84 -11
- package/dist/run/raw.d.ts +25 -26
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +30 -351
- package/dist/run/record-attempt.d.ts +8 -0
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +26 -12
- package/dist/run/repair-attempt.d.ts +68 -0
- package/dist/run/repair-attempt.d.ts.map +1 -0
- package/dist/run/repair-attempt.js +180 -0
- package/dist/run/resolve-destination.d.ts +49 -0
- package/dist/run/resolve-destination.d.ts.map +1 -0
- package/dist/run/resolve-destination.js +76 -0
- package/dist/run/routing-docs.d.ts.map +1 -1
- package/dist/run/routing-docs.js +9 -4
- package/dist/run/run.d.ts +30 -1
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +75 -148
- package/dist/run/telemetry-row.d.ts +92 -0
- package/dist/run/telemetry-row.d.ts.map +1 -0
- package/dist/run/telemetry-row.js +81 -0
- package/dist/run/validate.d.ts +12 -1
- package/dist/run/validate.d.ts.map +1 -1
- package/dist/run/validate.js +31 -0
- package/dist/run/web-search-pricing.d.ts +43 -0
- package/dist/run/web-search-pricing.d.ts.map +1 -0
- package/dist/run/web-search-pricing.js +56 -0
- package/dist/settings/grading-guide.d.ts +27 -1
- package/dist/settings/grading-guide.d.ts.map +1 -1
- package/dist/status.d.ts +6 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +4 -1
- package/dist/telemetry/artifact-store.d.ts.map +1 -1
- package/dist/telemetry/artifact-store.js +11 -0
- package/dist/telemetry/attempt-meta.d.ts +55 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +24 -1
- package/dist/telemetry/exporter-setup.d.ts +2 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -1
- package/dist/telemetry/exporter-setup.js +6 -1
- package/dist/telemetry/grade-mappers.d.ts +5 -2
- package/dist/telemetry/grade-mappers.d.ts.map +1 -1
- package/dist/telemetry/grade-mappers.js +8 -2
- package/dist/telemetry/grades-sql.d.ts +4 -1
- package/dist/telemetry/grades-sql.d.ts.map +1 -1
- package/dist/telemetry/grades-sql.js +26 -3
- package/dist/telemetry/ingest-protocol.d.ts +26 -2
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +32 -29
- package/dist/telemetry/org-identity.d.ts +44 -0
- package/dist/telemetry/org-identity.d.ts.map +1 -0
- package/dist/telemetry/org-identity.js +98 -0
- package/dist/telemetry/route-registration.d.ts +48 -0
- package/dist/telemetry/route-registration.d.ts.map +1 -0
- package/dist/telemetry/route-registration.js +77 -0
- package/dist/telemetry/sinks.d.ts +10 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +52 -6
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +13 -0
- package/dist/tenancy/api-key-format.d.ts +16 -1
- package/dist/tenancy/api-key-format.d.ts.map +1 -1
- package/dist/tenancy/api-key-format.js +17 -0
- package/dist/types/provider.d.ts +20 -3
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/provider.js +1 -0
- package/dist/types/route.d.ts +76 -0
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +30 -2
- package/dist/types/telemetry.d.ts.map +1 -1
- package/docs/agent-skill/SKILL.md +73 -5
- package/docs/instrumentation.md +81 -36
- package/docs/llms.txt +95 -16
- package/docs/managed-serving.md +150 -0
- package/docs/mcp-oracle.md +75 -2
- package/docs/migration-playbook.md +5 -4
- package/docs/quickstart.md +169 -83
- package/package.json +3 -2
- package/registry/registry.json +82 -0
- package/dist/feedback/feedback.d.ts +0 -35
- package/dist/feedback/feedback.d.ts.map +0 -1
- package/dist/feedback/feedback.js +0 -39
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native web-search per-call pricing (Native Web Search lane, spec N3) — the
|
|
3
|
+
* SINGLE source of truth for the surcharge a provider bills when the model calls
|
|
4
|
+
* its native `web_search` tool, and the generator behind the published rates.
|
|
5
|
+
*
|
|
6
|
+
* WHY ITS OWN FILE: same doctrine as `raw-defaults.ts` / `raw-support.ts` — a code
|
|
7
|
+
* constant the runtime reads (to write the synthetic `rung:"search"` cost row via
|
|
8
|
+
* `recordSearchCostRow`) AND the docs generator renders, so the published rate can
|
|
9
|
+
* never drift from what we charge. A drift test asserts the rendered rate is read
|
|
10
|
+
* from THIS constant (never retyped).
|
|
11
|
+
*
|
|
12
|
+
* COST IS AN ESTIMATE, NOT A MEASUREMENT: like all ModelRig cost, `perCallUsd` is a
|
|
13
|
+
* declared list rate. Vendor rates drift and vary by context tier — the lane's live
|
|
14
|
+
* gate reconciles these against a real invoice before any public claim is un-tagged.
|
|
15
|
+
*
|
|
16
|
+
* [ARCH-TODO] (builder, Step 4): before un-tagging, replace the placeholder rates
|
|
17
|
+
* below with the verified per-search list price for each provider (research §7
|
|
18
|
+
* [verify-live]) and wire `perCallUsd` into the raw success path (raw.ts:551-556)
|
|
19
|
+
* via `recordSearchCostRow`.
|
|
20
|
+
*/
|
|
21
|
+
import type { ProviderId } from "../types/provider";
|
|
22
|
+
/** One provider's native web-search billing facts. */
|
|
23
|
+
export interface WebSearchRate {
|
|
24
|
+
/** USD billed per native `web_search` tool call (surcharge, on top of tokens). */
|
|
25
|
+
readonly perCallUsd: number;
|
|
26
|
+
/** Teaching note rendered in the docs table and the fixHint. */
|
|
27
|
+
readonly note: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Per-provider native web-search rates. Only providers whose grounding is
|
|
31
|
+
* `supported: true` in `RAW_KNOB_SUPPORT` need an entry; a provider with no native
|
|
32
|
+
* search never reaches the cost row (it uses the inject rung instead). Partial by
|
|
33
|
+
* design — a `Partial<Record<...>>` so unsupported providers are simply absent.
|
|
34
|
+
*
|
|
35
|
+
* [ARCH-TODO] rates are PLACEHOLDERS pending the [verify-live] invoice reconciliation.
|
|
36
|
+
*/
|
|
37
|
+
export declare const WEB_SEARCH_PRICING: Partial<Record<ProviderId, WebSearchRate>>;
|
|
38
|
+
/** Lookup used by the raw success path to price the synthetic search-cost row.
|
|
39
|
+
* Returns 0 when the provider has no declared native-search rate (never throws —
|
|
40
|
+
* an absent rate must not break dispatch; it surfaces as a 0 estimate + the drift
|
|
41
|
+
* test / live gate catches a missing entry for a supported provider). */
|
|
42
|
+
export declare function webSearchPerCallUsd(provider: ProviderId): number;
|
|
43
|
+
//# sourceMappingURL=web-search-pricing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search-pricing.d.ts","sourceRoot":"","sources":["../../src/run/web-search-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAgBzE,CAAC;AAEF;;;yEAGyE;AACzE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Native web-search per-call pricing (Native Web Search lane, spec N3) — the
|
|
4
|
+
* SINGLE source of truth for the surcharge a provider bills when the model calls
|
|
5
|
+
* its native `web_search` tool, and the generator behind the published rates.
|
|
6
|
+
*
|
|
7
|
+
* WHY ITS OWN FILE: same doctrine as `raw-defaults.ts` / `raw-support.ts` — a code
|
|
8
|
+
* constant the runtime reads (to write the synthetic `rung:"search"` cost row via
|
|
9
|
+
* `recordSearchCostRow`) AND the docs generator renders, so the published rate can
|
|
10
|
+
* never drift from what we charge. A drift test asserts the rendered rate is read
|
|
11
|
+
* from THIS constant (never retyped).
|
|
12
|
+
*
|
|
13
|
+
* COST IS AN ESTIMATE, NOT A MEASUREMENT: like all ModelRig cost, `perCallUsd` is a
|
|
14
|
+
* declared list rate. Vendor rates drift and vary by context tier — the lane's live
|
|
15
|
+
* gate reconciles these against a real invoice before any public claim is un-tagged.
|
|
16
|
+
*
|
|
17
|
+
* [ARCH-TODO] (builder, Step 4): before un-tagging, replace the placeholder rates
|
|
18
|
+
* below with the verified per-search list price for each provider (research §7
|
|
19
|
+
* [verify-live]) and wire `perCallUsd` into the raw success path (raw.ts:551-556)
|
|
20
|
+
* via `recordSearchCostRow`.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.WEB_SEARCH_PRICING = void 0;
|
|
24
|
+
exports.webSearchPerCallUsd = webSearchPerCallUsd;
|
|
25
|
+
/**
|
|
26
|
+
* Per-provider native web-search rates. Only providers whose grounding is
|
|
27
|
+
* `supported: true` in `RAW_KNOB_SUPPORT` need an entry; a provider with no native
|
|
28
|
+
* search never reaches the cost row (it uses the inject rung instead). Partial by
|
|
29
|
+
* design — a `Partial<Record<...>>` so unsupported providers are simply absent.
|
|
30
|
+
*
|
|
31
|
+
* [ARCH-TODO] rates are PLACEHOLDERS pending the [verify-live] invoice reconciliation.
|
|
32
|
+
*/
|
|
33
|
+
exports.WEB_SEARCH_PRICING = {
|
|
34
|
+
// [ARCH-TODO] verify against live billing before un-tagging (research §7).
|
|
35
|
+
gemini: { perCallUsd: 0, note: "[ARCH-TODO] Google grounding rate — verify-live" },
|
|
36
|
+
openai: {
|
|
37
|
+
perCallUsd: 0.01,
|
|
38
|
+
note: "$10/1k calls (tool surcharge; tokens billed separately); verified live 2026-09-09 via Responses API web_search",
|
|
39
|
+
},
|
|
40
|
+
grok: {
|
|
41
|
+
perCallUsd: 0.005,
|
|
42
|
+
note: "$5/1k calls = $0.005 per CALL (not per-source; 'per-source' was the retired Live Search surface); retrieved content billed separately as input tokens. Verified live 2026-09-09 — 15/15 recency, 100% citation presence, avg 3.80 cites/response",
|
|
43
|
+
},
|
|
44
|
+
// Z.ai / GLM (B4a stub, consumed by B4b): native web_search is free/included, so
|
|
45
|
+
// the surcharge is 0. Present now so B4b flips zai.grounding → supported and this
|
|
46
|
+
// cost row is already wired. Grounding itself stays fail-closed until B4b.
|
|
47
|
+
zai: { perCallUsd: 0, note: "GLM native web_search is free/included" },
|
|
48
|
+
// Phase 2: anthropic (Messages web_search) — add when built.
|
|
49
|
+
};
|
|
50
|
+
/** Lookup used by the raw success path to price the synthetic search-cost row.
|
|
51
|
+
* Returns 0 when the provider has no declared native-search rate (never throws —
|
|
52
|
+
* an absent rate must not break dispatch; it surfaces as a 0 estimate + the drift
|
|
53
|
+
* test / live gate catches a missing entry for a supported provider). */
|
|
54
|
+
function webSearchPerCallUsd(provider) {
|
|
55
|
+
return exports.WEB_SEARCH_PRICING[provider]?.perCallUsd ?? 0;
|
|
56
|
+
}
|
|
@@ -19,7 +19,22 @@
|
|
|
19
19
|
* TYPES ONLY — no behavior. Validation lives at the single write boundary
|
|
20
20
|
* (modelrig-server's task-settings path).
|
|
21
21
|
*/
|
|
22
|
-
/**
|
|
22
|
+
/** A criterion's scale. Absent = binary pass/fail (equivalent to `{ max: 1 }`).
|
|
23
|
+
* `{ max }` is an ordinal points scale 0..max; `{ enum }` is ordered categories
|
|
24
|
+
* (index 0 = worst … last = best). Either way a per-criterion sub-score
|
|
25
|
+
* normalizes to [0,1] for the weighted roll-up (call-qa F1; grade-rollup.ts). */
|
|
26
|
+
export type GradingGuideScale = {
|
|
27
|
+
readonly max: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly enum: readonly string[];
|
|
30
|
+
};
|
|
31
|
+
/** One criterion — the unit the expert authors and the judge applies.
|
|
32
|
+
*
|
|
33
|
+
* `id`/`title`/`pass`/`fail` are the original binary shape and are all a
|
|
34
|
+
* criterion needs; the four optional fields (call-qa F1) let a QA-style
|
|
35
|
+
* scorecard carry weight, a non-binary scale, a fatal (auto-fail) flag, and an
|
|
36
|
+
* evidence requirement WITHOUT breaking any existing binary guide — every
|
|
37
|
+
* shipped template omits them and stays valid. */
|
|
23
38
|
export interface GradingGuideCriterion {
|
|
24
39
|
/** Stable handle, unique within the guide (per-criterion grades key on it). */
|
|
25
40
|
readonly id: string;
|
|
@@ -28,6 +43,17 @@ export interface GradingGuideCriterion {
|
|
|
28
43
|
readonly pass: string;
|
|
29
44
|
/** One sentence describing what a FAIL on this criterion looks like. */
|
|
30
45
|
readonly fail: string;
|
|
46
|
+
/** Relative contribution to the weighted overall score. Default 1; must be
|
|
47
|
+
* a finite number > 0. (call-qa F1) */
|
|
48
|
+
readonly weight?: number;
|
|
49
|
+
/** Scoring scale. Absent = binary pass/fail. (call-qa F1) */
|
|
50
|
+
readonly scale?: GradingGuideScale;
|
|
51
|
+
/** When true, a FAIL on this criterion forces the overall verdict to fail
|
|
52
|
+
* regardless of the weighted score — a fatal compliance miss. (call-qa F1) */
|
|
53
|
+
readonly fatal?: boolean;
|
|
54
|
+
/** When true, the scorer must cite at least one grounded evidence quote for
|
|
55
|
+
* this criterion (enforced by the F3 groundedness check). (call-qa F1) */
|
|
56
|
+
readonly evidence_required?: boolean;
|
|
31
57
|
}
|
|
32
58
|
/** Escalation jury knobs (ruling §7.6 — defaults: single judge for volume,
|
|
33
59
|
* jury on escalation only). All optional; absent = server defaults at judge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grading-guide.d.ts","sourceRoot":"","sources":["../../src/settings/grading-guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,
|
|
1
|
+
{"version":3,"file":"grading-guide.d.ts","sourceRoot":"","sources":["../../src/settings/grading-guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;iFAGiF;AACjF,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEhG;;;;;;kDAMkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;2CACuC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC;kFAC8E;IAC9E,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB;8EAC0E;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED;;4CAE4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,0DAA0D;AAC1D,MAAM,WAAW,sBAAsB;IACrC;gEAC4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED;;gEAEgE;AAChE,MAAM,WAAW,iBAAiB;IAChC;4EACwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACpD;qFACiF;IACjF,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;2CACuC;IACvC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;CAC9C;AAED;;;gCAGgC;AAChC,MAAM,WAAW,YAAY;IAC3B;;qDAEiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACpD,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;CAC9C"}
|
package/dist/status.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface RigStatus {
|
|
|
27
27
|
/** Content custody (E2-C) — its own gate, unchanged by the §2 metadata flip. */
|
|
28
28
|
readonly contentCustody: boolean;
|
|
29
29
|
readonly otlp: "configured" | "disabled";
|
|
30
|
+
/** Managed serving (Unified Route U3, ruling D-2) — the `config.managedServing`
|
|
31
|
+
* flag (set IN CODE via `createRig`, NOT an env var; always resolved), reported
|
|
32
|
+
* honestly like `otlp`. `enabled` here means the flag is on for this rig; a run
|
|
33
|
+
* still only serves `modelrig-served` for a served-capable provider (else
|
|
34
|
+
* fail-closed). */
|
|
35
|
+
readonly managedServing: "enabled" | "disabled";
|
|
30
36
|
/** Cache accounting posture (cache-aware-routing WS-A/WS-D). Derived from the
|
|
31
37
|
* policy registry — config-only, so `status` shows it anywhere. Live per-route
|
|
32
38
|
* hit rate + effective input rate are a control-plane read, surfaced on the
|
package/dist/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;kFAC8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,gFAAgF;IAChF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAAC;IACzC;;;qFAGiF;IACjF,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B;gEAC4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,CAAC,CAAC;IACxE;iFAC6E;IAC7E,QAA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H,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAGtD;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAkC5D"}
|
package/dist/status.js
CHANGED
|
@@ -79,6 +79,7 @@ function buildRigStatus(config, tasks = new Map(), runs, posture = null) {
|
|
|
79
79
|
artifacts: artifactsPosture(config, posture),
|
|
80
80
|
contentCustody: contentCustodyOn(config, posture),
|
|
81
81
|
otlp: config.otlp ? "configured" : "disabled",
|
|
82
|
+
managedServing: config.managedServing === true ? "enabled" : "disabled",
|
|
82
83
|
cache: cachePosture(),
|
|
83
84
|
tasks: [...tasks].map(([task, s]) => ({ task, ...s })),
|
|
84
85
|
...(runs != null ? { runs } : {}),
|
|
@@ -91,9 +92,10 @@ function formatBootBanner(config, posture = null) {
|
|
|
91
92
|
const a = artifactsPosture(config, posture);
|
|
92
93
|
const content = contentCustodyOn(config, posture) ? "on" : "off";
|
|
93
94
|
const otlp = config.otlp ? "on" : "off";
|
|
95
|
+
const managedServing = config.managedServing === true ? "on" : "off";
|
|
94
96
|
return (`[modelrig] telemetry: ${exportModeOf(config)} · ` +
|
|
95
97
|
`artifacts: ${a.enabled ? "on" : "off"} (${a.reason}) · ` +
|
|
96
|
-
`content: ${content} · otlp: ${otlp}`);
|
|
98
|
+
`content: ${content} · otlp: ${otlp} · managed-serving: ${managedServing}`);
|
|
97
99
|
}
|
|
98
100
|
/**
|
|
99
101
|
* Emit the boot banner to stderr — ONCE at rig construction, and ONLY when a
|
|
@@ -116,6 +118,7 @@ function formatStatusReport(status) {
|
|
|
116
118
|
` artifacts : ${status.artifacts.enabled ? "enabled" : "disabled"} (${status.artifacts.reason})`,
|
|
117
119
|
` content custody : ${status.contentCustody ? "enabled" : "disabled"}`,
|
|
118
120
|
` otlp span export : ${status.otlp}`,
|
|
121
|
+
` managed serving : ${status.managedServing} (config: managedServing)`,
|
|
119
122
|
` cache accounting : on (policy ${status.cache.policyVersion}) — cache-eligible: ${status.cache.eligibleProviders.length > 0 ? status.cache.eligibleProviders.join(", ") : "none"}`,
|
|
120
123
|
" (live hit rate + effective input rate: console route cache page)",
|
|
121
124
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-store.d.ts","sourceRoot":"","sources":["../../src/telemetry/artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C;;yFAEqF;IACrF,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC;kFAC8E;IAC9E,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAClG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IAClG,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAClG,gFAAgF;IAChF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAAC;IACjD;gEAC4D;IAC5D,eAAe,CAAC,EAAE,EAAE,MA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AAW,EAAE,CAAC;IACjD;gEAC4D;IAC5D,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAChD;;oFAEgF;IAChF,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;CACf;AA2DD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CA2H/D"}
|
|
@@ -77,6 +77,17 @@ function openArtifactStore(dbPath) {
|
|
|
77
77
|
// IGNORE) so pre-grade evaluations still export as grades. Additive.
|
|
78
78
|
db.exec(grades_sql_1.GRADES_TABLE_SQL);
|
|
79
79
|
(0, grades_sql_1.backfillGradesFromEvaluations)(db);
|
|
80
|
+
// F4: additive per-criterion `criteria` column on a dev DB that predates it
|
|
81
|
+
// and was created by THIS handle (so the telemetry store's v16 rung may not
|
|
82
|
+
// have run). CREATE IF NOT EXISTS above won't add it to an existing table;
|
|
83
|
+
// gradeBindParams now binds @criteria, so the column must exist before any
|
|
84
|
+
// insert. Same swallow-on-duplicate pattern as scrub/run_id.
|
|
85
|
+
try {
|
|
86
|
+
db.exec("ALTER TABLE grades ADD COLUMN criteria TEXT");
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* column already present — no-op */
|
|
90
|
+
}
|
|
80
91
|
// Additive column for a dev DB that predates E4 (CREATE TABLE IF NOT EXISTS
|
|
81
92
|
// won't add it to an existing table). SQLite has no ADD COLUMN IF NOT EXISTS;
|
|
82
93
|
// a duplicate-column error on re-run is expected and swallowed.
|
|
@@ -12,9 +12,33 @@
|
|
|
12
12
|
* enum/identifier/hash (length > 128 or containing whitespace).
|
|
13
13
|
*/
|
|
14
14
|
import type { AdapterUsage, ProviderId } from "../types/provider";
|
|
15
|
+
import type { OutputKind } from "../types/route";
|
|
15
16
|
import type { ScreenReceipt } from "../screen/types";
|
|
16
17
|
export type FinishReason = "stop" | "length" | "tool_calls" | "content_filter" | "refusal" | "error" | "other";
|
|
17
18
|
export type ContextBucket = "≤4k" | "≤16k" | "≤64k" | "≤200k" | ">200k";
|
|
19
|
+
/**
|
|
20
|
+
* How the rendered prompt reached the model on ONE attempt (GitLab issue #5,
|
|
21
|
+
* R1) — the proof surface for the cache-handle rule, stamped on
|
|
22
|
+
* `inferences.meta.prompt_delivery` by the adapter that made the call:
|
|
23
|
+
* • `system` — the rendered system prompt went as the provider's system
|
|
24
|
+
* instruction; the user turn carried the trigger / `prompt.user`.
|
|
25
|
+
* • `user` — no system instruction was sent because the rendered system
|
|
26
|
+
* prompt was EMPTY; the user turn alone carried the prompt.
|
|
27
|
+
* • `user+cache` — a cache HANDLE was sent (Gemini `cachedContent`), so the
|
|
28
|
+
* system instruction could not be: everything rendered — the
|
|
29
|
+
* system prompt (if any), then the user turn — was delivered
|
|
30
|
+
* AS the user turn. Nothing was dropped.
|
|
31
|
+
* Stamped today by the Gemini adapter (the one provider where a handle changes
|
|
32
|
+
* delivery); absent on other providers' rows (⇒ delivered as declared).
|
|
33
|
+
*/
|
|
34
|
+
export type PromptDelivery = "system" | "user" | "user+cache";
|
|
35
|
+
export declare const PROMPT_DELIVERIES: ReadonlySet<string>;
|
|
36
|
+
/** The output contract a ROUTE-lane attempt was held to (issue #1 / plan §7.3,
|
|
37
|
+
* QA-S7): `json` (parsed + schema-checked) or `text` (returned verbatim). Same
|
|
38
|
+
* producer/enum pattern as {@link PromptDelivery}; stamped on
|
|
39
|
+
* `inferences.meta.output_kind` for every dispatched route-lane row, absent on
|
|
40
|
+
* raw-lane rows (the raw lane has no route contract). */
|
|
41
|
+
export declare const OUTPUT_KINDS: ReadonlySet<string>;
|
|
18
42
|
/** D1 egress receipt — shape RESERVED here; populated by the D1 mission. */
|
|
19
43
|
export interface EgressReceiptV1 {
|
|
20
44
|
readonly endpoint?: string;
|
|
@@ -27,6 +51,7 @@ export interface EgressReceiptV1 {
|
|
|
27
51
|
readonly search_provider?: string;
|
|
28
52
|
readonly tool_calls?: number;
|
|
29
53
|
}
|
|
54
|
+
export type ServedTierSource = "provider" | "requested_fallback";
|
|
30
55
|
export interface AttemptMetaV1 {
|
|
31
56
|
readonly v: 1;
|
|
32
57
|
readonly finish_reason?: FinishReason;
|
|
@@ -51,6 +76,13 @@ export interface AttemptMetaV1 {
|
|
|
51
76
|
readonly search_provider?: string;
|
|
52
77
|
};
|
|
53
78
|
readonly model_snapshot?: string;
|
|
79
|
+
/** Issue #2 (L6 F5): where `servedTier` came from — `provider` (the response
|
|
80
|
+
* echoed a tier: openai `service_tier`, gemini `serviceTier` /
|
|
81
|
+
* `usageMetadata.trafficType`) or `requested_fallback` (no echo; the adapter
|
|
82
|
+
* assumed the requested tier). Pricing reads the served tier, so a
|
|
83
|
+
* fallback-priced row is identifiable here. Absent on adapters without the
|
|
84
|
+
* signal. */
|
|
85
|
+
readonly served_tier_source?: ServedTierSource;
|
|
54
86
|
readonly provider_request_id?: string;
|
|
55
87
|
readonly http_status?: number;
|
|
56
88
|
readonly error_code?: string;
|
|
@@ -66,6 +98,11 @@ export interface AttemptMetaV1 {
|
|
|
66
98
|
/** sha256 of the RENDERED request — a hash, never content. */
|
|
67
99
|
readonly input_hash?: string;
|
|
68
100
|
readonly output_hash?: string;
|
|
101
|
+
/** R2 (issue #6): `sha256:<hex>` of the CANONICAL (sorted-key) JSON of the
|
|
102
|
+
* schema this attempt was asked to conform to — the raw lane's declared
|
|
103
|
+
* `responseSchema` today. A hash, never content; lets declared-vs-served
|
|
104
|
+
* schema drift be queried on `inferences.meta`. Absent ⇒ no schema declared. */
|
|
105
|
+
readonly schema_sha?: string;
|
|
69
106
|
readonly context_bucket?: ContextBucket;
|
|
70
107
|
readonly egress?: EgressReceiptV1;
|
|
71
108
|
/** LRE-2: the live A/B experiment arm this call was drawn onto (an identifier —
|
|
@@ -81,6 +118,12 @@ export interface AttemptMetaV1 {
|
|
|
81
118
|
* single producer `summarizeScreen`; NEVER carries a matched value. Reserved &
|
|
82
119
|
* additive. */
|
|
83
120
|
readonly screen?: ScreenReceipt;
|
|
121
|
+
/** Issue #5 (R1): how the rendered prompt reached the model — see
|
|
122
|
+
* {@link PromptDelivery}. Absent ⇒ the adapter did not report it. */
|
|
123
|
+
readonly prompt_delivery?: PromptDelivery;
|
|
124
|
+
/** QA-S7 (issue #1, plan §7.3): the route's output contract on this attempt —
|
|
125
|
+
* `json` | `text`. Route lane only; absent on raw rows. */
|
|
126
|
+
readonly output_kind?: OutputKind;
|
|
84
127
|
}
|
|
85
128
|
export interface RunMetaV1 {
|
|
86
129
|
readonly v: 1;
|
|
@@ -103,6 +146,8 @@ export interface AttemptMetaSource {
|
|
|
103
146
|
readonly renderedRequest?: string;
|
|
104
147
|
readonly outputText?: string | null;
|
|
105
148
|
readonly declaredToolNames?: readonly string[];
|
|
149
|
+
/** QA-S7: the route's output contract (route lane only). */
|
|
150
|
+
readonly outputKind?: OutputKind;
|
|
106
151
|
}
|
|
107
152
|
/** Canonicalize the RENDERED request for `input_hash` (spec §2) — system + user
|
|
108
153
|
* + schema, joined the SAME way in both lanes so a routed and a raw call with
|
|
@@ -125,10 +170,19 @@ export interface AttemptMetaInputs {
|
|
|
125
170
|
readonly outputText?: string | null;
|
|
126
171
|
/** Declared tool ids; any tool_call name NOT in this set is hashed. */
|
|
127
172
|
readonly declaredToolNames?: readonly string[];
|
|
173
|
+
/** R2: the canonical schema sha (`sha256:<hex>`) to stamp on `meta.schema_sha`.
|
|
174
|
+
* Already a hash — gated by the classification rule like any identifier.
|
|
175
|
+
* Absent ⇒ no key ⇒ byte-identical to a schema-free row. */
|
|
176
|
+
readonly schemaSha?: string;
|
|
177
|
+
/** QA-S7: the route-lane output contract to stamp on `meta.output_kind`.
|
|
178
|
+
* Absent (the raw lane) ⇒ no key ⇒ byte-identical. */
|
|
179
|
+
readonly outputKind?: OutputKind;
|
|
128
180
|
/** For the cost components (via src/run/cost.ts). */
|
|
129
181
|
readonly provider?: ProviderId;
|
|
130
182
|
readonly model?: string;
|
|
131
|
-
readonly usage?: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h"
|
|
183
|
+
readonly usage?: Pick<AdapterUsage, "tokensIn" | "tokensOut" | "tokensCached" | "tokensCacheWrite" | "tokensCacheWrite1h"> &
|
|
184
|
+
/** issue #2: the served tier, so `meta.cost` components price like the row. */
|
|
185
|
+
Partial<Pick<AdapterUsage, "servedTier">>;
|
|
132
186
|
/** Whether the caller streamed deltas (run loop stream() path). */
|
|
133
187
|
readonly streaming?: boolean;
|
|
134
188
|
/** Repair-rung count carried by the run loop, if any. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt-meta.d.ts","sourceRoot":"","sources":["../../src/telemetry/attempt-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAExE,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,M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B,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAExD;AAOD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAgCrG;AAID;gEACgE;AAChE,eAAO,MAAM,iBAAiB,mEAAoE,CAAC;AACnG,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AA4BhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,CAAA;CAAE,EAAE,CAS5G;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;;2CAG2C;AAC3C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBrE;AAwCD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,IAAI,CA0GpF"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* enum/identifier/hash (length > 128 or containing whitespace).
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.RESERVED_TAG_KEYS = void 0;
|
|
16
|
+
exports.RESERVED_TAG_KEYS = exports.OUTPUT_KINDS = exports.PROMPT_DELIVERIES = void 0;
|
|
17
17
|
exports.renderRequestForHash = renderRequestForHash;
|
|
18
18
|
exports.isMetaSafeString = isMetaSafeString;
|
|
19
19
|
exports.sanitizeMetaForWire = sanitizeMetaForWire;
|
|
@@ -26,6 +26,13 @@ const node_fs_1 = require("node:fs");
|
|
|
26
26
|
const node_path_1 = require("node:path");
|
|
27
27
|
const cost_1 = require("../run/cost");
|
|
28
28
|
const config_1 = require("../config");
|
|
29
|
+
exports.PROMPT_DELIVERIES = new Set(["system", "user", "user+cache"]);
|
|
30
|
+
/** The output contract a ROUTE-lane attempt was held to (issue #1 / plan §7.3,
|
|
31
|
+
* QA-S7): `json` (parsed + schema-checked) or `text` (returned verbatim). Same
|
|
32
|
+
* producer/enum pattern as {@link PromptDelivery}; stamped on
|
|
33
|
+
* `inferences.meta.output_kind` for every dispatched route-lane row, absent on
|
|
34
|
+
* raw-lane rows (the raw lane has no route contract). */
|
|
35
|
+
exports.OUTPUT_KINDS = new Set(["json", "text"]);
|
|
29
36
|
/** Canonicalize the RENDERED request for `input_hash` (spec §2) — system + user
|
|
30
37
|
* + schema, joined the SAME way in both lanes so a routed and a raw call with
|
|
31
38
|
* the identical prompt+schema hash identically (lane parity, spec §6.3). The
|
|
@@ -234,6 +241,9 @@ function summarizeAttemptMeta(inputs) {
|
|
|
234
241
|
meta.finish_reason = a.finish_reason;
|
|
235
242
|
if (typeof a.refusal === "boolean")
|
|
236
243
|
meta.refusal = a.refusal;
|
|
244
|
+
if (a.served_tier_source === "provider" || a.served_tier_source === "requested_fallback") {
|
|
245
|
+
meta.served_tier_source = a.served_tier_source;
|
|
246
|
+
}
|
|
237
247
|
if (typeof a.streaming === "boolean")
|
|
238
248
|
meta.streaming = a.streaming;
|
|
239
249
|
else if (typeof inputs.streaming === "boolean")
|
|
@@ -242,11 +252,24 @@ function summarizeAttemptMeta(inputs) {
|
|
|
242
252
|
// no key ⇒ byte-identical to a non-experiment row).
|
|
243
253
|
if (isMetaSafeString(inputs.arm))
|
|
244
254
|
meta.arm = inputs.arm;
|
|
255
|
+
// R2 declared-schema hash — a `sha256:` string (71 chars, no whitespace).
|
|
256
|
+
if (isMetaSafeString(inputs.schemaSha))
|
|
257
|
+
meta.schema_sha = inputs.schemaSha;
|
|
245
258
|
// SC-1a screen receipt (spec §5, §8) — the counts-only screen summary rides
|
|
246
259
|
// on meta.screen (ZERO migration). Already counts/enums/hashes; passed
|
|
247
260
|
// through verbatim (absent ⇒ no key ⇒ byte-identical to a non-screened row).
|
|
248
261
|
if (inputs.screen !== undefined)
|
|
249
262
|
meta.screen = inputs.screen;
|
|
263
|
+
// Issue #5 (R1): prompt delivery — an enum our adapters produce; anything
|
|
264
|
+
// outside the vocabulary is dropped (absent ⇒ no key ⇒ byte-identical).
|
|
265
|
+
if (typeof a.prompt_delivery === "string" && exports.PROMPT_DELIVERIES.has(a.prompt_delivery)) {
|
|
266
|
+
meta.prompt_delivery = a.prompt_delivery;
|
|
267
|
+
}
|
|
268
|
+
// QA-S7: route-lane output contract — the same enum discipline; anything
|
|
269
|
+
// outside `json` | `text` is dropped (absent ⇒ no key ⇒ byte-identical).
|
|
270
|
+
if (typeof inputs.outputKind === "string" && exports.OUTPUT_KINDS.has(inputs.outputKind)) {
|
|
271
|
+
meta.output_kind = inputs.outputKind;
|
|
272
|
+
}
|
|
250
273
|
// Externally-sourced identifiers — gated by the classification rule.
|
|
251
274
|
if (isMetaSafeString(a.model_snapshot))
|
|
252
275
|
meta.model_snapshot = a.model_snapshot;
|
|
@@ -19,6 +19,8 @@ export interface ExporterSetupExtras {
|
|
|
19
19
|
readonly artifactStore: ArtifactStore | null;
|
|
20
20
|
/** E4 chunk 0: retry 404'd content after a confirmed artifacts flush. */
|
|
21
21
|
readonly onArtifactsFlushed?: () => Promise<void>;
|
|
22
|
+
/** `createRig({ expectOrg })` (M5) — threaded to the api sink's org line. */
|
|
23
|
+
readonly expectOrg?: string;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Construct the sink for the configured mode, wire the exporter, and start its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter-setup.d.ts","sourceRoot":"","sources":["../../src/telemetry/exporter-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,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CACpC,SAAS,EAAE,wBAAwB,EACnC,YAAY,EAAE,eAAe,GAAG,kBAAkB,EAClD,MAAM,EAAE,mBAAmB,GAC1B,QAAQ,CAyBV"}
|
|
@@ -10,13 +10,14 @@ exports.startTelemetryExporter = startTelemetryExporter;
|
|
|
10
10
|
const node_os_1 = require("node:os");
|
|
11
11
|
const exporter_1 = require("./exporter");
|
|
12
12
|
const sinks_1 = require("./sinks");
|
|
13
|
+
const route_registration_1 = require("./route-registration");
|
|
13
14
|
/**
|
|
14
15
|
* Construct the sink for the configured mode, wire the exporter, and start its
|
|
15
16
|
* flush loop. Returns the running exporter (the caller stops it on close()).
|
|
16
17
|
*/
|
|
17
18
|
function startTelemetryExporter(telemetry, exportConfig, extras) {
|
|
18
19
|
const sourceId = exportConfig.sourceId ?? (0, node_os_1.hostname)();
|
|
19
|
-
const sink = (0, sinks_1.buildTelemetrySink)(exportConfig, sourceId);
|
|
20
|
+
const sink = (0, sinks_1.buildTelemetrySink)(exportConfig, sourceId, extras.expectOrg !== undefined ? { expectOrg: extras.expectOrg } : {});
|
|
20
21
|
const exporter = (0, exporter_1.createTelemetryExporter)(telemetry, {
|
|
21
22
|
sink,
|
|
22
23
|
sourceId,
|
|
@@ -30,5 +31,9 @@ function startTelemetryExporter(telemetry, exportConfig, extras) {
|
|
|
30
31
|
...(extras.onArtifactsFlushed !== undefined ? { onArtifactsFlushed: extras.onArtifactsFlushed } : {}),
|
|
31
32
|
});
|
|
32
33
|
exporter.start();
|
|
34
|
+
// RV-1 declare-on-startup: the declared routes (metadata + bundle) go out now,
|
|
35
|
+
// fire-and-forget, so a route is visible before its first call / first flush.
|
|
36
|
+
// Never awaited, never throws — createRig cannot block or fail on it.
|
|
37
|
+
void (0, route_registration_1.registerRoutesOnStartup)(sink, sourceId, extras.routes);
|
|
33
38
|
return exporter;
|
|
34
39
|
}
|
|
@@ -11,8 +11,11 @@ import type { WireGrade } from "./ingest-protocol";
|
|
|
11
11
|
/** GradeRow → WireGrade (the exporter's `:grades` stream mapper). org_id is
|
|
12
12
|
* spread-iff-present so stampBatch falls back to the exporter's tenant. */
|
|
13
13
|
export declare function toWireGrade(row: GradeRow): WireGrade;
|
|
14
|
-
/** WireGrade → a grades row (the SDK's sole judgment write path).
|
|
15
|
-
|
|
14
|
+
/** WireGrade → a grades row (the SDK's sole judgment write path). `criteria`
|
|
15
|
+
* (F4) is deliberately destructured OUT here: `public.grades` has no criteria
|
|
16
|
+
* column — the per-criterion breakdown fans out to `grade_criteria` in a
|
|
17
|
+
* separate best-effort write at the ingest boundary, keyed to this grade's id. */
|
|
18
|
+
export declare function gradeToRow({ org_id, criteria: _criteria, ...g }: WireGrade, tenancy: Tenancy): Record<string, unknown>;
|
|
16
19
|
/**
|
|
17
20
|
* Grades naming an org other than the presented key's. The ingest endpoint drops
|
|
18
21
|
* and COUNTS these so a caller cannot file a judgment into another tenant's corpus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grade-mappers.d.ts","sourceRoot":"","sources":["../../src/telemetry/grade-mappers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"grade-mappers.d.ts","sourceRoot":"","sources":["../../src/telemetry/grade-mappers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,CAmBpD;AAED;;;kFAGkF;AAClF,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBtH;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAEhG"}
|
|
@@ -27,10 +27,16 @@ function toWireGrade(row) {
|
|
|
27
27
|
created_by: row.createdBy,
|
|
28
28
|
ts: row.ts,
|
|
29
29
|
...(row.orgId !== null ? { org_id: row.orgId } : {}),
|
|
30
|
+
// F4: mirror the per-criterion breakdown iff present (spread-iff — a
|
|
31
|
+
// single-score grade's wire shape is byte-identical to pre-F4).
|
|
32
|
+
...(row.criteria !== undefined ? { criteria: row.criteria } : {}),
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
|
-
/** WireGrade → a grades row (the SDK's sole judgment write path).
|
|
33
|
-
|
|
35
|
+
/** WireGrade → a grades row (the SDK's sole judgment write path). `criteria`
|
|
36
|
+
* (F4) is deliberately destructured OUT here: `public.grades` has no criteria
|
|
37
|
+
* column — the per-criterion breakdown fans out to `grade_criteria` in a
|
|
38
|
+
* separate best-effort write at the ingest boundary, keyed to this grade's id. */
|
|
39
|
+
function gradeToRow({ org_id, criteria: _criteria, ...g }, tenancy) {
|
|
34
40
|
return {
|
|
35
41
|
org_id: org_id ?? tenancy.org_id,
|
|
36
42
|
project_id: tenancy.project_id,
|
|
@@ -16,7 +16,7 @@ import type Database from "better-sqlite3";
|
|
|
16
16
|
import type { GradeRow } from "../types/telemetry";
|
|
17
17
|
/** `CREATE TABLE IF NOT EXISTS grades …` — safe to run on every open. Mirrors
|
|
18
18
|
* `public.grades` minus the export-stamped columns (org handling below). */
|
|
19
|
-
export declare const GRADES_TABLE_SQL = "\nCREATE TABLE IF NOT EXISTS grades (\n id TEXT PRIMARY KEY,\n ts TEXT,\n subject_kind TEXT NOT NULL CHECK (subject_kind IN ('inference','run','artifact')),\n subject_id TEXT NOT NULL,\n score REAL NOT NULL,\n scale_max REAL,\n scale_label TEXT,\n comment TEXT,\n kind TEXT NOT NULL CHECK (kind IN ('human','model-judge','deterministic')),\n grader TEXT,\n source TEXT,\n org_id TEXT,\n created_by TEXT\n);\nCREATE INDEX IF NOT EXISTS idx_grades_subject ON grades (subject_kind, subject_id);\n";
|
|
19
|
+
export declare const GRADES_TABLE_SQL = "\nCREATE TABLE IF NOT EXISTS grades (\n id TEXT PRIMARY KEY,\n ts TEXT,\n subject_kind TEXT NOT NULL CHECK (subject_kind IN ('inference','run','artifact')),\n subject_id TEXT NOT NULL,\n score REAL NOT NULL,\n scale_max REAL,\n scale_label TEXT,\n comment TEXT,\n kind TEXT NOT NULL CHECK (kind IN ('human','model-judge','deterministic')),\n grader TEXT,\n source TEXT,\n org_id TEXT,\n created_by TEXT,\n criteria TEXT\n);\nCREATE INDEX IF NOT EXISTS idx_grades_subject ON grades (subject_kind, subject_id);\n";
|
|
20
20
|
/** The row shape as it sits in SQLite (snake_case, nullable columns as read back). */
|
|
21
21
|
export interface GradeDbRow {
|
|
22
22
|
id: string;
|
|
@@ -32,6 +32,9 @@ export interface GradeDbRow {
|
|
|
32
32
|
source: string | null;
|
|
33
33
|
org_id: string | null;
|
|
34
34
|
created_by: string | null;
|
|
35
|
+
/** JSON-encoded per-criterion breakdown (call-qa F4), or null for a
|
|
36
|
+
* single-score grade / a row written before the v16 rung. */
|
|
37
|
+
criteria: string | null;
|
|
35
38
|
}
|
|
36
39
|
/** Prepare the grade insert statement against an open handle. INSERT OR IGNORE:
|
|
37
40
|
* a grade id is unique, and a re-inserted id (e.g. the backfill racing a live
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grades-sql.d.ts","sourceRoot":"","sources":["../../src/telemetry/grades-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"grades-sql.d.ts","sourceRoot":"","sources":["../../src/telemetry/grades-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAkB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnE;4EAC4E;AAC5E,eAAO,MAAM,gBAAgB,ulBAkB5B,CAAC;AAEF,sFAAsF;AACtF,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;iEAC6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAWD;;iCAEiC;AACjC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAE5E;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBtE;AAED,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,QAAQ,CAqBlD;AAcD;;;yCAGyC;AACzC,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAetE;AAED;;0EAE0E;AAC1E,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAgBzE"}
|
|
@@ -36,17 +36,18 @@ CREATE TABLE IF NOT EXISTS grades (
|
|
|
36
36
|
grader TEXT,
|
|
37
37
|
source TEXT,
|
|
38
38
|
org_id TEXT,
|
|
39
|
-
created_by TEXT
|
|
39
|
+
created_by TEXT,
|
|
40
|
+
criteria TEXT
|
|
40
41
|
);
|
|
41
42
|
CREATE INDEX IF NOT EXISTS idx_grades_subject ON grades (subject_kind, subject_id);
|
|
42
43
|
`;
|
|
43
44
|
const INSERT_GRADE_SQL = `
|
|
44
45
|
INSERT OR IGNORE INTO grades (
|
|
45
46
|
id, ts, subject_kind, subject_id, score, scale_max, scale_label, comment,
|
|
46
|
-
kind, grader, source, org_id, created_by
|
|
47
|
+
kind, grader, source, org_id, created_by, criteria
|
|
47
48
|
) VALUES (
|
|
48
49
|
@id, @ts, @subject_kind, @subject_id, @score, @scale_max, @scale_label, @comment,
|
|
49
|
-
@kind, @grader, @source, @org_id, @created_by
|
|
50
|
+
@kind, @grader, @source, @org_id, @created_by, @criteria
|
|
50
51
|
)`;
|
|
51
52
|
/** Prepare the grade insert statement against an open handle. INSERT OR IGNORE:
|
|
52
53
|
* a grade id is unique, and a re-inserted id (e.g. the backfill racing a live
|
|
@@ -70,6 +71,10 @@ function gradeBindParams(row) {
|
|
|
70
71
|
source: row.source,
|
|
71
72
|
org_id: row.orgId,
|
|
72
73
|
created_by: row.createdBy,
|
|
74
|
+
// F4: the per-criterion breakdown is stored as a JSON string (or null for a
|
|
75
|
+
// single-score grade). One column, no sidecar table locally — the server is
|
|
76
|
+
// where it fans out to `grade_criteria`.
|
|
77
|
+
criteria: row.criteria !== undefined ? JSON.stringify(row.criteria) : null,
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
/** Read one SQLite grade row back into a GradeRow. */
|
|
@@ -88,8 +93,26 @@ function toGradeRow(r) {
|
|
|
88
93
|
source: r.source,
|
|
89
94
|
orgId: r.org_id ?? null,
|
|
90
95
|
createdBy: r.created_by ?? null,
|
|
96
|
+
// F4: parse the JSON `criteria` column back. Null (pre-F4 or single-score) ⇒
|
|
97
|
+
// the field is ABSENT on the GradeRow (spread-iff), so the wire stays
|
|
98
|
+
// byte-identical for a plain grade. A malformed value degrades to absent
|
|
99
|
+
// rather than throwing on the export read.
|
|
100
|
+
...parseCriteriaColumn(r.criteria),
|
|
91
101
|
};
|
|
92
102
|
}
|
|
103
|
+
/** Narrow the stored JSON `criteria` column to a spread-iff-present GradeRow
|
|
104
|
+
* fragment. Malformed / null ⇒ `{}` (field absent). Never throws on the read. */
|
|
105
|
+
function parseCriteriaColumn(raw) {
|
|
106
|
+
if (raw === null)
|
|
107
|
+
return {};
|
|
108
|
+
try {
|
|
109
|
+
const parsed = JSON.parse(raw);
|
|
110
|
+
return Array.isArray(parsed) ? { criteria: parsed } : {};
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
93
116
|
/** Backfill `grades` from the local `feedback` table, if it exists (grade
|
|
94
117
|
* primitive, GP-1). Same mapping as migration 00070's feedback→grades leg.
|
|
95
118
|
* Idempotent (INSERT OR IGNORE keyed on the source row id). Runs inside the
|