fix(board): track an open HTML comment through to its closer

Skipping lines that START with the comment opener is not the same as
skipping a comment. Every continuation line of a wrapped comment under
the NESTE heading still looked like prose, so the excerpt became comment
internals instead of the next step. Both the board line and the route
line wrap easily; measured, 1 of 28 repos was affected, with the symptom
held down only by the convention of keeping those comments one-line.

An open comment is now tracked to its closer, and a NESTE block that is
nothing but a comment reports an empty block rather than promoting the
comment's own text.

Two limits are the format, not leftovers: an HTML comment body may not
contain the closer at all, so a rationale quoting it still ends its own
comment early.

The fixture is the real shape - one-line, wrapped, one-line, prose -
because a lone wrapped comment passes even with a flag that never
resets, and the continuation marker sits at the start of its line
because the table's 38-char cut would otherwise truncate it away and
the check would pass against the broken code too.

board-selftest 138 -> 142.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014K262DRWBJzEpWoMsBjB8J
This commit is contained in:
Kjell Tore Guttormsen 2026-08-03 09:53:25 +02:00
commit 123d40e4b4
10 changed files with 96 additions and 10 deletions

View file

@ -366,6 +366,55 @@ check "NESTE marker anchored to heading, not any content line mentioning it" $?
printf '%s' "$NESTE_OUT" | grep -qE 'repo-neste-lookalike.*tilfeldig linje'
[ $? -ne 0 ]; check "content line mentioning NESTE is not mistaken for the marker" $?
# A MULTI-LINE HTML comment under NESTE must be skipped THROUGH TO ITS CLOSER,
# not just on its opening line. Skipping only lines that START with the opener
# leaves every continuation line looking like prose, so the excerpt becomes
# comment internals - measured on the real tree, this repo was 1 of 28 affected
# and held the symptom down by keeping its comments one-line.
# The fixture is the REAL shape deliberately: one-line, multi-line, one-line,
# prose. A lone multi-line comment would prove enter-and-exit but not that the
# open-comment flag RESETS - a flag stuck on would still pass that weaker
# fixture by falling through to the same prose.
# NOTE: an HTML comment body cannot contain '-->' at all (that is the format,
# not a board.sh limit), so a rationale that quotes the closer still ends the
# comment early. That constraint survives this fix by construction.
mkrepo "$ROOT/repo-multiline-comment"
{
echo "# STATE - repo-multiline-comment"
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- board: status=planned; blocked-on=-; next-cost=Opus 5/high -->"
# The marker sits at the START of the continuation line on purpose: the table
# cuts the excerpt at 38 characters, so a marker further in would be truncated
# away and the check would pass against the BROKEN code too.
echo "<!-- route: path=known; verification=strong; reversibility=cheap;"
echo " FORTSETTELSESLINJE som ikke er noe neste steg;"
echo " scope=local; rationale=brer seg over flere linjer. -->"
echo "<!-- route-last: model=Opus 5; effort=high; completed=yes -->"
echo "Det ekte neste steget staar under kommentarblokken."
} > "$ROOT/repo-multiline-comment/STATE.md"
ML_OUT="$("$BOARD" --roots "$ROOT" 2>/dev/null)"
printf '%s' "$ML_OUT" | grep -qE 'repo-multiline-comment.*ekte neste steget'
check "multi-line HTML comment skipped through to its closer" $?
printf '%s' "$ML_OUT" | grep -q 'FORTSETTELSESLINJE'
[ $? -ne 0 ]; check "comment continuation line never becomes the NESTE excerpt" $?
# The board line still parses: it is read by its own anchored grep, so the
# excerpt fix must not disturb it.
printf '%s' "$ML_OUT" | grep -qE 'repo-multiline-comment.*planned'
check "board line still parsed alongside a wrapped route comment" $?
# A NESTE block that is NOTHING BUT a multi-line comment has no next step, and
# must say so rather than promote comment internals to the excerpt.
mkrepo "$ROOT/repo-comment-only"
{
echo "# STATE - repo-comment-only"
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
echo "<!-- route: path=known; verification=strong;"
echo " scope=local; rationale=BARE EN KOMMENTAR her. -->"
} > "$ROOT/repo-comment-only/STATE.md"
CO_OUT="$("$BOARD" --roots "$ROOT" 2>/dev/null)"
printf '%s' "$CO_OUT" | grep -qE 'repo-comment-only.*tom NESTE-blokk'
check "NESTE block of only a multi-line comment reports an empty block" $?
"$BOARD" --help >/dev/null 2>&1; check "--help exits 0" $?
# Unreadable root is a no-op, not a crash.