# Changelog

## v1.0.0

v0.3.3 was not released. PR #23 was merged to `main` without a tag. Its limit-detection, reporting
and broker changes ship here. Its calibration work is removed with the rest of the calibration
layer.

- Replace calibration with an estimate that follows Hostinger's readings. v0.3 estimated the bank
  from the guest's own CPU count with a fitted margin and let Hostinger's readings only lower it.
  That one rule needed a meter fit, drift detection, a steal model, holds, a 90-day history store, a
  replay command and three modes. An audit found that about half the product code served it, and
  that its machinery had raised false alarms on a live box. The new estimate is about 200 lines in
  `src/estimate.ts`, and `src/` goes from 10,104 lines to 4,149.
  [The credit estimate](docs/estimate.md) describes it:
  - Anchor. Hostinger's own CPU readings, about one every 30 minutes through the API or the broker,
    are replayed through its published credit rules. Readings move the estimate both ways.
  - Tail. The 30 to 100 minutes no settled reading covers yet come from `/proc/stat`, at 1.05 × busy
    cores + 0.04, plus what the last day's readings showed above that: the mean plus two standard
    deviations of the last 48.
  - Guard. A reading under what the guest counted itself cannot be Hostinger's bill, so the own
    count stands in for it. A reading counts for at most 1.3 × the guest's count + steal + 0.3
    cores, so a feed that breaks high cannot starve the box.
  - Steal. The tail charges stolen CPU whole while the VM delivers more than a credit limit could,
    the plan's limit + 0.1 cores. At or under that it charges none, because the steal may be a
    limit's own.
  - Unknown time. A reading no sample covers is billed and earns nothing, because a limit may have
    come and gone unseen. Time nothing measured, as after a reboot or a hole in the readings longer
    than the samples reach, counts at the most the VM could have spent until readings settle past
    it.
  - Clock. Readings carry Hostinger's clock. After a wall-clock step of more than a minute, either
    way, the estimate carries on from the guest's own count, and readings that end more than two
    hours before the box's clock move nothing.
- Remove the modes. There is no `calibration.mode`. With a Hostinger token or broker configured, the
  estimate follows the readings. Without one it runs on the guest's own count alone.
- Use one spending floor, 10% of capacity. It was 5% in `apply` and 20% in `off`. The spend law is
  otherwise the same.
- Learn one thing from limits. The first lift test that fails says what holds the VM. Held at the
  plan's limit, it is Hostinger's credit limit, and the pad, the cores billed on top of every
  reading, rises by 1.25 times the rate the estimate was wrong. What the limit found is the lowest
  the estimate read in the 20 minutes before it, since the estimate rises under a limit nobody has
  recognised yet. A limit that found the estimate already empty teaches nothing. Neither does one
  whose first failed test finds the VM held higher, as Hostinger's sustained-use limit may, or one
  whose first test passes. The own count's addition, pad included, stops at the baseline less 1.05 ×
  (the plan's limit − 0.2 cores): past that the governor would hold the box harder in normal running
  than while a limit recovers.
- After any limit the estimate carries on from what the guest's own count rebuilt since the limit
  began, and the anchor is set there. Nothing from before the limit comes back: what the limit found
  may have been spent while it lasted, and the earlier anchor, replayed through a limit that work
  pressed on, would earn what the bank did not.
- Drop the three-hour hold at the baseline that followed a sustained-use limit. No governed box has
  met that limit, and the hold was part of the calibration layer.
- Stop false credit limits on a nearly idle box. A probe compares two 15-second steal shares, and at
  a third of a core of demand it scores noise. A live box on v0.3.1 took two false limits in one
  morning that way, each holding every login at 0.2 cores for 23 minutes, and v0.3.2's 0.4-core gate
  would have cleared that box by 2%. A probe that passes now only earns a burner test, and the
  burners decide: a credit limit holds the VM at the plan's limit whatever is asked of it, so only a
  VM they find held there starts a limit. Replayed on the box's own samples, v0.3.1 enters two
  limits, v0.3.2 one or two, and v1.0.0 none. The burner test adds 35 seconds to recognising a limit
  through a probe.
- A limit lifts when the VM delivers three quarters of what the burners ask, whatever the neighbours
  take on top. Their steal used to keep a limit in force.
- Keep the rest of v0.3.2's limit detection: evident steal, the probe that cuts the slice to 20%,
  the burner test when the VM is pinned at the cap, the cooldown that backs off from 10 to 60
  minutes, and the bypass when steal jumps. The live steal charge of #23 and the detection rules
  added for it are gone. This hardening from #23 stays:
  - No plan probes a slice whose own CPU is at or under 0.20 cores, KVM 1 and KVM 2 included: a 20%
    quota cannot cut it. Such a slice goes to the burner check, `pinnedAtCap()`, which runs before a
    probe is considered.
  - A limit the burner check enters starts its recovery clock after the burners. It still needs a
    failed lift test to count as confirmed.
  - `limitPressing()` needs demand and steal a cap could cause, so a neighbour's blip on an idle box
    does not stop the estimate earning.
  - The recovery ceiling tracks `tightenedCeiling` apart from spikes of work outside the slice. It
    tightens at once and relaxes to what every sample of the five-minute window allows: a spike
    gives its room back once it has left the window, and outside load that keeps swinging holds the
    low side instead of moving the quota every pass.
  - A probe's cooldown runs from the probe's end, and the backoff returns to 10 minutes after 24
    hours of calm past the cooldown.
  - On plans with 4 or more vCPUs, outside a limit and away from the 20% floor and the full-plan
    ceiling, 10% ceiling jitter is skipped. While the allowance is under every vCPU, tightening is
    never delayed, so the deadband cannot bias spending upward.
- Keep the reporting and broker fixes from #23:
  - Resolve `saYYYYMMDD` and legacy `saDD` sysstat files across the union of local and UTC calendar
    dates, counted as dates so a night that skips midnight loses no day, and deduplicate `sadf` rows
    by timestamp. Keep 72 hours of settled readings in public state so `governor report 72` has full
    API history.
  - Show `Not available` instead of zero peaks when memory, swap or load history is empty.
  - Publish `capFailed` in public state. `governor status` and `governor report` show a recovery
    quota that failed to apply during a limit, and share one warning list. Warnings carry their
    date.
  - Enforce a total HTTP deadline inside `API_SECONDS` (15 s) in `tools/hostinger-broker.py` via
    `ITIMER_REAL`, using a private deadline exception outside `OSError`, with any outer timer taken
    off while it runs and restored after it. Map non-JSON HTTP 200 replies to
    `upstream_unavailable`.
  - `governor check-hostinger` retries a transient broker `busy` and runs both of its requests
    inside one 50-second budget, which setup's 55-second connection check allows for.
- Fetch readings during a limit too. v0.3 started no new fetch while limited. The estimate still
  ignores readings until the lift.
- Change public state under `credits`, keeping `schemaVersion: 1`. `credits.calibration` is gone.
  `credits.staleSince` is new: the timestamp in milliseconds of the last settled reading once none
  has arrived for two hours, else null. `credits.anchor.applied` now means the estimate stands on
  Hostinger's readings. `credits.law.floor` is 0.1.
- Fire three hook events: `limit-start`, `limit-end` and `calibration`, which now fires when a limit
  raises the pad. `limit-classified`, `rules-mismatch` and `readings-invalid` no longer fire.
- Remove `governor calibrate --explain`. It prints a message and exits 2. The `--reset` form stays
  and resets the pad and the addition learned from readings. Every other command is unchanged.
- Remove `recovery.quota_period_ms`, the 10 ms quota period while limited. The fallback quota still
  resets a period an earlier release left.
- Log an `estimate:` line after each fetch, with the balance, anchor, margin and pad. The
  `recovery observation` line at each lift stays, and now says whether a lift test confirmed the
  limit.
- Replace the calibration studies with 23 eight-week studies in `test/studies.ts`, which run in
  under two minutes in sequence. `deno task sim:legacy` and `deno task sim:jumps` are gone.
  [Study results](docs/study-results.md) has every number. All of it is simulation:
  - At the recorded seed all 23 studies pass. Over 12 seeds, 276 runs of 56 simulated days, they
    take 26 credit limits: one per run in S3 and S23, the limit that teaches a 0.10-core billing
    gap, and 2 in S17, a 0.5-core jump in Hostinger's meter. 275 runs pass. In the other a simulated
    sustained-use limit, once its cap has fallen to the plan's limit, raises the pad.
  - The floor was chosen on the first 17 studies: with a 5% floor their 204 runs took 52 limits,
    with 7.5% they took 20, and with 10% they took 15. CPU delivered differed by 0.17% between 5%
    and 10%.
  - The 15 week-long scenarios take 27 throttles at seed 1, against 43 for v0.3.3 `apply` and 46 for
    `off`, with 80.3 throttled hours against 248.7 and 241.1. They deliver 9,798.7 core-hours
    against 9,147.9 and 9,129.2. One scenario carries most of that gap: without it v1.0.0 delivers
    1.4% more than `apply`, and throttled hours go from 106.9 to 80.3. All 27 throttles are in the
    three scenarios where Hostinger's real baseline is 30%, not the published 60%.
  - The 25 detection scenarios take 46 throttles against 58 and 48, and no false limit where the
    earlier design took 2.

Real hardware has shown little of this.
[The credit estimate](docs/estimate.md#what-real-hardware-has-shown) lists what was measured. No
governed box has yet met a real credit limit, a meter jump or a sustained-use limit, so the design
assumes Hostinger bills what its readings show plus a small constant. If real billing runs above the
readings, the box takes a limit and the pad learns.

Upgrade by running the installer again and updating `/usr/local/libexec/governor-hostinger.py` as
described in [Hostinger credentials](docs/hostinger-credentials.md).

- Configuration. The `calibration`, `readings` and `recovery` blocks of an older config are accepted
  and ignored. The daemon logs one line naming them. Every other setting works as before.
- State. `persist.json` is now schema 3. The first start carries a v0.3 file over: its estimate, the
  lower of the open and the acted one, its samples and readings, a probe cooldown, and any active
  limit. The estimate stands where v0.3 had it and readings move it from there. What v0.3's limits
  taught carries over as the pad: `apply`'s billing gap, or the margin `off` and `shadow` widened.
  State from before v0.3 starts the estimate from zero and keeps an active limit.
- Upgrade outside a limit if you can. A limit in force is carried with the ceiling it was held at
  and its lift-test clock, but what it would have taught is not: on a host that bills more than it
  reads, the same upgrade took one more limit in simulation where a v0.3.2 restart took none.
- `initial_balance`. It counts on a first start only, and only when above zero. A `persist.json`
  that is lost, unreadable or holds no state starts the estimate from zero, as v0.3 did. v0.3 told
  lost state from a first start by its history file. v1.0.0 keeps none and goes by `daemon.lock` in
  `/var/lib/governor`, which every release leaves behind from its first run.
- Daemon stops and reboots. Time the daemon did not watch is charged from the kernel's counters and
  earns nothing, as before. It is no longer laid beside Hostinger's readings, and the readings that
  cover it are billed without earning either: a limit may have come and gone unseen. The estimate
  reads low after a long stop until the bank is next full.
- Readings from before the governor watched are never replayed. A first start, or lost state, begins
  at zero and climbs with what the bank earns from then on.
- History. `history.json` and `history.log` in `/var/lib/governor` are no longer read or written.
  Delete them once the upgrade has settled.
- Downgrade. v0.3.2 does not read schema 3, so going back starts its estimate from zero. It does
  read its old `history.json` as if no time had passed, a limit that was in force then included.
  Delete both history files before going back.
- Floor. A box that ran in `off`, the default, now spends down to 10% of its bank where it stopped
  at 20%. A box in `apply` holds 10% where it held 5%.
- Hooks. A hook that waits for `limit-classified`, `rules-mismatch` or `readings-invalid` never
  hears them again. Readings that stop arriving show in `credits.staleSince` and in
  `governor status`.
- Scripts. `governor calibrate --explain` exits 2, and `credits.calibration` is gone from
  `governor status --json`. `credits.margin`, `credits.anchor` and `credits.staleSince` hold what is
  left to read. In `limit`, `entry.used` is gone and `confirmed` is new: unset until a lift test
  fails, then whether that test found the VM held at the plan's limit.
- `tick_seconds` above 100. Limit detection now looks at the last three passes when they take longer
  than five minutes. In v0.3 such a box recognised no limit at all.

## v0.3.2

- Stop false credit limits on an idle box when neighbour steal rises:
  - The limit probe runs only while `user.slice`'s own demand (its busy CPU plus its share of the
    steal, excluding steal on work outside the slice) is at least 0.4 cores on KVM 4 and up, or 0.3
    cores on KVM 1 and 2. Below that, cutting the slice to 0.2 cores removes too little demand to
    tell a limit from neighbour noise.
  - Steal of 60% of demand enters a limit without a probe only when it is also at least a quarter of
    the plan's limit in cores; otherwise a busy slice is still probed.
  - When work outside an idle slice sits near the plan's limit (85% of the limit up to +0.1 cores)
    with at least 15% steal, the governor confirms the cap with its burners before entering so noisy
    neighbours near the cap do not cause false limits.
  - After a confirmed credit lift, only evident steal starts a limit for as long as full use takes
    to spend the 20% bank a lift leaves, measured from the last failed lift test. Unknown and
    sustained-use lifts set no quiet window. Failed probes and cap checks keep the 10-minute
    exponential backoff up to an hour.
  - During a limit, the ceiling tightens only where the slice's current-sample demand exceeds the
    tighter ceiling.
- Unstick drift verification during a pending change: while a CUSUM drift change is pending, the
  extreme-residual test, its recovery and the fit's 6σ filter judge each reading against the band
  between the reference and the raised fit. Against the raised fit alone, idle readings sitting at
  the reference scored 6σ below an offset-only raise, marked the readings invalid and stalled
  verification.
- Report fixed upstream error codes from the Hostinger broker (`upstream_status` with the HTTP
  status, including refused redirects, and `upstream_unavailable` for timeouts, connection/TLS
  errors and truncated or malformed HTTP replies) so the daemon logs the cause without exposing
  upstream text.
- Print a clean permission message instead of a Deno stack trace when a non-root user runs
  `governor calibrate --explain` (or other commands lacking file access), and state in the startup
  `governor up` line when a reboot restarts the credit estimate at 0%.

Upgrade by running the installer again. Configuration, credit estimates, the legacy margin and the
learned calibration are kept. To get the broker's new upstream error codes, also update
`/usr/local/libexec/governor-hostinger.py` separately as described in
[Hostinger credentials](docs/hostinger-credentials.md). On a box upgraded while a drift change is
pending, `governor calibrate --explain` may report a checkpoint digest mismatch until the first pass
writes a new checkpoint.

## v0.3.1

- Address issue #19: drift detection follows the newest meter fit that qualified, not only the fit
  the learned margin kept. Refits run daily and the margin only tightens, so on a box whose start is
  tighter than its meter the margin keeps its first fit, and drift detection judged every reading
  against that frozen fit: an upward jump had to be that much bigger before it alarmed. CUSUM, a
  drift change's verification, the extreme-residual test, the refit's 6σ filter and corroboration
  now judge against the newest qualifying fit, and the CUSUM sums start again at each new one. The
  margin still only tightens. After a verified drift change, the fit on the readings after it
  replaces what limits taught during the change only when it reads at least as high as the margin's
  fit from three guest cores to the VM's vCPUs; otherwise the gap and margin they taught stay.
  `status --json` shows the new reference as `credits.calibration.referenceFit`, and
  `calibrate --explain` as `evidence.referenceFit` and, in its text form, a `Drift reference` line
  when it differs from the margin's fit. Recovery without `persist.json` restores the reference and,
  for a drift change still holding, the margin's fit; a catch-up that changes the reference starts
  the sums again.
- The own-count hold corroborates returning readings against a replay of its limit's recorded inputs
  above the drift reference. It compared them with its own gap, measured above the governor's
  charges, and a real 0.5-core jump read as 0.295 cores there and failed to agree. History keeps
  that limit's inputs until the first diagnosis after the hold ends, so a later limit in the same
  outage can't leave the readings invalid. `ownHold.central` is no longer reported.
- The fit still can't set the multiplier below `start.mul`, and readings still never raise the acted
  estimate.
  [Calibration](https://github.com/olmezsoy/hostinger-governor/blob/v0.3.1/docs/calibration.md#running-closer-to-the-readings)
  says what evidence each needs first.
- In the calibration studies, S4's clamp and CUSUM act 9.5 hours after its slope change instead of
  11.5 and 12.0, and S12 logs 22 would-be changes instead of 24. The 0.5-core meter jump costs 7
  limits over ten seeds, one more than v0.3.0; every jump still meets the criteria.

Upgrade by running the installer again. Configuration, credit estimates, the legacy margin and the
learned calibration are kept. Until the first refit after the upgrade, drift detection judges
against the margin's fit, as v0.3.0 did.

## v0.3.0

- Address issue #13: calibrate the margin and spending floor from this VPS's own record, opt-in
  through `calibration.mode`. `off`, the default, keeps the 1.05× + 0.08 margin, the 20% floor and
  `widen()`. `shadow` actuates the same way and logs what `apply` would decide. `apply` starts at
  1.05× + 0.04 with a 5% floor, tightens from Hostinger's readings and confirmed credit limits, and
  requires `hostinger.vm_id` and a token source or broker. Readings never raise the estimate the
  governor acts on. The first switch to `apply` drops what `shadow` learned and keeps what the
  readings and limits are doing: staleness, readings marked invalid, the holds and any cooldown.
  Raising `start`, `gap_start` or the start floor takes effect at the next daemon start.
- Keep 90 days of readings, ten-minute CPU slots, reading revisions, the last 50 limits and the last
  100 calibration decisions in `/var/lib/governor`: a daily `history.json` snapshot and an
  append-only `history.log` of what changed since. The files are private, bound to the plan and VM,
  and written after the pass sets its ceiling. History recorded without a VM binds to the one first
  configured, so adding `vm_id` keeps it; one bound to a VM stays bound when the config names none.
  Writes come to about 0.9 MB a day in the benchmark and 1.3 MB with a realistic 90-day file. A
  corrupt snapshot is quarantined and rebuilt without failing a pass, a record that fails
  validation, in the snapshot or a log line, is dropped alone, its decoded inputs included, and a
  torn log line costs only that write. The store checks that it only appends rows, so a slot sorted
  into place after a backward clock step reaches the log, and compaction syncs the directory after
  each rename, so a power cut can't pair the old snapshot with the new, empty log. At most 1,000
  reading revisions are kept. The daily snapshot is synced before its rename, and a leftover
  temporary file can't block a write. Losing `persist.json`, or one that doesn't parse, reruns the
  latest recorded evaluation from its inputs and recovers the whole calibration state, a drift
  change's verification included; without one, the newest decision since `apply` first ran holds the
  learned settings. The bank estimate restarts at 0, and the clamp with it. Off mode's widened
  margin is rebuilt from the legacy margin each limit record held at entry, before `apply`'s first
  start inherits it. One the daemon can't read stays for the next run, and with `persist.json`
  missing too the run writes no `persist.json`, so the next start still recovers. Every pass writes
  history before `persist.json`, syncing each log line, and a start that finds a newer recorded
  evaluation, by an evaluation serial rather than the clock, reruns it, so a crash or power cut
  between the two can't undo a reset or drop a decision. Every pass compares the whole history with
  what was written and appends the difference, so no change can miss the write. A failed write is
  retried as a snapshot every 10 minutes, and until it succeeds `persist.json` records that history
  is behind it. Recovered state is never older, by serial, than anything history recorded, and
  history that shows `apply` ran rules out `apply`'s first start. Calibration state is bound to the
  VM it learned from. A limit history recorded and `persist.json` missed or lost goes on as a limit,
  and one history shows lifted ends; a `persist.json` this run can't read rules out a first start,
  so it never grants `initial_balance`. The sustained-use cooldown follows from the limit records,
  and a failing evaluation's fallback, with the margin below the open estimate it keeps, is held
  every pass and kept in `persist.json`, so a restart, status (`failing`) and `--explain` show it
  too. A request in the seconds after a pass takes that pass's time, so nothing it records is later
  than the evaluation after it; the request and the pass decide that from one clock reading. A
  recovery without a recorded evaluation that verifies applies a reset among the newer decisions
  before raising to the newest, so a decision after the reset no longer undoes it. A reboot inside a
  slot comes back to that slot instead of reading as a clock step. If an evaluation fails, `apply`
  holds the 1.05× + 0.08 fallback, fires `calibration`, and acts on the open estimate less the
  clamp's last margin; lifted limits are still classified and sustained-use estimates restored, so
  off mode's `widen()` gate, the cooldown and the restore don't depend on the rest of calibration. A
  widening off learned from a limit entered in `apply` comes back with a lost `persist.json` too.
  `governor run` refuses to run as root, whose files the service couldn't read, and a second daemon
  exits instead of appending to the same history.
- Hold the daemon to 0.1% of one core averaged over a day with 90 days of history. The new
  `deno task bench:cpu` measures a day of control passes without the JIT, with the clamp replaying
  on every pass: 0.012 to 0.015% of a core on an M-series Mac, of which calibration and history add
  0.005 to 0.007%.
- Treat each reading as covering the interval since the previous one, 900 to 2,700 seconds apart, so
  `replay()` and the CPU comparison work with real spacing. Compare each newest reading with its
  later values; `newestFinal` reports seven days of comparisons without a revision.
- Fit Hostinger's meter, watch for upward drift with a one-sided CUSUM, and learn the billing gap
  from confirmed credit limits by bisecting a replay of settled readings. In `apply`, the acted
  estimate is the lower of the guest estimate and the readings replay plus 2.5% of capacity. Across
  reading gaps and clock-invalid time, the clamp bills the guest's count at the settings in force;
  learning bills the fitted meter across reading gaps. Each replay's base carries over, so the clamp
  stays on when its anchor ages out of history or a replay meets time no local sample covers; a
  reboot, a seed, `limit off` or a lost `persist.json` gives it a new anchor. Readings after
  intervals longer than 2,700 seconds are paired apart, in `longIntervals`, until data shows how
  Hostinger averages them.
- Treat a drift alarm as a temporary hold, not learned state. Once verified, it lasts until a fit on
  the readings after the change point qualifies; that fit, and each refit until its window has
  passed the change point, sets the margin against the one learned before the change, so an additive
  jump no longer leaves a higher multiplier behind. The alarm reads a slope only from pairs at three
  or more guest cores, so a small change at idle can't read as a multiplier of 2 or more. The fit's
  noise is never below what its light-load pairs show, and its slope bound resamples only days that
  hold a qualifying pair: idle weekend days set the multiplier as high as 1.233 after an `apply`
  start without `shadow`. A meter pair whose interval a later reading split is computed again over
  the new interval, or dropped. All three rules-mismatch tests replay to the recorded onset, so a
  short span after a lift no longer reads a gap of twice the real one, nor a 1-core meter jump as
  beyond a core, and a corroboration bills its rise only after the readings turned extreme. Readings
  are invalid for spacing when more than 12 of the last 24 hours are badly spaced, outages left out.
  On small plans a sustained-use fall must exceed the credit band's 0.3 cores as well as 20% of
  vCPUs an hour. Residuals beyond 6 σ never feed drift detection or a fit, readings at the 100% cap
  never feed drift detection, and readings marked invalid are replayed as gaps. A confirmed credit
  limit whose rise in billing agrees with the invalid readings' residual, within ±50% either way,
  makes them count again; a feed in the wrong units cannot. While readings are invalid or stale, a
  second confirmed credit limit within seven days raises a temporary hold by the full own-count
  result plus two σ; it ends when readings resume. In the recorded simulator run over ten seeds, a
  meter jump of up to 0.5 cores cost at most one limit and one of up to a core at most two; the CI
  gate allows one, one, three and four limits for jumps of 0.25, 0.5, 0.75 and 1 core.
  `governor calibrate --explain [--json]` replays the recorded decision read-only, and
  `sudo governor calibrate --reset` returns calibration to its configured start.
- Keep the seconds each slot pressed on a limit, so Hostinger's earning is replayed for the rest of
  it: a 30-second lift test no longer costs its slot all its earning, and the lift check predicts
  recovery times again. The clamp, a lower bound, keeps counting such a slot as earning nothing.
- Classify every limit at its lift as credit, sustained-use or unknown. Only a confirmed credit
  limit teaches, in every mode, so `off` now widens its margin at the lift rather than at the first
  failed lift test. After a sustained-use limit the allowance stays at or below the baseline for
  three hours, and the estimate its reset hid is restored from the guest's own count. On KVM 1 a
  sustained-use first cap must also clear the credit band. A failed lift test places the cap only if
  it found limited evidence or a later test failed too, so neighbours' steal after a lift can't make
  a credit limit sustained-use. Recovery times or gaps that the pinned rules cannot explain, judged
  from the detected lift, latch a rules mismatch, which falls back to `widen()` learning. A limit
  whose gap a reboot or clock jump leaves unmeasurable still raises the floor. The floor replays the
  settings in force, holds included. A raise made while readings are unusable is undone when the
  readings that return are corroborated as a meter change, so a jump during an outage no longer
  leaves the floor at 10%.
- In `apply`, hold at least 1.05× + 0.08 after a day of stale or invalid readings, and release the
  hold when readings resume and the fit finds one of them normal, so a feed that comes back broken
  after an outage keeps both holds and the fallback's clock. Readings beyond 6 σ that agree with the
  rise the own-count hold's limits measured count again, so a real jump during an outage still ends
  the hold. An outage of more than 6 hours counts as staleness, not as bad spacing, so readings are
  usable as soon as they return. A downward meter step beyond 6 σ keeps the readings invalid, and
  the fallback in force, until `calibrate --reset`: no billing evidence can confirm a meter that
  reads low.
- Reject configuration keys the governor doesn't know, anywhere in the file, so a misspelt setting
  fails `governor validate-config` instead of leaving its default in force. `apply` needs a token
  source or broker as well as `hostinger.vm_id`. The broker reports a wrong unit or value as
  `invalid_metrics`, so a brokered box alerts with `readings-invalid` as a direct one does. The
  direct API path takes a reading's timestamp only as the broker does, digits alone, so `"1.5"` or
  `"1e3"` no longer passes on one path and fails on the other. Both accept a reading up to 5 minutes
  ahead of this box's clock, which v0.2.5 rejected, so a slightly slow clock doesn't fail fetches. A
  value too large for a float is invalid metrics on the broker too, not a failed fetch, and a
  response without `cpu_usage` and its `usage` mapping is a failed fetch on the direct path too, not
  an empty one.
- `limit on` while a limit is already detected leaves it going, so its record still gets its lift
  and class. Requests run in the order they were sent, so `limit on` and `limit off` sent together
  no longer run the other way round, and a lift never lands before its record's entry.
- Add hooks `limit-classified` for sustained-use and unknown limits, `calibration`, `rules-mismatch`
  and `readings-invalid`, delivered after the pass sets its quota, and `credits.law` and
  `credits.calibration` in public state, whose `applied` is the settings in force: the legacy margin
  in `off` and `shadow`. `credits.anchor.applied`, always false in v0.2.5, is true while the
  readings lower the balance `apply` acts on; the hold while calibration fails shows as `failing`
  instead. `calibration` fires when learning tightens the learned settings under a higher hold too,
  once a pass and only when something changed. Reports count runway and reserve against the spending
  floor. `--explain` prints the learned settings whenever they differ from those in force, as in
  `shadow`. `learning.onset_margin_s` may be 0.
- Add an optional `recovery.quota_period_ms: 10`: a 10 ms quota period while limited, through a
  third `governor-cap` argument. It is off by default and unverified against Hostinger's scheduling.
  A failed restore of the default is retried after 15 minutes.
- Add eight-week calibration studies S1 to S14 to the simulator. CI checks each recorded outcome
  with `deno task sim:check`, and that the features each study relies on ran: the lift check
  predicted, the clamp was available, drift detection alarmed. `deno task sim:jumps` runs meter
  jumps of 0.25 to 1 core over ten seeds, during an outage and with a feed at 8x the meter, against
  the v0.3.0 criteria. `deno task sim:legacy` keeps `off` on the legacy scenarios as recorded, and
  `bench:cpu` fails above the 0.1% budget; CI runs all three. A randomized test drives the daemon
  through restarts, lost and corrupt `persist.json`, reboots, stops, clock jumps, resets and a meter
  jump, and checks after every step that nothing loosens, recovery gives back the state, and
  `calibrate --explain` equals the daemon's state.
- Address issue #12: the VM read returns the VM's IPv4 addresses next to its CPU count, and
  `governor check-hostinger` prints them as an `ipv4` array, so a deployment can require one of them
  to be among the host's own addresses. Each must be a canonical dotted quad: anything else in the
  list rejects the response, a null field means no addresses, and an older broker that omits the
  field gets a warning. The setup wizard's post-install check also requires the broker to return one
  of the addresses preflight matched to a local interface.
- Run provider diagnostics in the background after the pass sets its ceiling, with at most one
  request in flight and the 30-minute schedule and retry backoff measured from completion, so a slow
  or hung broker can't delay a pass. New requests pause while limited. Startup sizes the plan from
  `vcpus` or the kernel's CPU count and no longer asks Hostinger. Shutdown waits for the active
  request, and the installer sets `KillMode=mixed` so systemd signals only the daemon first. A
  `token_command` runs in its own session, shares a 15-second budget with the HTTP request that
  follows, and its output is capped at 8,192 bytes.

Upgrade by running the installer again, which also updates `governor-cap`. Existing configuration,
credit estimates and the legacy margin are kept, and calibration starts in `off`. The installer
checks the configuration with the new binary before it stops the daemon, so a key v0.3.0 doesn't
know stops the upgrade with the old daemon still running; fix or remove the key and run the
installer again. It also hands state files an earlier `sudo governor run` left root-owned back to
the governor user. A limit in progress during the upgrade is classified at its lift from the caps it
presses on after the upgrade, and widens the margin only if it was a credit limit. A brokered box
also needs the matching release's broker. The release publishes `hostinger-broker.py` beside the
binaries; [Hostinger credentials](docs/hostinger-credentials.md) shows how to fetch it on the VPS,
check it against `SHA256SUMS` and install it as `/usr/local/libexec/governor-hostinger.py`. Until
then a wrong unit or value from Hostinger makes readings go stale instead of raising
`readings-invalid`. Hook authors: `limit-classified`, `rules-mismatch` and `readings-invalid` are
new events, and they fire in every mode, `off` included: for a sustained-use or unknown limit, a
latched rules mismatch, and readings marked invalid. `calibration` fires only in `apply`. To try it,
set `hostinger.vm_id` and `"calibration": { "mode": "shadow" }`, then see
[Calibration](https://github.com/olmezsoy/hostinger-governor/blob/v0.3.0/docs/calibration.md).

## v0.2.5

- Address issue #5: add root-only `governor tick` to run one control pass through the running daemon
  and wait for persisted and public state writes. Serialize requests with timed passes without
  postponing their timer. Report unavailable daemons, failed passes and timeouts to callers.
- Fold intervals shorter than `min(5 seconds, tick_seconds / 2)` into the next sample so counter
  noise cannot tighten recovery quotas. Apply queued commands and publish state on every pass. Keep
  timed control running if the optional control socket fails. Cover synchronous completion,
  concurrent requests, timed ticks and failures, plus real limit/quota verification at the
  production cadence in the Linux smoke test. Test the real control pass through the socket,
  including state-write and quota failures.

Upgrade by running the installer again, or restart the daemon after replacing the binary. Both the
CLI and running daemon need the new binary for `governor tick`. Existing configuration and credit
estimates are kept.

## v0.2.4

- Fix issue #3: embed V8's `--jitless` flag in release, CI and local compiled binaries so the
  runtime no longer needs executable memory for JIT compilation. Governor has no WebAssembly
  dependencies.
- Document an optional daemon MDWE drop-in for systemd v255+, including sudo, JIT hooks and rollback
  requirements. Its restart check discards the previous daemon's public state, so it cannot pass
  before the new daemon sets its ceiling. CI follows those steps, then runs quota control and broker
  integration with the opt-in enabled. The installer keeps the setting opt-in for older hosts.
- Require `version`, `status --json` and `report 1` to run under MDWE as root and a regular user.
  Install a JIT-enabled build of the current source, verify CPU control, and require that build to
  abort under MDWE as a negative control. This does not test a historical release binary.
- Share build commands through named tasks that compile with the Deno running the task. Keep the JIT
  fixture in a temporary directory that the smoke test removes on exit.
- Cover Ubuntu 22.04, 24.04 and 26.04, plus native ARM64 execution on 24.04. Check the production
  broker sudo grant with sudo-rs separately from full broker integration on 24.04. Run release
  packaging and its 24.04 smoke gate on pull requests, with publication restricted to version tags.

Upgrade by running the installer again. Existing configuration and v0.2 credit estimates are kept.
Read-only services can keep `MemoryDenyWriteExecute=yes` with the new binary. Daemon hardening is
optional and applies to hooks too. Remove the MDWE drop-in before installing a JIT-enabled binary.

## v0.2.3

- Address issue #1: configurable `fallback_cpu_percent`, default 20% of one vCPU. Validate it
  against the VM size, use it before startup and after stopping, and mirror it into the boot quota
  during installation. Invalid or unreadable configuration falls back to 20%. Recovery and probe
  floors remain unchanged. Document outside workloads, baseline and host-limit constraints.
- Add `schemaVersion: 1` to public state and hook snapshots without changing the persisted credit
  schema. Existing estimates survive upgrade. Built-in readers accept legacy snapshots without the
  field and reject unknown versions.
- Run hooks on a bounded background FIFO, after quota application, with captured event state. Each
  hook has its own `hook_timeout_seconds`, default 60, including time blocked on stdin. Kill its
  ordinary process group when the parent exits, at the deadline or shutdown; failures cannot hold up
  CPU control or later notifications. Limit payload/backlog memory and log drops without logging
  hook output.
- Add an operation-only `hostinger.request_command` adapter. A separate broker can return VM details
  and CPU readings without giving Governor a bearer token. Validate the versioned protocol, enforce
  response and lifetime limits, redact command errors and refuse ambiguous token sources.
- Add `governor check-hostinger` for read-only connection checks and a restricted Linux/systemd
  reference broker with encrypted worker-only credentials, fixed GET endpoints, VM authorization,
  request limits and a separate provider identity. Existing token options remain supported.
- Add a generic SSH setup wizard with hidden token entry, VPS verification, confirmation before
  installation and rollback tests. Provision the isolated worker and retire an installer-managed raw
  token into a verified encrypted backup. Refuse to copy a raw token over a broker installation.
  Share successful metrics across authorized request windows so connection checks do not consume the
  daemon's next request. Report temporary busy/cooldown refusals without accepting arbitrary error
  text. Add a dummy-token Linux integration test for the real credential/sudo/systemd path.
- Keep setup tokens out of sudo's logged stdin with a private FIFO bridge. Share API transport,
  security limits and validation with the bundled broker. Attempt every rollback step independently,
  preserve recovery files on incomplete rollback and verify fresh service state after recovery.
  Cover early failures, partial publication, failed restores and hidden-input/confirmation behavior.
  Extend the Linux test to localhost SSH, enabled sudo I/O logging, journal inspection, separate key
  ownership and a readable canary proving `ProtectHome`. Bound the worker's full lifecycle below the
  25-second caller deadline.
- Report unsupported public schemas cleanly from `status`, `report` and `exec`. Run child CLI tests
  with explicit permissions and keep writable test data separate from tracked fixtures.
- Verify setup against the new daemon's publication, not its predecessor's shutdown state. Record
  rollback intent before file changes so interrupts cannot skip restores. Test the real freshness
  check, FIFO safety refusals, stalled receivers and environment cleanup. Reuse broker VM validation
  and request construction, name setup deadlines, and document root authority and manual rotation.
  The Linux integration test now drives the actual Bash wizard through localhost SSH; offline
  adapters are installed after loading unchanged modules, without slicing source text.
- Size setup's stop and fresh-state waits from Governor's longest tick (a history request plus a
  limit test) and systemd's stop timeout, so a limit test in progress cannot roll back a good
  install. Rollback cancels the overall setup deadline and relies on its own step deadlines.
- Remove obsolete `CPUAccounting=yes` from the generated boot drop-in. Fail startup if systemd
  cannot apply the fallback, instead of starting without that cap.

Upgrade with the installer. Existing configuration and v0.2 estimates are kept. The default
fallback, credit rules and report formats are unchanged. Choosing a larger fallback is an explicit
availability tradeoff, not an automatic safety guarantee. A stale status file alone does not apply
the fallback.

Hooks no longer log stdout/stderr. Each event captures state at notification time, and the FIFO
holds at most 16 waiting events with payloads limited to 1 MiB. Overflows are logged and dropped;
delivery is best-effort. Hooks that start background work must wait for those children, since the
runner now kills remaining ordinary children when the parent exits. Move daemonized work to a
separate supervised service before upgrading.

Editing `fallback_cpu_percent` changes runtime behavior after a restart. Re-run the matching
installer to update the early-boot quota too. Broker setup is optional and separate from the regular
installer; upgrades do not automatically migrate or revoke existing tokens.

## v0.2.2

- Retire inherited, quota-only `user.slice` drop-ins into recoverable backups before installation.
  Check shadowed files too. Refuse mixed-setting files or quotas in the main unit before changing
  the installation, so unrelated settings are kept and stale persistent caps cannot override the
  boot fallback. Stop the old governor before migrating quotas and maintain a safe runtime cap.
- Support enrollment of bare service templates such as `xfs_scrub@.service` without loading an
  instance. Verify a real template instance in the Linux smoke test.
- Explain reserve rebuilding in public state and reports without treating it as a host limit or
  closing job admission. Keep compatible v0.2 estimates on upgrade. Mark CPU sample warmup and use
  reserve-aware, margin-adjusted runway in text reports too.
- Add channel-neutral resource reports with readable text tables, an HTML table-and-chart layout,
  and structured JSON through `governor report [hours] --format text|html|json`. Include an editable
  browser preview template. No bot, credentials, extra runtime or delivery mechanism is bundled.
  Test missing readings, recovery, warmup, rates, runway and HTML escaping.
- Watch Hostinger's CPU credit article. A scheduled workflow opens an issue when the article
  changes, with the reviewed and live numbers, numbers it can no longer find, contradictions inside
  the article, the changed lines, and whether the code still agrees. Only markers from the workflow
  or verified maintainers count as reported, failures are reported once per kind, and an optional
  heartbeat alerts when the watcher stops running or cannot read all essential rules. Bot markers
  inside quoted article content cannot suppress other versions.
- `rules/hostinger-cpu-credits.json` records the reviewed version (a fingerprint, the numbers and
  their source sentences, not the article). `deno task rules:accept` refuses incomplete records, and
  `deno task check` keeps `src/plans.ts` and the new `EARNING_PAUSE_SHARE` in line with the record.
  The daemon still never reads the article.

Upgrade by running the installer again. Existing v0.2 configuration and estimates are kept. Resource
reports are built in; connect their output using `docs/resource-reports.md`. The baseline, credit
policy and 20% fallback are unchanged.

## v0.2.1

- Exclude probe and lift-test intervals from quota control, outside-demand estimates, and recovery
  warnings while continuing to bill their CPU. Reset pending tests and learning across reboots.
- Back failed lift tests off for 2, 4, 8, then 15 minutes after completion. Allow evident or sharply
  increased steal to bypass a failed neighbour probe's cooldown.
- Defer margin learning until healthy burners show delivery consistent with an ongoing limit. Failed
  burners and ambiguous delivery cannot widen the margin. A first passing test leaves the margin
  unchanged without assuming a false alarm or restoring unproven credits.
- Add bounded `governor exec --wait <seconds>` and low-weight batch scopes. Document per-user
  weights, cron retry behavior, the fallback escape hatch, and the limits of aggregate quotas.
- Log recovery timing, predicted duration, conservative earning pauses, and baseline assumptions.
  Add the supplied simulator with alternate paused-billing scenarios and week-long regression tests.
- Remove the obsolete `--consumer` flag from the install example and extend the Linux smoke test to
  verify batch scope weight.

Upgrade by running the installer again. Existing v0.2 state and configuration are kept. The 20%
fallback and 60% default baseline are unchanged; live Hostinger billing still needs verification.

## v0.2.0

- Use kernel uptime and boot identity for CPU accounting and status freshness. Reboots, counter
  resets, and upgrades from v0.1 start the estimate at zero. Unknown intervals cannot earn credits.
- Make API history diagnostic only. Validate metric units and values, omit the newest bucket,
  invalidate replay certainty across gaps, compare complete guest intervals, and back off retries.
- Measure steal relative to demand. Tighten recovery quotas every minute using measured outside
  consumption and demand. Verify lift with delivered CPU and a 15% steal threshold, with independent
  tests after the earliest possible recovery time and two-minute retries.
- Require root for control requests and verify ownership at the daemon. Revoke legacy consumer write
  access. Restrict the privileged cap helper to `user.slice` and install a boot fallback quota.
- Add a configurable baseline and allow billing margins to keep learning beyond the previous caps.
  Keep the documented 60% default, with guidance for verifying the deployed rules.
- Count all CPU in the managed slice, including containers and services. Add `governor exec`,
  `enroll-service`, and `configure-docker` for workload placement and expose outside demand in
  status.
- Validate installer arguments and config, update package indexes before installing sysstat, and add
  regression tests for accounting, recovery, permissions, API failures, and installation.

Upgrade by running the installer again. The v0.1 estimate is discarded and rebuilds from observed
usage. `limit` and `seed` now require root. Service enrollment requires a restart; existing Docker
containers require recreation. API history no longer raises the balance automatically.
