@chrono-meta/fh-gate 3.34.0 → 3.36.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 (44) hide show
  1. package/.claude-plugin/marketplace.json +5 -5
  2. package/CHEATSHEET.md +1 -0
  3. package/README.md +2 -2
  4. package/docs/USER_GUIDE.md +7 -3
  5. package/knowledge/shared/harness-core/field_verdict_crossfamily_gate.md +2 -0
  6. package/knowledge/shared/learnings/subagent_invocations_log.yaml +48 -0
  7. package/package.json +2 -1
  8. package/plugins/fh-commons/.claude-plugin/plugin.json +2 -2
  9. package/plugins/fh-commons/agents/a11y-lens.md +11 -0
  10. package/plugins/fh-commons/agents/be-dev-lens.md +11 -0
  11. package/plugins/fh-commons/agents/designer-lens.md +11 -0
  12. package/plugins/fh-commons/agents/fe-dev-lens.md +11 -0
  13. package/plugins/fh-commons/agents/qa-lens.md +11 -0
  14. package/plugins/fh-commons/agents/ux-writer-lens.md +11 -0
  15. package/plugins/fh-commons/skills/deliberation/SKILL.md +3 -11
  16. package/plugins/fh-commons/skills/deliberation/SKILL_detail.md +19 -0
  17. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +8 -80
  18. package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +107 -0
  19. package/plugins/fh-commons/skills/standpoint-review/SKILL.md +235 -0
  20. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  21. package/plugins/fh-meta/CHANGELOG.md +30 -0
  22. package/plugins/fh-meta/agents/fact-checker.md +11 -0
  23. package/plugins/fh-meta/agents/hub-persona-auditor.md +13 -0
  24. package/plugins/fh-meta/agents/persona-innovator.md +12 -0
  25. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +6 -103
  26. package/plugins/fh-meta/skills/auto-decorrelation/SKILL_detail.md +132 -0
  27. package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL.md +3 -20
  28. package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL_detail.md +36 -0
  29. package/plugins/fh-meta/skills/install-doctor/SKILL.md +4 -25
  30. package/plugins/fh-meta/skills/install-doctor/SKILL_detail.md +44 -0
  31. package/plugins/fh-meta/skills/verify-bidirectional/SKILL.md +7 -51
  32. package/plugins/fh-meta/skills/verify-bidirectional/SKILL_detail.md +75 -0
  33. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  34. package/plugins/fh-preprep/skills/preprep/SKILL.md +7 -207
  35. package/plugins/fh-preprep/skills/preprep/SKILL_detail.md +235 -0
  36. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  37. package/scripts/degrade_direction_scan.sh +87 -1
  38. package/scripts/pr_merge_verified.sh +20 -3
  39. package/scripts/selfcheck.sh +155 -7
  40. package/scripts/test_degrade_scan_shell_probes.sh +63 -0
  41. package/scripts/test_pr_merge_verified_lanes.sh +33 -0
  42. package/scripts/test_selfcheck_shard_lanes.sh +135 -0
  43. package/templates/.git-hooks/pre-commit +1 -1
  44. package/templates/degrade_direction_scan.sh +87 -1
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env bash
2
+ # test_selfcheck_shard_lanes.sh — known-pair anchor for `selfcheck.sh --shard i/N`.
3
+ #
4
+ # WHAT IS PROVED, and how (every claim below is a lane, with a control that can fail):
5
+ # S1 bad --shard arguments are refused with rc 2 and run nothing (not a pass).
6
+ # S2 UNION: the suites shard 1..N run are exactly the suites an unsharded plan (1/1) runs.
7
+ # S3 DISJOINT: no suite basename is run by two shards.
8
+ # S4 NON-VACUOUS: the full set is large and contains a suite we know is wired (a lane that
9
+ # compares two empty sets passes — the control is a fact about the target, not the shim).
10
+ # S5 KNOWN-NEGATIVE: the same duplicate/union detector, pointed at a selfcheck whose assignment is
11
+ # broken on purpose (every shard "owns" every suite), must go RED. A detector that cannot fail
12
+ # proves nothing about S2/S3.
13
+ # S6 --shard ABSENT = today: the lifted helper block defines no `bash` function and every helper
14
+ # answers "run it".
15
+ # S7 every shard owns at least one suite for N in 2..4 (an empty shard is a wasted runner and a
16
+ # sign the plan collapsed).
17
+ # The runs are DRY (`--shard-dry`): nothing is executed, the decision is appended to $FH_SHARD_TRACE.
18
+ # So this suite costs seconds, and it cannot recurse into itself (a dry run never runs a suite).
19
+ set -u
20
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ ROOT="$(cd "$HERE/.." && pwd)"
22
+ SC="$ROOT/scripts/selfcheck.sh"
23
+ [ -f "$SC" ] || { echo "FAIL selfcheck shard lanes: subject $SC missing"; exit 1; }
24
+ T=$(mktemp -d "${TMPDIR:-/tmp}/shardlanes.XXXXXX") || { echo "HARNESS ERROR mktemp -d failed — lanes NOT run (not a pass)"; exit 10; }
25
+ : "${T:?}"
26
+ trap 'rm -rf "$T"' EXIT
27
+ pass=0; failn=0
28
+ chk() { # chk <rc> <label>
29
+ if [ "$1" -eq 0 ]; then pass=$((pass + 1)); echo " ✅ $2"; else failn=$((failn + 1)); echo " ❌ $2"; fi
30
+ }
31
+
32
+ # plan <selfcheck> <root> <i> <N> <out> — one dry run; the trace file is the evidence.
33
+ plan() {
34
+ : > "$5"
35
+ ( cd "$2" && env -u FH_SELFCHECK_SHARD FH_SHARD_TRACE="$5" bash "$1" --shard "$3/$4" --shard-dry >/dev/null 2>&1 )
36
+ }
37
+ names() { awk '$1 == "RUN" { print $2 }' "$1" | LC_ALL=C sort -u; }
38
+
39
+ # ── S1 argument validation ────────────────────────────────────────────────────────────────────
40
+ for bad in 0/4 5/4 2 x/4 2/x 1/0 "" 01/4 /4 1/04 999/1000; do # 01/4 · /4 · 1/04 · 999/1000 = codex R1 2026-10-31 (ran nothing, printed PASS)
41
+ out=$(cd "$ROOT" && env -u FH_SELFCHECK_SHARD bash "$SC" --shard "$bad" --shard-dry 2>&1); rc=$?
42
+ [ "$rc" -eq 2 ] && printf '%s' "$out" | grep -q 'HARNESS ERROR'; chk $? "S1 --shard '$bad' refused with rc 2 and a HARNESS ERROR line (rc=$rc)"
43
+ done
44
+
45
+ # ── S2 / S3 / S4 / S7 union and disjointness ────────────────────────────────────────────────
46
+ full="$T/full.txt"; plan "$SC" "$ROOT" 1 1 "$full"
47
+ names "$full" > "$T/full.names"
48
+ nfull=$(wc -l < "$T/full.names" | tr -d ' ')
49
+ [ "$nfull" -ge 100 ]; chk $? "S4 control: the unsharded plan names $nfull suites (>= 100 — a plan of 0 would make S2/S3 vacuous)"
50
+ grep -qx 'test_mutation_probe_lanes.sh' "$T/full.names"; chk $? "S4 control: a suite known to be wired (test_mutation_probe_lanes.sh) is in the plan"
51
+ grep -qx 'test_selfcheck_shard_lanes.sh' "$T/full.names"; chk $? "S4 control: this suite is itself in the plan (an unwired anchor is prose)"
52
+
53
+ # check_split <selfcheck> <root> <N> <tag> → rc 0 iff union == full AND disjoint AND (all non-empty)
54
+ check_split() {
55
+ local sc="$1" root="$2" n="$3" tag="$4" i u_ok=0 dup_ok=0 empty_ok=0
56
+ : > "$T/$tag.all"
57
+ for i in $(seq 1 "$n"); do
58
+ plan "$sc" "$root" "$i" "$n" "$T/$tag.$i.trace"
59
+ names "$T/$tag.$i.trace" > "$T/$tag.$i.names"
60
+ [ -s "$T/$tag.$i.names" ] || empty_ok=1
61
+ cat "$T/$tag.$i.names" >> "$T/$tag.all"
62
+ done
63
+ LC_ALL=C sort "$T/$tag.all" | LC_ALL=C uniq -d > "$T/$tag.dups"
64
+ [ -s "$T/$tag.dups" ] && dup_ok=1
65
+ LC_ALL=C sort -u "$T/$tag.all" > "$T/$tag.union"
66
+ cmp -s "$T/$tag.union" "$T/full.names" || u_ok=1
67
+ SPLIT_UNION_BAD=$u_ok; SPLIT_DUP=$dup_ok; SPLIT_EMPTY=$empty_ok
68
+ [ $u_ok -eq 0 ] && [ $dup_ok -eq 0 ] && [ $empty_ok -eq 0 ]
69
+ }
70
+ for n in 2 3 4; do
71
+ check_split "$SC" "$ROOT" "$n" "n$n"
72
+ [ "$SPLIT_UNION_BAD" -eq 0 ]; chk $? "S2 N=$n: union of shards 1..$n == the unsharded plan ($(wc -l < "$T/n$n.union" | tr -d ' ') suites)"
73
+ [ "$SPLIT_DUP" -eq 0 ]; chk $? "S3 N=$n: no suite runs in two shards ($(wc -l < "$T/n$n.dups" | tr -d ' ') duplicated)"
74
+ [ "$SPLIT_EMPTY" -eq 0 ]; chk $? "S7 N=$n: every shard owns at least one suite"
75
+ done
76
+
77
+ # ── S5 known-negative: break the assignment, the same detector must go red ───────────────────
78
+ # The mutant lives in a scratch tree of symlinks (selfcheck cd's to its own parent, so a copy has to sit
79
+ # under a root that looks like the repo). Nothing is written into the real tree.
80
+ MR="$T/mutroot"; mkdir -p "$MR/scripts"
81
+ for e in "$ROOT"/* "$ROOT"/.[!.]*; do
82
+ [ -e "$e" ] || continue
83
+ b=$(basename "$e"); [ "$b" = scripts ] && continue
84
+ ln -s "$e" "$MR/$b"
85
+ done
86
+ for e in "$ROOT"/scripts/*; do
87
+ b=$(basename "$e"); [ "$b" = selfcheck.sh ] && continue
88
+ ln -s "$e" "$MR/scripts/$b"
89
+ done
90
+ # the one-line break: every shard owns every suite
91
+ sed 's|^ _shard_mine() { .*$| _shard_mine() { return 0; }|' "$SC" > "$MR/scripts/selfcheck.sh"
92
+ cmp -s "$SC" "$MR/scripts/selfcheck.sh" && echo " (!) mutant identical to subject — the _shard_mine line moved; S5 below is void"
93
+ cmp -s "$SC" "$MR/scripts/selfcheck.sh"; chk $((1 - $?)) "S5 control: the mutation was APPLIED (mutant differs from subject)"
94
+ check_split "$MR/scripts/selfcheck.sh" "$MR" 3 mut
95
+ [ "$SPLIT_DUP" -eq 1 ]; chk $? "S5 known-negative: with every shard owning every suite the duplicate detector goes RED"
96
+
97
+ # ── S6 --shard absent = today ────────────────────────────────────────────────────────────────
98
+ START=$(grep -n '^# ── --shard i/N' "$SC" | head -1 | cut -d: -f1)
99
+ END=$(grep -n '^ _shard_inline_skip() { return 1; }' "$SC" | head -1 | cut -d: -f1)
100
+ if [ -z "$START" ] || [ -z "$END" ]; then
101
+ chk 1 "S6 the shard block markers are still in selfcheck.sh (lane would test nothing)"
102
+ else
103
+ sed -n "${START},$((END + 1))p" "$SC" > "$T/block.sh"
104
+ res=$(cd "$ROOT" && env -u FH_SELFCHECK_SHARD bash -c '
105
+ set -u
106
+ f="$1"; set -- # no arguments, as `npm test` calls it
107
+ . "$f"
108
+ if declare -F bash >/dev/null 2>&1; then echo "BASH-SHADOWED"; fi
109
+ _shard_inline; echo "inline=$?"
110
+ _shard_mine anything; echo "mine=$?"
111
+ _shard_skip anything; echo "skip=$?"
112
+ _shard_inline_skip x; echo "inlineskip=$?"
113
+ ' _ "$T/block.sh" 2>&1)
114
+ # control for the line below: the SAME block with --shard given must define the shim (else "absent" is vacuous)
115
+ resS=$(cd "$ROOT" && env -u FH_SELFCHECK_SHARD bash -c 'f="$1"; shift; set -- --shard 2/4 --shard-dry; . "$f"; declare -F bash >/dev/null 2>&1 && echo BASH-SHADOWED' _ "$T/block.sh" 2>&1)
116
+ printf '%s' "$resS" | grep -q 'BASH-SHADOWED'; chk $? "S6 control: with --shard 2/4 the same block DOES define the bash shim"
117
+ printf '%s' "$res" | grep -q 'BASH-SHADOWED'; chk $((1 - $?)) "S6 without --shard no function named bash exists"
118
+ printf '%s' "$res" | grep -qx 'inline=0'; chk $? "S6 without --shard inline checks run"
119
+ printf '%s' "$res" | grep -qx 'mine=0'; chk $? "S6 without --shard every suite is mine"
120
+ printf '%s' "$res" | grep -qx 'skip=1'; chk $? "S6 without --shard nothing is skipped"
121
+ printf '%s' "$res" | grep -qx 'inlineskip=1'; chk $? "S6 without --shard no inline check is skipped"
122
+ fi
123
+
124
+ # ── notes (printed, never a verdict) ────────────────────────────────────────────────────────
125
+ if [ -f "$ROOT/scripts/selfcheck_shard_weights.txt" ]; then
126
+ awk 'NF >= 2 && $1 ~ /^[0-9.]+$/ && $2 != "@inline" { print $2 }' "$ROOT/scripts/selfcheck_shard_weights.txt" | LC_ALL=C sort -u > "$T/w.names"
127
+ stale=$(comm -13 "$T/full.names" "$T/w.names" | wc -l | tr -d ' ')
128
+ unlisted=$(comm -23 "$T/full.names" "$T/w.names" | wc -l | tr -d ' ')
129
+ echo " NOTE weights file: $(wc -l < "$T/w.names" | tr -d ' ') rows · $stale name(s) no longer in the plan · $unlisted suite(s) unlisted (placed by hash)"
130
+ else
131
+ echo " NOTE no scripts/selfcheck_shard_weights.txt — every suite is placed by hash"
132
+ fi
133
+
134
+ echo "════ lanes: $pass passed · $failn failed ════"
135
+ [ "$failn" -eq 0 ]
@@ -3120,7 +3120,7 @@ if [ -n "$LOADBEARING" ]; then
3120
3120
  # advisory result, :542) and for "files could not be measured" (_FORCE_NONCLEAN=2, :548) —
3121
3121
  # codex cross-family catch on the first draft of this fix, which printed "DID NOT complete"
3122
3122
  # for a completed scan that merely found smells. Discriminate by the output markers.
3123
- _dd_raw=$(bash "$DDSCAN" "${_dd_targets[@]}" 2>/dev/null); _dd_rc=$?
3123
+ _dd_raw=$(bash "$DDSCAN" --staged "${_dd_targets[@]}" 2>/dev/null); _dd_rc=$?
3124
3124
  _dd=$(printf '%s\n' "$_dd_raw" | grep -Ff <(printf '%s\n' "$LOADBEARING") 2>/dev/null | head -5 || true)
3125
3125
  _dd_unm=$(printf '%s\n' "$_dd_raw" | grep -c "COULD NOT BE MEASURED" || true); _dd_unm=${_dd_unm:-0}
3126
3126
  if [ "$_dd_unm" -gt 0 ]; then
@@ -26,11 +26,97 @@
26
26
  #
27
27
  # Usage:
28
28
  # bash scripts/degrade_direction_scan.sh [path ...] # scan dirs/files (default: .)
29
+ # bash scripts/degrade_direction_scan.sh --staged [path ...] # scan the INDEX content (commit-time callers)
29
30
  # git diff --name-only main..HEAD -- '*.py' | xargs bash scripts/degrade_direction_scan.sh
30
31
  # Exit: 0 = no smells found; 2 = smells found (ADVISORY signal — do not hard-block on it)
31
32
  set -uo pipefail
32
33
 
34
+ # --staged (2026-10-31, harness-doctor S-4): scan the INDEX content, not the working tree. A commit-time
35
+ # caller (templates/.git-hooks/pre-commit) must judge what will be committed; `git add` then an edit
36
+ # leaves the two different, and a working-tree read lets a staged smell pass (or flags a fixed one).
37
+ # Targets, if given, narrow the staged set (exact path or directory prefix). Default behaviour is unchanged.
38
+ STAGED=0
39
+ if [ "${1:-}" = "--staged" ]; then STAGED=1; shift; fi
33
40
  TARGETS=("$@")
41
+ if [ "$STAGED" -eq 1 ]; then
42
+ _sroot=$(git rev-parse --show-toplevel 2>/dev/null); _src=$?
43
+ if [ "$_src" -ne 0 ] || [ -z "$_sroot" ]; then
44
+ echo "degrade-scan: --staged needs a git work tree — NOT measured, not clean"; exit 2
45
+ fi
46
+ _stmp=$(mktemp -d) || { echo "degrade-scan: mktemp failed — NOT measured, not clean"; exit 2; }
47
+ trap 'rm -rf "$_stmp"' EXIT
48
+ # -z: without it git quotes non-ASCII / tab / quote names ("\355\225\234.sh"), which then match no
49
+ # target and fail `git show` (codex R1 #1). NUL list goes to a file so the git exit code survives.
50
+ git -C "$_sroot" diff --cached --name-only -z --diff-filter=ACMR > "$_stmp/.staged_list" 2>/dev/null; _src=$?
51
+ if [ "$_src" -ne 0 ]; then
52
+ echo "degrade-scan: could not list staged files (git exit $_src) — NOT measured, not clean"; exit 2
53
+ fi
54
+ # Targets are normalised to repo-relative paths the way a filesystem target would resolve
55
+ # (codex R1 #3): absolute paths under the repo root, `./` and `.`, and paths relative to a subdir cwd.
56
+ _spfx=$(git rev-parse --show-prefix 2>/dev/null)
57
+ _ntg=()
58
+ for _tg in ${TARGETS[@]+"${TARGETS[@]}"}; do
59
+ # An existing path is resolved physically first (macOS /tmp -> /private/tmp, `..`, `sub/./a`,
60
+ # `a//b` — codex R2 #2 #3); a path that does not exist on disk is normalised as a string only.
61
+ if [ -e "$_tg" ]; then
62
+ if [ -d "$_tg" ]; then _tg=$(cd "$_tg" 2>/dev/null && pwd -P)
63
+ else _tg="$(cd "$(dirname "$_tg")" 2>/dev/null && pwd -P)/$(basename "$_tg")"; fi
64
+ fi
65
+ case "$_tg" in
66
+ "$_sroot") _tg="." ;;
67
+ "$_sroot"/*) _tg="${_tg#"$_sroot"/}" ;;
68
+ /*) _tg="//outside//" ;; # absolute path outside the repo: matches nothing
69
+ *) _tg="${_spfx}${_tg}" ;;
70
+ esac
71
+ while [ "${_tg#./}" != "$_tg" ]; do _tg="${_tg#./}"; done
72
+ _tg="${_tg%/}"; _tg="${_tg%/.}"
73
+ [ -z "$_tg" ] && _tg="."
74
+ _ntg+=("$_tg")
75
+ done
76
+ _tmatch=()
77
+ for _tg in ${_ntg[@]+"${_ntg[@]}"}; do _tmatch+=(0); done
78
+ _copied=()
79
+ _sn=0
80
+ mkdir -p "$_stmp/t"
81
+ while IFS= read -r -d '' _sp; do
82
+ [ -z "$_sp" ] && continue
83
+ if [ ${#_ntg[@]} -gt 0 ]; then
84
+ _hit=0; _ti=0
85
+ for _tg in "${_ntg[@]}"; do
86
+ case "$_sp" in "$_tg"|"$_tg"/*) _hit=1; _tmatch[$_ti]=1 ;; esac
87
+ [ "$_tg" = "." ] && { _hit=1; _tmatch[$_ti]=1; }
88
+ _ti=$((_ti+1))
89
+ done
90
+ [ "$_hit" -eq 1 ] || continue
91
+ fi
92
+ mkdir -p "$_stmp/t/$(dirname "$_sp")"
93
+ if ! git -C "$_sroot" show ":$_sp" > "$_stmp/t/$_sp" 2>/dev/null; then
94
+ echo "degrade-scan: could not read staged content of $_sp — NOT measured, not clean"; exit 2
95
+ fi
96
+ _sn=$((_sn+1)); _copied+=("$_sp")
97
+ done < "$_stmp/.staged_list"
98
+ # Every NAMED target must select at least one staged file — one unmatched target among matched ones
99
+ # is still an omission, and the aggregate count cannot see it (codex R2 #3).
100
+ _ti=0
101
+ for _tg in ${_ntg[@]+"${_ntg[@]}"}; do
102
+ if [ "${_tmatch[$_ti]}" -eq 0 ]; then
103
+ echo "degrade-scan: target '$_tg' matched no staged file — COULD NOT BE MEASURED, not clean"; exit 2
104
+ fi
105
+ _ti=$((_ti+1))
106
+ done
107
+ if [ "$_sn" -eq 0 ]; then
108
+ if [ ${#_ntg[@]} -gt 0 ]; then
109
+ # Named targets that select no staged file are a caller/path mismatch, not a clean result —
110
+ # the hook must not print its clean checkmark here (codex R1 #2).
111
+ echo "degrade-scan: ${#_ntg[@]} target(s) matched no staged file — COULD NOT BE MEASURED, not clean"; exit 2
112
+ fi
113
+ echo "degrade-scan: no staged files — nothing measured (exit 0 = no input, not a verdict)"; exit 0
114
+ fi
115
+ cd "$_stmp/t" || exit 2 # relative paths in output = real repo paths
116
+ # Pass the copied FILES, not ".": directory discovery silently drops unsupported file types, while an
117
+ # explicit file target reports them as OUTSIDE the scannable set (codex R2 #1).
118
+ TARGETS=("${_copied[@]}")
119
+ fi
34
120
  [ ${#TARGETS[@]} -eq 0 ] && TARGETS=(".")
35
121
 
36
122
  # Permissive values a verdict/gate surface must never land on by *default* / fall-through.
@@ -96,7 +182,7 @@ command -v awk >/dev/null 2>&1 || { _S1B_OK=0; _FORCE_NONCLEAN=2; }
96
182
  # 하지 않아 정상 폴백은 100% 실패하고, 반대로 공격자가 그 이름에 심링크를 심어두면 **성공해서
97
183
  # 레포 밖에 쓴다**(실증됨). 즉 "공격받을 때만 동작하는 코드" 였다.
98
184
  _MD_TMP="$(mktemp -d 2>/dev/null)" || { _MD_TMP=""; _MD_OK=0; }
99
- trap '[ -n "$_MD_TMP" ] && rm -rf "$_MD_TMP"' EXIT
185
+ trap '[ -n "$_MD_TMP" ] && rm -rf "$_MD_TMP"; [ -n "${_stmp:-}" ] && rm -rf "$_stmp"' EXIT # also the --staged copy (this trap replaces the one set above)
100
186
  # LANGUAGE-SPLIT shadows (2026-08-12). The first version extracted only ```bash-family fences, and
101
187
  # extending it to ```python by widening the same regex would have written python source into a `.sh`
102
188
  # shadow — where `is_sh` is decided by the extension, so the SHELL probes would run on python and the