Show what has actually been installed

Automatic updates leave no other trace. The Flatpak that sat here as "1 update
available" installed itself at 00:14 this morning and nothing on the machine
would have said so.

Both sources are asked in their own machine-readable form and merged on time, so
the answer reads as one history rather than two lists to interleave by eye.

Two parsing traps worth recording next to the code. flatpak's --json prints
timestamps as "Aug 20 08:07:46" with no year in them, so the year is inferred
and a date that would land in the future is read as last year's. And dnf5's
start_time is epoch UTC while its own history table prints that same value as
though it were local -- checked against rpm, and the local rendering here is the
correct one.

The contract asserts entries are newest first, that none is dated in the future,
and that both sources parse; it was verified to fail by breaking the year
inference so every flatpak entry landed tomorrow.

Loaded on demand rather than with the page, because it reads both full
transaction logs.

Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
Gabriel Brown
2026-08-20 11:30:31 -04:00
parent de45f205ad
commit 4cbab01ae2
4 changed files with 216 additions and 0 deletions
+38
View File
@@ -100,6 +100,44 @@ jq -e '.kernel.rebootNeeded == (.kernel.running != .kernel.newestInstalled)' <<<
[[ -n "$("$helper" bogus 2>/dev/null | jq -r '.error // ""')" ]] \
|| fail 'an unknown command was accepted'
# ── Update history ──────────────────────────────────────────────────────────
#
# Worth showing because automatic updates leave no other trace: something that
# installed itself overnight is invisible until somebody looks here.
#
# Both sources are asked in their own machine-readable form. flatpak's is the
# awkward one -- it prints a JSON array whose timestamps are "Aug 20 08:07:46",
# with no year -- so the year is inferred, and a date that would land in the
# future is read as last year's. dnf's start_time is epoch UTC; its own table
# prints that value as though it were local, which it is not.
history="$("$helper" history)" || fail 'history failed'
printf '%s' "$history" | python3 -c "
import json, sys, time
payload = json.load(sys.stdin)
entries = payload['entries']
if not entries:
raise SystemExit(0) # a machine with no transactions is legitimate
now = int(time.time())
previous = None
for entry in entries:
if entry['source'] not in ('dnf', 'flatpak'):
raise SystemExit(f\"unknown source {entry['source']}\")
at = int(entry['at'])
if at and at > now + 86400:
raise SystemExit(f\"{entry['summary']} is dated in the future, so the year was read wrong\")
if at and previous is not None and at > previous:
raise SystemExit('entries are not newest first')
if at:
previous = at
if not str(entry['summary']).strip():
raise SystemExit('an entry has nothing to say it did')
if not any(e['source'] == 'flatpak' for e in entries) and not any(e['source'] == 'dnf' for e in entries):
raise SystemExit('neither source produced anything, so nothing was parsed')
" || fail 'the update history is not usable'
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")" \