Tier 0: render what the services already decided, honestly

Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
Gabriel Brown
2026-08-25 00:24:30 -04:00
parent be0e55214b
commit 8b1205e4b8
38 changed files with 1474 additions and 260 deletions
+77
View File
@@ -283,6 +283,83 @@ grep -Fq 'dnf-automatic is not installed' "$helper" \
grep -q 'def set_auto_dnf' "$helper" \
|| fail 'automatic package updates are reported but cannot be turned on'
# ── 9. A check that failed is not an up-to-date machine ─────────────────────
#
# Every source used to answer a failure with an empty list and no error: dnf
# outside exit 0/100, flatpak against an unreachable remote, fwupdmgr printing
# nothing (its --json exits 0 on failure and says so in the payload). The page
# then added three zeroes together, said "Up to date", and stamped the clock --
# the reassuring wrong answer, on the one page whose whole job is security
# fixes.
#
# Proved with the same stubs the changelog section uses: every tool present and
# every tool failing.
check_work="$(mktemp -d /tmp/panama-updates-check.XXXXXX)"
trap 'rm -rf "$changelog_work" "$check_work"' EXIT
mkdir -p "$check_work/cache/panama"
run_check() {
PATH="$changelog_bin:$PATH" XDG_CACHE_HOME="$check_work/cache" "$helper" "$@"
}
failed_check="$(run_check check)" || fail 'check crashed instead of reporting the failure'
for source in dnf flatpak firmware; do
[[ -n "$(jq -r ".$source.error // \"\"" <<<"$failed_check")" ]] \
|| fail "$source reported no error after failing, so its empty list reads as nothing to do: $failed_check"
[[ "$(jq -r ".$source.count" <<<"$failed_check")" == "0" ]] \
|| fail "$source invented a count out of a failed check: $failed_check"
[[ "$(jq -r ".$source.checkedAt" <<<"$failed_check")" == "0" ]] \
|| fail "$source stamped its clock on a check that failed: $failed_check"
done
[[ "$(jq -r .checkedAt <<<"$failed_check")" == "0" ]] \
|| fail "a check where nothing answered still stamped the overall clock: $failed_check"
[[ "$(jq -r '.dnf.securityKnown' <<<"$failed_check")" == "false" ]] \
|| fail "a failed advisory query still claims the security count is known: $failed_check"
# A clean stamp already on record is CARRIED, not refreshed. "Checked 2 minutes
# ago" beside a stale count is the same lie wearing a timestamp.
printf '%s' '{"checkedAt":1000,"dnf":{"available":true,"count":0,"packages":[],"securityCount":0,"securityKnown":true,"error":"","checkedAt":1000},"flatpak":{"available":true,"count":0,"applications":[],"error":"","checkedAt":1000},"firmware":{"available":true,"count":0,"devices":[],"error":"","checkedAt":1000}}' \
>"$check_work/cache/panama/updates.json"
stale_check="$(run_check check)" || fail 'check crashed over an existing cache'
[[ "$(jq -r .checkedAt <<<"$stale_check")" == "1000" ]] \
|| fail "a failed check moved the overall clock forward: $stale_check"
[[ "$(jq -r '.dnf.checkedAt' <<<"$stale_check")" == "1000" ]] \
|| fail "a failed source moved its own clock forward: $stale_check"
# An old cache with none of these fields must still read, rather than losing
# them at the surface where a missing error looks exactly like no error.
printf '%s' '{"checkedAt":1000,"dnf":{"available":true,"count":0,"packages":[],"securityCount":0}}' \
>"$check_work/cache/panama/updates.json"
legacy="$(run_check snapshot)" || fail 'snapshot crashed over a cache written before per-source errors'
jq -e '(.dnf | has("error") and has("checkedAt"))
and (.flatpak | has("error") and has("checkedAt"))
and (.firmware | has("error") and has("checkedAt"))' <<<"$legacy" >/dev/null \
|| fail "an older cache lost the per-source honesty fields: $legacy"
# The service must refuse "Up to date" while a source is unknown, and must ask
# that question BEFORE it asks whether the total is zero -- a failed source
# contributes zero, which is what made the two indistinguishable.
grep -Fq 'if (root.anySourceFailed) {' "$service" \
|| fail 'the summary does not consider a source that could not answer'
python3 - "$service" <<'PY' || fail 'the summary can still say "Up to date" over a source that never answered'
import sys
body = open(sys.argv[1], encoding="utf-8").read()
start = body.index("function summary()")
end = body.index("\n }", start)
summary = body[start:end]
if "anySourceFailed" not in summary:
raise SystemExit('summary() does not test anySourceFailed')
if summary.index("anySourceFailed") > summary.index('"Up to date"'):
raise SystemExit('summary() says "Up to date" before it asks whether a source failed')
PY
grep -Fq 'Updates.sourceError("flatpak") === ""' "$page" \
|| fail 'the applications row says "Current" without asking whether the list was read'
grep -Fq 'Updates.sourceError("firmware") === ""' "$page" \
|| fail 'the firmware row says "Current" without asking whether the list was read'
grep -Fq 'securityKnown' "$page" \
|| fail 'the headline says "nothing security-critical" without asking whether advisories were read'
printf 'updates contract: PASS (%s dnf, %s flatpak, %s firmware; reboot needed: %s)\n' \
"$(jq -r '.dnf.count // 0' <<<"$state")" \
"$(jq -r '.flatpak.count // 0' <<<"$state")" \