feat(coord,board): flag mailboxes no session has ever read (WP1d detection half)

coord-count.sh gains a fourth TSV column: "-" when a mailbox has .origin
(a real session has read it via SessionStart), otherwise the age in whole
days of the oldest pending message. .origin is only written by
coord-inbox.sh's non---repo path, so its absence means the mailbox is
never reached by normal injection — a genuine dead letter, not merely
slow. board.sh's --brief surfaces mailboxes past the 3-day threshold as
a new "ALDRI LEST" section, mirroring the existing orphan-mailbox
listing. This is WP1d's detection half only (per .claude's coord
bestilling 2026-08-14); the action half (report-to-sender / retract) is
unapproved design, not built here.

coord-selftest.sh: 191 -> 197 checks. board-selftest.sh: 175 -> 178
checks (net +3; section 16 adds 3 new fixtures on top of the existing
175 baseline, some pre-existing counts shift with the trailing column).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0194eV8b6BXNv6aKLovP8TP6
This commit is contained in:
Kjell Tore Guttormsen 2026-08-14 21:52:47 +02:00
commit 19c0c1010b
6 changed files with 211 additions and 18 deletions

View file

@ -1465,6 +1465,73 @@ check "--help documents --inbox-plan" $?
/bin/rm -rf "$IP_ROOT" "$IP_COORD" 2>/dev/null
# --- 16. Dead-letter flagging in --brief (.origin-age, coord-count.sh col 4) -
# WP1d (.claude, 2026-08-14): a census of the real mailbox found unhandled mail
# sitting in mailboxes no session has ever read - .origin is written only by
# coord-inbox.sh's real (non --repo) SessionStart path, so a mailbox lacking it
# is never reached by the normal injection at all. This is the detection half
# of WP1d only: coord-count.sh's fourth column reports the age in days of the
# OLDEST pending message when .origin is absent (coord-selftest.sh section 31);
# --brief surfaces mailboxes past the 3-day threshold as their own class,
# mirroring how it already surfaces orphan mailboxes with no matching repo.
# The action half (report to sender / retract) is unapproved design and is
# deliberately not built here.
DL_ROOT="$(mktemp -d)"
DL_COORD="$(mktemp -d)"
mkrepo "$DL_ROOT/dead-letter-repo"
{
echo "# STATE - dead-letter-repo"
echo ""
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=planned; blocked-on=-; next-cost=sonnet/high -->"
echo "Noe a gjore."
} > "$DL_ROOT/dead-letter-repo/STATE.md"
mkdir -p "$DL_COORD/dead-letter-repo/inbox"
cat > "$DL_COORD/dead-letter-repo/inbox/$(date -u -v-10d +%Y%m%dT%H%M%SZ)-1-from-somebody.md" <<'EOF'
---
from: somebody
to: dead-letter-repo
subject: rotting notice
date: 2026-08-01T00:00:00Z
reply-expected: no
---
Nobody has ever read this mailbox.
EOF
# A mailbox WITH .origin must never be flagged, no matter how old its mail is -
# .origin means a real session claims and reads it regularly.
mkrepo "$DL_ROOT/claimed-repo"
{
echo "# STATE - claimed-repo"
echo ""
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=planned; blocked-on=-; next-cost=sonnet/high -->"
echo "Noe annet."
} > "$DL_ROOT/claimed-repo/STATE.md"
mkdir -p "$DL_COORD/claimed-repo/inbox"
printf '%s\n' "/tmp/claimed-repo" > "$DL_COORD/claimed-repo/.origin"
cat > "$DL_COORD/claimed-repo/inbox/$(date -u -v-10d +%Y%m%dT%H%M%SZ)-1-from-somebody.md" <<'EOF'
---
from: somebody
to: claimed-repo
subject: old but claimed
date: 2026-08-01T00:00:00Z
reply-expected: no
---
This mailbox is claimed - never flagged.
EOF
DLBRIEF="$(CLAUDE_COORD_DIR="$DL_COORD" "$BOARD" --roots "$DL_ROOT" --brief 2>/dev/null)"
printf '%s' "$DLBRIEF" | grep -qi 'dead-letter-repo'
check "brief flags a mailbox with no .origin and mail older than the threshold" $?
printf '%s' "$DLBRIEF" | grep -qi 'aldri lest\|never read\|\.origin'
check "the flag names why the mailbox is flagged, not just its name" $?
printf '%s' "$DLBRIEF" | grep -A3 -i 'aldri lest' | grep -qi 'claimed-repo'; [ $? -ne 0 ]
check "a mailbox WITH .origin is never flagged, regardless of message age" $?
/bin/rm -rf "$DL_ROOT" "$DL_COORD" 2>/dev/null
echo ""
echo "board-selftest: $PASS passed, $FAIL failed"
[ "$FAIL" -eq 0 ] || exit 1