@chrono-meta/fh-gate 3.16.0 → 3.17.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 (60) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +27 -0
  3. package/CATALOG.md +60 -0
  4. package/CLAUDE.md +5 -0
  5. package/README.ja.md +2 -2
  6. package/README.ko.md +2 -2
  7. package/README.md +2 -2
  8. package/README.zh.md +2 -2
  9. package/docs/OUTPUT_EVIDENCE.md +1 -1
  10. package/docs/codex-compat.md +24 -0
  11. package/knowledge/shared/harness-core/checkout_layer_drift.md +301 -0
  12. package/knowledge/shared/learnings/subagent_invocations_log.yaml +25 -0
  13. package/package.json +11 -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 +42 -0
  17. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-preprep/skills/preprep/SKILL.md +5 -0
  19. package/plugins/fh-preprep/skills/preprep/lane_font_embed.py +235 -0
  20. package/plugins/fh-preprep/skills/preprep/ooxml/gate.py +67 -5
  21. package/plugins/fh-preprep/skills/preprep/ooxml/test_gate_exitcodes.py +136 -0
  22. package/plugins/fh-preprep/skills/preprep/preprep.py +16 -1
  23. package/plugins/fh-preprep/skills/preprep/presentation_checklist.md +108 -6
  24. package/plugins/fh-preprep/skills/preprep/safe_install.py +22 -3
  25. package/plugins/fh-preprep/skills/preprep/surfaces.example.yaml +11 -0
  26. package/plugins/fh-preprep/skills/preprep/test_lane_font_embed.py +117 -0
  27. package/plugins/fh-preprep/skills/preprep/test_safe_install_app_xml.py +77 -0
  28. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  29. package/scripts/count_check.sh +46 -14
  30. package/scripts/daily_report.sh +17 -1
  31. package/scripts/env_layer_fingerprint.sh +309 -0
  32. package/scripts/gate_bootstrap_ephemeral.sh +248 -0
  33. package/scripts/governor_board.sh +841 -0
  34. package/scripts/map_postprocess.py +89 -4
  35. package/scripts/multibyte_bracket_lint.sh +135 -0
  36. package/scripts/outbound_pr_gate.sh +12 -0
  37. package/scripts/package_coverage_check.sh +34 -0
  38. package/scripts/selfcheck.sh +245 -0
  39. package/scripts/session_close_check.sh +96 -1
  40. package/scripts/stale_ref_scan.py +2 -1
  41. package/scripts/test_count_check_decl_lanes.sh +176 -0
  42. package/scripts/test_env_layer_fingerprint_lanes.sh +192 -0
  43. package/scripts/test_gate_bootstrap_ephemeral_lanes.sh +262 -0
  44. package/scripts/test_locale_invariance_lanes.sh +581 -0
  45. package/scripts/test_map_postprocess_lanes.sh +84 -4
  46. package/scripts/test_marker_crossfamily_lanes.sh +5 -1
  47. package/scripts/test_marker_defense_lanes.sh +5 -1
  48. package/scripts/test_marker_standpoint_lanes.sh +5 -1
  49. package/scripts/test_marker_thirdparty_lanes.sh +5 -1
  50. package/scripts/test_multibyte_bracket_lint_lanes.sh +107 -0
  51. package/scripts/test_outbound_pr_gate_lanes.sh +133 -0
  52. package/scripts/test_preprep_drift_anchor.sh +34 -9
  53. package/scripts/test_preprep_drift_anchor_lanes.sh +64 -2
  54. package/scripts/test_session_close_chain_lanes.sh +45 -0
  55. package/scripts/test_stale_ref_close_lanes.sh +197 -0
  56. package/scripts/test_stale_ref_scan_lanes.sh +6 -1
  57. package/scripts/test_worktree_reclaim_lanes.sh +267 -1
  58. package/scripts/worktree_reclaim.sh +246 -11
  59. package/templates/.git-hooks/pre-commit +108 -27
  60. package/templates/settings.PreToolUse.snippet.json +54 -1
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # worktree_reclaim.sh — reclaim gitignored `tracks/**` artifacts from a git worktree BEFORE it is removed.
2
+ # worktree_reclaim.sh — reclaim what a worktree removal would silently destroy, BEFORE it is removed.
3
3
  #
4
4
  # WHY (N=2, so a script — 2026-09-02 signal + 2026-09-05 push-zone dispatch): the Destructive-Op gate
5
5
  # enumerates COMMITS, and `tracks/**` is gitignored, so a worktree removal can delete a session's only
@@ -9,14 +9,52 @@
9
9
  # remove — is exactly what this script does, in that order, because after the copy «never existed»
10
10
  # and «already moved» are indistinguishable (the list file is the evidence).
11
11
  #
12
+ # 🟥 SCOPE WIDENED 2026-09-21 — the first version looked ONLY at `tracks/`, and that made it lie.
13
+ # Measured the same day: a policy-lens worktree held `scripts/fixtures/…` (52 files) and
14
+ # `scripts/score_policy_lens.sh` as UNTRACKED files outside `tracks/`. The script enumerated
15
+ # «only-in-worktree: 0» and printed «✅ nothing left only in the worktree — safe to: git worktree
16
+ # remove». It was not merely incomplete — it ACTIVELY AUTHORIZED the destroy step on an irreversible
17
+ # surface. Second face of the same defect: `[ -d "$SRC" ] || exit 0` read «no tracks/ dir» as
18
+ # «nothing to reclaim» ([[feedback_not_found_is_not_zero_family]]). 🟥 And the LANE had frozen that
19
+ # false green as correct (old W5e: «worktree without tracks/ → rc=0 nothing to reclaim»).
20
+ #
21
+ # Two zones, deliberately NOT symmetric:
22
+ # tracks/** AUTO-RECLAIM — the measured loss class. Copied on --apply, byte-verified.
23
+ # everywhere SURFACE-ONLY — every other path git will not carry. Listed and it WITHHOLDS the
24
+ # «safe to remove» line, but is never auto-copied: the destination is a judgment
25
+ # (is `scripts/foo.sh` for the main tree, or worktree scratch?), and guessing it
26
+ # into a SHARED checkout is its own accident.
27
+ #
28
+ # 🟥 WHAT DOES *NOT* BLOCK, and why that list is short (S-2, 2026-09-21, 2nd cross-family round).
29
+ # The first attempt at the over-block problem below said «ignored never blocks». That opened a
30
+ # hole big enough to lose the exact thing this script exists to protect: measured on this repo's
31
+ # own `.gitignore`, a worktree holding ONLY `knowledge/**/*_paper_draft.md` (unpublished drafts)
32
+ # and `outputs/` (field-harness run artifacts) was told **«✅ safe to: git worktree remove»**.
33
+ # `CLAUDE.local.md`, `.claude/specs/`, `.claude/rules/.public-surface-patterns` are the same class
34
+ # — ignored AND irreplaceable, several of them with no undo at all.
35
+ # 🟥 That was the SECOND time in one session that a fix here re-created the disease it was fixing.
36
+ # So the non-blocking set is now a NAMED WHITELIST, not a category:
37
+ # ⓐ session runtime sentinels the hooks rewrite every run (`_runtime_sentinel`)
38
+ # ⓑ path-shaped build output, and ONLY when git already ignores it (`_regenerable`)
39
+ # Everything else blocks. Both lists are small frozen judgments (§Mechanization Boundary), accepted
40
+ # because their failure is LOUD and cheap (one extra path a human glances at) rather than silent.
41
+ # 🟥 `_regenerable` deliberately does NOT apply to UNTRACKED paths: «nobody ever told git about it»
42
+ # is no evidence that a path named `build/` is disposable, and a freshly written
43
+ # `scripts/build/report.md` is real work. Over-blocking trains the override, so the lane carries an
44
+ # over-block control (W6d), a control ON that control (W6e), and an ignored-CONTENT arm (W7g) whose
45
+ # fixture is taken from the real loss class rather than from a made-up sentinel name.
46
+ #
12
47
  # USAGE
13
48
  # bash scripts/worktree_reclaim.sh <worktree-path> # enumerate only (writes the list file)
14
49
  # bash scripts/worktree_reclaim.sh <worktree-path> --apply # enumerate + copy + verify
15
50
  #
16
- # EXIT 0 = nothing to reclaim, or everything reclaimed and byte-verified
17
- # 1 = files exist on BOTH sides with different content — a human must merge (listed, not copied)
51
+ # EXIT 0 = nothing left in the worktree that its removal would destroy
52
+ # 1 = something is still worktree-only: tracks/ files not yet reclaimed · both-sides DIFF ·
53
+ # OUTSIDE artifacts a human must dispose of (listed, never auto-copied)
18
54
  # 2 = usage / not a worktree of a main checkout
19
- # 10 = harness error (list file unwritable, copy failed verification)
55
+ # 10 = the sweep itself could not be trusted — enumerator failed (git status / diff), the
56
+ # enumeration was PARTIAL (a git warning), the main-worktree root did not resolve, the
57
+ # list file was unwritable, or a copy failed byte verification
20
58
  #
21
59
  # NEVER removes the worktree. Removal stays an explicit `git worktree remove` after this exits 0.
22
60
  set -uo pipefail
@@ -36,17 +74,163 @@ COMMON="$(cd "$COMMON" && pwd -P)"; GITDIR="$(cd "$GITDIR" && pwd -P)"
36
74
  if [ "$COMMON" = "$GITDIR" ]; then
37
75
  echo "🟥 $WT is the MAIN checkout (git-dir == git-common-dir), not a worktree — nothing to reclaim from itself" >&2; exit 2
38
76
  fi
39
- ROOT="$(dirname "$COMMON")" # main checkout root = parent of the shared .git
77
+ # 🟥 A-6 — `dirname "$COMMON"` assumes «the shared .git sits directly under the repo root». In a
78
+ # SUBMODULE worktree `--git-common-dir` is `<super>/.git/modules/<name>`, so ROOT became
79
+ # `<super>/.git/modules` and reclaimed files were copied INSIDE `.git`. This script is shipped on
80
+ # npm (`package.json` files[]), so the consumer's layout is the target, not this repo's.
81
+ ROOT="$(git -C "$WT" worktree list --porcelain 2>/dev/null | sed -n '1s/^worktree //p')"
82
+ [ -n "$ROOT" ] && [ -d "$ROOT" ] || { echo "🟥 could not resolve the main worktree root for $WT" >&2; exit 10; }
40
83
  WT="$(cd "$WT" && pwd -P)"
41
84
  SRC="$WT/tracks"; DST="$ROOT/tracks"
42
- [ -d "$SRC" ] || { echo "ℹ️ no tracks/ in worktree — nothing to reclaim (rc=0)"; exit 0; }
85
+ # 🟥 NO early exit on a missing `tracks/`. «tracks/ 가 없다» is not «there is nothing to reclaim» —
86
+ # that green is exactly what authorized the destroy step. A missing tracks/ empties THAT ZONE;
87
+ # the OUTSIDE sweep below still runs.
43
88
  mkdir -p "$DST/_meta/dispatch" 2>/dev/null || { echo "🟥 cannot create $DST/_meta/dispatch" >&2; exit 10; }
44
89
 
45
90
  NAME="$(basename "$WT")"; TS="$(date +%Y%m%d-%H%M%S)"
46
91
  LIST="$DST/_meta/dispatch/reclaim_${NAME}_${TS}.txt"
47
92
 
48
93
  # 1. ENUMERATE — the list lands in a file FIRST (the evidence that survives the copy)
49
- ONLY=(); DIFF=()
94
+ ONLY=(); DIFF=(); OUTSIDE=(); SKIPPED=(); ZONE=(); CONFIG=(); _DIRTY=0
95
+ _p=''; _k='' # 🟥 A-7 — `set -u` kills the loop below if a warning line arrives first
96
+
97
+ # 1-a. OUTSIDE — every path git will NOT carry, outside `tracks/`. Source is git itself, not a
98
+ # hand-rolled find: `-uall` lists untracked files individually; `--ignored` collapses wholly
99
+ # ignored dirs, which is the shape the exclusion list matches on.
100
+ # ⓐ Session runtime sentinels — rewritten by hooks on every run, and measured to be present in a
101
+ # real worktree on every run (this is what made «ignored blocks» an unpassable gate).
102
+ # 🟥 THE TEST FOR THIS LIST IS «the hooks rewrite it every run», NOT «it lives under .claude/».
103
+ # Two entries failed that test and were REMOVED in the 3rd adversarial round (2026-09-21):
104
+ # `.claude/settings.json` / `.claude/settings.local.json` — written by a human or the wizard,
105
+ # and `[[feedback_gitignored_config_has_no_undo]]` measured that losing one has NO undo
106
+ # (not in `git status`, not recoverable by `git checkout`). settings.local.json is the
107
+ # session's PERMISSION LEDGER. A worktree holding only those two was told «safe to remove».
108
+ # `.playwright-mcp/*` — holds screenshots/snapshots that exist ONLY in that worktree.
109
+ # Both were found by adversarial review, both reproduced by execution, neither self-caught.
110
+ # 🟥 And this list had never been cross-checked against this repo's OWN `.gitignore`: one entry of
111
+ # the five in the same «prior-art hook runtime sentinels» comment block was missing, so genuinely
112
+ # regenerable files were blocking. The lane now diffs the two (W7j) — this drift does not get
113
+ # re-noticed by eye.
114
+ # ⓒ Worktree-LOCAL config. 🟥 4th round: pulling `.claude/settings*.json` out of ⓐ (they are not
115
+ # «rewritten by the hooks») made them BLOCK, and a session that works in a worktree creates them
116
+ # there — so the gate became unclearable again, which is the `--force` training A-3 closed.
117
+ # Measured before deciding: a FRESH `git worktree add` carries **zero** ignored files — the main
118
+ # checkout's `.claude/settings.json` is NOT copied in. So a worktree's copy exists only because a
119
+ # session made it there, and it is scoped to that worktree's session (settings.local.json is that
120
+ # session's permission approvals). The main checkout's settings are never at risk from this tool.
121
+ # ⇒ They get their OWN verdict: they do not block, and the green line NAMES them, because
122
+ # «silently skipped» and «blocks forever» are both wrong here. The loss becomes visible AT the
123
+ # decision point instead of at neither end.
124
+ _worktree_local_config() {
125
+ case "$1" in
126
+ .claude/settings.json|.claude/settings.local.json) return 0 ;;
127
+ esac
128
+ return 1
129
+ }
130
+
131
+ _runtime_sentinel() {
132
+ case "$1" in
133
+ .claude/.prior_art_prompted_*|.claude/.prior_art_events.tsv) return 0 ;;
134
+ .claude/.outbound_hook_events.tsv|.claude/.proposal_hook_events.tsv) return 0 ;;
135
+ .claude/settings*.json.bak) return 0 ;; # 🟥 백업만. 원본은 아래 주석 참조
136
+ .claude/.outbound_hook_uncalibrated_notice|.claude/be_last_sync) return 0 ;;
137
+ .claude/worktrees/*|.claude/mcp_circuit/*|.claude/registry/*) return 0 ;;
138
+ .claude/skills/*|skills-lock.json|.codex/*) return 0 ;;
139
+ .claude/*.lock|.claude/goal-quench.*) return 0 ;;
140
+ .claude-octopus/*|.claude-octopus/) return 0 ;;
141
+ .fd_*|*/.fd_*) return 0 ;;
142
+ *-playwright-demo.png) return 0 ;;
143
+ .DS_Store|*/.DS_Store) return 0 ;;
144
+ esac
145
+ return 1
146
+ }
147
+
148
+ # ⓑ Path-shaped build output. 🟥 Consulted ONLY for paths git already ignores — see the header.
149
+ _regenerable() {
150
+ case "$1" in
151
+ tracks/*|tracks/) return 0 ;; # handled by its own zone below
152
+ .git/*|.git/) return 0 ;;
153
+ node_modules/*|*/node_modules/*) return 0 ;;
154
+ __pycache__/*|*/__pycache__/*) return 0 ;;
155
+ .venv/*|venv/*|*/.venv/*|*/venv/*) return 0 ;;
156
+ dist/*|build/*|target/*|*/dist/*|*/build/*|*/target/*) return 0 ;;
157
+ .next/*|.cache/*|*/.next/*|*/.cache/*) return 0 ;;
158
+ *.pyc|*.pyo|*.DS_Store) return 0 ;;
159
+ esac
160
+ return 1 # 🟥 unknown path → LISTED, never skipped
161
+ }
162
+ # 🟥 S-1 (2026-09-21, cross-family) — the FIRST version of this sweep threw the rc away:
163
+ # `done < <(git … 2>/dev/null)`. Process substitution is not a pipeline, so `pipefail` never
164
+ # applied, there is no `set -e`, and `2>/dev/null` ate the fatal message. A corrupt worktree
165
+ # index made git exit 128 with ZERO stdout lines → OUTSIDE=() → «outside-tracks: 0» →
166
+ # **«✅ safe to: git worktree remove»**. Measured, not theorised (rc=128, script rc=0).
167
+ # 🟥 That is THIS SCRIPT'S OWN DISEASE, re-introduced one layer up: the widening meant to stop
168
+ # «unlooked» rendering as «none» was itself carried by an unchecked enumerator.
169
+ # So the enumerator's rc is now load-bearing: it cannot fail quietly.
170
+ # 🟥 A-8 — `warning:`/`fatal:` below are ENGLISH git strings. git translates them under NLS
171
+ # (ko `경고:`, ja `警告:`), and a translated warning falls through to `*) continue` — which is
172
+ # exactly the partial-enumeration hole the `_DIRTY` branch exists to close. This ships on npm,
173
+ # so the consumer's locale is the target and «this machine is English» is not evidence
174
+ # ([[feedback_compare_beats_pinning_a_constant]]). B-5: `core.quotePath=false` so a non-ASCII
175
+ # path prints as itself — the script tells a human to «move or delete each one», and they cannot
176
+ # find a file named `\355\225\234.md`.
177
+ _ST=$(LC_ALL=C git -C "$WT" -c core.quotePath=false status --porcelain --ignored -uall 2>&1); _ST_RC=$?
178
+ if [ "$_ST_RC" -ne 0 ]; then
179
+ echo "🟥 git status failed (rc=$_ST_RC) — the worktree could not be enumerated." >&2
180
+ echo " An empty result here is NOT «clean». Do NOT remove the worktree." >&2
181
+ printf ' %s\n' "$_ST" >&2
182
+ exit 10
183
+ fi
184
+ while IFS= read -r _l; do
185
+ [ -n "$_l" ] || continue
186
+ # 🟥 A-1 — the first version used `${_l#?? }`. In parameter expansion the word is a PATTERN, so
187
+ # `?` is a glob: `?? ` matched EVERY porcelain status line. Consequences, all measured:
188
+ # the `!! ` branch was dead code, the `continue` guard never fired, ` M README.md` (a TRACKED
189
+ # file) was reported as OUTSIDE «git will not carry this», and `R old -> new` produced a path
190
+ # that does not exist. Literal `case` patterns instead — and the ??/!! KIND is now kept,
191
+ # because that distinction is the only signal that separates A-3's two populations.
192
+ case "$_l" in
193
+ '?? '*) _p="${_l#?? }"; _k=U ;; # untracked — nobody ever told git about it
194
+ '!! '*) _p="${_l#!! }"; _k=I ;; # ignored — someone wrote a rule for it on purpose
195
+ # 🟥 A-5 — `2>&1` merged git's warnings INTO this stream, and `*) continue` then discarded them
196
+ # as «not a line we parse». git exits 0 on `warning: could not open directory … Permission
197
+ # denied`, so rc alone does not see a PARTIAL enumeration — and a partial enumeration is
198
+ # exactly «unlooked rendered as none». Louder than the `2>/dev/null` it replaced, not quieter.
199
+ 'warning:'*|'fatal:'*|'error:'*) printf ' %s\n' "$_l" >&2; _DIRTY=1; continue ;;
200
+ *) continue ;; # tracked states (M/A/D/R/U…) die with nothing
201
+ esac
202
+ case "$_p" in '"'*'"') _p="${_p#\"}"; _p="${_p%\"}" ;; esac # git quotes non-ASCII paths
203
+ # 🟥 A-10/A-11 — `tracks/` gets its OWN bucket, before anything else looks at it. The 2nd-round
204
+ # code sent it through `_regenerable` (whose first case is `tracks/*`), so every tracks file was
205
+ # labelled «skipped as REGENERABLE» to the reader — the measured loss class, reported as
206
+ # disposable — and the SAME path printed twice, once as ONLY (blocking) and once as SKIP (not).
207
+ # And where `tracks/` is NOT gitignored it arrived as `??` and blocked forever: `--apply` copied
208
+ # it and the screen still said «NOT auto-copied», with rc=1 that re-running never cleared.
209
+ # Both reproduced by execution. It is neither skipped nor blocked here — it is JUDGED BELOW.
210
+ case "$_p" in tracks/*|tracks/) ZONE+=("$_p"); continue ;; esac
211
+ # 🟥 S-2 — the non-blocking set is a NAMED WHITELIST, and it is consulted only for `!!`.
212
+ # An untracked path blocks whatever it is called: a path SHAPED like build output is not
213
+ # evidence that it IS build output when nobody ever told git about it.
214
+ if [ "$_k" = "I" ] && _worktree_local_config "$_p"; then
215
+ CONFIG+=("$_p") # 🟥 4R — named in the verdict, does not block
216
+ elif [ "$_k" = "I" ] && { _runtime_sentinel "$_p" || _regenerable "$_p"; }; then
217
+ SKIPPED+=("$_p") # 🟥 A-2 — counted and listed, never vanished
218
+ else
219
+ OUTSIDE+=("$_p") # untracked, or ignored-but-not-whitelisted → BLOCKS
220
+ fi
221
+ done <<EOF
222
+ $_ST
223
+ EOF
224
+
225
+ # 1-b. tracks/ — both-sides comparison. 🟥 `diff` rc is three-valued: 0 same · 1 differ · 2 ERROR.
226
+ # The first version discarded it, so an EACCES on one subdirectory gave partial output and a
227
+ # green verdict — in the zone that holds the MEASURED loss class. Same face as S-1.
228
+ if [ -d "$SRC" ]; then
229
+ _DF=$(LC_ALL=C diff -rq "$SRC" "$DST" 2>&1); _DF_RC=$?
230
+ if [ "$_DF_RC" -gt 1 ]; then
231
+ echo "🟥 diff failed (rc=$_DF_RC) comparing $SRC — tracks/ could not be compared." >&2
232
+ printf ' %s\n' "$_DF" >&2; exit 10
233
+ fi
50
234
  while IFS= read -r line; do
51
235
  case "$line" in
52
236
  "Only in $SRC"*)
@@ -60,18 +244,40 @@ while IFS= read -r line; do
60
244
  fi ;;
61
245
  "Files $SRC"*" differ") DIFF+=("$(printf '%s' "${line#Files }" | sed "s# and .*##; s#^$SRC/##")") ;;
62
246
  esac
63
- done < <(diff -rq "$SRC" "$DST" 2>/dev/null)
247
+ done <<EOF
248
+ $_DF
249
+ EOF
250
+ fi
64
251
 
65
252
  {
66
253
  echo "# worktree_reclaim — $WT → $ROOT ($TS)"
67
- echo "# only-in-worktree: ${#ONLY[@]} differ-both-sides: ${#DIFF[@]} mode: ${MODE:-enumerate}"
254
+ echo "# blocking: only-in ${#ONLY[@]} · differ ${#DIFF[@]} · outside ${#OUTSIDE[@]} | non-blocking: skipped ${#SKIPPED[@]} · tracks-zone ${#ZONE[@]} · config ${#CONFIG[@]} mode: ${MODE:-enumerate}"
255
+ [ -d "$SRC" ] || echo "# note: worktree has no tracks/ — that ZONE is empty, which is not 'nothing to reclaim'"
68
256
  for p in ${ONLY[@]+"${ONLY[@]}"}; do echo "ONLY $p"; done
69
257
  for p in ${DIFF[@]+"${DIFF[@]}"}; do echo "DIFF $p"; done
258
+ for p in ${OUTSIDE[@]+"${OUTSIDE[@]}"}; do echo "OUTSIDE $p"; done
259
+ for p in ${SKIPPED[@]+"${SKIPPED[@]}"}; do echo "SKIP $p"; done
260
+ for p in ${ZONE[@]+"${ZONE[@]}"}; do echo "ZONE $p"; done
261
+ for p in ${CONFIG[@]+"${CONFIG[@]}"}; do echo "CONFIG $p"; done
70
262
  } > "$LIST" || { echo "🟥 cannot write list file $LIST" >&2; exit 10; }
71
263
  echo "── worktree_reclaim: $NAME ──"
72
- echo " only-in-worktree: ${#ONLY[@]} · differ-both-sides: ${#DIFF[@]} · list: ${LIST#$ROOT/}"
264
+ echo " ⛔ blocking: only-in ${#ONLY[@]} · differ ${#DIFF[@]} · outside ${#OUTSIDE[@]} | ℹ️ non-blocking: skipped ${#SKIPPED[@]} · tracks-zone ${#ZONE[@]} · config ${#CONFIG[@]}"
265
+ echo " list: ${LIST#$ROOT/}"
73
266
  for p in ${ONLY[@]+"${ONLY[@]}"}; do echo " ONLY $p"; done
74
267
  for p in ${DIFF[@]+"${DIFF[@]}"}; do echo " DIFF $p (both sides exist and differ — NOT copied, merge by hand)"; done
268
+ for p in ${OUTSIDE[@]+"${OUTSIDE[@]}"}; do echo " OUTSIDE $p (untracked — git will not carry this, NOT auto-copied)"; done
269
+ for p in ${SKIPPED[@]+"${SKIPPED[@]}"}; do echo " SKIP $p (on the named regenerable/sentinel list — does not block)"; done
270
+ [ "${#ZONE[@]}" -gt 0 ] && echo " ZONE ${#ZONE[@]} path(s) under tracks/ — judged by the tracks/ zone above, not here"
271
+ for p in ${CONFIG[@]+"${CONFIG[@]}"}; do echo " CONFIG $p (worktree-local session config — will be DESTROYED with the worktree)"; done
272
+
273
+ # 🟥 B-6 — this check used to sit AFTER the copy loop, so a partial enumeration printed a column of
274
+ # «✅ reclaimed …» before the warning. Copying is additive, so nothing was destroyed — but a human
275
+ # stops scrolling at green check marks. A partial sweep must not reach the reclaim decision.
276
+ if [ "$_DIRTY" -ne 0 ]; then
277
+ echo "🟥 git reported a warning while enumerating — the sweep was PARTIAL, not clean (rc=10)." >&2
278
+ echo " Nothing was reclaimed. Do NOT remove the worktree." >&2
279
+ exit 10
280
+ fi
75
281
 
76
282
  # 2. RECLAIM (--apply) — copy, then verify byte-identical; a copy that cannot be verified is a harness error
77
283
  if [ "$MODE" = "--apply" ] && [ "${#ONLY[@]}" -gt 0 ]; then
@@ -91,5 +297,34 @@ if [ "${#ONLY[@]}" -gt 0 ] && [ "$MODE" != "--apply" ]; then
91
297
  echo "ℹ️ ${#ONLY[@]} file(s) exist only in the worktree — re-run with --apply to copy them (rc=1 until reclaimed)"
92
298
  exit 1
93
299
  fi
94
- echo "✅ nothing left only in the worktree — safe to: git worktree remove $WT"
300
+ # 🟥 OUTSIDE does not clear with --apply — it is deliberately not copied, so a human must dispose
301
+ # of it before this script will say the removal is safe.
302
+ # 🟥 A-3 — only UNTRACKED blocks. Measured on the real repo: an FH worktree carries ignored runtime
303
+ # sentinels outside tracks/ on every run (`.claude/.prior_art_prompted_<session>`,
304
+ # `.claude/.outbound_hook_events.tsv`, `.claude-octopus/state.json`, …). Blocking on those made
305
+ # rc=1 PERMANENT, and the only ways past are deleting a sentinel the hooks still need or reaching
306
+ # for `git worktree remove --force` — i.e. this script's own header warning («over-blocking trains
307
+ # the override») coming true on its primary target.
308
+ # 🟥 NOT «ignored always passes»: `tracks/**` is ignored AND is the measured loss class, which is
309
+ # exactly why it keeps its own zone above. The split is by PROVENANCE — untracked means nobody
310
+ # ever told git about it, ignored means someone wrote a rule for it on purpose.
311
+ if [ "${#OUTSIDE[@]}" -gt 0 ]; then
312
+ echo "🟥 ${#OUTSIDE[@]} untracked path(s) live ONLY in the worktree and git will not carry them."
313
+ echo " NOT copied — the destination is a judgment call, not a default."
314
+ echo " Move or delete each one, then re-run. Until then: do NOT remove the worktree (rc=1)."
315
+ exit 1
316
+ fi
317
+ # 🟥 A-4 — the green line used to be unconditional, so it said «nothing left» forty lines under a
318
+ # list of files it had just printed. What is skipped must ride along with the verdict.
319
+ if [ "${#CONFIG[@]}" -gt 0 ]; then
320
+ echo "✅ nothing that needs reclaiming — safe to: git worktree remove $WT"
321
+ echo " 🟥 ${#CONFIG[@]} worktree-local config file(s) WILL BE DESTROYED (listed above)."
322
+ echo " A fresh worktree has none; these exist because a session wrote them here."
323
+ [ "${#SKIPPED[@]}" -gt 0 ] && echo " (plus ${#SKIPPED[@]} skipped as regenerable/sentinel)"
324
+ elif [ "${#SKIPPED[@]}" -gt 0 ]; then
325
+ echo "✅ nothing that needs reclaiming — safe to: git worktree remove $WT"
326
+ echo " (${#SKIPPED[@]} path(s) skipped as regenerable/sentinel — listed above, judged, not unseen)"
327
+ else
328
+ echo "✅ nothing left only in the worktree — safe to: git worktree remove $WT"
329
+ fi
95
330
  exit 0
@@ -706,6 +706,26 @@ fi
706
706
  # ⚠️ **채널 검사다**: 「그 값이 옳은가」가 아니라 「이 기록이 템플릿 자신인가」를 묻는다.
707
707
  # 🟥 좁게 잡는다 — 꺾쇠를 정당하게 쓰는 기술 서술을 안 막으려고, **힌트에 실제로 등장하는
708
708
  # 문자열**만 본다. 목록이지 정규식 일반화가 아니다. 힌트를 바꾸면 여기도 같이 바꿔라.
709
+ # ── 문자 수 — 로케일에 의존하지 않는다 (2026-09-21) ───────────────────────────
710
+ # 🟥 `${#var}` 도 `wc -m` 도 **로케일이 센다.** `LC_CTYPE` 이 UTF-8 이 아닌 기계
711
+ # (베어 컨테이너 · 많은 CI 러너 · `LANG` 이 안 걸린 셸)에서는 둘 다 **바이트**를 센다:
712
+ # `대상이 없다` → ${#var} 16 · wc -m 16 (실제 문자 6)
713
+ # `운영자가 승인했다고 한다` → ${#var} 35 (실제 문자 13)
714
+ # 방향이 **fail-OPEN 이다** — 한글 근거가 약 3배로 크레딧돼 `-lt 20` 류 하한을 공짜로
715
+ # 넘는다. 영어로 쓴 같은 길이의 근거는 막히는데 한글 근거는 통과한다. #780 의 `wc -w`
716
+ # 결함과 **같은 클래스, 방향만 반대**(저쪽은 과차단, 이쪽은 fail-open).
717
+ # 🟥 이 레포의 하한 주석들은 전부 «chars» / «자» 라고 적고 있다 — 의도는 처음부터
718
+ # 문자였고, 계기가 그것을 구현하지 않았을 뿐이다. 이 훅 자신도 두 자리에서 이미
719
+ # 그렇게 적어두고( `${#}` is locale-dependent ) 열두 줄 뒤에 어겼다.
720
+ # 셈법: UTF-8 의 이어지는 바이트(0x80–0xBF)를 지우면 문자당 선두 바이트 하나만 남으므로,
721
+ # 남은 바이트 수가 곧 문자 수다. **UTF-8 기계에서는 `${#var}` 와 같은 수**이고(한글
722
+ # 포함, 실측) 따라서 기존 문턱값이 한 칸도 안 움직인다 — 바뀌는 것은 바이트 로케일뿐.
723
+ # ⚠️ 명시된 잔여: 결합 문자(NFD)와 이모지 ZWJ 열은 코드포인트 단위로 세진다. 그것은
724
+ # `${#var}` 가 UTF-8 기계에서 하던 셈법 그대로이므로 회귀가 아니라 동등이다.
725
+ _charlen() { # $1 = 문자열 → 문자 수 (로케일 무관)
726
+ printf '%s' "${1-}" | LC_ALL=C tr -d '\200-\277' | LC_ALL=C wc -c | tr -d ' '
727
+ }
728
+
709
729
  _marker_template_residue() { # $1 = 줄 내용 → 0 = 템플릿 잔여
710
730
  # 🟥 **세 번째 설계다. 앞의 둘이 왜 틀렸는지 남긴다** (cross-family 3라운드, 자력 적발 0).
711
731
  # v1 손목록 → 규칙 문서가 새 자리표시자를 실을 때마다 어긋났다(구조적 desync).
@@ -814,7 +834,7 @@ validate_defense_leg() { # $1 = marker path — fires ONLY at the floor tiers (s
814
834
  v=$(printf '%s' "$v" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')
815
835
  case "$(printf '%s' "$v" | tr 'A-Z' 'a-z')" in
816
836
  ok|yes|y|n/a|na|none|done|true|-|tbd|todo) bad="$bad $k(vacuous:'$v')" ;;
817
- *) [ "${#v}" -ge 12 ] || bad="$bad $k(too short:'$v')" ;;
837
+ *) [ "$(_charlen "$v")" -ge 12 ] || bad="$bad $k(too short:'$v')" ;;
818
838
  esac
819
839
  done
820
840
  if [ -n "$bad" ]; then
@@ -903,7 +923,14 @@ validate_crossfamily_leg() { # $1 = marker path
903
923
  # `panel(codex,` — a well-formed panel rejected as malformed. An over-block on the
904
924
  # correct shape is the failure that teaches --no-verify, so it is a defect, not strictness.
905
925
  val=$(printf '%s' "$line" | sed -E 's/[[:space:]]*(—|--).*$//' | sed -E 's/[[:space:]]+$//')
906
- reason=$(printf '%s' "$line" | sed -E 's/^[^—-]*(—|--)[[:space:]]*//')
926
+ # 🟥 `[^—-]*` 금지 — 브래킷은 비-UTF-8 로케일에서 바이트 집합이 된다
927
+ # (scripts/multibyte_bracket_lint.sh 가 이 자리를 막는다). `val` 이 이미 «구분자 앞» 이므로
928
+ # 그 접두를 떼면 부정 클래스 없이 구해지고, 구분자가 맨 앞이라 앵커로 벗길 수 있다.
929
+ # 부수 효과로 로케일과 무관한 실물 버그가 닫힌다: 값에 하이픈이 있고 ASCII 이중대시를 쓰면
930
+ # (`panel(a) -- 근거`) 옛 식은 아무것도 못 벗겨 reason 이 통째로 남았고, 바로 아래 비교가
931
+ # 그것을 **빈 근거**로 렌더해 정상 마커를 과차단했다(2026-09-21 실측).
932
+ reason=${line#"$val"}
933
+ reason=$(printf '%s' "$reason" | sed -E 's/^[[:space:]]*(—|--)[[:space:]]*//')
907
934
  [ "$reason" = "$line" ] && reason=""
908
935
 
909
936
  # residency= token — computed once, consumed by whichever branch below needs it (REQUIRED for
@@ -1000,7 +1027,7 @@ validate_crossfamily_leg() { # $1 = marker path
1000
1027
  fi ;;
1001
1028
  esac
1002
1029
  done
1003
- if [ "${#reason}" -lt 20 ] || [ -z "$_cf_cited" ]; then
1030
+ if [ "$(_charlen "$reason")" -lt 20 ] || [ -z "$_cf_cited" ]; then
1004
1031
  echo " ❌ FAIL — 'declined' must cite a record that EXISTS on disk."
1005
1032
  echo " declined = the OPERATOR declined sidecars, a chosen floor. It does NOT mean"
1006
1033
  echo " 'I judged decorrelation unnecessary here' — that is a CHOICE the author made"
@@ -1010,7 +1037,7 @@ validate_crossfamily_leg() { # $1 = marker path
1010
1037
  echo " crossfamily: declined — chosen floor per CLAUDE.local.md §sidecar"
1011
1038
  echo " No such record → you are not describing an operator declination:"
1012
1039
  echo " crossfamily: DEGRADED_PANEL_UNUSED — codex+agy reachable, not recruited (<why>)"
1013
- [ "${#reason}" -ge 20 ] && echo " (grounds were substantive but named no resolvable path)"
1040
+ [ "$(_charlen "$reason")" -ge 20 ] && echo " (grounds were substantive but named no resolvable path)"
1014
1041
  return 1
1015
1042
  fi
1016
1043
  if [ "$_res_active" -eq 1 ] && [ "$_res_ntok" -gt 0 ]; then
@@ -1178,7 +1205,7 @@ validate_crossfamily_leg() { # $1 = marker path
1178
1205
  SHARED|MIXED)
1179
1206
  # 문자 수 기준(공백 제외). 4자 미만이면 «diff» 같은 한 토큰이고, 그건 어느 산출물인지
1180
1207
  # 말하지 않는다. 🟥 낱말 수로 세지 않는다 — CJK 와 하이픈 복합어가 전부 1 낱말이 된다.
1181
- if [ "$(printf '%s' "$_ev_strip" | wc -m | tr -d ' ')" -lt 6 ]; then
1208
+ if [ "$(_charlen "$_ev_strip")" -lt 6 ]; then
1182
1209
  echo " ❌ FAIL — evidence=$_ev_kind(...) body too thin to identify the artifact: '$_ev_body'"
1183
1210
  echo " Name it (\"same staged diff\", \"one findings.jsonl\", \"동일 프롬프트 파일\")."
1184
1211
  echo " A bare $_ev_kind(diff) records the weak arm as if it were documented."
@@ -1191,7 +1218,7 @@ validate_crossfamily_leg() { # $1 = marker path
1191
1218
  # A degrade is allowed; being silent about WHICH degrade, or about its grounds, is not.
1192
1219
  # Two conditions, because either alone is porous: enough substance to be a statement
1193
1220
  # (length) AND a token naming what was actually looked at.
1194
- if [ "${#reason}" -lt 20 ] \
1221
+ if [ "$(_charlen "$reason")" -lt 20 ] \
1195
1222
  || ! printf '%s' "$reason" | grep -qiE 'prob(e|ed|ing)|reachab|unreach|not reachable|0 |none reachable|empty|absent|declin|consent|codex|gemini|agy|copilot|gateway|cli|panel|scope|budget|offline'; then
1196
1223
  echo " ❌ FAIL — $val without substantive grounds on the same line."
1197
1224
  case "$val" in
@@ -1321,7 +1348,11 @@ validate_standpoint_leg() { # $1 = marker path
1321
1348
  'standpoint: tier2' misses it; drop the quotes next time]";; esac
1322
1349
  line=$(printf '%s' "$line" | sed -E 's/^["'"'"']//; s/["'"'"']$//')
1323
1350
  val=$(printf '%s' "$line" | sed -E 's/[[:space:]]*(—|--).*$//' | sed -E 's/[[:space:]]+$//')
1324
- reason=$(printf '%s' "$line" | sed -E 's/^[^—-]*((—|--)[[:space:]]*)?//')
1351
+ # 🟥 `[^—-]*` 금지 — 위 crossfamily 자리와 같은 이유·같은 처방(lint 가 막는다).
1352
+ # 옛 식은 구분자가 없으면 `[^—-]*` 가 값의 첫 하이픈까지만 먹고 옵셔널 그룹을 건너뛰어
1353
+ # `not-applicable — 근거` 를 `-applicable — 근거` 로 **깨진 근거**로 만들었다(실측).
1354
+ reason=${line#"$val"}
1355
+ reason=$(printf '%s' "$reason" | sed -E 's/^[[:space:]]*(—|--)[[:space:]]*//')
1325
1356
  # Cross-axis contamination. `crossfamily:` and `standpoint:` each carry a three-way degrade
1326
1357
  # triad and the doctrine says the literals are DISTINCT ON PURPOSE. Borrowing the other axis's
1327
1358
  # token records the wrong axis while looking well-formed.
@@ -1346,7 +1377,7 @@ validate_standpoint_leg() { # $1 = marker path
1346
1377
  # ⓒ «출력» 의 형태(`30/30`, `rc=`, `./path`)도 실행의 증거로 받는다.
1347
1378
  # ⚠️ 방향: 이건 **느슨하게** 만드는 변경이다. 막고 싶은 것은 «명령도 출력도 안 적은 줄» 이고,
1348
1379
  # 길이 20 자 하한은 그대로 남는다.
1349
- if [ "${#reason}" -lt 20 ] || ! printf '%s' "$reason" \
1380
+ if [ "$(_charlen "$reason")" -lt 20 ] || ! printf '%s' "$reason" \
1350
1381
  | grep -qiE '(^|[^[:alpha:]])(ran|run|runs|exec|invoke[ds]?|call|calls|called|exit|output|suite|test|tests|tested|bash|sh|zsh|grep|npm|pnpm|yarn|pytest|python|python3|cargo|make|go|gradle|mvn|dotnet|node|command)([^[:alpha:]]|$)|실행|돌렸|돌린|돌려|호출|출력|스위트|커맨드|rc=|[0-9]+/[0-9]+|\./'; then
1351
1382
  # Grace: markers dated before STANDPOINT_GROUNDS_GRACE_DATE keep the old advisory
1352
1383
  # behaviour (no retro-blocking), same pattern as the residency=/evidence= tokens.
@@ -1382,7 +1413,7 @@ validate_standpoint_leg() { # $1 = marker path
1382
1413
  not-applicable)
1383
1414
  # §7: asserting non-applicability without naming what was checked is indistinguishable from
1384
1415
  # UNKNOWN wearing a permissive label. Measured: 6 bare instances in this corpus.
1385
- if [ "${#reason}" -lt 20 ]; then
1416
+ if [ "$(_charlen "$reason")" -lt 20 ]; then
1386
1417
  echo " ❌ FAIL — bare 'not-applicable' with no grounds on the same line."
1387
1418
  echo " That is UNKNOWN wearing a permissive label. Name what you checked:"
1388
1419
  echo " no named peer carries this surface AND it changes no consumer-visible behavior."
@@ -1390,7 +1421,7 @@ validate_standpoint_leg() { # $1 = marker path
1390
1421
  fi
1391
1422
  echo " ✅ standpoint leg: not-applicable$quoted" ;;
1392
1423
  DEGRADED_NO_TARGET_ACCESS*|DEGRADED_NOT_RUN*|UNKNOWN*)
1393
- if [ "${#reason}" -lt 20 ]; then
1424
+ if [ "$(_charlen "$reason")" -lt 20 ]; then
1394
1425
  echo " ❌ FAIL — $val without substantive grounds on the same line."
1395
1426
  echo " could-not / did-not / did-not-look are separate values on purpose; collapsing"
1396
1427
  echo " them renders an unrun probe as a zero finding. Name what you probed."
@@ -1479,7 +1510,7 @@ validate_thirdparty_leg() { # $1 = marker path
1479
1510
  return 1 ;;
1480
1511
  esac
1481
1512
  reason=$(printf '%s' "$line" | sed -E 's/^[^(]*\(//')
1482
- if [ "${#reason}" -lt 12 ]; then
1513
+ if [ "$(_charlen "$reason")" -lt 12 ]; then
1483
1514
  echo " ❌ FAIL — '$val(...)' grounds are vacuous. Name what was searched and what came back."
1484
1515
  return 1
1485
1516
  fi
@@ -1632,7 +1663,7 @@ validate_defeater_leg() { # $1 = marker path
1632
1663
  esac
1633
1664
  # 비공허성 — 한글 코퍼스이므로 **낱말 수**로 센다. `${#}` 는 로케일 의존이고, 긴 한글 한 덩어리가
1634
1665
  # 문자 수 검사를 그냥 통과한 전례가 있다(A6 레인).
1635
- words=$(printf '%s' "$body" | wc -w | tr -d ' '); words=${words:-0}
1666
+ words=$(printf '%s\n' "$body" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.'); words=${words:-0}
1636
1667
  if [ "$words" -lt 6 ]; then
1637
1668
  echo " ❌ FAIL — defeater 가 공허하다 ($words 낱말). **무엇이 관측될 것인가**를 적어라."
1638
1669
  echo " '틀렸을 수 있다' 는 반증 조건이 아니다 — 관측 가능한 사건이어야 한다."
@@ -1640,8 +1671,12 @@ validate_defeater_leg() { # $1 = marker path
1640
1671
  fi
1641
1672
  # 🟥 기록의 속성 하나 더: defeater 가 ①영혼 줄의 **복붙**이면 두 필드가 한 필드다.
1642
1673
  # (이것은 «내용이 옳은가»가 아니라 «두 칸이 서로 다른 값을 담는가»다 — 채널 검사.)
1643
- soul_line=$(grep -m1 -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul)[[:space:]]*[:—-]' "$m" 2>/dev/null \
1644
- | sed -E 's/^[^:—-]*[:—-][[:space:]]*//; s/[[:space:]]+$//')
1674
+ # 🟥 A multibyte character inside a BRACKET EXPRESSION is a byte set under LC_CTYPE=POSIX, so
1675
+ # `[:—-]` there matches the lead byte of 「①」 and `[^:—-]*` stops on it. Measured 2026-09-21:
1676
+ # lane D9-copy-of-soul-blocks went BLOCK → **PASS** with LANG unset — a fail-OPEN, unlike the
1677
+ # word-count defect above. Alternation is byte-safe in every locale; brackets are not.
1678
+ soul_line=$(grep -m1 -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul)[[:space:]]*(:|—|-)' "$m" 2>/dev/null \
1679
+ | sed -E 's/^[[:space:]]*#*[[:space:]]*(①영혼|soul)[[:space:]]*(:|—|-)[[:space:]]*//; s/[[:space:]]+$//')
1645
1680
  if [ -n "$soul_line" ] && [ "$body" = "$soul_line" ]; then
1646
1681
  echo " ❌ FAIL — defeater 가 ①영혼 줄과 글자 그대로 같다. 두 칸이 한 칸이 되었다."
1647
1682
  echo " 성공 정의와 그 반증 조건은 다른 문장이다."
@@ -1731,7 +1766,7 @@ validate_affected_leg() { # $1 = marker path
1731
1766
  echo " ❌ FAIL — affected 가 힌트의 자리표시자 그대로다 (기록이 아직 안 쓰였다)."
1732
1767
  return 1
1733
1768
  fi
1734
- words=$(printf '%s' "$body" | wc -w | tr -d ' '); words=${words:-0}
1769
+ words=$(printf '%s\n' "$body" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.'); words=${words:-0}
1735
1770
  if [ "$words" -lt 3 ]; then
1736
1771
  echo " ❌ FAIL — affected 가 공허하다 ($words 낱말). 건드리는 것 · 열린 질문을 적어라."
1737
1772
  return 1
@@ -1855,7 +1890,7 @@ validate_oracle_leg() { # $1 = marker path
1855
1890
  echo " ❌ FAIL — oracle 근거가 힌트의 자리표시자 그대로다 (기록이 아직 안 쓰였다)."
1856
1891
  return 1
1857
1892
  fi
1858
- words=$(printf '%s' "$rest" | wc -w | tr -d ' '); words=${words:-0}
1893
+ words=$(printf '%s\n' "$rest" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.'); words=${words:-0}
1859
1894
  if [ "$words" -lt 2 ]; then
1860
1895
  echo " ❌ FAIL — oracle 근거가 공허하다 ($words 낱말). 무엇을 무엇과 대조했는지 적어라."
1861
1896
  return 1
@@ -1919,7 +1954,7 @@ validate_soul_present_leg() { # $1 = marker path
1919
1954
  # corpus writes «## ①영혼 — 설계 전에 쓴 …» as a heading, and P7 flipped to BLOCK when the first
1920
1955
  # version of this regex forbade it. The known-pair caught that in one run).
1921
1956
  # Prose inside a field VALUE can no longer vote.
1922
- _soul_src=$(grep -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*[:—-]' "$m" 2>/dev/null \
1957
+ _soul_src=$(grep -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*(:|—|-)' "$m" 2>/dev/null \
1923
1958
  | grep -vE '^[[:space:]]*soul-check[[:space:]]*:')
1924
1959
  n=$(printf '%s\n' "$_soul_src" | grep -cE '①영혼|^[[:space:]]*soul:|성공 ?정의|절대 안 함'); n=${n:-0}
1925
1960
  if [ "$n" -eq 0 ]; then
@@ -1937,7 +1972,7 @@ validate_soul_present_leg() { # $1 = marker path
1937
1972
  f && /^[[:space:]]*$/{exit}
1938
1973
  f && seen && /^[[:space:]]*[A-Za-z][A-Za-z0-9_-]*:/{exit}
1939
1974
  f{print; seen=1}' <<< "$_soul_src")
1940
- words=$(printf '%s' "$body" | wc -w | tr -d ' '); words=${words:-0}
1975
+ words=$(printf '%s\n' "$body" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.'); words=${words:-0}
1941
1976
  # 🟥 A DECLARED ABSENCE IS A VALUE, not a gap. CLAUDE.md §자기 대조 explicitly permits
1942
1977
  # «없으면 `없음`», and the first version of this leg BLOCKED a bare `soul: 없음` (2 words) while
1943
1978
  # PASSING a 33-word paragraph whose content was «I did not write one». That punishes the honest
@@ -1948,7 +1983,7 @@ validate_soul_present_leg() { # $1 = marker path
1948
1983
  # 🟥 `$body` — this leg's own local. The first version read `$soul_body`, which is the OTHER
1949
1984
  # leg's variable name; unset here, so the case never matched and the fix was inert while the
1950
1985
  # lane suite stayed green ([[feedback_unedited_parts_of_my_own_file]] · half-fix).
1951
- _sbare=$(printf '%s' "$body" | sed -E 's/^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*[:—-]*//' | tr -d '[:space:].·]')
1986
+ _sbare=$(printf '%s' "$body" | sed -E 's/^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*(:|—|-)*//' | tr -d '[:space:].·]')
1952
1987
  case "$_sbare" in
1953
1988
  없음|없음—|none|None|NONE|n/a|N/A|-|해당없음)
1954
1989
  echo " ⚠️ ①영혼: 없음 — declared absent. Recorded, not silent."
@@ -2072,7 +2107,7 @@ DEGRADED_SINGLE_FAMILY|DEGRADED_PANEL_UNUSED|DEGRADED_NO_TARGET_ACCESS|DEGRADED_
2072
2107
  # corpus writes «## ①영혼 — 설계 전에 쓴 …» as a heading, and P7 flipped to BLOCK when the first
2073
2108
  # version of this regex forbade it. The known-pair caught that in one run).
2074
2109
  # Prose inside a field VALUE can no longer vote.
2075
- _soul_src=$(grep -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*[:—-]' "$m" 2>/dev/null \
2110
+ _soul_src=$(grep -E '^[[:space:]]*#*[[:space:]]*(①영혼|soul|절대 안 함|성공 ?정의)[[:space:]]*(:|—|-)' "$m" 2>/dev/null \
2076
2111
  | grep -vE '^[[:space:]]*soul-check[[:space:]]*:')
2077
2112
  soul_n=$(printf '%s\n' "$_soul_src" | grep -cE '①영혼|^[[:space:]]*soul:|성공 ?정의|절대 안 함'); soul_n=${soul_n:-0}
2078
2113
  # Body = the ①영혼 block only: stop at a blank line OR at the next ASCII field key. An earlier
@@ -2080,16 +2115,35 @@ DEGRADED_SINGLE_FAMILY|DEGRADED_PANEL_UNUSED|DEGRADED_NO_TARGET_ACCESS|DEGRADED_
2080
2115
  # scored as having content — the fixture G9 caught it.
2081
2116
  # 🟥 Counted in WORDS, not characters. `${#var}` on Korean text is bytes-or-chars depending on
2082
2117
  # locale, and this corpus is Korean — a char threshold silently changes meaning per machine
2083
- # ⚠️ Honest caveat, measured: `wc -w` is NOT a human word count on Korean either («①영혼: 완주»
2118
+ # ⚠️ Honest caveat, measured: this is NOT a human word count on Korean either («①영혼: 완주»
2084
2119
  # reports 3, not 2). It is stable per-machine and monotonic, which is all a floor needs — but
2085
2120
  # every threshold here was calibrated by RUNNING it, never by reasoning about word counts.
2086
- # ([[feedback_instrument_vs_target_and_budget]], 단위 혼동). Word count is locale-independent.
2121
+ # ([[feedback_instrument_vs_target_and_budget]], 단위 혼동).
2122
+ # 🟥 RETRACTED 2026-09-21 — this comment used to end «Word count is locale-independent.» and
2123
+ # that sentence was FALSE. `wc -w` splits on whitespace as the LOCALE classifies characters:
2124
+ # with LANG unset (LC_CTYPE=POSIX — the default in a bare container or CI runner) a Korean
2125
+ # grounds line counts **0** words and a mixed line counts only its ASCII tokens. Known pair,
2126
+ # measured in a clean clone of a9e9b29: `LC_ALL=POSIX` → 0, `LC_ALL=C.UTF-8` → 8, same bytes.
2127
+ # The whole point of choosing words over `${#var}` was locale-independence, so the instrument
2128
+ # was selected on a property it did not have. ⇒ counted by splitting on ASCII whitespace with
2129
+ # `tr` and counting non-empty lines under a forced `LC_ALL=C` — byte-level, identical in both
2130
+ # locales, and identical to the old `wc -w` numbers on any UTF-8 machine (so no threshold moves
2131
+ # where the gate already worked). Anchor: scripts/test_locale_invariance_lanes.sh.
2087
2132
  soul_body=$(awk '/①영혼|^[[:space:]]*soul:|성공 ?정의|절대 안 함/{if (!f) f=1}
2088
2133
  f && /^[[:space:]]*$/{exit}
2089
2134
  f && seen && /^[[:space:]]*[A-Za-z][A-Za-z0-9_-]*:/{exit}
2090
2135
  f{print; seen=1}' "$m" 2>/dev/null \
2091
- | sed -E '1s/^[[:space:]]*(①영혼|soul)[^[:alnum:]«]*//')
2092
- soul_words=$(printf '%s' "$soul_body" | wc -w | tr -d ' ')
2136
+ | sed -E '1s/^[[:space:]]*(①영혼|soul)([[:space:]]*(:|—|-))*[[:space:]]*//')
2137
+ # 🟥 2026-09-21 — 위 strip 은 `[^[:alnum:]«]*` 였다. `[:alnum:]` 은 `LC_CTYPE=POSIX` 에서
2138
+ # **ASCII 전용**이라, 「«」 도 ASCII 영숫자도 없는 **순한글 ①영혼 줄**이 부정 클래스에
2139
+ # 통째로 먹혀 soul_body 가 빈 문자열이 됐다. 방향이 둘이다 — 정상 한글 마커가 차단되고
2140
+ # (ⓐ), 영혼 줄이 멀쩡히 있는데 `DEGRADED_NO_SOUL` 을 적은 거짓 주장이 통과한다(ⓒ).
2141
+ # 측정된 known pair: 순한글 본문 `LC_ALL=POSIX` → 0 낱말 / `C.UTF-8` → 8, 같은 바이트를
2142
+ # ASCII 로 쓴 컨트롤은 두 로케일 모두 6. ⇒ 구분자를 **교차**로 적어 바이트 집합 퇴화를
2143
+ # 피한다. UTF-8 기계에서는 실제 마커 형태 전부에서 옛 식과 같은 수를 낸다(문턱값 불변).
2144
+ # 🟥 이 결함은 위 낱말 세기 수리 **뒤에야 관측 가능하다** — 그 전에는 셈법이 먼저
2145
+ # 죽어서 어느 쪽 원인인지 갈리지 않았다. 앵커: test_locale_invariance_lanes.sh L11.
2146
+ soul_words=$(printf '%s\n' "$soul_body" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.')
2093
2147
  soul_words=${soul_words:-0}
2094
2148
 
2095
2149
  case "$val" in
@@ -2108,7 +2162,7 @@ DEGRADED_SINGLE_FAMILY|DEGRADED_PANEL_UNUSED|DEGRADED_NO_TARGET_ACCESS|DEGRADED_
2108
2162
  # 🟥 agy (claims axis, 2026-08-21): this leg's own comment above condemns `${#var}` on
2109
2163
  # Korean text and then used `${#reason}` twelve lines later — [[feedback_citing_a_rule_is_not_obeying_it]],
2110
2164
  # verbatim. Inherited from the sibling legs, which does not excuse it here. Word count.
2111
- _rwords=$(printf '%s' "$reason" | wc -w | tr -d ' '); _rwords=${_rwords:-0}
2165
+ _rwords=$(printf '%s\n' "$reason" | tr -s ' \t\n' '\n' | LC_ALL=C grep -c '.'); _rwords=${_rwords:-0}
2112
2166
  if [ "$_rwords" -lt 3 ]; then
2113
2167
  echo " ❌ FAIL — '$val(...)' grounds are vacuous. Name what read the ①영혼 line back,"
2114
2168
  echo " against what, and what came back."
@@ -2258,7 +2312,15 @@ validate_first_use_leg() { # $1 = marker path
2258
2312
  echo " 읽는 사람과 기계가 같은 값을 보지 않는다. 한 줄에 한 번만 적어라."
2259
2313
  return 1
2260
2314
  fi
2261
- e_val=$(printf '%s' "$line" | sed -n 's/.*[[:space:]]ⓔ=\([^ⓕ]*\).*/\1/p' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
2315
+ # 🟥 2026-09-21 — 포착식은 `[^ⓕ]*` 였다. 브래킷 안의 「ⓕ」는 `LC_CTYPE=POSIX` 에서
2316
+ # **바이트 집합 {E2,93,95}** 이라, ⓔ 값이 E2 로 시작하면(`→…` · `①…` · 한글) 포착이
2317
+ # 빈 문자열이 되고 바로 아래 `''|none|…` 가지에 걸려 **채워진 필드가 «none» 으로 차단**된다.
2318
+ # 하필 fh_4axis_gate.md 가 권하는 포인터 형태와 `shadow(...)` 앞의 화살표가 그 모양이다.
2319
+ # 측정된 known pair: `ⓔ=→shadow(N=3, F=2)` → POSIX `[]` / UTF-8 `[→shadow(N=3, F=2)]`,
2320
+ # ASCII 컨트롤 `ⓔ=shadow(...)` 는 두 로케일 모두 포착된다. ⇒ 브래킷을 버리고 리터럴
2321
+ # 「ⓕ」로 자른다(리터럴은 바이트열 그대로 맞으므로 로케일 무관). `-n` 의 «맞을 때만
2322
+ # 출력» 의미는 주소 블록으로 보존한다. 앵커: test_locale_invariance_lanes.sh L12.
2323
+ e_val=$(printf '%s' "$line" | sed -E -n '/[[:space:]]ⓔ=/{ s/.*[[:space:]]ⓔ=//; s/ⓕ.*//; p; }' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
2262
2324
  case "$e_val" in
2263
2325
  ''|none|None|NONE|-)
2264
2326
  echo " ❌ MARKER — 이 커밋은 **새 계기를 추가**하는데 'axes-run' 의 ⓔ(첫 실사용)이 'none' 이다."
@@ -2445,8 +2507,27 @@ validate_marker_floor() {
2445
2507
  # Rubber-stamp guard: the ack must contain a QUOTED operator utterance
2446
2508
  # ("..." or “…”, ≥2 chars). A bare reason is agent-self-writable; a quote
2447
2509
  # ties the ack to a conversational event auditable in the session record.
2510
+ #
2511
+ # 🟥 2026-09-21 — the curly-quote arm was `“[^”]{2,}”` and that bracket is the
2512
+ # same locale defect as the two sites above. `”` is E2 80 9D; under a byte
2513
+ # locale `[^”]` becomes «not E2, not 80, not 9D», and Korean syllables carry
2514
+ # byte 80 as a continuation (`대` = EB 8C 80), so the negated class ends
2515
+ # inside the quoted utterance and the closing `”` is never reached. Measured
2516
+ # known pair on this machine, `below-floor-ack: “그대로 진행해” — 승인했다`
2517
+ # → LC_ALL=POSIX BLOCK / LC_ALL=C.utf8 pass; the ASCII-quote control passes
2518
+ # in both and the no-quote known-negative blocks in both, so the instrument
2519
+ # discriminates and only the Korean arm moves. Same fairness shape as the
2520
+ # word count: an operator utterance quoted in Korean typography reads as
2521
+ # «no quote present» on a machine without a UTF-8 locale, while the English
2522
+ # one passes. `.{2,}` carries no bracket, so both locales agree on every
2523
+ # realistic input (`“”` and `“a”` still block in both).
2524
+ # ⚠️ Named residual: under a byte locale the ≥2 is counted in BYTES, so a
2525
+ # single Korean character (`“가”`, 3 bytes) satisfies it where UTF-8 rejects
2526
+ # it — a one-character margin at a pathological input, and strictly narrower
2527
+ # than today's blanket rejection of every Korean-quoted ack.
2528
+ # Lane: scripts/test_locale_invariance_lanes.sh L13.
2448
2529
  if ! grep -m1 -E '^[[:space:]]*below-floor-ack:' "$m" \
2449
- | grep -qE '"[^"]{2,}"|“[^”]{2,}”'; then
2530
+ | grep -qE '"[^"]{2,}"|“.{2,}”'; then
2450
2531
  echo " ❌ BELOW-FLOOR ack without quoted operator utterance (rubber-stamp guard)"
2451
2532
  echo " The ack line must quote the operator's approval verbatim:"
2452
2533
  echo " below-floor-ack: \"<what the operator actually said>\" — <reason>"