@trazum/core 1.45.0 → 1.46.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/dist/index.d.ts CHANGED
@@ -20,6 +20,8 @@ export { buildHistory, storedReportFrom, MIN_RUN } from './history.js';
20
20
  export { answerCost } from './answer.js';
21
21
  export { guardSpend } from './guard.js';
22
22
  export type { GuardAlternative, GuardAnswer, GuardRequest, GuardVerdict } from './guard.js';
23
+ export { proposeInit, HEADLINE_FLOOR_SHARE, MIN_RATE_DAYS } from './init.js';
24
+ export type { InitDecline, InitHeadline, InitJustification, InitKey, InitObservations, InitOptions, InitProposal, NoHeadline, ProviderSighting, UsageSighting, } from './init.js';
23
25
  export type { AnswerRequest, AnswerVerdict, BudgetPosition, CallEstimate, CannotTellReasonAnswer, CostAnswer, } from './answer.js';
24
26
  export { evaluateWatch, firedKey, COVERAGE_FLOOR, DAY_MS } from './watch.js';
25
27
  export type { NotJudgeable, WatchAbstention, WatchCrossing, WatchGate, WatchOptions, WatchResult, WatchThresholds, } from './watch.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","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;AACpB,YAAY,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,c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MIN_RUN } from './history.js';
24
24
  export { answerCost } from './answer.js';
25
25
  export { guardSpend } from './guard.js';
26
+ export { proposeInit, HEADLINE_FLOOR_SHARE, MIN_RATE_DAYS } from './init.js';
26
27
  export { evaluateWatch, firedKey, COVERAGE_FLOOR, DAY_MS } from './watch.js';
27
28
  export { STORE_SCHEMA_VERSION, identityOf, resolveStore, recordsFromBuckets, bucketsFromRecords, storeInventory, pruneRecords, } from './store.js';
28
29
  export { CONNECTORS, connectorFor, normalizeAnthropicUsage, normalizeOpenAIUsage, bucketedProfile, bucketedCacheEconomics, } from './connector.js';
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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,OAAO,EAAE,OAAO,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/init.d.ts ADDED
@@ -0,0 +1,231 @@
1
+ /**
2
+ * The first five minutes, decided without touching a disk.
3
+ *
4
+ * Everything since 1.41 raised the ceiling. This lowers the floor: from
5
+ * `npx @trazum/cli` to a finding worth money, without reading a page of
6
+ * documentation. Twenty-one commands is a wall to somebody who has none of
7
+ * them yet, and that wall is why a good tool gets closed inside a minute.
8
+ *
9
+ * **The proposal is a document, not a side effect.** What `init` would write
10
+ * is decided here, from observations the CLI collected, and returned as a
11
+ * value. So every rule below is testable without a filesystem, and `--dry-run`
12
+ * is the same code path minus the write rather than a second implementation
13
+ * that drifts from the first.
14
+ *
15
+ * **A key with no evidence is not written.** A generated config full of
16
+ * guessed thresholds is a config nobody trusts and everybody deletes — and it
17
+ * is worse than an empty one, because it looks like a decision somebody made.
18
+ * Every key that lands carries the observation that justified it; every key
19
+ * that does not carries what would settle it. Both are typed values, because a
20
+ * first run that explains itself only in prose cannot be checked by a test.
21
+ *
22
+ * **Measurement is not policy.** A log says what your traffic *was* — how many
23
+ * calls, which model, how long the outputs ran. Those are measurements and
24
+ * this file writes them. A budget says what your traffic *may cost*, which no
25
+ * log can answer: picking "the measured month plus twenty per cent" would be
26
+ * this tool inventing a threshold and then grading somebody against it. So
27
+ * `spend` is always declined, and the measured figure is handed over so the
28
+ * person who *can* set a budget has the number in front of them.
29
+ */
30
+ import type { TrazumConfig } from './config-schema.js';
31
+ import type { Detection, EvidenceKind } from './detect.js';
32
+ import type { HostEnvironment } from './host.js';
33
+ import type { SliceLevers } from './levers.js';
34
+ import type { PricingCatalogue } from './pricing.js';
35
+ import type { UsageProfileReport } from './usage.js';
36
+ import type { Locale } from './i18n/index.js';
37
+ /** A source file that was read, and what `detectFromSource` made of it. */
38
+ export interface ProviderSighting {
39
+ file: string;
40
+ detection: Detection;
41
+ }
42
+ /**
43
+ * Something that might hold usage, found lying around.
44
+ *
45
+ * `where` is a path for the file kinds and the **name** of an environment
46
+ * variable for a credential — never its value. That rule has held since the
47
+ * connector shipped in 1.41 and it holds here: a first-run summary is the
48
+ * single most likely thing somebody pastes into a chat window.
49
+ */
50
+ export interface UsageSighting {
51
+ kind: 'log-file' | 'log-directory' | 'store' | 'connector-credential';
52
+ where: string;
53
+ /** The provider this source belongs to, when the sighting names one. */
54
+ provider: string | null;
55
+ }
56
+ /** Everything the CLI saw, handed over as data. */
57
+ export interface InitObservations {
58
+ host: HostEnvironment;
59
+ /** Every source file read, strongest evidence first within each file. */
60
+ sightings: ProviderSighting[];
61
+ /** Prompt files the walk found. */
62
+ promptFiles: string[];
63
+ /** Usage sources found. Empty is a real answer and is reported as one. */
64
+ usage: UsageSighting[];
65
+ /**
66
+ * The profile of a usage source that was found **and** parsed.
67
+ *
68
+ * Null covers two different situations and the proposal keeps them apart:
69
+ * nothing was found, or something was found and could not be read. The
70
+ * caller says which by what it puts in `usage`.
71
+ */
72
+ measured: UsageProfileReport | null;
73
+ /** The locale the environment asked for, when it asked for one. */
74
+ locale: Locale | null;
75
+ /** A config already sitting in the working directory. */
76
+ existing: {
77
+ path: string;
78
+ config: TrazumConfig;
79
+ } | null;
80
+ }
81
+ /** Every config key `init` is allowed to have an opinion about. */
82
+ export type InitKey = 'locale' | 'extensions' | 'usage.model' | 'usage.callsPerMonth' | 'usage.avgOutputTokens' | 'usage.cacheHitRate' | 'usage.batchEligible' | 'labels' | 'spend.maxUsd';
83
+ /** Why a key was written, in a shape a test can assert on. */
84
+ export type InitJustification = {
85
+ key: 'locale';
86
+ value: Locale;
87
+ from: 'environment';
88
+ } | {
89
+ key: 'extensions';
90
+ value: string[];
91
+ from: 'walk';
92
+ files: number;
93
+ } | {
94
+ key: 'usage.model';
95
+ value: string;
96
+ from: 'measured';
97
+ /** Share of the measured bill this model carries, 0-1. */
98
+ share: number;
99
+ } | {
100
+ key: 'usage.model';
101
+ value: string;
102
+ from: 'source';
103
+ file: string;
104
+ line: number;
105
+ evidence: EvidenceKind;
106
+ } | {
107
+ key: 'usage.callsPerMonth';
108
+ value: number;
109
+ from: 'measured';
110
+ calls: number;
111
+ days: number;
112
+ } | {
113
+ key: 'usage.avgOutputTokens';
114
+ value: number;
115
+ from: 'measured';
116
+ outputTokens: number;
117
+ calls: number;
118
+ } | {
119
+ key: 'usage.cacheHitRate';
120
+ value: number;
121
+ from: 'measured';
122
+ cacheReadTokens: number;
123
+ inputTokens: number;
124
+ };
125
+ /**
126
+ * Why a key was left out, and what would settle it.
127
+ *
128
+ * A refusal never arrives bare — the rule the guard established in 1.45, here
129
+ * applied to a file rather than to a call. "No provider written" with nothing
130
+ * after it is indistinguishable from a bug.
131
+ */
132
+ export type InitDecline = {
133
+ key: 'usage.model';
134
+ why: 'no-evidence';
135
+ } | {
136
+ key: 'usage.model';
137
+ why: 'conflicting-evidence';
138
+ files: string[];
139
+ } | {
140
+ key: 'usage.model';
141
+ why: 'provider-only';
142
+ provider: string;
143
+ file: string;
144
+ } | {
145
+ key: 'usage.callsPerMonth';
146
+ why: 'nothing-measured';
147
+ } | {
148
+ key: 'usage.callsPerMonth';
149
+ why: 'window-too-short';
150
+ days: number;
151
+ calls: number;
152
+ } | {
153
+ key: 'usage.callsPerMonth';
154
+ why: 'undated-calls';
155
+ undated: number;
156
+ calls: number;
157
+ } | {
158
+ key: 'usage.avgOutputTokens';
159
+ why: 'nothing-measured';
160
+ } | {
161
+ key: 'usage.cacheHitRate';
162
+ why: 'nothing-measured';
163
+ } | {
164
+ key: 'usage.cacheHitRate';
165
+ why: 'not-recorded';
166
+ } | {
167
+ key: 'usage.batchEligible';
168
+ why: 'only-you-know';
169
+ } | {
170
+ key: 'labels';
171
+ why: 'unprovable';
172
+ labels: number;
173
+ } | {
174
+ key: 'spend.maxUsd';
175
+ why: 'a-budget-is-a-policy';
176
+ measuredUsd: number | null;
177
+ days: number | null;
178
+ };
179
+ /**
180
+ * The single most valuable thing the first run found, with its arithmetic.
181
+ *
182
+ * One finding, not a ranked table. `doctor` and `plan` exist for the table,
183
+ * and a first run that opens with fourteen rows has told somebody nothing —
184
+ * they came to find out whether this is worth an afternoon.
185
+ */
186
+ export interface InitHeadline {
187
+ slice: SliceLevers;
188
+ /** Which lever the figure is. `route+batch` is computed, never summed. */
189
+ lever: 'route' | 'batch' | 'route+batch';
190
+ savingUsd: number;
191
+ /** Always measured. Nothing in a headline rests on a call that never happened. */
192
+ provenance: 'measured';
193
+ /** Days of measurement behind it, so the figure has a unit a reader can check. */
194
+ days: number;
195
+ }
196
+ export type NoHeadline = 'nothing-measured' | 'nothing-could-be-priced' | 'no-lever-clears-the-floor';
197
+ export interface InitProposal {
198
+ schemaVersion: 1;
199
+ /** Exactly the keys that were justified, and nothing else. */
200
+ config: TrazumConfig;
201
+ justified: InitJustification[];
202
+ declined: InitDecline[];
203
+ headline: InitHeadline | null;
204
+ /** Set when `headline` is null, so "nothing found" is never bare. */
205
+ noHeadline: NoHeadline | null;
206
+ /**
207
+ * The config already there, and which of its keys this proposal would
208
+ * change. Named before anything is written: an `init` that silently replaces
209
+ * a config somebody tuned is the worst possible first impression.
210
+ */
211
+ overwrites: {
212
+ path: string;
213
+ keys: InitKey[];
214
+ } | null;
215
+ }
216
+ /**
217
+ * The shortest measured span that may be stated as a monthly rate.
218
+ *
219
+ * Four weeks, so every weekday appears the same number of times. Three days of
220
+ * traffic multiplied by ten is a forecast wearing a measurement's clothes, and
221
+ * this repository has refused that since the series shipped in 1.40.
222
+ */
223
+ export declare const MIN_RATE_DAYS = 28;
224
+ /** The share of the bill a headline must clear to be worth being the headline. */
225
+ export declare const HEADLINE_FLOOR_SHARE = 0.01;
226
+ export interface InitOptions {
227
+ catalogue: PricingCatalogue;
228
+ on?: Date;
229
+ }
230
+ export declare function proposeInit(observations: InitObservations, options: InitOptions): InitProposal;
231
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,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;IAC1E,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,UAAU,EAAE,UAAU,CAAC;IACvB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,yBAAyB,GACzB,2BAA2B,CAAC;AAEhC,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,CAAC,CAAC;IACjB,8DAA8D;IAC9D,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,qEAAqE;IACrE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;CACtD;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAqCzC,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,EAAE,CAAC,EAAE,IAAI,CAAC;CACX;AAED,wBAAgB,WAAW,CACzB,YAAY,EAAE,gBAAgB,EAC9B,OAAO,EAAE,WAAW,GACnB,YAAY,CAyPd"}
package/dist/init.js ADDED
@@ -0,0 +1,325 @@
1
+ /**
2
+ * The first five minutes, decided without touching a disk.
3
+ *
4
+ * Everything since 1.41 raised the ceiling. This lowers the floor: from
5
+ * `npx @trazum/cli` to a finding worth money, without reading a page of
6
+ * documentation. Twenty-one commands is a wall to somebody who has none of
7
+ * them yet, and that wall is why a good tool gets closed inside a minute.
8
+ *
9
+ * **The proposal is a document, not a side effect.** What `init` would write
10
+ * is decided here, from observations the CLI collected, and returned as a
11
+ * value. So every rule below is testable without a filesystem, and `--dry-run`
12
+ * is the same code path minus the write rather than a second implementation
13
+ * that drifts from the first.
14
+ *
15
+ * **A key with no evidence is not written.** A generated config full of
16
+ * guessed thresholds is a config nobody trusts and everybody deletes — and it
17
+ * is worse than an empty one, because it looks like a decision somebody made.
18
+ * Every key that lands carries the observation that justified it; every key
19
+ * that does not carries what would settle it. Both are typed values, because a
20
+ * first run that explains itself only in prose cannot be checked by a test.
21
+ *
22
+ * **Measurement is not policy.** A log says what your traffic *was* — how many
23
+ * calls, which model, how long the outputs ran. Those are measurements and
24
+ * this file writes them. A budget says what your traffic *may cost*, which no
25
+ * log can answer: picking "the measured month plus twenty per cent" would be
26
+ * this tool inventing a threshold and then grading somebody against it. So
27
+ * `spend` is always declined, and the measured figure is handed over so the
28
+ * person who *can* set a budget has the number in front of them.
29
+ */
30
+ import { DEFAULT_EXTENSIONS } from './config-schema.js';
31
+ import { billLevers } from './levers.js';
32
+ /** A month, for turning a measured span into a rate. */
33
+ const DAYS_PER_MONTH = 30;
34
+ /**
35
+ * The shortest measured span that may be stated as a monthly rate.
36
+ *
37
+ * Four weeks, so every weekday appears the same number of times. Three days of
38
+ * traffic multiplied by ten is a forecast wearing a measurement's clothes, and
39
+ * this repository has refused that since the series shipped in 1.40.
40
+ */
41
+ export const MIN_RATE_DAYS = 28;
42
+ /** The share of the bill a headline must clear to be worth being the headline. */
43
+ export const HEADLINE_FLOOR_SHARE = 0.01;
44
+ /** Days between two `YYYY-MM-DD` days, inclusive of both. */
45
+ function spanDays(first, last) {
46
+ const a = Date.parse(`${first}T00:00:00Z`);
47
+ const b = Date.parse(`${last}T00:00:00Z`);
48
+ if (Number.isNaN(a) || Number.isNaN(b))
49
+ return 0;
50
+ return Math.round((b - a) / 86_400_000) + 1;
51
+ }
52
+ /** The extensions actually present among the prompt files found. */
53
+ function extensionsOf(files) {
54
+ const seen = new Set();
55
+ for (const file of files) {
56
+ const dot = file.lastIndexOf('.');
57
+ const slash = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
58
+ if (dot > slash + 1)
59
+ seen.add(file.slice(dot).toLowerCase());
60
+ }
61
+ return [...seen].sort();
62
+ }
63
+ /**
64
+ * The one model a config may name, from what was measured.
65
+ *
66
+ * A log spread across four models has no single answer, and writing the
67
+ * largest of the four would silently price every prompt in the repository
68
+ * against a model most of them never touch. The threshold is a majority: past
69
+ * half the bill, "this is what you use" is a fair sentence.
70
+ */
71
+ function dominantModel(report) {
72
+ if (report.total.totalUsd <= 0 || report.byModel.length === 0)
73
+ return null;
74
+ const top = report.byModel[0];
75
+ if (top === undefined)
76
+ return null;
77
+ const share = top.breakdown.totalUsd / report.total.totalUsd;
78
+ return share > 0.5 ? { model: top.model, share } : null;
79
+ }
80
+ export function proposeInit(observations, options) {
81
+ const { catalogue, on = new Date() } = options;
82
+ const { measured } = observations;
83
+ const justified = [];
84
+ const declined = [];
85
+ const config = {};
86
+ // --- locale -------------------------------------------------------------
87
+ if (observations.locale !== null) {
88
+ config.locale = observations.locale;
89
+ justified.push({ key: 'locale', value: observations.locale, from: 'environment' });
90
+ }
91
+ // --- extensions ---------------------------------------------------------
92
+ //
93
+ // Only when the walk found something the defaults do not already cover.
94
+ // Writing `[".txt", ".md", ".prompt", ".tmpl"]` back into a config is a key
95
+ // that changes nothing and has to be maintained forever.
96
+ const extensions = extensionsOf(observations.promptFiles);
97
+ if (extensions.length > 0 && extensions.some((e) => !DEFAULT_EXTENSIONS.includes(e))) {
98
+ config.extensions = extensions;
99
+ justified.push({
100
+ key: 'extensions',
101
+ value: extensions,
102
+ from: 'walk',
103
+ files: observations.promptFiles.length,
104
+ });
105
+ }
106
+ // --- usage.model --------------------------------------------------------
107
+ //
108
+ // Measured beats detected, and it is not close. An import says which SDK
109
+ // somebody installed; a log says which model was billed. When there is no
110
+ // log, a literal in the source will do — but a *provider* with no model is
111
+ // declined rather than filled in from that provider's default. `where` may
112
+ // print a provider default because a reader can see it is a guess; a config
113
+ // file cannot, because six weeks later it reads as a decision.
114
+ const dominant = measured === null ? null : dominantModel(measured);
115
+ const modelSighting = observations.sightings.find((s) => s.detection.model !== null && s.detection.conflicts.length === 0);
116
+ const conflicting = observations.sightings.filter((s) => s.detection.conflicts.length > 0);
117
+ const providerOnly = observations.sightings.find((s) => s.detection.provider !== null && s.detection.model === null && s.detection.conflicts.length === 0);
118
+ if (dominant !== null) {
119
+ config.usage = { ...config.usage, model: dominant.model };
120
+ justified.push({
121
+ key: 'usage.model',
122
+ value: dominant.model,
123
+ from: 'measured',
124
+ share: dominant.share,
125
+ });
126
+ }
127
+ else if (modelSighting !== undefined) {
128
+ const evidence = modelSighting.detection.evidence.find((e) => e.model !== undefined) ??
129
+ modelSighting.detection.evidence[0];
130
+ config.usage = { ...config.usage, model: modelSighting.detection.model };
131
+ justified.push({
132
+ key: 'usage.model',
133
+ value: modelSighting.detection.model,
134
+ from: 'source',
135
+ file: modelSighting.file,
136
+ line: evidence?.line ?? 0,
137
+ evidence: evidence?.kind ?? 'model-literal',
138
+ });
139
+ }
140
+ else if (conflicting.length > 0) {
141
+ declined.push({
142
+ key: 'usage.model',
143
+ why: 'conflicting-evidence',
144
+ files: conflicting.map((s) => s.file),
145
+ });
146
+ }
147
+ else if (providerOnly !== undefined) {
148
+ declined.push({
149
+ key: 'usage.model',
150
+ why: 'provider-only',
151
+ provider: providerOnly.detection.provider,
152
+ file: providerOnly.file,
153
+ });
154
+ }
155
+ else {
156
+ declined.push({ key: 'usage.model', why: 'no-evidence' });
157
+ }
158
+ // --- the measured span, which three keys below depend on ----------------
159
+ const dated = measured?.spendByDay ?? [];
160
+ const first = dated[0];
161
+ const last = dated[dated.length - 1];
162
+ const days = first === undefined || last === undefined ? 0 : spanDays(first.day, last.day);
163
+ const datedCalls = dated.reduce((sum, d) => sum + d.calls, 0);
164
+ const undated = measured === null ? 0 : Math.max(0, measured.total.calls - datedCalls);
165
+ // --- usage.callsPerMonth ------------------------------------------------
166
+ //
167
+ // Three separate refusals, and they are not the same refusal. No log is one
168
+ // situation; a log covering four days is another; a log whose records carry
169
+ // no clock is a third — and that last one is the one that would go wrong
170
+ // quietly, because the calls are all *there*, they simply cannot be placed
171
+ // in time. Dividing them by a span they were never proven to fall inside is
172
+ // how a rate comes out too high and nobody can see why.
173
+ if (measured === null) {
174
+ declined.push({ key: 'usage.callsPerMonth', why: 'nothing-measured' });
175
+ }
176
+ else if (undated > 0) {
177
+ declined.push({
178
+ key: 'usage.callsPerMonth',
179
+ why: 'undated-calls',
180
+ undated,
181
+ calls: measured.total.calls,
182
+ });
183
+ }
184
+ else if (days < MIN_RATE_DAYS) {
185
+ declined.push({
186
+ key: 'usage.callsPerMonth',
187
+ why: 'window-too-short',
188
+ days,
189
+ calls: measured.total.calls,
190
+ });
191
+ }
192
+ else {
193
+ const perMonth = Math.round((measured.total.calls / days) * DAYS_PER_MONTH);
194
+ config.usage = { ...config.usage, callsPerMonth: perMonth };
195
+ justified.push({
196
+ key: 'usage.callsPerMonth',
197
+ value: perMonth,
198
+ from: 'measured',
199
+ calls: measured.total.calls,
200
+ days,
201
+ });
202
+ }
203
+ // --- usage.avgOutputTokens ----------------------------------------------
204
+ //
205
+ // An average of what happened, not a forecast of what will — so unlike the
206
+ // rate above it needs no minimum span. One day of real calls gives a real
207
+ // average of those calls.
208
+ if (measured === null || measured.total.calls === 0) {
209
+ declined.push({ key: 'usage.avgOutputTokens', why: 'nothing-measured' });
210
+ }
211
+ else {
212
+ const avg = Math.round(measured.total.outputTokens / measured.total.calls);
213
+ config.usage = { ...config.usage, avgOutputTokens: avg };
214
+ justified.push({
215
+ key: 'usage.avgOutputTokens',
216
+ value: avg,
217
+ from: 'measured',
218
+ outputTokens: measured.total.outputTokens,
219
+ calls: measured.total.calls,
220
+ });
221
+ }
222
+ // --- usage.cacheHitRate -------------------------------------------------
223
+ //
224
+ // **Not recorded is not not-happened.** A log with no cache fields at all
225
+ // does not prove a hit rate of zero — it proves the exporter did not write
226
+ // the column. Writing 0 there would tell every later caching advisory that
227
+ // caching is doing nothing, which is a finding invented out of a missing
228
+ // field.
229
+ if (measured === null) {
230
+ declined.push({ key: 'usage.cacheHitRate', why: 'nothing-measured' });
231
+ }
232
+ else {
233
+ const read = measured.total.cacheReadTokens;
234
+ const written = measured.total.cacheWriteTokens;
235
+ const input = measured.total.inputTokens;
236
+ if (read === 0 && written === 0) {
237
+ declined.push({ key: 'usage.cacheHitRate', why: 'not-recorded' });
238
+ }
239
+ else {
240
+ const denominator = read + input;
241
+ const rate = denominator === 0 ? 0 : Math.round((read / denominator) * 100) / 100;
242
+ config.usage = { ...config.usage, cacheHitRate: rate };
243
+ justified.push({
244
+ key: 'usage.cacheHitRate',
245
+ value: rate,
246
+ from: 'measured',
247
+ cacheReadTokens: read,
248
+ inputTokens: input,
249
+ });
250
+ }
251
+ }
252
+ // --- usage.batchEligible ------------------------------------------------
253
+ //
254
+ // Never written, in either direction. Whether the work tolerates a batch
255
+ // window is a fact about a product decision, and no log records it. A
256
+ // default of `false` would quietly delete the batch lever from every report
257
+ // this config touches; `true` would offer a saving on latency somebody never
258
+ // agreed to give up.
259
+ declined.push({ key: 'usage.batchEligible', why: 'only-you-know' });
260
+ // --- labels -------------------------------------------------------------
261
+ //
262
+ // Mapping a log label to a prompt file is a claim about which file produced
263
+ // which calls, and a directory walk cannot prove one. A wrong entry here is
264
+ // worse than a missing one: `profile` would go and read the wrong file and
265
+ // explain a cache verdict with the wrong prompt's structure, confidently.
266
+ const labels = measured?.byLabel.length ?? 0;
267
+ if (labels > 0)
268
+ declined.push({ key: 'labels', why: 'unprovable', labels });
269
+ // --- spend --------------------------------------------------------------
270
+ //
271
+ // The measured figure is handed over, and the threshold is not invented.
272
+ declined.push({
273
+ key: 'spend.maxUsd',
274
+ why: 'a-budget-is-a-policy',
275
+ measuredUsd: measured === null ? null : measured.total.totalUsd,
276
+ days: measured === null ? null : days,
277
+ });
278
+ // --- the headline -------------------------------------------------------
279
+ let headline = null;
280
+ let noHeadline = null;
281
+ if (measured === null) {
282
+ noHeadline = 'nothing-measured';
283
+ }
284
+ else if (measured.total.totalUsd <= 0) {
285
+ noHeadline = 'nothing-could-be-priced';
286
+ }
287
+ else {
288
+ const levers = billLevers(measured, { catalogue, on, minShare: HEADLINE_FLOOR_SHARE });
289
+ const top = levers.slices[0];
290
+ if (top === undefined || top.combinedUsd <= 0) {
291
+ noHeadline = 'no-lever-clears-the-floor';
292
+ }
293
+ else {
294
+ headline = {
295
+ slice: top,
296
+ lever: top.route !== null && top.batch !== null
297
+ ? 'route+batch'
298
+ : top.route !== null
299
+ ? 'route'
300
+ : 'batch',
301
+ savingUsd: top.combinedUsd,
302
+ provenance: 'measured',
303
+ days,
304
+ };
305
+ }
306
+ }
307
+ // --- what this would overwrite ------------------------------------------
308
+ let overwrites = null;
309
+ if (observations.existing !== null) {
310
+ const already = observations.existing.config;
311
+ const keys = [];
312
+ if (config.locale !== undefined && already.locale !== undefined)
313
+ keys.push('locale');
314
+ if (config.extensions !== undefined && already.extensions !== undefined)
315
+ keys.push('extensions');
316
+ for (const k of ['model', 'callsPerMonth', 'avgOutputTokens', 'cacheHitRate']) {
317
+ if (config.usage?.[k] !== undefined && already.usage?.[k] !== undefined) {
318
+ keys.push(`usage.${k}`);
319
+ }
320
+ }
321
+ overwrites = { path: observations.existing.path, keys };
322
+ }
323
+ return { schemaVersion: 1, config, justified, declined, headline, noHeadline, overwrites };
324
+ }
325
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8JzC,wDAAwD;AACxD,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM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,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjG,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,CAAU,EAAE,CAAC;YACvF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBACxE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAa,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACD,UAAU,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAC7F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trazum/core",
3
- "version": "1.45.0",
3
+ "version": "1.46.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
@@ -51,6 +51,19 @@ export { buildHistory, storedReportFrom, MIN_RUN } from './history.js';
51
51
  export { answerCost } from './answer.js';
52
52
  export { guardSpend } from './guard.js';
53
53
  export type { GuardAlternative, GuardAnswer, GuardRequest, GuardVerdict } from './guard.js';
54
+ export { proposeInit, HEADLINE_FLOOR_SHARE, MIN_RATE_DAYS } from './init.js';
55
+ export type {
56
+ InitDecline,
57
+ InitHeadline,
58
+ InitJustification,
59
+ InitKey,
60
+ InitObservations,
61
+ InitOptions,
62
+ InitProposal,
63
+ NoHeadline,
64
+ ProviderSighting,
65
+ UsageSighting,
66
+ } from './init.js';
54
67
  export type {
55
68
  AnswerRequest,
56
69
  AnswerVerdict,
package/src/init.ts ADDED
@@ -0,0 +1,500 @@
1
+ /**
2
+ * The first five minutes, decided without touching a disk.
3
+ *
4
+ * Everything since 1.41 raised the ceiling. This lowers the floor: from
5
+ * `npx @trazum/cli` to a finding worth money, without reading a page of
6
+ * documentation. Twenty-one commands is a wall to somebody who has none of
7
+ * them yet, and that wall is why a good tool gets closed inside a minute.
8
+ *
9
+ * **The proposal is a document, not a side effect.** What `init` would write
10
+ * is decided here, from observations the CLI collected, and returned as a
11
+ * value. So every rule below is testable without a filesystem, and `--dry-run`
12
+ * is the same code path minus the write rather than a second implementation
13
+ * that drifts from the first.
14
+ *
15
+ * **A key with no evidence is not written.** A generated config full of
16
+ * guessed thresholds is a config nobody trusts and everybody deletes — and it
17
+ * is worse than an empty one, because it looks like a decision somebody made.
18
+ * Every key that lands carries the observation that justified it; every key
19
+ * that does not carries what would settle it. Both are typed values, because a
20
+ * first run that explains itself only in prose cannot be checked by a test.
21
+ *
22
+ * **Measurement is not policy.** A log says what your traffic *was* — how many
23
+ * calls, which model, how long the outputs ran. Those are measurements and
24
+ * this file writes them. A budget says what your traffic *may cost*, which no
25
+ * log can answer: picking "the measured month plus twenty per cent" would be
26
+ * this tool inventing a threshold and then grading somebody against it. So
27
+ * `spend` is always declined, and the measured figure is handed over so the
28
+ * person who *can* set a budget has the number in front of them.
29
+ */
30
+
31
+ import { DEFAULT_EXTENSIONS } from './config-schema.js';
32
+ import type { TrazumConfig } from './config-schema.js';
33
+ import type { Detection, EvidenceKind } from './detect.js';
34
+ import type { HostEnvironment } from './host.js';
35
+ import { billLevers } from './levers.js';
36
+ import type { SliceLevers } from './levers.js';
37
+ import type { PricingCatalogue } from './pricing.js';
38
+ import type { UsageProfileReport } from './usage.js';
39
+ import type { Locale } from './i18n/index.js';
40
+
41
+ /** A source file that was read, and what `detectFromSource` made of it. */
42
+ export interface ProviderSighting {
43
+ file: string;
44
+ detection: Detection;
45
+ }
46
+
47
+ /**
48
+ * Something that might hold usage, found lying around.
49
+ *
50
+ * `where` is a path for the file kinds and the **name** of an environment
51
+ * variable for a credential — never its value. That rule has held since the
52
+ * connector shipped in 1.41 and it holds here: a first-run summary is the
53
+ * single most likely thing somebody pastes into a chat window.
54
+ */
55
+ export interface UsageSighting {
56
+ kind: 'log-file' | 'log-directory' | 'store' | 'connector-credential';
57
+ where: string;
58
+ /** The provider this source belongs to, when the sighting names one. */
59
+ provider: string | null;
60
+ }
61
+
62
+ /** Everything the CLI saw, handed over as data. */
63
+ export interface InitObservations {
64
+ host: HostEnvironment;
65
+ /** Every source file read, strongest evidence first within each file. */
66
+ sightings: ProviderSighting[];
67
+ /** Prompt files the walk found. */
68
+ promptFiles: string[];
69
+ /** Usage sources found. Empty is a real answer and is reported as one. */
70
+ usage: UsageSighting[];
71
+ /**
72
+ * The profile of a usage source that was found **and** parsed.
73
+ *
74
+ * Null covers two different situations and the proposal keeps them apart:
75
+ * nothing was found, or something was found and could not be read. The
76
+ * caller says which by what it puts in `usage`.
77
+ */
78
+ measured: UsageProfileReport | null;
79
+ /** The locale the environment asked for, when it asked for one. */
80
+ locale: Locale | null;
81
+ /** A config already sitting in the working directory. */
82
+ existing: { path: string; config: TrazumConfig } | null;
83
+ }
84
+
85
+ /** Every config key `init` is allowed to have an opinion about. */
86
+ export type InitKey =
87
+ | 'locale'
88
+ | 'extensions'
89
+ | 'usage.model'
90
+ | 'usage.callsPerMonth'
91
+ | 'usage.avgOutputTokens'
92
+ | 'usage.cacheHitRate'
93
+ | 'usage.batchEligible'
94
+ | 'labels'
95
+ | 'spend.maxUsd';
96
+
97
+ /** Why a key was written, in a shape a test can assert on. */
98
+ export type InitJustification =
99
+ | { key: 'locale'; value: Locale; from: 'environment' }
100
+ | { key: 'extensions'; value: string[]; from: 'walk'; files: number }
101
+ | {
102
+ key: 'usage.model';
103
+ value: string;
104
+ from: 'measured';
105
+ /** Share of the measured bill this model carries, 0-1. */
106
+ share: number;
107
+ }
108
+ | {
109
+ key: 'usage.model';
110
+ value: string;
111
+ from: 'source';
112
+ file: string;
113
+ line: number;
114
+ evidence: EvidenceKind;
115
+ }
116
+ | { key: 'usage.callsPerMonth'; value: number; from: 'measured'; calls: number; days: number }
117
+ | {
118
+ key: 'usage.avgOutputTokens';
119
+ value: number;
120
+ from: 'measured';
121
+ outputTokens: number;
122
+ calls: number;
123
+ }
124
+ | {
125
+ key: 'usage.cacheHitRate';
126
+ value: number;
127
+ from: 'measured';
128
+ cacheReadTokens: number;
129
+ inputTokens: number;
130
+ };
131
+
132
+ /**
133
+ * Why a key was left out, and what would settle it.
134
+ *
135
+ * A refusal never arrives bare — the rule the guard established in 1.45, here
136
+ * applied to a file rather than to a call. "No provider written" with nothing
137
+ * after it is indistinguishable from a bug.
138
+ */
139
+ export type InitDecline =
140
+ | { key: 'usage.model'; why: 'no-evidence' }
141
+ | { key: 'usage.model'; why: 'conflicting-evidence'; files: string[] }
142
+ | { key: 'usage.model'; why: 'provider-only'; provider: string; file: string }
143
+ | { key: 'usage.callsPerMonth'; why: 'nothing-measured' }
144
+ | { key: 'usage.callsPerMonth'; why: 'window-too-short'; days: number; calls: number }
145
+ | { key: 'usage.callsPerMonth'; why: 'undated-calls'; undated: number; calls: number }
146
+ | { key: 'usage.avgOutputTokens'; why: 'nothing-measured' }
147
+ | { key: 'usage.cacheHitRate'; why: 'nothing-measured' }
148
+ | { key: 'usage.cacheHitRate'; why: 'not-recorded' }
149
+ | { key: 'usage.batchEligible'; why: 'only-you-know' }
150
+ | { key: 'labels'; why: 'unprovable'; labels: number }
151
+ | { key: 'spend.maxUsd'; why: 'a-budget-is-a-policy'; measuredUsd: number | null; days: number | null };
152
+
153
+ /**
154
+ * The single most valuable thing the first run found, with its arithmetic.
155
+ *
156
+ * One finding, not a ranked table. `doctor` and `plan` exist for the table,
157
+ * and a first run that opens with fourteen rows has told somebody nothing —
158
+ * they came to find out whether this is worth an afternoon.
159
+ */
160
+ export interface InitHeadline {
161
+ slice: SliceLevers;
162
+ /** Which lever the figure is. `route+batch` is computed, never summed. */
163
+ lever: 'route' | 'batch' | 'route+batch';
164
+ savingUsd: number;
165
+ /** Always measured. Nothing in a headline rests on a call that never happened. */
166
+ provenance: 'measured';
167
+ /** Days of measurement behind it, so the figure has a unit a reader can check. */
168
+ days: number;
169
+ }
170
+
171
+ export type NoHeadline =
172
+ | 'nothing-measured'
173
+ | 'nothing-could-be-priced'
174
+ | 'no-lever-clears-the-floor';
175
+
176
+ export interface InitProposal {
177
+ schemaVersion: 1;
178
+ /** Exactly the keys that were justified, and nothing else. */
179
+ config: TrazumConfig;
180
+ justified: InitJustification[];
181
+ declined: InitDecline[];
182
+ headline: InitHeadline | null;
183
+ /** Set when `headline` is null, so "nothing found" is never bare. */
184
+ noHeadline: NoHeadline | null;
185
+ /**
186
+ * The config already there, and which of its keys this proposal would
187
+ * change. Named before anything is written: an `init` that silently replaces
188
+ * a config somebody tuned is the worst possible first impression.
189
+ */
190
+ overwrites: { path: string; keys: InitKey[] } | null;
191
+ }
192
+
193
+ /** A month, for turning a measured span into a rate. */
194
+ const DAYS_PER_MONTH = 30;
195
+
196
+ /**
197
+ * The shortest measured span that may be stated as a monthly rate.
198
+ *
199
+ * Four weeks, so every weekday appears the same number of times. Three days of
200
+ * traffic multiplied by ten is a forecast wearing a measurement's clothes, and
201
+ * this repository has refused that since the series shipped in 1.40.
202
+ */
203
+ export const MIN_RATE_DAYS = 28;
204
+
205
+ /** The share of the bill a headline must clear to be worth being the headline. */
206
+ export const HEADLINE_FLOOR_SHARE = 0.01;
207
+
208
+ /** Days between two `YYYY-MM-DD` days, inclusive of both. */
209
+ function spanDays(first: string, last: string): number {
210
+ const a = Date.parse(`${first}T00:00:00Z`);
211
+ const b = Date.parse(`${last}T00:00:00Z`);
212
+ if (Number.isNaN(a) || Number.isNaN(b)) return 0;
213
+ return Math.round((b - a) / 86_400_000) + 1;
214
+ }
215
+
216
+ /** The extensions actually present among the prompt files found. */
217
+ function extensionsOf(files: string[]): string[] {
218
+ const seen = new Set<string>();
219
+ for (const file of files) {
220
+ const dot = file.lastIndexOf('.');
221
+ const slash = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
222
+ if (dot > slash + 1) seen.add(file.slice(dot).toLowerCase());
223
+ }
224
+ return [...seen].sort();
225
+ }
226
+
227
+ /**
228
+ * The one model a config may name, from what was measured.
229
+ *
230
+ * A log spread across four models has no single answer, and writing the
231
+ * largest of the four would silently price every prompt in the repository
232
+ * against a model most of them never touch. The threshold is a majority: past
233
+ * half the bill, "this is what you use" is a fair sentence.
234
+ */
235
+ function dominantModel(report: UsageProfileReport): { model: string; share: number } | null {
236
+ if (report.total.totalUsd <= 0 || report.byModel.length === 0) return null;
237
+ const top = report.byModel[0];
238
+ if (top === undefined) return null;
239
+ const share = top.breakdown.totalUsd / report.total.totalUsd;
240
+ return share > 0.5 ? { model: top.model, share } : null;
241
+ }
242
+
243
+ export interface InitOptions {
244
+ catalogue: PricingCatalogue;
245
+ on?: Date;
246
+ }
247
+
248
+ export function proposeInit(
249
+ observations: InitObservations,
250
+ options: InitOptions,
251
+ ): InitProposal {
252
+ const { catalogue, on = new Date() } = options;
253
+ const { measured } = observations;
254
+ const justified: InitJustification[] = [];
255
+ const declined: InitDecline[] = [];
256
+ const config: TrazumConfig = {};
257
+
258
+ // --- locale -------------------------------------------------------------
259
+ if (observations.locale !== null) {
260
+ config.locale = observations.locale;
261
+ justified.push({ key: 'locale', value: observations.locale, from: 'environment' });
262
+ }
263
+
264
+ // --- extensions ---------------------------------------------------------
265
+ //
266
+ // Only when the walk found something the defaults do not already cover.
267
+ // Writing `[".txt", ".md", ".prompt", ".tmpl"]` back into a config is a key
268
+ // that changes nothing and has to be maintained forever.
269
+ const extensions = extensionsOf(observations.promptFiles);
270
+ if (extensions.length > 0 && extensions.some((e) => !DEFAULT_EXTENSIONS.includes(e))) {
271
+ config.extensions = extensions;
272
+ justified.push({
273
+ key: 'extensions',
274
+ value: extensions,
275
+ from: 'walk',
276
+ files: observations.promptFiles.length,
277
+ });
278
+ }
279
+
280
+ // --- usage.model --------------------------------------------------------
281
+ //
282
+ // Measured beats detected, and it is not close. An import says which SDK
283
+ // somebody installed; a log says which model was billed. When there is no
284
+ // log, a literal in the source will do — but a *provider* with no model is
285
+ // declined rather than filled in from that provider's default. `where` may
286
+ // print a provider default because a reader can see it is a guess; a config
287
+ // file cannot, because six weeks later it reads as a decision.
288
+ const dominant = measured === null ? null : dominantModel(measured);
289
+ const modelSighting = observations.sightings.find(
290
+ (s) => s.detection.model !== null && s.detection.conflicts.length === 0,
291
+ );
292
+ const conflicting = observations.sightings.filter((s) => s.detection.conflicts.length > 0);
293
+ const providerOnly = observations.sightings.find(
294
+ (s) => s.detection.provider !== null && s.detection.model === null && s.detection.conflicts.length === 0,
295
+ );
296
+
297
+ if (dominant !== null) {
298
+ config.usage = { ...config.usage, model: dominant.model };
299
+ justified.push({
300
+ key: 'usage.model',
301
+ value: dominant.model,
302
+ from: 'measured',
303
+ share: dominant.share,
304
+ });
305
+ } else if (modelSighting !== undefined) {
306
+ const evidence =
307
+ modelSighting.detection.evidence.find((e) => e.model !== undefined) ??
308
+ modelSighting.detection.evidence[0];
309
+ config.usage = { ...config.usage, model: modelSighting.detection.model as string };
310
+ justified.push({
311
+ key: 'usage.model',
312
+ value: modelSighting.detection.model as string,
313
+ from: 'source',
314
+ file: modelSighting.file,
315
+ line: evidence?.line ?? 0,
316
+ evidence: evidence?.kind ?? 'model-literal',
317
+ });
318
+ } else if (conflicting.length > 0) {
319
+ declined.push({
320
+ key: 'usage.model',
321
+ why: 'conflicting-evidence',
322
+ files: conflicting.map((s) => s.file),
323
+ });
324
+ } else if (providerOnly !== undefined) {
325
+ declined.push({
326
+ key: 'usage.model',
327
+ why: 'provider-only',
328
+ provider: providerOnly.detection.provider as string,
329
+ file: providerOnly.file,
330
+ });
331
+ } else {
332
+ declined.push({ key: 'usage.model', why: 'no-evidence' });
333
+ }
334
+
335
+ // --- the measured span, which three keys below depend on ----------------
336
+ const dated = measured?.spendByDay ?? [];
337
+ const first = dated[0];
338
+ const last = dated[dated.length - 1];
339
+ const days = first === undefined || last === undefined ? 0 : spanDays(first.day, last.day);
340
+ const datedCalls = dated.reduce((sum, d) => sum + d.calls, 0);
341
+ const undated = measured === null ? 0 : Math.max(0, measured.total.calls - datedCalls);
342
+
343
+ // --- usage.callsPerMonth ------------------------------------------------
344
+ //
345
+ // Three separate refusals, and they are not the same refusal. No log is one
346
+ // situation; a log covering four days is another; a log whose records carry
347
+ // no clock is a third — and that last one is the one that would go wrong
348
+ // quietly, because the calls are all *there*, they simply cannot be placed
349
+ // in time. Dividing them by a span they were never proven to fall inside is
350
+ // how a rate comes out too high and nobody can see why.
351
+ if (measured === null) {
352
+ declined.push({ key: 'usage.callsPerMonth', why: 'nothing-measured' });
353
+ } else if (undated > 0) {
354
+ declined.push({
355
+ key: 'usage.callsPerMonth',
356
+ why: 'undated-calls',
357
+ undated,
358
+ calls: measured.total.calls,
359
+ });
360
+ } else if (days < MIN_RATE_DAYS) {
361
+ declined.push({
362
+ key: 'usage.callsPerMonth',
363
+ why: 'window-too-short',
364
+ days,
365
+ calls: measured.total.calls,
366
+ });
367
+ } else {
368
+ const perMonth = Math.round((measured.total.calls / days) * DAYS_PER_MONTH);
369
+ config.usage = { ...config.usage, callsPerMonth: perMonth };
370
+ justified.push({
371
+ key: 'usage.callsPerMonth',
372
+ value: perMonth,
373
+ from: 'measured',
374
+ calls: measured.total.calls,
375
+ days,
376
+ });
377
+ }
378
+
379
+ // --- usage.avgOutputTokens ----------------------------------------------
380
+ //
381
+ // An average of what happened, not a forecast of what will — so unlike the
382
+ // rate above it needs no minimum span. One day of real calls gives a real
383
+ // average of those calls.
384
+ if (measured === null || measured.total.calls === 0) {
385
+ declined.push({ key: 'usage.avgOutputTokens', why: 'nothing-measured' });
386
+ } else {
387
+ const avg = Math.round(measured.total.outputTokens / measured.total.calls);
388
+ config.usage = { ...config.usage, avgOutputTokens: avg };
389
+ justified.push({
390
+ key: 'usage.avgOutputTokens',
391
+ value: avg,
392
+ from: 'measured',
393
+ outputTokens: measured.total.outputTokens,
394
+ calls: measured.total.calls,
395
+ });
396
+ }
397
+
398
+ // --- usage.cacheHitRate -------------------------------------------------
399
+ //
400
+ // **Not recorded is not not-happened.** A log with no cache fields at all
401
+ // does not prove a hit rate of zero — it proves the exporter did not write
402
+ // the column. Writing 0 there would tell every later caching advisory that
403
+ // caching is doing nothing, which is a finding invented out of a missing
404
+ // field.
405
+ if (measured === null) {
406
+ declined.push({ key: 'usage.cacheHitRate', why: 'nothing-measured' });
407
+ } else {
408
+ const read = measured.total.cacheReadTokens;
409
+ const written = measured.total.cacheWriteTokens;
410
+ const input = measured.total.inputTokens;
411
+ if (read === 0 && written === 0) {
412
+ declined.push({ key: 'usage.cacheHitRate', why: 'not-recorded' });
413
+ } else {
414
+ const denominator = read + input;
415
+ const rate = denominator === 0 ? 0 : Math.round((read / denominator) * 100) / 100;
416
+ config.usage = { ...config.usage, cacheHitRate: rate };
417
+ justified.push({
418
+ key: 'usage.cacheHitRate',
419
+ value: rate,
420
+ from: 'measured',
421
+ cacheReadTokens: read,
422
+ inputTokens: input,
423
+ });
424
+ }
425
+ }
426
+
427
+ // --- usage.batchEligible ------------------------------------------------
428
+ //
429
+ // Never written, in either direction. Whether the work tolerates a batch
430
+ // window is a fact about a product decision, and no log records it. A
431
+ // default of `false` would quietly delete the batch lever from every report
432
+ // this config touches; `true` would offer a saving on latency somebody never
433
+ // agreed to give up.
434
+ declined.push({ key: 'usage.batchEligible', why: 'only-you-know' });
435
+
436
+ // --- labels -------------------------------------------------------------
437
+ //
438
+ // Mapping a log label to a prompt file is a claim about which file produced
439
+ // which calls, and a directory walk cannot prove one. A wrong entry here is
440
+ // worse than a missing one: `profile` would go and read the wrong file and
441
+ // explain a cache verdict with the wrong prompt's structure, confidently.
442
+ const labels = measured?.byLabel.length ?? 0;
443
+ if (labels > 0) declined.push({ key: 'labels', why: 'unprovable', labels });
444
+
445
+ // --- spend --------------------------------------------------------------
446
+ //
447
+ // The measured figure is handed over, and the threshold is not invented.
448
+ declined.push({
449
+ key: 'spend.maxUsd',
450
+ why: 'a-budget-is-a-policy',
451
+ measuredUsd: measured === null ? null : measured.total.totalUsd,
452
+ days: measured === null ? null : days,
453
+ });
454
+
455
+ // --- the headline -------------------------------------------------------
456
+ let headline: InitHeadline | null = null;
457
+ let noHeadline: NoHeadline | null = null;
458
+
459
+ if (measured === null) {
460
+ noHeadline = 'nothing-measured';
461
+ } else if (measured.total.totalUsd <= 0) {
462
+ noHeadline = 'nothing-could-be-priced';
463
+ } else {
464
+ const levers = billLevers(measured, { catalogue, on, minShare: HEADLINE_FLOOR_SHARE });
465
+ const top = levers.slices[0];
466
+ if (top === undefined || top.combinedUsd <= 0) {
467
+ noHeadline = 'no-lever-clears-the-floor';
468
+ } else {
469
+ headline = {
470
+ slice: top,
471
+ lever:
472
+ top.route !== null && top.batch !== null
473
+ ? 'route+batch'
474
+ : top.route !== null
475
+ ? 'route'
476
+ : 'batch',
477
+ savingUsd: top.combinedUsd,
478
+ provenance: 'measured',
479
+ days,
480
+ };
481
+ }
482
+ }
483
+
484
+ // --- what this would overwrite ------------------------------------------
485
+ let overwrites: InitProposal['overwrites'] = null;
486
+ if (observations.existing !== null) {
487
+ const already = observations.existing.config;
488
+ const keys: InitKey[] = [];
489
+ if (config.locale !== undefined && already.locale !== undefined) keys.push('locale');
490
+ if (config.extensions !== undefined && already.extensions !== undefined) keys.push('extensions');
491
+ for (const k of ['model', 'callsPerMonth', 'avgOutputTokens', 'cacheHitRate'] as const) {
492
+ if (config.usage?.[k] !== undefined && already.usage?.[k] !== undefined) {
493
+ keys.push(`usage.${k}` as InitKey);
494
+ }
495
+ }
496
+ overwrites = { path: observations.existing.path, keys };
497
+ }
498
+
499
+ return { schemaVersion: 1, config, justified, declined, headline, noHeadline, overwrites };
500
+ }