@chrono-meta/fh-gate 3.30.0 → 3.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/CLAUDE.md +1 -1
  3. package/README.ja.md +6 -5
  4. package/README.ko.md +6 -5
  5. package/README.md +18 -5
  6. package/README.zh.md +6 -5
  7. package/docs/REFERENCE.md +6 -5
  8. package/docs/USER_GUIDE.md +3 -0
  9. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +50 -0
  10. package/knowledge/shared/harness-core/sonnet_floor_doctrine.md +7 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +84 -0
  12. package/package.json +5 -1
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/CHANGELOG.md +32 -0
  16. package/plugins/fh-meta/skills/install-wizard/SKILL.md +31 -0
  17. package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +24 -6
  18. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  19. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  20. package/scripts/abstract_consult_check.py +573 -0
  21. package/scripts/fh_detach.py +466 -0
  22. package/scripts/fh_session_load.sh +17 -0
  23. package/scripts/mutation_probe.py +16 -0
  24. package/scripts/selfcheck.sh +83 -6
  25. package/scripts/test_abstract_consult_check_lanes.sh +201 -0
  26. package/scripts/test_fh_detach_lanes.sh +302 -0
  27. package/scripts/test_fh_run_resolver_lanes.sh +16 -0
  28. package/scripts/test_mutation_probe_lanes.sh +62 -20
  29. package/scripts/test_ollama_panel_lanes.sh +107 -11
  30. package/scripts/test_prepush_real_fire_lanes.sh +1 -1
  31. package/scripts/test_selfcheck_state_lanes.sh +73 -1
  32. package/templates/CLAUDE.md +16 -0
@@ -159,6 +159,17 @@ procs_matching() { # count live processes whose WHOLE cmdline is $1 — /proc,
159
159
  for c in /proc/[0-9]*/cmdline; do [ -e "$c" ] || continue; [ "$(tr '\0' ' ' < "$c" 2>/dev/null)" = "$1 " ] && n=$((n+1)); done
160
160
  echo "$n"
161
161
  }
162
+ # The counter is exact per cmdline but its SCOPE is the whole machine: /proc is not scoped to a
163
+ # checkout, so a fixture named `sleep 4747` is a name two runs can both claim. Measured 2026-10-26:
164
+ # this suite and three others went red only under concurrent load and passed 3/3 standalone in both
165
+ # trees — two copies in DIFFERENT trees each counted the other's live fixtures, so N6/S7-5 ("no
166
+ # orphan is left running") saw the sibling's healthy, about-to-be-killed sleep and called it an
167
+ # orphan. Nothing was broken in the subject; the lanes were reading each other.
168
+ # The fix is to make the fixture's name unique to THIS run. A fractional suffix keeps the cmdline
169
+ # exactly matchable (`sleep 4747.12345` is one argv word) while making the token un-shareable.
170
+ # $$ is unique among live processes and $RANDOM breaks the PID-reuse case; digits only, one dot.
171
+ _PSFX="$$${RANDOM}"
172
+ TOK_N6="4747.$_PSFX"; TOK_K0="4646.$_PSFX"; TOK_S75="4848.$_PSFX"
162
173
  if [ -d /proc/self ]; then HAVE_PROC=1; else HAVE_PROC=0; fi
163
174
 
164
175
  # B4 — the baseline lane writes its own subject: refuse, and leave the ORIGINAL bytes
@@ -227,12 +238,12 @@ out=$(python3 "$PROBE" lat.sh lane_weak.sh 2>&1); rc=$?
227
238
  [ "$rc" -eq 2 ] && grep -q 'not UTF-8' <<<"$out" ; chk $? "N5 non-UTF-8 subject → 2 with the reason (v1: traceback rc 1)"
228
239
 
229
240
  # N6 — no orphan keeps running a mutant after a timeout
230
- printf '. ./n1.sh\nis_adult 19 && exit 0\n( touch n6.started; exec sleep 4747 ) &\nwait\n' > lane_n6.sh
241
+ printf '. ./n1.sh\nis_adult 19 && exit 0\n( touch n6.started; exec sleep %s ) &\nwait\n' "$TOK_N6" > lane_n6.sh
231
242
  rm -f n6.started
232
243
  out=$(python3 "$PROBE" n1.sh lane_n6.sh --timeout 2 2>&1)
233
244
  sleep 0.5
234
245
  if [ "$HAVE_PROC" -eq 1 ]; then
235
- [ -e n6.started ] && grep -q 'TIMEOUT' <<<"$out" && [ "$(procs_matching 'sleep 4747')" -eq 0 ] ; chk $? "N6 the timed-out lane's grandchildren are killed with its process group (counted via /proc — v6 used pgrep, vacuous when absent)"
246
+ [ -e n6.started ] && grep -q 'TIMEOUT' <<<"$out" && [ "$(procs_matching "sleep $TOK_N6")" -eq 0 ] ; chk $? "N6 the timed-out lane's grandchildren are killed with its process group (counted via /proc — v6 used pgrep, vacuous when absent)"
236
247
  else
237
248
  echo " ⚠️ N6 UNMEASURED — no /proc"; UNMEASURED=$((UNMEASURED+1))
238
249
  fi
@@ -554,8 +565,16 @@ out=$(python3 "$PROBE" z28.sh --list 2>&1)
554
565
  ! grep -qF '==' <<<"$out" && grep -qF '[=→!=]' <<<"$out" ; chk $? "Z28 #!/bin/sh: '!=' is not flipped to the non-POSIX '==' (= → != still is)"
555
566
 
556
567
  if [ "$HAVE_PROC" -eq 1 ]; then # the process counter itself, on a known pair, before any lane trusts it
557
- sleep 4646 & kp=$!; sleep 0.1; k1=$(procs_matching 'sleep 4646'); kill "$kp"; wait "$kp" 2>/dev/null; k0=$(procs_matching 'sleep 4646')
568
+ sleep "$TOK_K0" & kp=$!; sleep 0.1; k1=$(procs_matching "sleep $TOK_K0"); kill "$kp"; wait "$kp" 2>/dev/null; k0=$(procs_matching "sleep $TOK_K0")
558
569
  [ "$k1" -eq 1 ] && [ "$k0" -eq 0 ] ; chk $? "K0 the /proc process counter sees a live sleep (1) and not a dead one (0) — and not itself"
570
+ # K1 (2026-10-26) — the token must be unique to this run, not merely exact. Known pair against a
571
+ # live FOREIGN process carrying the old shared name: the thing a concurrent sibling used to be.
572
+ sleep 4747 & kf=$!; sleep 0.1
573
+ [ "$(procs_matching 'sleep 4747')" -ge 1 ] ; chk $? "K1a known-POSITIVE: the OLD shared token does count a foreign process (the collision was real)"
574
+ [ "$(procs_matching "sleep $TOK_N6")" -eq 0 ] ; chk $? "K1b known-NEGATIVE: this run's unique token does not count it — N6/S7-5 cannot read a sibling's fixtures"
575
+ kill "$kf" 2>/dev/null; wait "$kf" 2>/dev/null
576
+ # And the three tokens must differ from each other, or one lane's fixture answers another's count.
577
+ [ "$TOK_N6" != "$TOK_K0" ] && [ "$TOK_K0" != "$TOK_S75" ] && [ "$TOK_N6" != "$TOK_S75" ] ; chk $? "K1c the three fixture tokens are distinct within a run"
559
578
  fi
560
579
  echo "── S7: v7 safety contract — each lane red on v6 (2026-10-08, from the v6 capture-recapture detectors)"
561
580
 
@@ -592,10 +611,10 @@ out=$(python3 "$PROBE" s74.sh lane_s74.sh --timeout 30 2>&1); rc=$?
592
611
  # S7-5 — a setsid escapee is killed (Linux subreaper); unmeasurable without /proc → UNMEASURED, never PASS
593
612
  if [ "$HAVE_PROC" -eq 1 ] && command -v setsid >/dev/null 2>&1; then
594
613
  cp age.sh s75.sh; rm -f s75.started
595
- printf '. ./s75.sh\nsetsid sh -c "touch s75.started; exec sleep 4848" </dev/null >/dev/null 2>&1 &\nsleep 0.3\nis_adult 20 || exit 1\nis_adult 19 || exit 1\nexit 0\n' > lane_s75.sh
614
+ printf '. ./s75.sh\nsetsid sh -c "touch s75.started; exec sleep %s" </dev/null >/dev/null 2>&1 &\nsleep 0.3\nis_adult 20 || exit 1\nis_adult 19 || exit 1\nexit 0\n' "$TOK_S75" > lane_s75.sh
596
615
  out=$(python3 "$PROBE" s75.sh lane_s75.sh --timeout 30 2>&1)
597
616
  sleep 0.3
598
- [ -e s75.started ] && grep -qE 'mutants=1 ' <<<"$out" && [ "$(procs_matching 'sleep 4848')" -eq 0 ] ; chk $? "S7-5 a setsid descendant of the lane does not outlive the probe (v6: it kept running with the mutant)"
617
+ [ -e s75.started ] && grep -qE 'mutants=1 ' <<<"$out" && [ "$(procs_matching "sleep $TOK_S75")" -eq 0 ] ; chk $? "S7-5 a setsid descendant of the lane does not outlive the probe (v6: it kept running with the mutant)"
599
618
  else
600
619
  echo " ⚠️ S7-5 UNMEASURED — no /proc or no setsid"; UNMEASURED=$((UNMEASURED+1))
601
620
  fi
@@ -674,25 +693,48 @@ echo "── R7: blind review of v7 (2026-10-08) — each lane red on fbfe773"
674
693
  # lane wrote the subject during the control run) and this lane went red on a correct probe. Now the
675
694
  # delay is measured on this machine: one undisturbed run times its «subject:» header (printed after
676
695
  # the lock), and the restore fires at half of that. Twice the lines makes that window seconds wide.
696
+ # 🟥 2026-10-28 (downstream report 2026-10-27): the measured half-time window was still a timed guess — on another
697
+ # downstream runner the second run was faster than the calibration run and the restore landed after
698
+ # the lock. Now the window is OBSERVED: MUTATION_PROBE_TEST_AFTER_READ makes the probe touch
699
+ # <seam>.read right after it reads the subject and wait for <seam>.go before it goes on to lock, so the
700
+ # restore lands inside the window on any runner. No timing, no calibration run, no UNMEASURED arm.
677
701
  printf '#!/usr/bin/env bash\n[ "$a" -ne 1 ] && echo x1\n' > r71.orig
678
- for k in $(seq 2 12000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; done >> r71.orig
679
702
  printf 'grep -q "exit 113" r71.sh && exit 1\nexit 0\n' > lane_r71.sh
680
- cp r71.orig r71.sh
681
- _ms(){ python3 -c 'import time; print(int(time.time() * 1000))'; } # BSD date has no %N
682
- c71=$(_ms); h71=""
683
- while IFS= read -r l; do
684
- case "$l" in subject:*) [ -n "$h71" ] || h71=$(( $(_ms) - c71 )) ;; esac
685
- done < <(python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 2>&1)
686
- cmp -s r71.sh r71.orig || cp r71.orig r71.sh
687
- # no header = the calibration run never reached the lock: the delay is unknown, so the lane fails below
688
- # (d71 stays 0 → the restore lands before the read → no refusal) rather than guessing a number.
689
- [ -n "$h71" ] || echo " ⚠️ R7-1 calibration: no «subject:» header — time-to-lock unknown on this machine"
690
- d71=$(awk -v ms="${h71:-0}" 'BEGIN { printf "%.3f", ms / 2000 }')
691
703
  sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
692
- python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 > r71.out 2>&1 & pb=$!
693
- sleep "$d71"; cat r71.orig > r71.sh # … and now it restores (same inode)
704
+ _r71s="$PWD/r71.seam"; rm -f "$_r71s.read" "$_r71s.go"
705
+ MUTATION_PROBE_TEST_AFTER_READ="$_r71s" python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 > r71.out 2>&1 & pb=$!
706
+ _r71w=0; while [ ! -e "$_r71s.read" ] && kill -0 "$pb" 2>/dev/null && [ "$_r71w" -lt 600 ]; do sleep 0.1; _r71w=$((_r71w+1)); done
707
+ _r71seen=no; [ -e "$_r71s.read" ] && _r71seen=yes
708
+ cat r71.orig > r71.sh # … the other probe restores (same inode) — after the read
709
+ : > "$_r71s.go" # … and only now may this probe go on to lock
694
710
  wait "$pb"; rc=$?
695
- grep -q 'changed between reading it and locking it' r71.out && [ "$rc" -eq 2 ] && cmp -s r71.sh r71.orig && [ ! -e "$(bkpath r71.sh)" ] ; chk $? "R7-1 a subject that changed between read and lock → 2, the original stays (fbfe773: the stale mutant was backed up as «original» and written back)"
711
+ [ "$_r71seen" = yes ] && grep -q 'changed between reading it and locking it' r71.out && [ "$rc" -eq 2 ] && cmp -s r71.sh r71.orig && [ ! -e "$(bkpath r71.sh)" ] ; chk $? "R7-1 a subject that changed between read and lock → 2, the original stays (fbfe773: the stale mutant was backed up as «original» and written back)"
712
+ [ "$_r71seen" = yes ] || printf ' R7-1: the probe never signalled «read» (exit before reading?): %s\n' "$(head -2 r71.out | tr '\n' ' ')"
713
+ # R7-1c (codex R1) — the seam never writes through something already at <seam>.read: a link there → 2, target intact
714
+ printf 'keep\n' > r71c.target; ln -sf "$PWD/r71c.target" r71c.seam.read; cp r71.orig r71c.sh
715
+ MUTATION_PROBE_TEST_AFTER_READ="$PWD/r71c.seam" python3 "$PROBE" r71c.sh lane_r71.sh --max 1 --timeout 30 > r71c.out 2>&1; rc=$?
716
+ [ "$rc" -eq 2 ] && grep -q 'test seam .*cannot be created' r71c.out && [ "$(cat r71c.target)" = keep ] && cmp -s r71c.sh r71.orig ; chk $? "R7-1c a link already at <seam>.read → 2, the link's target is not truncated, the subject untouched"
717
+
718
+ # R7-1b (2026-10-26) — the known pair for the UNMEASURED arm above. The claim it rests on is that a
719
+ # leftover backup under either key makes the probe refuse BEFORE it prints its header; if that is not
720
+ # true, the arm above is an excuse rather than a verdict. Measured both ways on a throwaway subject,
721
+ # and the planted file is removed in the same lane (it is a 52-byte fixture, not anyone's recovery data).
722
+ cp age.sh r71b.sh
723
+ _r71b_bk="$(ibkpath r71b.sh)"
724
+ mkdir -p "$(dirname "$_r71b_bk")" 2>/dev/null
725
+ if [ -e "$_r71b_bk" ]; then
726
+ echo " ⚠️ R7-1b UNMEASURED — a backup is already at $_r71b_bk; this lane will not touch someone else's"
727
+ UNMEASURED=$((UNMEASURED+1))
728
+ else
729
+ cp age.sh "$_r71b_bk"
730
+ out=$(python3 "$PROBE" r71b.sh lane_weak.sh --max 1 --timeout 30 2>&1); rc=$?
731
+ [ "$rc" -eq 2 ] && grep -q 'a previous run left a backup' <<<"$out" && ! grep -q '^subject:' <<<"$out"
732
+ chk $? "R7-1b known-POSITIVE: a leftover backup at the INODE key makes the probe refuse before its header (so a missing header is UNMEASURED, not a lane failure)"
733
+ rm -f "$_r71b_bk"
734
+ out=$(python3 "$PROBE" r71b.sh lane_weak.sh --max 1 --timeout 30 2>&1); rc=$?
735
+ grep -q '^subject:' <<<"$out"
736
+ chk $? "R7-1b known-NEGATIVE: with the leftover gone, the same subject reaches the header (the refusal was the backup, not the subject)"
737
+ fi
696
738
  cp r71.orig r71.sh
697
739
 
698
740
  # R7-2 — the lane hard-links an unrelated file to the subject's path: that file is never written
@@ -19,7 +19,27 @@ set -u
19
19
  ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
20
20
  CAL="$ROOT/scripts/sidecar_calibrate.sh"
21
21
  pass=0; fail=0
22
- PORT="${FH_LANE_PORT:-18011}"
22
+ # PORT — asked of the OS, not hardcoded (2026-10-26). It was `${FH_LANE_PORT:-18011}`, and 18011
23
+ # is machine-global: a TCP port is not scoped to a checkout. Two copies of this suite running in
24
+ # DIFFERENT trees on one machine both try to bind it; the loser's stub dies with "Address already in
25
+ # use", every lane in the losing run then talks to the WINNER's stub, and the verdicts come back as
26
+ # an unreproducible mix that reads exactly like a flake — measured 2026-10-26, when this suite and
27
+ # three others only ever went red under concurrent load and passed 3/3 standalone in both trees.
28
+ # The lesson generalizes past this file: a fixture keyed on a machine-global name (a port, a
29
+ # /proc-wide process pattern, a fixed /tmp path) is not hermetic however hermetic its logic is.
30
+ # FH_LANE_PORT still wins when set — an operator pinning a port has a reason, and overriding them
31
+ # would trade one surprise for another.
32
+ _free_port() { # a port the OS says is free right now: bind :0, read it back, release it
33
+ python3 -c 'import socket
34
+ s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
35
+ s.bind(("127.0.0.1", 0)); print(s.getsockname()[1]); s.close()'
36
+ }
37
+ # A released ephemeral port can be taken in the window before the stub binds it — rare, and the
38
+ # honest answer to rare is a retry that NAMES itself, not a lane failure that looks like a defect
39
+ # in the subject. start_stub re-picks on each attempt when the port was not pinned.
40
+ PORT="${FH_LANE_PORT:-}"
41
+ [ -n "$PORT" ] || PORT="$(_free_port)"
42
+ PORT_PINNED=0; [ -n "${FH_LANE_PORT:-}" ] && PORT_PINNED=1
23
43
  SRV_PID=""
24
44
 
25
45
  # `wait` after the kill, so bash reaps the child quietly instead of printing "Terminated: 15" into
@@ -97,15 +117,24 @@ HTTPServer(("127.0.0.1", PORT), H).serve_forever()
97
117
  PY
98
118
  # shellcheck disable=SC2016
99
119
  start_stub() {
100
- stop_stub
101
- python3 "$STUB" "$PORT" "$1" >/dev/null 2>&1 &
102
- SRV_PID=$!
103
- for _ in $(seq 1 40); do
104
- # Ready = ANY HTTP answer, not a 2xx: the notollama mode answers /api/version with a 404 on
105
- # purpose, and `-f` would read that as "stub never came up".
106
- _c="$(curl -s -o /dev/null --max-time 1 -w '%{http_code}' "http://127.0.0.1:$PORT/api/version" 2>/dev/null)"
107
- [ "${_c:-000}" != "000" ] && return 0
108
- sleep 0.25
120
+ local _try
121
+ for _try in 1 2 3; do
122
+ stop_stub
123
+ [ "$_try" -eq 1 ] || [ "$PORT_PINNED" -eq 1 ] || PORT="$(_free_port)"
124
+ python3 "$STUB" "$PORT" "$1" >/dev/null 2>&1 &
125
+ SRV_PID=$!
126
+ for _ in $(seq 1 40); do
127
+ # Ready = ANY HTTP answer, not a 2xx: the notollama mode answers /api/version with a 404 on
128
+ # purpose, and `-f` would read that as "stub never came up".
129
+ _c="$(curl -s -o /dev/null --max-time 1 -w '%{http_code}' "http://127.0.0.1:$PORT/api/version" 2>/dev/null)"
130
+ [ "${_c:-000}" != "000" ] && return 0
131
+ # The stub process being GONE is a different fact from "not ready yet", and waiting out the
132
+ # remaining 10 s on a dead process is how a bind collision used to present as a timeout.
133
+ kill -0 "$SRV_PID" 2>/dev/null || break
134
+ sleep 0.25
135
+ done
136
+ [ "$PORT_PINNED" -eq 1 ] && break
137
+ echo " ⚠️ stub did not come up on port $PORT (attempt $_try/3) — re-picking a free port" >&2
109
138
  done
110
139
  return 1
111
140
  }
@@ -163,13 +192,80 @@ MODELS=" stub-model:1b , " \
163
192
  expect "S14 padding around commas is trimmed" ok YES "PIN-OK(envelope)" "INPUT-ERROR"
164
193
 
165
194
  # S6 — absence must be MEASURED, never assumed. No server at the host at all.
166
- out=$( FH_OLLAMA_HOST="http://127.0.0.1:$((PORT+7))" bash "$CAL" --only ollama --quiet 2>&1 )
195
+ # The dead host used to be `$((PORT+7))`, which is arithmetic on an assumption: PORT+7 is free
196
+ # because nobody is expected to be there. On a busy machine somebody is, and then this lane asserts
197
+ # ABSENT against a host that answers and goes red for a reason that has nothing to do with the
198
+ # subject. Ask the OS for a port and then CHECK it is silent — the lane's own premise, measured.
199
+ _dead_port=""
200
+ for _ in 1 2 3; do
201
+ _p="$(_free_port)"
202
+ [ "$(curl -s -o /dev/null --max-time 1 -w '%{http_code}' "http://127.0.0.1:$_p/api/version" 2>/dev/null)" = "000" ] \
203
+ && { _dead_port="$_p"; break; }
204
+ done
205
+ if [ -z "$_dead_port" ]; then
206
+ # UNMEASURED, not a pass and not a failure of the subject: three ports in a row answered, so this
207
+ # lane never got the silent host its premise needs. Counted as a failure because an unmeasured
208
+ # known pair proves nothing — the same rule the suites around this one already follow.
209
+ printf ' ❌ %-44s UNMEASURED: could not obtain a silent port (3 tries)\n' "S6 no server at host"
210
+ fail=$((fail+1))
211
+ else
212
+ out=$( FH_OLLAMA_HOST="http://127.0.0.1:$_dead_port" bash "$CAL" --only ollama --quiet 2>&1 )
167
213
  if printf '%s' "$out" | grep -q 'ABSENT — no server at the configured host'; then
168
214
  printf ' ✅ %-44s reported ABSENT\n' "S6 no server at host"; pass=$((pass+1))
169
215
  else
170
216
  printf ' ❌ %-44s (expected a measured ABSENT line)\n' "S6 no server at host"
171
217
  printf ' out: %s\n' "$(printf '%s' "$out" | head -3)"; fail=$((fail+1))
172
218
  fi
219
+ fi
220
+
221
+ # ── S20 (2026-10-26) — the known pair for the port repair itself ───────────────────────────────
222
+ # The defect this suite shipped with was not in its logic: PORT was the fixed 18011, so two copies
223
+ # running in different trees on one machine fought over one socket. That is only a repair if the
224
+ # collision is REAL and the repair survives it, so this lane holds a port open and asks both
225
+ # questions against the live code rather than against my description of it.
226
+ echo "── S20 port is not machine-global ──"
227
+ _hold_out="$(mktemp)"; _held=""
228
+ python3 -c 'import socket,sys,time
229
+ s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
230
+ s.bind(("127.0.0.1", 0)); s.listen(1)
231
+ print(s.getsockname()[1], flush=True)
232
+ time.sleep(45)' > "$_hold_out" 2>/dev/null &
233
+ _hold_pid=$!
234
+ for _ in $(seq 1 40); do _held="$(head -1 "$_hold_out" 2>/dev/null)"; [ -n "$_held" ] && break; sleep 0.25; done
235
+ _saved_port="$PORT"; _saved_pinned="$PORT_PINNED"
236
+ if [ -z "$_held" ]; then
237
+ # UNMEASURED: no holder, so neither arm below means anything. Counted, for the same reason S6's
238
+ # unmeasured arm is counted — a known pair that did not run is not a known pair that passed.
239
+ printf ' ❌ %-44s UNMEASURED: could not hold a port open\n' "S20 occupied-port known pair"
240
+ fail=$((fail+1))
241
+ else
242
+ # known-POSITIVE: the collision is real. Pin the stub to the held port and the stub cannot come
243
+ # up. If this arm ever passes, binding a busy port stopped failing and the lane below proves
244
+ # nothing — so the positive control is what keeps the negative one honest.
245
+ PORT="$_held"; PORT_PINNED=1
246
+ if start_stub ok 2>/dev/null; then
247
+ printf ' ❌ %-44s a stub came up on an OCCUPIED port — the control is broken\n' "S20a known-positive"
248
+ fail=$((fail+1))
249
+ else
250
+ printf ' ✅ %-44s a pinned, occupied port really does stop the stub\n' "S20a known-positive"
251
+ pass=$((pass+1))
252
+ fi
253
+ stop_stub
254
+ # known-NEGATIVE: with the port NOT pinned, the same occupied port is simply not chosen — which
255
+ # is the whole repair. The old `${FH_LANE_PORT:-18011}` form had no way to express this.
256
+ PORT_PINNED=0; PORT="$_held"
257
+ if start_stub ok && [ "$PORT" != "$_held" ]; then
258
+ printf ' ✅ %-44s unpinned: picked %s instead of the occupied port\n' "S20b known-negative" "$PORT"
259
+ pass=$((pass+1))
260
+ else
261
+ printf ' ❌ %-44s unpinned run did not route around the occupied port (port=%s)\n' "S20b known-negative" "$PORT"
262
+ fail=$((fail+1))
263
+ fi
264
+ stop_stub
265
+ fi
266
+ kill "$_hold_pid" 2>/dev/null; wait "$_hold_pid" 2>/dev/null
267
+ rm -f "$_hold_out"
268
+ PORT="$_saved_port"; PORT_PINNED="$_saved_pinned"
173
269
 
174
270
  echo
175
271
  if [ "$fail" -eq 0 ]; then
@@ -77,7 +77,7 @@ EOF
77
77
  }
78
78
  remote_ref() { git -C "$1/remote.git" rev-parse -q --verify "$2" 2>/dev/null || echo ABSENT; }
79
79
  fired() { wc -l < "$1/fired" | tr -d ' '; }
80
- stdin_has() { cat "$1"/stdin.* 2>/dev/null | grep -qE "$2"; }
80
+ stdin_has() { grep -qE "$2" "$1"/stdin.* 2>/dev/null; } # no pipe: grep -q exiting early cannot SIGPIPE a producer (downstream report 2026-10-27)
81
81
 
82
82
  # run_lane <name> <ref-to-watch> <stdin-regex> <push args...>
83
83
  run_lane() {
@@ -474,7 +474,79 @@ else
474
474
  # The loop must route through the function — a lifted function with no caller is decoration.
475
475
  # Uncommented line only (codex review 2026-10-19: a commented-out call passed the first form).
476
476
  # Still a text check — it cannot prove the line is reached; that residual is named, not closed.
477
- grep -qE '^[[:space:]]+_pair_rc_verdict "\$_lbl" "\$_subj" "\$_rc" \|\| fail=1' "$SELFCHECK"; chk $? "pair loop calls _pair_rc_verdict (uncommented) and sets fail on it"
477
+ grep -qE '^[[:space:]]+_pair_rc_verdict "\$_lbl" "\$_subj" "\$_rc" "\$_bud" \|\| fail=1' "$SELFCHECK"; chk $? "pair loop calls _pair_rc_verdict (uncommented, with the budget) and sets fail on it"
478
+ # The TIMEOUT line must name the budget the run actually used. Before 2026-10-26 it printed a
479
+ # hardcoded "limit 300 s"; once budgets differ per suite, that line is a wrong fact in the one
480
+ # place a reader greps. Known pair: a non-default budget must appear, and the default must not.
481
+ _o=$(_pair_rc_verdict lane_x.sh subj_x 124 600)
482
+ printf '%s' "$_o" | grep -q 'budget 600 s' && ! printf '%s' "$_o" | grep -q 'budget 300 s'
483
+ chk $? "rc=124 with a 600 s budget → the line names 600, not the default"
484
+ _o=$(_pair_rc_verdict lane_x.sh subj_x 124)
485
+ printf '%s' "$_o" | grep -q 'budget 300 s'; chk $? "rc=124 with no budget argument → falls back to the default, still named"
486
+ fi
487
+
488
+ # ── Per-suite lane budget (2026-10-26) ────────────────────────────────────────
489
+ # fh_signal_2026-10-26_mutation-probe-budget-cliff: test_mutation_probe_lanes.sh takes 318–322 s
490
+ # standalone and the loop's single global `timeout 300` killed it, so 122 known-pair lanes reported
491
+ # as one TIMEOUT line and went UNMEASURED. Nothing in the suite or its subject had changed. The
492
+ # repair is a per-suite budget plus an advisory margin line; these lanes pin BOTH halves, because a
493
+ # budget with no margin warning reproduces the same blindness one host-slowdown later.
494
+ echo ""
495
+ echo "── per-suite lane budget (_lane_budget · _lane_margin_note) ──"
496
+ _BUDFN=$(sed -n '/^_lane_budget() {/,/^}/p' "$SELFCHECK")
497
+ _MARGINFN=$(sed -n '/^_lane_margin_note() {/,/^}/p' "$SELFCHECK")
498
+ # `grep -m1 FILE` rather than `grep … | head -1`: under `set -o pipefail` (line 23) an early-exit
499
+ # consumer SIGPIPEs the producer and the residual rc becomes the pipeline's — the defect class
500
+ # scripts/pipefail_earlyexit_scan.sh locks at zero NEW sites. Measured here: the first draft of
501
+ # these lanes added three such sites and selfcheck's class-lock lane went red on my own commit.
502
+ _BUDDEF=$(grep -m1 -E '^_LANE_BUDGET_DEFAULT=[0-9]+$' "$SELFCHECK")
503
+ if [ -z "$_BUDFN" ] || [ -z "$_MARGINFN" ] || [ -z "$_BUDDEF" ]; then
504
+ chk 1 "_lane_budget / _lane_margin_note / _LANE_BUDGET_DEFAULT found in selfcheck.sh (lane would test nothing)"
505
+ else
506
+ eval "$_BUDDEF"; eval "$_BUDFN"; eval "$_MARGINFN"
507
+ _WARNLINE=$(grep -m1 -E '^_LANE_BUDGET_WARN_PCT=[0-9]+' "$SELFCHECK")
508
+ _WARNPCT=$(sed -E 's/[^0-9]*([0-9]*).*/\1/' <<<"$_WARNLINE")
509
+ [ -n "$_WARNPCT" ] && eval "_LANE_BUDGET_WARN_PCT=$_WARNPCT"
510
+
511
+ [ "$(_lane_budget some_other_suite.sh)" = "$_LANE_BUDGET_DEFAULT" ]
512
+ chk $? "an undeclared suite gets the default budget ($_LANE_BUDGET_DEFAULT s) — the table is an exception list, not a rewrite"
513
+ # known-POSITIVE for the defect: the measured suite's budget must EXCEED its measured cost, or
514
+ # the repair changed nothing. 322 s is the slowest of the three reps taken on 2026-10-26.
515
+ [ "$(_lane_budget test_mutation_probe_lanes.sh)" -gt 322 ]
516
+ chk $? "test_mutation_probe_lanes.sh's budget exceeds its measured 322 s — the kill that started this cannot recur at the same cost"
517
+ # known-NEGATIVE: the default does NOT, which is why the suite died. If someone "fixes" this by
518
+ # raising the default instead, this lane goes red and says so.
519
+ [ "$_LANE_BUDGET_DEFAULT" -lt 322 ]
520
+ chk $? "known-NEGATIVE: the default budget is still below that cost (the repair is per-suite, not a global raise)"
521
+ # A budget with no bound is the other wrong repair: it turns a killed suite into a hung CI job.
522
+ [ "$(_lane_budget test_mutation_probe_lanes.sh)" -gt 0 ] && [ "$(_lane_budget test_mutation_probe_lanes.sh)" -le 1800 ]
523
+ chk $? "the raised budget is still a BOUND (>0 and ≤1800 s), not an absent timeout"
524
+
525
+ # The margin note: fires close to the budget, silent well inside it, and says PASSED either way.
526
+ _o=$(_lane_margin_note lane_x.sh 290 300)
527
+ printf '%s' "$_o" | grep -q '^NOTE ' && printf '%s' "$_o" | grep -q 'PASSED'
528
+ chk $? "known-POSITIVE: 290 s of a 300 s budget → an advisory NOTE that says the suite passed"
529
+ _o=$(_lane_margin_note lane_x.sh 290 300)
530
+ ! printf '%s' "$_o" | grep -qE '^(FAIL|TIMEOUT|HARNESS ERROR|❌)'
531
+ chk $? "the advisory is not a verdict — no FAIL/TIMEOUT/HARNESS ERROR vocabulary in it"
532
+ _o=$(_lane_margin_note lane_x.sh 30 300); [ -z "$_o" ]
533
+ chk $? "known-NEGATIVE: 30 s of a 300 s budget → silent (a note on every suite is a note nobody reads)"
534
+ _lane_margin_note lane_x.sh 290 300 >/dev/null; chk $? "the advisory returns 0 — it can never set fail"
535
+ _o=$(_lane_margin_note lane_x.sh 5 0); [ -z "$_o" ]
536
+ chk $? "a zero budget → silent, no division by zero"
537
+ # It must be WIRED into the loop. A margin function nobody calls is the decoration this repo
538
+ # names built-but-not-wired; text check only, same residual as the _pair_rc_verdict grep above.
539
+ grep -qE '^[[:space:]]+\[ "\$_t0" -gt 0 \].*_lane_margin_note "\$_lbl"' "$SELFCHECK"
540
+ chk $? "the pair loop calls _lane_margin_note (uncommented)"
541
+ grep -qE '^[[:space:]]+_lane_to=""; command -v timeout' "$SELFCHECK"
542
+ chk $? "the loop installs a PER-SUITE timeout var (not reassigning the shared \$_LANE_TO)"
543
+ # Why that last lane exists: $_LANE_TO is read again by two dispatches hundreds of lines below the
544
+ # loop. Reassigning it per suite would hand one suite's budget to unrelated blocks, silently.
545
+ # Ends in `wc -l`, which reads to EOF: `| grep -q .` here would kill awk mid-stream and hand the
546
+ # pipeline a SIGPIPE rc under pipefail. Same reason as the two greps above.
547
+ _lto_below=$(grep -n '\$_LANE_TO' "$SELFCHECK" | awk -F: '$1>1200' | wc -l)
548
+ [ "$_lto_below" -ge 1 ]
549
+ chk $? "known-POSITIVE for that risk: \$_LANE_TO really is still read below the loop ($_lto_below sites)"
478
550
  fi
479
551
 
480
552
  echo ""
@@ -79,6 +79,22 @@ When persisting new assets (memory · feedback · patterns · rules) during a se
79
79
 
80
80
  When the judgment is ambiguous, the AI **states synergy potential first** then delegates the location decision to the user.
81
81
 
82
+ ## When this file and the code disagree
83
+
84
+ - When this file states a convention (naming, structure, error types, module style) that the existing code does not follow, follow the established convention of the code nearest to your change (the same package or module) and say that you found the conflict. Do not rewrite unrelated existing code to match this file; changes the requested task needs are fine. A rule this file explicitly scopes to new or changed code (a migration, or "new X must ...") wins within that scope, and its security, privacy, safety and gate rules always win, whatever form they take.
85
+
86
+ <!-- Measured 2026-10-24, Sonnet 5.5, small synthetic fixtures, 4 runs per cell (arXiv:2610.30571 shape). Three batches:
87
+ (1) 3 stale-convention fixtures, no line: the stale file line was followed in 10/12 runs, existing definitions rewritten
88
+ to match it in 4/12. An early wording without the "scoped to new code" exception then overrode an explicit
89
+ migration line 4/4. Keep that exception.
90
+ (2) 8 fixtures (the 3 above + migration + 4 written later: rule for new code, security rule phrased as an error rule,
91
+ monorepo nearest package, unseen stale rule), no line vs a near-final wording: right 24/32 vs 32/32, detected
92
+ definition rewrites 2 runs vs 0. On the 4 later fixtures both arms were right 16/16, so no regression was observed
93
+ there and no benefit was shown either.
94
+ (3) This wording ("wins within that scope"), 4 core fixtures: right 16/16, 0 rewrites. Every diff in (2)-(3) read by hand.
95
+ Not measured: a stale convention dressed as a gate rule ("gate: reject camelCase") would now always win. -->
96
+
97
+
82
98
  ## Knowledge Hub (forge-harness)
83
99
 
84
100
  Persistent knowledge for this project is stored at `~/projects/forge-harness/`.