Gas station inventory specialist - daily stock-balance tool - paste four numbers a day per tank (opening stick, delivered, metered out, closing stick) and the identity check runs itself by fuel: a day over the line goes red, and a run of small same-direction residuals goes yellow - the slow leak wears the yellow costume
You are a coding agent. Build a single-file HTML "fuel stock daily
balance checker" for a station's inventory specialist: paste the
numbers in, immediately see which day and which fuel is out of
balance. Runs locally, no network, no dependencies.
The problem it solves: every fuel tank satisfies a daily identity -
opening measured volume + deliveries - metered sales = closing
measured volume. A recording error, a missed entry or a theft
breaks the identity. Manual daily checking is dull and rows get
read past each other; this tool lays a whole month of residuals out
at once so the shape is visible.
Inputs:
- Data paste: one row per day - date, tank or fuel, opening
measured volume, delivered that day, metered out that day, closing
measured volume (paste straight from a spreadsheet, tab or comma
separated)
- Rules (user-configured): daily tolerance [ ] (volume or
percentage, either), same-direction run length [ ]
Computation and judgment:
- Each row: residual = opening + delivered - metered out - closing;
rate = residual / metered out
- Three states:
|residual| <= tolerance -> even
over -> red
same direction, within tolerance, but persisting >= the
configured run length -> yellow (systematic drift; more
suspicious than a single red day)
- Rows with a delivery are flagged: "check drop reconciliation and
post-settling re-gauge first" - delivery-day residuals usually
live in the drop measurement, so look there before anything else
Output:
- Month overview: date x fuel grid, each cell showing that day's
residual, red/yellow/green colored - which day, which fuel, at a
glance
- Detail: click a day to expand its four numbers and the residual's
composition
- Summary row: month-to-date cumulative residual and red/yellow day
counts per fuel
- One-click copy of the month's results as plain text, straight
into the inventory report
Implementation:
- Single-file HTML, inline CSS and JS, opens by double-click, zero
network requests
- Nothing persists; refresh wipes - no network means the data never
leaves this computer
- Preloaded demo month including one red day and one tank that
turns yellow through a run - both anomalies visible on first open
You may not:
- Build trend forecasts or "smart attribution" - the tool shows the
difference; attributing it is the human's job against drop
records and self-test logs
- Write guesses like "possibly a leak" anywhere in the interface -
coloring is the tool's entire opinion
- Add accounts, cloud sync, or external libraries
Why it is written this way
The same-direction yellow is the tool's most important judgment - worth more than the red. A single big red day is seen by everyone: pull that day's drop record and shift log and it usually resolves. The quiet bleed is the small, consistent, never-over-the-line residual: three months later the cumulative gap is a crater, and slow leaks, mild meter drift and a drifting ATG all wear exactly that costume. Making "same direction for N days" a co-equal criterion with the tolerance is what lets the tool see chronic disease, not just acute symptoms.
Delivery days carry their own flag because a residual means different things on those days: on a normal day it can only come from dispensing or metering, but on a delivery day there is a third source - the received quantity itself being measured badly. Unflagged, delivery-day residuals get investigated at the dispensers and the search runs in the wrong direction. One line of prompt hands the order to the human: drop numbers first, everything else second.
"Show the difference, never guess the cause" draws the tool/human boundary. Causes - leak, meter error, recording slip - require the drop records, self-test logs and shift notes; the moment a tool starts "attributing", its output becomes verdicts of unknown reliability that nobody double-checks. Red says "look here", yellow says "watch longer"; the why belongs to the specialist.
Variables
| Variable | Description |
|---|---|
| Daily tolerance [ ] | Liters or percent, per company metering policy; once set, keep it fixed - changing it means re-reading the history |
| Same-direction run length [ ] | Minimum days of persistent one-way residuals before yellow; set it so any run inside one month gets caught |