feat(board): nested repos enter on a STATE.md, and the scan reports its nevner

Order 20260903T190201Z-238406410-from-.claude (.claude, operator decision
2026-09-03). A git repo nested under a depth-1 REPO was invisible: discovery
adds a depth-1 repo and stops, and the else-branch container scan - the only
place children are ever looked at - is unreachable for an entry that is itself
a repo. Measured before writing anything: 12 nested repos across the real tree,
exactly 1 with a STATE.md (from-ai-to-chitta/content-sadhguru), which had been
running work and reporting to nobody.

Admission is criterion (a) and nothing wider. add_nested_repos() sits beside
add_dot_repos(), never a widening of the `*` loops - the same argument ordre
20260818T124828Z made for dot repos, and the order made it again before this
repo wrote a line: routing a depth-1 repo into the container branch would admit
every vendored clone under claude-code-100x/. One level only; depth 3 is pinned
as NOT admitted. A dot-prefixed depth-1 repo gets the same nested scan, since
nothing in the criterion distinguishes it.

A nested repo now carries TWO names. The board KEY is <parent>/<child> as the
order specifies. The MAILBOX name is not that key: a mailbox is addressed by
basename(git toplevel), so $COORD/<parent>/<child>/inbox finds no directory and
INN/ORDRE/FLY would print 0 for a repo that may have mail - a failed
measurement wearing the reassuring value, in three columns at once. The record
loop carries `mbox` beside `name`; --voyage's order lookup takes
basename($vy_dir) for the same reason. Which dirs are nested is RECORDED by
discovery (NESTED_LIST), not re-derived from "is my parent a repo?", which
would prefix every depth-1 repo if a scan root were ever a checkout.

The denominator line is independent of all of that and went in regardless:
"undersoekt: N katalog(er) depth 1, M polyrepo-container(e), K nestede repo
(J med STATE.md tatt med)". The header count answers how many were found and
nothing about how many were looked at, so a criterion excluding 11 of 12 was
invisible at the surface built to show it. Real tree 2026-09-04: 43 / 5 / 12
(1 tatt med). A non-repo dot-dir counts in N and never in M - it is a
denominator, not a partition.

Its wording broke an existing check: "polyrepo container itself is not listed
as a repo" grepped the whole output for `polyrepo` and matched the footer's own
`polyrepo-container(e)` - the same class as a grep reading a comment that
EXPLAINS a pattern as an instance of it. Now anchored at column 1, which is
what it always meant.

Verified with board.sh, not from memory: from-ai-to-chitta/content-sadhguru
in-progress, Sonnet 5/high, and --plan gives it a real tab with paste=.
Mutation-verified: reverting the eight $COORD/$mbox reads turns exactly the
three mailbox checks red with the rest of the section green.

Bounded gaps, stated rather than closed: the mailbox-keyed JOINS ($OWED,
brief_orphans, --inbox-plan) still key on the board name - neither created nor
worsened here, since the repo was previously absent from RECORDS entirely; a
34-char key overflows the table's %-32s REPO column (same class as Fable
5.1/xhigh in KOST, and widening moves three cut -c89- helpers); a dot-prefixed
NESTED repo is not looked for.

board-selftest 368 -> 393. Suites: coord 257, board 393, route 73, orders 116,
guard 54 = 893. npm test 11/11.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-04 21:35:55 +02:00
commit cde185979c
10 changed files with 428 additions and 23 deletions

View file

@ -355,7 +355,13 @@ printf '%s' "$OUT" | grep -q 'repo-a'; check "discovers top-level git repo" $?
printf '%s' "$OUT" | grep -q 'plug-x'; check "discovers nested polyrepo git repo (depth 2)" $?
printf '%s' "$OUT" | grep -q 'repo-c'; check "lists git repo without STATE.md" $?
printf '%s' "$OUT" | grep -q 'plain-dir'; [ $? -ne 0 ]; check "ignores non-git directory tree" $?
printf '%s' "$OUT" | grep -q 'polyrepo'; [ $? -ne 0 ]; check "polyrepo container itself is not listed as a repo" $?
# Anchored at column 1, and the anchor is load-bearing: the claim is "the
# container has no ROW", and a row starts with the repo name. Unanchored, this
# check now matches the denominator line's own word "polyrepo-container(e)" -
# the same defect class as a file-wide grep reading a comment that EXPLAINS a
# pattern as an instance of it (coord-selftest section 38's cache assertion,
# and the done-guard's rule that prose saying status=done must not trigger it).
printf '%s' "$OUT" | grep -q '^polyrepo'; [ $? -ne 0 ]; check "polyrepo container itself is not listed as a repo" $?
# Guard the fixture itself: if git ever stops writing a .git FILE for
# worktrees, the next two checks would pass for the wrong reason.
[ -f "$ROOT/wt-feature/.git" ]; check "fixture: worktree .git is a FILE, not a dir" $?
@ -3044,6 +3050,208 @@ PAOUT2="$(CLAUDE_COORD_DIR="$PACOORD" "$BOARD" --roots "$PAROOT" 2>/dev/null)"
check "pendingage: an unparseable filename reads ?, never a fabricated 0" $?
/bin/rm -rf "$PAROOT" "$PACOORD" 2>/dev/null
# --- 31. Nested git repos with a STATE.md (admission a) ---------------------
# Operator decision 2026-09-03, order 20260903T190201Z-238406410-from-.claude:
# a git repo nested at depth 2 UNDER a directory that is itself a git repo
# (claude-code-100x/*, from-ai-to-chitta/*) was invisible to the board - the
# discovery loop adds a depth-1 repo and never looks inside it, and the
# else-branch container scan is reached only when the depth-1 entry is NOT a
# repo. Admission is criterion (a) and nothing wider: such a repo enters the
# board ONLY when it carries a STATE.md. A nested repo without one stays
# invisible ON PURPOSE - it does not even reach the UTEN STATE.md bucket,
# because that bucket is for repos the operator opens, and these are vendored
# or experimental checkouts nobody has declared a next step for. Measured on
# the real tree the day the order was written: 12 nested repos, exactly 1 with
# a STATE.md (from-ai-to-chitta/content-sadhguru).
#
# A dedicated add_nested_repos() beside add_dot_repos(), never a widening of
# the `*` loops: the same argument ordre 20260818T124828Z made for dot repos.
# Turning the depth-1 repo branch into a container scan would admit every
# nested checkout, which is precisely what criterion (a) declines.
NEST_ROOT="$(mktemp -d)"
NEST_COORD="$(mktemp -d)"
mk_nest_state() {
{
echo "# STATE - $2"
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=$3; blocked-on=-; next-cost=Sonnet 5/high -->"
echo "Next step for $2."
} > "$1/STATE.md"
}
# A depth-1 repo holding THREE nested repos, exactly one with a STATE.md.
mkrepo "$NEST_ROOT/parent-repo"
mk_nest_state "$NEST_ROOT/parent-repo" parent-repo in-progress
mkrepo "$NEST_ROOT/parent-repo/nest-with-state"
mk_nest_state "$NEST_ROOT/parent-repo/nest-with-state" nest-with-state planned
mkrepo "$NEST_ROOT/parent-repo/nest-no-state-1"
mkrepo "$NEST_ROOT/parent-repo/nest-no-state-2"
# Known-positive control: an ordinary depth-1 repo must still be found, so a
# green section cannot come from a fix that broke the case that already worked.
mkrepo "$NEST_ROOT/plain-repo"
mk_nest_state "$NEST_ROOT/plain-repo" plain-repo planned
# Known-negative control: a depth-1 repo whose nested repos carry NO STATE.md
# must contribute exactly zero extra rows.
mkrepo "$NEST_ROOT/barren-parent"
mk_nest_state "$NEST_ROOT/barren-parent" barren-parent done
mkrepo "$NEST_ROOT/barren-parent/nest-barren"
NEST_OUT="$(CLAUDE_COORD_DIR="$NEST_COORD" "$BOARD" --roots "$NEST_ROOT" 2>/dev/null)"
# Ground truth for the fixture itself, before anything depends on it: the
# nested checkout really is a git repo and really does carry a STATE.md.
[ -e "$NEST_ROOT/parent-repo/nest-with-state/.git" ] && \
[ -f "$NEST_ROOT/parent-repo/nest-with-state/STATE.md" ]
check "nested: ground truth - the fixture nested repo has .git AND STATE.md" $?
[ -e "$NEST_ROOT/parent-repo/nest-no-state-1/.git" ] && \
[ ! -f "$NEST_ROOT/parent-repo/nest-no-state-1/STATE.md" ]
check "nested: ground truth - the excluded fixture has .git and NO STATE.md" $?
printf '%s' "$NEST_OUT" | grep -q 'parent-repo/nest-with-state'
check "nested: a nested repo with STATE.md is on the board, keyed <parent>/<child>" $?
printf '%s' "$NEST_OUT" | grep -q 'nest-no-state-1'; [ $? -ne 0 ]
check "nested: a nested repo WITHOUT STATE.md stays invisible (criterion a)" $?
printf '%s' "$NEST_OUT" | grep -q 'nest-no-state-2'; [ $? -ne 0 ]
check "nested: the second STATE-less nested repo is invisible too" $?
printf '%s' "$NEST_OUT" | grep -q 'nest-barren'; [ $? -ne 0 ]
check "nested: known-negative - a parent with no STATE-carrying child adds 0 rows" $?
printf '%s' "$NEST_OUT" | grep -q '^plain-repo '
check "nested: known-positive - the ordinary depth-1 repo is still found" $?
printf '%s' "$NEST_OUT" | grep -q '(4 repo'
check "nested: exactly one row is added (4 = parent + plain + barren + nested)" $?
# The nested row is a repo like any other: its status comes from its OWN
# STATE.md, not the parent's.
printf '%s' "$NEST_OUT" | grep '^parent-repo/nest-with-state ' | grep -q 'planned'
check "nested: the nested row reads its own STATE.md board line" $?
printf '%s' "$NEST_OUT" | grep '^parent-repo ' | grep -q 'in-progress'
check "nested: the parent keeps its own status (known-positive)" $?
# The display key is <parent>/<child>; the MAILBOX name is not. A mailbox is
# addressed by basename(git toplevel) - coord-send.sh's own rule - so a repo
# named parent-repo/nest-with-state on the board still counts its mail under
# <coord>/nest-with-state. Reading the compound name against $COORD would find
# no directory and print INN 0, which is a failed measurement wearing the
# reassuring value - the one thing this file refuses everywhere.
mkdir -p "$NEST_COORD/nest-with-state/inbox" "$NEST_COORD/nest-with-state/orders/claimed"
: > "$NEST_COORD/nest-with-state/inbox/20260101T000000Z-1-from-x.md"
: > "$NEST_COORD/nest-with-state/inbox/20260101T000000Z-2-from-x.md"
: > "$NEST_COORD/nest-with-state/orders/$(date -u +%Y%m%dT%H%M%SZ)-3-from-x.md"
: > "$NEST_COORD/nest-with-state/orders/claimed/20260101T000000Z-4-from-x.md"
NEST_OUT2="$(CLAUDE_COORD_DIR="$NEST_COORD" "$BOARD" --roots "$NEST_ROOT" 2>/dev/null)"
nest_cells="$(printf '%s' "$NEST_OUT2" | grep '^parent-repo/nest-with-state ' | cut -c89-)"
# Exact values, never "not 0": before the fix the row did not exist at all, so
# `awk '{print $1}'` on an empty string is "" - which is not "0" and would have
# passed these two checks while measuring nothing. That is state-line-guard
# section 11's vacuously-green defect, and it was observed here on the red run.
[ -n "$nest_cells" ]
check "nested: ground truth - the nested row exists before its cells are read" $?
# A today-stamped filename, because a PENDING order's age is read from the
# FILENAME, not the mtime (0.32.1) - a fixed 2026-01 stem would date this cell
# to whenever the suite happens to run.
[ "$(printf '%s' "$nest_cells" | awk '{print $1}')" = "1:0d" ]
check "nested: ORDRE is counted under the mailbox BASENAME, not the compound key" $?
[ "$(printf '%s' "$nest_cells" | awk '{print $2}')" = "1:0d" ]
check "nested: FLY likewise reads <coord>/<basename>" $?
printf '%s' "$NEST_OUT2" | grep '^parent-repo/nest-with-state ' | grep -q ' 2 '
check "nested: INN reads the basename mailbox, never a fabricated 0" $?
# Depth 3 is NOT admitted: the order says depth 2 under a depth-1 repo, and a
# repo nested inside a nested repo is a checkout of a checkout. Widening was
# not ordered, and an unmeasured widening is the defect ordre 20260818 flagged.
mkrepo "$NEST_ROOT/parent-repo/nest-with-state/deeper"
mk_nest_state "$NEST_ROOT/parent-repo/nest-with-state/deeper" deeper planned
NEST_OUT3="$(CLAUDE_COORD_DIR="$NEST_COORD" "$BOARD" --roots "$NEST_ROOT" 2>/dev/null)"
printf '%s' "$NEST_OUT3" | grep -q 'deeper'; [ $? -ne 0 ]
check "nested: depth 3 is not admitted (one level under a depth-1 repo only)" $?
/bin/rm -rf "$NEST_ROOT/parent-repo/nest-with-state/deeper"
# A polyrepo container's children are UNCHANGED - their parent is not a repo,
# so they keep their bare basename and never grow a <parent>/ prefix.
mkdir -p "$NEST_ROOT/container-dir"
mkrepo "$NEST_ROOT/container-dir/child-repo"
mk_nest_state "$NEST_ROOT/container-dir/child-repo" child-repo planned
NEST_OUT4="$(CLAUDE_COORD_DIR="$NEST_COORD" "$BOARD" --roots "$NEST_ROOT" 2>/dev/null)"
printf '%s' "$NEST_OUT4" | grep -q '^child-repo '
check "nested: a polyrepo container's child keeps its bare name (known-positive)" $?
printf '%s' "$NEST_OUT4" | grep -q 'container-dir/child-repo'; [ $? -ne 0 ]
check "nested: container children are NOT renamed to <parent>/<child>" $?
# Same rule under a dot-prefixed depth-1 repo: it is a depth-1 repo, so its
# STATE-carrying nested repo is admitted on exactly the same criterion. The
# asymmetry would otherwise be arbitrary - ordinary parents scanned, dot ones
# not - and nothing in the order distinguishes them.
mkrepo "$NEST_ROOT/.dotparent"
mk_nest_state "$NEST_ROOT/.dotparent" .dotparent planned
mkrepo "$NEST_ROOT/.dotparent/dotnest"
mk_nest_state "$NEST_ROOT/.dotparent/dotnest" dotnest planned
NEST_OUT5="$(CLAUDE_COORD_DIR="$NEST_COORD" "$BOARD" --roots "$NEST_ROOT" 2>/dev/null)"
printf '%s' "$NEST_OUT5" | grep -q '\.dotparent/dotnest'
check "nested: a dot-prefixed depth-1 repo's nested repo is admitted too" $?
/bin/rm -rf "$NEST_ROOT" "$NEST_COORD" 2>/dev/null
# --- 32. The scan reports its own denominator -------------------------------
# Independent of section 31 and required regardless (the order says so in as
# many words). Verifiseringsloven ansikt 4 applied to the board's own reading:
# a repo count alone answers "how many were found" and says nothing about how
# many directories were LOOKED AT, so a criterion that silently excludes 11 of
# 12 nested repos is invisible at the surface that is supposed to show it.
# The line names all four quantities, including the excluded ones.
DEN_ROOT="$(mktemp -d)"
DEN_COORD="$(mktemp -d)"
mk_den_state() {
{
echo "# STATE - $2"
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=planned; blocked-on=-; next-cost=Sonnet 5/high -->"
echo "Next step for $2."
} > "$1/STATE.md"
}
# Depth-1 directories: 4 (two repos, one polyrepo container, one plain dir).
mkrepo "$DEN_ROOT/d1-repo-a"
mk_den_state "$DEN_ROOT/d1-repo-a" d1-repo-a
mkrepo "$DEN_ROOT/d1-repo-b"
mk_den_state "$DEN_ROOT/d1-repo-b" d1-repo-b
mkdir -p "$DEN_ROOT/d1-container"
mkrepo "$DEN_ROOT/d1-container/contained"
mk_den_state "$DEN_ROOT/d1-container/contained" contained
mkdir -p "$DEN_ROOT/d1-emptydir"
# Nested repos: 3 under d1-repo-a, of which 2 carry a STATE.md.
mkrepo "$DEN_ROOT/d1-repo-a/n1"; mk_den_state "$DEN_ROOT/d1-repo-a/n1" n1
mkrepo "$DEN_ROOT/d1-repo-a/n2"; mk_den_state "$DEN_ROOT/d1-repo-a/n2" n2
mkrepo "$DEN_ROOT/d1-repo-a/n3"
DEN_OUT="$(CLAUDE_COORD_DIR="$DEN_COORD" "$BOARD" --roots "$DEN_ROOT" 2>/dev/null)"
DEN_LINE="$(printf '%s\n' "$DEN_OUT" | grep '^undersoekt:')"
[ -n "$DEN_LINE" ]
check "denominator: the board prints an 'undersoekt:' line" $?
printf '%s' "$DEN_LINE" | grep -q '4 katalog(er) depth 1'
check "denominator: depth-1 directory count matches the fixture (4)" $?
printf '%s' "$DEN_LINE" | grep -q '2 polyrepo-container(e)'
check "denominator: container count matches the fixture (2: one with a repo, one empty)" $?
printf '%s' "$DEN_LINE" | grep -q '3 nestede repo'
check "denominator: nested-repo count matches the fixture (3)" $?
printf '%s' "$DEN_LINE" | grep -q '2 med STATE.md tatt med'
check "denominator: admitted-nested count matches the fixture (2 of 3)" $?
# The line must be a real reading, not a constant: change the tree and it moves.
mkrepo "$DEN_ROOT/d1-repo-a/n4"; mk_den_state "$DEN_ROOT/d1-repo-a/n4" n4
DEN_OUT2="$(CLAUDE_COORD_DIR="$DEN_COORD" "$BOARD" --roots "$DEN_ROOT" 2>/dev/null)"
printf '%s\n' "$DEN_OUT2" | grep '^undersoekt:' | grep -q '4 nestede repo (3 med STATE.md tatt med)'
check "denominator: the counts follow the tree, they are not hardcoded" $?
# A root that does not exist contributes nothing and must not silently inflate
# the denominator - F10's rule, applied to the new counters.
DEN_OUT3="$(CLAUDE_COORD_DIR="$DEN_COORD" "$BOARD" --roots "$DEN_ROOT,/nonexistent-root-$$" 2>/dev/null)"
printf '%s\n' "$DEN_OUT3" | grep '^undersoekt:' | grep -q '4 katalog(er) depth 1'
check "denominator: a missing scan root adds nothing to the counts" $?
/bin/rm -rf "$DEN_ROOT" "$DEN_COORD" 2>/dev/null
echo ""
echo "board-selftest: $PASS passed, $FAIL failed"
[ "$FAIL" -eq 0 ] || exit 1