@chrono-meta/fh-gate 3.39.1 → 3.40.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 (46) hide show
  1. package/.claude/regression/probes_live.yaml +9 -2
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/CLAUDE.md +2 -2
  4. package/README.ja.md +20 -18
  5. package/README.zh.md +20 -18
  6. package/knowledge/shared/harness-core/claude_md_full_reference.md +8 -1
  7. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
  8. package/knowledge/shared/harness-core/fh_module_contract.md +55 -1
  9. package/knowledge/shared/harness-core/lease_record_channel.md +26 -2
  10. package/knowledge/shared/harness-core/onboarding_acceleration_autopilot.md +7 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
  12. package/knowledge/shared/rules/operations.md +1 -0
  13. package/package.json +10 -1
  14. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  16. package/plugins/fh-meta/CHANGELOG.md +35 -0
  17. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  19. package/scripts/agent_tools_pin.txt +16 -0
  20. package/scripts/catch_tally.py +215 -0
  21. package/scripts/claim_precision_report.py +138 -0
  22. package/scripts/fh_module_check.py +182 -1
  23. package/scripts/generated_harness_check.py +4 -0
  24. package/scripts/package_coverage_check.sh +5 -0
  25. package/scripts/post_squash_verify.sh +53 -1
  26. package/scripts/pr_merge_verified.sh +56 -0
  27. package/scripts/probe_live_eval.sh +61 -0
  28. package/scripts/probe_live_eval_lib.py +47 -4
  29. package/scripts/selfcheck.sh +5 -0
  30. package/scripts/selfdev_merge_tier.sh +153 -0
  31. package/scripts/session_checklist.py +38 -1
  32. package/scripts/session_close_check.sh +67 -1
  33. package/scripts/sim_isolated_run.sh +62 -1
  34. package/scripts/test_agent_tools_pin_lanes.sh +73 -0
  35. package/scripts/test_catch_tally_lanes.sh +10 -0
  36. package/scripts/test_claim_precision_report_lanes.sh +77 -0
  37. package/scripts/test_fh_module_check_lanes.sh +106 -1
  38. package/scripts/test_generated_harness_check_lanes.sh +8 -0
  39. package/scripts/test_post_squash_verify_lanes.sh +23 -2
  40. package/scripts/test_pr_merge_verified_lanes.sh +55 -3
  41. package/scripts/test_probe_live_eval_lanes.sh +160 -5
  42. package/scripts/test_selfdev_merge_tier_lanes.sh +128 -0
  43. package/scripts/test_session_checklist_lanes.sh +57 -0
  44. package/scripts/test_session_close_chain_lanes.sh +93 -0
  45. package/scripts/test_sim_isolated_run_lanes.sh +67 -0
  46. package/templates/harness_birth_core.md +57 -0
@@ -17,7 +17,7 @@ set -uo pipefail
17
17
 
18
18
  # 상속된 git 환경변수를 끊는다 — export 된 GIT_DIR 이 있으면 `git -C "$FH"` 가 인자로 받은
19
19
  # 레포가 아니라 그 레포를 잰다(Axis 2 at-floor LOW, 2026-08-06). READ-ONLY 체커라 부작용 없음.
20
- unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
20
+ unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR # GIT_COMMON_DIR: ①-r would read another repo's receipts (codex R2, 2026-11-08)
21
21
  FH="${1:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
22
22
  TODAY=$(date +%Y-%m-%d)
23
23
  CARD="$FH/tracks/_meta/reference_next_session_starter.md"
@@ -122,6 +122,72 @@ if command -v gh >/dev/null 2>&1; then
122
122
  [ "${PRS:-0}" -gt 0 ] && echo "⚠️ ①-b $PRS open PR(s) by you — classify: self-mergeable vs awaiting-external"
123
123
  fi
124
124
 
125
+ # ①-r MERGE RECEIPTS — report only («advisory, does not block»; rc unchanged). `pr_merge_verified.sh` appends one
126
+ # JSON line per merge to <git-common-dir>/fh-merge-receipts.jsonl (or $PMV_RECEIPTS), but nothing at close read it:
127
+ # FH #1057 merged with `verify-incomplete` and only a hand check found it (2026-11-08 harvest H2). The flagged set is
128
+ # «last outcome is NOT `verified`» — never an enumerated list, so a new outcome name is shown, not passed. «Last» is
129
+ # FILE order (append order), not the `at` string. Only THIS repo's file is read: receipts carry no repo field and PR
130
+ # numbers collide across repos. Absent/empty file = UNMEASURED, never «all verified». Malformed lines are counted.
131
+ # Only the last FH_RECEIPT_WINDOW_DAYS (default 7) days are named; older ones are counted on their own line.
132
+ # Anchored by scripts/test_session_close_chain_lanes.sh lanes ①-r-*.
133
+ RCPT="${PMV_RECEIPTS:-}"
134
+ if [ -z "$RCPT" ]; then
135
+ _gcd=$(git -C "$FH" rev-parse --path-format=absolute --git-common-dir 2>/dev/null) || _gcd=""
136
+ [ -n "$_gcd" ] && RCPT="$_gcd/fh-merge-receipts.jsonl"
137
+ fi
138
+ if [ -z "$RCPT" ] || [ ! -s "$RCPT" ]; then
139
+ echo "ℹ️ ①-r receipts: none/UNMEASURED (${RCPT:-no git dir}) — advisory, does not block"
140
+ elif ! command -v python3 >/dev/null 2>&1; then
141
+ echo "ℹ️ ①-r receipts: UNMEASURED — python3 not found ($RCPT) — advisory, does not block"
142
+ else
143
+ python3 - "$RCPT" <<'PYEOF' || echo "ℹ️ ①-r receipts: UNMEASURED — reader failed ($RCPT) — advisory, does not block"
144
+ import json, sys
145
+ path = sys.argv[1]
146
+ last, bad, total = {}, 0, 0
147
+ with open(path, encoding="utf-8", errors="replace") as f:
148
+ for raw in f:
149
+ if not raw.strip():
150
+ continue
151
+ total += 1
152
+ try:
153
+ d = json.loads(raw)
154
+ pr, out = d["pr"], d["outcome"]
155
+ if isinstance(pr, bool) or not isinstance(pr, int) or not isinstance(out, str) or not out:
156
+ raise ValueError
157
+ except Exception:
158
+ bad += 1
159
+ continue
160
+ at = d.get("at")
161
+ last[pr] = (out, at if isinstance(at, str) and at else "?") # file order: a later line replaces an earlier one
162
+ if total == 0: # whitespace-only file: nothing was read — UNMEASURED, never an all-clear (codex R1)
163
+ print("ℹ️ ①-r receipts: none/UNMEASURED (%s holds no receipt line) — advisory, does not block" % path)
164
+ sys.exit(0)
165
+ flagged = sorted((pr, o, at) for pr, (o, at) in last.items() if o != "verified")
166
+ # window (operator 2026-11-08 «판단후추천대로»): name only receipts from the last N days (default 7 = the weekly-audit
167
+ # cycle) so the same old PRs do not repeat at every close until nobody reads the line. Older ones are COUNTED, never
168
+ # dropped silently. A receipt whose `at` has no readable date is treated as recent (shown). N=0 shows everything.
169
+ import datetime, os, re
170
+ try:
171
+ days = int(os.environ.get("FH_RECEIPT_WINDOW_DAYS", "7"))
172
+ except ValueError:
173
+ days = 7
174
+ cutoff = (datetime.date.today() - datetime.timedelta(days=days)).isoformat() if days > 0 else None
175
+ def _recent(at):
176
+ return cutoff is None or not re.match(r"\d{4}-\d{2}-\d{2}", at) or at[:10] >= cutoff
177
+ shown = [f for f in flagged if _recent(f[2])]
178
+ older = len(flagged) - len(shown)
179
+ if shown:
180
+ items = " · ".join("#%d %s (%s)" % (pr, o, at[:10]) for pr, o, at in shown)
181
+ print("⚠️ ①-r %d PR(s) whose last merge receipt is not «verified»: %s — read each; advisory, does not block" % (len(shown), items))
182
+ if older:
183
+ print("ℹ️ ①-r %d older PR(s) (> %d days) whose last receipt is not «verified» — not named here; FH_RECEIPT_WINDOW_DAYS=0 lists all" % (older, days))
184
+ if bad:
185
+ print("⚠️ ①-r %d malformed receipt line(s) of %d in %s — those merges are UNMEASURED; advisory, does not block" % (bad, total, path))
186
+ if not flagged and not bad:
187
+ print("✅ ①-r merge receipts: last outcome «verified» for all %d PR(s) (%s)" % (len(last), path))
188
+ PYEOF
189
+ fi
190
+
125
191
  # ── ①-d CLOSE RE-OPENED? ──────────────────────────────────────────────────────
126
192
  # WHY: a session that closed cleanly and then kept working looks IDENTICAL to one that never
127
193
  # closed — both read Completed from outside, and ①-c cannot separate them. Measured 2026-08-09:
@@ -315,6 +315,8 @@ _PYEOF
315
315
  BASE_REF=""; BASE_SHA=""
316
316
  ARM=""; REPS=1; PROMPT=""; MODE="observe"; MODEL="sonnet"; TIMEOUT=900; OUTDIR=""; NOHARNESS=0; SETUP=""; EXTRA=""
317
317
  TURNS=""; NORESUME=0
318
+ SETSRC=""; SETFILE=""; PERMMODE=""; ADDWRAP=0 # §CONSUMER SURFACE — never inherited from the env (codex R1)
319
+ _needval() { [ "$#" -ge 2 ] || { echo "FAIL: $1 needs a value" >&2; exit 2; }; }
318
320
  while [ $# -gt 0 ]; do
319
321
  case "$1" in
320
322
  --arm) ARM="${2:-}"; shift 2 ;;
@@ -332,9 +334,56 @@ while [ $# -gt 0 ]; do
332
334
  --mcp-config) MCPCFG="${2:-}"; shift 2 ;; # the ONLY MCP servers an arm may see (see MCP ISOLATION). Default: none.
333
335
  --turns) TURNS="${2:-}"; shift 2 ;; # MULTI-TURN: one turn per line. See §MULTI-TURN.
334
336
  --no-resume) NORESUME=1; shift ;; # CONTROL arm for --turns:each turn is a fresh session. See §MULTI-TURN.
337
+ --setting-sources) _needval "$@"; SETSRC="$2"; [ -n "$SETSRC" ] || { echo "FAIL: --setting-sources is empty" >&2; exit 2; }; shift 2 ;; # §CONSUMER SURFACE — e.g. project,local
338
+ --settings) _needval "$@"; SETFILE="$2"; [ -n "$SETFILE" ] || { echo "FAIL: --settings is empty" >&2; exit 2; }; shift 2 ;; # §CONSUMER SURFACE — permission file
339
+ --permission-mode) _needval "$@"; PERMMODE="$2"
340
+ case "$PERMMODE" in default|acceptEdits|plan) ;; *) echo "FAIL: --permission-mode '$PERMMODE' refused — only default|acceptEdits|plan (an unattended arm must not bypass the runner's deny rules)" >&2; exit 2 ;; esac
341
+ shift 2 ;;
342
+ --add-wrapper-dir) ADDWRAP=1; shift ;; # §CONSUMER SURFACE — the rep's own wrapper (clone + siblings)
335
343
  *) echo "unknown flag: $1" >&2; exit 2 ;;
336
344
  esac
337
345
  done
346
+ # ── §CONSUMER SURFACE (2026-11-10, AQ-20261110-6) ───────────────────────────────────────────
347
+ # WHY: the blind harness-birth test (branch claude/blind-birth-test-092883, its fixtures folder
348
+ # blind_birth_2026-11-10 — not on main when this landed) needed an arm that
349
+ # looks like a CONSUMER install, and the runner could not express one:
350
+ # · user-scope settings (the operator's own plugins and hooks) load into every non-restricted
351
+ # arm — so an "FH arm" measured FH + whatever this operator installed, and a "bare" arm could
352
+ # not be made bare without `--no-harness`;
353
+ # · `--no-harness` (= --restricted) kills act-mode writes (see the header), and plain act mode
354
+ # cannot reach a sibling project folder next to the clone.
355
+ # The test ran through a PATH shim that appended these four flags. This section makes the shim
356
+ # unnecessary. Known pair, 2026-11-10: with `--setting-sources project,local` the FH clone still
357
+ # answers «yes, the 🐿️ greeting rule» (project memory kept) and an emptied clone answers «no»;
358
+ # neither lists any user-scope `fh-` skill.
359
+ # 🟥 ALL FOUR ARE OPT-IN. With none given, the argv handed to `claude` is byte-identical to before
360
+ # (lane L31a). `--permission-mode bypassPermissions` is REFUSED: an unattended arm that can bypass
361
+ # the deny rules this runner writes is not isolated, and the auto-mode classifier refused the same
362
+ # shape when it was tried by hand. Only default|acceptEdits|plan pass.
363
+ # 🟥 RESIDUAL, named: headless arms still cannot write under `<project>/.claude/` even with an explicit
364
+ # allow — the platform treats it as sensitive and wants a human. Not fixable here; score what the
365
+ # arm wrote, and record how it reacted to the block.
366
+ # 🟥 PILOT THE HELD-OUT TASK ON A BARE ARM FIRST. In the same test the stage-2 task hit the ceiling:
367
+ # an arm with NO harness found the planted false claim 6/6 and held the publish script 6/6, so the
368
+ # task could not tell a harness from none. Before registering a task, run it once on an emptied
369
+ # clone (no harness); if that arm already passes, the task measures nothing — pick a harder one.
370
+ # A same-model-authored trap is the usual cause (the cartridge rounds saw it six times).
371
+ SURF=()
372
+ if [ -n "$SETSRC" ]; then
373
+ # Validate the exact string that is forwarded, not a shell-split copy of it (codex R2).
374
+ printf '%s' "$SETSRC" | grep -qE '^(user|project|local)(,(user|project|local))*$' \
375
+ || { echo "FAIL: --setting-sources takes a comma list of user|project|local, got '$SETSRC'" >&2; exit 2; }
376
+ # 🟥 `local` is REQUIRED: the runner's isolation deny rules live in the clone's local settings
377
+ # file — a source list without `local` silently drops them (codex R2).
378
+ case ",$SETSRC," in *,local,*) ;; *) echo "FAIL: --setting-sources must include 'local' — the runner's isolation deny rules are a local settings file" >&2; exit 2 ;; esac
379
+ SURF+=(--setting-sources "$SETSRC")
380
+ fi
381
+ if [ -n "$SETFILE" ]; then
382
+ [ -f "$SETFILE" ] || { echo "FAIL: --settings file not found: $SETFILE" >&2; exit 2; }
383
+ SETFILE="$(cd "$(dirname "$SETFILE")" && pwd)/$(basename "$SETFILE")"
384
+ SURF+=(--settings "$SETFILE")
385
+ fi
386
+ [ -n "$PERMMODE" ] && SURF+=(--permission-mode "$PERMMODE") # validated in the parser (empty refused there)
338
387
  [ -n "$ARM" ] || { echo "FAIL: --arm required" >&2; exit 2; }
339
388
  [ -n "$PROMPT" ] || [ -n "$TURNS" ] || { echo "FAIL: --prompt or --turns required" >&2; exit 2; }
340
389
  case "$MODE" in observe|act) ;; *) echo "FAIL: --mode must be observe|act" >&2; exit 2 ;; esac
@@ -409,6 +458,7 @@ fh_run_turns() {
409
458
  if [ -n "$_sid" ] && [ "$NORESUME" -eq 0 ]; then _resume=(--resume "$_sid"); fi
410
459
  ( cd "$WORK" && fh_timeout "$TIMEOUT" claude -p "$_t" \
411
460
  --model "$MODEL" "${TOOLS[@]}" ${MCPARGS[@]+"${MCPARGS[@]}"} \
461
+ ${SURFREP[@]+"${SURFREP[@]}"} \
412
462
  ${_resume[@]+"${_resume[@]}"} --output-format json \
413
463
  < /dev/null 2>"${_tf}.stderr.txt" ) > "${_tf}.json"
414
464
  _rc=$?; _lastrc=$_rc
@@ -810,7 +860,10 @@ for r in $(seq 1 "$REPS"); do
810
860
  # = "only the servers given by --mcp-config" (CLI --help), and with no --mcp-config that is
811
861
  # NONE. An arm that legitimately needs a server (e.g. Playwright for a web target) gets it
812
862
  # explicitly via --mcp-config <file inside the clone>; nothing is inherited.
813
- MCPARGS=(--strict-mcp-config); [ -n "${MCPCFG:-}" ] && MCPARGS+=(--mcp-config "$MCPCFG") # bash 3.2 + set -u: expanded with the ${a[@]+"${a[@]}"} idiom below
863
+ MCPARGS=(--strict-mcp-config); [ -n "${MCPCFG:-}" ] && MCPARGS+=(--mcp-config "$MCPCFG")
864
+ # §CONSUMER SURFACE — per-rep copy: the wrapper dir differs per rep. Empty unless opted in.
865
+ SURFREP=(${SURF[@]+"${SURF[@]}"}); [ "$ADDWRAP" -eq 1 ] && SURFREP+=(--add-dir "$WRAP") # bash 3.2 + set -u: expanded with the ${a[@]+"${a[@]}"} idiom below
866
+ _wall_t0=$(date +%s) # COST AXIS (2026-11-12): wall seconds per episode, record only — never scored
814
867
  if [ -n "$TURNS" ]; then
815
868
  # §MULTI-TURN — the single-shot branch below is left byte-identical on purpose: `--turns`
816
869
  # adds a path, it does not modify the one every existing probe already runs on.
@@ -819,9 +872,16 @@ for r in $(seq 1 "$REPS"); do
819
872
  else
820
873
  ( cd "$WORK" && fh_timeout "$TIMEOUT" claude -p "$PROMPT" \
821
874
  --model "$MODEL" "${TOOLS[@]}" ${MCPARGS[@]+"${MCPARGS[@]}"} \
875
+ ${SURFREP[@]+"${SURFREP[@]}"} \
822
876
  < /dev/null 2>"$OUTDIR/${ARM}_r${r}.stderr.txt" ) > "$OUTDIR/${ARM}_r${r}.txt"
823
877
  rc=$?
824
878
  fi
879
+ # A failed clock read must not become 0 or an epoch-sized number (codex R1): both reads digits,
880
+ # delta >= 0, else UNMEASURED. Residual: a wall-clock step during the episode is not detected.
881
+ _wall_t1=$(date +%s)
882
+ case "$_wall_t0$_wall_t1" in (''|*[!0-9]*) _wall_s=UNMEASURED ;;
883
+ (*) if [ -n "$_wall_t0" ] && [ -n "$_wall_t1" ] && [ "$_wall_t1" -ge "$_wall_t0" ]; then
884
+ _wall_s=$((_wall_t1 - _wall_t0)); else _wall_s=UNMEASURED; fi ;; esac
825
885
  bytes=$(wc -c < "$OUTDIR/${ARM}_r${r}.txt" | tr -d ' ')
826
886
 
827
887
  # ── BUDGET LINE (2026-10-17) — which cap this episode ran under, and did it END at that cap. ──
@@ -849,6 +909,7 @@ for r in $(seq 1 "$REPS"); do
849
909
  printf 'max_turns\t%s\n' "$_cap_turns"
850
910
  printf 'token_cap\t%s\n' "$_cap_tokens"
851
911
  printf 'ended_at_cap\t%s\n' "$_cap_end"
912
+ printf 'wall_s\t%s\n' "$_wall_s"
852
913
  } >> "$OUTDIR/${ARM}_r${r}.meta.tsv"
853
914
 
854
915
  # 🟥 An empty output is NOT a "no" answer. The first version of tonight's runner used
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # Pin each agent definition's `tools:` restriction against scripts/agent_tools_pin.txt.
3
+ # Origin: digest 2026-11-11 (arXiv:2611.09895, «restriction silently deleted» mutant). Measured that
4
+ # day: deleting all 14 `tools:` lines left validate_yaml and the whole selfcheck unchanged — the
5
+ # restrictions were held by prose only. This lane asserts a property of the record (present and equal
6
+ # to the declared value), not whether the restriction is right.
7
+ # T1 every declared file exists and its `tools:` line equals the declared value
8
+ # T2 every agent file under plugins/*/agents and .claude/agents that has a `tools:` line is declared
9
+ # K1-K3 known pair on a temp copy: deletion / widening / undeclared new agent → red; untouched → green
10
+ set -u
11
+ ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
12
+ PIN="$ROOT/scripts/agent_tools_pin.txt"
13
+
14
+ # `tools:` read from the YAML frontmatter only (between the first two `---` lines) — a body line that
15
+ # happens to say «tools: Read» is not a restriction (codex R1).
16
+ fm_tools() { awk 'NR==1 && $0=="---" {f=1; next} f && $0=="---" {exit} f && /^tools:/ {sub(/^tools: */, ""); print; exit}' "$1"; }
17
+
18
+ check() { # $1 = repo root; prints problems, returns count via rc (capped)
19
+ local root="$1" pin="$1/scripts/agent_tools_pin.txt" n=0 f want got
20
+ [ -f "$pin" ] || { echo " pin list missing: $pin"; return 1; }
21
+ while IFS='|' read -r f want || [ -n "$f" ]; do
22
+ case "$f" in ''|\#*) continue ;; esac
23
+ if [ ! -f "$root/$f" ]; then echo " declared but missing: $f"; n=$((n+1)); continue; fi
24
+ got="$(fm_tools "$root/$f")"
25
+ if [ -z "$got" ]; then echo " tools: line deleted: $f (declared: $want)"; n=$((n+1))
26
+ elif [ "$got" != "$want" ]; then echo " tools: changed: $f «$got» (declared: «$want»)"; n=$((n+1)); fi
27
+ done < "$pin"
28
+ local found frc d dirs=()
29
+ # .claude/agents may legitimately not exist — only existing roots go to find, so any find error
30
+ # (GNU quotes paths ‘…’, BSD does not — a message-text filter broke on CI) is an incomplete measurement.
31
+ for d in "$root/plugins" "$root/.claude/agents"; do [ -d "$d" ] && dirs+=("$d"); done
32
+ [ "${#dirs[@]}" -gt 0 ] || { echo " discovery incomplete (no agent roots) — not measured"; return 1; }
33
+ found="$(find "${dirs[@]}" -path '*agents*' -name '*.md' -type f 2>&1)"; frc=$?
34
+ if [ "$frc" -ne 0 ]; then echo " discovery incomplete (find rc=$frc) — not measured"; n=$((n+1)); fi
35
+ while IFS= read -r f; do
36
+ case "$f" in find:*|'') continue ;; esac
37
+ rel="${f#"$root"/}"
38
+ [ -n "$(fm_tools "$f")" ] || continue
39
+ grep -q "^$rel|" "$pin" || { echo " undeclared tools: line: $rel"; n=$((n+1)); }
40
+ done <<< "$found"
41
+ [ "$n" -eq 0 ]
42
+ }
43
+
44
+ fail=0
45
+ declared=$(grep -cvE '^(#|$)' "$PIN" 2>/dev/null); declared=${declared:-0}
46
+ if [ "$declared" -eq 0 ]; then echo " ❌ T0 pin list empty or missing — nothing measured"; fail=1
47
+ elif out="$(check "$ROOT")"; then echo " ✅ T1/T2 $declared declared tools: lines present, unchanged, none undeclared"
48
+ else echo "$out"; echo " ❌ T1/T2 tools: pin drift"; fail=1; fi
49
+
50
+ # Known pair on a temp copy of just the files involved.
51
+ T="$(mktemp -d "${TMPDIR:-/tmp}/atp.XXXXXX")"; trap 'rm -rf "$T"' EXIT
52
+ mk() { rm -rf "$T/r"; mkdir -p "$T/r/scripts"; cp "$PIN" "$T/r/scripts/"
53
+ ( cd "$ROOT" && find plugins .claude/agents -path '*agents*' -name '*.md' -type f 2>/dev/null ) \
54
+ | while IFS= read -r f; do mkdir -p "$T/r/$(dirname "$f")"; cp "$ROOT/$f" "$T/r/$f"; done; }
55
+ first="$(grep -vE '^(#|$)' "$PIN" | head -1 | cut -d'|' -f1)"
56
+ mk; check "$T/r" >/dev/null && echo " ✅ K0 untouched copy green (control)" || { echo " ❌ K0 control red"; fail=1; }
57
+ mk; sed -i.bak '/^tools:/d' "$T/r/$first"
58
+ check "$T/r" >/dev/null && { echo " ❌ K1 deletion not caught"; fail=1; } || echo " ✅ K1 deleted restriction → red"
59
+ mk; sed -i.bak 's/^tools: .*/&, Bash/' "$T/r/$first"
60
+ check "$T/r" >/dev/null && { echo " ❌ K2 widening not caught"; fail=1; } || echo " ✅ K2 widened restriction (+Bash) → red"
61
+ mk; mkdir -p "$T/r/plugins/zz/agents"; printf -- '---\nname: x\ntools: Read\n---\n' > "$T/r/plugins/zz/agents/x.md"
62
+ check "$T/r" >/dev/null && { echo " ❌ K3 undeclared agent not caught"; fail=1; } || echo " ✅ K3 undeclared new tools: line → red"
63
+
64
+ # K4 frontmatter restriction deleted, same text left in the body → still red (codex R1)
65
+ mk; awk 'BEGIN{d=0} /^tools:/ && !d {t=$0; d=1; next} {print} END{print ""; print t}' "$T/r/$first" > "$T/x" && mv "$T/x" "$T/r/$first"
66
+ check "$T/r" >/dev/null && { echo " ❌ K4 body-only tools: line accepted"; fail=1; } || echo " ✅ K4 restriction moved out of frontmatter → red"
67
+ # K5 pin list without a trailing newline still checks its last entry (codex R1)
68
+ mk; printf '%s' "$(cat "$T/r/scripts/agent_tools_pin.txt")" > "$T/r/scripts/agent_tools_pin.txt"
69
+ last="$(grep -vE '^(#|$)' "$PIN" | tail -1 | cut -d'|' -f1)"; sed -i.bak '/^tools:/d' "$T/r/$last"
70
+ check "$T/r" >/dev/null && { echo " ❌ K5 last unterminated entry skipped"; fail=1; } || echo " ✅ K5 unterminated last entry still checked → red"
71
+
72
+ echo "agent_tools_pin lanes: $([ $fail = 0 ] && echo PASS || echo FAIL)"
73
+ exit $fail
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # test_catch_tally_lanes.sh — catch_tally.py 의 기록 규칙 known-pair (얇은 래퍼).
3
+ # 절 없는 날·범위 없는 0건 = 미기록(0 아님) · 목록 밖 방법/놓친 쪽 = INVALID(세지 않음)
4
+ # · 다른 절·범위 밖 날은 안 셈 · 컨트롤(유효 기록만이면 rc=0). 레인은 파이썬 안에 있다.
5
+ # exit: 0 전 레인 PASS · 1 실패 · 10 harness error(python3 부재)
6
+ set -uo pipefail
7
+ SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ command -v python3 >/dev/null 2>&1 || {
9
+ echo "harness error: python3 absent -- cannot measure. Not a pass." >&2; exit 10; }
10
+ python3 "$SRC/catch_tally.py" --self-test
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ # Lanes for scripts/claim_precision_report.py — known pair + channel-gap cases.
3
+ # P1 DONE → PARTIAL in a later sheet → M=1 (known-positive)
4
+ # P2 DONE → DONE → M=0 (known-negative, same run)
5
+ # P3 DONE → empty 상태 → B=1, M unchanged (not re-judged ≠ corrected)
6
+ # P4 a session with one sheet → listed NOT MEASURED, contributes nothing
7
+ # P5 empty folder → rc 10, NOT MEASURED (absence ≠ 0)
8
+ set -u
9
+ HERE="$(cd "$(dirname "$0")" && pwd)"
10
+ R="$HERE/claim_precision_report.py"
11
+ T="$(mktemp -d "${TMPDIR:-/tmp}/cpr.XXXXXX")"
12
+ trap 'rm -rf "$T"' EXIT
13
+ pass=0; fail=0
14
+ ok(){ echo " ✅ $1"; pass=$((pass+1)); }
15
+ ng(){ echo " ❌ $1"; fail=$((fail+1)); }
16
+
17
+ hdr='| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |
18
+ |---|---|---|---|---|---|---|'
19
+ mkdir -p "$T/d"
20
+ { echo "$hdr"
21
+ echo '| 1 | 11-01 10:00 | alpha request | ✅DONE | e1 | — | — |'
22
+ echo '| 2 | 11-01 11:00 | beta request | ✅DONE | e2 | — | — |'
23
+ echo '| 3 | 11-01 12:00 | gamma request | ✅DONE | e3 | — | — |'; } > "$T/d/session_checklist_2026-11-01_sA.md"
24
+ { echo "$hdr"
25
+ echo '| 1 | 11-01 10:00 | alpha request | 🟡PARTIAL | e1 | narrowed | later |'
26
+ echo '| 2 | 11-01 11:00 | beta request | ✅DONE | e2 | — | — |'
27
+ echo '| 3 | 11-01 12:00 | gamma request | | | | |'; } > "$T/d/session_checklist_2026-11-02_sA.md"
28
+ { echo "$hdr"
29
+ echo '| 1 | 11-03 09:00 | solo request | ✅DONE | e | — | — |'; } > "$T/d/session_checklist_2026-11-03_sB.md"
30
+
31
+ out="$(python3 "$R" --dir "$T/d" 2>&1)"; rc=$?
32
+ echo "$out" | sed 's/^/ | /'
33
+ [ "$rc" = 0 ] && ok "rc 0 on sheets" || ng "rc=$rc"
34
+ echo "$out" | grep -q 'N done-rows=3 ' && ok "P2 N=3 (DONE rows of the measured session)" || ng "P2 N"
35
+ echo "$out" | grep -q 'M later reopened (non-DONE in the enum)=1 ' && ok "P1 M=1 known-positive" || ng "P1 M"
36
+ echo "$out" | grep -q 'alpha request' && ok "P1 reopened row is the alpha row" || ng "P1 row identity"
37
+ echo "$out" | grep -q 'beta request' && ng "P2 known-negative listed as reopened" || ok "P2 beta not listed"
38
+ echo "$out" | grep -q 'B not re-judged in newest sheet (blank, absent or outside the enum)=1 ' && ok "P3 blank counted apart (B=1)" || ng "P3 B"
39
+ echo "$out" | grep -q 'not-measured(<2 readable sheets)=1' && echo "$out" | grep -q 'readable sheets sB' \
40
+ && ok "P4 single-sheet session named NOT MEASURED" || ng "P4"
41
+
42
+ mkdir -p "$T/empty"
43
+ out="$(python3 "$R" --dir "$T/empty" 2>&1)"; rc=$?
44
+ [ "$rc" = 10 ] && echo "$out" | grep -q 'NOT MEASURED' && ok "P5 empty folder → rc 10 NOT MEASURED" || ng "P5 rc=$rc"
45
+
46
+ # Codex R1 (2026-11-11) — each reproduced red against the first version before the fix.
47
+ # P6 two sheets that cannot be parsed → not measured, never «measured=1 N=0 M=0».
48
+ mkdir -p "$T/bad"; : > "$T/bad/session_checklist_2026-11-01_sC.md"; : > "$T/bad/session_checklist_2026-11-02_sC.md"
49
+ out="$(python3 "$R" --dir "$T/bad" 2>&1)"
50
+ echo "$out" | grep -q 'measured=0 ' && echo "$out" | grep -q 'unreadable sheets session_checklist_2026-11-01_sC.md' \
51
+ && ok "P6 unreadable sheets → measured=0, named" || ng "P6"
52
+ # P7 DONE → PARTIAL → DONE: the reopening stays counted (sticky).
53
+ mkdir -p "$T/sticky"
54
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | delta request | ✅DONE | e | — | — |'; } > "$T/sticky/session_checklist_2026-11-01_sD.md"
55
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | delta request | 🟡PARTIAL | e | x | y |'; } > "$T/sticky/session_checklist_2026-11-02_sD.md"
56
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | delta request | ✅DONE | e | — | — |'; } > "$T/sticky/session_checklist_2026-11-03_sD.md"
57
+ python3 "$R" --dir "$T/sticky" 2>&1 | grep -q 'M later reopened (non-DONE in the enum)=1 ' && ok "P7 reopening is sticky" || ng "P7"
58
+ # P8 a DONE row absent from the newest sheet counts in B (not re-judged), not as silence.
59
+ mkdir -p "$T/gone"
60
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | eps request | ✅DONE | e | — | — |'; } > "$T/gone/session_checklist_2026-11-01_sE.md"
61
+ { echo "$hdr"; echo '| 1 | 11-02 10:00 | other request | ✅DONE | e | — | — |'; } > "$T/gone/session_checklist_2026-11-02_sE.md"
62
+ python3 "$R" --dir "$T/gone" 2>&1 | grep -q '(blank, absent or outside the enum)=1 ' && ok "P8 absent row counted in B" || ng "P8"
63
+
64
+ # Codex R2: P9 sheets whose 상태 table lacks 시각/발화 → nothing measurable → not measured.
65
+ mkdir -p "$T/nocols"
66
+ for d in 01 02; do printf '| 상태 | 메모 |\n|---|---|\n| ✅DONE | x |\n' > "$T/nocols/session_checklist_2026-11-${d}_sF.md"; done
67
+ python3 "$R" --dir "$T/nocols" 2>&1 | grep -q 'measured=0 ' && ok "P9 no 시각/발화 columns → measured=0" || ng "P9"
68
+
69
+ # P10 a later «—» (outside the enum) is not a reopening: it counts in B, M stays 0.
70
+ mkdir -p "$T/dash"
71
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | zeta request | ✅DONE | e | — | — |'; } > "$T/dash/session_checklist_2026-11-01_sG.md"
72
+ { echo "$hdr"; echo '| 1 | 11-01 10:00 | zeta request | — | e | — | — |'; } > "$T/dash/session_checklist_2026-11-02_sG.md"
73
+ o="$(python3 "$R" --dir "$T/dash" 2>&1)"
74
+ echo "$o" | grep -q 'M later reopened (non-DONE in the enum)=0 ' && echo "$o" | grep -q 'outside the enum)=1 ' && ok "P10 «—» → B, not M" || ng "P10"
75
+
76
+ echo "claim_precision_report lanes: pass=$pass fail=$fail"
77
+ [ "$fail" = 0 ]
@@ -6,7 +6,9 @@
6
6
  # Revert probe: FH_MODULE_PROBE=<name> neuters one check in a TEMP COPY of the checker (never the real
7
7
  # one) and the matching lane must go red:
8
8
  # hook-action | enum | route | strictest | dependants | unreadable | gating | corepat | irrverb |
9
- # case | shape | filescan | events | uncalmerge | uncal | dupkey | mergefloor | mergevalid | emptyinst
9
+ # case | shape | filescan | events | uncalmerge | uncal | dupkey | mergefloor | mergevalid | emptyinst |
10
+ # rtguard | rtscan | rtpkg | rtdyn | rtnear | rtdef | rtshadow | rtattr | rtenc | rtwalk |
11
+ # rtkw | rtbuiltins | rtarg | rtmeth | rtgen
10
12
  set -u
11
13
  HERE="$(cd "$(dirname "$0")" && pwd)"
12
14
  REPO="$(dirname "$HERE")"
@@ -31,6 +33,21 @@ if [ -n "${FH_MODULE_PROBE:-}" ]; then
31
33
  mergefloor) needle='merged = {ax: AXES[ax].index(v) for ax, v in CORE_FLOOR.items()}'; repl='merged = {}' ;;
32
34
  mergevalid) needle=' for x in sub.blocks: vd.block("%s: %s" % (p, x))'; repl=' pass' ;;
33
35
  emptyinst) needle=' if not files:'; repl=' if False:' ;;
36
+ rtguard) needle=' if node.lineno in guarded:'; repl=' if True:' ;;
37
+ rtscan) needle=' runtime_deps(m, repo, vd)'; repl=' pass' ;;
38
+ rtpkg) needle='or os.path.join(d, mod, "__init__.py") in shipped:'; repl=':' ;;
39
+ rtdyn) needle=' elif _dynamic_import(node, bare):'; repl=' elif False:' ;;
40
+ rtnear) needle='or _is_stdlib(mod) or _is_local(mod, f):'; repl='or _is_stdlib(mod) or mod in {os.path.splitext(os.path.basename(x))[0] for x in shipped}:' ;;
41
+ rtdef) needle=' if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):'; repl=' if False:' ;;
42
+ rtshadow) needle=' return x.id in _CATCH and x.id not in bound'; repl=' return x.id in _CATCH' ;;
43
+ rtattr) needle=' return (isinstance(x, ast.Attribute)'; repl=' return False and (isinstance(x, ast.Attribute)' ;;
44
+ rtkw) needle='next((k.value for k in n.keywords if k.arg == "name"), None)'; repl='None' ;;
45
+ rtbuiltins) needle='and "builtins" not in bound and x.attr in _CATCH'; repl='and x.attr in _CATCH' ;;
46
+ rtarg) needle=' out.add(n.arg)'; repl=' pass' ;;
47
+ rtmeth) needle=' and f.value.id == "importlib")):'; repl=' or True)):' ;;
48
+ rtgen) needle=' if isinstance(n, ast.GeneratorExp):'; repl=' if False:' ;;
49
+ rtwalk) needle=' files += [os.path.join(dp, f) for f in sorted(fns) if f.endswith(".py")]'; repl=' pass' ;;
50
+ rtenc) needle=' with tokenize.open(f) as fh:'; repl=' with open(f, encoding="utf-8") as fh:' ;;
34
51
  hook-action) needle='elif act not in HOOK_ACTIONS:'; repl='elif False:' ;;
35
52
  enum) needle='if h.get("event") not in HOOK_EVENTS:'; repl='if False:' ;;
36
53
  route) needle='if route not in gates:'; repl='if False:' ;;
@@ -577,5 +594,93 @@ run "EX12 calibration rc 2 is UNMEASURED, not BLOCK (2)" 2 c expo
577
594
  if [ ! -e "$W/out8" ] && [ ! -e "$W/out12" ] && [ ! -e "$R/inside" ] && ! ls -d "$W"/.fh-export-* >/dev/null 2>&1; then PASS=$((PASS+1)); echo "PASS EX13 refused or failed exports leave no folder and no staging"
578
595
  else FAIL=$((FAIL+1)); echo "FAIL EX13 leftovers after a refused export"; fi
579
596
 
597
+ # RD — runtime dependencies (spec 2b; A/B C10 2026-11-08: a guarded PyYAML import lost 9/9 runs in an env without it)
598
+ printf 'import yaml\nprint(yaml)\n' > "$R/mod/dep_bad.py"
599
+ printf 'import json\ntry:\n import yaml\nexcept ImportError:\n yaml = None\n' > "$R/mod/dep_guard.py"
600
+ printf 'import json, os, re\nfrom collections import OrderedDict\n' > "$R/mod/dep_std.py"
601
+ printf 'def f():\n import requests\n return requests\n' > "$R/mod/dep_lazy.py"
602
+ printf 'import dep_std\n' > "$R/mod/dep_local.py"
603
+ printf 'def broken(:\n' > "$R/mod/dep_syntax.py"
604
+ for n in bad guard std lazy local syntax; do
605
+ extra=""; [ "$n" = local ] && extra=", mod/dep_std.py"
606
+ mk "rd_$n" <<YAML
607
+ id: rd-$n
608
+ version: 1.0.0
609
+ touches_irreversible: none
610
+ files: [mod/dep_$n.py$extra]
611
+ $TAIL
612
+ YAML
613
+ done
614
+ run "RD1 unguarded non-stdlib import blocks (1)" 1 c check "$W/rd_bad/fh-module.yaml"
615
+ run "RD2 guarded non-stdlib import passes with a NOTE (0)" 0 c check "$W/rd_guard/fh-module.yaml"
616
+ out="$(c check "$W/rd_guard/fh-module.yaml" 2>&1)"
617
+ if printf '%s\n' "$out" | grep -q '^NOTE: runtime dependency yaml (mod/dep_guard.py:3)'; then PASS=$((PASS+1)); echo "PASS RD2b the NOTE names the module and the line"
618
+ else FAIL=$((FAIL+1)); echo "FAIL RD2b no NOTE naming yaml"; echo "$out" | sed 's/^/ /'; fi
619
+ run "RD3 stdlib-only passes (0)" 0 c check "$W/rd_std/fh-module.yaml"
620
+ run "RD4 unguarded lazy import inside a function blocks (1)" 1 c check "$W/rd_lazy/fh-module.yaml"
621
+ run "RD5 a sibling module the module ships is not a dependency (0)" 0 c check "$W/rd_local/fh-module.yaml"
622
+ run "RD6 unparsable python is UNMEASURED, not OK (2)" 2 c check "$W/rd_syntax/fh-module.yaml"
623
+ mkdir -p "$R/mod/dep_pkg/helpers"; : > "$R/mod/dep_pkg/helpers/__init__.py"; printf 'import helpers\n' > "$R/mod/dep_pkg/main.py"
624
+ mk rd_pkg <<YAML
625
+ id: rd-pkg
626
+ version: 1.0.0
627
+ touches_irreversible: none
628
+ files: [mod/dep_pkg]
629
+ $TAIL
630
+ YAML
631
+ run "RD7 a package folder the module ships is not a dependency (0)" 0 c check "$W/rd_pkg/fh-module.yaml"
632
+ # RD8–RD13 — codex R1 on the first draft (2026-11-09), one lane per verified finding
633
+ mkdir -p "$R/mod/dep_far/elsewhere"
634
+ printf 'import importlib\nimportlib.import_module("fh_missing_dep")\n' > "$R/mod/dep_dyn.py"
635
+ printf 'import fh_missing_dep\n' > "$R/mod/dep_far/main.py"; : > "$R/mod/dep_far/elsewhere/fh_missing_dep.py"
636
+ printf 'try:\n def f():\n import fh_missing_dep\nexcept ImportError:\n pass\nf()\n' > "$R/mod/dep_def.py"
637
+ printf 'ImportError = ValueError\ntry:\n import fh_missing_dep\nexcept ImportError:\n pass\n' > "$R/mod/dep_shadow.py"
638
+ printf 'import builtins\ntry:\n import fh_missing_dep\nexcept builtins.ImportError:\n fh_missing_dep = None\n' > "$R/mod/dep_attr.py"
639
+ printf '# coding: latin-1\nlabel = "caf\351"\nimport json\n' > "$R/mod/dep_enc.py"
640
+ for n in dyn far def shadow attr enc; do
641
+ tgt="mod/dep_$n.py"; [ "$n" = far ] && tgt="mod/dep_far"
642
+ mk "rd_$n" <<YAML
643
+ id: rd-$n
644
+ version: 1.0.0
645
+ touches_irreversible: none
646
+ files: [$tgt]
647
+ $TAIL
648
+ YAML
649
+ done
650
+ run "RD8 a literal importlib/__import__ of a non-stdlib module blocks (1)" 1 c check "$W/rd_dyn/fh-module.yaml"
651
+ run "RD9 a same-named file in an unrelated folder does not satisfy it (1)" 1 c check "$W/rd_far/fh-module.yaml"
652
+ run "RD10 a try around a def does not guard the import inside it (1)" 1 c check "$W/rd_def/fh-module.yaml"
653
+ run "RD11 a rebound ImportError does not count as a guard (1)" 1 c check "$W/rd_shadow/fh-module.yaml"
654
+ run "RD12 except builtins.ImportError is a guard (0, NOTE)" 0 c check "$W/rd_attr/fh-module.yaml"
655
+ run "RD13 a latin-1 coding cookie is read, not UNMEASURED (0)" 0 c check "$W/rd_enc/fh-module.yaml"
656
+ # RD14–RD17 — codex R2 (2026-11-09): new gaps in the R1 fixes
657
+ printf 'import importlib\nimportlib.import_module(name="fh_missing_dep")\n' > "$R/mod/dep_kw.py"
658
+ printf 'import types\nbuiltins = types.SimpleNamespace(ImportError=ValueError)\ntry:\n import fh_missing_dep\nexcept builtins.ImportError:\n pass\n' > "$R/mod/dep_builtins.py"
659
+ printf 'def f(ImportError=ValueError):\n try:\n import fh_missing_dep\n except ImportError:\n pass\nf()\n' > "$R/mod/dep_arg.py"
660
+ printf 'class Loader:\n def import_module(self, name):\n return name\nLoader().import_module("label")\n' > "$R/mod/dep_meth.py"
661
+ for n in kw builtins arg meth; do
662
+ mk "rd_$n" <<YAML
663
+ id: rd-$n
664
+ version: 1.0.0
665
+ touches_irreversible: none
666
+ files: [mod/dep_$n.py]
667
+ $TAIL
668
+ YAML
669
+ done
670
+ run "RD14 import_module(name=\"…\") with a literal blocks (1)" 1 c check "$W/rd_kw/fh-module.yaml"
671
+ run "RD15 a rebound builtins receiver does not count as a guard (1)" 1 c check "$W/rd_builtins/fh-module.yaml"
672
+ run "RD16 a parameter named ImportError does not count as a guard (1)" 1 c check "$W/rd_arg/fh-module.yaml"
673
+ run "RD17 a method named import_module is not a dependency (0)" 0 c check "$W/rd_meth/fh-module.yaml"
674
+ # RD18 — codex R3: a generator inside the try runs on next(), outside it
675
+ printf 'import importlib\nrows = [[1]]\ntry:\n arrays = (importlib.import_module("fh_missing_dep").array(r) for r in rows)\nexcept ImportError:\n arrays = iter(rows)\nnext(arrays)\n' > "$R/mod/dep_gen.py"
676
+ mk rd_gen <<YAML
677
+ id: rd-gen
678
+ version: 1.0.0
679
+ touches_irreversible: none
680
+ files: [mod/dep_gen.py]
681
+ $TAIL
682
+ YAML
683
+ run "RD18 an import inside a generator in a try is not guarded by it (1)" 1 c check "$W/rd_gen/fh-module.yaml"
684
+
580
685
  echo "lanes: pass=$PASS fail=$FAIL"
581
686
  [ "$FAIL" = 0 ]
@@ -321,5 +321,13 @@ OUT=$("$PY" "$CHK" "$D/lnk" --json 2>&1); RC=$?
321
321
  N=$(printf '%s' "$OUT" | "$PY" -c 'import json,sys; print(sum(1 for x in json.load(sys.stdin)["human_review"] if x["id"]=="H2"))' 2>/dev/null)
322
322
  [ "$RC" -eq 1 ] && [ "$N" = "1" ] && ok "L14 링크된 .claude/CLAUDE.md 는 두 번 세지 않는다 (H2=1, rc=1)" || no "L14 링크 중복" "rc=$RC H2=$N"
323
323
 
324
+ # L15 — W8 (정보): description 에 질문 모양이 없으면 표시, 있으면 표시 없음. rc 는 둘 다 0 (정보는 판정에 영향 없음)
325
+ mkdir -p "$D/w8a/.claude/skills/a" "$D/w8b/.claude/skills/b"
326
+ printf -- '---\nname: a\ndescription: Use when reviewing a SQL migration\n---\n## Done When\n- x\n' > "$D/w8a/.claude/skills/a/SKILL.md"
327
+ printf -- '---\nname: b\ndescription: Use when reviewing a SQL migration, or asked «will this migration wipe data?»\n---\n## Done When\n- x\n' > "$D/w8b/.claude/skills/b/SKILL.md"
328
+ OUTA=$("$PY" "$CHK" "$D/w8a" 2>&1); RCA=$?; OUTB=$("$PY" "$CHK" "$D/w8b" 2>&1); RCB=$?
329
+ [ "$RCA" -eq 0 ] && [ "$RCB" -eq 0 ] && printf '%s' "$OUTA" | /usr/bin/grep -qE '^ W8 ' && ! printf '%s' "$OUTB" | /usr/bin/grep -qE '^ W8 ' \
330
+ && ok "L15 W8: 질문 모양 없는 description 표시 · 있는 쪽 표시 없음 · rc 0/0" || no "L15 W8" "rcA=$RCA rcB=$RCB $OUTA"
331
+
324
332
  /bin/rm -rf "$D"
325
333
  echo "PASS=$PASS FAIL=$FAIL"; [ "$FAIL" -eq 0 ] && { echo "FAILED=0"; exit 0; } || { echo "FAILED=1"; exit 1; }
@@ -71,11 +71,12 @@ done
71
71
  [ "$_tf" -eq 0 ] && ok "trivial ② (: · true · ' true ; ' · exit 0 · '' · /usr/bin/true) → rc=3 each"
72
72
 
73
73
  # failing ② on a byte-correct merge → rc=1
74
- run "$T/ok" "$TIP_OK" --rerun 'grep -q NOPE a'
74
+ run "$T/ok" "$TIP_OK" --rerun 'grep -q NOPE a && echo found'
75
75
  [ "$RC" -eq 1 ] && ok "failing ② on a byte-correct squash → rc=1" || { bad "failing ② rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
76
76
 
77
77
  # silent ② (rc=0, no output) → rc=4, never a pass
78
- run "$T/ok" "$TIP_OK" --rerun 'grep -q a2 a'
78
+ # (wrapped in bash -c: a bare `grep -q` is now refused before running — X12; the guard must still catch what X12 cannot see)
79
+ run "$T/ok" "$TIP_OK" --rerun 'bash -c "grep -q a2 a"'
79
80
  [ "$RC" -eq 4 ] && ok "silent ② (rc=0, empty output) → rc=4" || { bad "silent ② rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
80
81
 
81
82
  # COMBINED: main also changed a (different line region) after the branch was cut → not DIFFERS
@@ -179,5 +180,25 @@ _p2=$(bash "$SC" --precheck --rerun 'grep -q x y; echo z' >/dev/null 2>&1; echo
179
180
  _p3=$(bash "$SC" --precheck >/dev/null 2>&1; echo $?)
180
181
  [ "$_p1$_p2$_p3" = "302" ] && ok "X11 --precheck: trivial=3 · real=0 · missing=2" || bad "X11 --precheck got $_p1/$_p2/$_p3 (want 3/0/2)"
181
182
 
183
+ # X12 a ② that is statically silent on success is refused BEFORE merging (rc=3). Origin: the 7 merges in the
184
+ # receipts that ended verify-incomplete (2026-11-09) — content intact, ② a quiet check, the rc=4 silence
185
+ # guard fired only after the merge. Shapes below are those real --rerun strings, reduced. Pass side: a
186
+ # quiet check that also says what passed, and commands that print, must stay accepted.
187
+ _x12=0
188
+ for q in 'grep -q x y' 'bash a.sh --help >/dev/null 2>&1; grep -q "A pass" b.md' 'git show HEAD:f | grep -qx L' \
189
+ 'grep -qF "curl -sL \"u\"" s.md' 'python3 -c "import yaml;yaml.safe_load(open(\"l.yaml\"))"' \
190
+ 'git check-ignore -q f' 'test -f a && [ -s a ]' 'cmp -s a b'; do
191
+ _r=$(bash "$SC" --precheck --rerun "$q" >/dev/null 2>&1; echo $?)
192
+ [ "$_r" = 3 ] || { bad "X12 quiet ② '$q' → rc=$_r (want 3)"; _x12=1; }
193
+ done
194
+ for p in 'grep -q x y && echo ok' 'pytest -q t' 'bash scripts/x.sh' 'python3 -c "import yaml;print(1)"' \
195
+ 'git grep -e x' 'grep -c x y' 'make t >/dev/null 2>&1; echo done' 'cat a 2>/dev/null' 'bash -c true' \
196
+ 'cat a 3>/dev/null' 'cat a >/dev/null 1>&2' "printf '%s\\n' -q | grep -- -q" "python3 -c 'import os; os.write(1,b\"ok\")'" \
197
+ "grep -q '\"' a; echo \"ok\"" "grep -q x a & echo done" 'cat a >&2 | test -d /tmp'; do # last 7 = cross-family R1 over-refusals
198
+ _r=$(bash "$SC" --precheck --rerun "$p" >/dev/null 2>&1; echo $?)
199
+ [ "$_r" = 0 ] || { bad "X12 printing ② '$p' → rc=$_r (want 0)"; _x12=1; }
200
+ done
201
+ [ "$_x12" -eq 0 ] && ok "X12 quiet ② refused before merge (8 shapes → 3) · printing ② accepted (16 shapes → 0)"
202
+
182
203
  printf 'PASS %d · FAIL %d\n' "$PASS" "$FAIL"
183
204
  [ "$FAIL" -eq 0 ]