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.
Files changed (223) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/README.md +51 -27
  3. package/data/PROVENANCE.md +14 -0
  4. package/data/pricing-map.json +26 -0
  5. package/dist/adapters/attempt-meta-map.d.ts +8 -1
  6. package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
  7. package/dist/adapters/attempt-meta-map.js +4 -0
  8. package/dist/adapters/build-adapters.js +2 -2
  9. package/dist/adapters/gemini.d.ts +28 -1
  10. package/dist/adapters/gemini.d.ts.map +1 -1
  11. package/dist/adapters/gemini.js +38 -9
  12. package/dist/adapters/grok.d.ts.map +1 -1
  13. package/dist/adapters/grok.js +53 -4
  14. package/dist/adapters/openai-compat.d.ts +8 -2
  15. package/dist/adapters/openai-compat.d.ts.map +1 -1
  16. package/dist/adapters/openai-compat.js +8 -1
  17. package/dist/adapters/openai-stream.d.ts +10 -2
  18. package/dist/adapters/openai-stream.d.ts.map +1 -1
  19. package/dist/adapters/openai-stream.js +5 -1
  20. package/dist/adapters/openai.d.ts +10 -1
  21. package/dist/adapters/openai.d.ts.map +1 -1
  22. package/dist/adapters/openai.js +57 -7
  23. package/dist/adapters/responses-api.d.ts +61 -0
  24. package/dist/adapters/responses-api.d.ts.map +1 -0
  25. package/dist/adapters/responses-api.js +124 -0
  26. package/dist/artifacts/artifact.d.ts +20 -0
  27. package/dist/artifacts/artifact.d.ts.map +1 -1
  28. package/dist/artifacts/artifact.js +207 -171
  29. package/dist/artifacts/index.d.ts +3 -1
  30. package/dist/artifacts/index.d.ts.map +1 -1
  31. package/dist/artifacts/index.js +8 -1
  32. package/dist/bakeoff/groundedness.d.ts +58 -0
  33. package/dist/bakeoff/groundedness.d.ts.map +1 -0
  34. package/dist/bakeoff/groundedness.js +165 -0
  35. package/dist/bakeoff/quality.d.ts +14 -1
  36. package/dist/bakeoff/quality.d.ts.map +1 -1
  37. package/dist/bakeoff/quality.js +10 -0
  38. package/dist/bakeoff/replay.d.ts.map +1 -1
  39. package/dist/bakeoff/replay.js +4 -0
  40. package/dist/cli.d.ts.map +1 -1
  41. package/dist/cli.js +8 -0
  42. package/dist/config.d.ts +31 -0
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +23 -0
  45. package/dist/doctor-cli.d.ts +7 -0
  46. package/dist/doctor-cli.d.ts.map +1 -0
  47. package/dist/doctor-cli.js +67 -0
  48. package/dist/doctor-preflight.d.ts +52 -0
  49. package/dist/doctor-preflight.d.ts.map +1 -0
  50. package/dist/doctor-preflight.js +112 -0
  51. package/dist/feedback/grade.d.ts +8 -1
  52. package/dist/feedback/grade.d.ts.map +1 -1
  53. package/dist/feedback/grade.js +4 -0
  54. package/dist/gateway/http-protocol.d.ts +19 -0
  55. package/dist/gateway/http-protocol.d.ts.map +1 -1
  56. package/dist/gateway/serve-client.d.ts +99 -0
  57. package/dist/gateway/serve-client.d.ts.map +1 -0
  58. package/dist/gateway/serve-client.js +360 -0
  59. package/dist/index.d.ts +25 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +62 -8
  62. package/dist/prompts/manifest.d.ts +128 -0
  63. package/dist/prompts/manifest.d.ts.map +1 -0
  64. package/dist/prompts/manifest.js +214 -0
  65. package/dist/prompts/prompt-fetch.d.ts +84 -0
  66. package/dist/prompts/prompt-fetch.d.ts.map +1 -0
  67. package/dist/prompts/prompt-fetch.js +120 -0
  68. package/dist/prompts/prompt-resolve.d.ts +76 -0
  69. package/dist/prompts/prompt-resolve.d.ts.map +1 -0
  70. package/dist/prompts/prompt-resolve.js +93 -0
  71. package/dist/prompts/slot-resolver.d.ts +91 -0
  72. package/dist/prompts/slot-resolver.d.ts.map +1 -0
  73. package/dist/prompts/slot-resolver.js +135 -0
  74. package/dist/prompts/tools-register.d.ts +60 -0
  75. package/dist/prompts/tools-register.d.ts.map +1 -0
  76. package/dist/prompts/tools-register.js +48 -0
  77. package/dist/prompts/version-hash.d.ts +29 -0
  78. package/dist/prompts/version-hash.d.ts.map +1 -0
  79. package/dist/prompts/version-hash.js +54 -0
  80. package/dist/prompts-export-cli.d.ts +21 -0
  81. package/dist/prompts-export-cli.d.ts.map +1 -0
  82. package/dist/prompts-export-cli.js +130 -0
  83. package/dist/registry/cache-policy.d.ts.map +1 -1
  84. package/dist/registry/cache-policy.js +22 -0
  85. package/dist/registry/pricing-shape.d.ts +38 -8
  86. package/dist/registry/pricing-shape.d.ts.map +1 -1
  87. package/dist/registry/pricing-shape.js +40 -12
  88. package/dist/registry/pricing.d.ts +6 -5
  89. package/dist/registry/pricing.d.ts.map +1 -1
  90. package/dist/registry/pricing.js +9 -5
  91. package/dist/routes/destination-loader.d.ts +16 -0
  92. package/dist/routes/destination-loader.d.ts.map +1 -0
  93. package/dist/routes/destination-loader.js +29 -0
  94. package/dist/routes/draft.d.ts +7 -0
  95. package/dist/routes/draft.d.ts.map +1 -1
  96. package/dist/routes/draft.js +12 -0
  97. package/dist/routes/loader.d.ts.map +1 -1
  98. package/dist/routes/loader.js +27 -54
  99. package/dist/routes/output-loader.d.ts +42 -0
  100. package/dist/routes/output-loader.d.ts.map +1 -0
  101. package/dist/routes/output-loader.js +112 -0
  102. package/dist/routes/prompt-loader.d.ts +49 -0
  103. package/dist/routes/prompt-loader.d.ts.map +1 -0
  104. package/dist/routes/prompt-loader.js +113 -0
  105. package/dist/routes/resolved-bundle.d.ts +19 -0
  106. package/dist/routes/resolved-bundle.d.ts.map +1 -1
  107. package/dist/routes/resolved-bundle.js +24 -0
  108. package/dist/routes/screen-loader.d.ts +1 -1
  109. package/dist/routes/screen-loader.d.ts.map +1 -1
  110. package/dist/routes/screen-loader.js +8 -1
  111. package/dist/run/accept.d.ts +3 -0
  112. package/dist/run/accept.d.ts.map +1 -1
  113. package/dist/run/accept.js +1 -0
  114. package/dist/run/cost.d.ts +31 -2
  115. package/dist/run/cost.d.ts.map +1 -1
  116. package/dist/run/cost.js +57 -2
  117. package/dist/run/destination.d.ts +39 -0
  118. package/dist/run/destination.d.ts.map +1 -0
  119. package/dist/run/destination.js +45 -0
  120. package/dist/run/dispatch.d.ts +25 -3
  121. package/dist/run/dispatch.d.ts.map +1 -1
  122. package/dist/run/dispatch.js +26 -4
  123. package/dist/run/raw-defaults.d.ts.map +1 -1
  124. package/dist/run/raw-defaults.js +6 -1
  125. package/dist/run/raw-finalize.d.ts +50 -0
  126. package/dist/run/raw-finalize.d.ts.map +1 -0
  127. package/dist/run/raw-finalize.js +266 -0
  128. package/dist/run/raw-knobs.d.ts +36 -0
  129. package/dist/run/raw-knobs.d.ts.map +1 -0
  130. package/dist/run/raw-knobs.js +99 -0
  131. package/dist/run/raw-request.d.ts +24 -0
  132. package/dist/run/raw-request.d.ts.map +1 -0
  133. package/dist/run/raw-request.js +69 -0
  134. package/dist/run/raw-schema.d.ts +76 -0
  135. package/dist/run/raw-schema.d.ts.map +1 -0
  136. package/dist/run/raw-schema.js +166 -0
  137. package/dist/run/raw-search-cost.d.ts +48 -0
  138. package/dist/run/raw-search-cost.d.ts.map +1 -0
  139. package/dist/run/raw-search-cost.js +78 -0
  140. package/dist/run/raw-support.d.ts +64 -6
  141. package/dist/run/raw-support.d.ts.map +1 -1
  142. package/dist/run/raw-support.js +84 -11
  143. package/dist/run/raw.d.ts +25 -26
  144. package/dist/run/raw.d.ts.map +1 -1
  145. package/dist/run/raw.js +30 -351
  146. package/dist/run/record-attempt.d.ts +8 -0
  147. package/dist/run/record-attempt.d.ts.map +1 -1
  148. package/dist/run/record-attempt.js +26 -12
  149. package/dist/run/repair-attempt.d.ts +68 -0
  150. package/dist/run/repair-attempt.d.ts.map +1 -0
  151. package/dist/run/repair-attempt.js +180 -0
  152. package/dist/run/resolve-destination.d.ts +49 -0
  153. package/dist/run/resolve-destination.d.ts.map +1 -0
  154. package/dist/run/resolve-destination.js +76 -0
  155. package/dist/run/routing-docs.d.ts.map +1 -1
  156. package/dist/run/routing-docs.js +9 -4
  157. package/dist/run/run.d.ts +30 -1
  158. package/dist/run/run.d.ts.map +1 -1
  159. package/dist/run/run.js +75 -148
  160. package/dist/run/telemetry-row.d.ts +92 -0
  161. package/dist/run/telemetry-row.d.ts.map +1 -0
  162. package/dist/run/telemetry-row.js +81 -0
  163. package/dist/run/validate.d.ts +12 -1
  164. package/dist/run/validate.d.ts.map +1 -1
  165. package/dist/run/validate.js +31 -0
  166. package/dist/run/web-search-pricing.d.ts +43 -0
  167. package/dist/run/web-search-pricing.d.ts.map +1 -0
  168. package/dist/run/web-search-pricing.js +56 -0
  169. package/dist/settings/grading-guide.d.ts +27 -1
  170. package/dist/settings/grading-guide.d.ts.map +1 -1
  171. package/dist/status.d.ts +6 -0
  172. package/dist/status.d.ts.map +1 -1
  173. package/dist/status.js +4 -1
  174. package/dist/telemetry/artifact-store.d.ts.map +1 -1
  175. package/dist/telemetry/artifact-store.js +11 -0
  176. package/dist/telemetry/attempt-meta.d.ts +55 -1
  177. package/dist/telemetry/attempt-meta.d.ts.map +1 -1
  178. package/dist/telemetry/attempt-meta.js +24 -1
  179. package/dist/telemetry/exporter-setup.d.ts +2 -0
  180. package/dist/telemetry/exporter-setup.d.ts.map +1 -1
  181. package/dist/telemetry/exporter-setup.js +6 -1
  182. package/dist/telemetry/grade-mappers.d.ts +5 -2
  183. package/dist/telemetry/grade-mappers.d.ts.map +1 -1
  184. package/dist/telemetry/grade-mappers.js +8 -2
  185. package/dist/telemetry/grades-sql.d.ts +4 -1
  186. package/dist/telemetry/grades-sql.d.ts.map +1 -1
  187. package/dist/telemetry/grades-sql.js +26 -3
  188. package/dist/telemetry/ingest-protocol.d.ts +26 -2
  189. package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
  190. package/dist/telemetry/ingest-protocol.js +32 -29
  191. package/dist/telemetry/org-identity.d.ts +44 -0
  192. package/dist/telemetry/org-identity.d.ts.map +1 -0
  193. package/dist/telemetry/org-identity.js +98 -0
  194. package/dist/telemetry/route-registration.d.ts +48 -0
  195. package/dist/telemetry/route-registration.d.ts.map +1 -0
  196. package/dist/telemetry/route-registration.js +77 -0
  197. package/dist/telemetry/sinks.d.ts +10 -1
  198. package/dist/telemetry/sinks.d.ts.map +1 -1
  199. package/dist/telemetry/sinks.js +52 -6
  200. package/dist/telemetry/store-migrations.d.ts.map +1 -1
  201. package/dist/telemetry/store-migrations.js +13 -0
  202. package/dist/tenancy/api-key-format.d.ts +16 -1
  203. package/dist/tenancy/api-key-format.d.ts.map +1 -1
  204. package/dist/tenancy/api-key-format.js +17 -0
  205. package/dist/types/provider.d.ts +20 -3
  206. package/dist/types/provider.d.ts.map +1 -1
  207. package/dist/types/provider.js +1 -0
  208. package/dist/types/route.d.ts +76 -0
  209. package/dist/types/route.d.ts.map +1 -1
  210. package/dist/types/telemetry.d.ts +30 -2
  211. package/dist/types/telemetry.d.ts.map +1 -1
  212. package/docs/agent-skill/SKILL.md +73 -5
  213. package/docs/instrumentation.md +81 -36
  214. package/docs/llms.txt +95 -16
  215. package/docs/managed-serving.md +150 -0
  216. package/docs/mcp-oracle.md +75 -2
  217. package/docs/migration-playbook.md +5 -4
  218. package/docs/quickstart.md +169 -83
  219. package/package.json +3 -2
  220. package/registry/registry.json +82 -0
  221. package/dist/feedback/feedback.d.ts +0 -35
  222. package/dist/feedback/feedback.d.ts.map +0 -1
  223. package/dist/feedback/feedback.js +0 -39
@@ -31,6 +31,7 @@
31
31
  * holds a credential that can write any row in the database.
32
32
  */
33
33
  import type { FailureClass } from "../types/failures";
34
+ import type { EvalCaseOrigin } from "../types/telemetry";
34
35
  import type { ResolvedRouteBundle } from "../routes/resolved-bundle";
35
36
  export { foreignOrgGrades } from "./grade-mappers";
36
37
  /** The path the api sink posts to. Spelled once. */
@@ -129,6 +130,20 @@ export interface WireGrade {
129
130
  readonly ts: string | null;
130
131
  /** The grade's OWN org, when it differs from the exporter's (feedback doctrine). */
131
132
  readonly org_id?: string;
133
+ /** OPTIONAL per-criterion breakdown (call-qa F4). Carried on the wire so a
134
+ * client-recorded HUMAN scorecard reaches the server, which fans it out to
135
+ * `grade_criteria` (kind=human) after the parent grades row lands. NOT written
136
+ * to `public.grades` (no column there — `gradeToRow` drops it). Absent ⇒ a
137
+ * single-score grade. `turn_id` is optional on each evidence citation. */
138
+ readonly criteria?: readonly {
139
+ readonly id: string;
140
+ readonly score: number;
141
+ readonly evidence?: readonly {
142
+ readonly quote: string;
143
+ readonly turn_id?: number;
144
+ }[];
145
+ readonly comment?: string;
146
+ }[];
132
147
  }
133
148
  export interface WireEnvelope {
134
149
  readonly envelope_key: string;
@@ -244,7 +259,7 @@ export interface WireEvalCase {
244
259
  readonly task: string;
245
260
  readonly source_artifact_id: string;
246
261
  readonly corrected_artifact_id: string | null;
247
- readonly origin: "promoted-failure" | "human-corrected" | "manual";
262
+ readonly origin: EvalCaseOrigin;
248
263
  readonly note: string | null;
249
264
  readonly created_by: string | null;
250
265
  }
@@ -305,7 +320,16 @@ export interface TableWrite {
305
320
  * telemetry row. If you are about to add a table to the export, add it here
306
321
  * and both modes gain it at once — which is the point.
307
322
  */
308
- export declare function stampBatch(batch: IngestBatch, tenancy: Tenancy): TableWrite[];
323
+ /** How `stampBatch` treats route bundles. `declaredBundles` (the HOSTED ingest,
324
+ * RV-1): a bundle that arrived over `/v1/ingest` is stored as route CONFIG with
325
+ * `synced_at = null` — readable for pins/effective/bake-offs, but never picked
326
+ * by the hosted gateway, which serves only `synced_at`-stamped bundles (written
327
+ * by a trusted sync path). An `ingest`-scoped key must not decide what the
328
+ * gateway serves. Absent ⇒ the direct-mode behaviour (`synced_at = now`). */
329
+ export interface StampOptions {
330
+ readonly declaredBundles?: boolean;
331
+ }
332
+ export declare function stampBatch(batch: IngestBatch, tenancy: Tenancy, opts?: StampOptions): TableWrite[];
309
333
  /** What `/v1/ingest` answers. Counts only — a per-row error list on a
310
334
  * fire-and-forget telemetry path is a payload nobody reads and a leak surface
311
335
  * nobody audits. */
@@ -1 +1 @@
1
- {"version":3,"file":"ing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AAC,CAAC;IACnD;qCACiC;IACjC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD"}
@@ -52,14 +52,7 @@ exports.INGEST_PROTOCOL_VERSION = 2;
52
52
  exports.INGEST_PROTOCOL_VERSION_V1 = 1;
53
53
  /** Default ingest host — telemetry-ingestion-boundary.md §2.1. */
54
54
  exports.DEFAULT_INGEST_URL = "https://api.modelrig.ai";
55
- /**
56
- * Turn a batch plus a tenant into the writes it becomes.
57
- *
58
- * THE conformance seam. Both transports call this; nothing else builds a
59
- * telemetry row. If you are about to add a table to the export, add it here
60
- * and both modes gain it at once — which is the point.
61
- */
62
- function stampBatch(batch, tenancy) {
55
+ function stampBatch(batch, tenancy, opts = {}) {
63
56
  const writes = [];
64
57
  const now = new Date().toISOString();
65
58
  if (batch.routes !== undefined && batch.routes.length > 0) {
@@ -103,28 +96,38 @@ function stampBatch(batch, tenancy) {
103
96
  merge: true,
104
97
  rows: taskRows,
105
98
  });
106
- writes.push({
107
- table: "routes",
108
- onConflict: "org_id,route,version",
109
- merge: true,
110
- rows: batch.routes.map((r) => ({
111
- org_id: tenancy.org_id,
112
- route: r.route,
113
- version: r.version,
114
- candidates: r.candidates,
115
- capture: r.capture,
116
- updated_at: now,
117
- // Phase D (spec §13): the resolved bundle + its hash + the sync stamp.
118
- // Written only when the batch carries a bundle, so an older SDK's
119
- // metadata-only mirror leaves any existing bundle intact (a merge
120
- // upsert touches only the columns present in the row). `synced_at` is
121
- // the BUNDLE's timestamp — stamped iff a bundle synced — distinct from
122
- // `updated_at`, the row's metadata timestamp.
123
- ...(r.bundle !== undefined
124
- ? { bundle: r.bundle, bundle_sha: r.bundle_sha ?? null, synced_at: now }
125
- : {}),
126
- })),
99
+ const routeRow = (r) => ({
100
+ org_id: tenancy.org_id,
101
+ route: r.route,
102
+ version: r.version,
103
+ candidates: r.candidates,
104
+ capture: r.capture,
105
+ updated_at: now,
106
+ // Phase D (spec §13): the resolved bundle + its hash + the sync stamp.
107
+ // Written only when the route carries a bundle, so an older SDK's
108
+ // metadata-only mirror leaves any existing bundle intact (a merge
109
+ // upsert touches only the columns present in the row). `synced_at` is
110
+ // the BUNDLE's timestamp — stamped iff a bundle synced through a trusted
111
+ // path — distinct from `updated_at`, the row's metadata timestamp.
112
+ ...(r.bundle !== undefined
113
+ ? { bundle: r.bundle, bundle_sha: r.bundle_sha ?? null, synced_at: opts.declaredBundles === true ? null : now }
114
+ : {}),
127
115
  });
116
+ // TWO writes, split by bundle presence: a PostgREST bulk insert requires
117
+ // every row to carry the SAME keys (PGRST102), so one route whose bundle was
118
+ // dropped must not fail — or null out — its neighbours' bundles.
119
+ const withBundle = batch.routes.filter((r) => r.bundle !== undefined);
120
+ const withoutBundle = batch.routes.filter((r) => r.bundle === undefined);
121
+ for (const group of [withBundle, withoutBundle]) {
122
+ if (group.length === 0)
123
+ continue;
124
+ writes.push({
125
+ table: "routes",
126
+ onConflict: "org_id,route,version",
127
+ merge: true,
128
+ rows: group.map(routeRow),
129
+ });
130
+ }
128
131
  }
129
132
  if (batch.runs !== undefined && batch.runs.length > 0) {
130
133
  writes.push({
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The first-flush org line + the `expectOrg` mismatch signal (REL-1, ruling M5).
3
+ *
4
+ * A VALID key minted in the WRONG org is the failure the AUTH FAILED latch in
5
+ * sinks.ts cannot see: every POST is a 200, and the runs land in someone else's
6
+ * console. (Six weeks of InferWealth pipeline telemetry went to Nunexa this
7
+ * way.) So on the first successful flush in each process the api sink asks
8
+ * `GET /v1/whoami` once — through the same `whoamiPreflight` helper that
9
+ * `modelrig doctor` uses — and logs which org it is exporting to:
10
+ *
11
+ * [modelrig] exporting to org «InferWealth» (inferwealth) as key «InferWealth2» …ab12
12
+ *
13
+ * With `createRig({ expectOrg: "<slug>" })` a different resolved slug logs
14
+ * `ORG MISMATCH` loudly on EVERY successful flush (ruling M5), because nobody
15
+ * reads boot logs. It is a code option, not an env var (P15).
16
+ *
17
+ * Contract: non-blocking (never awaited by the sink), once per process per
18
+ * key, never throws, never drops or delays telemetry. A failed whoami is
19
+ * SILENT: a 401 already has its own loud line, and a network blip must not
20
+ * become noise.
21
+ */
22
+ import { type PreflightResult } from "../doctor-preflight";
23
+ /** The whoami call is aborted after this long, so it can never hold a
24
+ * process open (AbortSignal.timeout's timer is unref'd by Node). */
25
+ export declare const WHOAMI_TIMEOUT_MS = 5000;
26
+ /** TESTS ONLY — forget every key, so "once per process" cases are independent. */
27
+ export declare function __resetOrgIdentityForTest(): void;
28
+ export interface OrgIdentityInput {
29
+ readonly ingestUrl: string;
30
+ readonly apiKey: string;
31
+ readonly expectOrg?: string;
32
+ readonly fetchFn: typeof fetch;
33
+ /** Override WHOAMI_TIMEOUT_MS (tests). */
34
+ readonly timeoutMs?: number;
35
+ }
36
+ /** Build the one-line org banner from a successful whoami. */
37
+ export declare function formatOrgLine(result: PreflightResult, apiKey: string): string;
38
+ /**
39
+ * Record one successful flush. Returns immediately; the whoami (first flush
40
+ * only) runs in the background. Exposed as a promise-returning helper ONLY so
41
+ * tests can await the background work — the sink calls it with `void`.
42
+ */
43
+ export declare function noteSuccessfulFlush(input: OrgIdentityInput): Promise<void>;
44
+ //# sourceMappingURL=org-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-identity.d.ts","sourceRoot":"","sources":["../../src/telemetry/org-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAwC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGjG;oEACoE;AACpE,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAYtC,kFAAkF;AAClF,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAO7E;AAgBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B1E"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WHOAMI_TIMEOUT_MS = void 0;
4
+ exports.__resetOrgIdentityForTest = __resetOrgIdentityForTest;
5
+ exports.formatOrgLine = formatOrgLine;
6
+ exports.noteSuccessfulFlush = noteSuccessfulFlush;
7
+ /**
8
+ * The first-flush org line + the `expectOrg` mismatch signal (REL-1, ruling M5).
9
+ *
10
+ * A VALID key minted in the WRONG org is the failure the AUTH FAILED latch in
11
+ * sinks.ts cannot see: every POST is a 200, and the runs land in someone else's
12
+ * console. (Six weeks of InferWealth pipeline telemetry went to Nunexa this
13
+ * way.) So on the first successful flush in each process the api sink asks
14
+ * `GET /v1/whoami` once — through the same `whoamiPreflight` helper that
15
+ * `modelrig doctor` uses — and logs which org it is exporting to:
16
+ *
17
+ * [modelrig] exporting to org «InferWealth» (inferwealth) as key «InferWealth2» …ab12
18
+ *
19
+ * With `createRig({ expectOrg: "<slug>" })` a different resolved slug logs
20
+ * `ORG MISMATCH` loudly on EVERY successful flush (ruling M5), because nobody
21
+ * reads boot logs. It is a code option, not an env var (P15).
22
+ *
23
+ * Contract: non-blocking (never awaited by the sink), once per process per
24
+ * key, never throws, never drops or delays telemetry. A failed whoami is
25
+ * SILENT: a 401 already has its own loud line, and a network blip must not
26
+ * become noise.
27
+ */
28
+ const doctor_preflight_1 = require("../doctor-preflight");
29
+ const api_key_format_1 = require("../tenancy/api-key-format");
30
+ /** The whoami call is aborted after this long, so it can never hold a
31
+ * process open (AbortSignal.timeout's timer is unref'd by Node). */
32
+ exports.WHOAMI_TIMEOUT_MS = 5000;
33
+ /** Keyed by ingest origin + key, so two rigs sharing a key share one whoami. */
34
+ const states = new Map();
35
+ /** TESTS ONLY — forget every key, so "once per process" cases are independent. */
36
+ function __resetOrgIdentityForTest() {
37
+ states.clear();
38
+ }
39
+ /** Build the one-line org banner from a successful whoami. */
40
+ function formatOrgLine(result, apiKey) {
41
+ const org = result.whoami?.org ?? null;
42
+ const name = org?.name ?? org?.id ?? "?";
43
+ const slug = org?.slug ?? "?";
44
+ const keyName = result.whoami?.key?.name;
45
+ const keyLabel = typeof keyName === "string" && keyName !== "" ? `«${keyName}» ` : "";
46
+ return `[modelrig] exporting to org «${name}» (${slug}) as key ${keyLabel}${(0, api_key_format_1.redactApiKey)(apiKey)}`;
47
+ }
48
+ function mismatchLine(actual, expectOrg) {
49
+ return (`[modelrig] ORG MISMATCH: key resolves to «${actual}», expectOrg is «${expectOrg}» — ` +
50
+ `telemetry is landing in «${actual}»`);
51
+ }
52
+ function warnIfMismatch(result, expectOrg) {
53
+ const expected = expectOrg?.trim();
54
+ if (expected === undefined || expected === "")
55
+ return;
56
+ const actual = (0, doctor_preflight_1.expectedOrgMismatch)(result, expected);
57
+ if (actual !== null)
58
+ console.warn(mismatchLine(actual, expected));
59
+ }
60
+ /**
61
+ * Record one successful flush. Returns immediately; the whoami (first flush
62
+ * only) runs in the background. Exposed as a promise-returning helper ONLY so
63
+ * tests can await the background work — the sink calls it with `void`.
64
+ */
65
+ function noteSuccessfulFlush(input) {
66
+ let origin;
67
+ try {
68
+ origin = new URL(input.ingestUrl).origin;
69
+ }
70
+ catch {
71
+ return Promise.resolve();
72
+ }
73
+ const id = `${origin}|${input.apiKey}`;
74
+ let state = states.get(id);
75
+ if (state === undefined) {
76
+ state = { flushes: 0, resolved: null };
77
+ states.set(id, state);
78
+ }
79
+ state.flushes += 1;
80
+ const s = state;
81
+ if (s.flushes === 1) {
82
+ return (0, doctor_preflight_1.whoamiPreflight)(input.ingestUrl, input.apiKey, input.fetchFn, AbortSignal.timeout(input.timeoutMs ?? exports.WHOAMI_TIMEOUT_MS))
83
+ .then((result) => {
84
+ if (!result.ok)
85
+ return; // silent: a 401 has its own loud line
86
+ s.resolved = result;
87
+ console.log(formatOrgLine(result, input.apiKey));
88
+ warnIfMismatch(result, input.expectOrg);
89
+ })
90
+ .catch(() => {
91
+ // whoamiPreflight never throws, and logging must never break the sink.
92
+ });
93
+ }
94
+ // M5: loud on EVERY flush once the org is known (flush 1 warns when whoami lands).
95
+ if (s.resolved !== null)
96
+ warnIfMismatch(s.resolved, input.expectOrg);
97
+ return Promise.resolve();
98
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * RV-1 declare-on-startup — a rig with routes AND a control plane tells the
3
+ * control plane which routes it serves the moment it is created, so a route is
4
+ * visible (console, MCP `get_call_config`, `GET /v1/routes/:route/call-config
5
+ * ?include=effective`) BEFORE its first call.
6
+ *
7
+ * ── WHY A SEPARATE ONE-SHOT, WHEN THE EXPORTER ALREADY MIRRORS ROUTES ─────
8
+ * The exporter folds the routes mirror into its FIRST flush (one interval —
9
+ * 10s — after start). A short-lived process (a CLI, a cron, a lazily-built
10
+ * pipeline rig) that exits before that tick without `close()` never mirrors, and
11
+ * a long-lived one is invisible for the first interval. This sends the same
12
+ * metadata once, immediately. The exporter's header stays as the at-least-once
13
+ * retry path: the routes upsert is a merge on (org_id, route, version), so the
14
+ * duplicate is harmless.
15
+ *
16
+ * ── WHAT IT CARRIES (and does not) ────────────────────────────────────────
17
+ * route, version, candidates (provider/model), capture flag, AND the declared
18
+ * resolved bundle + its `bundle_sha` — the same payload the exporter's
19
+ * first-flush mirror has always carried (Matt's RV-1 ruling 1, 2026-10-10). The
20
+ * bundle is ROUTE CONFIGURATION (the authored prompt TEMPLATE with its
21
+ * placeholders, schema, candidates, policy — never per-call values); the control
22
+ * plane needs it so a call-config pin passes the eligibility gate (`loadBundle`)
23
+ * on a mirror-mode server. The server re-validates the bundle and recomputes the
24
+ * sha; once a PSR prompt has been promoted for the route, PSR's template wins
25
+ * over the declared one (modelrig-server ingest-route-config.ts). The org is
26
+ * never on the wire — the server stamps it from the key's principal (T3/T11).
27
+ * It travels through the SAME sink as telemetry, so in `api` mode it is a
28
+ * `POST /v1/ingest` with the rig's own key and needs only the `ingest` scope.
29
+ *
30
+ * ── FAIL-OPEN BY CONSTRUCTION ─────────────────────────────────────────────
31
+ * Fire-and-forget. Never awaited by createRig, never throws (sync or async),
32
+ * one console.warn on failure. It cannot change what THIS process serves (the
33
+ * SDK serves from its local bundles); it writes only the control-plane `routes`
34
+ * mirror, exactly as the exporter's first flush already does.
35
+ */
36
+ import type { IngestBatch } from "./ingest-protocol";
37
+ import type { ExportedRouteMirror } from "./exporter";
38
+ import type { TelemetrySink } from "./sinks";
39
+ /** The routes-only batch (metadata + declared bundle). v1 so any server vintage
40
+ * accepts it (an older server keeps the metadata and ignores the bundle). */
41
+ export declare function buildRouteRegistrationBatch(sourceId: string, routes: readonly ExportedRouteMirror[]): IngestBatch;
42
+ /**
43
+ * Register `routes` with the control plane through `sink`, once, now. Returns
44
+ * the in-flight promise (always resolves — for tests and callers that want to
45
+ * await it); createRig ignores it. No routes ⇒ no request.
46
+ */
47
+ export declare function registerRoutesOnStartup(sink: TelemetrySink, sourceId: string, routes: readonly ExportedRouteMirror[]): Promise<void>;
48
+ //# sourceMappingURL=route-registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-registration.d.ts","sourceRoot":"","sources":["../../src/telemetry/route-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;6EAC6E;AAC7E,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,mBAAmB,EAAE,GACrC,WAAW,CAYb;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,mBAAmB,EAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /**
3
+ * RV-1 declare-on-startup — a rig with routes AND a control plane tells the
4
+ * control plane which routes it serves the moment it is created, so a route is
5
+ * visible (console, MCP `get_call_config`, `GET /v1/routes/:route/call-config
6
+ * ?include=effective`) BEFORE its first call.
7
+ *
8
+ * ── WHY A SEPARATE ONE-SHOT, WHEN THE EXPORTER ALREADY MIRRORS ROUTES ─────
9
+ * The exporter folds the routes mirror into its FIRST flush (one interval —
10
+ * 10s — after start). A short-lived process (a CLI, a cron, a lazily-built
11
+ * pipeline rig) that exits before that tick without `close()` never mirrors, and
12
+ * a long-lived one is invisible for the first interval. This sends the same
13
+ * metadata once, immediately. The exporter's header stays as the at-least-once
14
+ * retry path: the routes upsert is a merge on (org_id, route, version), so the
15
+ * duplicate is harmless.
16
+ *
17
+ * ── WHAT IT CARRIES (and does not) ────────────────────────────────────────
18
+ * route, version, candidates (provider/model), capture flag, AND the declared
19
+ * resolved bundle + its `bundle_sha` — the same payload the exporter's
20
+ * first-flush mirror has always carried (Matt's RV-1 ruling 1, 2026-10-10). The
21
+ * bundle is ROUTE CONFIGURATION (the authored prompt TEMPLATE with its
22
+ * placeholders, schema, candidates, policy — never per-call values); the control
23
+ * plane needs it so a call-config pin passes the eligibility gate (`loadBundle`)
24
+ * on a mirror-mode server. The server re-validates the bundle and recomputes the
25
+ * sha; once a PSR prompt has been promoted for the route, PSR's template wins
26
+ * over the declared one (modelrig-server ingest-route-config.ts). The org is
27
+ * never on the wire — the server stamps it from the key's principal (T3/T11).
28
+ * It travels through the SAME sink as telemetry, so in `api` mode it is a
29
+ * `POST /v1/ingest` with the rig's own key and needs only the `ingest` scope.
30
+ *
31
+ * ── FAIL-OPEN BY CONSTRUCTION ─────────────────────────────────────────────
32
+ * Fire-and-forget. Never awaited by createRig, never throws (sync or async),
33
+ * one console.warn on failure. It cannot change what THIS process serves (the
34
+ * SDK serves from its local bundles); it writes only the control-plane `routes`
35
+ * mirror, exactly as the exporter's first flush already does.
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.buildRouteRegistrationBatch = buildRouteRegistrationBatch;
39
+ exports.registerRoutesOnStartup = registerRoutesOnStartup;
40
+ const ingest_protocol_1 = require("./ingest-protocol");
41
+ /** The routes-only batch (metadata + declared bundle). v1 so any server vintage
42
+ * accepts it (an older server keeps the metadata and ignores the bundle). */
43
+ function buildRouteRegistrationBatch(sourceId, routes) {
44
+ return {
45
+ v: ingest_protocol_1.INGEST_PROTOCOL_VERSION_V1,
46
+ source: sourceId,
47
+ routes: routes.map((r) => ({
48
+ route: r.route,
49
+ version: r.version,
50
+ candidates: r.candidates.map((c) => ({ provider: c.provider, model: c.model })),
51
+ capture: r.capture ?? false,
52
+ ...(r.bundle !== undefined ? { bundle: r.bundle, bundle_sha: r.bundleSha } : {}),
53
+ })),
54
+ };
55
+ }
56
+ /**
57
+ * Register `routes` with the control plane through `sink`, once, now. Returns
58
+ * the in-flight promise (always resolves — for tests and callers that want to
59
+ * await it); createRig ignores it. No routes ⇒ no request.
60
+ */
61
+ function registerRoutesOnStartup(sink, sourceId, routes) {
62
+ if (routes.length === 0)
63
+ return Promise.resolve();
64
+ let batch;
65
+ try {
66
+ batch = buildRouteRegistrationBatch(sourceId, routes);
67
+ }
68
+ catch {
69
+ return Promise.resolve();
70
+ }
71
+ return Promise.resolve()
72
+ .then(() => sink.send(batch))
73
+ .catch((err) => {
74
+ console.warn(`[modelrig] route registration (declare-on-startup) failed — routes will still be mirrored ` +
75
+ `by the exporter's first flush: ${err instanceof Error ? err.message : String(err)}`);
76
+ });
77
+ }
@@ -21,6 +21,9 @@
21
21
  */
22
22
  import type { IngestBatch, IngestOutcome, Tenancy } from "./ingest-protocol";
23
23
  import type { ApiExportConfig, DirectExportConfig } from "../config";
24
+ /** Reset the auth-failure latch — TESTS ONLY, so warn-once cases are independent
25
+ * of run order (mirrors deprecations.ts). */
26
+ export declare function __resetApiSinkWarningsForTest(): void;
24
27
  export interface TelemetrySink {
25
28
  /** Named so a boot banner and `/status` can say which lane is live without
26
29
  * inspecting config — the "which mode am I in?" question got asked enough
@@ -77,6 +80,10 @@ export interface ApiSinkConfig {
77
80
  * rows are being dropped must hear about it from their own process rather
78
81
  * than by noticing a gap in a chart weeks later. */
79
82
  readonly onOutcome?: (outcome: IngestOutcome) => void;
83
+ /** `createRig({ expectOrg })` (M5): the org slug this process expects its key
84
+ * to resolve to. A mismatch logs ORG MISMATCH on every flush (org-identity.ts);
85
+ * it never throws and never drops telemetry. */
86
+ readonly expectOrg?: string;
80
87
  }
81
88
  export declare function createApiSink(config: ApiSinkConfig): TelemetrySink;
82
89
  /**
@@ -86,5 +93,7 @@ export declare function createApiSink(config: ApiSinkConfig): TelemetrySink;
86
93
  * index.ts until Phase D; moved here — its natural home — to keep that file
87
94
  * under the LOC cap.)
88
95
  */
89
- export declare function buildTelemetrySink(exportConfig: ApiExportConfig | DirectExportConfig, sourceId: string): TelemetrySink;
96
+ export declare function buildTelemetrySink(exportConfig: ApiExportConfig | DirectExportConfig, sourceId: string, opts?: {
97
+ readonly expectOrg?: string;
98
+ }): TelemetrySink;
90
99
  //# sourceMappingURL=sinks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sinks.d.ts","sourceRoot":"","sources":["../../src/telemetry/sinks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,E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;AAMD,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;4EACwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IAChC;;;wDAGoD;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IACtD;;oDAEgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAsElE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,eAAe,GAAG,kBAAkB,EAClD,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACzC,aAAa,CA2Bf"}
@@ -22,12 +22,33 @@
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.SinkSendError = void 0;
25
+ exports.__resetApiSinkWarningsForTest = __resetApiSinkWarningsForTest;
25
26
  exports.createDirectSink = createDirectSink;
26
27
  exports.createApiSink = createApiSink;
27
28
  exports.buildTelemetrySink = buildTelemetrySink;
28
29
  const node_zlib_1 = require("node:zlib");
29
30
  const ingest_protocol_1 = require("./ingest-protocol");
30
31
  const constants_1 = require("../tenancy/constants");
32
+ const api_key_format_1 = require("../tenancy/api-key-format");
33
+ const org_identity_1 = require("./org-identity");
34
+ /**
35
+ * Auth-failure latch (once per FAILURE STREAK, not once per process).
36
+ *
37
+ * A 401/403 from ingest means the key is rejected and EVERY run is being dropped
38
+ * org-wide — categorically different from a single poison batch (422), and the
39
+ * exact silent failure that cost InferWealth days of invisible telemetry. The
40
+ * export path is fire-and-forget, so the only way this surfaces is a log line —
41
+ * and it must be loud, legible, and NOT drowned in per-batch noise. We warn ONCE
42
+ * and latch; a subsequent successful send clears the latch, so if the key breaks
43
+ * again later it re-alerts. No env var, no extra request — it rides the POST that
44
+ * is already failing.
45
+ */
46
+ let apiAuthFailureWarned = false;
47
+ /** Reset the auth-failure latch — TESTS ONLY, so warn-once cases are independent
48
+ * of run order (mirrors deprecations.ts). */
49
+ function __resetApiSinkWarningsForTest() {
50
+ apiAuthFailureWarned = false;
51
+ }
31
52
  /**
32
53
  * A sink send failed — the typed error both transports throw (E2 hardening
33
54
  * Phase 2, spec §2.3.1). It carries the HTTP status the sink observed (absent
@@ -127,14 +148,38 @@ function createApiSink(config) {
127
148
  throw new SinkSendError("ingest POST → network error", undefined);
128
149
  }
129
150
  if (!response.ok) {
130
- // Status only — never the response body. The key never appears in the
131
- // message (C2's leak gate covers failure text), and an exporter's
132
- // warnings are the likeliest place for a secret to reach someone else's
133
- // log aggregator. The status is the exporter's transient-vs-poison
134
- // signal: the server sends 422 for a deterministic control-plane
151
+ // A rejected KEY (401/403) is not one bad batch — it means every run is
152
+ // being dropped org-wide, silently. Say so, loudly, ONCE per failure
153
+ // streak. Safe to name here: the host is the public ingest endpoint and
154
+ // `redactApiKey` is the sanctioned last-four form (the same one the boot
155
+ // banner and `modelrig doctor` print) — never the body, never the secret.
156
+ if ((response.status === 401 || response.status === 403) && !apiAuthFailureWarned) {
157
+ apiAuthFailureWarned = true;
158
+ console.warn(`[modelrig] AUTH FAILED — telemetry is being DROPPED (${response.status} at ` +
159
+ `${new URL(url).origin}, key ${(0, api_key_format_1.redactApiKey)(config.apiKey)}). MODELRIG_API_KEY is not ` +
160
+ "accepted by this server/org; check the key and that it belongs to the org you expect " +
161
+ "at app.modelrig.ai. Runs will not appear until this is fixed. Confirm with `modelrig doctor`.");
162
+ }
163
+ // Status only in the THROWN error — never the response body. The key never
164
+ // appears in the message (C2's leak gate covers failure text), and an
165
+ // exporter's warnings are the likeliest place for a secret to reach
166
+ // someone else's log aggregator. The status is the exporter's transient-
167
+ // vs-poison signal: the server sends 422 for a deterministic control-plane
135
168
  // rejection, 503 for a transient one (spec §2.2/§2.3.1).
136
169
  throw new SinkSendError(`ingest POST → ${response.status}`, response.status);
137
170
  }
171
+ // A good send clears the auth-failure latch, so a later key breakage
172
+ // re-alerts instead of staying silent behind a once-per-process guard.
173
+ apiAuthFailureWarned = false;
174
+ // M5: name the org this key exports to (first flush per process, via
175
+ // /v1/whoami) and log ORG MISMATCH on every flush when `expectOrg` disagrees. Fire-
176
+ // and-forget — never awaited, never throws, never touches the batch.
177
+ void (0, org_identity_1.noteSuccessfulFlush)({
178
+ ingestUrl: config.ingestUrl,
179
+ apiKey: config.apiKey,
180
+ fetchFn,
181
+ ...(config.expectOrg !== undefined ? { expectOrg: config.expectOrg } : {}),
182
+ });
138
183
  if (config.onOutcome !== undefined) {
139
184
  const outcome = (await response.json().catch(() => null));
140
185
  if (outcome !== null)
@@ -150,11 +195,12 @@ function createApiSink(config) {
150
195
  * index.ts until Phase D; moved here — its natural home — to keep that file
151
196
  * under the LOC cap.)
152
197
  */
153
- function buildTelemetrySink(exportConfig, sourceId) {
198
+ function buildTelemetrySink(exportConfig, sourceId, opts = {}) {
154
199
  return exportConfig.mode === "api"
155
200
  ? createApiSink({
156
201
  ingestUrl: exportConfig.ingestUrl,
157
202
  apiKey: exportConfig.apiKey,
203
+ ...(opts.expectOrg !== undefined ? { expectOrg: opts.expectOrg } : {}),
158
204
  // A batch the server partly refused comes back 200. Without this, a
159
205
  // customer whose rows are being dropped would find out by noticing a
160
206
  // gap in a chart weeks later.
@@ -1 +1 @@
1
- {"version":3,"file":"store-migrations.d.ts","sourceRoot":"","sources":["../../src/telemetry/store-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C;sCACsC;AACtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAmL9D"}
1
+ {"version":3,"file":"store-migrations.d.ts","sourceRoot":"","sources":["../../src/telemetry/store-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C;sCACsC;AACtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAgM9D"}
@@ -193,4 +193,17 @@ function runStoreMigrations(db) {
193
193
  }
194
194
  db.pragma("user_version = 15");
195
195
  }
196
+ // v16 (call-qa F4): the per-criterion `criteria` column on the local `grades`
197
+ // table — a JSON breakdown a HUMAN scorecard carries so it can ride the wire
198
+ // to the server's `grade_criteria` (kind=human). Additive, nullable; old rows
199
+ // read null ("a single-score grade, or recorded before F4"). SCHEMA_SQL's
200
+ // CREATE handles a fresh database; this ALTER-if-absent gives a migrating one
201
+ // the column. Same pattern as v6/v13.
202
+ if (db.pragma("user_version", { simple: true }) < 16) {
203
+ const gradeCols = db.prepare("PRAGMA table_info(grades)").all();
204
+ if (gradeCols.length > 0 && !gradeCols.some((c) => c.name === "criteria")) {
205
+ db.exec("ALTER TABLE grades ADD COLUMN criteria TEXT");
206
+ }
207
+ db.pragma("user_version = 16");
208
+ }
196
209
  }
@@ -53,6 +53,21 @@ export declare const API_KEY_BODY_MIN_LENGTH = 43;
53
53
  * settings needs no scope — any org-scoped key may read, since they ride the
54
54
  * already-readable orgs row.
55
55
  *
56
+ * `serve` (managed-serving-keyless K2, 00084): SERVE a managed inference on the
57
+ * hosted gateway's MANAGED mirror lane (`POST /v1/chat/completions` resolving an
58
+ * org's mirrored route against OUR managed provider keys). This is the first-class
59
+ * inference authority the mirror lane was always meant to gate on — it replaces the
60
+ * overloaded `oracle-act` placeholder there (gateway-routes.ts flagged that as an
61
+ * interim stand-in for a real inference/serve scope). It is an ORDINARY machine
62
+ * grant (not owner-only to mint): serving is a delegated coding-agent act, like
63
+ * `route-config`/`prompt-write`, not a money/deletion authority. It is DISTINCT
64
+ * from per-org PROVISIONING: a key may carry `serve` and still be refused because
65
+ * the org is not provisioned for managed serving (orgs.managed_serving_enabled,
66
+ * 00085) — the scope says "this key may serve", the column says "this org may".
67
+ * During the K2 deprecation window the mirror lane still ALSO accepts `oracle-act`
68
+ * so keys minted before the remint keep working; that acceptance is removed once
69
+ * keys are reminted with `serve`.
70
+ *
56
71
  * `artifact-delete` (CD-1 / R-7, 00068): DELETE an org's own stored artifact
57
72
  * CONTENT (`DELETE /v1/artifacts/:id/content`) or PURGE the record
58
73
  * (`DELETE /v1/artifacts/:id`). Held by an automation deleting on the org's
@@ -68,7 +83,7 @@ export declare const API_KEY_BODY_MIN_LENGTH = 43;
68
83
  * owner-only session gate on the routes would be decorative, since the cheapest
69
84
  * way past a role check would be to issue yourself a credential that has none.
70
85
  */
71
- export declare const API_KEY_SCOPES: readonly ["ingest", "query", "grade", "decision", "oracle-act", "artifact-write", "artifact-read", "task-settings", "route-config", "org-settings", "artifact-delete"];
86
+ export declare const API_KEY_SCOPES: readonly ["ingest", "query", "grade", "decision", "oracle-act", "artifact-write", "artifact-read", "task-settings", "route-config", "org-settings", "artifact-delete", "prompt-write", "serve"];
72
87
  export type ApiKeyScope = (typeof API_KEY_SCOPES)[number];
73
88
  /** sha256 of the WHOLE presented string, prefix included — so a caller cannot
74
89
  * strip the prefix and land on a different row. */