@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.
- package/.claude-plugin/marketplace.json +5 -5
- package/CHEATSHEET.md +1 -0
- package/README.md +2 -2
- package/docs/USER_GUIDE.md +7 -3
- package/knowledge/shared/harness-core/field_verdict_crossfamily_gate.md +2 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +48 -0
- package/package.json +2 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +2 -2
- package/plugins/fh-commons/agents/a11y-lens.md +11 -0
- package/plugins/fh-commons/agents/be-dev-lens.md +11 -0
- package/plugins/fh-commons/agents/designer-lens.md +11 -0
- package/plugins/fh-commons/agents/fe-dev-lens.md +11 -0
- package/plugins/fh-commons/agents/qa-lens.md +11 -0
- package/plugins/fh-commons/agents/ux-writer-lens.md +11 -0
- package/plugins/fh-commons/skills/deliberation/SKILL.md +3 -11
- package/plugins/fh-commons/skills/deliberation/SKILL_detail.md +19 -0
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +8 -80
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +107 -0
- package/plugins/fh-commons/skills/standpoint-review/SKILL.md +235 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +30 -0
- package/plugins/fh-meta/agents/fact-checker.md +11 -0
- package/plugins/fh-meta/agents/hub-persona-auditor.md +13 -0
- package/plugins/fh-meta/agents/persona-innovator.md +12 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +6 -103
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL_detail.md +132 -0
- package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL.md +3 -20
- package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL_detail.md +36 -0
- package/plugins/fh-meta/skills/install-doctor/SKILL.md +4 -25
- package/plugins/fh-meta/skills/install-doctor/SKILL_detail.md +44 -0
- package/plugins/fh-meta/skills/verify-bidirectional/SKILL.md +7 -51
- package/plugins/fh-meta/skills/verify-bidirectional/SKILL_detail.md +75 -0
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-preprep/skills/preprep/SKILL.md +7 -207
- package/plugins/fh-preprep/skills/preprep/SKILL_detail.md +235 -0
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/degrade_direction_scan.sh +87 -1
- package/scripts/pr_merge_verified.sh +20 -3
- package/scripts/selfcheck.sh +155 -7
- package/scripts/test_degrade_scan_shell_probes.sh +63 -0
- package/scripts/test_pr_merge_verified_lanes.sh +33 -0
- package/scripts/test_selfcheck_shard_lanes.sh +135 -0
- package/templates/.git-hooks/pre-commit +1 -1
- package/templates/degrade_direction_scan.sh +87 -1
|
@@ -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
|
|
@@ -73,6 +73,23 @@ print(json.dumps({"at":time.strftime("%Y-%m-%dT%H:%M:%S%z"),"pr":int(e["PMV_R_PR
|
|
|
73
73
|
fi
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
# completion record: one line in tracks/_meta/fh_completed_<date>.md so a merge is never forgotten at session close. Called only
|
|
77
|
+
# after the merge landed (verified · verify-failed · verify-incomplete). Local record (tracks/ is gitignored), best-effort: never changes rc. A repo with
|
|
78
|
+
# no tracks/ dir (a consumer that does not use tracks) is skipped silently. Opt-out: FH_MERGE_NO_COMPLETED_LOG=1.
|
|
79
|
+
_clog() { # outcome-label merge_oid
|
|
80
|
+
[ "${FH_MERGE_NO_COMPLETED_LOG:-}" = 1 ] && return 0
|
|
81
|
+
local root; root=$(git rev-parse --show-toplevel 2>/dev/null) || return 0
|
|
82
|
+
[ -d "$root/tracks" ] || return 0
|
|
83
|
+
local title; title=$(gh pr view "$PR" --json title -q .title < /dev/null 2>/dev/null) || title=""
|
|
84
|
+
title=$(printf '%s' "$title" | tr '\n' ' '); [ -n "$title" ] || title="(title unreadable)"
|
|
85
|
+
local d="$root/tracks/_meta" f; f="$d/fh_completed_$(date +%F).md"
|
|
86
|
+
if ! { mkdir -p "$d" && { [ -s "$f" ] || printf '# Completed %s\n\n' "$(date +%F)" > "$f"; } \
|
|
87
|
+
&& printf -- '- %s PR #%s %s → merged %s (%s) — auto\n' "$(date +%H:%M)" "$PR" "$title" "$(printf '%s' "$2" | cut -c1-7)" "$1" >> "$f"; } 2>/dev/null; then
|
|
88
|
+
echo "WARNING: completion record NOT written ($f) - add by hand: PR #$PR merged ($1)" >&2
|
|
89
|
+
fi
|
|
90
|
+
return 0
|
|
91
|
+
}
|
|
92
|
+
|
|
76
93
|
# 1. head before merge
|
|
77
94
|
HEAD_OID=$(gh pr view "$PR" --json headRefOid -q .headRefOid < /dev/null) || HEAD_OID=""
|
|
78
95
|
[ -n "$HEAD_OID" ] || { echo "🟥 HARNESS-ERROR (before merge): could not read PR #$PR head" >&2; exit 4; }
|
|
@@ -154,7 +171,7 @@ echo "── merged as $MC"
|
|
|
154
171
|
# 4. verify
|
|
155
172
|
bash "$PSV" --repo . --tip "$HEAD_OID" --merge "$MC" --rerun "$RERUN"; rc=$?
|
|
156
173
|
case "$rc" in
|
|
157
|
-
0) _receipt "verified" "$MC"; echo "✅ PR #$PR merged and verified"; exit 0 ;;
|
|
158
|
-
1) _receipt "verify-failed" "$MC"; echo "🟥 PR #$PR IS MERGED but verification FAILED — the merge stands; fix forward or revert" >&2; exit 1 ;;
|
|
159
|
-
*) _receipt "verify-incomplete" "$MC"; echo "🟥 HARNESS-ERROR (AFTER merge): post_squash_verify rc=$rc — PR #$PR is merged, verification did not complete" >&2; exit 4 ;;
|
|
174
|
+
0) _receipt "verified" "$MC"; _clog "verified" "$MC"; echo "✅ PR #$PR merged and verified"; exit 0 ;;
|
|
175
|
+
1) _receipt "verify-failed" "$MC"; _clog "verify-failed rc=1" "$MC"; echo "🟥 PR #$PR IS MERGED but verification FAILED — the merge stands; fix forward or revert" >&2; exit 1 ;;
|
|
176
|
+
*) _receipt "verify-incomplete" "$MC"; _clog "verify-incomplete rc=$rc" "$MC"; echo "🟥 HARNESS-ERROR (AFTER merge): post_squash_verify rc=$rc — PR #$PR is merged, verification did not complete" >&2; exit 4 ;;
|
|
160
177
|
esac
|
package/scripts/selfcheck.sh
CHANGED
|
@@ -15,6 +15,124 @@ set -u
|
|
|
15
15
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
16
16
|
fail=0
|
|
17
17
|
|
|
18
|
+
# ── --shard i/N (2026-10-31) — run one slice of the suite list so CI can fan out ─────────────────────
|
|
19
|
+
# Without --shard NOTHING below is active: no function named `bash` exists, every helper is a no-op
|
|
20
|
+
# that answers "run it", and the file behaves as it did before this section was added.
|
|
21
|
+
# With --shard i/N, a lane suite runs only in the shard the plan assigns it to; everything that is not
|
|
22
|
+
# a lane suite (syntax checks, count_check, ref-path scans, the `--self-test` entry points) runs in
|
|
23
|
+
# shard 1 only. Sharding is by suite BASENAME, so a suite named by several rows still lands in one shard.
|
|
24
|
+
# PLAN = greedy longest-first packing over scripts/selfcheck_shard_weights.txt ("<seconds> <suite>",
|
|
25
|
+
# measured). Computed, not stored, so any N works and the weights file is the only data. A suite that
|
|
26
|
+
# is not in the file is placed by cksum(name) mod N — deterministic, order-independent, so a new
|
|
27
|
+
# suite is never lost, only possibly unbalanced until someone adds its row.
|
|
28
|
+
# Why a shim named `bash` and not a call-site rewrite: test_selfcheck_state_lanes.sh greps this file
|
|
29
|
+
# for the literal `bash scripts/<suite>.sh` (it asserts "executed exactly once"), so the call text is
|
|
30
|
+
# an interface. The shim keeps that text and decides at call time. Calls that bypass a shell function
|
|
31
|
+
# (`timeout N bash …`) do not pass through it; each of those sites carries its own `_shard_skip` /
|
|
32
|
+
# `_shard_inline` arm — grep for them.
|
|
33
|
+
# --shard-dry / FH_SHARD_DRY=1: do not execute suites or inline checks, only record the decision to
|
|
34
|
+
# $FH_SHARD_TRACE as "RUN <name>" / "SKIP <name>" — what test_selfcheck_shard_lanes.sh asserts on.
|
|
35
|
+
_SHARD_I=""; _SHARD_N=""; _SHARD_DRY="${FH_SHARD_DRY:-0}"; _SHARD_GIVEN=0; _SHARD_SPEC=""
|
|
36
|
+
# FH_SELFCHECK_SHARD=i/N is the same switch as --shard (the flag wins). CI uses the env form because
|
|
37
|
+
# test_remote_marker_gate_lanes.sh W1 matches the workflow line `bash scripts/selfcheck.sh` exactly.
|
|
38
|
+
if [ -n "${FH_SELFCHECK_SHARD:-}" ]; then _SHARD_GIVEN=1; _SHARD_SPEC="$FH_SELFCHECK_SHARD"; fi
|
|
39
|
+
while [ $# -gt 0 ]; do
|
|
40
|
+
case "$1" in
|
|
41
|
+
--shard) _SHARD_GIVEN=1; shift; _SHARD_SPEC="${1:-}" ;;
|
|
42
|
+
--shard=*) _SHARD_GIVEN=1; _SHARD_SPEC="${1#--shard=}" ;;
|
|
43
|
+
--shard-dry) _SHARD_DRY=1 ;;
|
|
44
|
+
*) ;; # unknown arguments were ignored before this section existed; they still are
|
|
45
|
+
esac
|
|
46
|
+
shift
|
|
47
|
+
done
|
|
48
|
+
if [ "$_SHARD_GIVEN" = 1 ]; then
|
|
49
|
+
_SHARD_I="${_SHARD_SPEC%%/*}"; _SHARD_N="${_SHARD_SPEC##*/}"
|
|
50
|
+
# each side must be a positive integer without a leading zero: «01» compares unequal to «1» and «/4» concatenates to digits
|
|
51
|
+
# — both ran no suite and printed PASS (codex R1 2026-10-31)
|
|
52
|
+
case "$_SHARD_I" in [1-9]|[1-9]*[0-9]) case "$_SHARD_I" in *[!0-9]*) _SHARD_I=bad ;; esac ;; *) _SHARD_I=bad ;; esac
|
|
53
|
+
case "$_SHARD_N" in [1-9]|[1-9]*[0-9]) case "$_SHARD_N" in *[!0-9]*) _SHARD_I=bad ;; esac ;; *) _SHARD_I=bad ;; esac
|
|
54
|
+
if [ "$_SHARD_I" = bad ] || [ "$_SHARD_SPEC" = "${_SHARD_SPEC#*/}" ] \
|
|
55
|
+
|| [ "$_SHARD_I" -lt 1 ] || [ "$_SHARD_I" -gt "$_SHARD_N" ]; then
|
|
56
|
+
echo "HARNESS ERROR --shard '$_SHARD_SPEC': expected i/N with 1 <= i <= N — nothing was run (not a pass)"
|
|
57
|
+
exit 2
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
[ -n "$_SHARD_N" ] && [ "$_SHARD_DRY" != 1 ] && echo "SHARD this run covers shard $_SHARD_I of $_SHARD_N only — it is a slice of the suite list, not the whole of it"
|
|
61
|
+
_SHARD_PLAN_TXT=""
|
|
62
|
+
_shard_trace() { [ -n "${FH_SHARD_TRACE:-}" ] && printf '%s\n' "$1" >> "$FH_SHARD_TRACE"; return 0; }
|
|
63
|
+
_shard_of() { # $1 = suite basename → its shard number (1..N)
|
|
64
|
+
local _hit
|
|
65
|
+
_hit=$(printf '%s\n' "$_SHARD_PLAN_TXT" | awk -v n="$1" '$1 == n { print $2; exit }')
|
|
66
|
+
if [ -n "$_hit" ]; then printf '%s\n' "$_hit"
|
|
67
|
+
else printf '%s\n' $(( $(printf '%s' "$1" | cksum | cut -d' ' -f1) % _SHARD_N + 1 )); fi
|
|
68
|
+
}
|
|
69
|
+
if [ -n "$_SHARD_N" ]; then
|
|
70
|
+
if [ -f scripts/selfcheck_shard_weights.txt ]; then
|
|
71
|
+
# LPT: heaviest first (ties by name, C locale), each into the currently lightest bin (ties: lowest index).
|
|
72
|
+
# `@inline` is not a suite: its seconds pre-load shard 1, which owns every non-suite check.
|
|
73
|
+
_SHARD_PRE=$(awk '$2 == "@inline" && $1 ~ /^[0-9.]+$/ { s += $1 } END { print s + 0 }' scripts/selfcheck_shard_weights.txt)
|
|
74
|
+
_SHARD_PLAN_TXT=$(LC_ALL=C sort -k1,1nr -k2,2 scripts/selfcheck_shard_weights.txt \
|
|
75
|
+
| awk -v n="$_SHARD_N" -v pre="$_SHARD_PRE" 'BEGIN { load[1] = pre + 0 } $2 != "@inline" && NF >= 2 && $1 ~ /^[0-9.]+$/ { b = 1; for (i = 2; i <= n; i++) if (load[i] + 0 < load[b] + 0) b = i; load[b] += $1; print $2, b }')
|
|
76
|
+
fi
|
|
77
|
+
# A shard that owns no suite would run nothing and still print PASS (codex R1: `--shard 999/1000`). Shard 1 always owns the
|
|
78
|
+
# inline checks; any other shard must own at least one weighted suite, or it is not a measurement.
|
|
79
|
+
if [ "$_SHARD_I" != 1 ] && [ -z "$(printf '%s\n' "$_SHARD_PLAN_TXT" | awk -v i="$_SHARD_I" '$2 == i { print; exit }')" ]; then
|
|
80
|
+
echo "HARNESS ERROR --shard $_SHARD_I/$_SHARD_N owns no suite in the weights plan — nothing would run (not a pass)"
|
|
81
|
+
exit 2
|
|
82
|
+
fi
|
|
83
|
+
# shard 1 owns every non-suite check. In dry mode nobody executes them.
|
|
84
|
+
_shard_inline() {
|
|
85
|
+
[ "$_SHARD_DRY" = 1 ] && return 1
|
|
86
|
+
[ "$_SHARD_I" = 1 ]
|
|
87
|
+
}
|
|
88
|
+
_shard_mine() { [ "$(_shard_of "$1")" = "$_SHARD_I" ]; }
|
|
89
|
+
# rc 0 = this inline check is shard 1's, not ours (named, so the omission is visible); rc 1 = run it.
|
|
90
|
+
_shard_inline_skip() { # $1 = label
|
|
91
|
+
if _shard_inline; then _shard_trace "INLINE $1"; return 1; fi
|
|
92
|
+
_shard_trace "SKIPINLINE $1"
|
|
93
|
+
echo "SHARD-SKIP $1 (inline check — runs in shard 1 only; this is $_SHARD_I/$_SHARD_N)"
|
|
94
|
+
return 0
|
|
95
|
+
}
|
|
96
|
+
# rc 0 = SKIP this suite here (it belongs to another shard, or this is a dry run); rc 1 = run it.
|
|
97
|
+
_shard_skip() {
|
|
98
|
+
if _shard_mine "$1"; then
|
|
99
|
+
_shard_trace "RUN $1"
|
|
100
|
+
[ "$_SHARD_DRY" = 1 ] && return 0
|
|
101
|
+
return 1
|
|
102
|
+
fi
|
|
103
|
+
_shard_trace "SKIP $1"
|
|
104
|
+
echo "SHARD-SKIP $1 (shard $(_shard_of "$1")/$_SHARD_N, this is $_SHARD_I/$_SHARD_N)"
|
|
105
|
+
return 0
|
|
106
|
+
}
|
|
107
|
+
bash() {
|
|
108
|
+
local _a1="${1:-}" _nm _x _st=0
|
|
109
|
+
case "$_a1" in scripts/*.sh) ;; *) command bash "$@"; return $? ;; esac
|
|
110
|
+
_nm="${_a1##*/}"
|
|
111
|
+
for _x in "$@"; do case "$_x" in --self-test|--selftest) _st=1 ;; esac; done
|
|
112
|
+
if [ "$_st" = 1 ]; then # an embedded self-test is an inline check: shard 1 only
|
|
113
|
+
if _shard_inline; then _shard_trace "INLINE $_nm"; command bash "$@"; return $?; fi
|
|
114
|
+
_shard_trace "SKIPINLINE $_nm"; return 0
|
|
115
|
+
fi
|
|
116
|
+
case "$_nm" in
|
|
117
|
+
test_*.sh|*_lanes.sh)
|
|
118
|
+
if _shard_skip "$_nm"; then return 0; fi
|
|
119
|
+
command bash "$@"; return $? ;;
|
|
120
|
+
# Non-suite checkers selfcheck runs once. `--list-accepted` is a data load every later block
|
|
121
|
+
# depends on (top of file), so it is never skipped.
|
|
122
|
+
count_check.sh|prepush_guard_check.sh|gate_anchor_check.sh|multibyte_bracket_lint.sh|package_coverage_check.sh|files_manifest_shipping_check.sh|lane_runner_check.sh|gate_pathspec_check.sh|sync_guard_check.sh)
|
|
123
|
+
case " $* " in *" --list-accepted "*) command bash "$@"; return $? ;; esac
|
|
124
|
+
if _shard_inline_skip "$_nm"; then return 0; fi
|
|
125
|
+
command bash "$@"; return $? ;;
|
|
126
|
+
esac
|
|
127
|
+
command bash "$@"
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
_shard_inline() { return 0; }
|
|
131
|
+
_shard_mine() { return 0; }
|
|
132
|
+
_shard_skip() { return 1; }
|
|
133
|
+
_shard_inline_skip() { return 1; }
|
|
134
|
+
fi
|
|
135
|
+
|
|
18
136
|
# Single source of "declared legitimately unshipped" — package_coverage_check.sh's ACCEPTED_ABSENT,
|
|
19
137
|
# read once via its --list-accepted flag. Two blocks below (ref-path, SessionStart anchor pairs) used
|
|
20
138
|
# to each re-derive "is this absence OK" from an environment predicate (`.git` presence) instead of
|
|
@@ -72,7 +190,7 @@ if [ "${FH_SELFCHECK_PROFILE:-full}" = consumer ]; then
|
|
|
72
190
|
if _package_mode; then _CONSUMER=1
|
|
73
191
|
else echo "⚠️ FH_SELFCHECK_PROFILE=consumer IGNORED — this tree is a git checkout; running the full suite"; fi
|
|
74
192
|
fi
|
|
75
|
-
CHECKOUT_ONLY_SUITES="test_package_coverage_lanes.sh test_files_manifest_shipping_lanes.sh test_map_postprocess_lanes.sh test_remote_marker_gate_lanes.sh test_worktree_reclaim_lanes.sh test_sim_isolated_run_lanes.sh test_utterance_intake_lanes.sh test_precommit_pointer_index_lanes.sh"
|
|
193
|
+
CHECKOUT_ONLY_SUITES="test_package_coverage_lanes.sh test_files_manifest_shipping_lanes.sh test_map_postprocess_lanes.sh test_remote_marker_gate_lanes.sh test_worktree_reclaim_lanes.sh test_sim_isolated_run_lanes.sh test_utterance_intake_lanes.sh test_precommit_pointer_index_lanes.sh test_selfcheck_shard_lanes.sh"
|
|
76
194
|
CONSUMER_SKIPPED=""
|
|
77
195
|
_consumer_skip() { # $1 = suite basename · rc 0 = skip it (and it has been named)
|
|
78
196
|
[ "$_CONSUMER" -eq 1 ] || return 1
|
|
@@ -118,6 +236,7 @@ _absent_subject_verdict() {
|
|
|
118
236
|
|
|
119
237
|
check() { # check <label> <cmd...>
|
|
120
238
|
local label="$1"; shift
|
|
239
|
+
_shard_inline || return 0 # syntax checks are inline checks: shard 1 only (always true without --shard)
|
|
121
240
|
if "$@" 2>/dev/null; then
|
|
122
241
|
echo "PASS $label"
|
|
123
242
|
else
|
|
@@ -208,7 +327,8 @@ done
|
|
|
208
327
|
# its drift diagnostics to stdout (measured 2026-08-05: 686 B stdout / 0 B stderr), so a failure
|
|
209
328
|
# printed a bare `FAIL` line carrying no diagnosis at all — worse than the truncation this session
|
|
210
329
|
# repaired in the lane blocks. Fixed at the call site; check() itself is a separate job (see above).
|
|
211
|
-
if
|
|
330
|
+
if _shard_inline_skip "fh-codex-doctor --strict"; then :
|
|
331
|
+
elif _out=$(node bin/fh-codex-doctor.js --strict 2>&1); then
|
|
212
332
|
echo "PASS fh-codex-doctor --strict"
|
|
213
333
|
else
|
|
214
334
|
echo "FAIL fh-codex-doctor --strict"
|
|
@@ -1187,6 +1307,8 @@ do
|
|
|
1187
1307
|
_subj="${_pair%%|*}"; _anc="${_pair##*|}"; _lbl="${_anc##*/}"
|
|
1188
1308
|
if [ ! -f "$_subj" ]; then
|
|
1189
1309
|
_absent_subject_verdict "$_lbl" "$_subj" || fail=1
|
|
1310
|
+
elif [ -f "$_anc" ] && _shard_skip "$_lbl"; then
|
|
1311
|
+
: # another shard's suite (or a dry run) — _shard_skip said so
|
|
1190
1312
|
elif [ -f "$_anc" ] && _consumer_skip "$_lbl"; then
|
|
1191
1313
|
:
|
|
1192
1314
|
elif [ -f "$_anc" ]; then
|
|
@@ -1282,6 +1404,7 @@ for _subj in compaction_probe judgment_circuit_lint novelty_claim_check chamber_
|
|
|
1282
1404
|
# printing in every run before that, unread, because stderr scrolls past a 240-second check.
|
|
1283
1405
|
# ★ A guard that announces its own failure every single run is still a silent failure if
|
|
1284
1406
|
# nothing reads the announcement. Fixed by deleting one word.
|
|
1407
|
+
_shard_inline_skip "$_subj --self-test" && continue
|
|
1285
1408
|
_to=""; command -v timeout >/dev/null 2>&1 && _to="timeout 120"
|
|
1286
1409
|
_st_out="$($_to bash "scripts/$_subj.sh" --self-test < /dev/null 2>&1)"; _st_rc=$?
|
|
1287
1410
|
# rc=10 (or the sibling harness-error codes) means the subject could not even set up its own
|
|
@@ -1459,6 +1582,7 @@ fi
|
|
|
1459
1582
|
if [ ! -f scripts/cluster_capability_scan.sh ]; then
|
|
1460
1583
|
echo "FAIL cluster_capability_scan.sh: missing — it ships via package.json files[], so absence is deletion, not package mode"
|
|
1461
1584
|
fail=1
|
|
1585
|
+
elif _shard_inline_skip "cluster_capability_scan.sh --self-test"; then :
|
|
1462
1586
|
elif _out=$(bash scripts/cluster_capability_scan.sh --self-test < /dev/null 2>&1) \
|
|
1463
1587
|
&& printf '%s\n' "$_out" | grep -qE '캘리브레이션 통과: [1-9][0-9]* PASS / 0 FAIL'; then
|
|
1464
1588
|
echo "PASS cluster_capability_scan.sh --self-test ($(printf '%s\n' "$_out" | grep -oE '[0-9]+ PASS / [0-9]+ FAIL' | tail -1))"
|
|
@@ -1469,7 +1593,7 @@ else
|
|
|
1469
1593
|
fi
|
|
1470
1594
|
# 밀폐 레인(2026-10-02, pmh-dev #84) — 호출자 env 에 클러스터 변수가 살아 있어도 self-test 판정이 같아야 한다.
|
|
1471
1595
|
# known-pair: 위 블록(env 없음)과 이 블록(env 있음)이 같은 «0 FAIL» 을 내고, 이 블록은 비운 사실을 이름으로 말한다.
|
|
1472
|
-
if [ -f scripts/cluster_capability_scan.sh ]; then
|
|
1596
|
+
if [ -f scripts/cluster_capability_scan.sh ] && ! _shard_inline_skip "cluster_capability_scan.sh --self-test (hermetic)"; then
|
|
1473
1597
|
if _out=$(FH_CLUSTER_ROOTS=/nonexistent-fh-a:/nonexistent-fh-b FH_TRACKS_ROOT=/nonexistent-fh-tracks FH_PROJECTS_HOME=/nonexistent-fh-home \
|
|
1474
1598
|
bash scripts/cluster_capability_scan.sh --self-test < /dev/null 2>&1) \
|
|
1475
1599
|
&& printf '%s\n' "$_out" | grep -qE '캘리브레이션 통과: [1-9][0-9]* PASS / 0 FAIL' \
|
|
@@ -1497,6 +1621,7 @@ fi
|
|
|
1497
1621
|
if [ ! -f scripts/capability_effect_probe.sh ]; then
|
|
1498
1622
|
echo "FAIL capability_effect_probe.sh: missing — it ships via package.json files[], so absence is deletion, not package mode"
|
|
1499
1623
|
fail=1
|
|
1624
|
+
elif _shard_inline_skip "capability_effect_probe.sh --self-test"; then :
|
|
1500
1625
|
elif _out=$(bash scripts/capability_effect_probe.sh --self-test < /dev/null 2>&1) \
|
|
1501
1626
|
&& printf '%s\n' "$_out" | grep -qE '^── capability_effect_probe lanes: [1-9][0-9]* PASS / 0 FAIL ──$'; then
|
|
1502
1627
|
echo "PASS capability_effect_probe.sh --self-test ($(printf '%s\n' "$_out" | grep -oE '[0-9]+ PASS / [0-9]+ FAIL' | tail -1))"
|
|
@@ -1527,6 +1652,7 @@ fi
|
|
|
1527
1652
|
if [ ! -f scripts/relay_channel.sh ] || [ ! -f scripts/test_relay_channel_lanes.sh ]; then
|
|
1528
1653
|
echo "FAIL relay_channel.sh: missing (relay_channel.sh or its sibling test_relay_channel_lanes.sh) — ships via package.json files[], so absence is deletion, not package mode"
|
|
1529
1654
|
fail=1
|
|
1655
|
+
elif _shard_inline_skip "relay_channel.sh --self-test"; then :
|
|
1530
1656
|
elif _out=$($_LANE_TO bash scripts/relay_channel.sh --self-test < /dev/null 2>&1); then
|
|
1531
1657
|
echo "PASS relay_channel.sh --self-test ($(printf '%s\n' "$_out" | grep -oE 'relay_channel lanes: [0-9]+ PASS / [0-9]+ FAIL' | tail -1))"
|
|
1532
1658
|
else
|
|
@@ -1562,6 +1688,7 @@ fi
|
|
|
1562
1688
|
if [ ! -f scripts/directional_diff_gate.sh ]; then
|
|
1563
1689
|
echo "FAIL directional_diff_gate.sh: missing — it ships via package.json files[], so absence is deletion, not package mode"
|
|
1564
1690
|
fail=1
|
|
1691
|
+
elif _shard_inline_skip "directional_diff_gate.sh --self-test"; then :
|
|
1565
1692
|
else
|
|
1566
1693
|
_out=$($_LANE_TO bash scripts/directional_diff_gate.sh --self-test < /dev/null 2>&1); _dd_rc=$?
|
|
1567
1694
|
case "$_dd_rc" in
|
|
@@ -1621,6 +1748,7 @@ fi
|
|
|
1621
1748
|
if [ ! -f scripts/prepublish_scope_note.sh ]; then
|
|
1622
1749
|
echo "FAIL prepublish_scope_note.sh: missing — it ships via package.json files[], so absence is deletion, not package mode"
|
|
1623
1750
|
fail=1
|
|
1751
|
+
elif _shard_inline_skip "prepublish_scope_note.sh --self-test"; then :
|
|
1624
1752
|
elif _out=$(bash scripts/prepublish_scope_note.sh --self-test < /dev/null 2>&1) \
|
|
1625
1753
|
&& printf '%s\n' "$_out" | grep -qE '^ ── [1-9][0-9]* pass / 0 fail$'; then
|
|
1626
1754
|
echo "PASS prepublish_scope_note.sh --self-test ($(printf '%s\n' "$_out" | grep -oE '[0-9]+ pass / [0-9]+ fail' | tail -1))"
|
|
@@ -2627,6 +2755,24 @@ if [ -f scripts/test_selfcheck_state_lanes.sh ]; then
|
|
|
2627
2755
|
fi
|
|
2628
2756
|
fi
|
|
2629
2757
|
|
|
2758
|
+
# `--shard i/N` (2026-10-31): the plan must cover every suite exactly once, or a sharded CI run silently
|
|
2759
|
+
# drops (or doubles) a suite while every shard is green. Dry runs only — seconds, and it cannot recurse.
|
|
2760
|
+
if [ -f scripts/test_selfcheck_shard_lanes.sh ]; then
|
|
2761
|
+
if _consumer_skip test_selfcheck_shard_lanes.sh; then :
|
|
2762
|
+
elif _out=$(bash scripts/test_selfcheck_shard_lanes.sh 2>&1); then
|
|
2763
|
+
echo "PASS test_selfcheck_shard_lanes.sh (union == full plan · disjoint · known-negative · --shard absent = today)"
|
|
2764
|
+
else
|
|
2765
|
+
echo "FAIL test_selfcheck_shard_lanes.sh: the shard plan would drop or double a suite"
|
|
2766
|
+
_show_failure "$_out"
|
|
2767
|
+
fail=1
|
|
2768
|
+
fi
|
|
2769
|
+
elif _ships_per_files "scripts/test_selfcheck_shard_lanes.sh"; then
|
|
2770
|
+
echo "FAIL test_selfcheck_shard_lanes.sh: DECLARED SHIPPED (package.json files[]) but absent — deletion or broken install"
|
|
2771
|
+
fail=1
|
|
2772
|
+
else
|
|
2773
|
+
echo "SKIP test_selfcheck_shard_lanes.sh (not in this package's files[], and absent)"
|
|
2774
|
+
fi
|
|
2775
|
+
|
|
2630
2776
|
# test_lane_runner_lanes.sh — the checker that finds unrun suites had no suite of its own until
|
|
2631
2777
|
# 2026-08-13. It guarded its own WIRING (it fails when selfcheck stops calling it) and nothing
|
|
2632
2778
|
# measured its BEHAVIOUR — the shape it exists to catch, one level up. Wired in the same change
|
|
@@ -2766,7 +2912,8 @@ fi
|
|
|
2766
2912
|
# consults it before FAILing, so the two paths render SKIP regardless of how `.git` happens to be
|
|
2767
2913
|
# shaped in the consumer's tree. `[ -e .git ]` still gates whether the SCAN runs at all (an installed
|
|
2768
2914
|
# package with no tracked-refs source to lint), which is a real and unrelated question.
|
|
2769
|
-
if
|
|
2915
|
+
if _shard_inline_skip "ref-path"; then :
|
|
2916
|
+
elif [ -e ".git" ]; then
|
|
2770
2917
|
# Backtick-quoted repo-relative file refs in the always-loaded governance surface
|
|
2771
2918
|
# (CLAUDE.md + .claude/rules/*.md) must exist. Phantom-reference class recurred
|
|
2772
2919
|
# N>=3 in the 2026-06-11 audit window — instrument-not-habit.
|
|
@@ -2837,7 +2984,8 @@ fi
|
|
|
2837
2984
|
# 이고 package.json files[] 로 출하된다(소비자가 받는 기본 패턴). 초판은 «전부 ignored» 로
|
|
2838
2985
|
# 썼고 깨끗한 트리에서 그 둘에 FAIL 을 냈다 — 과차단은 override 를 훈련시키므로 결함이다.
|
|
2839
2986
|
# 남는 한 칸 «tracked 도 ignored 도 아님» 이 정확히 유출 상태다.
|
|
2840
|
-
if
|
|
2987
|
+
if _shard_inline_skip "rules-dotfile"; then :
|
|
2988
|
+
elif [ -e .git ]; then
|
|
2841
2989
|
# 🟥 «디렉터리가 없다»와 «있는데 비었다»를 한 칸으로 접지 않는다 — find 는 둘 다 빈 출력이다.
|
|
2842
2990
|
# 앞은 계기 오류(이 검사가 겨눌 자리가 없다), 뒤는 소비자 설치의 정상 상태다.
|
|
2843
2991
|
if [ ! -d .claude/rules ]; then
|
|
@@ -2890,7 +3038,7 @@ if [ "$_CONSUMER" -eq 1 ]; then
|
|
|
2890
3038
|
echo "CONSUMER PROFILE — $_n checkout-only suite(s) NOT measured here (not a pass):$CONSUMER_SKIPPED"
|
|
2891
3039
|
fi
|
|
2892
3040
|
if [ "$fail" -ne 0 ]; then
|
|
2893
|
-
echo "SELFCHECK: FAIL"
|
|
3041
|
+
echo "SELFCHECK: FAIL${_SHARD_N:+ (shard $_SHARD_I/$_SHARD_N)}"
|
|
2894
3042
|
exit 1
|
|
2895
3043
|
fi
|
|
2896
|
-
if [ "$_CONSUMER" -eq 1 ]; then echo "SELFCHECK: PASS (consumer profile)"; else echo "SELFCHECK: PASS"; fi
|
|
3044
|
+
if [ "$_CONSUMER" -eq 1 ]; then echo "SELFCHECK: PASS (consumer profile)"; else echo "SELFCHECK: PASS${_SHARD_N:+ (shard $_SHARD_I/$_SHARD_N)}"; fi
|
|
@@ -916,5 +916,68 @@ else
|
|
|
916
916
|
fi
|
|
917
917
|
rm -rf "$_s7"
|
|
918
918
|
|
|
919
|
+
# ── --staged: the scanner reads the INDEX, not the working tree (harness-doctor S-4, 2026-10-31) ──
|
|
920
|
+
# Known pair in a throwaway repo. A: smell STAGED, working tree fixed -> must be found.
|
|
921
|
+
# B: staged clean, working tree dirtied afterwards -> must NOT be found. Default mode keeps reading the tree.
|
|
922
|
+
_stg=$(mktemp -d)
|
|
923
|
+
(
|
|
924
|
+
cd "$_stg" && git init -q . && git config user.email t@t && git config user.name t
|
|
925
|
+
printf '#!/usr/bin/env bash\nr=$(run_scan) || return 0\n' > a.sh
|
|
926
|
+
printf '#!/usr/bin/env bash\nexit 1\n' > b.sh
|
|
927
|
+
git add a.sh b.sh
|
|
928
|
+
printf '#!/usr/bin/env bash\nexit 1\n' > a.sh # worktree fixed, index still smelly
|
|
929
|
+
printf '#!/usr/bin/env bash\nr=$(run_scan) || return 0\n' > b.sh # worktree smelly, index clean
|
|
930
|
+
)
|
|
931
|
+
_sa=$(cd "$_stg" && bash "$SCAN" --staged a.sh 2>&1 | grep -cE '\[S1:')
|
|
932
|
+
_sb=$(cd "$_stg" && bash "$SCAN" --staged b.sh 2>&1 | grep -cE '\[S1:')
|
|
933
|
+
_sd=$(cd "$_stg" && bash "$SCAN" b.sh 2>&1 | grep -cE '\[S1:')
|
|
934
|
+
if [ "$_sa" -eq 1 ]; then ok "STAGED POS: smell only in the index is found"; else bad "STAGED POS: index smell missed ($_sa)"; fi
|
|
935
|
+
if [ "$_sb" -eq 0 ]; then ok "STAGED NEG: smell only in the working tree is not reported"; else bad "STAGED NEG: read the working tree ($_sb)"; fi
|
|
936
|
+
if [ "$_sd" -eq 1 ]; then ok "STAGED CTL: default mode still reads the working tree (control for NEG)"; else bad "STAGED CTL: default mode changed ($_sd) — NEG UNINTERPRETABLE"; fi
|
|
937
|
+
rm -rf "$_stg"
|
|
938
|
+
# codex R1 (2026-10-31): quoted names, «nothing measured» read as clean, and target spellings.
|
|
939
|
+
_stg2=$(mktemp -d); _stg2=$(cd "$_stg2" && pwd -P)
|
|
940
|
+
(
|
|
941
|
+
cd "$_stg2" && git init -q . && git config user.email t@t && git config user.name t
|
|
942
|
+
mkdir sub
|
|
943
|
+
printf '#!/usr/bin/env bash\nr=$(run_scan) || return 0\n' > "한글.sh"
|
|
944
|
+
printf '#!/usr/bin/env bash\nr=$(run_scan) || return 0\n' > sub/c.sh
|
|
945
|
+
git add "한글.sh" sub/c.sh
|
|
946
|
+
)
|
|
947
|
+
_q=$(cd "$_stg2" && bash "$SCAN" --staged "한글.sh" 2>&1 | grep -cE '\[S1:')
|
|
948
|
+
_qa=$(cd "$_stg2" && bash "$SCAN" --staged 2>&1 | grep -cE '\[S1:')
|
|
949
|
+
_m=$(cd "$_stg2" && bash "$SCAN" --staged missing.sh 2>&1); _mrc=$?
|
|
950
|
+
_d=$(cd "$_stg2" && bash "$SCAN" --staged ./ 2>&1 | grep -cE '\[S1:')
|
|
951
|
+
_ab=$(cd "$_stg2" && bash "$SCAN" --staged "$_stg2/sub/c.sh" 2>&1 | grep -cE '\[S1:')
|
|
952
|
+
_sd2=$(cd "$_stg2/sub" && bash "$SCAN" --staged c.sh 2>&1 | grep -cE '\[S1:')
|
|
953
|
+
if [ "$_q" -eq 1 ]; then ok "STAGED Q1: non-ASCII staged name given as target is scanned"; else bad "STAGED Q1: non-ASCII name missed ($_q)"; fi
|
|
954
|
+
if [ "$_qa" -eq 2 ]; then ok "STAGED Q2: no targets reads every staged file incl. non-ASCII (2)"; else bad "STAGED Q2: expected 2 smells, got $_qa"; fi
|
|
955
|
+
if [ "$_mrc" -eq 2 ] && printf '%s' "$_m" | grep -q "COULD NOT BE MEASURED"; then ok "STAGED M1: a target matching no staged file is NOT clean (rc 2 + marker)"; else bad "STAGED M1: rc=${_mrc} «${_m}»"; fi
|
|
956
|
+
if [ "$_d" -eq 2 ]; then ok "STAGED P1: './' selects the whole index"; else bad "STAGED P1: './' gave $_d"; fi
|
|
957
|
+
if [ "$_ab" -eq 1 ]; then ok "STAGED P2: absolute path under the repo resolves"; else bad "STAGED P2: absolute path gave $_ab"; fi
|
|
958
|
+
if [ "$_sd2" -eq 1 ]; then ok "STAGED P3: path relative to a subdir cwd resolves"; else bad "STAGED P3: subdir-relative gave $_sd2"; fi
|
|
959
|
+
rm -rf "$_stg2"
|
|
960
|
+
# codex R2 (2026-10-31): unsupported types, symlinked absolute paths, one unmatched target among matched.
|
|
961
|
+
_stg3=$(mktemp -d); _stg3p=$(cd "$_stg3" && pwd -P)
|
|
962
|
+
(
|
|
963
|
+
cd "$_stg3" && git init -q . && git config user.email t@t && git config user.name t
|
|
964
|
+
mkdir sub
|
|
965
|
+
printf 'x\n' > gate.js
|
|
966
|
+
printf '#!/usr/bin/env bash\nr=$(run_scan) || return 0\n' > sub/a.sh
|
|
967
|
+
printf '#!/usr/bin/env bash\nexit 1\n' > clean.sh
|
|
968
|
+
git add gate.js sub/a.sh clean.sh
|
|
969
|
+
)
|
|
970
|
+
_js=$(cd "$_stg3" && bash "$SCAN" --staged gate.js 2>&1); _jsrc=$?
|
|
971
|
+
_jsd=$(cd "$_stg3" && bash "$SCAN" gate.js 2>&1); _jsdrc=$?
|
|
972
|
+
_ln=""; [ "$_stg3" != "$_stg3p" ] && _ln="$_stg3"; [ -z "$_ln" ] && { ln -s "$_stg3p" "$_stg3p.lnk"; _ln="$_stg3p.lnk"; }
|
|
973
|
+
_sy=$(cd "$_stg3p" && bash "$SCAN" --staged "$_ln/sub/a.sh" clean.sh 2>&1 | grep -cE '\[S1:')
|
|
974
|
+
_dt=$(cd "$_stg3p" && bash "$SCAN" --staged sub/./a.sh clean.sh 2>&1 | grep -cE '\[S1:')
|
|
975
|
+
_um=$(cd "$_stg3p" && bash "$SCAN" --staged clean.sh nope.sh 2>&1); _umrc=$?
|
|
976
|
+
if [ "$_jsrc" -eq "$_jsdrc" ] && [ "$_jsrc" -ne 0 ]; then ok "STAGED U1: unsupported staged file exits like the default mode (rc ${_jsrc}, not 0)"; else bad "STAGED U1: staged rc=${_jsrc} default rc=${_jsdrc}"; fi
|
|
977
|
+
if [ "$_sy" -eq 1 ]; then ok "STAGED S1: symlinked absolute path resolves to the physical repo path"; else bad "STAGED S1: symlinked path gave ${_sy}"; fi
|
|
978
|
+
if [ "$_dt" -eq 1 ]; then ok "STAGED S2: sub/./a.sh resolves"; else bad "STAGED S2: sub/./a.sh gave ${_dt}"; fi
|
|
979
|
+
if [ "$_umrc" -eq 2 ] && printf '%s' "$_um" | grep -q "COULD NOT BE MEASURED"; then ok "STAGED S3: one unmatched target among matched ones is NOT clean"; else bad "STAGED S3: rc=${_umrc}"; fi
|
|
980
|
+
rm -rf "$_stg3" "$_stg3p.lnk"
|
|
981
|
+
|
|
919
982
|
echo "degrade-scan shell probes: $pass passed, $fail failed"
|
|
920
983
|
|
|
@@ -48,6 +48,7 @@ case "\$1 \$2" in
|
|
|
48
48
|
else echo "MERGED \$(cat "\$D/head.oid")"; fi
|
|
49
49
|
elif [ -f "\$D/closed" ]; then echo "CLOSED \$(cat "\$D/head.oid")"
|
|
50
50
|
else echo "OPEN \$(cat "\$D/head.oid")"; fi ;;
|
|
51
|
+
*title*) echo "Fake PR title" ;;
|
|
51
52
|
*headRefOid*) cat "\$D/head.oid"; echo ;;
|
|
52
53
|
*state*) if [ -f "\$D/merge.oid" ] && [ ! -f "\$D/queued" ]; then echo MERGED; else echo OPEN; fi ;;
|
|
53
54
|
*mergeCommit*) if [ -f "\$D/queued" ]; then echo null; else cat "\$D/merge.oid" 2>/dev/null; echo; fi ;; esac ;;
|
|
@@ -194,5 +195,37 @@ SETUP_EXTRA=1 setup cvd; mkgh "$T/cvd"; run "$T/cvd" 7 --rerun 'git --version &&
|
|
|
194
195
|
{ [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'mentions none of this PR'; } \
|
|
195
196
|
&& ok "L25b --rerun naming a tracked dir → advisory still fires (blobs only)" || bad "L25b rc=$RC (dir listing counted as coverage?)"
|
|
196
197
|
|
|
198
|
+
# ── completion record (tracks/_meta/fh_completed_<date>.md) ──
|
|
199
|
+
# cl_setup <name> : a work clone that HAS a tracks/ dir (a consumer without one is skipped silently — L30)
|
|
200
|
+
cl_setup() { setup "$1"; mkgh "$T/$1"; mkdir -p "$T/$1/work/tracks"; }
|
|
201
|
+
cl_file() { echo "$T/$1/work/tracks/_meta/fh_completed_$(date +%F).md"; }
|
|
202
|
+
cl_lines() { [ -f "$(cl_file "$1")" ] && grep -c '^- .* PR #7 ' "$(cl_file "$1")" || echo 0; }
|
|
203
|
+
# L26 merged + verified → exactly one line, says verified, carries title and short merge sha
|
|
204
|
+
cl_setup c1; run "$T/c1" 7 --rerun "$GOOD"
|
|
205
|
+
{ [ "$RC" -eq 0 ] && [ "$(cl_lines c1)" -eq 1 ] && grep -q 'PR #7 Fake PR title → merged '"$(cut -c1-7 "$T/c1/merge.oid")"' (verified) — auto$' "$(cl_file c1)" \
|
|
206
|
+
&& awk 'NR==1{exit !/^# /}' "$(cl_file c1)"; } \
|
|
207
|
+
&& ok "L26 merged+verified → one completion line (verified · sha · title) + header" || { bad "L26 rc=$RC"; cat "$(cl_file c1)" 2>/dev/null; }
|
|
208
|
+
# L27 merged + verification failed → one line saying verify-failed, rc unchanged (1)
|
|
209
|
+
cl_setup c2; : > "$T/c2/drop_b"; run "$T/c2" 7 --rerun 'grep -q a2 a && echo a-ok'
|
|
210
|
+
{ [ "$RC" -eq 1 ] && [ "$(cl_lines c2)" -eq 1 ] && grep -q '(verify-failed rc=1)' "$(cl_file c2)"; } \
|
|
211
|
+
&& ok "L27 merged+verify-failed → one line «verify-failed», rc=1" || { bad "L27 rc=$RC"; cat "$(cl_file c2)" 2>/dev/null; }
|
|
212
|
+
# L28 merge refused (gh fails, PR stays OPEN) and queued (not completed) → no line
|
|
213
|
+
cl_setup c3; : > "$T/c3/merge_fail"; run "$T/c3" 7 --rerun "$GOOD"; rc3=$RC
|
|
214
|
+
cl_setup c3q; : > "$T/c3q/queued"; run "$T/c3q" 7 --rerun "$GOOD"; rc3q=$RC
|
|
215
|
+
{ [ "$rc3" -eq 5 ] && [ "$rc3q" -eq 6 ] && [ ! -e "$(cl_file c3)" ] && [ ! -e "$(cl_file c3q)" ]; } \
|
|
216
|
+
&& ok "L28 merge refused / queued → no completion line" || bad "L28 rc=$rc3/$rc3q file written for a merge that did not complete"
|
|
217
|
+
# L29 opt-out FH_MERGE_NO_COMPLETED_LOG=1 → merge verified as usual, no line
|
|
218
|
+
cl_setup c4; FH_MERGE_NO_COMPLETED_LOG=1 run "$T/c4" 7 --rerun "$GOOD"
|
|
219
|
+
{ [ "$RC" -eq 0 ] && [ ! -e "$(cl_file c4)" ]; } && ok "L29 opt-out env → no line, rc=0" || bad "L29 rc=$RC"
|
|
220
|
+
# L30 repo without tracks/ → silent skip (nothing created, no warning)
|
|
221
|
+
setup c5; mkgh "$T/c5"; run "$T/c5" 7 --rerun "$GOOD"
|
|
222
|
+
{ [ "$RC" -eq 0 ] && [ ! -e "$T/c5/work/tracks" ] && ! printf '%s' "$OUT" | grep -q 'completion record'; } \
|
|
223
|
+
&& ok "L30 no tracks/ dir → skipped silently, tracks/ not created" || bad "L30 rc=$RC"
|
|
224
|
+
# L31 unwritable tracks/_meta → one warning, same rc as without the feature (0), merge stands
|
|
225
|
+
cl_setup c6; mkdir -p "$T/c6/work/tracks/_meta"; chmod 500 "$T/c6/work/tracks/_meta"; run "$T/c6" 7 --rerun "$GOOD"; chmod 700 "$T/c6/work/tracks/_meta"
|
|
226
|
+
if [ "$(id -u)" -eq 0 ]; then ok "L31 SKIP (root can write anywhere) — not a pass"
|
|
227
|
+
else { [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'WARNING: completion record NOT written' && printf '%s' "$OUT" | grep -q 'merged and verified'; } \
|
|
228
|
+
&& ok "L31 unwritable tracks/_meta → warning, rc=0 unchanged" || { bad "L31 rc=$RC"; printf '%s\n' "$OUT" | tail -3; }; fi
|
|
229
|
+
|
|
197
230
|
printf 'PASS %d · FAIL %d\n' "$PASS" "$FAIL"
|
|
198
231
|
[ "$FAIL" -eq 0 ]
|