Skip to content

feat(admin): the budget lever and the trend lines on the insights page (issue #181) - #183

Merged
edgehero merged 1 commit into
mainfrom
feat/insights-budget-lines
Aug 12, 2026
Merged

feat(admin): the budget lever and the trend lines on the insights page (issue #181)#183
edgehero merged 1 commit into
mainfrom
feat/insights-budget-lines

Conversation

@edgehero

Copy link
Copy Markdown
Owner

Second PR of #181: the page that prices everything now shows the one dial the operator can actually turn, and trends read as lines.

Budget panel (the lever)

Sits second from the top, beside the headline spend: reserved-vs-cap FACTS for the day/week/month job-slot windows and the daily token counter, with a decorative meter bar drawn only when both numbers are known (fill clamped at the track — overflow is carried by the state WORD), the soft-hold band as an amber tick, and the lever named (/dispatch set dailyCap|weeklyCap|monthlyCap|dailyTokenCap|softHoldPct <n>, the panel's s). The meter doctrine holds throughout: an overlay-unset cap renders unknown (day) or off (week/month with nothing reserved) with no bar and no percentage; an unreachable queue leaves the caps as facts, states the absence, and adds a banner; the page-global !/remaining/i pin now guards this section for free. States are computed assembler-side with the worker's own windowState (and the old dashboard token rule, >= cap) and ride the payload as words — the artifact builder cannot load the worker, and duplicating threshold arithmetic behind a parity test would put policy in two places. readBudget gains the token counter as a fourth plain GET plus a synchronous junk-URL parse guard (the readSchedulers failFast posture; without it every canned not-a-url test invocation burns the 2.5s timeout). GET-only doctrine intact.

Line charts

Per-flow daily spend as small multiples: one panel per top flow, one shared dollar scale (multiples are only comparable on one axis), the same band-center x math as the daily columns, segments dashed wherever an estimated day touches, floors marked , gap days sitting on the baseline as measured $0 facts, series identity carried by the panel TITLE — the palette has one non-reserved data hue and dashes already mean estimated, so overlaid lines could only be told apart by a channel the class system already spent. A (+K more flows · ~$X est.) tail keeps the cut honest. Plus a cumulative mini-chart with its OWN nice scale under the daily columns (a running total dwarfs daily bars; a second y-axis on one plot is the dual-axis lie), demoted permanently from its first estimated day and end-labelled with the running typed total, which converges to the KPI's provenance total by construction.

Data side: foldCosts gains dailyByFlow — the composite (day, flow) fold at the loop buildDaily and buildByFlow already walk separately, gap-padded per flow over the SHARED span, with flowLabelOf extracted so the two flow folds cannot drift on what a flow is called.

Specs

REQ-INSIGHTS-HTML-EXPORT gains clauses (g) and (h) plus the content list and acceptance rows. REQ-SPEND-CAPS-MULTI-WINDOW, REQ-TOKEN-ACCOUNTING-AND-CAPS, REQ-COST-ANALYTICS, CONST-BUDGET-BEFORE-TOKENS, DES-ADMIN-VIA-PI-EXTENSION all UNCHANGED, checked (the dashboard's budget meters and /dispatch budget are untouched — this ADDS a display, replaces nothing). DES-COST-FOLD-BY-SCAN amended for the series.

Tests

Suite green in the CI posture (2192 tests, 0 skipped, live Valkey). New: budget byte-pins (reserved 3 / cap 25 (overlay), cap unknown (worker env/default) with exactly three meter tracks for three known caps, off · no cap set, the soft-hold word, the lever line), budget degrades (off / unreachable-with-banner / junk-state-degrades-to-silence / missing-slice), layoutFlowLines and layoutCumulative geometry as numbers (shared scale, monotone x, dashed-segment rule, baseline zero days, permanent demotion, typed end label), determinism extended over reversed dailyByFlow/days/budget key order, the hostile-flow-name panel-title escape, the absent-series absent-section rule, dailyByFlow fold tests (shared-span gap padding, demotion, flowKey null), readBudget token GET + the never-constructs-a-client junk-URL test, and the command-level budget smoke. Headless-Chrome screenshot inspected before shipping.

Stacked on #182 (already merged), so the diff is this slice alone.

…e (issue #181)

The page that prices everything now shows the one dial the operator
can actually turn, and trends read as lines.

- BUDGET PANEL, second from the top beside the headline spend:
  reserved-vs-cap facts for the day/week/month job-slot windows and
  the daily token counter, a decorative meter bar only when both
  numbers are known (fill clamped at the track; overflow is the
  WORD's job), the soft-hold band as an amber tick, and the lever
  named. An overlay-unset cap is unknown/off with no bar and no
  percentage; an unreachable queue leaves caps as facts plus a
  banner; states are computed assembler-side with the worker's own
  windowState (and the old token rule, >= cap) and ride the payload
  as words the page never derives. readBudget gains the token
  counter as a fourth plain GET and a synchronous junk-URL parse
  guard (the readSchedulers failFast posture -- without it every
  canned not-a-url test invocation burns the 2.5s timeout); GET-only
  doctrine intact, CONST-BUDGET-BEFORE-TOKENS.
- LINE CHARTS: per-flow daily spend as SMALL MULTIPLES (one panel
  per top flow, one shared dollar scale, identity carried by the
  panel title -- the palette has one non-reserved data hue and
  dashes already mean estimated), segments dashed wherever an
  estimated day touches, floors marked, gap days on the baseline;
  plus a cumulative mini-chart with its OWN scale under the daily
  columns (a running total dwarfs daily bars; a second axis on one
  plot is the dual-axis lie), demoted permanently from its first
  estimated day, end-labelled with the running typed total.
- foldCosts gains dailyByFlow: the composite (day,flow) fold at the
  loop buildDaily and buildByFlow already walk separately, gap-padded
  per flow over the SHARED span, flowLabelOf extracted so the two
  flow folds cannot drift.

Specs in the same PR: REQ-INSIGHTS-HTML-EXPORT gains clauses (g)/(h)
and the content list; REQ-SPEND-CAPS-MULTI-WINDOW,
REQ-TOKEN-ACCOUNTING-AND-CAPS, REQ-COST-ANALYTICS,
CONST-BUDGET-BEFORE-TOKENS, DES-ADMIN-VIA-PI-EXTENSION all UNCHANGED,
checked; DES-COST-FOLD-BY-SCAN amended for the series.

Suite green in the CI posture: 2192 tests, 0 skipped, live Valkey.
Headless-Chrome screenshot inspected: budget rows, soft-hold word and
tick, unknown-cap row barless, demoted cumulative, four multiples on
one scale.

Signed-off-by: Rob Boerman <robboerman@live.nl>
@edgehero
edgehero merged commit 8d88229 into main Aug 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant