@trazum/core 1.37.0 → 1.38.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/README.md CHANGED
@@ -92,6 +92,20 @@ running on different models in different sources (judged on each source's
92
92
  dearest model, so a stray experiment is not a migration), and names sources
93
93
  where caching loses money while the aggregate pays off.
94
94
 
95
+ ## The plan
96
+
97
+ `buildPlan(report, levers, pricingLastReviewed)` turns a report and its
98
+ levers into a ranked `PlanDocument`: route and batch on one slice arrive as a
99
+ single pre-combined action (`combinedUsd`, never a sum), the truncation
100
+ action's stake is the measured retry bill, and a cache action exists only for
101
+ a settled loss — an unsettled verdict is a missing field, and "add the field"
102
+ is the report's advice, not a plan's. Projected savings and measured stakes
103
+ are totalled separately; every action carries typed assumptions
104
+ (`PlanAssumption`) the log cannot confirm, as data rather than prose, so the
105
+ renderer localizes them and a later verification can match them
106
+ structurally. `planLabelName` renders the unlabelled bucket without leaking
107
+ the sentinel.
108
+
95
109
  ## Comparing two versions
96
110
 
97
111
  ```ts
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ export { coverageDrift, COVERAGE_FIELDS, COVERAGE_DRIFT_MIN } from './coverage-d
13
13
  export { explainGateFailure, gateMargin, GATE_MARGIN_TIGHT } from './gate-explain.js';
14
14
  export { measuredUsage, labelCoverage, MIN_SCALE_DAYS, SCALE_TO_DAYS } from './measured-profile.js';
15
15
  export { assignSources, fleetRollup } from './fleet.js';
16
+ export { buildPlan, planLabelName } from './plan.js';
17
+ export type { PlanAction, PlanActionKind, PlanAssumption, PlanDocument } from './plan.js';
16
18
  export type { FleetSource, FleetRollup } from './fleet.js';
17
19
  export type { MeasuredUsage, LabelCoverage } from './measured-profile.js';
18
20
  export type { GateExplanation } from './gate-explain.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,uBA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AGE_FIELDS, COVERAGE_DRIFT_MIN } from './coverage-d
18
18
  export { explainGateFailure, gateMargin, GATE_MARGIN_TIGHT } from './gate-explain.js';
19
19
  export { measuredUsage, labelCoverage, MIN_SCALE_DAYS, SCALE_TO_DAYS } from './measured-profile.js';
20
20
  export { assignSources, fleetRollup } from './fleet.js';
21
+ export { buildPlan, planLabelName } from './plan.js';
21
22
  // The same tokens at another model's rates — arithmetic, not advice, and it
22
23
  // refuses to price a call the target could not have accepted. See reprice.ts.
23
24
  // The shape of a call's input — the half of the bill a total could only name.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAClF,gFAAgF;AAChF,4EAA4E;AAC5E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtF,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,yCAAyC;AACzC,4EAA4E;AAC5E,qDAAqD;AACrD,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,M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EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEpE,kDAAkD;AAClD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAGlB,6BAA6B;AAC7B,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpE,qEAAqE;AACrE,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAG3E,kFAAkF;AAClF,kFAAkF;AAClF,wCAAwC;AACxC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzF,mEAAmE;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGjE,gCAAgC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ9C,0EAA0E;AAC1E,+EAA+E;AAC/E,8EAA8E;AAC9E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,8EAA8E;AAC9E,6EAA6E;AAC7E,2DAA2D;AAC3D,OAAO,EACL,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/plan.d.ts ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Not a list of findings — a ranked, costed, non-additive plan of what to do.
3
+ *
4
+ * The report names findings; a person then decides what to do first by doing
5
+ * arithmetic in their head, and head-arithmetic on savings gets done by
6
+ * *adding* them — which the levers module has documented as wrong since it
7
+ * shipped ($12.60 plus $10.50 against a $21.00 slice). This module does the
8
+ * composition once, correctly, and attaches to every action the things the
9
+ * log cannot confirm, because a plan that hides its assumptions is advice
10
+ * pretending to be arithmetic.
11
+ *
12
+ * **Everything here is derived from figures the report already computed.**
13
+ * Route and batch come from `billLevers` (combined, never summed). The
14
+ * truncation action's stake is the retry bill `truncationRetries` measured.
15
+ * The cache action's stake is `cacheEconomics`' own delta. Nothing is
16
+ * invented, and each action carries how to check the part that is not
17
+ * arithmetic.
18
+ *
19
+ * **The total is stated honestly.** Actions on *different* slices add
20
+ * cleanly; the one composition that does not add — route and batch on the
21
+ * same slice — arrives already combined inside a single action, so the
22
+ * plan's total is a sum of non-overlapping figures by construction. Measured
23
+ * stakes (money already spent on retries, money already lost to caching) are
24
+ * totalled separately from projected savings: "what you would save" and
25
+ * "what you already paid" are different columns, and merging them makes a
26
+ * number that is neither.
27
+ */
28
+ import type { UsageProfileReport } from './usage.js';
29
+ import type { BillLevers } from './levers.js';
30
+ export type PlanActionKind = 'route' | 'batch' | 'route+batch' | 'fix-truncation' | 'fix-caching';
31
+ /**
32
+ * What the log cannot confirm, as data rather than prose.
33
+ *
34
+ * Rendering lives with whoever renders — the CLI localizes these, and 1.39's
35
+ * verification can match them structurally. An English sentence baked in here
36
+ * would be a browser-safe module deciding the reader's language.
37
+ */
38
+ export type PlanAssumption =
39
+ /** The cheaper model can actually do this work — quality, not arithmetic. */
40
+ {
41
+ kind: 'model-capability';
42
+ model: string;
43
+ }
44
+ /** These calls tolerate a batch window's latency. */
45
+ | {
46
+ kind: 'batch-window';
47
+ }
48
+ /** The truncation-retry pairing is real — the log sees shapes, not content. */
49
+ | {
50
+ kind: 'retry-pattern-real';
51
+ }
52
+ /** A max_tokens the answers fit inside removes the retry pair. */
53
+ | {
54
+ kind: 'max-tokens-fits';
55
+ }
56
+ /** The traffic pattern holds — a cache underwater on this log may pay on other traffic. */
57
+ | {
58
+ kind: 'traffic-pattern-holds';
59
+ };
60
+ export interface PlanAction {
61
+ kind: PlanActionKind;
62
+ /** The workload this acts on. `UNLABELLED` renders as the unlabelled bucket. */
63
+ label: string;
64
+ model: string;
65
+ /**
66
+ * Projected saving per the log's own period, for route/batch — or null for
67
+ * the measured-stake actions, whose money is in `stakeUsd` instead. Never
68
+ * both: a projection and a measurement in one field is a number that is
69
+ * neither.
70
+ */
71
+ savingUsd: number | null;
72
+ /**
73
+ * Money already measured against this problem — the retry bill, the cache
74
+ * loss. Null for the projected actions.
75
+ */
76
+ stakeUsd: number | null;
77
+ /** What the log cannot confirm. Every entry is a human's question to answer. */
78
+ assumes: PlanAssumption[];
79
+ /** How to check the assumption, when a Trazum command can. */
80
+ check: string | null;
81
+ /** What this action does, in one machine-stable keyword per detail. */
82
+ detail: {
83
+ /** Route target, when the action moves the calls. */
84
+ routeTo?: {
85
+ id: string;
86
+ displayName: string;
87
+ };
88
+ /** The measured pieces behind a stake. */
89
+ measured?: Record<string, number>;
90
+ };
91
+ }
92
+ export interface PlanDocument {
93
+ /** Same contract discipline as the profile JSON. */
94
+ schemaVersion: 1;
95
+ /** The period the plan's figures cover, or null when the log had no clock. */
96
+ span: {
97
+ fromMs: number;
98
+ toMs: number;
99
+ } | null;
100
+ /** The price table behind every dollar here. */
101
+ pricingLastReviewed: string;
102
+ /** Ranked: largest money first, projected or staked alike. */
103
+ actions: PlanAction[];
104
+ /**
105
+ * Projected savings summed — additive by construction, because same-slice
106
+ * compositions arrive pre-combined in one action.
107
+ */
108
+ projectedSavingUsd: number;
109
+ /** Measured stakes summed: money already paid to problems this plan names. */
110
+ measuredStakeUsd: number;
111
+ /** The bill the plan was made against. */
112
+ totalUsd: number;
113
+ }
114
+ /**
115
+ * Builds the plan from a report and its levers.
116
+ *
117
+ * `pricingLastReviewed` is passed in rather than imported so the plan records
118
+ * the catalogue that actually priced it — an overlay's date when one was in
119
+ * effect, which 1.39's verification needs to tell "the prediction was wrong"
120
+ * from "the prices changed".
121
+ */
122
+ export declare function buildPlan(report: UsageProfileReport, levers: BillLevers, pricingLastReviewed: string): PlanDocument;
123
+ /** Renders `UNLABELLED` for humans without leaking the sentinel. */
124
+ export declare function planLabelName(label: string, unlabelled: string): string;
125
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,MAAM,cAAc;AACxB,6EAA6E;AAC3E;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC7C,qDAAqD;GACnD;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE;AAC1B,+EAA+E;GAC7E;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE;AAChC,kEAAkE;GAChE;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE;AAC7B,2FAA2F;GACzF;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gFAAgF;IAChF,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,MAAM,EAAE;QACN,qDAAqD;QACrD,OAAO,CAAC,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;QAC9C,0CAA0C;QAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,aAAa,EAAE,CAAC,CAAC;IACjB,8EAA8E;IAC9E,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,gDAAgD;IAChD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,UAAU,EAClB,mBAAmB,EAAE,MAAM,GAC1B,YAAY,CAsFd;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvE"}
package/dist/plan.js ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Not a list of findings — a ranked, costed, non-additive plan of what to do.
3
+ *
4
+ * The report names findings; a person then decides what to do first by doing
5
+ * arithmetic in their head, and head-arithmetic on savings gets done by
6
+ * *adding* them — which the levers module has documented as wrong since it
7
+ * shipped ($12.60 plus $10.50 against a $21.00 slice). This module does the
8
+ * composition once, correctly, and attaches to every action the things the
9
+ * log cannot confirm, because a plan that hides its assumptions is advice
10
+ * pretending to be arithmetic.
11
+ *
12
+ * **Everything here is derived from figures the report already computed.**
13
+ * Route and batch come from `billLevers` (combined, never summed). The
14
+ * truncation action's stake is the retry bill `truncationRetries` measured.
15
+ * The cache action's stake is `cacheEconomics`' own delta. Nothing is
16
+ * invented, and each action carries how to check the part that is not
17
+ * arithmetic.
18
+ *
19
+ * **The total is stated honestly.** Actions on *different* slices add
20
+ * cleanly; the one composition that does not add — route and batch on the
21
+ * same slice — arrives already combined inside a single action, so the
22
+ * plan's total is a sum of non-overlapping figures by construction. Measured
23
+ * stakes (money already spent on retries, money already lost to caching) are
24
+ * totalled separately from projected savings: "what you would save" and
25
+ * "what you already paid" are different columns, and merging them makes a
26
+ * number that is neither.
27
+ */
28
+ import { UNLABELLED, cacheEconomics } from './usage.js';
29
+ /**
30
+ * Builds the plan from a report and its levers.
31
+ *
32
+ * `pricingLastReviewed` is passed in rather than imported so the plan records
33
+ * the catalogue that actually priced it — an overlay's date when one was in
34
+ * effect, which 1.39's verification needs to tell "the prediction was wrong"
35
+ * from "the prices changed".
36
+ */
37
+ export function buildPlan(report, levers, pricingLastReviewed) {
38
+ const actions = [];
39
+ for (const slice of levers.slices) {
40
+ const assumes = [];
41
+ let kind;
42
+ if (slice.route !== null && slice.batch !== null) {
43
+ kind = 'route+batch';
44
+ assumes.push({ kind: 'model-capability', model: slice.route.candidate.displayName });
45
+ assumes.push({ kind: 'batch-window' });
46
+ }
47
+ else if (slice.route !== null) {
48
+ kind = 'route';
49
+ assumes.push({ kind: 'model-capability', model: slice.route.candidate.displayName });
50
+ }
51
+ else if (slice.batch !== null) {
52
+ kind = 'batch';
53
+ assumes.push({ kind: 'batch-window' });
54
+ }
55
+ else {
56
+ continue;
57
+ }
58
+ actions.push({
59
+ kind,
60
+ label: slice.label,
61
+ model: slice.model,
62
+ savingUsd: slice.combinedUsd,
63
+ stakeUsd: null,
64
+ assumes,
65
+ check: slice.route !== null ? 'trazum route <log> --prompt-file <prompt> --cases <cases>' : null,
66
+ detail: slice.route !== null ? { routeTo: slice.route.candidate } : {},
67
+ });
68
+ }
69
+ for (const row of report.truncationRetries) {
70
+ actions.push({
71
+ kind: 'fix-truncation',
72
+ label: row.label,
73
+ model: row.model,
74
+ savingUsd: null,
75
+ stakeUsd: row.wastedUsd + row.retryUsd,
76
+ assumes: [{ kind: 'retry-pattern-real' }, { kind: 'max-tokens-fits' }],
77
+ check: null,
78
+ detail: {
79
+ measured: {
80
+ wastedUsd: row.wastedUsd,
81
+ retryUsd: row.retryUsd,
82
+ retried: row.retried,
83
+ truncatedCalls: row.truncatedCalls,
84
+ },
85
+ },
86
+ });
87
+ }
88
+ for (const slice of report.byLabelAndModel) {
89
+ const economics = cacheEconomics(slice.breakdown);
90
+ // Only a settled loss becomes an action: an unsettled verdict is a
91
+ // missing field, and "add the field" is the report's advice, not a plan's.
92
+ if (economics.verdict !== 'lost-money' || economics.worstCaseVerdict !== economics.verdict)
93
+ continue;
94
+ actions.push({
95
+ kind: 'fix-caching',
96
+ label: slice.label,
97
+ model: slice.model,
98
+ savingUsd: null,
99
+ stakeUsd: economics.deltaUsd,
100
+ assumes: [{ kind: 'traffic-pattern-holds' }],
101
+ check: null,
102
+ detail: {
103
+ measured: {
104
+ spentUsd: economics.spentUsd,
105
+ withoutCachingUsd: economics.withoutCachingUsd,
106
+ },
107
+ },
108
+ });
109
+ }
110
+ actions.sort((a, b) => (b.savingUsd ?? b.stakeUsd ?? 0) - (a.savingUsd ?? a.stakeUsd ?? 0));
111
+ return {
112
+ schemaVersion: 1,
113
+ span: report.span === null ? null : { fromMs: report.span.fromMs, toMs: report.span.toMs },
114
+ pricingLastReviewed,
115
+ actions,
116
+ projectedSavingUsd: actions.reduce((sum, a) => sum + (a.savingUsd ?? 0), 0),
117
+ measuredStakeUsd: actions.reduce((sum, a) => sum + (a.stakeUsd ?? 0), 0),
118
+ totalUsd: report.total.totalUsd,
119
+ };
120
+ }
121
+ /** Renders `UNLABELLED` for humans without leaking the sentinel. */
122
+ export function planLabelName(label, unlabelled) {
123
+ return label === UNLABELLED ? unlabelled : label;
124
+ }
125
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA2ExD;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,MAA0B,EAC1B,MAAkB,EAClB,mBAA2B;IAE3B,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,MAAM,OAAO,GAAqB,EAAE,CAAC;QACrC,IAAI,IAAoB,CAAC;QACzB,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACjD,IAAI,GAAG,aAAa,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;YACrF,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACzC,CAAC;aAAM,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAChC,IAAI,GAAG,OAAO,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACvF,CAAC;aAAM,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAChC,IAAI,GAAG,OAAO,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAA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AAC,EAAE,CAAC,CAAC;QAC3E,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QACxE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;KAChC,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,UAAkB;IAC7D,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/core",
3
- "version": "1.37.0",
3
+ "version": "1.38.0",
4
4
  "description": "Trazum core: priced advisories for LLM prompts (caching, model tier, batching, schemas), plus deterministic trimming, token counting and pricing.",
5
5
  "license": "MIT",
6
6
  "author": "David Mu\u00f1oz Rey",
package/src/index.ts CHANGED
@@ -44,6 +44,8 @@ export { coverageDrift, COVERAGE_FIELDS, COVERAGE_DRIFT_MIN } from './coverage-d
44
44
  export { explainGateFailure, gateMargin, GATE_MARGIN_TIGHT } from './gate-explain.js';
45
45
  export { measuredUsage, labelCoverage, MIN_SCALE_DAYS, SCALE_TO_DAYS } from './measured-profile.js';
46
46
  export { assignSources, fleetRollup } from './fleet.js';
47
+ export { buildPlan, planLabelName } from './plan.js';
48
+ export type { PlanAction, PlanActionKind, PlanAssumption, PlanDocument } from './plan.js';
47
49
  export type { FleetSource, FleetRollup } from './fleet.js';
48
50
  export type { MeasuredUsage, LabelCoverage } from './measured-profile.js';
49
51
  export type { GateExplanation } from './gate-explain.js';
package/src/plan.ts ADDED
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Not a list of findings — a ranked, costed, non-additive plan of what to do.
3
+ *
4
+ * The report names findings; a person then decides what to do first by doing
5
+ * arithmetic in their head, and head-arithmetic on savings gets done by
6
+ * *adding* them — which the levers module has documented as wrong since it
7
+ * shipped ($12.60 plus $10.50 against a $21.00 slice). This module does the
8
+ * composition once, correctly, and attaches to every action the things the
9
+ * log cannot confirm, because a plan that hides its assumptions is advice
10
+ * pretending to be arithmetic.
11
+ *
12
+ * **Everything here is derived from figures the report already computed.**
13
+ * Route and batch come from `billLevers` (combined, never summed). The
14
+ * truncation action's stake is the retry bill `truncationRetries` measured.
15
+ * The cache action's stake is `cacheEconomics`' own delta. Nothing is
16
+ * invented, and each action carries how to check the part that is not
17
+ * arithmetic.
18
+ *
19
+ * **The total is stated honestly.** Actions on *different* slices add
20
+ * cleanly; the one composition that does not add — route and batch on the
21
+ * same slice — arrives already combined inside a single action, so the
22
+ * plan's total is a sum of non-overlapping figures by construction. Measured
23
+ * stakes (money already spent on retries, money already lost to caching) are
24
+ * totalled separately from projected savings: "what you would save" and
25
+ * "what you already paid" are different columns, and merging them makes a
26
+ * number that is neither.
27
+ */
28
+
29
+ import { UNLABELLED, cacheEconomics } from './usage.js';
30
+ import type { UsageProfileReport } from './usage.js';
31
+ import type { BillLevers } from './levers.js';
32
+
33
+ export type PlanActionKind = 'route' | 'batch' | 'route+batch' | 'fix-truncation' | 'fix-caching';
34
+
35
+ /**
36
+ * What the log cannot confirm, as data rather than prose.
37
+ *
38
+ * Rendering lives with whoever renders — the CLI localizes these, and 1.39's
39
+ * verification can match them structurally. An English sentence baked in here
40
+ * would be a browser-safe module deciding the reader's language.
41
+ */
42
+ export type PlanAssumption =
43
+ /** The cheaper model can actually do this work — quality, not arithmetic. */
44
+ | { kind: 'model-capability'; model: string }
45
+ /** These calls tolerate a batch window's latency. */
46
+ | { kind: 'batch-window' }
47
+ /** The truncation-retry pairing is real — the log sees shapes, not content. */
48
+ | { kind: 'retry-pattern-real' }
49
+ /** A max_tokens the answers fit inside removes the retry pair. */
50
+ | { kind: 'max-tokens-fits' }
51
+ /** The traffic pattern holds — a cache underwater on this log may pay on other traffic. */
52
+ | { kind: 'traffic-pattern-holds' };
53
+
54
+ export interface PlanAction {
55
+ kind: PlanActionKind;
56
+ /** The workload this acts on. `UNLABELLED` renders as the unlabelled bucket. */
57
+ label: string;
58
+ model: string;
59
+ /**
60
+ * Projected saving per the log's own period, for route/batch — or null for
61
+ * the measured-stake actions, whose money is in `stakeUsd` instead. Never
62
+ * both: a projection and a measurement in one field is a number that is
63
+ * neither.
64
+ */
65
+ savingUsd: number | null;
66
+ /**
67
+ * Money already measured against this problem — the retry bill, the cache
68
+ * loss. Null for the projected actions.
69
+ */
70
+ stakeUsd: number | null;
71
+ /** What the log cannot confirm. Every entry is a human's question to answer. */
72
+ assumes: PlanAssumption[];
73
+ /** How to check the assumption, when a Trazum command can. */
74
+ check: string | null;
75
+ /** What this action does, in one machine-stable keyword per detail. */
76
+ detail: {
77
+ /** Route target, when the action moves the calls. */
78
+ routeTo?: { id: string; displayName: string };
79
+ /** The measured pieces behind a stake. */
80
+ measured?: Record<string, number>;
81
+ };
82
+ }
83
+
84
+ export interface PlanDocument {
85
+ /** Same contract discipline as the profile JSON. */
86
+ schemaVersion: 1;
87
+ /** The period the plan's figures cover, or null when the log had no clock. */
88
+ span: { fromMs: number; toMs: number } | null;
89
+ /** The price table behind every dollar here. */
90
+ pricingLastReviewed: string;
91
+ /** Ranked: largest money first, projected or staked alike. */
92
+ actions: PlanAction[];
93
+ /**
94
+ * Projected savings summed — additive by construction, because same-slice
95
+ * compositions arrive pre-combined in one action.
96
+ */
97
+ projectedSavingUsd: number;
98
+ /** Measured stakes summed: money already paid to problems this plan names. */
99
+ measuredStakeUsd: number;
100
+ /** The bill the plan was made against. */
101
+ totalUsd: number;
102
+ }
103
+
104
+ /**
105
+ * Builds the plan from a report and its levers.
106
+ *
107
+ * `pricingLastReviewed` is passed in rather than imported so the plan records
108
+ * the catalogue that actually priced it — an overlay's date when one was in
109
+ * effect, which 1.39's verification needs to tell "the prediction was wrong"
110
+ * from "the prices changed".
111
+ */
112
+ export function buildPlan(
113
+ report: UsageProfileReport,
114
+ levers: BillLevers,
115
+ pricingLastReviewed: string,
116
+ ): PlanDocument {
117
+ const actions: PlanAction[] = [];
118
+
119
+ for (const slice of levers.slices) {
120
+ const assumes: PlanAssumption[] = [];
121
+ let kind: PlanActionKind;
122
+ if (slice.route !== null && slice.batch !== null) {
123
+ kind = 'route+batch';
124
+ assumes.push({ kind: 'model-capability', model: slice.route.candidate.displayName });
125
+ assumes.push({ kind: 'batch-window' });
126
+ } else if (slice.route !== null) {
127
+ kind = 'route';
128
+ assumes.push({ kind: 'model-capability', model: slice.route.candidate.displayName });
129
+ } else if (slice.batch !== null) {
130
+ kind = 'batch';
131
+ assumes.push({ kind: 'batch-window' });
132
+ } else {
133
+ continue;
134
+ }
135
+ actions.push({
136
+ kind,
137
+ label: slice.label,
138
+ model: slice.model,
139
+ savingUsd: slice.combinedUsd,
140
+ stakeUsd: null,
141
+ assumes,
142
+ check: slice.route !== null ? 'trazum route <log> --prompt-file <prompt> --cases <cases>' : null,
143
+ detail: slice.route !== null ? { routeTo: slice.route.candidate } : {},
144
+ });
145
+ }
146
+
147
+ for (const row of report.truncationRetries) {
148
+ actions.push({
149
+ kind: 'fix-truncation',
150
+ label: row.label,
151
+ model: row.model,
152
+ savingUsd: null,
153
+ stakeUsd: row.wastedUsd + row.retryUsd,
154
+ assumes: [{ kind: 'retry-pattern-real' }, { kind: 'max-tokens-fits' }],
155
+ check: null,
156
+ detail: {
157
+ measured: {
158
+ wastedUsd: row.wastedUsd,
159
+ retryUsd: row.retryUsd,
160
+ retried: row.retried,
161
+ truncatedCalls: row.truncatedCalls,
162
+ },
163
+ },
164
+ });
165
+ }
166
+
167
+ for (const slice of report.byLabelAndModel) {
168
+ const economics = cacheEconomics(slice.breakdown);
169
+ // Only a settled loss becomes an action: an unsettled verdict is a
170
+ // missing field, and "add the field" is the report's advice, not a plan's.
171
+ if (economics.verdict !== 'lost-money' || economics.worstCaseVerdict !== economics.verdict) continue;
172
+ actions.push({
173
+ kind: 'fix-caching',
174
+ label: slice.label,
175
+ model: slice.model,
176
+ savingUsd: null,
177
+ stakeUsd: economics.deltaUsd,
178
+ assumes: [{ kind: 'traffic-pattern-holds' }],
179
+ check: null,
180
+ detail: {
181
+ measured: {
182
+ spentUsd: economics.spentUsd,
183
+ withoutCachingUsd: economics.withoutCachingUsd,
184
+ },
185
+ },
186
+ });
187
+ }
188
+
189
+ actions.sort(
190
+ (a, b) => (b.savingUsd ?? b.stakeUsd ?? 0) - (a.savingUsd ?? a.stakeUsd ?? 0),
191
+ );
192
+
193
+ return {
194
+ schemaVersion: 1,
195
+ span: report.span === null ? null : { fromMs: report.span.fromMs, toMs: report.span.toMs },
196
+ pricingLastReviewed,
197
+ actions,
198
+ projectedSavingUsd: actions.reduce((sum, a) => sum + (a.savingUsd ?? 0), 0),
199
+ measuredStakeUsd: actions.reduce((sum, a) => sum + (a.stakeUsd ?? 0), 0),
200
+ totalUsd: report.total.totalUsd,
201
+ };
202
+ }
203
+
204
+ /** Renders `UNLABELLED` for humans without leaking the sentinel. */
205
+ export function planLabelName(label: string, unlabelled: string): string {
206
+ return label === UNLABELLED ? unlabelled : label;
207
+ }