fix(board): cut the rationale before extracting route traits, not after

route_cmd_for()'s four extractions searched the WHOLE route line with a
greedy `.*trait=`, so a rationale that names a trait won the match over the
field itself. route.sh --help asks for a rationale per score, so a real
rationale names the traits routinely - this is the ordinary shape of the
data, not an edge case. route.sh then correctly refused the prose, --plan
printed command_missing=, and the operator read a broken PARSER as "that
repo has no route line": Verifiseringsloven ansikt 4 aimed at our own tooling.

Measured by .claude on four live STATE.md files before the order was written,
then re-measured here rather than quoted: A/B-ing the pre-fix script against
this one over the real tree at the same moment gives 25 tabs, command_missing
7 -> 2, and the five repos that gained a command (app-creator, catalog,
claude-code-llm-wiki, llm-security-commons, portfolio-optimiser-commons) are
exactly the five the order named. The two that remain are real and belong to
their own repos: okr writes scope=multi-module, outside the vocabulary, and
llm-security has no route line at all.

The cut keys on the FIRST `rationale=`, not on `; rationale=`: everything from
that token on is free text by definition, and the separator form would miss a
line written without the space. F4's [^;>]* class is untouched - the two answer
different questions and neither replaces the other.

The board line needs no equivalent change, and that was measured rather than
assumed: `grep -n 's/\.\*' scripts/board.sh` is the denominator, and the board
line's grammar carries no free-text field.

Selftest section 23 (7 checks, 252 -> 259) pins both failure directions,
including the sharp inverse where the FIELD is invalid (known2) while the
rationale holds a VALID value - before the fix that emitted a confident
command= built on prose the STATE line never declared. Two known-positive
controls prove the cut does not break the path that already worked.

Closes order 20260820T204409Z-8157821110-from-.claude

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AZa4oEsa93ac6pZQFEXqBF
This commit is contained in:
Kjell Tore Guttormsen 2026-08-20 23:06:09 +02:00
commit b70786db46
3 changed files with 174 additions and 6 deletions

View file

@ -593,13 +593,32 @@ route_cmd_for() {
# instead of the refusal this defect (F4) exists to force. route.sh still
# does the real rejection; this only stops the value from being mangled
# into something valid before it gets there.
rc_p="$(printf '%s' "$rc_line" | sed -n 's/.*path=\([^;>]*\).*/\1/p' \
# ...and it is applied to the line with the RATIONALE CUT OFF, not the raw
# line. `.*path=` is greedy, so it matches the LAST `path=` on the line - and
# route.sh --help asks for a rationale per score, so a real rationale names
# the traits routinely. Measured on four live STATE.md files (order
# 20260820T204409Z): catalog's `path` read "known: notatet som skal
# skrives...", app-creator's read "known. Ingen maskin sjekker...". route.sh
# then correctly refuses the prose, the plan says command_missing=, and the
# operator reads a broken PARSER as "that repo has no route line" -
# Verifiseringsloven ansikt 4 aimed at our own tooling. Re-measured here by
# A/B-ing the pre-fix script against this one over the real tree at the same
# moment: 25 tabs, command_missing 7 -> 2, and the five that gained a command
# are exactly the five the order named.
# The cut is at the FIRST `rationale=`, not at `; rationale=`: everything
# from that token on is free text by definition, and keying on the separator
# would miss a line written without the space. A route line that put a trait
# AFTER the rationale would lose it and degrade to command_missing= - the
# safe direction, since the alternative is a confident command built on
# prose, which is what this fixes.
rc_fields="$(printf '%s' "$rc_line" | sed 's/rationale=.*//')"
rc_p="$(printf '%s' "$rc_fields" | sed -n 's/.*path=\([^;>]*\).*/\1/p' \
| sed -e 's/--$//' -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')"
rc_v="$(printf '%s' "$rc_line" | sed -n 's/.*verification=\([^;>]*\).*/\1/p' \
rc_v="$(printf '%s' "$rc_fields" | sed -n 's/.*verification=\([^;>]*\).*/\1/p' \
| sed -e 's/--$//' -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')"
rc_r="$(printf '%s' "$rc_line" | sed -n 's/.*reversibility=\([^;>]*\).*/\1/p' \
rc_r="$(printf '%s' "$rc_fields" | sed -n 's/.*reversibility=\([^;>]*\).*/\1/p' \
| sed -e 's/--$//' -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')"
rc_s="$(printf '%s' "$rc_line" | sed -n 's/.*scope=\([^;>]*\).*/\1/p' \
rc_s="$(printf '%s' "$rc_fields" | sed -n 's/.*scope=\([^;>]*\).*/\1/p' \
| sed -e 's/--$//' -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')"
bash "$ROUTE" --path "$rc_p" --verification "$rc_v" \
--reversibility "$rc_r" --scope "$rc_s" --rationale brief 2>/dev/null \