@dzhechkov/harness-core 0.3.145 → 0.3.147
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/.dz-manifest.json +82 -34
- package/README.md +3 -1
- package/dist/compounding.d.ts +27 -0
- package/dist/compounding.d.ts.map +1 -1
- package/dist/compounding.js +29 -0
- package/dist/compounding.js.map +1 -1
- package/dist/cost-ledger.d.ts +318 -0
- package/dist/cost-ledger.d.ts.map +1 -0
- package/dist/cost-ledger.js +871 -0
- package/dist/cost-ledger.js.map +1 -0
- package/dist/cost-scoring.d.ts +9 -0
- package/dist/cost-scoring.d.ts.map +1 -1
- package/dist/cost-scoring.js +18 -0
- package/dist/cost-scoring.js.map +1 -1
- package/dist/event-chain.d.ts +302 -0
- package/dist/event-chain.d.ts.map +1 -0
- package/dist/event-chain.js +663 -0
- package/dist/event-chain.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +26 -0
- package/dist/operations.js.map +1 -1
- package/dist/recall-usage.d.ts +52 -4
- package/dist/recall-usage.d.ts.map +1 -1
- package/dist/recall-usage.js +106 -21
- package/dist/recall-usage.js.map +1 -1
- package/dist/usage.d.ts +32 -0
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +59 -10
- package/dist/usage.js.map +1 -1
- package/package.json +3 -3
- package/sbom.json +153 -33
- package/src/compounding.ts +61 -0
- package/src/cost-ledger.ts +1105 -0
- package/src/cost-scoring.ts +17 -0
- package/src/event-chain.ts +870 -0
- package/src/index.ts +86 -0
- package/src/operations.ts +25 -0
- package/src/recall-usage.ts +142 -24
- package/src/usage.ts +74 -12
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-stage cost ledger with a reconciliation invariant for feature-adr runs
|
|
3
|
+
* (feature `cost-ledger`, ADR-001/ADR-002/ADR-003).
|
|
4
|
+
*
|
|
5
|
+
* A feature-adr run reports ONE number. The recorded run `wf_0576bd7d-797` has
|
|
6
|
+
* `totalTokens: 623290` — the "623k subagent tokens" figure in project memory. That number cannot
|
|
7
|
+
* be attributed to a stage, so "where the budget burns" is a feeling. feature-adr ALREADY labels
|
|
8
|
+
* every stage via `stageLabel()` and the harness ALREADY persists those labels next to per-agent
|
|
9
|
+
* transcripts; nothing joined labels to spend. This module is that join.
|
|
10
|
+
*
|
|
11
|
+
* ## What this is
|
|
12
|
+
*
|
|
13
|
+
* A POST-HOC DERIVER (ADR-001). It reads what is already on disk —
|
|
14
|
+
* `<session>/workflows/wf_<runId>.json` for the stage labels and
|
|
15
|
+
* `<session>/subagents/workflows/<runId>/agent-<agentId>.jsonl` for the spend — and never edits
|
|
16
|
+
* `.claude/workflows/feature-adr.js`. A killed run is still derivable, which a stage-boundary
|
|
17
|
+
* writer could not manage; 5 of 29 recorded runs on this machine are killed.
|
|
18
|
+
*
|
|
19
|
+
* ## The invariant (ADR-002 — the load-bearing half)
|
|
20
|
+
*
|
|
21
|
+
* The obvious run total, the record's own `totalTokens`, is EXACTLY `Σ workflowProgress[].tokens`
|
|
22
|
+
* in 29 of 29 recorded runs. Reconciling against it can never fail: a vacuous gate that would print
|
|
23
|
+
* BALANCED forever and be believed. So the right-hand side comes from the run's transcript
|
|
24
|
+
* DIRECTORY LISTING — a source independent of the record — and both sides run the SAME estimator
|
|
25
|
+
* (`weightedTokensOf`, shared with `dz usage`):
|
|
26
|
+
*
|
|
27
|
+
* ```
|
|
28
|
+
* accountedTokens + unaccountedTokens === runTotalTokens
|
|
29
|
+
* accountedTokens + doubleAttributedTokens === stageTokensSum
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Raw integer equality, no epsilon: rounding happens exactly once, per sample, at extraction.
|
|
33
|
+
* {@link verifyCostLedgerReport} re-derives both identities from the emitted report — the writer
|
|
34
|
+
* clamps, the verifier enforces raw equality (the `event-chain.ts` house pattern). A mismatch is a
|
|
35
|
+
* NAMED defect from {@link COST_LEDGER_DEFECT_KINDS}, never a rounding remainder.
|
|
36
|
+
*
|
|
37
|
+
* ## What this is NOT — read {@link COST_LEDGER_SCOPE} before describing it to anyone
|
|
38
|
+
*
|
|
39
|
+
* The totals are LOCAL TRANSCRIPT ESTIMATES. No billing API is consulted. The invariant therefore
|
|
40
|
+
* catches ATTRIBUTION errors — a double-counted stage, a stage missing from the ledger — and says
|
|
41
|
+
* NOTHING about whether the prices are right. The USD column is a secondary figure derived from a
|
|
42
|
+
* static table that has no `claude-fable` entry, so it falls back to sonnet-class pricing for the
|
|
43
|
+
* default model of every recorded run; the fallback is REPORTED, per ADR-003, not hidden.
|
|
44
|
+
*
|
|
45
|
+
* The ADR-158 reference implementation this feature is grounded in quotes a ~50.5% figure. That
|
|
46
|
+
* number is SYNTHETIC, belongs to their document, and is never a measurement of this repo.
|
|
47
|
+
*
|
|
48
|
+
* @packageDocumentation
|
|
49
|
+
*/
|
|
50
|
+
/** The one sentence that states what the ledger is and is not. Printed by EVERY surface (ADR-003). */
|
|
51
|
+
export declare const COST_LEDGER_SCOPE: string;
|
|
52
|
+
export type CostLedgerDefectKind =
|
|
53
|
+
/** Run spend attributed to no stage — an agent transcript with no `workflowProgress[]` entry. */
|
|
54
|
+
'Unaccounted'
|
|
55
|
+
/** One usage sample claimed by more than one stage. */
|
|
56
|
+
| 'DoubleAttributed'
|
|
57
|
+
/** A stage claims a sample absent from the run's universe — the join went outside the run. */
|
|
58
|
+
| 'ForeignSample'
|
|
59
|
+
/** A stage present in the run record has no transcript, or a transcript with no usage samples. */
|
|
60
|
+
| 'MissingStageTranscript'
|
|
61
|
+
/** A record or sample whose fields are missing, mistyped or non-finite — never silently ignored. */
|
|
62
|
+
| 'MalformedRecord'
|
|
63
|
+
/** The transcript listing hit the file cap — the run total is INCOMPLETE, so no verdict may be
|
|
64
|
+
* built on it (Codex QE HIGH: a silent cap could emit BALANCED from a partial directory). */
|
|
65
|
+
| 'TruncatedListing';
|
|
66
|
+
/**
|
|
67
|
+
* The defect vocabulary, as data. Deliberately absent: any name implying these are BILLED amounts —
|
|
68
|
+
* that name would assert exactly the promise {@link COST_LEDGER_SCOPE} refuses. A test pins this
|
|
69
|
+
* list so the vocabulary cannot quietly grow such a name.
|
|
70
|
+
*/
|
|
71
|
+
export declare const COST_LEDGER_DEFECT_KINDS: readonly CostLedgerDefectKind[];
|
|
72
|
+
/**
|
|
73
|
+
* Three values, not two. `INSUFFICIENT_DATA` is NOT success: a caller must not read
|
|
74
|
+
* `verdict !== 'DEFECT'` as "reconciled" (ADR-003).
|
|
75
|
+
*/
|
|
76
|
+
export type CostLedgerVerdict = 'BALANCED' | 'DEFECT' | 'INSUFFICIENT_DATA';
|
|
77
|
+
export declare const COST_LEDGER_VERDICTS: readonly CostLedgerVerdict[];
|
|
78
|
+
/**
|
|
79
|
+
* Default reconciliation tolerance, as a FRACTION of the run total. Zero, because the arithmetic is
|
|
80
|
+
* exact integer — there is no rounding remainder for a tolerance to absorb, so any remainder is a
|
|
81
|
+
* defect. A caller may raise it to tolerate small orphans; its value is always printed.
|
|
82
|
+
*/
|
|
83
|
+
export declare const DEFAULT_COST_LEDGER_EPSILON = 0;
|
|
84
|
+
/** One deduped usage sample extracted from a transcript. */
|
|
85
|
+
export interface CostLedgerSample {
|
|
86
|
+
/** Dedup key: `message.id + ':' + requestId`, or a content key when both are absent. */
|
|
87
|
+
readonly key: string;
|
|
88
|
+
/** Epoch ms, or `null` when the record carried no parseable timestamp. */
|
|
89
|
+
readonly ts: number | null;
|
|
90
|
+
/** Cost-weighted input-equivalent tokens, ROUNDED — the single rounding point of the feature. */
|
|
91
|
+
readonly weighted: number;
|
|
92
|
+
readonly input: number;
|
|
93
|
+
readonly cacheWrite: number;
|
|
94
|
+
readonly cacheRead: number;
|
|
95
|
+
readonly output: number;
|
|
96
|
+
readonly model: string | null;
|
|
97
|
+
}
|
|
98
|
+
/** One `type: "workflow_agent"` entry of a run record, after clamping. */
|
|
99
|
+
export interface WorkflowStageEntry {
|
|
100
|
+
/** `stageLabel()` output, VERBATIM — the ledger invents no taxonomy (FR-2). */
|
|
101
|
+
readonly label: string;
|
|
102
|
+
readonly agentId: string;
|
|
103
|
+
readonly model: string;
|
|
104
|
+
readonly phase: string | null;
|
|
105
|
+
readonly startedAtMs: number | null;
|
|
106
|
+
readonly durationMs: number | null;
|
|
107
|
+
readonly state: string | null;
|
|
108
|
+
/** The record's own per-agent token count. Reported for traceability; NOT the invariant's input. */
|
|
109
|
+
readonly recordTokens: number | null;
|
|
110
|
+
}
|
|
111
|
+
/** A parsed `wf_<runId>.json` workflow run record. */
|
|
112
|
+
export interface WorkflowRunRecord {
|
|
113
|
+
readonly runId: string;
|
|
114
|
+
readonly workflowName: string | null;
|
|
115
|
+
readonly slug: string | null;
|
|
116
|
+
readonly status: string | null;
|
|
117
|
+
readonly startedAtMs: number | null;
|
|
118
|
+
readonly durationMs: number | null;
|
|
119
|
+
/** The record's cached `Σ workflowProgress[].tokens` — RAW, unweighted, and NOT the run total. */
|
|
120
|
+
readonly recordTotalTokens: number | null;
|
|
121
|
+
readonly stages: readonly WorkflowStageEntry[];
|
|
122
|
+
/** Non-fatal problems found while parsing — surfaced as `MalformedRecord` defects. */
|
|
123
|
+
readonly malformed: readonly string[];
|
|
124
|
+
}
|
|
125
|
+
/** One ledger row: a stage's aggregated spend (FR-1). */
|
|
126
|
+
export interface CostLedgerRow {
|
|
127
|
+
readonly runId: string;
|
|
128
|
+
readonly slug: string | null;
|
|
129
|
+
/** `stageLabel()` output, verbatim. */
|
|
130
|
+
readonly stage: string;
|
|
131
|
+
readonly phase: string | null;
|
|
132
|
+
/** The stage's model id, or `'mixed'` when several agents share a label with different models. */
|
|
133
|
+
readonly model: string;
|
|
134
|
+
readonly agentIds: readonly string[];
|
|
135
|
+
readonly tokensIn: number;
|
|
136
|
+
readonly tokensCacheWrite: number;
|
|
137
|
+
readonly tokensCacheRead: number;
|
|
138
|
+
readonly tokensOut: number;
|
|
139
|
+
/** Cost-weighted input-equivalent tokens — the PRIMARY number of the row. */
|
|
140
|
+
readonly weightedTokens: number;
|
|
141
|
+
/** Secondary, derived estimate. `pricingKnown === false` ⇒ sonnet-class fallback pricing. */
|
|
142
|
+
readonly costUsd: number;
|
|
143
|
+
readonly pricingKnown: boolean;
|
|
144
|
+
/** ISO, from the run record's stage boundaries (ADR-001) — `null` when the record lacked them. */
|
|
145
|
+
readonly startedTs: string | null;
|
|
146
|
+
readonly endedTs: string | null;
|
|
147
|
+
/** Number of deduped usage samples (billed calls) attributed to this stage. */
|
|
148
|
+
readonly calls: number;
|
|
149
|
+
}
|
|
150
|
+
export interface CostLedgerDefect {
|
|
151
|
+
readonly kind: CostLedgerDefectKind;
|
|
152
|
+
readonly detail: string;
|
|
153
|
+
/** Weighted tokens implicated, when the defect is quantitative. */
|
|
154
|
+
readonly tokens?: number;
|
|
155
|
+
/** Stage labels or agent ids implicated, when the defect is locatable. */
|
|
156
|
+
readonly subjects?: readonly string[];
|
|
157
|
+
}
|
|
158
|
+
export interface CostLedgerReconciliation {
|
|
159
|
+
/** RIGHT side — dedup-union over the run's transcript DIRECTORY (independent of the record). */
|
|
160
|
+
readonly runTotalTokens: number;
|
|
161
|
+
/** Dedup-union of samples claimed by at least one stage. */
|
|
162
|
+
readonly accountedTokens: number;
|
|
163
|
+
/** Σ of the per-stage sums. Exceeds `accountedTokens` exactly when a sample is double-claimed. */
|
|
164
|
+
readonly stageTokensSum: number;
|
|
165
|
+
/** `runTotalTokens - accountedTokens`. */
|
|
166
|
+
readonly unaccountedTokens: number;
|
|
167
|
+
/** `stageTokensSum - accountedTokens`. */
|
|
168
|
+
readonly doubleAttributedTokens: number;
|
|
169
|
+
/** Tolerance as a FRACTION of the run total; `0` by default (ADR-002). */
|
|
170
|
+
readonly epsilon: number;
|
|
171
|
+
/** Both raw integer identities held when the report was built. */
|
|
172
|
+
readonly identityHolds: boolean;
|
|
173
|
+
readonly verdict: CostLedgerVerdict;
|
|
174
|
+
readonly defects: readonly CostLedgerDefect[];
|
|
175
|
+
}
|
|
176
|
+
export interface CostLedgerReport {
|
|
177
|
+
readonly runId: string;
|
|
178
|
+
readonly slug: string | null;
|
|
179
|
+
readonly workflowName: string | null;
|
|
180
|
+
readonly status: string | null;
|
|
181
|
+
readonly startedTs: string | null;
|
|
182
|
+
readonly rows: readonly CostLedgerRow[];
|
|
183
|
+
readonly reconciliation: CostLedgerReconciliation;
|
|
184
|
+
/** The record's cached raw sum — reported, never the invariant's right-hand side (ADR-002). */
|
|
185
|
+
readonly recordTotalTokens: number | null;
|
|
186
|
+
readonly totalCostUsd: number;
|
|
187
|
+
/** Model ids whose USD figures used sonnet-class fallback pricing (ADR-003). */
|
|
188
|
+
readonly pricingFallbackModels: readonly string[];
|
|
189
|
+
/** ALWAYS `true` — a local aggregation, not an official API (mirrors `dz usage`). */
|
|
190
|
+
readonly estimated: true;
|
|
191
|
+
/** ALWAYS {@link COST_LEDGER_SCOPE}. */
|
|
192
|
+
readonly scope: string;
|
|
193
|
+
}
|
|
194
|
+
/** FR-8 feed-forward aggregate. WIRING INTO auto-cost ROUTING IS OUT OF SCOPE — this is a reader. */
|
|
195
|
+
export interface StageCostAggregate {
|
|
196
|
+
readonly stage: string;
|
|
197
|
+
readonly model: string;
|
|
198
|
+
readonly avgTokens: number;
|
|
199
|
+
readonly runs: number;
|
|
200
|
+
readonly totalTokens: number;
|
|
201
|
+
readonly avgCostUsd: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Extract deduped, weighted usage samples from ONE transcript's text. Pure and never-throw — a
|
|
205
|
+
* corrupt line is skipped, exactly as `computeUsage` does.
|
|
206
|
+
*
|
|
207
|
+
* `weighted` is `Math.round(weightedTokensOf(...))`: the SINGLE rounding point of the feature, so
|
|
208
|
+
* every sum downstream is exact integer arithmetic and the reconciliation identity is raw equality
|
|
209
|
+
* rather than a float comparison (ADR-002).
|
|
210
|
+
*/
|
|
211
|
+
export declare function extractCostSamples(text: string): CostLedgerSample[];
|
|
212
|
+
/**
|
|
213
|
+
* Parse a `wf_<runId>.json` object into a {@link WorkflowRunRecord}. Pure and never-throw; every
|
|
214
|
+
* number is clamped and every unusable field is RECORDED in `malformed` rather than dropped, so it
|
|
215
|
+
* can surface as a `MalformedRecord` defect (the vocabulary refuses silent ignores).
|
|
216
|
+
*
|
|
217
|
+
* `args` is stored as a JSON STRING in the recorded runs on this machine and as an object in
|
|
218
|
+
* others; both shapes are accepted.
|
|
219
|
+
*/
|
|
220
|
+
export declare function parseWorkflowRunRecord(raw: unknown): WorkflowRunRecord | null;
|
|
221
|
+
/** Per-stage sample sets, keyed by the `stageLabel()` string. */
|
|
222
|
+
export interface StageSampleSet {
|
|
223
|
+
readonly stage: string;
|
|
224
|
+
readonly samples: readonly CostLedgerSample[];
|
|
225
|
+
}
|
|
226
|
+
export interface BuildCostLedgerInput {
|
|
227
|
+
readonly record: WorkflowRunRecord;
|
|
228
|
+
/** LEFT side — one entry per `agentId` that had a transcript. */
|
|
229
|
+
readonly stageSamples: readonly {
|
|
230
|
+
readonly agentId: string;
|
|
231
|
+
readonly samples: readonly CostLedgerSample[];
|
|
232
|
+
}[];
|
|
233
|
+
/** RIGHT side — the dedup-union over the run's transcript DIRECTORY (ADR-002). */
|
|
234
|
+
readonly runSamples: readonly CostLedgerSample[];
|
|
235
|
+
/** Agent transcripts present in the run directory with no `workflowProgress[]` entry. */
|
|
236
|
+
readonly orphanAgentIds?: readonly string[];
|
|
237
|
+
/** Fraction of the run total tolerated as unaccounted. Default {@link DEFAULT_COST_LEDGER_EPSILON}. */
|
|
238
|
+
readonly epsilon?: number;
|
|
239
|
+
/** True when the transcript listing hit the file cap — the run total is incomplete (Codex QE HIGH). */
|
|
240
|
+
readonly transcriptListingTruncated?: boolean;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Build the report and evaluate the invariant. PURE — no filesystem, no clock. Every number that
|
|
244
|
+
* enters is clamped here (the writer clamps; {@link verifyCostLedgerReport} enforces raw equality).
|
|
245
|
+
*/
|
|
246
|
+
export declare function buildCostLedger(input: BuildCostLedgerInput): CostLedgerReport;
|
|
247
|
+
/**
|
|
248
|
+
* Re-derive both identities from an EMITTED report — the verifier half of the house pattern. It
|
|
249
|
+
* trusts nothing the builder computed except the numbers it printed, so a future writer bug shows
|
|
250
|
+
* up as a `MalformedRecord` finding instead of a plausible table.
|
|
251
|
+
*/
|
|
252
|
+
export declare function verifyCostLedgerReport(report: CostLedgerReport): readonly CostLedgerDefect[];
|
|
253
|
+
/**
|
|
254
|
+
* Aggregate per-stage cost across runs, for a future auto-cost router that today chooses models
|
|
255
|
+
* from a STATIC assumptions table.
|
|
256
|
+
*
|
|
257
|
+
* **WIRING INTO ROUTING IS OUT OF SCOPE for this feature** — this returns data and nothing consumes
|
|
258
|
+
* it yet. That is deliberate: an ESTIMATED number must not drive an expensive routing decision
|
|
259
|
+
* until it has been calibrated. Rows from runs whose verdict is not `BALANCED` are EXCLUDED, so a
|
|
260
|
+
* run with a known attribution defect can never quietly become a routing input.
|
|
261
|
+
*/
|
|
262
|
+
export declare function stageCostAggregates(reports: readonly CostLedgerReport[]): StageCostAggregate[];
|
|
263
|
+
/** Human table + reconciliation line + verdict + the honest-scope note (ADR-003). */
|
|
264
|
+
export declare function renderCostLedger(report: CostLedgerReport): string;
|
|
265
|
+
/**
|
|
266
|
+
* FR-7 serialization: one JSON object per line. The first line is a `kind: "cost-ledger-scope"`
|
|
267
|
+
* header carrying {@link COST_LEDGER_SCOPE}, so the honest scope travels with the file; the last is
|
|
268
|
+
* the reconciliation. This is a REGENERABLE REPORT, never a read-back source of truth (ADR-001).
|
|
269
|
+
*/
|
|
270
|
+
export declare function costLedgerJsonl(report: CostLedgerReport): string;
|
|
271
|
+
export interface CostLedgerIoOptions {
|
|
272
|
+
/** Override the `~/.claude/projects` root. Defaults to {@link claudeProjectsRoot}. */
|
|
273
|
+
readonly projectsRoot?: string;
|
|
274
|
+
/** Munged project directory name (e.g. `-home-user-repo`). Absent ⇒ scan every project. */
|
|
275
|
+
readonly projectDir?: string;
|
|
276
|
+
readonly epsilon?: number;
|
|
277
|
+
}
|
|
278
|
+
export interface CostLedgerRunRef {
|
|
279
|
+
readonly runId: string;
|
|
280
|
+
readonly slug: string | null;
|
|
281
|
+
readonly workflowName: string | null;
|
|
282
|
+
readonly status: string | null;
|
|
283
|
+
readonly startedAtMs: number | null;
|
|
284
|
+
/** Absolute path of the `wf_*.json` record. */
|
|
285
|
+
readonly recordPath: string;
|
|
286
|
+
/** Absolute path of `<session>/subagents/workflows/<runId>` — may not exist. */
|
|
287
|
+
readonly transcriptDir: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Enumerate workflow run records, newest first. NEVER throws — an unreadable tree yields `[]`.
|
|
291
|
+
* READONLY. `lstat` everywhere, so a symlinked session or run directory is never walked.
|
|
292
|
+
*/
|
|
293
|
+
export declare function listCostLedgerRuns(opts?: CostLedgerIoOptions): CostLedgerRunRef[];
|
|
294
|
+
export interface DeriveCostLedgerOptions extends CostLedgerIoOptions {
|
|
295
|
+
/** Exact run id. Must match `[A-Za-z0-9_.-]{1,128}` — it becomes a path segment. */
|
|
296
|
+
readonly runId?: string;
|
|
297
|
+
/** Most recent run with this `args.slug`. Same pattern restriction. */
|
|
298
|
+
readonly slug?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Derive the ledger for ONE run. Returns `null` when no run matches — an ABSENT run is never a
|
|
302
|
+
* BALANCED empty report (ADR-003). NEVER throws; READONLY.
|
|
303
|
+
*/
|
|
304
|
+
export declare function deriveCostLedger(opts?: DeriveCostLedgerOptions): CostLedgerReport | null;
|
|
305
|
+
/**
|
|
306
|
+
* FR-8 IO wrapper: derive every run and aggregate. Runs that do not reconcile are excluded by
|
|
307
|
+
* {@link stageCostAggregates}. NEVER throws; READONLY. Still NOT wired into routing.
|
|
308
|
+
*/
|
|
309
|
+
export declare function deriveStageCostAggregates(opts?: CostLedgerIoOptions & {
|
|
310
|
+
readonly maxRuns?: number;
|
|
311
|
+
}): StageCostAggregate[];
|
|
312
|
+
/**
|
|
313
|
+
* FR-7 opt-in materialization. Atomic: writes a sibling `.tmp` then `renameSync`s over the target,
|
|
314
|
+
* and removes the temp file if the rename fails, so a crash can never leave a half-written ledger.
|
|
315
|
+
* Returns `true` on success; never throws.
|
|
316
|
+
*/
|
|
317
|
+
export declare function writeCostLedgerJsonl(path: string, report: CostLedgerReport): boolean;
|
|
318
|
+
//# sourceMappingURL=cost-ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-ledger.d.ts","sourceRoot":"","sources":["../src/cost-ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAUH,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,QAEmC,CAAC;AAElE,MAAM,MAAM,oBAAoB;AAC9B,iGAAiG;AAC/F,aAAa;AACf,uDAAuD;GACrD,kBAAkB;AACpB,8FAA8F;GAC5F,eAAe;AACjB,kGAAkG;GAChG,wBAAwB;AAC1B,oGAAoG;GAClG,iBAAiB;AACnB;8FAC8F;GAC5F,kBAAkB,CAAC;AAEvB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,oBAAoB,EAOnE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,mBAAmB,CAAC;AAE5E,eAAO,MAAM,oBAAoB,EAAE,SAAS,iBAAiB,EAI5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAW7C,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,EAAE,MAAM,GAA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