fix(admin): the cost fold prorates on the requested window, and three what-if honesty fixes (issue #175) - #176
Merged
Merged
Conversation
… what-if honesty fixes (issue #175) Four corrections to the cost analytics, the first insights slice: - foldCosts gains sinceMs and prorates on the REQUESTED window, never the span the records happen to cover: a sparse window shrank the denominator and flipped plan verdicts to SAVING. COSTS_WINDOWS and costsSinceMs move into costs.mjs beside the fold so the scan cutoff and the denominator cannot drift; window.firstRunMs rides along for renderers that want the observed left edge, and daily buckets still start at the first observed run so the sparkline keeps its density. - byFlow rows carry flowKey (null for the no-flow bucket) and the what-if filters by it: the "(no flow)" display label matched no record, so a fully ledgered bucket rendered the seeded band. - The ledger's other/other overflow row leaves the what-if shortlist: it is unpriceable, so offering it silently degraded the estimate to the seeded band. - buildProvenance counts truncated ledgers (usage.truncated was persisted by the record contract and read by nothing); the TUI and text provenance lines render the count only when nonzero. Specs in the same PR: REQ-COST-ANALYTICS amended, acceptance rows only, the lettered labeling rules (a)-(g) untouched; DES-COST-FOLD-BY-SCAN amended with the first-run derivation moved to Rejected as a refuted correction. REQ-TOKEN-ACCOUNTING-AND-CAPS UNCHANGED, checked (the truncated field was always in the contract; only the reader changed). INT-RUN-HISTORY-FILE-CONTRACT UNCHANGED, checked. docs/costs.md example arithmetic recomputed under the honest denominator. Suite green in the CI posture: 2182 tests, 0 skipped, live Valkey. Signed-off-by: Rob Boerman <robboerman@live.nl>
This was referenced Aug 12, 2026
edgehero
added a commit
that referenced
this pull request
Aug 12, 2026
Ships the insights consolidation: issues #175 and #181, PRs #176-#180 and #182-#184. - admin 0.8.0: insights is the ONE analytics surface. Bare /dispatch insights (and the panel's i key) writes and opens the self-contained page: budget dials with used-vs-cap facts and the worker's own states, plan verdicts, daily + cumulative + per-flow spend charts, the four breakdowns, and the trigger/flow topology with schedule tips and spend badges. insights whatif is the estimator. The COSTS and GRAPH views and the costs/graph subcommands are REMOVED; the cost-fold correctness fixes (requested-window proration, flowKey, other/other, truncated-ledger counter) and the byTrigger/byRepo/ dailyByFlow folds ride along. dispatch_costs is unchanged. - worker 0.3.0 and receiver 0.2.1 are unchanged since v0.10.0 and their publishes skip. - Image ?v= tags normalized to this release's version. Suite green in the CI posture: 2192 tests, 0 skipped, live Valkey. Signed-off-by: Rob Boerman <robboerman@live.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First slice of #175: the cost fold's four correctness defects, fixed before anything new is built on top of it.
What
foldCostsgainssinceMs(the same instant the caller cut the scan at) and deriveswindow.daysfrom it; the old first-observed-run derivation shrank the denominator on any sparse window, prorated a $99 plan to pocket change, and flipped verdicts to SAVING. The new pinned test folds the same records twice: SAVING under the old derivation (kept for window-less callers,sinceMs: null), LOSING under the honest one.COSTS_WINDOWS/costsSinceMsmove INTOcosts.mjsbeside the fold so the scan cutoff and the denominator come from one function; the twins indashboard.tsandindex.tsare deleted.window.firstRunMsrides along, and daily buckets deliberately keep the first-run origin so the sparkline never opens with a month of leading zero cells.byFlow[]rows carryflowKey(null for the no-flow bucket) beside the displayflow; thewlayer stores both and hands the key towhatIfFlow. Before this, the"(no flow)"display label went into the(r.flow ?? null)filter, matched no record, and a fully ledgered bucket rendered the seeded band with "no ledgered run to measure from".other/otherleaves the what-if shortlist. The meter's 8-row overflow bucket is an aggregation artifact, not a model:getPricedModel("other","other")is null, so cycling onto it silently degraded the estimate to the seeded band.usage.truncatedwas persisted perINT-RUN-HISTORY-FILE-CONTRACTand read by nothing;buildProvenancenow counts runs whose ledger folded rows intoother, and both provenance renderers say so, only when nonzero (the rates-drift pattern).Specs
REQ-COST-ANALYTICSAMENDED, acceptance rows only; the lettered labeling rules (a)-(g) stand untouched.DES-COST-FOLD-BY-SCANAMENDED: the requested-window rule in the Decision, the refuted derivation on the Rejected list.REQ-TOKEN-ACCOUNTING-AND-CAPSUNCHANGED, checked:usage.truncatedwas always in the contract; only the reader changed.INT-RUN-HISTORY-FILE-CONTRACTUNCHANGED, checked.DES-SUBSCRIPTIONS-ARE-COUNTERFACTUAL-ONLYUNCHANGED, checked.docs/costs.md: the frame example recomputed under the honest denominator, the proration sentence, and the truncated-ledger honest limit.Tests
Suite green in the CI posture (2182 tests, 0 skipped, live Valkey). New pins: the SAVING→LOSING flip under
sinceMs,costsSinceMswindow edges including the future-edge clamp,flowKeyon the no-flow bucket, the seam receivingflow: nullfrom a no-flow what-if,other/othernever offered across a fullwcycle, and the truncated counter rendering only when it happened. The two amended window pins gained the newfirstRunMsfield; every other existing assertion passes unmodified.