doppler-gpu 0.4.14 → 0.5.1

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 (222) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +83 -52
  3. package/package.json +25 -2
  4. package/src/cli/doppler-cli.js +253 -94
  5. package/src/cli/runtime-profiles.js +3 -7
  6. package/src/client/doppler-api.d.ts +28 -0
  7. package/src/client/doppler-api.js +2 -0
  8. package/src/client/inspection.d.ts +122 -0
  9. package/src/client/inspection.js +343 -0
  10. package/src/client/runtime/index.d.ts +54 -0
  11. package/src/client/runtime/index.js +190 -18
  12. package/src/client/runtime/model-manager.d.ts +0 -4
  13. package/src/client/runtime/model-manager.js +0 -28
  14. package/src/client/runtime/model-session.d.ts +116 -1
  15. package/src/client/runtime/model-session.js +351 -1
  16. package/src/client/runtime/model-source.d.ts +10 -1
  17. package/src/client/runtime/scoped-session.d.ts +117 -0
  18. package/src/client/runtime/scoped-session.js +257 -0
  19. package/src/client/runtime/types.d.ts +0 -1
  20. package/src/client/runtime/types.js +0 -1
  21. package/src/config/evidence/boundary-evidence-policy.json +54 -0
  22. package/src/config/evidence/source-intake-policy.json +122 -0
  23. package/src/config/inspection/observation-policies.json +80 -0
  24. package/src/config/param-validator.js +21 -36
  25. package/src/config/runtime/compute/f16-activations.json +1 -0
  26. package/src/config/runtime/compute/f16-batched.json +1 -0
  27. package/src/config/runtime/default.json +1 -0
  28. package/src/config/runtime/diagnostics/debug-logits.json +1 -0
  29. package/src/config/runtime/experiments/bench/gemma3-bench-q4k-alt.json +1 -0
  30. package/src/config/runtime/experiments/bench/gemma3-bench-q4k-batched.json +1 -0
  31. package/src/config/runtime/experiments/bench/gemma3-bench-q4k.json +1 -0
  32. package/src/config/runtime/experiments/bench/gemma4-bench-q4k.json +1 -0
  33. package/src/config/runtime/experiments/bench/qwen3-bench-q4k-alt.json +1 -0
  34. package/src/config/runtime/experiments/bench/qwen3-bench-q4k-batched.json +1 -0
  35. package/src/config/runtime/experiments/debug/gemma3-browser-diagnose-q4k.json +1 -1
  36. package/src/config/runtime/experiments/debug/gemma3-debug-q4k.json +1 -3
  37. package/src/config/runtime/experiments/debug/gemma4-e2b-browser-diagnose-q4k.json +1 -1
  38. package/src/config/runtime/experiments/debug/qwen35-browser-diagnose-q4k.json +1 -1
  39. package/src/config/runtime/experiments/verify/gemma3-verify.json +1 -3
  40. package/src/config/runtime/experiments/verify/gemma4-e2b-verify.json +1 -3
  41. package/src/config/runtime/experiments/verify/lfm2-verify.json +1 -3
  42. package/src/config/runtime/experiments/verify/translategemma-verify.json +1 -3
  43. package/src/config/runtime/model/gemma2-debug.json +1 -0
  44. package/src/config/runtime/model/gemma2-pipeline-debug.json +1 -0
  45. package/src/config/runtime/model/gemma2-pipeline.json +1 -0
  46. package/src/config/runtime/model/gemma3-layer-probe.json +1 -0
  47. package/src/config/runtime/model/qwen3-5-layer-probe.json +1 -0
  48. package/src/config/runtime/model/qwen3-5-layer3-boundary-probe.json +1 -0
  49. package/src/config/runtime/model/qwen3-5-linear-attn-debug.json +1 -0
  50. package/src/config/runtime/optimization-candidates/registry.json +5 -0
  51. package/src/config/runtime/platform/metal-apple-q4k.json +1 -0
  52. package/src/config/runtime/profiles/default.json +1 -0
  53. package/src/config/runtime/profiles/diffusiongemma-26b-a4b-throughput.json +1 -0
  54. package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-overlapped-probe.json +1 -0
  55. package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-probe.json +1 -0
  56. package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-b4.json +1 -3
  57. package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-single.json +1 -3
  58. package/src/config/runtime/profiles/gemma4-31b-f16-activations-probe.json +1 -5
  59. package/src/config/runtime/profiles/gemma4-e2b-baseline-probe.json +1 -3
  60. package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-probe.json +1 -3
  61. package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-test.json +1 -0
  62. package/src/config/runtime/profiles/gemma4-e2b-int4ple-baseline-probe.json +1 -5
  63. package/src/config/runtime/profiles/gemma4-e2b-int4ple-f16a-probe.json +1 -5
  64. package/src/config/runtime/profiles/gemma4-e2b-int4ple-reference-export.json +1 -3
  65. package/src/config/runtime/profiles/gemma4-e2b-int4ple-retain-q4k-probe.json +1 -5
  66. package/src/config/runtime/profiles/gemma4-e2b-low-memory.json +1 -0
  67. package/src/config/runtime/profiles/gemma4-e2b-prefill-profile.json +1 -3
  68. package/src/config/runtime/profiles/gemma4-e2b-throughput-probe.json +1 -0
  69. package/src/config/runtime/profiles/low-memory.json +1 -0
  70. package/src/config/runtime/profiles/production.json +1 -3
  71. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-attn128-candidate.json +1 -0
  72. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-maxbatch64-candidate.json +1 -0
  73. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-normed-ffn-candidate.json +1 -0
  74. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-overlap-ringtokens1-candidate.json +1 -0
  75. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-parity.json +1 -0
  76. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-sequential-candidate.json +1 -0
  77. package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-throughput.json +1 -0
  78. package/src/config/runtime/profiles/qwen-3-5-0-8b-prefill-profile.json +1 -3
  79. package/src/config/runtime/profiles/qwen-3-5-0-8b-throughput-probe.json +1 -0
  80. package/src/config/runtime/profiles/qwen-3-5-2b-f16-primary-throughput.json +1 -5
  81. package/src/config/runtime/profiles/qwen-3-5-2b-metal-parity.json +1 -0
  82. package/src/config/runtime/profiles/qwen-3-5-2b-metal-throughput.json +1 -0
  83. package/src/config/runtime/profiles/qwen-3-5-9b-metal-correctness.json +1 -0
  84. package/src/config/runtime/profiles/qwen-3-embedding-0-6b-metal-stability.json +1 -3
  85. package/src/config/runtime/profiles/qwen-3-embedding-0-6b-metal-throughput.json +1 -0
  86. package/src/config/runtime/profiles/qwen-3-reranker-0-6b-metal-stability.json +1 -0
  87. package/src/config/runtime/profiles/qwen-3-reranker-0-6b-metal-throughput.json +1 -0
  88. package/src/config/runtime/profiles/qwen3-6-27b-f16-activations-probe.json +1 -5
  89. package/src/config/runtime/profiles/rerank-stability.json +1 -3
  90. package/src/config/runtime/profiles/rerank-throughput.json +1 -3
  91. package/src/config/runtime/profiles/simulation.json +1 -3
  92. package/src/config/runtime/profiles/throughput.json +1 -3
  93. package/src/config/runtime/profiles/trace-layers.json +1 -3
  94. package/src/config/runtime/profiles/translategemma-1b-nativekd2-q4k-rdna3-throughput-probe.json +1 -0
  95. package/src/config/runtime/profiles/turboquant-contiguous-prod.json +1 -0
  96. package/src/config/runtime/profiles/turboquant-contiguous.json +1 -0
  97. package/src/config/runtime/profiles/turboquant.json +1 -0
  98. package/src/config/runtime/profiles/vector-stability.json +1 -3
  99. package/src/config/runtime/profiles/vector-throughput.json +1 -0
  100. package/src/config/runtime/profiles/verbose-trace.json +1 -3
  101. package/src/config/runtime/tiers/gemma4-128gb.json +1 -0
  102. package/src/config/runtime/tiers/gemma4-16gb.json +1 -0
  103. package/src/config/runtime/tiers/gemma4-24gb.json +1 -0
  104. package/src/config/runtime/tiers/gemma4-32gb.json +1 -0
  105. package/src/config/schema/benchmark.schema.d.ts +7 -0
  106. package/src/config/schema/benchmark.schema.js +5 -0
  107. package/src/config/schema/index.d.ts +8 -16
  108. package/src/config/schema/index.js +5 -8
  109. package/src/config/schema/kernel-thresholds.schema.d.ts +0 -12
  110. package/src/config/schema/kernel-thresholds.schema.js +0 -12
  111. package/src/config/schema/kernel-warmup.schema.d.ts +1 -3
  112. package/src/config/schema/kernel-warmup.schema.js +0 -1
  113. package/src/config/schema/runtime-profile.schema.d.ts +24 -0
  114. package/src/config/schema/runtime-profile.schema.js +92 -0
  115. package/src/config/schema/shared-runtime.schema.d.ts +1 -4
  116. package/src/config/schema/shared-runtime.schema.js +0 -2
  117. package/src/config/schema/tooling.schema.d.ts +8 -5
  118. package/src/config/schema/tooling.schema.js +3 -2
  119. package/src/debug/tensor.d.ts +2 -0
  120. package/src/debug/tensor.js +21 -2
  121. package/src/gpu/command-recorder.d.ts +5 -0
  122. package/src/gpu/command-recorder.js +17 -0
  123. package/src/gpu/kernel-runtime.js +2 -10
  124. package/src/gpu/kernels/index.d.ts +0 -2
  125. package/src/gpu/kernels/index.js +0 -2
  126. package/src/gpu/kernels/kernel-prewarm.d.ts +3 -0
  127. package/src/gpu/kernels/kernel-prewarm.js +60 -0
  128. package/src/gpu/kernels/utils.d.ts +2 -4
  129. package/src/gpu/kernels/utils.js +2 -4
  130. package/src/index.d.ts +13 -1
  131. package/src/index.js +7 -1
  132. package/src/inference/browser-harness-model-helpers.js +4 -0
  133. package/src/inference/browser-harness-runtime-helpers.js +25 -10
  134. package/src/inference/browser-harness-text-helpers.js +4 -1
  135. package/src/inference/browser-harness.d.ts +4 -0
  136. package/src/inference/browser-harness.js +91 -4
  137. package/src/inference/observation-context.d.ts +22 -0
  138. package/src/inference/observation-context.js +41 -0
  139. package/src/inference/pipelines/text/attention/attn-config.js +1 -1
  140. package/src/inference/pipelines/text/attention/executor-immediate.js +42 -0
  141. package/src/inference/pipelines/text/attention/executor-recorded.js +29 -0
  142. package/src/inference/pipelines/text/attention/index.js +7 -0
  143. package/src/inference/pipelines/text/attention/interpreter.js +1334 -0
  144. package/src/inference/pipelines/text/attention/plan.d.ts +36 -0
  145. package/src/inference/pipelines/text/attention/plan.js +328 -0
  146. package/src/inference/pipelines/text/attention/receipt.js +60 -0
  147. package/src/inference/pipelines/text/attention/record.js +8 -1278
  148. package/src/inference/pipelines/text/attention/run.js +8 -1386
  149. package/src/inference/pipelines/text/generator-decode-policy.js +4 -1
  150. package/src/inference/pipelines/text/generator-helpers.js +2 -0
  151. package/src/inference/pipelines/text/generator-steps.js +32 -15
  152. package/src/inference/pipelines/text/generator.js +10 -5
  153. package/src/inference/pipelines/text/init.d.ts +3 -0
  154. package/src/inference/pipelines/text/layer-plan-gpu.js +2 -0
  155. package/src/inference/pipelines/text/layer.js +2 -0
  156. package/src/inference/pipelines/text/model-load.d.ts +0 -1
  157. package/src/inference/pipelines/text/model-load.js +2 -11
  158. package/src/inference/pipelines/text/probes.js +10 -0
  159. package/src/inference/pipelines/text/resolved-runtime-session.d.ts +56 -0
  160. package/src/inference/pipelines/text/resolved-runtime-session.js +175 -0
  161. package/src/inference/pipelines/text/state.d.ts +6 -0
  162. package/src/inference/pipelines/text/state.js +3 -0
  163. package/src/inference/pipelines/text/types.d.ts +6 -0
  164. package/src/inference/pipelines/text.js +16 -1
  165. package/src/inference/refactor-receipt.d.ts +49 -0
  166. package/src/inference/refactor-receipt.js +188 -0
  167. package/src/inference/resource-scope.d.ts +33 -0
  168. package/src/inference/resource-scope.js +168 -0
  169. package/src/inference/test-harness.d.ts +3 -0
  170. package/src/inference/test-harness.js +1 -0
  171. package/src/storage/model-cache.d.ts +53 -0
  172. package/src/storage/model-cache.js +550 -0
  173. package/src/tooling/boundary-evidence.d.ts +51 -0
  174. package/src/tooling/boundary-evidence.js +408 -0
  175. package/src/tooling/browser-command-runner.js +4 -4
  176. package/src/tooling/command-context.d.ts +25 -0
  177. package/src/tooling/command-context.js +53 -0
  178. package/src/tooling/command-runner-shared.js +22 -5
  179. package/src/tooling/demo-receipts.d.ts +56 -0
  180. package/src/tooling/demo-receipts.js +113 -0
  181. package/src/tooling/diagnose-runner.js +2 -2
  182. package/src/tooling/execution-cost-ledger.d.ts +21 -0
  183. package/src/tooling/execution-cost-ledger.js +199 -0
  184. package/src/tooling/node-command-runner.js +2 -2
  185. package/src/tooling/opfs-cache.d.ts +11 -49
  186. package/src/tooling/opfs-cache.js +4 -510
  187. package/src/tooling/precision-replay-math.d.ts +42 -0
  188. package/src/tooling/precision-replay-math.js +174 -0
  189. package/src/tooling/program-bundle-parity.d.ts +3 -0
  190. package/src/tooling/program-bundle-parity.js +8 -0
  191. package/src/tooling/program-bundle.d.ts +1 -52
  192. package/src/tooling/program-bundle.js +0 -139
  193. package/src/tooling/registered-variant-calibration.d.ts +24 -0
  194. package/src/tooling/registered-variant-calibration.js +286 -0
  195. package/src/tooling/runtime-input-composition.js +105 -53
  196. package/src/tooling/runtime-intent.js +41 -0
  197. package/src/tooling/runtime-optimization-index.d.ts +6 -0
  198. package/src/tooling/runtime-optimization-index.js +72 -0
  199. package/src/tooling/runtime-optimization.d.ts +47 -6
  200. package/src/tooling/runtime-optimization.js +559 -40
  201. package/src/tooling/source-intake.d.ts +49 -0
  202. package/src/tooling/source-intake.js +414 -0
  203. package/src/tooling-exports/evidence.d.ts +34 -0
  204. package/src/tooling-exports/evidence.js +34 -0
  205. package/src/tooling-exports/runtime.d.ts +7 -0
  206. package/src/tooling-exports/runtime.js +7 -0
  207. package/src/tooling-exports.d.ts +11 -0
  208. package/src/tooling-exports.js +6 -3
  209. package/src/tooling-exports.shared.d.ts +32 -0
  210. package/src/tooling-exports.shared.js +31 -0
  211. package/src/version.js +1 -1
  212. package/src/config/schema/tuner.schema.d.ts +0 -39
  213. package/src/config/schema/tuner.schema.js +0 -13
  214. package/src/gpu/kernel-tuner/benchmarks.js +0 -902
  215. package/src/gpu/kernel-tuner/cache.js +0 -145
  216. package/src/gpu/kernel-tuner/index.js +0 -38
  217. package/src/gpu/kernel-tuner/tuner.js +0 -247
  218. package/src/gpu/kernel-tuner.js +0 -12
  219. package/src/gpu/kernels/kernel-tuning.d.ts +0 -42
  220. package/src/gpu/kernels/kernel-tuning.js +0 -158
  221. package/src/gpu/profiler.js +0 -382
  222. package/src/inference/pipelines/text/attention/output-gate-fusion.js +0 -37
@@ -5,7 +5,7 @@ import path from 'node:path';
5
5
  import { fileURLToPath, pathToFileURL } from 'node:url';
6
6
  import { runNodeCommand } from '../tooling/node-command-runner.js';
7
7
  import { runBrowserCommandInNode } from '../tooling/node-browser-command-runner.js';
8
- import { writeProgramBundle, writeReferenceReceipt } from '../tooling/program-bundle.js';
8
+ import { writeProgramBundle } from '../tooling/program-bundle.js';
9
9
  import {
10
10
  TOOLING_COMMANDS,
11
11
  normalizeToolingCommandRequest,
@@ -86,8 +86,11 @@ function usage() {
86
86
  ' doppler distill --config <path|url|json> [--surface auto|node]',
87
87
  ' doppler program-bundle --config <path|json>',
88
88
  ' doppler program-bundle --manifest <path> --reference-report <path> --out <path> [--conversion-config <path>]',
89
- ' doppler reference-receipt --config <path|json>',
90
- ' doppler reference-receipt --manifest <path> --reference-transcript <path> --out <path>',
89
+ ' doppler onboard inspect --source <checkpoint-dir> --out <dir> [--family-intake <source-intake.json>]',
90
+ ' doppler boundary capture --report <diagnose-report.json> --out <runtime-boundaries.json>',
91
+ ' doppler boundary source-pack --provider-capture <provider-capture.json> --out <source-boundaries.json>',
92
+ ' doppler boundary token-evidence --reference-transcript <reference-transcript.json> --out <token-evidence.json>',
93
+ ' doppler boundary compare --source-pack <source-boundaries.json> --runtime-capture <runtime-boundaries.json> --token-evidence <json> --out <receipt.json>',
91
94
  ' doppler intake --convert-config <path|json> [--manifest <path>] [--out <intake-report.json>]',
92
95
  ' doppler bundle --manifest <path> --out <dir> [--prompt <text>] [--max-tokens <n>] [--surface node|browser]',
93
96
  ' doppler bundle --convert-config <path|json> --out <dir>',
@@ -123,6 +126,7 @@ function usage() {
123
126
  function parseArgs(argv) {
124
127
  const out = {
125
128
  command: null,
129
+ action: null,
126
130
  flags: {},
127
131
  };
128
132
 
@@ -139,6 +143,10 @@ function parseArgs(argv) {
139
143
  throw new Error(`Unsupported short flag "${token}". Use long-form flags (for example --help).`);
140
144
  }
141
145
  if (!token.startsWith('--')) {
146
+ if ((out.command === 'onboard' || out.command === 'boundary') && out.action === null) {
147
+ out.action = token;
148
+ continue;
149
+ }
142
150
  throw new Error('Positional arguments are not supported. Use --config for command payloads.');
143
151
  }
144
152
 
@@ -280,6 +288,120 @@ function validateIntakeFlags(parsed) {
280
288
  }
281
289
  }
282
290
 
291
+ function validateOnboardFlags(parsed) {
292
+ if (parsed.action !== 'inspect') {
293
+ throw new Error('onboard: expected the action "inspect".');
294
+ }
295
+ const allowedFlags = new Set([
296
+ 'source',
297
+ 'out',
298
+ 'family-intake',
299
+ 'pretty',
300
+ 'json',
301
+ 'help',
302
+ 'h',
303
+ ]);
304
+ for (const key of Object.keys(parsed.flags || {})) {
305
+ if (allowedFlags.has(key)) continue;
306
+ throw new Error(`Unknown flag --${key} for "onboard inspect".`);
307
+ }
308
+ if (!asStringOrNull(parsed.flags.source)) {
309
+ throw new Error('onboard inspect: --source <checkpoint-dir> is required.');
310
+ }
311
+ if (!asStringOrNull(parsed.flags.out)) {
312
+ throw new Error('onboard inspect: --out <dir> is required.');
313
+ }
314
+ }
315
+
316
+ function validateBoundaryFlags(parsed) {
317
+ const captureFlags = new Set([
318
+ 'report',
319
+ 'out',
320
+ 'tolerance-policy',
321
+ 'pretty',
322
+ 'json',
323
+ 'help',
324
+ 'h',
325
+ ]);
326
+ const compareFlags = new Set([
327
+ 'source-pack',
328
+ 'runtime-capture',
329
+ 'source-control',
330
+ 'token-evidence',
331
+ 'artifact-precision',
332
+ 'out',
333
+ 'pretty',
334
+ 'json',
335
+ 'help',
336
+ 'h',
337
+ ]);
338
+ const tokenEvidenceFlags = new Set([
339
+ 'reference-transcript',
340
+ 'out',
341
+ 'pretty',
342
+ 'json',
343
+ 'help',
344
+ 'h',
345
+ ]);
346
+ const sourcePackFlags = new Set([
347
+ 'provider-capture',
348
+ 'out',
349
+ 'pretty',
350
+ 'json',
351
+ 'help',
352
+ 'h',
353
+ ]);
354
+ const allowedFlags = parsed.action === 'capture'
355
+ ? captureFlags
356
+ : (
357
+ parsed.action === 'compare'
358
+ ? compareFlags
359
+ : (
360
+ parsed.action === 'token-evidence'
361
+ ? tokenEvidenceFlags
362
+ : (parsed.action === 'source-pack' ? sourcePackFlags : null)
363
+ )
364
+ );
365
+ if (!allowedFlags) {
366
+ throw new Error(
367
+ 'boundary: expected "capture", "source-pack", "token-evidence", or "compare".'
368
+ );
369
+ }
370
+ for (const key of Object.keys(parsed.flags || {})) {
371
+ if (allowedFlags.has(key)) continue;
372
+ throw new Error(`Unknown flag --${key} for "boundary ${parsed.action}".`);
373
+ }
374
+ if (!asStringOrNull(parsed.flags.out)) {
375
+ throw new Error(`boundary ${parsed.action}: --out <path> is required.`);
376
+ }
377
+ if (parsed.action === 'capture' && !asStringOrNull(parsed.flags.report)) {
378
+ throw new Error('boundary capture: --report <diagnose-report.json> is required.');
379
+ }
380
+ if (
381
+ parsed.action === 'source-pack'
382
+ && !asStringOrNull(parsed.flags['provider-capture'])
383
+ ) {
384
+ throw new Error(
385
+ 'boundary source-pack: --provider-capture <provider-capture.json> is required.'
386
+ );
387
+ }
388
+ if (
389
+ parsed.action === 'token-evidence'
390
+ && !asStringOrNull(parsed.flags['reference-transcript'])
391
+ ) {
392
+ throw new Error(
393
+ 'boundary token-evidence: --reference-transcript <reference-transcript.json> is required.'
394
+ );
395
+ }
396
+ if (parsed.action === 'compare') {
397
+ for (const key of ['source-pack', 'runtime-capture', 'token-evidence']) {
398
+ if (!asStringOrNull(parsed.flags[key])) {
399
+ throw new Error(`boundary compare: --${key} <path> is required.`);
400
+ }
401
+ }
402
+ }
403
+ }
404
+
283
405
  function validateBundleFlags(parsed) {
284
406
  const allowedFlags = new Set([
285
407
  'convert-config',
@@ -293,7 +415,6 @@ function validateBundleFlags(parsed) {
293
415
  'runtime-config',
294
416
  'out',
295
417
  'bundle-id',
296
- 'receipt-id',
297
418
  'created-at',
298
419
  'skip-convert',
299
420
  'skip-capture',
@@ -310,26 +431,6 @@ function validateBundleFlags(parsed) {
310
431
  }
311
432
  }
312
433
 
313
- function validateReferenceReceiptFlags(parsed) {
314
- const allowedFlags = new Set([
315
- 'config',
316
- 'manifest',
317
- 'model-dir',
318
- 'reference-transcript',
319
- 'out',
320
- 'receipt-id',
321
- 'created-at',
322
- 'pretty',
323
- 'json',
324
- 'help',
325
- 'h',
326
- ]);
327
- for (const key of Object.keys(parsed.flags || {})) {
328
- if (allowedFlags.has(key)) continue;
329
- throw new Error(`Unknown flag --${key} for "reference-receipt".`);
330
- }
331
- }
332
-
333
434
  function validateProfilesFlags(parsed) {
334
435
  const allowedFlags = new Set([
335
436
  'pretty',
@@ -703,44 +804,130 @@ async function runIntakeCommand(parsed, jsonOutput) {
703
804
  }
704
805
  }
705
806
 
706
- async function buildReferenceReceiptOptions(parsed) {
707
- const repoRoot = path.resolve(fileURLToPath(new URL('../..', import.meta.url)));
708
- const configValue = asStringOrNull(parsed.flags.config);
709
- const config = configValue
710
- ? await readJsonObjectInput(configValue, '--config')
711
- : {};
712
- return {
713
- repoRoot,
714
- ...config,
715
- manifestPath: parsed.flags.manifest ?? config.manifestPath ?? null,
716
- modelDir: parsed.flags['model-dir'] ?? config.modelDir ?? null,
717
- referenceTranscriptPath:
718
- parsed.flags['reference-transcript'] ?? config.referenceTranscriptPath ?? null,
719
- outputPath: parsed.flags.out ?? config.outputPath ?? config.out ?? null,
720
- receiptId: parsed.flags['receipt-id'] ?? config.receiptId ?? null,
721
- createdAtUtc: parsed.flags['created-at'] ?? config.createdAtUtc ?? null,
807
+ async function runOnboardInspectCommand(parsed, jsonOutput) {
808
+ const { inspectSourceModel } = await import('../tooling/source-intake.js');
809
+ const policyPath = fileURLToPath(
810
+ new URL('../config/evidence/source-intake-policy.json', import.meta.url)
811
+ );
812
+ const policy = await readJsonObjectFile(policyPath, 'source intake policy');
813
+ const familyIntakePath = asStringOrNull(parsed.flags['family-intake']);
814
+ const familyIntake = familyIntakePath
815
+ ? await readJsonObjectFile(path.resolve(familyIntakePath), '--family-intake')
816
+ : null;
817
+ const result = await inspectSourceModel({
818
+ sourceDir: path.resolve(parsed.flags.source),
819
+ policy,
820
+ familyIntake,
821
+ });
822
+ const outputDir = path.resolve(parsed.flags.out);
823
+ await fs.mkdir(outputDir, { recursive: true });
824
+ const outputs = {
825
+ intake: path.join(outputDir, 'source-intake.json'),
826
+ conversion: path.join(outputDir, 'conversion-config.skeleton.json'),
827
+ contractTests: path.join(outputDir, 'contract-tests.plan.json'),
722
828
  };
723
- }
724
-
725
- async function runReferenceReceiptCommand(parsed, jsonOutput) {
726
- const result = await writeReferenceReceipt(await buildReferenceReceiptOptions(parsed));
829
+ await Promise.all([
830
+ fs.writeFile(outputs.intake, `${JSON.stringify(result.report, null, 2)}\n`, 'utf8'),
831
+ fs.writeFile(outputs.conversion, `${JSON.stringify(result.artifacts.conversion, null, 2)}\n`, 'utf8'),
832
+ fs.writeFile(outputs.contractTests, `${JSON.stringify(result.artifacts.contractTests, null, 2)}\n`, 'utf8'),
833
+ ]);
727
834
  const summary = {
728
- ok: true,
729
- outputPath: path.relative(process.cwd(), result.outputPath),
730
- modelId: result.receipt.modelId,
731
- receiptId: result.receipt.receiptId,
732
- executionGraphHash: result.receipt.sources.executionGraph.hash,
733
- tokensGenerated: result.receipt.referenceTranscript?.output?.tokensGenerated ?? null,
734
- stopReason: result.receipt.referenceTranscript?.output?.stopReason ?? null,
835
+ ...result.report,
836
+ outputPaths: Object.fromEntries(
837
+ Object.entries(outputs).map(([key, value]) => [key, path.relative(process.cwd(), value)])
838
+ ),
735
839
  };
736
840
  if (jsonOutput) {
737
841
  console.log(JSON.stringify(summary, null, 2));
738
- return;
842
+ } else {
843
+ const status = result.report.ok ? 'ok' : 'review';
844
+ console.log(
845
+ `[${status}] source intake wrote ${path.relative(process.cwd(), outputDir)} ` +
846
+ `(${result.report.summary.accepted} accepted, ${result.report.summary.unresolved} unresolved)`
847
+ );
739
848
  }
740
- console.log(
741
- `[ok] wrote ${summary.outputPath} ` +
742
- `(modelId=${summary.modelId}, tokens=${summary.tokensGenerated}, stopReason=${summary.stopReason})`
849
+ if (!result.report.ok) process.exitCode = 1;
850
+ }
851
+
852
+ async function runBoundaryCommand(parsed, jsonOutput) {
853
+ const {
854
+ buildDeterministicTokenEvidenceFromReferenceTranscript,
855
+ buildRuntimeBoundaryCapture,
856
+ buildSourceBoundaryPackFromProviderCapture,
857
+ compareBoundaryEvidence,
858
+ } = await import('../tooling/boundary-evidence.js');
859
+ const policyPath = fileURLToPath(
860
+ new URL('../config/evidence/boundary-evidence-policy.json', import.meta.url)
743
861
  );
862
+ const policy = await readJsonObjectFile(policyPath, 'boundary evidence policy');
863
+ let result;
864
+ if (parsed.action === 'capture') {
865
+ const report = await readJsonObjectFile(
866
+ path.resolve(parsed.flags.report),
867
+ '--report'
868
+ );
869
+ result = buildRuntimeBoundaryCapture({
870
+ report,
871
+ policy,
872
+ tolerancePolicyId: asStringOrNull(parsed.flags['tolerance-policy'])
873
+ ?? 'doppler.boundary-tolerance/source-f16-v1',
874
+ });
875
+ } else if (parsed.action === 'source-pack') {
876
+ const providerCapture = await readJsonObjectFile(
877
+ path.resolve(parsed.flags['provider-capture']),
878
+ '--provider-capture'
879
+ );
880
+ result = buildSourceBoundaryPackFromProviderCapture(providerCapture);
881
+ } else if (parsed.action === 'token-evidence') {
882
+ const transcript = await readJsonObjectFile(
883
+ path.resolve(parsed.flags['reference-transcript']),
884
+ '--reference-transcript'
885
+ );
886
+ result = buildDeterministicTokenEvidenceFromReferenceTranscript(transcript);
887
+ } else {
888
+ const [sourcePack, runtimeCapture, tokenEvidence] = await Promise.all([
889
+ readJsonObjectFile(path.resolve(parsed.flags['source-pack']), '--source-pack'),
890
+ readJsonObjectFile(path.resolve(parsed.flags['runtime-capture']), '--runtime-capture'),
891
+ readJsonObjectFile(path.resolve(parsed.flags['token-evidence']), '--token-evidence'),
892
+ ]);
893
+ const sourceControlPath = asStringOrNull(parsed.flags['source-control']);
894
+ const sourcePrecisionControlReceipt = sourceControlPath
895
+ ? await readJsonObjectFile(path.resolve(sourceControlPath), '--source-control')
896
+ : null;
897
+ result = compareBoundaryEvidence({
898
+ sourcePack,
899
+ runtimeCapture,
900
+ policy,
901
+ artifactPrecision: asStringOrNull(parsed.flags['artifact-precision']) ?? 'source',
902
+ sourcePrecisionControlReceipt,
903
+ deterministicTokenEvidence: tokenEvidence,
904
+ });
905
+ }
906
+ const outputPath = path.resolve(parsed.flags.out);
907
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
908
+ await fs.writeFile(outputPath, `${JSON.stringify(result, null, 2)}\n`, 'utf8');
909
+ if (jsonOutput) {
910
+ console.log(JSON.stringify({ ...result, outputPath: path.relative(process.cwd(), outputPath) }, null, 2));
911
+ } else if (parsed.action === 'capture') {
912
+ console.log(`[ok] captured ${result.boundaries.length} semantic boundaries`);
913
+ } else if (parsed.action === 'source-pack') {
914
+ console.log(`[ok] source pack contains ${result.boundaries.length} semantic boundaries`);
915
+ } else if (parsed.action === 'token-evidence') {
916
+ const status = result.exact ? 'ok' : 'fail';
917
+ console.log(`[${status}] token evidence covers ${result.tokenCount} tokens`);
918
+ } else {
919
+ const status = result.promotionGate.passed ? 'ok' : 'fail';
920
+ console.log(
921
+ `[${status}] boundary comparison ` +
922
+ `(first divergence: ${result.firstDivergence?.boundaryId ?? 'none'})`
923
+ );
924
+ }
925
+ if (
926
+ (parsed.action === 'compare' && !result.promotionGate.passed)
927
+ || (parsed.action === 'token-evidence' && !result.exact)
928
+ ) {
929
+ process.exitCode = 1;
930
+ }
744
931
  }
745
932
 
746
933
  async function runProfilesCommand(jsonOutput) {
@@ -845,7 +1032,7 @@ async function runBundleCommand(parsed, jsonOutput) {
845
1032
  writeReferenceTranscript,
846
1033
  normalizeModelUrl,
847
1034
  } = await import('../tooling/reference-verify.js');
848
- const { writeProgramBundle, writeReferenceReceipt } = await import('../tooling/program-bundle.js');
1035
+ const { writeProgramBundle } = await import('../tooling/program-bundle.js');
849
1036
  const fsMod = await import('node:fs/promises');
850
1037
 
851
1038
  const outDir = asStringOrNull(parsed.flags.out);
@@ -1013,39 +1200,6 @@ async function runBundleCommand(parsed, jsonOutput) {
1013
1200
  return emitBundleSummary({ ok: false, stages, blockers, artifactPaths, jsonOutput, resolvedOut });
1014
1201
  }
1015
1202
 
1016
- stages.push({ stage: 'receipt', status: 'starting' });
1017
- try {
1018
- const receiptOutputPath = path.join(resolvedOut, 'reference-receipt.json');
1019
- const receiptResult = await writeReferenceReceipt({
1020
- repoRoot,
1021
- manifestPath,
1022
- modelDir: modelDirResolved,
1023
- referenceTranscriptPath: artifactPaths.referenceTranscript
1024
- ? path.resolve(artifactPaths.referenceTranscript)
1025
- : referenceTranscriptPath,
1026
- outputPath: receiptOutputPath,
1027
- receiptId: asStringOrNull(parsed.flags['receipt-id']),
1028
- createdAtUtc: asStringOrNull(parsed.flags['created-at']),
1029
- });
1030
- artifactPaths.referenceReceipt = path.relative(process.cwd(), receiptResult.outputPath);
1031
- stages[stages.length - 1] = {
1032
- stage: 'receipt',
1033
- status: 'succeeded',
1034
- receiptId: receiptResult.receipt.receiptId,
1035
- executionGraphHash: receiptResult.receipt.sources.executionGraph.hash,
1036
- tokensGenerated: receiptResult.receipt.referenceTranscript?.output?.tokensGenerated ?? null,
1037
- stopReason: receiptResult.receipt.referenceTranscript?.output?.stopReason ?? null,
1038
- };
1039
- } catch (error) {
1040
- stages[stages.length - 1] = {
1041
- stage: 'receipt',
1042
- status: 'failed',
1043
- error: error?.message || String(error),
1044
- };
1045
- blockers.push({ stage: 'receipt', code: 'receipt_write_failed', message: error?.message || String(error) });
1046
- return emitBundleSummary({ ok: false, stages, blockers, artifactPaths, jsonOutput, resolvedOut });
1047
- }
1048
-
1049
1203
  stages.push({ stage: 'parity', status: 'starting' });
1050
1204
  try {
1051
1205
  const { checkProgramBundleParity } = await import('../tooling/program-bundle-parity.js');
@@ -1715,16 +1869,21 @@ async function main() {
1715
1869
  await runProgramBundleCommand(parsed, parsed.flags.pretty !== true);
1716
1870
  return;
1717
1871
  }
1718
- if (parsed.command === 'reference-receipt') {
1719
- validateReferenceReceiptFlags(parsed);
1720
- await runReferenceReceiptCommand(parsed, parsed.flags.pretty !== true);
1721
- return;
1722
- }
1723
1872
  if (parsed.command === 'profiles') {
1724
1873
  validateProfilesFlags(parsed);
1725
1874
  await runProfilesCommand(parsed.flags.pretty !== true);
1726
1875
  return;
1727
1876
  }
1877
+ if (parsed.command === 'onboard') {
1878
+ validateOnboardFlags(parsed);
1879
+ await runOnboardInspectCommand(parsed, parsed.flags.pretty !== true);
1880
+ return;
1881
+ }
1882
+ if (parsed.command === 'boundary') {
1883
+ validateBoundaryFlags(parsed);
1884
+ await runBoundaryCommand(parsed, parsed.flags.pretty !== true);
1885
+ return;
1886
+ }
1728
1887
  if (parsed.command === 'intake') {
1729
1888
  validateIntakeFlags(parsed);
1730
1889
  await runIntakeCommand(parsed, parsed.flags.pretty !== true);
@@ -95,8 +95,6 @@ function compareProfiles(a, b) {
95
95
 
96
96
  function toProfileSummary(profile, filePath, rootDir) {
97
97
  const runtime = profile.runtime;
98
- const shared = isPlainObject(runtime?.shared) ? runtime.shared : {};
99
- const tooling = isPlainObject(shared.tooling) ? shared.tooling : {};
100
98
  const relativePath = path.relative(process.cwd(), filePath).split(path.sep).join('/');
101
99
  const rootRelativePath = path.relative(rootDir, filePath).split(path.sep).join('/');
102
100
  const signals = summarizeSignals(runtime);
@@ -109,11 +107,9 @@ function toProfileSummary(profile, filePath, rootDir) {
109
107
  : null
110
108
  ),
111
109
  intent: typeof profile.intent === 'string' && profile.intent.trim() ? profile.intent.trim() : null,
112
- toolingIntent: (
113
- typeof tooling.intent === 'string' && tooling.intent.trim()
114
- ? tooling.intent.trim()
115
- : null
116
- ),
110
+ compatibleIntents: Array.isArray(profile.compatibleIntents)
111
+ ? profile.compatibleIntents.filter((intent) => typeof intent === 'string' && intent.trim())
112
+ : [],
117
113
  stability: (
118
114
  typeof profile.stability === 'string' && profile.stability.trim()
119
115
  ? profile.stability.trim()
@@ -8,6 +8,10 @@ import type {
8
8
  DopplerLoadProgress,
9
9
  DopplerModelHandle,
10
10
  DopplerModelSource,
11
+ DopplerGenerationResult,
12
+ DopplerPromptInput,
13
+ DopplerScopedGenerateOptions,
14
+ DopplerScopedModelSession,
11
15
  LoRAManifest,
12
16
  } from './runtime/index.js';
13
17
 
@@ -23,12 +27,21 @@ export type DopplerModel = DopplerModelHandle;
23
27
  export interface DopplerNamespace {
24
28
  (prompt: string, options: DopplerCallOptions): AsyncGenerator<string, void, void>;
25
29
  load(model: DopplerModelSource, options?: DopplerLoadOptions): Promise<DopplerModel>;
30
+ open(model: DopplerModelSource, options?: DopplerLoadOptions): Promise<DopplerScopedModelSession>;
31
+ generate(
32
+ model: DopplerModelSource,
33
+ input: DopplerPromptInput,
34
+ options?: DopplerLoadOptions & DopplerScopedGenerateOptions
35
+ ): Promise<DopplerGenerationResult>;
26
36
  text(prompt: string, options: DopplerCallOptions): Promise<string>;
27
37
  chat(messages: ChatMessage[], options: DopplerCallOptions): AsyncGenerator<string, void, void>;
28
38
  chatText(messages: ChatMessage[], options: DopplerCallOptions): Promise<DopplerChatResponse>;
29
39
  evict(model: DopplerModelSource): Promise<boolean>;
30
40
  evictAll(): Promise<void>;
31
41
  listModels(): Promise<string[]>;
42
+ listModelDetails(): Promise<Array<Record<string, unknown> & { modelId: string }>>;
43
+ listPersistentModels(): Promise<Array<Record<string, unknown> & { modelId: string }>>;
44
+ removePersistentModel(model: DopplerModelSource): Promise<boolean>;
32
45
  }
33
46
 
34
47
  export declare function load(
@@ -36,6 +49,17 @@ export declare function load(
36
49
  options?: DopplerLoadOptions
37
50
  ): Promise<DopplerModel>;
38
51
 
52
+ export declare function open(
53
+ model: DopplerModelSource,
54
+ options?: DopplerLoadOptions
55
+ ): Promise<DopplerScopedModelSession>;
56
+
57
+ export declare function generate(
58
+ model: DopplerModelSource,
59
+ input: DopplerPromptInput,
60
+ options?: DopplerLoadOptions & DopplerScopedGenerateOptions
61
+ ): Promise<DopplerGenerationResult>;
62
+
39
63
  export declare function createDefaultNodeLoadProgressLogger(): (event: DopplerLoadProgress) => void;
40
64
 
41
65
  export declare function resolveLoadProgressHandlers(options?: DopplerLoadOptions): {
@@ -52,6 +76,10 @@ export type {
52
76
  DopplerLoadOptions,
53
77
  DopplerLoadProgress,
54
78
  DopplerModelSource,
79
+ DopplerGenerationResult,
80
+ DopplerPromptInput,
81
+ DopplerScopedGenerateOptions,
82
+ DopplerScopedModelSession,
55
83
  };
56
84
 
57
85
  export type {
@@ -23,6 +23,8 @@ const runtime = createDopplerRuntimeService({
23
23
 
24
24
  export const doppler = runtime.doppler;
25
25
  export const load = runtime.load;
26
+ export const open = runtime.open;
27
+ export const generate = runtime.generate;
26
28
  export const clearModelCache = runtime.clearModelCache;
27
29
  export { createDefaultNodeLoadProgressLogger };
28
30
 
@@ -0,0 +1,122 @@
1
+ export type DopplerClaimType =
2
+ | 'execution-identity'
3
+ | 'coarse-performance'
4
+ | 'quality-inspection'
5
+ | 'diagnostic';
6
+
7
+ export interface DopplerObservationPolicy {
8
+ id: string;
9
+ label: string;
10
+ modifiesExecution: boolean;
11
+ performanceRepresentative: boolean;
12
+ requiredCaptures: string[];
13
+ allowedClaimTypes: DopplerClaimType[];
14
+ gpuTimestampQueries: boolean;
15
+ perplexity: null | {
16
+ wordSegmentation: 'doppler.word-segmentation/unicode-whitespace-v1';
17
+ aggregation: 'doppler.perplexity/summed-word-surprisal-v1';
18
+ rollingWindow: {
19
+ unit: 'words' | 'tokens';
20
+ size: number;
21
+ };
22
+ };
23
+ }
24
+
25
+ export interface DopplerComparisonFingerprint {
26
+ schema: 'doppler.comparison-fingerprint/v1';
27
+ identity: {
28
+ artifact: {
29
+ modelId: string;
30
+ manifestHash: string;
31
+ };
32
+ tokenizer: {
33
+ contract: unknown;
34
+ digest: string;
35
+ };
36
+ promptTokenIds: number[];
37
+ sampling: Record<string, unknown>;
38
+ observationPolicy: {
39
+ id: string;
40
+ modifiesExecution: boolean;
41
+ performanceRepresentative: boolean;
42
+ requiredCaptures: string[];
43
+ allowedClaimTypes: DopplerClaimType[];
44
+ };
45
+ perplexity: DopplerObservationPolicy['perplexity'];
46
+ execution: Record<string, unknown>;
47
+ browser: Record<string, string>;
48
+ adapter: Record<string, string | null>;
49
+ };
50
+ fullDigest: string;
51
+ qualityDigest: string;
52
+ performanceDigest: string;
53
+ }
54
+
55
+ export interface DopplerInspectionTokenRecord {
56
+ index: number;
57
+ tokenId: number;
58
+ text: string;
59
+ probability: number | null;
60
+ surprisal: number | null;
61
+ topCandidates: Array<{
62
+ tokenId: number;
63
+ logit: number;
64
+ text: string;
65
+ probability: number | null;
66
+ }>;
67
+ }
68
+
69
+ export interface DopplerWordQualityRecord {
70
+ wordIndex: number;
71
+ text: string;
72
+ tokenIndexes: number[];
73
+ tokenCount: number;
74
+ summedSurprisal: number;
75
+ probabilityAvailable: boolean;
76
+ rollingPerplexity: number | null;
77
+ cumulativePerplexity: number | null;
78
+ rollingWindow: {
79
+ unit: 'words' | 'tokens';
80
+ size: number;
81
+ tokenCount: number;
82
+ };
83
+ }
84
+
85
+ export declare const OBSERVATION_POLICY_REGISTRY_SCHEMA: 'doppler.observation-policy-registry/v1';
86
+ export declare const COMPARISON_FINGERPRINT_SCHEMA: 'doppler.comparison-fingerprint/v1';
87
+ export declare const MODEL_INSPECTION_RECEIPT_SCHEMA: 'doppler.model-inspection-receipt/v1';
88
+ export declare const WORD_SEGMENTATION_SCHEMA: 'doppler.word-segmentation/unicode-whitespace-v1';
89
+ export declare const PERPLEXITY_AGGREGATION_SCHEMA: 'doppler.perplexity/summed-word-surprisal-v1';
90
+
91
+ export declare function listObservationPolicies(): DopplerObservationPolicy[];
92
+ export declare function resolveObservationPolicy(policyId?: string): DopplerObservationPolicy;
93
+ export declare function buildComparisonFingerprint(input: {
94
+ artifact: { modelId: string; manifestHash: string };
95
+ tokenizer: unknown;
96
+ promptTokenIds: readonly number[];
97
+ sampling?: Record<string, unknown>;
98
+ observationPolicyId: string;
99
+ execution?: Record<string, unknown>;
100
+ browser?: Record<string, unknown>;
101
+ adapter?: Record<string, unknown>;
102
+ }): DopplerComparisonFingerprint;
103
+ export declare function assertComparableFingerprints(
104
+ kind: 'quality' | 'performance',
105
+ left: DopplerComparisonFingerprint,
106
+ right: DopplerComparisonFingerprint
107
+ ): true;
108
+ export declare function buildInspectionTokenRecords(
109
+ tokenIds: readonly number[],
110
+ logitsByStep: ArrayLike<number>[],
111
+ tokenizer: { decode(ids: readonly number[], skipSpecialTokens?: boolean, cleanUp?: boolean): string },
112
+ topKSize?: number
113
+ ): DopplerInspectionTokenRecord[];
114
+ export declare function aggregateWordPerplexity(
115
+ tokenRecords: DopplerInspectionTokenRecord[],
116
+ options?: { windowUnit?: 'words' | 'tokens'; windowSize?: number }
117
+ ): {
118
+ wordSegmentation: 'doppler.word-segmentation/unicode-whitespace-v1';
119
+ aggregation: 'doppler.perplexity/summed-word-surprisal-v1';
120
+ rollingWindow: { unit: 'words' | 'tokens'; size: number };
121
+ words: DopplerWordQualityRecord[];
122
+ };