An unparseable *last* ledger line sends updater_status to the service-scoped fallback, so a stuck container can read rolled off a sibling's ledger
Id: TD-PPagop-26082932 · Status: open · Filed: 2026-08-29
lib/updater-health.sh’s _updater_health_last_entry prints nothing when a
ledger’s final line will not parse, and updater_status reads that empty
result as “no invocation recorded under our own name yet” — the same branch a
genuinely fresh container takes — and falls through to the rolled fallback
scan over every other container’s ledger. That scan deliberately skips this
container’s own file, so the run of allow entries sitting directly above the
corrupt line is never consulted. With a same-service sibling in the ledger
directory, the verdict is {status: "rolled", …} sourced from that sibling.
Reproduced on the branch of PR #929: a ledger of 30 allow entries spanning
9000 s (well past a 1200 s updater_stuck_after_minutes) with a single
unparseable final line reports {"status":"rolled","at":…,"seconds":153},
timed off a different container’s ledger, where the same ledger without the
trailing corrupt line reports {"status":"stuck","seconds":9000,"reason":"allow"}.
test/updater-health.test.sh’s “an unreadable last line reads null rather
than a guess” covers this input only in a ledger directory with no sibling
file, where the fallback finds nothing and the null masks the routing.
The adjacent case is the same shape: a line that is valid JSON but carries a
verdict with no ts ends the streak mid-scan in _updater_health_streak_start
([[ "$v" == "$want" && -n "$t" ]] fails, and the corrupt-line arm requires
both fields empty), so a 9000 s streak with one such line nine polls back
reports 2700 s. Neither line is one record_verdict writes, so both are
corruption cases rather than format cases.
Why it matters. This is the same failure the review of #929 raised as its
points 5 and 8 — a stuck container reading healthy off a sibling’s ledger, and
a single bad line silencing the alarm — surviving in the one position those
fixes do not reach. Points 5 and 8 were fixed for the mid-streak position and
for cross-service siblings; the last-line position routes past both. Severity
is low: the writer is a single container appending one short line per poll, and
the next poll’s clean allow restores the correct verdict about five minutes
later. But the direction of the error is the wrong one — a fault reads as
healthy, which is exactly what #603 exists to stop — and it is silent.
Where. lib/updater-health.sh (_updater_health_last_entry, and
updater_status’s own-entry-empty branch that treats it as “never polled”);
_updater_health_streak_start’s corrupt-line arm for the second case;
test/updater-health.test.sh (“an unreadable last line…”, which would need a
sibling ledger present to distinguish the two readings); the file header,
docs/DASHBOARD-SPEC.md and docs/IMPLEMENTATION-PIPELINE-SPEC.md
requirement 2.5, all of which currently state the contract this would change.
Suggested fix. Distinguish “this container has no ledger file” from “this
container has a ledger whose newest line will not parse” before choosing the
fallback: a file that exists must never be answered for by another container’s
file, whatever its last line says. The cheap form is to have the own-file read
scan back to the newest parseable entry rather than looking only at the final
line — the single-pass jq that _updater_health_streak_start already runs
over the whole file can return it — with the streak scan’s corrupt-line arm
widened to “any entry this file cannot read”, covering the missing-ts case
too. Deliberately not applied during review of #929: the “its last line will
not parse → prints nothing” contract is stated in the library header and in
both specs, so changing it is a spec edit and a judgement about what an
unreadable own-ledger should mean, not a local correction.
Noticed while reviewing https://github.com/Poetic-Poems/agent-ops/pull/929,
which introduces the check. Distinct from TD-PPagop-26082913, which is about a
node whose watchtower stops polling altogether keeping a valid final allow
for ever.
Migrated to https://github.com/Pullwright/agent-ops/issues/2001.