fix(board): FILENAME== the focus-filter join, matching the file's own rule
F12: a third NR==FNR survived at the focus-filter join in plan() (fp_names x pf), next to two comments that already state this file's rule -- never by NR==FNR. Measured before fixing: unlike the two prior instances, this join has no third file whose lookup table a misroute could corrupt, and FOCUS_SLUGS is provably a subset of what focus_slugs() finds in the same $RECORDS focus_declares() re-checks -- so fp_names cannot be empty while the filter applies, and even forced empty the old and new form produce identical output. No reachable defect to pin behaviourally; the fix closes the file's own stated invariant instead. Pinned structurally in selftest section 21: no live NR==FNR outside a comment, with a known-positive control proving the filter can still find one. board-selftest: 239/239 (was 237). coord/route/orders/guard unchanged and green (220/69/99/40), npm test 11/11. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YkJ1rKh5YNfVUr5UDKpfh
This commit is contained in:
parent
6b26b8e94b
commit
2928c28044
3 changed files with 62 additions and 2 deletions
|
|
@ -1905,6 +1905,37 @@ printf '%s' "$ORD_OUT" | grep -q 'summeres ALDRI'
|
|||
check "the legend states that INN and ORDRE are never summed" $?
|
||||
/bin/rm -rf "$ORD_ROOT" 2>/dev/null
|
||||
|
||||
# --- 21. board.sh contains no live NR==FNR (structural invariant) ----------
|
||||
# F12: a third NR==FNR survived at the focus-filter join in plan() (fp_names x
|
||||
# pf), next to two comments (1131-1138, 1294) that state the file's own rule -
|
||||
# "never by NR==FNR" - as prose. Measured before writing this section (not
|
||||
# assumed): for a plain two-file keep-set join with no third file whose lookup
|
||||
# table a misroute could corrupt, an empty fp_names produces the SAME output
|
||||
# (0 kept) under NR==FNR and under FILENAME== alike, because when fp_names is
|
||||
# genuinely empty (0 repos anywhere declare the resolved focus slug) 0 kept
|
||||
# IS the correct answer - unlike the two prior instances in this file, where
|
||||
# an empty first file silently dropped a lookup table (ub[]/ow[]) consumed by
|
||||
# a THIRD file. FOCUS_SLUGS is provably a subset of what focus_slugs() finds
|
||||
# in $RECORDS, and focus_declares() re-checks the identical regex against the
|
||||
# identical $RECORDS, so fp_names cannot be empty while fp_applied=1 in normal
|
||||
# use - there is no reachable, observable defect here to pin behaviourally,
|
||||
# and a --focus fixture asserting one would pass identically before and after
|
||||
# this fix (verified with a standalone awk run, both forms, both empty and
|
||||
# non-empty first files: identical output every time). The fix is therefore
|
||||
# structural, not behavioural: line 1195 is a live counter-example to a rule
|
||||
# this file states about itself, which is a trap for the next session that
|
||||
# greps NR==FNR expecting every hit to be a bug and finds one that works.
|
||||
grep -v '^[[:space:]]*#' "$BOARD" | grep -c 'NR==FNR' | grep -q '^0$'
|
||||
check "board.sh has no live NR==FNR outside comments (the file's own stated rule)" $?
|
||||
|
||||
# Known-positive control: without this, the check above could be finding
|
||||
# nothing because the filter is broken, not because the file is clean.
|
||||
NRFNR_FIXTURE="${TMPDIR:-/tmp}/board-nrfnr-fixture.$$"
|
||||
printf ' awk NR==FNR live code, not a comment\n' > "$NRFNR_FIXTURE"
|
||||
grep -v '^[[:space:]]*#' "$NRFNR_FIXTURE" | grep -q 'NR==FNR'
|
||||
check "the same filter+grep DOES find a live NR==FNR in a known-positive fixture" $?
|
||||
/bin/rm -f "$NRFNR_FIXTURE" 2>/dev/null
|
||||
|
||||
echo ""
|
||||
echo "board-selftest: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" -eq 0 ] || exit 1
|
||||
|
|
|
|||
|
|
@ -1192,7 +1192,7 @@ plan() {
|
|||
[ -n "$fp_d" ] && [ -f "$fp_d/STATE.md" ] || continue
|
||||
focus_declares "$fp_d" && printf '%s\n' "$fp_n"
|
||||
done > "$fp_names"
|
||||
awk -F'|' 'NR==FNR{keep[$0]=1;next} keep[$4]' "$fp_names" "$pf" > "$fp_kept"
|
||||
awk -F'|' -v NAMES="$fp_names" 'FILENAME==NAMES{keep[$0]=1;next} keep[$4]' "$fp_names" "$pf" > "$fp_kept"
|
||||
/bin/rm -f "$fp_names" 2>/dev/null
|
||||
mv "$fp_kept" "$pf"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue