|
14 | 14 | # block each, and a surface the project does not have is not created. Added 2026-09-20 |
15 | 15 | # after an eval session read AGENTS.md/CLAUDE.md/PROJECT.md, never opened CLAUDE.local.md, |
16 | 16 | # and so never saw the company brain at all (retrieval 2/3 → 3/3 once this was fixed). |
| 17 | +# T2c a re-point under BSD-awk rules (no newline in -v, as macOS awk) still rewrites in place, |
| 18 | +# and a rewrite that fails prints FAILED, not Updated, leaves the file alone and is not |
| 19 | +# counted (#598) |
17 | 20 | # T3 wire refuses an unshaped folder; wire on a project without CLAUDE.local.md refuses |
18 | 21 | # T4 check-no-private-citations: positive control (planted pointer) exits 1, clean tree exits 0, |
19 | 22 | # the toolkit's own templates/company-brain/ path is not a hit |
@@ -62,6 +65,38 @@ r=$(grep -c "^$P " "$B/projects.tsv"); [ "$r" -eq 1 ] && ok "re-wire: still regi |
62 | 65 | B2="$WORK/acme-brain-2"; "$INIT" "$B2" >/dev/null 2>&1; "$BIN/wire-company-brain.sh" "$P" "$B2" >/dev/null 2>&1 |
63 | 66 | grep -qF "$B2/ROUTING.md" "$CL" && ! grep -qF "$B/ROUTING.md" "$CL" && ok "re-point rewrites in place" || bad "re-point left the old path" |
64 | 67 |
|
| 68 | +echo "== T2c: re-point under BSD-awk rules; a failed rewrite never says Updated (#598) ==" |
| 69 | +# macOS awk (one-true-awk 20200816) refuses a newline in a -v value ("newline in string"); gawk |
| 70 | +# and mawk accept it, so the re-point above passes on Linux whatever the script does. This stub |
| 71 | +# enforces the BSD rule and otherwise hands over to the real awk. |
| 72 | +REAL_AWK="$(command -v awk)"; SB="$WORK/bsd-awk"; mkdir -p "$SB" |
| 73 | +cat > "$SB/awk" <<STUB |
| 74 | +#!/usr/bin/env bash |
| 75 | +prev="" |
| 76 | +for a in "\$@"; do |
| 77 | + if [ "\$prev" = "-v" ]; then case "\$a" in *\$'\n'*) echo "awk: newline in string" >&2; exit 2;; esac; fi |
| 78 | + prev="\$a" |
| 79 | +done |
| 80 | +exec "$REAL_AWK" "\$@" |
| 81 | +STUB |
| 82 | +chmod +x "$SB/awk" |
| 83 | +B3="$WORK/acme-brain-3"; "$INIT" "$B3" >/dev/null 2>&1 |
| 84 | +out=$(PATH="$SB:$PATH" "$BIN/wire-company-brain.sh" "$P" "$B3" 2>&1) |
| 85 | +grep -qF "$B3/ROUTING.md" "$CL" && ! grep -qF "$B2/ROUTING.md" "$CL" \ |
| 86 | + && ok "re-point under BSD-awk rules rewrites in place" || bad "re-point under BSD-awk rules left the old path: $out" |
| 87 | +# A rewrite that fails must not report success, and must leave the file and the count alone. |
| 88 | +cat > "$SB/awk" <<'STUB' |
| 89 | +#!/usr/bin/env bash |
| 90 | +echo "awk: simulated failure" >&2; exit 2 |
| 91 | +STUB |
| 92 | +chmod +x "$SB/awk" |
| 93 | +before=$(cksum < "$CL") |
| 94 | +out=$(PATH="$SB:$PATH" "$BIN/wire-company-brain.sh" "$P" "$B" 2>&1) |
| 95 | +echo "$out" | grep -q "^Updated: CLAUDE.local.md" && bad "failed rewrite still printed Updated: $out" || ok "failed rewrite does not print Updated" |
| 96 | +echo "$out" | grep -q "^FAILED: CLAUDE.local.md" && ok "failed rewrite is reported as FAILED" || bad "no FAILED line: $out" |
| 97 | +[ "$(cksum < "$CL")" = "$before" ] && ok "failed rewrite leaves the file unchanged" || bad "file changed after a failed rewrite" |
| 98 | +echo "$out" | grep -q "written to 0 instruction surface" && ok "failed surface is not counted" || bad "count wrong: $(echo "$out" | grep 'written to')" |
| 99 | + |
65 | 100 | echo "== T2b: the pointer reaches every instruction surface that exists ==" |
66 | 101 | M="$WORK/multi"; mkdir -p "$M" |
67 | 102 | "$BIN/init-project.sh" "$M" --ignore-sources >/dev/null 2>&1 |
|
0 commit comments