fix(orders): a pending order's age comes from the filename, not the mtime
`coord-order-done --return` rewrites the order file's mtime, and both age surfaces read mtime, so putting an order back reset the very reading that says how long it has waited. An order returned three times could never look old - on the one surface that exists precisely so a repo nobody opens still shows something. Found by reading the board right after this repo returned an order of its own, not by looking for it: a file whose name says 2026-09-02 rendered `ORDRE 1:0d` and `pending, 0d old` minutes later. Verified live after the fix: the same order now reads 1d. Two questions, two sources, and only one of them moved. A PENDING order's age is "how long has this sat with no owner" = now - delivery time, which only the filename carries and nothing rewrites. A CLAIMED order's age is "how long has it been in flight", which is the claim's own mtime and was already right. So oldest_pending_age() sits BESIDE oldest_order_age(), and pending_age_of() beside age_of() - switching FLY to the filename would answer the delivery question in the column that asks the flight question. An unparseable filename yields "?" for the whole reading, never a fabricated 0, because an unmeasured order could be the oldest one. TDD, red first: orders-selftest section 11 (110 -> 116) and board-selftest section 30 (360 -> 368), each asserting its own ground truth before anything depends on it, with controls that a freshly delivered order still reads 0d and that FLY did not move. Mutation-verified in both files: restoring the mtime read turns exactly the defect checks red and leaves every control green. Section 28's fixtures were rewritten as part of this rather than incidentally: they encoded their ages in `touch -t` while their filenames held fixed 2026-01/2026-08 dates, which a filename-based reading makes both wrong and time-dependent. They now compute their stems from `date -v` and the section asserts two ground truths, the filename for ORDRE and the mtime for FLY. Order 20260903T185736Z-1290610855 (.claude). Version 0.32.1 across all seven files; no catalog change in this session. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
a2019d44f7
commit
5316688844
13 changed files with 332 additions and 24 deletions
|
|
@ -408,6 +408,69 @@ CLAUDE_COORD_DIR="$O10DIR" "$SEND" --to .profile --from tester --subject s --mes
|
|||
check "10d: control - a dot-prefixed target name still receives its order" $?
|
||||
/bin/rm -rf "$O10DIR" 2>/dev/null
|
||||
|
||||
# --- 11. Pending age comes from the FILENAME, never the mtime ---------------
|
||||
# ORDRE 20260903T185736Z-1290610855: `--return` rewrites the order file's
|
||||
# mtime, and both age surfaces read mtime, so an order returned three times can
|
||||
# never read as old. Measured on the live queue before the order was written: a
|
||||
# file whose name says 2026-09-02 reported "0d old" minutes after a return.
|
||||
#
|
||||
# PM decision, and it is two questions with two answers: a PENDING order's age
|
||||
# is "how long has this sat with no owner" = now - the DELIVERY time, which only
|
||||
# the filename carries; a CLAIMED order's age is "how long has it been in
|
||||
# flight" = the claim marker's mtime, which is already right and stays.
|
||||
O11DIR="$WORK/o11"; mkdir -p "$O11DIR"
|
||||
o11_old_ts="$(date -u -v-2d +%Y%m%dT%H%M%SZ 2>/dev/null)"
|
||||
CLAUDE_COORD_DIR="$O11DIR" "$SEND" --to o11repo --from dispatcher \
|
||||
--subject "aged order" --message "body" >/dev/null 2>&1
|
||||
o11_q="$O11DIR/o11repo/orders"
|
||||
o11_orig="$(ls -1 "$o11_q"/*.md 2>/dev/null | head -1)"
|
||||
o11_id="$(basename "$o11_orig" .md)"
|
||||
o11_aged_id="${o11_old_ts}-${o11_id#*-}"
|
||||
mv "$o11_orig" "$o11_q/$o11_aged_id.md" 2>/dev/null
|
||||
|
||||
# Ground truth FIRST, so a broken `date -v` fails here instead of turning the
|
||||
# whole section into a test of nothing (the F13 section-11 lesson).
|
||||
[ -n "$o11_old_ts" ] && [ -f "$o11_q/$o11_aged_id.md" ]
|
||||
check "11a: ground truth - the fixture order's filename timestamp is 2 days old" $?
|
||||
|
||||
# Drive the REAL defect: claim it, then return it. The return is what rewrites
|
||||
# the mtime, so this is the path that produced the live 0d reading.
|
||||
CLAUDE_COORD_DIR="$O11DIR" "$CLAIM" --repo o11repo "$o11_aged_id" >/dev/null 2>&1
|
||||
CLAUDE_COORD_DIR="$O11DIR" "$ODONE" --repo o11repo "$o11_aged_id" --return --reason "test" >/dev/null 2>&1
|
||||
o11_mtime="$(stat -f %m "$o11_q/$o11_aged_id.md" 2>/dev/null)"
|
||||
o11_now="$(date +%s)"
|
||||
[ -n "$o11_mtime" ] && [ $(( o11_now - o11_mtime )) -lt 300 ]
|
||||
check "11b: ground truth - the return really did rewrite the file's mtime to now" $?
|
||||
|
||||
o11_out="$(CLAUDE_COORD_DIR="$O11DIR" "$READ" --repo o11repo 2>/dev/null)"
|
||||
printf '%s' "$o11_out" | grep -q 'pending, 2d old'
|
||||
check "11c: a returned order reports its DELIVERY age (2d), not 0d" $?
|
||||
|
||||
# Known-positive control: the reading must still be able to say 0d, or 11c
|
||||
# would pass just as well against a function that always prints 2.
|
||||
CLAUDE_COORD_DIR="$O11DIR" "$SEND" --to o11fresh --from dispatcher \
|
||||
--subject "fresh order" --message "body" >/dev/null 2>&1
|
||||
o11_fresh="$(CLAUDE_COORD_DIR="$O11DIR" "$READ" --repo o11fresh 2>/dev/null)"
|
||||
printf '%s' "$o11_fresh" | grep -q 'pending, 0d old'
|
||||
check "11d: control - a freshly delivered order still reports 0d" $?
|
||||
|
||||
# FLY is the OTHER question and must not move: the claim marker's mtime is when
|
||||
# the claim happened, and an order with an ancient filename claimed just now has
|
||||
# been in flight for 0 days.
|
||||
CLAUDE_COORD_DIR="$O11DIR" "$CLAIM" --repo o11repo "$o11_aged_id" >/dev/null 2>&1
|
||||
o11_fly="$(CLAUDE_COORD_DIR="$O11DIR" "$READ" --repo o11repo 2>/dev/null)"
|
||||
printf '%s' "$o11_fly" | grep -q 'CLAIMED 0d ago'
|
||||
check "11e: FLY age still comes from the claim marker's mtime, not the filename" $?
|
||||
|
||||
# A name the grammar does not produce has no readable delivery time. It must
|
||||
# read "?" - the same fail-safe the mtime path already used, never a fabricated
|
||||
# 0, which would make an unmeasured order look brand new.
|
||||
mkdir -p "$O11DIR/o11bad/orders"
|
||||
printf -- '---\nfrom: x\nsubject: s\n---\nbody\n' > "$O11DIR/o11bad/orders/not-a-timestamp.md"
|
||||
o11_bad="$(CLAUDE_COORD_DIR="$O11DIR" "$READ" --repo o11bad 2>/dev/null)"
|
||||
printf '%s' "$o11_bad" | grep -q 'pending, ?d old'
|
||||
check "11f: an unparseable filename timestamp reads ?, never 0" $?
|
||||
|
||||
echo
|
||||
echo "orders-selftest: $PASS passed, $FAIL failed, $SKIP skipped (of $((PASS+FAIL+SKIP)) checks)"
|
||||
[ "$FAIL" -eq 0 ] || exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue