@chrono-meta/fh-gate 3.41.0 → 3.43.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 (108) hide show
  1. package/.claude/regression/probes_live.yaml +16 -8
  2. package/.claude/rules/fh_4axis_gate.md +8 -0
  3. package/.claude-plugin/marketplace.json +4 -4
  4. package/AGENTS.md +5 -0
  5. package/README.ja.md +2 -0
  6. package/README.ko.md +2 -0
  7. package/README.md +2 -0
  8. package/README.zh.md +2 -0
  9. package/docs/HOW_FH_DIFFERS.en.md +37 -0
  10. package/docs/HOW_FH_DIFFERS.md +39 -0
  11. package/docs/USER_GUIDE.md +113 -2
  12. package/docs/model_tier_expectations.md +8 -4
  13. package/knowledge/shared/harness-core/claude_md_full_reference.md +10 -0
  14. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +18 -0
  15. package/knowledge/shared/harness-core/fh_module_contract.md +19 -0
  16. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +24 -0
  17. package/knowledge/shared/learnings/subagent_invocations_log.yaml +30 -0
  18. package/package.json +7 -1
  19. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  20. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +12 -5
  21. package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +17 -0
  22. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  23. package/plugins/fh-meta/CHANGELOG.md +49 -3
  24. package/plugins/fh-meta/skills/edit-manifest/SKILL.md +14 -1
  25. package/plugins/fh-meta/skills/harvest-loop/SKILL.md +1 -1
  26. package/plugins/fh-meta/skills/meta-prompt-builder/SKILL.md +19 -0
  27. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  28. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  29. package/scripts/capability_registry_check.sh +15 -2
  30. package/scripts/fh_session_load.sh +3 -1
  31. package/scripts/live_eval_trace.py +122 -0
  32. package/scripts/package_coverage_check.sh +7 -0
  33. package/scripts/pr_merge_verified.sh +7 -0
  34. package/scripts/probe_live_eval.sh +6 -3
  35. package/scripts/probe_live_eval_lib.py +89 -1
  36. package/scripts/remote_marker_gate.sh +56 -0
  37. package/scripts/selfcheck.sh +9 -1
  38. package/scripts/session_close_check.sh +16 -0
  39. package/scripts/sim_isolated_run.sh +17 -2
  40. package/scripts/test_abstract_consult_check_lanes.sh +1 -0
  41. package/scripts/test_adapter_lanes.sh +1 -0
  42. package/scripts/test_axis23_skip_reason_lanes.sh +1 -0
  43. package/scripts/test_backtick_guard_lanes.sh +1 -0
  44. package/scripts/test_claim_propagation_lanes.sh +1 -0
  45. package/scripts/test_claude_md_size_lanes.sh +1 -0
  46. package/scripts/test_consent_registry.sh +1 -0
  47. package/scripts/test_count_check_all_plugins_lanes.sh +1 -0
  48. package/scripts/test_count_check_decl_lanes.sh +1 -0
  49. package/scripts/test_count_check_readme_format_lanes.sh +1 -0
  50. package/scripts/test_degrade_scan_shell_probes.sh +1 -0
  51. package/scripts/test_destructive_pre_gate_lanes.sh +1 -0
  52. package/scripts/test_dispatch_receipt_lanes.sh +1 -0
  53. package/scripts/test_doc_claim_triad_lanes.sh +1 -0
  54. package/scripts/test_env_delta_worktree_lanes.sh +1 -0
  55. package/scripts/test_env_layer_fingerprint_lanes.sh +1 -0
  56. package/scripts/test_evidence_root_psa_lanes.sh +1 -0
  57. package/scripts/test_fh_detach_lanes.sh +1 -0
  58. package/scripts/test_fh_goal_change_detection_lanes.sh +1 -0
  59. package/scripts/test_fh_module_check_lanes.sh +1 -0
  60. package/scripts/test_fh_qp_lanes.sh +1 -0
  61. package/scripts/test_files_manifest_shipping_lanes.sh +1 -0
  62. package/scripts/test_fixture_git_env_lanes.sh +15 -0
  63. package/scripts/test_fixture_guard_coverage_lanes.sh +141 -0
  64. package/scripts/test_gate_bootstrap_ephemeral_lanes.sh +1 -0
  65. package/scripts/test_halffix_lanes.sh +1 -0
  66. package/scripts/test_hook_drift_lanes.sh +1 -0
  67. package/scripts/test_hook_templates_copilot_compat_lanes.sh +1 -0
  68. package/scripts/test_lane_gap_hint_lanes.sh +1 -0
  69. package/scripts/test_lane_runner_lanes.sh +1 -0
  70. package/scripts/test_live_eval_trace_lanes.sh +145 -0
  71. package/scripts/test_main_commit_guard_lanes.sh +1 -0
  72. package/scripts/test_marker_axes_run_lanes.sh +1 -0
  73. package/scripts/test_marker_crossfamily_lanes.sh +1 -0
  74. package/scripts/test_marker_defense_lanes.sh +1 -0
  75. package/scripts/test_marker_diff_sha_lanes.sh +1 -0
  76. package/scripts/test_marker_floor_lanes.sh +1 -0
  77. package/scripts/test_meta_prompt_restate_lanes.sh +36 -0
  78. package/scripts/test_mutation_probe_lanes.sh +26 -6
  79. package/scripts/test_name_boundary_locale_lanes.sh +1 -0
  80. package/scripts/test_outbound_pr_gate_lanes.sh +1 -0
  81. package/scripts/test_package_coverage_lanes.sh +1 -0
  82. package/scripts/test_peer_worktree_detect_lanes.sh +1 -0
  83. package/scripts/test_pipe_verdict_guard_lanes.sh +1 -0
  84. package/scripts/test_post_squash_verify_lanes.sh +1 -0
  85. package/scripts/test_pr_merge_verified_lanes.sh +24 -0
  86. package/scripts/test_precommit_gitlink_lanes.sh +1 -0
  87. package/scripts/test_precommit_pointer_index_lanes.sh +1 -0
  88. package/scripts/test_precommit_staged_drift_lanes.sh +1 -0
  89. package/scripts/test_prepush_stdin_integrity.sh +1 -0
  90. package/scripts/test_prior_art_prompt_lanes.sh +1 -0
  91. package/scripts/test_prless_delta_scan_lanes.sh +1 -0
  92. package/scripts/test_probe_live_eval_lanes.sh +1 -0
  93. package/scripts/test_psa_singlefile_lanes.sh +1 -0
  94. package/scripts/test_remote_marker_gate_lanes.sh +97 -0
  95. package/scripts/test_residency_admission_lanes.sh +1 -0
  96. package/scripts/test_revert_probe_lanes.sh +1 -0
  97. package/scripts/test_reviewer_capability_conformance.sh +1 -0
  98. package/scripts/test_selfcheck_state_lanes.sh +1 -0
  99. package/scripts/test_session_close_chain_lanes.sh +1 -0
  100. package/scripts/test_session_close_lanes.sh +8 -0
  101. package/scripts/test_session_load_mirror_fp_lanes.sh +1 -0
  102. package/scripts/test_sim_isolated_run_lanes.sh +1 -0
  103. package/scripts/test_stale_clone_guard_lanes.sh +1 -0
  104. package/scripts/test_stale_ref_close_lanes.sh +1 -0
  105. package/scripts/test_tag_version_lanes.sh +1 -0
  106. package/scripts/test_version_lockstep_lanes.sh +1 -0
  107. package/scripts/test_wizard_snippet_merge_lanes.sh +1 -0
  108. package/scripts/test_worktree_reclaim_lanes.sh +1 -0
@@ -8,6 +8,7 @@
8
8
  # authors) must be identical before and after.
9
9
  #
10
10
  # Revert probe: delete the `for _fg_v in $FH_FIXTURE_GIT_ENV; do unset …` line in the lib → L1-L3 go red.
11
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
11
12
  set -u
12
13
  cd "$(dirname "${BASH_SOURCE[0]}")/.."
13
14
  LIB="$PWD/scripts/fixture_guard_lib.sh"; TRIP="$PWD/scripts/lane_identity_tripwire.sh"
@@ -83,5 +84,19 @@ out="$(GIT_SHALLOW_FILE="$T/shallow" bash "$TRIP" "$V")"; rc=$?
83
84
  printf '%s' "$out" | grep -q 'WARN: 1 commit'; chk $? "L8e inherited GIT_SHALLOW_FILE cutting history at the tip → lane commit still found (codex R1)"
84
85
  bash "$TRIP" "$T/nope" >/dev/null; rc=$?; [ "$rc" -eq 2 ]; chk $? "L8d tripwire on non-repo → HARNESS-ERROR rc=2, not «ok» (got $rc)"
85
86
 
87
+ # ── L9: the session-start caller (fh_session_load.sh) — non-git FH silent, clean git silent, lane commit warns ──
88
+ # BE must be a git repo or the loader exits before its banner; no remote, so the fetch fails fast offline.
89
+ LOAD="$PWD/scripts/fh_session_load.sh"; BE9="$T/be9"; mkdir -p "$BE9" "$T/h9"; ( cd "$BE9" && clean git init -q && touch INDEX.md )
90
+ mkfh() { rm -rf "$1"; mkdir -p "$1/scripts"; cp "$TRIP" "$1/scripts/"; }
91
+ sl() { env -u GIT_DIR -u GIT_INDEX_FILE HOME="$T/h9" CLAUDE_PROJECT_DIR="$1" BE_DIR="$BE9" bash "$LOAD" </dev/null 2>&1 | grep 'LANE-TRIPWIRE'; }
92
+ mkfh "$T/fh_nongit"; out="$(sl "$T/fh_nongit")"
93
+ [ -z "$out" ]; chk $? "L9a session start, FH not a git repo (npm install) → no tripwire line (got: ${out:-none})"
94
+ mkfh "$T/fh_git"; ( cd "$T/fh_git" && clean git init -q && clean git -c user.name=v -c user.email=v@v commit -q --allow-empty -m root )
95
+ out="$(sl "$T/fh_git")"; [ -z "$out" ]; chk $? "L9b session start, clean git FH → no tripwire line"
96
+ ( cd "$T/fh_git" && clean git -c user.name=lane -c user.email=lane@example.invalid commit -q --allow-empty -m base )
97
+ out="$(sl "$T/fh_git")"; printf '%s' "$out" | grep -q 'WARN: 1 commit'; chk $? "L9c session start, lane commit in FH → WARN line (control: the caller does run the tripwire)"
98
+ out="$(GIT_DIR="$T/missing" GIT_COMMON_DIR="$T/missing" HOME="$T/h9" CLAUDE_PROJECT_DIR="$T/fh_git" BE_DIR="$BE9" bash "$LOAD" </dev/null 2>&1 | grep 'LANE-TRIPWIRE')"
99
+ printf '%s' "$out" | grep -q 'WARN: 1 commit'; chk $? "L9d session start with an inherited bogus GIT_DIR → the git-repo probe is not fooled, WARN still prints (codex R1)"
100
+
86
101
  echo "fixture-git-env lanes: $pass passed, $fail failed"
87
102
  [ "$fail" -eq 0 ]
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env bash
2
+ # test_fixture_guard_coverage_lanes.sh — ratchet: every lane that calls git must source
3
+ # fixture_guard_lib.sh BEFORE its first git call.
4
+ #
5
+ # WHY: the lib unsets inherited GIT_DIR / GIT_INDEX_FILE / … at source time (#1088). A lane that calls
6
+ # git without it, run directly from a shell with GIT_DIR exported, commits into (or reads) that repo
7
+ # instead of its fixture. Measured 2026-11-13 on a decoy: 62 of 90 lanes wrote into it under GIT_DIR.
8
+ #
9
+ # RULE (one rule, no writer/reader split): a file matching scripts/test_*.sh or scripts/*_lanes.sh that
10
+ # contains a git invocation must contain a line sourcing fixture_guard_lib.sh, and that line must come
11
+ # before the first git invocation. Readers are included on purpose: under an exported GIT_DIR a
12
+ # read-only lane inspects the wrong repo and reports on it — a wrong answer, not just a leak.
13
+ #
14
+ # SEEN since 2026-11-14: git captured into a variable (`G=$(command -v git)`, `G=/usr/bin/git`) and a
15
+ # guard line inside a heredoc body (not counted). NOT SEEN (named residuals): git reached through
16
+ # indirection the assignment regex does not name (`eval`, arrays, a function wrapping git), and a guard
17
+ # in an unexecuted branch (`if false; then . …; fi`) — the scan reads lines, not control flow.
18
+ # Known over-block (fail-closed, red not green): a quoted `"<<EOF"` in text opens heredoc state, so a
19
+ # real guard right after it is not counted until a line equal to EOF appears. The heredoc tracker is a
20
+ # line scanner, not a shell parser: two codex rounds each found new delimiter shapes (R1 numeric ·
21
+ # multiple; R2 tab strip · `EOF-X`), all fixed with fixtures C15–C17; further shapes are this residual.
22
+ #
23
+ # SUBJECT: the scan below, run over the live scripts/ directory (L-live) and over planted fixtures
24
+ # (calibration). Revert probe: delete the guard line from any one lane → L-live goes red naming it.
25
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
26
+ set -u
27
+ SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
28
+ cd "$(dirname "${BASH_SOURCE[0]}")/.."
29
+ pass=0; fail=0; skipped=0
30
+ sk() { skipped=$((skipped+1)); echo " SKIP $1"; }
31
+ chk() { if [ "$1" -eq 0 ]; then pass=$((pass+1)); echo " PASS $2"; else fail=$((fail+1)); echo " FAIL $2"; fi; }
32
+
33
+ GIT_RE='(^|[^A-Za-z0-9_.-])(/[A-Za-z0-9_./-]*/)?"?git"?[[:space:]]+(-[A-Za-z-]|[a-z])'
34
+ SRC_RE='^[[:space:]]*(\.|source)[[:space:]]+("[^"#]*("[^"#]*"[^"#]*)*fixture_guard_lib\.sh"|[^[:space:]"#]*fixture_guard_lib\.sh)[[:space:]]*(#.*)?$'
35
+
36
+ # git captured into a variable (`G=git`, `G=/usr/bin/git`, `G=$(command -v git)`, `$(which git)`): the
37
+ # assignment line counts as the first git reference, so a lane that only ever runs "$G" is in scope.
38
+ VAR_RE='^[[:space:]]*(export[[:space:]]+|local[[:space:]]+)?[A-Za-z_][A-Za-z0-9_]*=("|'"'"')?((/[A-Za-z0-9_./-]*/)?git|\$\((command -v|which)[[:space:]]+git\))("|'"'"')?([[:space:];]|$)'
39
+ # guard_line <file> → line number of the first guard source line that is NOT inside a heredoc body
40
+ # (a `. …fixture_guard_lib.sh` written into a here-document is data for another file, not a guard here).
41
+ guard_line() {
42
+ SRC_RE="$SRC_RE" awk 'BEGIN { re = ENVIRON["SRC_RE"]; np = 0; qi = 0 }
43
+ qi < np { t = $0; if (dash[qi]) sub(/^\t+/, "", t); if (t == q[qi]) qi++; next }
44
+ /^[[:space:]]*#/ { next }
45
+ $0 ~ re { print NR; exit }
46
+ { l = $0; gsub(/<<</, "", l)
47
+ while (match(l, /<<-?[[:space:]]*[^[:space:]<>|&;()]+/)) {
48
+ tag = substr(l, RSTART, RLENGTH); dash[np] = (tag ~ /^<<-/)
49
+ sub(/^<<-?[[:space:]]*/, "", tag); gsub(/["\047\\]/, "", tag)
50
+ q[np++] = tag; l = substr(l, RSTART + RLENGTH) } }
51
+ ' "$1"
52
+ }
53
+
54
+ # scan <dir> → prints one line per offending file; exit 0 when none, 1 when any, 2 when nothing scanned
55
+ scan() {
56
+ _n=0; _bad=0; _seen=""
57
+ for f in "$1"/test_*.sh "$1"/*_lanes.sh; do
58
+ [ -f "$f" ] || continue
59
+ case "$f" in "$1"/test_*_lanes.sh) case " $_seen " in *" $f "*) continue ;; esac ;; esac
60
+ _seen="${_seen:-} $f"
61
+ case "$f" in */fixture_guard_lib.sh) continue ;; esac
62
+ g="$(grep -nE "$GIT_RE|$VAR_RE" "$f" | grep -vE '^[0-9]+:[[:space:]]*#' | head -1 | cut -d: -f1)"
63
+ [ -n "$g" ] || continue
64
+ _n=$((_n+1))
65
+ s="$(guard_line "$f")"
66
+ if [ -z "$s" ]; then echo "UNGUARDED $f (first git call line $g, no fixture_guard_lib.sh source)"; _bad=$((_bad+1))
67
+ elif [ "$s" -gt "$g" ]; then echo "LATE-GUARD $f (guard line $s after first git call line $g)"; _bad=$((_bad+1)); fi
68
+ done
69
+ echo "SCANNED $_n"
70
+ [ "$_n" -gt 0 ] || return 2
71
+ [ "$_bad" -eq 0 ]
72
+ }
73
+
74
+ T="$(mktemp -d "${TMPDIR:-/tmp}/fgcov.XXXXXX")"; trap 'rm -rf "$T"' EXIT
75
+ GUARD='. "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh"'
76
+
77
+ # ── calibration: planted fixtures ──
78
+ mkdir "$T/c1"; printf '#!/bin/bash\n%s\ngit -C "$d" init -q\n' "$GUARD" > "$T/c1/test_ok_lanes.sh"
79
+ out="$(scan "$T/c1")"; rc=$?; [ "$rc" -eq 0 ]; chk $? "C1 guarded writer → green (rc=$rc)"
80
+ mkdir "$T/c2"; printf '#!/bin/bash\ngit -C "$d" commit -q -m base\n' > "$T/c2/test_w_lanes.sh"
81
+ out="$(scan "$T/c2")"; rc=$?; [ "$rc" -eq 1 ] && printf '%s' "$out" | grep -q 'UNGUARDED.*test_w_lanes'; chk $? "C2 planted unguarded writer → red, named (rc=$rc)"
82
+ mkdir "$T/c3"; printf '#!/bin/bash\nx=$(git log -1 --format=%%h)\n' > "$T/c3/test_r_lanes.sh"
83
+ out="$(scan "$T/c3")"; rc=$?; [ "$rc" -eq 1 ]; chk $? "C3 unguarded read-only lane → red too (rule covers readers) (rc=$rc)"
84
+ mkdir "$T/c4"; printf '#!/bin/bash\ngit -C "$d" init -q\n%s\n' "$GUARD" > "$T/c4/test_late_lanes.sh"
85
+ out="$(scan "$T/c4")"; rc=$?; [ "$rc" -eq 1 ] && printf '%s' "$out" | grep -q LATE-GUARD; chk $? "C4 guard after first git call → red (rc=$rc)"
86
+ mkdir "$T/c5"; printf '#!/bin/bash\n# git commit is only mentioned in a comment\necho digit init\n' > "$T/c5/test_none_lanes.sh"
87
+ out="$(scan "$T/c5")"; rc=$?; [ "$rc" -eq 2 ]; chk $? "C5 no git call anywhere → nothing scanned = rc 2, not a pass (rc=$rc)"
88
+ mkdir "$T/c6"; printf '#!/bin/bash\ngit init -q\n' > "$T/c6/helper.sh"; printf '#!/bin/bash\n%s\ngit status\n' "$GUARD" > "$T/c6/test_x_lanes.sh"
89
+ out="$(scan "$T/c6")"; rc=$?; [ "$rc" -eq 0 ]; chk $? "C6 non-lane script is out of scope (rc=$rc)"
90
+
91
+ mkdir "$T/c7"; printf '#!/bin/bash\n. /dev/null # fixture_guard_lib.sh\ngit -C "$d" commit -q\n' > "$T/c7/test_fake_lanes.sh"
92
+ out="$(scan "$T/c7")"; rc=$?; [ "$rc" -eq 1 ]; chk $? "C7 decoy source line (\`. /dev/null # fixture_guard_lib.sh\`) does not count as a guard (rc=$rc, codex R1)"
93
+ mkdir "$T/c8"; printf '#!/bin/bash\ngit --git-dir="$d/.git" commit -q\n' > "$T/c8/test_gd_lanes.sh"; printf '#!/bin/bash\ngit\tstatus\n' > "$T/c8/test_tab_lanes.sh"
94
+ out="$(scan "$T/c8")"; rc=$?; [ "$rc" -eq 1 ] && [ "$(printf '%s\n' "$out" | grep -c UNGUARDED)" -eq 2 ]; chk $? "C8 \`git --git-dir=…\` and tab-separated git are both seen (rc=$rc, codex R1)"
95
+
96
+ mkdir "$T/c9"; for form in 'git -p status' 'git -C"$d" status' '/usr/bin/git status' '"git" status'; do printf '#!/bin/bash\n%s\n' "$form" > "$T/c9/test_$(printf '%s' "$form" | tr -c 'a-z' _)_lanes.sh"; done
97
+ out="$(scan "$T/c9")"; rc=$?; [ "$rc" -eq 1 ] && [ "$(printf '%s\n' "$out" | grep -c UNGUARDED)" -eq 4 ]; chk $? "C9 git -p · git -C\"…\" · /usr/bin/git · \"git\" are all seen (rc=$rc, codex R2)"
98
+
99
+ # C10: the same file run from a non-git copy (an installed package's shape) must SKIP L-live by name,
100
+ # exit 0, and NOT print a PASS for it. The checkout run below is the opposite arm (L-live measured).
101
+ if [ -z "${FGCOV_INNER:-}" ]; then
102
+ mkdir -p "$T/pkg/scripts"; cp "$SELF" scripts/fixture_guard_lib.sh "$T/pkg/scripts/"
103
+ out="$(cd "$T/pkg" && FGCOV_INNER=1 bash scripts/test_fixture_guard_coverage_lanes.sh 2>&1)"; rc=$?
104
+ [ "$rc" -eq 0 ] && printf '%s\n' "$out" | grep -q '^ SKIP L-live — NOT-APPLICABLE' \
105
+ && ! printf '%s\n' "$out" | grep -q 'PASS L-live' && printf '%s\n' "$out" | grep -q '1 skipped (not a pass)'
106
+ chk $? "C10 non-git tree (installed package) → L-live SKIPPED by name, not red, not counted as pass (rc=$rc)"
107
+ fi
108
+
109
+ mkdir "$T/c11"; printf '#!/bin/bash\nG=$(command -v git)\n"$G" -C "$d" commit -q\n' > "$T/c11/test_var_lanes.sh"; printf '#!/bin/bash\nREALGIT=/usr/bin/git\n"$REALGIT" status\n' > "$T/c11/test_var2_lanes.sh"
110
+ out="$(scan "$T/c11")"; rc=$?; [ "$rc" -eq 1 ] && [ "$(printf '%s\n' "$out" | grep -c UNGUARDED)" -eq 2 ]; chk $? "C11 git only through a variable (\$(command -v git) · /usr/bin/git) is seen (rc=$rc)"
111
+ mkdir "$T/c12"; printf '#!/bin/bash\n%s\nG=$(command -v git)\n"$G" status\n' "$GUARD" > "$T/c12/test_vok_lanes.sh"
112
+ out="$(scan "$T/c12")"; rc=$?; [ "$rc" -eq 0 ]; chk $? "C12 control: guarded variable lane stays green (rc=$rc)"
113
+ mkdir "$T/c13"; printf '#!/bin/bash\ncat > "$d/x.sh" <<EOF\n%s\nEOF\ngit -C "$d" status\n' "$GUARD" > "$T/c13/test_hd_lanes.sh"
114
+ out="$(scan "$T/c13")"; rc=$?; [ "$rc" -eq 1 ] && printf '%s' "$out" | grep -q 'UNGUARDED.*test_hd_lanes'; chk $? "C13 guard line inside a heredoc body does not count (rc=$rc)"
115
+ mkdir "$T/c14"; printf '#!/bin/bash\ncat > "$d/x.sh" <<'"'"'EOF'"'"'\necho hi\nEOF\n%s\ngit -C "$d" status\n' "$GUARD" > "$T/c14/test_hdok_lanes.sh"
116
+ out="$(scan "$T/c14")"; rc=$?; [ "$rc" -eq 0 ]; chk $? "C14 control: heredoc closes, real guard after it counts (rc=$rc)"
117
+
118
+ mkdir "$T/c15"; printf '#!/bin/bash\ncat <<123\n%s\n123\ngit status\n' "$GUARD" > "$T/c15/test_num_lanes.sh"; printf '#!/bin/bash\ncat <<ONE <<TWO\nfirst\nONE\n%s\nTWO\ngit status\n' "$GUARD" > "$T/c15/test_two_lanes.sh"
119
+ out="$(scan "$T/c15")"; rc=$?; [ "$rc" -eq 1 ] && [ "$(printf '%s\n' "$out" | grep -c UNGUARDED)" -eq 2 ]; chk $? "C15 numeric heredoc delimiter and two heredocs on one line are both tracked (rc=$rc, codex R1)"
120
+
121
+ mkdir "$T/c16"; printf '#!/bin/bash\ncat <<EOF\n\tEOF\n%s\nEOF\ngit status\n' "$GUARD" > "$T/c16/test_tab_lanes.sh"; printf '#!/bin/bash\ncat <<EOF-X\nEOF\n%s\nEOF-X\ngit status\n' "$GUARD" > "$T/c16/test_dash_lanes.sh"
122
+ out="$(scan "$T/c16")"; rc=$?; [ "$rc" -eq 1 ] && [ "$(printf '%s\n' "$out" | grep -c UNGUARDED)" -eq 2 ]; chk $? "C16 tab-prefixed terminator closes only <<- heredocs · delimiter EOF-X is not closed by EOF (rc=$rc, codex R2)"
123
+ mkdir "$T/c17"; printf '#!/bin/bash\ncat <<-EOF\n\tbody\n\tEOF\n%s\ngit status\n' "$GUARD" > "$T/c17/test_dok_lanes.sh"
124
+ out="$(scan "$T/c17")"; rc=$?; [ "$rc" -eq 0 ]; chk $? "C17 control: <<- heredoc closed by a tab-indented terminator, guard after it counts (rc=$rc)"
125
+
126
+ # ── live ──
127
+ # The floor 80 is a CHECKOUT number: an installed npm package ships fewer lanes (70 in 3.41.0), so run
128
+ # there the scan is not wrong, it is measuring a different tree. Same test selfcheck uses for package
129
+ # mode (`[ ! -e .git ]`). Non-git → the live lane is SKIPPED by name and the summary says so; it is
130
+ # never counted as a pass. Calibration C1–C9 above still runs — the scanner itself works anywhere.
131
+ if [ ! -e .git ]; then
132
+ sk "L-live — NOT-APPLICABLE: not a git checkout (installed package mode); the floor 80 counts the checkout's lanes. Run in a clone to measure. Not a pass."
133
+ else
134
+ out="$(scan scripts)"; rc=$?
135
+ printf '%s\n' "$out" | grep -vE '^SCANNED' | sed 's/^/ /'
136
+ n="$(printf '%s\n' "$out" | sed -n 's/^SCANNED //p')"
137
+ [ "$rc" -eq 0 ] && [ "${n:-0}" -ge 80 ]; chk $? "L-live every git-calling lane sources the guard first (scanned ${n:-0}, floor 80 — measured 86 on 2026-11-13; a sharp drop means the scan regex broke)"
138
+ fi
139
+
140
+ echo "fixture-guard coverage lanes: $pass passed, $fail failed$( [ "$skipped" -gt 0 ] && printf ', %s skipped (not a pass)' "$skipped")"
141
+ [ "$fail" -eq 0 ]
@@ -9,6 +9,7 @@
9
9
  #
10
10
  # 되돌림 프로브(L10)가 있다: 로케일 차단 줄을 지운 사본에서 판정이 뒤집히지 않으면
11
11
  # 이 레인은 그 줄에 안 묶여 있는 것이다 — 공허한 초록.
12
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
12
13
  set -u
13
14
  SUBJ="$(cd "$(dirname "$0")/.." && pwd)/scripts/gate_bootstrap_ephemeral.sh"
14
15
  [ -f "$SUBJ" ] || { echo "❌ INSTRUMENT ERROR — subject not found: $SUBJ"; exit 10; }
@@ -22,6 +22,7 @@
22
22
  # ADVISORY BY MANDATE, not by preference: the operator's spec for this debt says "표시(차단 아님 —
23
23
  # 정당한 복제도 있다)" — mark, do not block, because legitimate duplication exists.
24
24
 
25
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
25
26
  set -u
26
27
  ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
27
28
  SCAN="$ROOT/scripts/halffix_propagation_scan.sh"
@@ -9,6 +9,7 @@
9
9
  # go red on exactly that fixture — otherwise this file would be green whether or not the fix exists.
10
10
  #
11
11
  # Runs under bash 3.2 (/bin/bash) and bash 5.
12
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
12
13
  set -uo pipefail
13
14
  HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
15
  ROOT="$(cd "$HERE/.." && pwd)"
@@ -30,6 +30,7 @@
30
30
  # back → flagged). A scanner that flags nothing on the positive is a dead instrument → exit 1.
31
31
  # Exit: 0 = all lanes pass · 1 = a lane failed or the instrument/extraction broke.
32
32
 
33
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
33
34
  set -uo pipefail
34
35
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
35
36
  ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # test_lane_gap_hint_lanes.sh — scripts/lane_gap_hint.py (UserPromptSubmit, advisory). G1 is the positive control: a turn
3
3
  # that edited code and ran nothing produces the line; every other lane is a turn that must stay silent, plus exit 0 always.
4
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
4
5
  set -u
5
6
  HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
7
  H="$HERE/lane_gap_hint.py"
@@ -12,6 +12,7 @@
12
12
  #
13
13
  # Script-relative, NOT `git rev-parse --show-toplevel`: in a vendored tree rev-parse returns the
14
14
  # OUTER repo and this suite would then test someone else's checkout.
15
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
15
16
  set -uo pipefail
16
17
  REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
17
18
  CHECK="$REPO_ROOT/scripts/lane_runner_check.sh"
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env bash
2
+ # Lanes for live_eval_trace.py + the behave:/inventory layer in probe_live_eval_lib.score_run (FH-3).
3
+ # Fixtures carry the event keys a real `claude -p --output-format stream-json --verbose` run emits
4
+ # (system/init tools+mcp_servers · assistant message.content[].tool_use · result) — checked against a
5
+ # recorded stream on the author machine; set LIVE_TRACE_REAL=<file.jsonl> to re-check that shape (TR0).
6
+ # TR1 extract: result text + init inventory; a stream with no result event → rc 3 and empty text
7
+ # TR2 the calibration PAIR: «did it» (Read CATALOG.md) PASS/BEHAVIOUR · «said it» (names CATALOG, no call) FAIL
8
+ # TR3 first_read is order: CATALOG.md read second → FAIL
9
+ # TR4 control arm does the action too → UNCALIBRATED (cannot discriminate)
10
+ # TR5 no trace on disk → text verdict kept, scored_by=MENTION-ONLY, counted in mention_only_pass
11
+ # TR6 arms with different tool/MCP lists (82 vs 24) → INVALID-COMPARISON, overall has no pass_rate
12
+ # TR7 a malformed behave: spec → UNCALIBRATED with BAD-BEHAVE, never a silent text-only pass
13
+ # TR8 the runner refuses --trace with --turns (rc 2), never ignores it
14
+ # TR13 ablation_calibrate.sh (direct claude -p measurement path) pins MCP in every arm
15
+ # TR9 revert probe: a scorer without the «said, not done → FAIL» line turns TR2 red
16
+ set -u
17
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
+ LIB="${LIVE_EVAL_LIB_DIR:-$HERE}"
19
+ pass=0; fail=0; ok(){ pass=$((pass+1)); echo " ✅ $1"; }; bad(){ fail=$((fail+1)); echo " ❌ $1"; }
20
+ T="$(mktemp -d)"; trap 'rm -rf "$T"' EXIT
21
+
22
+ python3 "$HERE/live_eval_trace.py" extract /dev/null /dev/null /dev/null >/dev/null 2>&1; [ $? -eq 3 ] \
23
+ && ok "TR0 the shipped file runs by its own path (empty stream → rc 3)" || bad "TR0 direct run"
24
+ if [ -n "${LIVE_TRACE_REAL:-}" ]; then
25
+ r=$(python3 "$HERE/live_eval_trace.py" extract "$LIVE_TRACE_REAL" "$T/real.txt" "$T/real.tools" ; echo "rc=$?")
26
+ grep -q '^tools=.*Read' "$T/real.tools" && [ -s "$T/real.txt" ] && echo " ℹ️ TR0b real stream shape read ($r)" \
27
+ || echo " ⚠️ TR0b real stream NOT read ($r) — fixtures may not match the real shape"
28
+ else
29
+ echo " ℹ️ TR0b real-shape re-check UNMEASURED this run (LIVE_TRACE_REAL unset) — not a pass"
30
+ fi
31
+
32
+ # fixture writer: ev <file> <tools csv> <mcp csv> <result text> [ToolName=path ...]
33
+ cat > "$T/mk.py" <<'PY'
34
+ import json, sys
35
+ f, tools, mcp, res = sys.argv[1:5]
36
+ ev = [{"type": "system", "subtype": "hook_started", "hook_name": "SessionStart"}]
37
+ if tools != "NOINIT":
38
+ ev.append({"type": "system", "subtype": "init", "tools": [t for t in tools.split(",") if t],
39
+ "mcp_servers": [{"name": m.split(":")[0], "status": (m.split(":") + ["connected"])[1]} for m in mcp.split(",") if m]})
40
+ # call forms: Read=path · ERR:Read=path (tool_result is_error) · SUB:Read=path (inside a subagent)
41
+ for n, c in enumerate(sys.argv[5:]):
42
+ flag = ""
43
+ if ":" in c.split("=", 1)[0]:
44
+ flag, c = c.split(":", 1)
45
+ name, p = c.split("=", 1)
46
+ key = "pattern" if name == "Glob" else "file_path" if name == "Read" else "path"
47
+ a = {"type": "assistant", "message": {"content": [{"type": "tool_use", "id": "t%d" % n, "name": name, "input": {key: p}}]}}
48
+ if flag == "SUB":
49
+ a["parent_tool_use_id"] = "task0"
50
+ ev.append(a)
51
+ ev.append({"type": "user", "message": {"content": [{"type": "tool_result", "tool_use_id": "t%d" % n, "is_error": flag == "ERR"}]}})
52
+ ev.append({"type": "result", "subtype": "success", "result": res})
53
+ open(f, "w").write("".join(json.dumps(e, ensure_ascii=False) + "\n" for e in ev))
54
+ PY
55
+ mk(){ python3 "$T/mk.py" "$@"; }
56
+
57
+ mk "$T/a.jsonl" "Read,Grep,Glob" "" "CATALOG says x" Read=CATALOG.md
58
+ python3 "$HERE/live_eval_trace.py" extract "$T/a.jsonl" "$T/a.txt" "$T/a.tools"; xrc=$?
59
+ printf '%s\n' '{"type":"system","subtype":"init","tools":["Read"]}' > "$T/nores.jsonl"
60
+ python3 "$HERE/live_eval_trace.py" extract "$T/nores.jsonl" "$T/n.txt" "$T/n.tools"; nrc=$?
61
+ [ $xrc -eq 0 ] && [ "$(cat "$T/a.txt")" = "CATALOG says x" ] && grep -qx 'tools=Glob,Grep,Read | mcp=' "$T/a.tools" \
62
+ && [ $nrc -eq 3 ] && [ ! -s "$T/n.txt" ] \
63
+ && ok "TR1 extract writes result + inventory; no result event → rc 3, empty text" \
64
+ || bad "TR1 xrc=$xrc nrc=$nrc txt=$(cat "$T/a.txt") tools=$(cat "$T/a.tools")"
65
+
66
+ # run_root builder: build <root> <probe> <reps> <primary-spec|-> <control-spec|-> ; spec = "tools|mcp|text|calls..."
67
+ build(){ local root="$1" pid="$2" reps="$3" ps="$4" cs="$5" i arm spec
68
+ mkdir -p "$root/$pid"
69
+ for i in $(seq 1 "$reps"); do
70
+ for arm in primary control; do
71
+ [ $arm = primary ] && spec="$ps" || spec="$cs"
72
+ IFS='|' read -r tl mc tx calls <<<"$spec"
73
+ printf '%s' "$tx" > "$root/$pid/${arm}_r$i.txt"
74
+ if [ "$tl" != "-" ]; then set -f; mk "$root/$pid/${arm}_r$i.stream.jsonl" "$tl" "$mc" "$tx" $calls; set +f; fi
75
+ done
76
+ done; }
77
+ score(){ python3 - "$LIB" "$1" "$2" "$3" "${4:-}" <<'PY'
78
+ import sys, json; sys.path.insert(0, sys.argv[1]); import probe_live_eval_lib as L
79
+ root, pid, behave, pol = sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5] or 'present'
80
+ spec = {'id': pid, 'polarity': pol, 'expect_re': 'CATALOG'}
81
+ if behave: spec['behave'] = behave
82
+ r = L.score_run([spec], root, [pid], 0.8, 'sonnet', reps=3)
83
+ row = r['rows'][0]
84
+ print(row['verdict'], row['scored_by'], r['overall'], r['pass_rate'], r['mention_only_pass'], r['behaviour_backed'], '|', row['reason'])
85
+ PY
86
+ }
87
+ RT='Read,Grep,Glob'
88
+ build "$T/did" P 3 "$RT||CATALOG has it|Read=CATALOG.md Read=x.md" "$RT||오늘 맑아|"
89
+ build "$T/said" P 3 "$RT||I will read CATALOG.md first|" "$RT||오늘 맑아|"
90
+ d=$(score "$T/did" P 'first_read=CATALOG\.md'); s=$(score "$T/said" P 'first_read=CATALOG\.md')
91
+ [[ "$d" == "PASS BEHAVIOUR PASS 1.0 0 1 "* ]] && [[ "$s" == "FAIL BEHAVIOUR "* ]] \
92
+ && ok "TR2 pair: did → PASS/BEHAVIOUR · said-only → FAIL (same text pattern hits both)" || bad "TR2 did=[$d] said=[$s]"
93
+
94
+ build "$T/order" P 3 "$RT||CATALOG has it|Grep=knowledge Read=CATALOG.md" "$RT||오늘 맑아|"
95
+ o=$(score "$T/order" P 'first_read=CATALOG\.md'); o2=$(score "$T/order" P 'read=CATALOG\.md')
96
+ [[ "$o" == FAIL* ]] && [[ "$o2" == PASS* ]] && ok "TR3 first_read reads order (second → FAIL; read= → PASS)" || bad "TR3 first=[$o] any=[$o2]"
97
+
98
+ build "$T/ctl" P 3 "$RT||CATALOG has it|Read=CATALOG.md" "$RT||오늘 맑아|Read=CATALOG.md"
99
+ c=$(score "$T/ctl" P 'read=CATALOG\.md')
100
+ [[ "$c" == "UNCALIBRATED "* ]] && ok "TR4 control does the action → UNCALIBRATED" || bad "TR4 [$c]"
101
+
102
+ build "$T/old" P 3 "-||CATALOG has it|" "-||오늘 맑아|"
103
+ m=$(score "$T/old" P 'read=CATALOG\.md'); m0=$(score "$T/old" P '')
104
+ [[ "$m" == "PASS MENTION-ONLY PASS 1.0 1 0 "* ]] && [[ "$m0" == "PASS MENTION-ONLY "* ]] \
105
+ && ok "TR5 no trace → text verdict kept, labelled MENTION-ONLY, counted as mention-only" || bad "TR5 [$m] [$m0]"
106
+
107
+ build "$T/inv" P 3 "Read,Grep,Glob|drive,wiki|CATALOG has it|Read=CATALOG.md" "$RT||오늘 맑아|"
108
+ v=$(score "$T/inv" P 'read=CATALOG\.md')
109
+ [[ "$v" == "INVALID-COMPARISON MENTION-ONLY INVALID-COMPARISON None "* || "$v" == "INVALID-COMPARISON BEHAVIOUR INVALID-COMPARISON None "* ]] && [[ "$v" == *"different tool/MCP lists"* ]] \
110
+ && ok "TR6 arms with different tool/MCP lists → INVALID-COMPARISON, no pass_rate" || bad "TR6 [$v]"
111
+
112
+ b=$(score "$T/did" P 'reads=CATALOG')
113
+ [[ "$b" == "UNCALIBRATED "* ]] && [[ "$b" == *BAD-BEHAVE* ]] && ok "TR7 malformed behave: → UNCALIBRATED/BAD-BEHAVE" || bad "TR7 [$b]"
114
+
115
+ tout=$(bash "$HERE/sim_isolated_run.sh" --arm primary --prompt x --trace --turns 'a' 2>&1); trc=$?
116
+ [ $trc -eq 2 ] && [[ "$tout" == *"--trace is single-shot only"* ]] && ok "TR8 runner refuses --trace with --turns (rc 2)" || bad "TR8 rc=$trc $tout"
117
+
118
+ mkdir -p "$T/mut"; cp "$LIB/live_eval_trace.py" "$T/mut/"
119
+ sed 's/^\( *\)v = FAIL # said it, did not do it$/\1pass/' "$LIB/probe_live_eval_lib.py" > "$T/mut/probe_live_eval_lib.py"
120
+ if grep -q 'said it, did not do it' "$T/mut/probe_live_eval_lib.py"; then bad "TR9 mutation did not apply (instrument error, not a pass)"
121
+ else ms=$(LIB="$T/mut" score "$T/said" P 'first_read=CATALOG\.md')
122
+ [[ "$ms" == PASS* ]] && ok "TR9 revert probe: without the line, said-only scores PASS → TR2 would be red" || bad "TR9 mutant still [$ms]"; fi
123
+
124
+ build "$T/deny" P 3 "$RT||CATALOG has it|ERR:Read=CATALOG.md" "$RT||오늘 맑아|"
125
+ build "$T/sub" P 3 "$RT||CATALOG has it|SUB:Read=CATALOG.md Read=x.md" "$RT||오늘 맑아|"
126
+ build "$T/grp" P 3 "$RT||CATALOG has it|Grep=. Glob=CATALOG.md" "$RT||오늘 맑아|"
127
+ dn=$(score "$T/deny" P 'read=CATALOG\.md'); sb=$(score "$T/sub" P 'read=CATALOG\.md'); gp=$(score "$T/grp" P 'read=CATALOG\.md')
128
+ [[ "$dn" == FAIL* ]] && [[ "$sb" == FAIL* ]] && [[ "$gp" == FAIL* ]] \
129
+ && ok "TR10 a failed Read, a subagent's Read, and a Glob/Grep-pattern hit are not «read» (codex R1)" || bad "TR10 deny=[$dn] sub=[$sb] glob=[$gp]"
130
+ build "$T/noinit" P 3 "NOINIT||CATALOG has it|Read=CATALOG.md" "$RT||오늘 맑아|"
131
+ build "$T/mstat" P 3 "$RT|drive:connected|CATALOG has it|Read=CATALOG.md" "$RT|drive:failed|오늘 맑아|"
132
+ ni=$(score "$T/noinit" P 'read=CATALOG\.md'); ms2=$(score "$T/mstat" P 'read=CATALOG\.md')
133
+ [[ "$ni" == INVALID-COMPARISON* ]] && [[ "$ms2" == INVALID-COMPARISON* ]] \
134
+ && ok "TR11 one arm without init, or MCP connected vs failed → INVALID-COMPARISON (codex R1)" || bad "TR11 noinit=[$ni] status=[$ms2]"
135
+ build "$T/half" P 3 "$RT||CATALOG has it|Read=CATALOG.md" "-||오늘 맑아|"
136
+ hf=$(score "$T/half" P 'read=CATALOG\.md')
137
+ [[ "$hf" == UNCALIBRATED* ]] && [[ "$hf" == *TRACE-INCOMPLETE* ]] && ok "TR12 a control arm with no trace while primary has one → UNCALIBRATED, not text-only PASS" || bad "TR12 [$hf]"
138
+
139
+ # TR13 the direct `claude -p` measurement path (not via sim_isolated_run) pins MCP in all three arms.
140
+ # Static check of the argv only — a pin is not proof; the recorded tool list (TR6/TR11) is the defence.
141
+ npin=$(grep -cE '^ (allowlist|denylist|baseline)\) +FLAGS=\(.*--strict-mcp-config' "$HERE/ablation_calibrate.sh")
142
+ [ "$npin" -eq 3 ] && ok "TR13 ablation_calibrate.sh pins MCP (--strict-mcp-config) in all 3 arms" || bad "TR13 pinned arms=$npin/3"
143
+
144
+ [ $pass -eq 14 ] || bad "lane count $pass != 14 — a case did not run"
145
+ echo "live_eval_trace lanes: $pass passed, $fail failed"; [ $fail -eq 0 ]
@@ -13,6 +13,7 @@
13
13
  # H4 FH asset on main + MAIN_COMMIT_OK=1 → override line (channel works through the hook)
14
14
  # REVERT: the hook with the guard call removed must turn H1 red — else H1 is decoration.
15
15
  # Usage: bash scripts/test_main_commit_guard_lanes.sh [--hook <path>]
16
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
16
17
  set -u
17
18
  ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
18
19
  HOOK="$ROOT/templates/.git-hooks/pre-commit"; [ "${1:-}" = "--hook" ] && HOOK="$2"
@@ -25,6 +25,7 @@
25
25
  #
26
26
  # Usage: bash scripts/test_marker_axes_run_lanes.sh Exit: 0 = all fixtures behave; 1 = regression.
27
27
 
28
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
28
29
  set -uo pipefail
29
30
  REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
30
31
  HOOK="$REPO_ROOT/templates/.git-hooks/pre-commit"
@@ -16,6 +16,7 @@
16
16
  #
17
17
  # Usage: bash scripts/test_marker_crossfamily_lanes.sh Exit: 0 = all behave; 1 = regression.
18
18
 
19
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
19
20
  set -uo pipefail
20
21
  # Script-relative, NOT `git rev-parse --show-toplevel`. Measured 2026-08-13 in a vendored tree
21
22
  # (npm install, then `git init` at a level above — a monorepo committing node_modules is the
@@ -14,6 +14,7 @@
14
14
  #
15
15
  # Usage: bash scripts/test_marker_defense_lanes.sh Exit: 0 = all behave; 1 = regression.
16
16
 
17
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
17
18
  set -uo pipefail
18
19
  # Script-relative, NOT `git rev-parse --show-toplevel` — same reason as the sibling lanes: in a
19
20
  # vendored tree rev-parse answers with the OUTER repo and the suite measures somebody else's files.
@@ -13,6 +13,7 @@
13
13
  # the hook function · revert probe: neuter the comparison and the mismatch lane must turn red.
14
14
  #
15
15
  # Usage: bash scripts/test_marker_diff_sha_lanes.sh Exit: 0 = all behave; 1 = regression.
16
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
16
17
  set -uo pipefail
17
18
  REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
18
19
  HOOK="$REPO_ROOT/templates/.git-hooks/pre-commit"
@@ -8,6 +8,7 @@
8
8
  #
9
9
  # Usage: bash scripts/test_marker_floor_lanes.sh Exit: 0 = all fixtures behave; 1 = regression.
10
10
 
11
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
11
12
  set -uo pipefail
12
13
  # Script-relative, NOT `git rev-parse --show-toplevel`. Measured 2026-08-13 in a vendored tree
13
14
  # (npm install, then `git init` at a level above — a monorepo committing node_modules is the
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # test_meta_prompt_restate_lanes.sh — meta-prompt-builder carries the cold-reader restate check.
3
+ # Record-shape only: item 4 of Step 3 names the three fields, the GUESS -> WARN rule, the
4
+ # self-restate exclusion and the NOT RUN rule, and Done When lists it as a mandatory-pass row.
5
+ # Whether a session actually runs it is a blind sim, not this lane.
6
+ # Known-negative in-file: the same check on a copy with item 4 removed must FAIL.
7
+ # exit: 0 PASS · 1 FAIL · 10 harness error
8
+ set -uo pipefail
9
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10
+ F="${1:-$ROOT/plugins/fh-meta/skills/meta-prompt-builder/SKILL.md}"
11
+ [ -f "$F" ] || { echo "harness error: $F missing -- not a pass" >&2; exit 10; }
12
+
13
+ check() { # $1 = file; prints findings, returns 0 if all present
14
+ local f="$1" item4 done_rows rc=0 n
15
+ # item 4 = from its own line to the next numbered item or "Items that fail"
16
+ item4=$(awk '/^4\. \*\*Restate check/{on=1} on && /^Items that fail/{on=0} on' "$f")
17
+ done_rows=$(awk '/^## Done When/{on=1;next} /^## /{on=0} on' "$f")
18
+ for n in 'GOAL' 'DONE' 'CONSTRAINTS' 'RESTATABLE' '`GUESS`' 'brief not restatable' \
19
+ 'Do not tell the reader' 'Restating your own draft yourself does not count' 'NOT RUN'; do
20
+ printf '%s\n' "$item4" | grep -qF -- "$n" || { echo " missing in item 4: $n"; rc=1; }
21
+ done
22
+ printf '%s\n' "$done_rows" | grep -qF 'Step 3 item 4 ran on every draft' \
23
+ || { echo " missing in Done When: item-4 row"; rc=1; }
24
+ return $rc
25
+ }
26
+
27
+ if check "$F"; then echo "PASS: item 4 and its Done When row present"; else echo "FAIL: $F"; exit 1; fi
28
+
29
+ # known-negative: strip item 4 and its Done When row -> must fail
30
+ tmp=$(mktemp) || { echo "harness error: mktemp" >&2; exit 10; }
31
+ trap 'rm -f "$tmp"' EXIT
32
+ awk '/^4\. \*\*Restate check/{skip=1} skip && /^Items that fail/{skip=0} !skip' "$F" \
33
+ | grep -vF 'Step 3 item 4 ran on every draft' > "$tmp"
34
+ if check "$tmp" >/dev/null; then echo "FAIL: control alive check — stripped copy still passed (lane is decorative)"; exit 1; fi
35
+ echo "PASS: control — stripped copy fails"
36
+ exit 0
@@ -18,7 +18,7 @@
18
18
  # the original · setsid escapees · --json only when measured · kernel shebang · mode bits · future
19
19
  # mtime · inode-keyed leftovers) — each lane red on v6.
20
20
  # G7 the v6 generator defect classes, pinned — fail-closed: an uncertain region yields no mutant.
21
- # K0 the /proc process counter used by N6/S7-5, on a known pair, before either trusts it.
21
+ # K0 the process counter used by N6/S7-5 (/proc, or ps on macOS), on a known pair, before either trusts it.
22
22
  #
23
23
  # Exit 0 = all lanes behave · 1 = regression (or an UNMEASURED lane — never folded into PASS).
24
24
  set -uo pipefail
@@ -156,6 +156,9 @@ ibkpath() { python3 -c 'import os,sys;st=os.stat(sys.argv[1]);print("/tmp/mutati
156
156
  sha_of() { python3 -c 'import hashlib,sys;print(hashlib.sha256(open(sys.argv[1],"rb").read()).hexdigest())' "$1"; }
157
157
  procs_matching() { # count live processes whose WHOLE cmdline is $1 — /proc, not pgrep (pgrep absent → vacuous);
158
158
  local n=0 c # exact match, so the counter never counts itself (a substring grep did)
159
+ if [ "$HAVE_PROC" -eq 0 ]; then # macOS: no /proc, but `ps` lists every process's argv — same exact-line rule
160
+ grep -cxF -- "$1" <<<"$(ps -axww -o command= 2>/dev/null)"; return 0
161
+ fi
159
162
  for c in /proc/[0-9]*/cmdline; do [ -e "$c" ] || continue; [ "$(tr '\0' ' ' < "$c" 2>/dev/null)" = "$1 " ] && n=$((n+1)); done
160
163
  echo "$n"
161
164
  }
@@ -171,6 +174,15 @@ procs_matching() { # count live processes whose WHOLE cmdline is $1 — /proc,
171
174
  _PSFX="$$${RANDOM}"
172
175
  TOK_N6="4747.$_PSFX"; TOK_K0="4646.$_PSFX"; TOK_S75="4848.$_PSFX"
173
176
  if [ -d /proc/self ]; then HAVE_PROC=1; else HAVE_PROC=0; fi
177
+ # HAVE_COUNTER (2026-11-14): N6 and K0 used to need /proc, so on macOS they printed UNMEASURED and the
178
+ # suite exited 1 on every local run — a red the author learned to read past (CI on Linux was green).
179
+ # N6 does not need /proc; it needs a process counter. `ps -axww -o command=` is one, and K0/K1 below
180
+ # calibrate whichever counter is in use on a known pair before N6 trusts it. No counter at all is
181
+ # still UNMEASURED (red), never a pass.
182
+ HAVE_COUNTER=0
183
+ if [ "$HAVE_PROC" -eq 1 ]; then HAVE_COUNTER=1; _COUNTER="/proc"
184
+ elif ps -axww -o command= >/dev/null 2>&1; then HAVE_COUNTER=1; _COUNTER="ps"; fi
185
+ NOT_APPLICABLE=0; NA_NAMES=""
174
186
 
175
187
  # B4 — the baseline lane writes its own subject: refuse, and leave the ORIGINAL bytes
176
188
  cp age.sh b4.sh; h0=$(sha_of b4.sh)
@@ -242,10 +254,10 @@ printf '. ./n1.sh\nis_adult 19 && exit 0\n( touch n6.started; exec sleep %s ) &\
242
254
  rm -f n6.started
243
255
  out=$(python3 "$PROBE" n1.sh lane_n6.sh --timeout 2 2>&1)
244
256
  sleep 0.5
245
- if [ "$HAVE_PROC" -eq 1 ]; then
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)"
257
+ if [ "$HAVE_COUNTER" -eq 1 ]; then
258
+ [ -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 $_COUNTER, calibrated by K0 — v6 used pgrep, vacuous when absent)"
247
259
  else
248
- echo " ⚠️ N6 UNMEASURED — no /proc"; UNMEASURED=$((UNMEASURED+1))
260
+ echo " ⚠️ N6 UNMEASURED — no process counter (/proc absent and ps failed)"; UNMEASURED=$((UNMEASURED+1))
249
261
  fi
250
262
 
251
263
  # N2 · N3 · N7 — generator noise
@@ -564,9 +576,9 @@ printf '#!/bin/sh\n[ "$a" != b ] && echo d\n[ "$c" = d ] && echo e\n' > z28.sh
564
576
  out=$(python3 "$PROBE" z28.sh --list 2>&1)
565
577
  ! grep -qF '==' <<<"$out" && grep -qF '[=→!=]' <<<"$out" ; chk $? "Z28 #!/bin/sh: '!=' is not flipped to the non-POSIX '==' (= → != still is)"
566
578
 
567
- if [ "$HAVE_PROC" -eq 1 ]; then # the process counter itself, on a known pair, before any lane trusts it
579
+ if [ "$HAVE_COUNTER" -eq 1 ]; then # the process counter itself, on a known pair, before any lane trusts it
568
580
  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")
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"
581
+ [ "$k1" -eq 1 ] && [ "$k0" -eq 0 ] ; chk $? "K0 the process counter ($_COUNTER) sees a live sleep (1) and not a dead one (0) — and not itself"
570
582
  # K1 (2026-10-26) — the token must be unique to this run, not merely exact. Known pair against a
571
583
  # live FOREIGN process carrying the old shared name: the thing a concurrent sibling used to be.
572
584
  sleep 4747 & kf=$!; sleep 0.1
@@ -615,6 +627,13 @@ if [ "$HAVE_PROC" -eq 1 ] && command -v setsid >/dev/null 2>&1; then
615
627
  out=$(python3 "$PROBE" s75.sh lane_s75.sh --timeout 30 2>&1)
616
628
  sleep 0.3
617
629
  [ -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)"
630
+ elif [ "$(uname -s)" != Linux ]; then
631
+ # NOT-APPLICABLE, not UNMEASURED: the subject itself declares this behaviour Linux-only
632
+ # (mutation_probe.py: PR_SET_CHILD_SUBREAPER; elsewhere it prints «no subreaper on this OS … named
633
+ # residual»). There is no contract here to measure. On Linux a missing /proc or setsid is still
634
+ # UNMEASURED and red — the platform is the oracle, not the tool's absence.
635
+ echo " ⏭️ S7-5 NOT-APPLICABLE on $(uname -s) — setsid-escapee kill is Linux-only by the probe's own contract (CI measures it)"
636
+ NOT_APPLICABLE=$((NOT_APPLICABLE+1)); NA_NAMES="$NA_NAMES S7-5"
618
637
  else
619
638
  echo " ⚠️ S7-5 UNMEASURED — no /proc or no setsid"; UNMEASURED=$((UNMEASURED+1))
620
639
  fi
@@ -856,5 +875,6 @@ grep -q '\[>→>=\] cmd >= out.txt' <<<"$out" ; chk $? "RV2 without the (( )) re
856
875
 
857
876
  echo ""
858
877
  if [ "$FAILED" -eq 0 ] && [ "$UNMEASURED" -gt 0 ]; then echo "INCOMPLETE mutation probe: $PASS lanes passed, $UNMEASURED UNMEASURED — not a pass"; exit 1; fi
878
+ if [ "$FAILED" -eq 0 ] && [ "$NOT_APPLICABLE" -gt 0 ]; then echo "PASS mutation probe: $PASS lanes · $NOT_APPLICABLE NOT-APPLICABLE on $(uname -s) ($NA_NAMES ) — not measured here, not counted as passed"; exit 0; fi
859
879
  if [ "$FAILED" -eq 0 ]; then echo "PASS mutation probe: $PASS lanes"; exit 0; fi
860
880
  echo "FAIL mutation probe"; exit 1
@@ -12,6 +12,7 @@
12
12
  # B4 behaviour: /bin/bash + ko_KR.UTF-8 runs the pr_merge_verified lanes (lease path S1–S3)
13
13
  # to rc 0 with no "unbound variable" — only where that locale exists, else a named SKIP
14
14
  # (a SKIP is not a pass). B4c checks the locale really triggers the defect (control).
15
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
15
16
  set -uo pipefail
16
17
  cd "$(dirname "$0")/.." || exit 2
17
18
  SCAN=scripts/shell_name_boundary_scan.sh
@@ -12,6 +12,7 @@
12
12
  # empty-record branch, a different path) and anchor its skeleton with a second revert probe.
13
13
  # L17/L17b are the WIRING arms: the snippet must register this hook, and the gate must finish
14
14
  # inside the timeout the snippet configures — a hook killed by its own timeout is fail-OPEN.
15
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
15
16
  set -uo pipefail
16
17
  HERE="$(cd "$(dirname "$0")" && pwd)"
17
18
  REPO="$(cd "$HERE/.." && pwd)"
@@ -25,6 +25,7 @@
25
25
  # UNCALIBRATED and printed in the summary, and exit stays 0. Stated precisely because the
26
26
  # earlier wording promised more than the code delivers, and an exit contract that overstates
27
27
  # is exactly the false-clean this suite exists to prevent (round-3 review, LOW).
28
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
28
29
  set -uo pipefail
29
30
 
30
31
  REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -18,6 +18,7 @@
18
18
  # trains skimming past the lines that matter)
19
19
  # A lane that only asserts the positive would pass on a script that flags literally everything.
20
20
 
21
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
21
22
  set -uo pipefail
22
23
  cd "$(dirname "$0")/.." || exit 1
23
24
  REPO_ROOT="$(pwd -P)"
@@ -25,6 +25,7 @@
25
25
  # reads. Shipping S6 would have been a 0-true-positive probe — exactly the failure S5's own
26
26
  # comment records ("100% FP trains dismissal of the one hit that will matter").
27
27
 
28
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
28
29
  set -u
29
30
  G="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/pipe_verdict_guard.sh"
30
31
  pass=0; fail=0
@@ -7,6 +7,7 @@
7
7
  # plus: trivial ② refused (rc=3) · failing ② (rc=1) · silent ② (rc=4) · a path main ALSO changed is
8
8
  # COMBINED, not DIFFERS · an extra path in the squash is 🟥 EXTRA · the caller's HEAD is untouched.
9
9
  # Every fixture is a throwaway repo built here (portable; no dependency on this repo's history).
10
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
10
11
  set -uo pipefail
11
12
  cd "$(dirname "$0")/.."
12
13
  SC="$PWD/scripts/post_squash_verify.sh"