fix(board): a missing coord-count.sh sibling warns instead of lying

Review finding 1 (docs/2026-08-14-confident-zero-review.md), tier 1 #2,
prioritized by .claude 2026-08-14T21:24:16Z coord message.

board.sh:381,395,409,516-517 gated four coord-count.sh invocations on
`[ -f "$SELFDIR/coord-count.sh" ]` and silently continued with empty
lookups when it failed - the 0.12.1 deployed-copy incident shape, a real
deployment state, not hypothetical. Reproduced exactly as the review
measured it (copy board.sh + route.sh to a scratch dir without
coord-count.sh, fixture mailbox with one reply-owing message): --brief
claimed "Ingen repo skylder noen et svar i dag." and then actively
mislabeled the reply-owing repo as "bare FYI-post" - a false statement,
not merely an absent one, since inbox>0/owed==0 looks identical whether
owed is genuinely 0 or simply uncomputed. --inbox-plan silently rendered
0 blocks instead of 1.

Fixed by computing HAVE_COUNT once and checking it everywhere a missing
sibling would otherwise read as "checked, found nothing": brief() no
longer enters the zero-debt/FYI-mislabel branch when the sibling is
missing, printing a warning instead; brief_orphans() and
brief_deadletters() warn instead of silently returning nothing (the
review's "dead-letter and orphan cross-checks vanish silently too");
plan() and inbox_plan() emit a key=value `advarsel=` line (not a '#'
comment - the driver consumer drops comment lines by rule, same
reasoning as the existing fokus= disclosure). plan()'s `keep` membership
logic is deliberately untouched: changing which repos appear in --plan
under this condition is a policy change to a format with a second
consumer in another repo that no test here can hold stable, and is a
proposal for the operator, not this fix.

Verified red before fixing: the reviewer's exact reproduction against
`git show HEAD:scripts/board.sh` (pre-fix) confirmed the mislabel and
the silent 0-block --inbox-plan, so the new board-selftest.sh section 17
fixture is red for the right reason, not by accident. Smoke-tested
against the real ~/repos tree (coord-count.sh present, HAVE_COUNT=1):
unchanged output, no warning.

All four selftest suites green: coord 200/200, board 183/183 (5 new
checks in section 17), route 69/69, guard 21/21.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F1mzsaUmjqFHArbArG7EpF
This commit is contained in:
Kjell Tore Guttormsen 2026-08-14 23:53:31 +02:00
commit 87194fe574
2 changed files with 104 additions and 6 deletions

View file

@ -1532,6 +1532,61 @@ check "a mailbox WITH .origin is never flagged, regardless of message age" $?
/bin/rm -rf "$DL_ROOT" "$DL_COORD" 2>/dev/null
# --- 17. Missing coord-count.sh sibling never reads as "checked, zero debt" -
# Review finding 1 (2026-08-14), reproduced exactly as measured: copy board.sh
# + route.sh to a scratch dir WITHOUT coord-count.sh (the 0.12.1 deployed-copy
# incident shape), point it at a fixture mailbox where one repo holds a
# reply-owing message. Before the fix, the copy's --brief claimed "Ingen repo
# skylder noen et svar i dag." and then actively mislabeled the reply-owing
# repo as "bare FYI-post" - a false statement, not merely an absent one - and
# --inbox-plan silently rendered 0 blocks instead of 1. This section pins the
# fix's actual claim: a warning, never a confident zero or a mislabel.
SIB_ROOT="$(mktemp -d)"
SIB_COORD="$(mktemp -d)"
SIB_SCRATCH="$(mktemp -d)"
cp "$DIR/board.sh" "$SIB_SCRATCH/board.sh"
cp "$DIR/route.sh" "$SIB_SCRATCH/route.sh"
chmod +x "$SIB_SCRATCH/board.sh" "$SIB_SCRATCH/route.sh"
# coord-count.sh deliberately not copied here.
mkrepo "$SIB_ROOT/repo-a"
{
echo "# STATE - repo-a"
echo ""
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=in-progress; blocked-on=-; next-cost=sonnet/high -->"
echo "Noe a gjore."
} > "$SIB_ROOT/repo-a/STATE.md"
mkdir -p "$SIB_COORD/repo-a/inbox"
cat > "$SIB_COORD/repo-a/inbox/20260101T000000Z-1-from-somebody.md" <<'EOF'
---
from: somebody
to: repo-a
subject: needs an answer
date: 2026-01-01T00:00:00Z
reply-expected: yes
---
Please respond.
EOF
SIBBRIEF="$(CLAUDE_COORD_DIR="$SIB_COORD" "$SIB_SCRATCH/board.sh" --roots "$SIB_ROOT" --brief 2>/dev/null)"
printf '%s' "$SIBBRIEF" | grep -qi 'bare FYI-post'; [ $? -ne 0 ]
check "missing sibling: --brief never mislabels a reply-owing repo as FYI-only" $?
printf '%s' "$SIBBRIEF" | grep -qi 'coord-count.sh mangler'
check "missing sibling: --brief surfaces a warning instead of a confident zero" $?
printf '%s' "$SIBBRIEF" | grep -qi '^Ingen repo skylder noen et svar i dag\.$'; [ $? -ne 0 ]
check "missing sibling: --brief does not print the debt-free claim it could not verify" $?
SIBPLAN="$(CLAUDE_COORD_DIR="$SIB_COORD" "$SIB_SCRATCH/board.sh" --roots "$SIB_ROOT" --plan 2>/dev/null)"
printf '%s' "$SIBPLAN" | grep -q '^advarsel=coord-count.sh mangler'
check "missing sibling: --plan carries a machine-readable warning key" $?
SIBIP="$(CLAUDE_COORD_DIR="$SIB_COORD" "$SIB_SCRATCH/board.sh" --roots "$SIB_ROOT" --inbox-plan 2>/dev/null)"
printf '%s' "$SIBIP" | grep -q '^advarsel=coord-count.sh mangler'
check "missing sibling: --inbox-plan carries a machine-readable warning key, not a silent 0 blocks" $?
/bin/rm -rf "$SIB_ROOT" "$SIB_COORD" "$SIB_SCRATCH" 2>/dev/null
echo ""
echo "board-selftest: $PASS passed, $FAIL failed"
[ "$FAIL" -eq 0 ] || exit 1