`scripts/visual-gate` is this repo's stated sign-off harness — three probes plus a budget over the silent-loss counters — and it watched six classes. Two that belong were not among them, and both read zero on every boot in the tree, which is exactly the state in which a gate is worth adding rather than argued about. Component: `scripts/visual-gate`. Harness only; no device code touched. - **`render_unimplemented`** — the class a green run hides best. AGENTS.md already says it in so many words: an `Ok` from `render::decode` is not a decode, because `Kind::OtherAccepted` is the catch-all for "no arm claimed this". The draw completes, the guest is stamped, and the only trace is this one line. It is deduped per opcode, so the count is a count of *kinds* lost. - **`device_info truncated`** — the device-info reply could not carry every capability key the guest's own key-table length admits. The guest asks once per boot, frees the buffer and answers every later reader from what it parsed, so a firing is a capability gone for that boot's life. Both enter `baseline.tsv` at **0** with their measurement written beside them, which is the file's own rule: zero is the default and needs no argument, a non-zero budget is an admission about the device. `render_unimplemented` is zero across all seventeen archived boots, driven and idle; `device_info truncated` is zero by construction on the guests measured here — a whole page of pair slots against a table of a few dozen keys. The parser is proved to see them rather than assumed to. `self-test.sh` gains three cases: one per class firing on text quoted from the emitter, and one asserting an `OFF `-prefixed lookalike is *not* counted — the channel inversion AGENTS.md warns about when ranking `reason=` slugs. Its class-count guard goes 6 → 8, which is what caught the headers this commit also fixes; that guard exists so a class can never quietly stop being parsed. Verified: `self-test.sh` PASS, 17/17 cases. `counter-budget.sh` against the archived driven boot at this branch's head (`journal/2026-08-06-driven-boot-at-head.log`) prints all eight classes at 0 and exits 0. Synthetic firings of both new classes take it to exit 1. A full `visual-gate.sh --quick` on a live x86/PCI boot of this head passed earlier this session — 3/3 probes green, counters all zero over 1.27 MB of fail log — but that run predates these two classes; what covers them is the archived-log check above, not that run. Not verified: no live gate run since the classes were added, and neither class has ever been observed firing on real hardware — that is the point of the zero, not a gap in it.
98 lines
4.0 KiB
Bash
Executable File
98 lines
4.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# counter-budget.sh — read the eight silent-loss classes out of one window of the
|
|
# fail log and hold each to its budget.
|
|
#
|
|
# Split out of `visual-gate.sh` so it can be tested against synthetic log text
|
|
# without a live boot. A parser that silently matches nothing reads exactly like
|
|
# a clean run, which is the failure mode this whole gate exists to remove.
|
|
#
|
|
# scripts/visual-gate/counter-budget.sh WINDOW_LOG [BASELINE_TSV]
|
|
#
|
|
# Prints one `name<TAB>count<TAB>budget` line per class, in a fixed order. Exits
|
|
# 0 when every class is inside its budget, 1 when any is over, 2 when a file
|
|
# cannot be read.
|
|
#
|
|
# Five classes are line families, keyed on the prefix their emitter writes at
|
|
# the start of a line. Three are `note_store_route` counts, which arrive as
|
|
# `key=value` fields on a `store_routes` line — that line is emitted once per
|
|
# per-second window, so a class has to be summed across every such line in the
|
|
# window rather than read off the last one.
|
|
#
|
|
# The budgets live in `baseline.tsv` rather than here, because a non-zero one is
|
|
# an admission about the device and needs its measurement written beside it.
|
|
set -euo pipefail
|
|
export LC_ALL=C
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
[ $# -ge 1 ] && [ $# -le 2 ] || {
|
|
echo "counter-budget: usage: counter-budget.sh WINDOW_LOG [BASELINE_TSV]" >&2; exit 2; }
|
|
WINDOW="$1"
|
|
BASELINE="${2:-$SCRIPT_DIR/baseline.tsv}"
|
|
[ -r "$WINDOW" ] || { echo "counter-budget: cannot read $WINDOW" >&2; exit 2; }
|
|
[ -r "$BASELINE" ] || { echo "counter-budget: cannot read $BASELINE" >&2; exit 2; }
|
|
|
|
# `deferred_flush_lost` — a guest render this device dropped.
|
|
# `mapping_page_drift` — the page list changed under an armed window.
|
|
# `THRASH present_action_starvation` — one class spelled as two words.
|
|
# `render_unimplemented` — a render opcode the decoder accepted and nothing
|
|
# executed. This is the class a green run hides best: `render::decode`
|
|
# returning `Ok` is not a decode, because `Kind::OtherAccepted` is the
|
|
# catch-all for "no arm claimed this", so the draw completes, the guest is
|
|
# stamped, and the only trace is this line. It is deduped to one per distinct
|
|
# opcode, so the count is a count of *kinds* lost, not of records.
|
|
# `device_info truncated` — the device-info reply could not carry every
|
|
# capability key the guest's own parse ceiling admits. The guest asks once per
|
|
# boot and never re-asks, so a firing is a capability gone for that boot's
|
|
# life. Spelled as two words for the same reason the starvation class is.
|
|
LINE_CLASSES=(
|
|
'deferred_flush_lost|deferred_flush_lost '
|
|
'mapping_page_drift|mapping_page_drift '
|
|
'present_action_starvation|THRASH present_action_starvation '
|
|
'render_unimplemented|render_unimplemented '
|
|
'device_info_truncated|device_info truncated '
|
|
)
|
|
|
|
# `gw_audit_unsound` — the gather witness refuted itself; a stale image is being
|
|
# served.
|
|
# `render_flush_over_guest_write` — documented as expected-never; if it fires the
|
|
# writeback ordering repair has broken.
|
|
# `tdc_overflow` — the census target map overflowed and re-seeded.
|
|
ROUTE_CLASSES=(gw_audit_unsound render_flush_over_guest_write tdc_overflow)
|
|
|
|
# A class with no row in the baseline is budgeted zero. A new class therefore
|
|
# starts strict rather than starting unwatched, which is the direction a
|
|
# forgotten entry should fail in.
|
|
budget_for() {
|
|
awk -F'\t' -v key="$1" '
|
|
/^#/ || /^[[:space:]]*$/ { next }
|
|
$1 == key { print $2 + 0; found = 1; exit }
|
|
END { if (!found) print 0 }' "$BASELINE"
|
|
}
|
|
|
|
over=0
|
|
report() { # report NAME COUNT
|
|
local budget
|
|
budget=$(budget_for "$1")
|
|
printf '%s\t%s\t%s\n' "$1" "$2" "$budget"
|
|
[ "$2" -le "$budget" ] || over=1
|
|
}
|
|
|
|
for entry in "${LINE_CLASSES[@]}"; do
|
|
name=${entry%%|*}
|
|
prefix=${entry#*|}
|
|
report "$name" "$(grep -c -- "^$prefix" "$WINDOW" || true)"
|
|
done
|
|
|
|
for name in "${ROUTE_CLASSES[@]}"; do
|
|
report "$name" "$(awk -v key="$name" '
|
|
/^store_routes /{
|
|
for (i = 2; i <= NF; i++) {
|
|
split($i, kv, "=")
|
|
if (kv[1] == key) total += kv[2]
|
|
}
|
|
}
|
|
END { print total + 0 }' "$WINDOW")"
|
|
done
|
|
|
|
exit "$over"
|