@oh-my-pi/omp-stats 18.16.0 → 18.17.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 +7 -0
- package/dist/client/index.css +1 -1
- package/dist/client/index.js +102 -99
- package/dist/types/client/api.d.ts +4 -1
- package/dist/types/client/app/nav.d.ts +1 -1
- package/dist/types/client/charts/Chart.d.ts +16 -8
- package/dist/types/client/charts/DotWhisker.d.ts +50 -0
- package/dist/types/client/charts/Sparkline.d.ts +1 -1
- package/dist/types/client/charts/Waterfall.d.ts +26 -0
- package/dist/types/client/charts/index.d.ts +2 -0
- package/dist/types/client/charts/types.d.ts +8 -2
- package/dist/types/client/routes/SpotlightRoute.d.ts +7 -0
- package/dist/types/client/routes/index.d.ts +1 -0
- package/dist/types/client/spotlight/Compounding.d.ts +8 -0
- package/dist/types/client/spotlight/Coverage.d.ts +6 -0
- package/dist/types/client/spotlight/Economics.d.ts +10 -0
- package/dist/types/client/spotlight/FetchBack.d.ts +9 -0
- package/dist/types/client/spotlight/Hero.d.ts +12 -0
- package/dist/types/client/spotlight/Overhead.d.ts +6 -0
- package/dist/types/client/spotlight/Ranking.d.ts +6 -0
- package/dist/types/client/spotlight/ResultsFeed.d.ts +6 -0
- package/dist/types/client/spotlight/Savings.d.ts +10 -0
- package/dist/types/client/spotlight/ShareTrend.d.ts +8 -0
- package/dist/types/client/spotlight/Steps.d.ts +6 -0
- package/dist/types/client/spotlight/TimeCost.d.ts +6 -0
- package/dist/types/client/spotlight/chips.d.ts +16 -0
- package/dist/types/client/spotlight/meta.d.ts +64 -0
- package/dist/types/db.d.ts +26 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/parser.d.ts +4 -0
- package/dist/types/rollup.d.ts +22 -1
- package/dist/types/shared-types.d.ts +419 -0
- package/dist/types/spotlight-aggregator.d.ts +189 -0
- package/dist/types/spotlight-bootstrap.d.ts +32 -0
- package/dist/types/spotlight-ingest.d.ts +258 -0
- package/dist/types/spotlight-measures.d.ts +51 -0
- package/package.json +5 -5
- package/src/aggregator.ts +3 -1
- package/src/client/App.tsx +3 -0
- package/src/client/api.ts +21 -0
- package/src/client/app/nav.ts +4 -1
- package/src/client/charts/Chart.tsx +105 -22
- package/src/client/charts/DotWhisker.tsx +149 -0
- package/src/client/charts/Sparkline.tsx +3 -2
- package/src/client/charts/Waterfall.tsx +86 -0
- package/src/client/charts/index.ts +2 -0
- package/src/client/charts/types.ts +9 -2
- package/src/client/react-css.d.ts +1 -1
- package/src/client/routes/SpotlightRoute.tsx +138 -0
- package/src/client/routes/index.ts +1 -0
- package/src/client/spotlight/Compounding.tsx +222 -0
- package/src/client/spotlight/Coverage.tsx +96 -0
- package/src/client/spotlight/Economics.tsx +167 -0
- package/src/client/spotlight/FetchBack.tsx +222 -0
- package/src/client/spotlight/Hero.tsx +177 -0
- package/src/client/spotlight/Overhead.tsx +135 -0
- package/src/client/spotlight/Ranking.tsx +248 -0
- package/src/client/spotlight/ResultsFeed.tsx +354 -0
- package/src/client/spotlight/Savings.tsx +355 -0
- package/src/client/spotlight/ShareTrend.tsx +103 -0
- package/src/client/spotlight/Steps.tsx +225 -0
- package/src/client/spotlight/TimeCost.tsx +64 -0
- package/src/client/spotlight/chips.tsx +63 -0
- package/src/client/spotlight/meta.ts +206 -0
- package/src/client/spotlight/spotlight.css +1387 -0
- package/src/client/styles.css +289 -1
- package/src/db.ts +480 -2
- package/src/index.ts +10 -1
- package/src/live.ts +21 -9
- package/src/parser.ts +44 -8
- package/src/rollup.ts +203 -10
- package/src/server.ts +42 -0
- package/src/shared-types.ts +453 -0
- package/src/spotlight-aggregator.ts +1738 -0
- package/src/spotlight-bootstrap.ts +110 -0
- package/src/spotlight-ingest.ts +981 -0
- package/src/spotlight-measures.ts +667 -0
package/src/shared-types.ts
CHANGED
|
@@ -321,6 +321,459 @@ export interface GainDashboardStats {
|
|
|
321
321
|
projects: string[];
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* A tool the Spotlight experiment shaped, by the name it was called with (`read`, `grep`, an MCP tool's name, …).
|
|
326
|
+
* Every tool's results are shaped (`spotlight.experiment.tools`, default all); read, bash and eval have their own
|
|
327
|
+
* paths in pi, every other tool goes through the generic one.
|
|
328
|
+
*/
|
|
329
|
+
export type SpotlightTool = string;
|
|
330
|
+
|
|
331
|
+
/** One tool's totals, for lists ordered by the tool's saving. */
|
|
332
|
+
export interface SpotlightToolRow extends SpotlightToolTotals {
|
|
333
|
+
tool: SpotlightTool;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* How the model got back output a shortened result hid:
|
|
338
|
+
* - `artifact`: a later call read or searched an artifact the shortened result named (`artifact://N`);
|
|
339
|
+
* - `reread`: a later `read` of the same file whose selection overlaps the hidden lines, or the whole file again;
|
|
340
|
+
* - `rerun`: a later call of the same tool repeating the shortened one: a bash command with a pipe, redirect or
|
|
341
|
+
* changed flags; any other tool with near-identical arguments (same tool, argument tokens' Jaccard ≥ 0.6).
|
|
342
|
+
*/
|
|
343
|
+
export type SpotlightRecoveryKind = "artifact" | "reread" | "rerun";
|
|
344
|
+
|
|
345
|
+
/** A ratio over sessions with its bootstrap 90% interval (`lo`/`hi` null under 3 sessions; `value` null with none). */
|
|
346
|
+
export interface SpotlightEstimate {
|
|
347
|
+
value: number | null;
|
|
348
|
+
lo: number | null;
|
|
349
|
+
hi: number | null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Token totals of one tool's evaluated results. Savings are measured against the `plain` text pi would have shown
|
|
354
|
+
* unshaped for the same call (its inline cap and read page), not against the full output shaping reads.
|
|
355
|
+
*/
|
|
356
|
+
export interface SpotlightToolTotals {
|
|
357
|
+
/** Results the experiment evaluated. */
|
|
358
|
+
results: number;
|
|
359
|
+
/** Results it shortened. */
|
|
360
|
+
shaped: number;
|
|
361
|
+
/** The full output shaping read (a spilled bash output's whole artifact, a whole file up to 2 MiB). */
|
|
362
|
+
inTokens: number;
|
|
363
|
+
/**
|
|
364
|
+
* What `plain` would have shown: the trace's `plainTokens`, else (read, bash and eval traces written before pi
|
|
365
|
+
* recorded it) estimated from the inline cap.
|
|
366
|
+
*/
|
|
367
|
+
plainTokens: number;
|
|
368
|
+
outTokens: number;
|
|
369
|
+
/**
|
|
370
|
+
* Σ (plainTokens − outTokens) over shortened results; a cut that showed more than `plain` would have counts
|
|
371
|
+
* negative (see {@link SpotlightGross.widerThanPlain}).
|
|
372
|
+
*/
|
|
373
|
+
savedTokens: number;
|
|
374
|
+
/** Σ (inTokens − outTokens): the saving against the full output, which overstates what the model was spared. */
|
|
375
|
+
fullSavedTokens: number;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** Strategy 1, gross savings: what the cuts removed. */
|
|
379
|
+
export interface SpotlightGross extends SpotlightToolTotals {
|
|
380
|
+
/** savedTokens / (savedTokens + every tool-output token the model saw in the same sessions). */
|
|
381
|
+
ofToolOutput: number | null;
|
|
382
|
+
/** savedTokens / every token of the same sessions' requests (input + output + cache read + cache write). */
|
|
383
|
+
ofSessionTokens: number | null;
|
|
384
|
+
/** Every tool with an evaluated result in the range, the largest saving first. */
|
|
385
|
+
byTool: SpotlightToolRow[];
|
|
386
|
+
/** Shortened results whose `plainTokens` is estimated (journaled before pi recorded it). */
|
|
387
|
+
estimatedPlain: number;
|
|
388
|
+
/**
|
|
389
|
+
* Shortened results whose cut was wider than what `plain` would have shown (out > plain): a loss where the cut
|
|
390
|
+
* was shown, a saving of 0 where pi capped it at `plain`'s text (counted by the would-be cut).
|
|
391
|
+
*/
|
|
392
|
+
widerThanPlain: number;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** Recovery totals of one kind. */
|
|
396
|
+
export interface SpotlightRecoveryTotals {
|
|
397
|
+
events: number;
|
|
398
|
+
/** Tokens of the recovery calls' results, which re-enter the context. */
|
|
399
|
+
tokens: number;
|
|
400
|
+
/** Requests that issued nothing but recovery calls. */
|
|
401
|
+
turns: number;
|
|
402
|
+
/** Provider cost of those requests. */
|
|
403
|
+
turnsUsd: number;
|
|
404
|
+
/**
|
|
405
|
+
* The recovery tokens carried through later requests, priced like {@link SpotlightCompounding.savedUsd}
|
|
406
|
+
* (excluding `turnsUsd`); Σ over kinds + clawback.turnsUsd = compounding.recoveryUsd.
|
|
407
|
+
*/
|
|
408
|
+
usd: number;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** Strategy 2, clawback: what getting hidden output back cost. */
|
|
412
|
+
export interface SpotlightClawback extends SpotlightRecoveryTotals {
|
|
413
|
+
/** Shortened results with hidden lines: the ones a recovery can follow. */
|
|
414
|
+
withHidden: number;
|
|
415
|
+
/** Of those, the results at least one recovery followed. */
|
|
416
|
+
recovered: number;
|
|
417
|
+
byKind: Record<SpotlightRecoveryKind, SpotlightRecoveryTotals>;
|
|
418
|
+
/** gross.savedTokens − tokens. */
|
|
419
|
+
netTokens: number;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Strategy 3, compounding: savings as every later request of the session would have re-read them. */
|
|
423
|
+
export interface SpotlightCompounding {
|
|
424
|
+
/** Σ over shortened results of saved tokens × later requests of the session until a compaction. */
|
|
425
|
+
avoidedTokens: number;
|
|
426
|
+
/** Recovery tokens carried the same way: they undo what the cut avoided. */
|
|
427
|
+
recoveredCarriedTokens: number;
|
|
428
|
+
/** Prompt tokens the same sessions' requests processed (input + cache read + cache write). */
|
|
429
|
+
promptTokens: number;
|
|
430
|
+
/** (avoided − recoveredCarried) / (promptTokens + avoided − recoveredCarried). */
|
|
431
|
+
avoidedShare: number | null;
|
|
432
|
+
/** Avoided tokens priced at each later request's own cache-read rate, plus one cache write. */
|
|
433
|
+
savedUsd: number;
|
|
434
|
+
/** recoveredCarriedTokens priced the same way, plus clawback.turnsUsd. */
|
|
435
|
+
recoveryUsd: number;
|
|
436
|
+
/** Spotlight's own bill (`spotlight:shape` costUsd). */
|
|
437
|
+
spotlightUsd: number;
|
|
438
|
+
/** savedUsd − recoveryUsd − spotlightUsd. */
|
|
439
|
+
netUsd: number;
|
|
440
|
+
/** Wall time shaping added to tool calls (Σ `spotlight:shape` ms). */
|
|
441
|
+
shapeMs: number;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Strategy 4: one bucket of the tool-output share of context, per session group. */
|
|
445
|
+
export interface SpotlightSharePoint {
|
|
446
|
+
/** Bucket start (the range's bucket size, as every time series). */
|
|
447
|
+
timestamp: number;
|
|
448
|
+
/** `shaped`: an experiment session from its marker on; `outside`: everything else. */
|
|
449
|
+
group: "shaped" | "outside";
|
|
450
|
+
sessions: number;
|
|
451
|
+
/** Tool-result tokens the model saw. */
|
|
452
|
+
toolTokens: number;
|
|
453
|
+
/** Everything that entered the context: tool results, assistant output, user prompts and the first request's prompt. */
|
|
454
|
+
contextTokens: number;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** One bucket of savings over time. */
|
|
458
|
+
export interface SpotlightBucket {
|
|
459
|
+
timestamp: number;
|
|
460
|
+
results: number;
|
|
461
|
+
shaped: number;
|
|
462
|
+
savedTokens: number;
|
|
463
|
+
recoveries: number;
|
|
464
|
+
recoveredTokens: number;
|
|
465
|
+
netTokens: number;
|
|
466
|
+
savedUsd: number;
|
|
467
|
+
netUsd: number;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** A recovery attributed to the latest shortened result it fetches from. */
|
|
471
|
+
export interface SpotlightRecovery {
|
|
472
|
+
kind: SpotlightRecoveryKind;
|
|
473
|
+
toolCallId: string;
|
|
474
|
+
tool: string;
|
|
475
|
+
/** The call's command, path or pattern, clipped to 200 chars. */
|
|
476
|
+
target: string;
|
|
477
|
+
timestamp: number;
|
|
478
|
+
tokens: number;
|
|
479
|
+
/** Tool calls between the shortened result and this one. */
|
|
480
|
+
after: number;
|
|
481
|
+
/** Its request issued nothing but recovery calls. */
|
|
482
|
+
turn: boolean;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** One evaluated result that changed the output, or would have (`holdout`). */
|
|
486
|
+
export interface SpotlightResultRow {
|
|
487
|
+
sessionFile: string;
|
|
488
|
+
toolCallId: string;
|
|
489
|
+
timestamp: number;
|
|
490
|
+
tool: SpotlightTool;
|
|
491
|
+
/** Held out: the model saw the result unshaped; `savedTokens` is what the cut would have saved. */
|
|
492
|
+
holdout: boolean;
|
|
493
|
+
/** Command, path (with selector) or eval code head, clipped to 200 chars. */
|
|
494
|
+
target: string;
|
|
495
|
+
inTokens: number;
|
|
496
|
+
outTokens: number;
|
|
497
|
+
savedTokens: number;
|
|
498
|
+
hiddenLines: number;
|
|
499
|
+
steps: string[];
|
|
500
|
+
spotlightUsd: number;
|
|
501
|
+
shapeMs: number;
|
|
502
|
+
/** What `plain` would have shown (see {@link SpotlightToolTotals.plainTokens}). */
|
|
503
|
+
plainTokens: number;
|
|
504
|
+
/** Cut by the no-score fallback rules because the score-free coin skipped Spotlight. */
|
|
505
|
+
scoreFree: boolean;
|
|
506
|
+
recoveries: SpotlightRecovery[];
|
|
507
|
+
/** savedTokens − Σ recovery tokens. */
|
|
508
|
+
netTokens: number;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Who saw what for a result in the fetch-back comparison:
|
|
513
|
+
* - `applied`: Spotlight shortened it and the model saw the shortened text;
|
|
514
|
+
* - `holdout`: Spotlight would have shortened it, but the result was held out at random and the model saw it
|
|
515
|
+
* unshaped (the experiment's true counterfactual);
|
|
516
|
+
* - `reference`: shaping left it unchanged (results of the same tool and sessions, standardized to the applied
|
|
517
|
+
* cuts' original-size mix), the stand-in until held-out results accumulate;
|
|
518
|
+
* - `scoreFree`: shortened by the no-score fallback rules because a random coin skipped Spotlight
|
|
519
|
+
* (`spotlight.experiment.scoreFree`), the model saw the cut: against `applied`, what Spotlight's scores add;
|
|
520
|
+
* - `gated`: a read pi's former edit gate (removed) kept whole, the model saw plain's page; only in transcripts
|
|
521
|
+
* journaled while the gate ran.
|
|
522
|
+
* `applied` holds only cuts Spotlight scored (score-free cuts and cuts whose Spotlight calls failed are not in it).
|
|
523
|
+
*/
|
|
524
|
+
export type SpotlightCutGroup = "applied" | "holdout" | "reference" | "scoreFree" | "gated";
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Share of results the agent fetched more of within 12 calls, by one rule for every group: a later `read` of the
|
|
528
|
+
* same path overlapping the result's own window (the whole file without a selector), a rerun (see
|
|
529
|
+
* {@link SpotlightRecoveryKind}), or a read of an artifact the result named; not counted after an edit of that path
|
|
530
|
+
* (reads) or any edit (reruns), nor from the same request.
|
|
531
|
+
*/
|
|
532
|
+
export interface SpotlightFetchBackCell {
|
|
533
|
+
tool: SpotlightTool;
|
|
534
|
+
group: SpotlightCutGroup;
|
|
535
|
+
results: number;
|
|
536
|
+
sessions: number;
|
|
537
|
+
/** Session-clustered bootstrap over the group's results. */
|
|
538
|
+
rate: SpotlightEstimate;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** What the cuts of one tool earned, in tokens and dollars (applied cuts only; held-out results save nothing). */
|
|
542
|
+
export interface SpotlightCutEconomics {
|
|
543
|
+
tool: SpotlightTool;
|
|
544
|
+
cuts: number;
|
|
545
|
+
savedTokens: number;
|
|
546
|
+
recoveredTokens: number;
|
|
547
|
+
/** Requests that did nothing but fetch back output these cuts hid. */
|
|
548
|
+
extraTurns: number;
|
|
549
|
+
savedUsd: number;
|
|
550
|
+
/** Recovered tokens carried through later requests, priced like the savings. */
|
|
551
|
+
recoveryUsd: number;
|
|
552
|
+
/** Provider cost of the extra turns. */
|
|
553
|
+
turnUsd: number;
|
|
554
|
+
/** savedUsd − recoveryUsd − turnUsd − this cell's Spotlight bill. */
|
|
555
|
+
netUsd: number;
|
|
556
|
+
extraTurnsPer100Cuts: number;
|
|
557
|
+
netUsdPer100Cuts: number;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Calls between a cut (or held-out result) and the first fetch-back after it. */
|
|
561
|
+
export type SpotlightGapBin = "1" | "2" | "3" | "4–6" | "7–12";
|
|
562
|
+
|
|
563
|
+
/** Fetch-backs per gap bin and tool, for applied and held-out results: every bin of each tool with at least one. */
|
|
564
|
+
export interface SpotlightGapCount {
|
|
565
|
+
tool: SpotlightTool;
|
|
566
|
+
gap: SpotlightGapBin;
|
|
567
|
+
applied: number;
|
|
568
|
+
holdout: number;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** What shaping costs in time and reliability (all evaluated results, held-out ones included). */
|
|
572
|
+
export interface SpotlightOverhead {
|
|
573
|
+
results: number;
|
|
574
|
+
/** Wall time shaping added to a tool call. */
|
|
575
|
+
shapeMsP50: number | null;
|
|
576
|
+
shapeMsP90: number | null;
|
|
577
|
+
/** Spotlight's own request time, over results whose calls all answered. */
|
|
578
|
+
spotlightMsP50: number | null;
|
|
579
|
+
spotlightMsP90: number | null;
|
|
580
|
+
/** Results whose Spotlight calls failed or timed out (shaped by the no-score fallback). */
|
|
581
|
+
failureRate: number | null;
|
|
582
|
+
/** Wall time tool calls spent shaping results whose Spotlight calls failed (mostly the 5 s timeout per call). */
|
|
583
|
+
failedWaitMs: number;
|
|
584
|
+
spotlightUsd: number;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* The net once fetch-backs that would have happened anyway are taken out: held-out results (the model saw them
|
|
589
|
+
* unshaped) show how much of a would-be cut's output the agent reads again regardless, per tool; only recoveries
|
|
590
|
+
* beyond that baseline are the cut's cost. A tool's baseline is thin while it has fewer than `minHoldouts`.
|
|
591
|
+
*/
|
|
592
|
+
export interface SpotlightAdjustedTool {
|
|
593
|
+
tool: SpotlightTool;
|
|
594
|
+
/** Applied cuts (scored and score-free) and their recovered tokens. */
|
|
595
|
+
cuts: number;
|
|
596
|
+
recoveredTokens: number;
|
|
597
|
+
/** Held-out would-be cuts the baseline is measured on. */
|
|
598
|
+
holdouts: number;
|
|
599
|
+
/** Recovered tokens per held-out would-be cut, over all the tool's holdouts (session-clustered bootstrap). */
|
|
600
|
+
baselinePerCut: SpotlightEstimate;
|
|
601
|
+
/** max(0, recovered − baseline per cut × cuts). */
|
|
602
|
+
excessTokens: SpotlightEstimate;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** Holdout-adjusted net savings (tokens, against the `plain` baseline). */
|
|
606
|
+
export interface SpotlightAdjusted {
|
|
607
|
+
byTool: SpotlightAdjustedTool[];
|
|
608
|
+
/** Σ tools' excess (bootstrapped jointly over sessions). */
|
|
609
|
+
excessTokens: SpotlightEstimate;
|
|
610
|
+
/** gross.savedTokens − excessTokens. */
|
|
611
|
+
netTokens: SpotlightEstimate;
|
|
612
|
+
/** compounding.savedUsd − recoveryUsd × (excess / recovered) − spotlightUsd. */
|
|
613
|
+
netUsd: SpotlightEstimate;
|
|
614
|
+
/** Holdouts per tool below which its baseline is too thin to trust (the UI marks the tool). */
|
|
615
|
+
minHoldouts: number;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Lines of a shaped read's original the agent needed later: lines a later `read` of the same file selected, and lines
|
|
620
|
+
* a later `edit` of it changed (located by its Find text in the original), until the file's first edit or a later
|
|
621
|
+
* whole-file read.
|
|
622
|
+
*/
|
|
623
|
+
export type SpotlightNeedSource = "reread" | "edit";
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* How well a group's per-line choices match what the agent needed later, over shaped reads with at least one needed
|
|
627
|
+
* line. Applied and score-free cuts are biased alike (the agent re-reads what it lacks), so compare them with each
|
|
628
|
+
* other; held-out would-be cuts are the unbiased measure.
|
|
629
|
+
*/
|
|
630
|
+
export interface SpotlightRankingCell {
|
|
631
|
+
group: "applied" | "holdout" | "scoreFree";
|
|
632
|
+
results: number;
|
|
633
|
+
neededLines: number;
|
|
634
|
+
/** P(heat of a needed line > heat of an unneeded line of the same result), ties half; 0.5 is chance. Null for `scoreFree` (no heat). */
|
|
635
|
+
auc: SpotlightEstimate;
|
|
636
|
+
/** Needed-line rate among each result's hottest 10% of lines over its rate among all lines; 1 is no better than chance. */
|
|
637
|
+
topLift: SpotlightEstimate;
|
|
638
|
+
/** Share of needed lines the cut kept over the share of all lines it kept; 1 is a random cut of the same size. */
|
|
639
|
+
keptLift: SpotlightEstimate;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/** Mean heat (0–9) of one line position over shaped results of at least 40 lines. */
|
|
643
|
+
export interface SpotlightHeatPosition {
|
|
644
|
+
/** `line 1`, `lines 2–3`, then `0–10%` … `90–100%` of the output. */
|
|
645
|
+
label: string;
|
|
646
|
+
meanHeat: number;
|
|
647
|
+
lines: number;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** Ranking quality: does Spotlight keep the lines the agent comes back for? */
|
|
651
|
+
export interface SpotlightRanking {
|
|
652
|
+
cells: SpotlightRankingCell[];
|
|
653
|
+
position: SpotlightHeatPosition[];
|
|
654
|
+
/** Results with needed lines, by how the need was observed (a result can count under both). */
|
|
655
|
+
sources: Record<SpotlightNeedSource, number>;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/** Saved-token bins (against `plain`) the step economics split cuts by; a negative saving falls in `<250`. */
|
|
659
|
+
export type SpotlightSizeBin = "<250" | "250–1k" | "1k–4k" | "≥4k";
|
|
660
|
+
|
|
661
|
+
/** What one shaping step (or combination) earns at one cut size: applied cuts of one tool. */
|
|
662
|
+
export interface SpotlightStepCell {
|
|
663
|
+
tool: SpotlightTool;
|
|
664
|
+
/** The cut's shaping steps joined with `+` (`outline+window`); combinations under 10 cuts in the range fold into `other`. */
|
|
665
|
+
steps: string;
|
|
666
|
+
size: SpotlightSizeBin;
|
|
667
|
+
cuts: number;
|
|
668
|
+
fetchBackRate: SpotlightEstimate;
|
|
669
|
+
/** Σ (plain − out), negative cuts (wider than `plain`) included. */
|
|
670
|
+
savedTokens: number;
|
|
671
|
+
recoveredTokens: number;
|
|
672
|
+
/** max(0, recovered − Σ each cut's holdout baseline (its tool's)). */
|
|
673
|
+
excessTokens: number;
|
|
674
|
+
/** (saved − excess) / saved: the share of the saving that stays saved; null when the cell saved nothing (≤ 0). */
|
|
675
|
+
keptShare: number | null;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** What the experiment costs in agent time. */
|
|
679
|
+
export interface SpotlightTimeCost {
|
|
680
|
+
/** Model time of the experiment sessions' requests (Σ request duration). */
|
|
681
|
+
agentMs: number;
|
|
682
|
+
/** Requests that did nothing but fetch back cut output, and their model time. */
|
|
683
|
+
fetchBackTurns: number;
|
|
684
|
+
fetchBackMs: number;
|
|
685
|
+
/** Wall time tool calls spent shaping (Spotlight requests included). */
|
|
686
|
+
shapeMs: number;
|
|
687
|
+
/** (fetchBackMs + shapeMs) / agentMs. */
|
|
688
|
+
share: number | null;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** One tool's share of the tool output experiment sessions' models saw (chars ÷ 4). */
|
|
692
|
+
export interface SpotlightCoverageRow {
|
|
693
|
+
tool: string;
|
|
694
|
+
/** The experiment evaluated results of it in the range. */
|
|
695
|
+
shaped: boolean;
|
|
696
|
+
calls: number;
|
|
697
|
+
tokens: number;
|
|
698
|
+
share: number;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Which transcripts the Spotlight dashboard measures (`GET /api/stats/spotlight?agent=`, default `all`): `main`
|
|
703
|
+
* agents only, task `subagent`s only, or everything (advisors appear only under `all`). Every metric, the share
|
|
704
|
+
* trend's `outside` group included, is filtered the same way.
|
|
705
|
+
*/
|
|
706
|
+
export type SpotlightAgentScope = "all" | "main" | "subagent";
|
|
707
|
+
|
|
708
|
+
/** An experiment session, for the context chart's picker. */
|
|
709
|
+
export interface SpotlightSessionSummary {
|
|
710
|
+
sessionFile: string;
|
|
711
|
+
title: string | null;
|
|
712
|
+
folder: string;
|
|
713
|
+
/** Which agent wrote the transcript (each subagent transcript is its own experiment session). */
|
|
714
|
+
agentType: AgentType;
|
|
715
|
+
/** The session's first Spotlight marker: activity before it (a resumed pre-experiment session) is not measured. */
|
|
716
|
+
startedAt: number;
|
|
717
|
+
requests: number;
|
|
718
|
+
savedTokens: number;
|
|
719
|
+
netUsd: number;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Spotlight dashboard payload (`GET /api/stats/spotlight?range=&agent=`). Every experiment session shapes tool
|
|
724
|
+
* output; held-out results within them are the counterfactual. Only activity at or after a session's Spotlight
|
|
725
|
+
* marker is the experiment's; earlier activity of the same transcript counts as `outside` in the share trend and is
|
|
726
|
+
* left out of every other metric.
|
|
727
|
+
*/
|
|
728
|
+
export interface SpotlightDashboardStats {
|
|
729
|
+
/** Experiment sessions with activity in the range. */
|
|
730
|
+
sessions: number;
|
|
731
|
+
/** First Spotlight marker ever seen (not range-bound), for the trend's marker; null before the experiment. */
|
|
732
|
+
experimentStart: number | null;
|
|
733
|
+
gross: SpotlightGross;
|
|
734
|
+
clawback: SpotlightClawback;
|
|
735
|
+
compounding: SpotlightCompounding;
|
|
736
|
+
series: SpotlightBucket[];
|
|
737
|
+
share: SpotlightSharePoint[];
|
|
738
|
+
/** Latest 60 shortened results, newest first. */
|
|
739
|
+
recent: SpotlightResultRow[];
|
|
740
|
+
/** Latest 30 experiment sessions in the range, newest first. */
|
|
741
|
+
sessionList: SpotlightSessionSummary[];
|
|
742
|
+
/** Held-out results in the range (would-be cuts the model saw unshaped). */
|
|
743
|
+
holdouts: number;
|
|
744
|
+
/** Score-free cuts in the range (shortened without Spotlight by the fallback rules). */
|
|
745
|
+
scoreFree: number;
|
|
746
|
+
adjusted: SpotlightAdjusted;
|
|
747
|
+
ranking: SpotlightRanking;
|
|
748
|
+
steps: SpotlightStepCell[];
|
|
749
|
+
timeCost: SpotlightTimeCost;
|
|
750
|
+
coverage: SpotlightCoverageRow[];
|
|
751
|
+
fetchBack: SpotlightFetchBackCell[];
|
|
752
|
+
economics: SpotlightCutEconomics[];
|
|
753
|
+
gaps: SpotlightGapCount[];
|
|
754
|
+
overhead: SpotlightOverhead;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/** One request of a session's context chart. */
|
|
758
|
+
export interface SpotlightContextPoint {
|
|
759
|
+
timestamp: number;
|
|
760
|
+
/** input + cache read + cache write of this request. */
|
|
761
|
+
contextTokens: number;
|
|
762
|
+
/** The context without shaping: contextTokens + net tokens saved so far (reset at a compaction). */
|
|
763
|
+
withoutTokens: number;
|
|
764
|
+
/** The context shrank sharply before this request (a compaction). */
|
|
765
|
+
compacted: boolean;
|
|
766
|
+
/** Tokens saved and recovered by results that landed since the previous request. */
|
|
767
|
+
saved: number;
|
|
768
|
+
recovered: number;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/** A session's context with and without shaping (`GET /api/stats/spotlight/session?file=`). */
|
|
772
|
+
export interface SpotlightSessionContext {
|
|
773
|
+
session: SpotlightSessionSummary;
|
|
774
|
+
points: SpotlightContextPoint[];
|
|
775
|
+
}
|
|
776
|
+
|
|
324
777
|
/**
|
|
325
778
|
* Aggregated usage for a single tool over the active range.
|
|
326
779
|
*
|