fix(coord-count): distinguish claimed from unmeasured, fix Linux date parse
Review finding 11 (docs/2026-08-14-confident-zero-review.md), tier 1,
prioritized by .claude 2026-08-14T21:24:16Z coord message.
Two bugs collapsed into one token. Column 4 of coord-count.sh (the WP1d
origin-age column) printed "-" for both "has .origin" (claimed, not a
dead-letter candidate) and "age could not be measured" - a consumer could
not tell "not a dead letter" from "not measured". Fixed by reserving "-"
for claimed only and introducing "?" for could-not-measure; board.sh's
sole column-4 consumer (awk '$4 != "-" && $4+0 >= 3') needed no change,
since awk's numeric coercion already treats "?" as 0 and filters it out
the same way "-" always was.
Second, the age computation itself used `date -u -j -f ...`, a BSD-only
invocation. Measured directly (Ubuntu 24.04, GNU coreutils 9.4, real
coord-count.sh, unmodified) rather than reasoned about: GNU date rejects
-j outright ("invalid option -- 'j'", exit 1), so every mailbox printed
"-" on Linux regardless of actual dead-letter status - WP1d detection was
silently inert on the one platform this public plugin cannot assume away.
Fixed with a one-time `date --version` flavor check (measured: exits 0
with a GNU banner on GNU date, exits nonzero with "illegal option" on BSD
date) branching to `date -u -d <RFC-3339-string>` on GNU, unchanged
`-j -f` on BSD. The RFC 3339 acceptance is documented (GNU Coreutils
manual, "Options for date"), not live-measured, since Colima was removed
from this machine mid-session before that specific sub-claim could be
re-verified live.
coord-selftest.sh section 31 (e) previously pinned the bug (asserted "-"
for an ungrammatical filename); updated to assert "?", plus a new
contrast check that claimed and could-not-measure are always different
tokens. Section 32 pins the GNU branch with a PATH shim for `date` that
replays only measured facts (the --version and -j behaviors above) rather
than a speculative mock.
All four selftest suites green: coord 200/200, board 178/178 (regression,
unaffected as predicted), route 69/69, guard 21/21.
Out of scope, reported not fixed: coord-sweep.sh:77 and both selftests'
fixture generators use `date -v-Nd` (BSD-only, same class) - the suite
itself cannot run on Linux yet. No CI exists in this repo to catch that
drift automatically.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F1mzsaUmjqFHArbArG7EpF
This commit is contained in:
parent
108a73a497
commit
db57b43f50
2 changed files with 112 additions and 15 deletions
|
|
@ -58,6 +58,19 @@ done
|
|||
|
||||
[ -d "$COORD" ] || exit 0
|
||||
|
||||
# GNU/BSD date flavor, detected once per run (not per mailbox): BSD date
|
||||
# rejects --version outright (exit nonzero, "illegal option" - measured on
|
||||
# this machine); GNU date supports it and prints a version banner (exit 0 -
|
||||
# measured directly against Ubuntu 24.04 / GNU coreutils 9.4). The origin_age
|
||||
# column below needs this because BSD's `date -j -f` and GNU's `date -d`
|
||||
# share no common invocation - GNU date has no -j at all (measured: "date:
|
||||
# invalid option -- 'j'", exit 1), which is why every mailbox printed "-"
|
||||
# (now "?", see the F11a comment below) on Linux before this branch existed.
|
||||
# coord-selftest.sh section 32 pins the GNU branch via a PATH shim that
|
||||
# replays these measured facts.
|
||||
DATE_IS_GNU=0
|
||||
date --version >/dev/null 2>&1 && DATE_IS_GNU=1
|
||||
|
||||
# Does this message owe a reply? Absent field means YES: every message written
|
||||
# before 0.11.0 lacks it, so absence has to keep meaning what it always meant.
|
||||
# The read is bounded to the frontmatter block - a body line is untrusted
|
||||
|
|
@ -108,20 +121,35 @@ for d in "$COORD"/* "$COORD"/.[!.]*; do
|
|||
fi
|
||||
done
|
||||
[ "$n" -gt 0 ] || continue
|
||||
# "-" means either .origin exists (claimed, never a dead-letter candidate
|
||||
# regardless of age) or the age could not be read (fail-safe, not
|
||||
# fail-open - an unreadable age must never be treated as old, matching
|
||||
# coord-sweep.sh's identical rule for the same filename grammar).
|
||||
# "-" means .origin exists (claimed, never a dead-letter candidate
|
||||
# regardless of age). "?" means unclaimed but the age could not be read -
|
||||
# fail-safe, not fail-open, an unreadable age must never be treated as old,
|
||||
# matching coord-sweep.sh's identical rule for the same filename grammar -
|
||||
# and, critically, must never be reported as the SAME token as claimed
|
||||
# (review finding 11, 2026-08-14: both used to print "-", collapsing "not a
|
||||
# dead-letter candidate" and "not measured" into one token a consumer could
|
||||
# not tell apart). Only a real computed age is neither.
|
||||
origin_age="-"
|
||||
if [ ! -f "$d/.origin" ] && [ -n "$oldest_ts" ]; then
|
||||
oldest_epoch="$(date -u -j -f '%Y%m%dT%H%M%SZ' "$oldest_ts" '+%s' 2>/dev/null)"
|
||||
case "$oldest_epoch" in
|
||||
[0-9]*)
|
||||
now_epoch="$(date -u +%s)"
|
||||
age_days=$(( (now_epoch - oldest_epoch) / 86400 ))
|
||||
[ "$age_days" -ge 0 ] && origin_age="$age_days"
|
||||
;;
|
||||
esac
|
||||
if [ ! -f "$d/.origin" ]; then
|
||||
origin_age="?"
|
||||
if [ -n "$oldest_ts" ]; then
|
||||
if [ "$DATE_IS_GNU" -eq 1 ]; then
|
||||
# Compact grammar (YYYYMMDDTHHMMSSZ) expanded to the RFC 3339 form
|
||||
# GNU date documents as always parseable by -d regardless of locale.
|
||||
# Bash 3.2 substring expansion, no external command needed.
|
||||
oldest_iso="${oldest_ts:0:4}-${oldest_ts:4:2}-${oldest_ts:6:2}T${oldest_ts:9:2}:${oldest_ts:11:2}:${oldest_ts:13:2}Z"
|
||||
oldest_epoch="$(date -u -d "$oldest_iso" '+%s' 2>/dev/null)"
|
||||
else
|
||||
oldest_epoch="$(date -u -j -f '%Y%m%dT%H%M%SZ' "$oldest_ts" '+%s' 2>/dev/null)"
|
||||
fi
|
||||
case "$oldest_epoch" in
|
||||
[0-9]*)
|
||||
now_epoch="$(date -u +%s)"
|
||||
age_days=$(( (now_epoch - oldest_epoch) / 86400 ))
|
||||
[ "$age_days" -ge 0 ] && origin_age="$age_days"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
# Absent, not zero: the question is "who has unhandled mail", and a list of
|
||||
# zeroes answers a different one at every reader's expense. A mailbox holding
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue