@@ -807,6 +807,36 @@ human_s() {
807807 if (( s >= 60 )) ; then printf ' %ss (%dm%02ds)' " $s " $(( s / 60 )) $(( s % 60 )) ; else printf ' %ss' " $s " ; fi
808808}
809809
810+ # Epoch seconds → a UTC instant a reader can compare against a dated report, or
811+ # NOTHING (return 1) when this host's `date` cannot produce one. Two spellings
812+ # exist and they are not interchangeable: GNU takes `-d @N`, BSD/macOS takes
813+ # `-r N`. ⚠ The failure this guards is not the rejected flag -- it is that on
814+ # macOS `-d` means something else entirely (it sets the DST flag), so
815+ # `date -u -d @N '+…'` there formats NOW and returns a perfectly well-formed
816+ # string for the WRONG INSTANT. A shape check cannot tell that apart from a real
817+ # conversion, so neither spelling is trusted on shape: each is probed against an
818+ # epoch whose answer is known, and only a `date` that turns 0 into 1970-01-01 is
819+ # asked to turn anything else into anything. Same discipline as
820+ # `stamp_resolution` above, for the same reason -- a caller that cannot get a
821+ # right answer here must be handed no answer, never a confident wrong one.
822+ utc_stamp () {
823+ local fmt=' +%Y-%m-%dT%H:%M:%SZ' out
824+ if [[ " $( date -u -d @0 " $fmt " 2> /dev/null) " == ' 1970-01-01T00:00:00Z' ]]; then
825+ out=" $( date -u -d " @${1} " " $fmt " 2> /dev/null) "
826+ elif [[ " $( date -u -r 0 " $fmt " 2> /dev/null) " == ' 1970-01-01T00:00:00Z' ]]; then
827+ out=" $( date -u -r " $1 " " $fmt " 2> /dev/null) "
828+ else
829+ return 1
830+ fi
831+ case " $out " in
832+ [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z)
833+ printf ' %s' " $out "
834+ return 0
835+ ;;
836+ esac
837+ return 1
838+ }
839+
810840# --- the ledger -------------------------------------------------------------
811841#
812842# WHY A LEDGER AND NOT MORE STDERR.
@@ -1719,6 +1749,73 @@ mode_report() {
17191749 ' ' | * [!0-9]* ) printf ' records: %s\n' " $total " ;;
17201750 * ) printf ' records: %s, spanning %s\n' " $total " " $( human_s $(( last - first)) ) " ;;
17211751 esac
1752+
1753+ # ⚠ THE POPULATION, AND WHERE ITS FLOOR ACTUALLY IS. Everything below is
1754+ # computed over ONE file -- the path printed at the top -- and that file's
1755+ # history is not the fleet's. This script already knew that: the ageing
1756+ # paragraph in the slots block had to state it in order to explain why a
1757+ # constant could not be sized against a p95 that does not exist. But it stated
1758+ # it in a comment eight hundred lines from the only surface that prints these
1759+ # numbers, so no reader of a REPORT ever met it, while the report went on
1760+ # ranking commands under a fleet-scale heading. An agent asking "is a
1761+ # 19-minute hold normal here?" got a confident, well-formed answer over a
1762+ # population that structurally could not contain one -- the same shape as the
1763+ # two mixed-population hazards the blocks below already have to warn about,
1764+ # one level up: an instrument answering in the green direction about something
1765+ # it did not measure.
1766+ #
1767+ # The path alone does not discharge this. A path is a LOCATION; a population
1768+ # is an INTERVAL, and no reader can derive the second from the first -- the
1769+ # ledger is redirectable (`OS_VERIFY_LOCK_LEDGER`), so even the `/tmp` in the
1770+ # default is not a fixed premise, and `/tmp` would still not say WHEN the
1771+ # records begin. So the floor is printed as a number, from data this report
1772+ # already holds.
1773+ #
1774+ # ⛔ WHAT THIS DELIBERATELY DOES NOT SAY is "since this container started",
1775+ # and it does not print an uptime beside the first record. That pairing is the
1776+ # obvious spelling and it is MEASURED WRONG. On the box this was written on,
1777+ # `/proc/uptime` reported 878s -- while ALL 74 records in the live ledger, and
1778+ # the ledger file's own birth time, predated that boot, the oldest by 8h11m
1779+ # (positive control, same command: a file touched at that moment read as after
1780+ # the boot, so the comparison can return both answers). The uptime clock and
1781+ # the filesystem holding the ledger are not guaranteed to restart together.
1782+ # `/proc/uptime` also does not exist on the macOS hosts this file's bash-3.2
1783+ # floor exists for. A report that prints a confident wrong boundary is worse
1784+ # than one that prints none -- that is the very defect being repaired here --
1785+ # so the floor is stated as what it provably is, the first record, and the
1786+ # reason it sits there is left unasserted.
1787+ local nowts age fstamp floor
1788+ printf ' scope: every figure below is computed over ONE file — the ledger named above —\n'
1789+ printf ' and over nothing else.\n'
1790+ # Both halves of the floor, because they answer different questions and either
1791+ # can be unavailable: the INSTANT is what a reader compares a dated
1792+ # observation against ("my 19-minute hold was on the 26th — is it in here?"),
1793+ # the AGE is what tells them how much shift this population is. Whichever can
1794+ # be established is printed; if neither can, the two sentences either side
1795+ # still state the shape of the bound, which is the half that cannot be wrong.
1796+ floor=' '
1797+ case " $first " in
1798+ ' ' | * [!0-9]* ) ;;
1799+ * )
1800+ fstamp=" $( utc_stamp " $first " ) " || fstamp=' '
1801+ nowts=" $( now_s 2> /dev/null) " || nowts=' '
1802+ age=' '
1803+ case " $nowts " in
1804+ ' ' | * [!0-9]* ) ;;
1805+ * ) (( nowts >= first)) && age=" $( human_s $(( nowts - first)) ) ago" ;;
1806+ esac
1807+ if [[ -n " $fstamp " && -n " $age " ]]; then
1808+ floor=" ${fstamp} , ${age} "
1809+ elif [[ -n " $fstamp " ]]; then
1810+ floor=" $fstamp "
1811+ else
1812+ floor=" $age "
1813+ fi
1814+ ;;
1815+ esac
1816+ [[ -n " $floor " ]] && printf ' ⇒ it reaches back to its first record and no further: %s.\n' " $floor "
1817+ printf ' ⇒ runs from before that, and runs recorded against any other copy of this path,\n'
1818+ printf ' are absent from every figure below. Absent is not the same as counted zero.\n'
17221819 local size
17231820 size=" $( wc -c < " $LEDGER_FILE " 2> /dev/null | tr -d ' ' ) "
17241821 case " $size " in
@@ -1799,7 +1896,13 @@ mode_report() {
17991896 # not by the worst single run: the command that decides how much the fleet
18001897 # queues is the one that owns the most lock-seconds, which a per-run maximum
18011898 # can point away from entirely.
1802- printf ' \nlock-seconds held, by command (top 10 — this is where hold time actually goes):\n'
1899+ # ⛔ The heading is bound to the population, not to the fleet. The old wording
1900+ # -- "this is where hold time actually goes" -- is the one sentence this
1901+ # report PRINTS that makes a fleet-scale claim; the two similar phrasings
1902+ # elsewhere in this file are source comments about the mechanism's purpose and
1903+ # are not output. Leaving it beside the scope block above would have shipped
1904+ # the disclosure and the claim it contradicts in the same report.
1905+ printf ' \nlock-seconds held, by command (top 10 — where the hold time in THIS ledger went):\n'
18031906 awk ' {
18041907 h = ""; lbl = ""
18051908 for (i = 2; i <= NF; i++) {
@@ -2623,6 +2726,77 @@ mode_self_test() {
26232726 " $( printf ' %s\n' " $rpt " | grep -c ' it does not count the HOLDER either' ) " 1
26242727 st_case ' and the off-by-one heading itself is gone, not merely annotated' \
26252728 " $( printf ' %s\n' " $rpt " | grep -c ' waiters already ahead):' ) " 0
2729+
2730+ # --- the scope of the population, and the clock that names its floor ------
2731+ #
2732+ # The report used to state its span and never its POSITION: `records: N,
2733+ # spanning T` says how wide the window is and nothing about where it starts,
2734+ # while the ranking below it was headed with a fleet-scale claim. So an agent
2735+ # asking "is a 19-minute hold normal here?" was answered over a population
2736+ # that could not contain one, and nothing printed said so. These cases are
2737+ # spelled against the SAME capture as the four above, which each assert a 1 --
2738+ # so a zero here cannot be a zero produced by a capture that came back empty.
2739+ st_case ' and --report states that its population is one file, not the fleet' \
2740+ " $( printf ' %s\n' " $rpt " | grep -c ' computed over ONE file' ) " 1
2741+ st_case ' and names the floor of that population rather than only its width' \
2742+ " $( printf ' %s\n' " $rpt " | grep -c ' it reaches back to its first record and no further' ) " 1
2743+ st_case ' and says the runs outside it are absent, which is not a measured zero' \
2744+ " $( printf ' %s\n' " $rpt " | grep -c ' Absent is not the same as counted zero' ) " 1
2745+ # ⛔ BOTH SIDES, because the defect was a HEADING and not a missing sentence:
2746+ # a report that kept "this is where hold time actually goes" beside the new
2747+ # scope block would satisfy every presence assertion above while still
2748+ # printing the fleet-scale claim the scope block contradicts.
2749+ st_case ' and the ranking is headed by its population, not by the fleet' \
2750+ " $( printf ' %s\n' " $rpt " | grep -c ' where the hold time in THIS ledger went' ) " 1
2751+ st_case ' and the fleet-scale heading is gone, not merely annotated' \
2752+ " $( printf ' %s\n' " $rpt " | grep -c ' this is where hold time actually goes' ) " 0
2753+
2754+ # `utc_stamp`, which supplies the instant in that floor. A KNOWN epoch mapped
2755+ # to a KNOWN string, because the failure mode here is not an error: it is a
2756+ # well-formed string for the wrong instant (see the helper's own comment), and
2757+ # only a fixed expected value can tell those apart.
2758+ st_case ' utc_stamp converts a known epoch rather than formatting now' \
2759+ " $( utc_stamp 1787849472) " ' 2026-08-27T16:51:12Z'
2760+ st_case ' and converts the epoch its own probe is built on' \
2761+ " $( utc_stamp 0) " ' 1970-01-01T00:00:00Z'
2762+ st_case ' and hands back NOTHING, loudly, rather than a guess it cannot make' \
2763+ " $( utc_stamp not-an-epoch; printf ' rc=%s' " $? " ) " ' rc=1'
2764+
2765+ # ⚠ THE macOS BRANCH, ACTUALLY EXERCISED. `-r` exists in `utc_stamp` for a
2766+ # host CI never runs on — the same blind spot the bash-3.2 floor gate exists
2767+ # for — so without these two cases it is a guard nobody has ever seen fire.
2768+ # The fake below is macOS-SHAPED, not macOS: `-r` reads an epoch and `-d` does
2769+ # not, which is the actual difference. Two directions, and the second is the
2770+ # one that keeps the first honest: the helper must still answer the RIGHT
2771+ # instant through the fake (only reachable via `-r`), and the fake must be
2772+ # shown to really mis-answer `-d` — otherwise the first case would pass
2773+ # against a fake that was quietly just GNU `date`.
2774+ local fakebin realdate
2775+ realdate=" $( command -v date) "
2776+ fakebin=" ${tmp} /fakebin"
2777+ mkdir -p " $fakebin "
2778+ cat > " ${fakebin} /date" << FAKEDATE
2779+ #!/usr/bin/env bash
2780+ # macOS-shaped: -r takes an epoch, -d sets a flag and swallows its operand.
2781+ epoch=""
2782+ fmt=""
2783+ while [[ \$ # -gt 0 ]]; do
2784+ case "\$ 1" in
2785+ -u) ;;
2786+ -d) shift ;;
2787+ -r) epoch="\$ 2"; shift ;;
2788+ +*) fmt="\$ 1" ;;
2789+ esac
2790+ shift
2791+ done
2792+ [[ -n "\$ epoch" ]] && exec "$realdate " -u -d "@\$ {epoch}" "\$ fmt"
2793+ exec "$realdate " -u "\$ fmt"
2794+ FAKEDATE
2795+ chmod +x " ${fakebin} /date"
2796+ st_case ' utc_stamp answers a macOS-shaped date through -r, with the right instant' \
2797+ " $( PATH=" ${fakebin} :$PATH " ; utc_stamp 1787849472) " ' 2026-08-27T16:51:12Z'
2798+ st_case ' and that fake really is macOS-shaped — its own -d formats now, not the epoch' \
2799+ " $( PATH=" ${fakebin} :$PATH " ; date -u -d @0 ' +%Y' ) " " $( date -u ' +%Y' ) "
26262800 # A measurement apparatus that can redden a gate has become part of the thing
26272801 # it measures. This is the case that keeps it out of the way.
26282802 st_case ' an unwritable ledger loses records, never runs' \
0 commit comments