@chrono-meta/fh-gate 3.26.1 → 3.27.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 +4 -4
- package/AGENTS.md +2 -1
- package/CLAUDE.md +84 -1329
- package/knowledge/shared/dialogue/memory_intent_recall.md +35 -0
- package/knowledge/shared/harness-core/builtin_capability_map.md +70 -0
- package/knowledge/shared/harness-core/claude_md_full_reference.md +1277 -0
- package/knowledge/shared/harness-core/multi_model_sidecar_strategy.md +64 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +64 -0
- package/package.json +5 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +20 -0
- package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -1
- package/plugins/fh-meta/skills/install-doctor/SKILL.md +1 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/capability_effect_probe.sh +98 -23
- package/scripts/fh_env_delta_scan.sh +20 -4
- package/scripts/memory_gc_report.py +270 -0
- package/scripts/selfcheck.sh +27 -0
- package/scripts/test_env_delta_worktree_lanes.sh +61 -0
- package/scripts/test_memory_gc_report_lanes.sh +210 -0
- package/scripts/test_regression_guard_sibling_lanes.sh +193 -0
- package/templates/regression_guard.sh +30 -12
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_regression_guard_sibling_lanes.sh — Axis 1's «moved is not lost» sibling lookup.
|
|
3
|
+
#
|
|
4
|
+
# WHY (2026-10-16): CLAUDE.md became a ~95-line resident core and the full ruleset moved to
|
|
5
|
+
# knowledge/shared/harness-core/claude_md_full_reference.md. The guard's sibling lookup only knew
|
|
6
|
+
# SKILL.md <-> SKILL_detail.md, so the move read as 100% token loss and hard-blocked the commit.
|
|
7
|
+
# The pair was added to the same symmetric lookup. No lane covered the lookup before — not even the
|
|
8
|
+
# SKILL pair — so these lanes cover both pairs and both directions:
|
|
9
|
+
# moved into the sibling -> no M-tier (exit != 2)
|
|
10
|
+
# dropped from both -> M-tier block (exit 2) <- the lookup must not become a free pass
|
|
11
|
+
# plus a REVERT PROBE: the CLAUDE.md case is deleted from a copy of the guard and lane S1 must turn red.
|
|
12
|
+
#
|
|
13
|
+
# Usage: bash scripts/test_regression_guard_sibling_lanes.sh Exit: 0 = all behave; 1 = regression.
|
|
14
|
+
|
|
15
|
+
set -uo pipefail
|
|
16
|
+
. "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # fixtures never write the real repo
|
|
17
|
+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
18
|
+
GUARD="$REPO_ROOT/templates/regression_guard.sh"
|
|
19
|
+
T="$(fh_fixture_root "$(mktemp -d)")"
|
|
20
|
+
: "${T:?fixture root unset — refusing to run git in cwd}"
|
|
21
|
+
trap 'rm -rf "$T"' EXIT
|
|
22
|
+
FAIL=0
|
|
23
|
+
REF=knowledge/shared/harness-core/claude_md_full_reference.md
|
|
24
|
+
|
|
25
|
+
BODY='## Execution Steps
|
|
26
|
+
Step 0 read. Step 1 scan. Step 2 propose. Step 3 run.
|
|
27
|
+
```bash
|
|
28
|
+
bash scripts/x.sh
|
|
29
|
+
```
|
|
30
|
+
```bash
|
|
31
|
+
bash scripts/y.sh
|
|
32
|
+
```
|
|
33
|
+
```bash
|
|
34
|
+
bash scripts/z.sh
|
|
35
|
+
```
|
|
36
|
+
## Done When
|
|
37
|
+
the gate says PASS or BLOCK.
|
|
38
|
+
M-tier and S-tier are defined in the guard.
|
|
39
|
+
'
|
|
40
|
+
|
|
41
|
+
# $1=dir — base commit: CLAUDE.md and a skill both carry the tokens, no siblings yet
|
|
42
|
+
mkrepo() {
|
|
43
|
+
local d=$1
|
|
44
|
+
mkdir -p "$d/plugins/p/skills/s" "$d/knowledge/shared/harness-core"
|
|
45
|
+
git -C "$d" init -q && git -C "$d" config user.email t@t && git -C "$d" config user.name t
|
|
46
|
+
printf '# hub\n%s' "$BODY" > "$d/CLAUDE.md"
|
|
47
|
+
printf -- '---\nname: s\ndescription: d\n---\n# s\n%s' "$BODY" > "$d/plugins/p/skills/s/SKILL.md"
|
|
48
|
+
git -C "$d" add -A && git -C "$d" commit -q -m base
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# $1=id $2=dir $3=guard $4=expect(block|pass)
|
|
52
|
+
run_lane() {
|
|
53
|
+
local id=$1 d=$2 g=$3 want=$4 rc out
|
|
54
|
+
out=$(cd "$d" && bash "$g" --staged 2>&1); rc=$?
|
|
55
|
+
if [ -z "$out" ]; then echo " ❌ $id — guard printed nothing (instrument silence, not a pass)"; FAIL=1; return; fi
|
|
56
|
+
if [ "$rc" -ne 0 ] && [ "$rc" -ne 1 ] && [ "$rc" -ne 2 ]; then
|
|
57
|
+
echo " ❌ $id — guard rc=$rc (could not run)"; printf '%s\n' "$out" | tail -3 | sed 's/^/ /'; FAIL=1; return
|
|
58
|
+
fi
|
|
59
|
+
if [ "$want" = block ] && [ "$rc" -eq 2 ]; then echo " ✅ $id — M-tier block (rc=2)"
|
|
60
|
+
elif [ "$want" = pass ] && [ "$rc" -ne 2 ] && grep -q "moved to" <<<"$out"; then echo " ✅ $id — no M-tier, move recognised (rc=$rc)"
|
|
61
|
+
elif [ "$want" = pass ] && [ "$rc" -ne 2 ]; then echo " ❌ $id — rc=$rc but no «moved to» line: the pair was never examined (a SKIP is not a pass)"; FAIL=1
|
|
62
|
+
else echo " ❌ $id — expected $want, got rc=$rc"; printf '%s\n' "$out" | grep -E 'M-TIER|moved' | head -4 | sed 's/^/ /'; FAIL=1; fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
echo "── regression_guard sibling lanes ──"
|
|
66
|
+
|
|
67
|
+
# S1: CLAUDE.md slimmed, content moved to the reference file -> move, not loss
|
|
68
|
+
d=$T/s1; mkrepo "$d"
|
|
69
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"
|
|
70
|
+
printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
71
|
+
git -C "$d" add -A
|
|
72
|
+
run_lane "S1 CLAUDE.md -> reference move" "$d" "$GUARD" pass
|
|
73
|
+
|
|
74
|
+
# S2: CLAUDE.md slimmed, reference file lacks the content -> real loss still blocks
|
|
75
|
+
d=$T/s2; mkrepo "$d"
|
|
76
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"
|
|
77
|
+
printf '# full reference\nunrelated.\n' > "$d/$REF"
|
|
78
|
+
git -C "$d" add -A
|
|
79
|
+
run_lane "S2 CLAUDE.md loss with empty reference" "$d" "$GUARD" block
|
|
80
|
+
|
|
81
|
+
# S3: CLAUDE.md slimmed, no reference file at all -> blocks
|
|
82
|
+
d=$T/s3; mkrepo "$d"
|
|
83
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"
|
|
84
|
+
git -C "$d" add -A
|
|
85
|
+
run_lane "S3 CLAUDE.md loss, reference absent" "$d" "$GUARD" block
|
|
86
|
+
|
|
87
|
+
# S4: the older pair still works — SKILL.md content moved to SKILL_detail.md
|
|
88
|
+
d=$T/s4; mkrepo "$d"
|
|
89
|
+
printf -- '---\nname: s\ndescription: d\n---\n# s\nsee detail.\n' > "$d/plugins/p/skills/s/SKILL.md"
|
|
90
|
+
printf '# detail\n%s' "$BODY" > "$d/plugins/p/skills/s/SKILL_detail.md"
|
|
91
|
+
git -C "$d" add -A
|
|
92
|
+
run_lane "S4 SKILL.md -> SKILL_detail.md move" "$d" "$GUARD" pass
|
|
93
|
+
|
|
94
|
+
# S5: a file that is NOT a pair member does not borrow the reference's content
|
|
95
|
+
d=$T/s5; mkrepo "$d"
|
|
96
|
+
printf '# agents\n%s' "$BODY" > "$d/AGENTS.md"; git -C "$d" add AGENTS.md; git -C "$d" commit -q -m agents
|
|
97
|
+
printf '# agents\nshort.\n' > "$d/AGENTS.md"
|
|
98
|
+
printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
99
|
+
git -C "$d" add -A
|
|
100
|
+
out=$(cd "$d" && bash "$GUARD" --staged 2>&1)
|
|
101
|
+
if grep -q "AGENTS.md" <<<"$out" && ! grep -qE "moved to SKILL_detail.md.*" <<<"$out"; then
|
|
102
|
+
sec=$(grep -A30 "AGENTS.md" <<<"$out"); if [[ "$sec" == *"M-TIER"* ]]; then echo " ✅ S5 AGENTS.md loss is not excused by the reference file"
|
|
103
|
+
else echo " ❌ S5 AGENTS.md token loss produced no M-TIER line"; FAIL=1; fi
|
|
104
|
+
else echo " ❌ S5 AGENTS.md was not examined, or was treated as a move"; FAIL=1; fi
|
|
105
|
+
|
|
106
|
+
# S6: the sibling ALREADY held the content (unchanged this commit) -> deleting from CLAUDE.md still blocks
|
|
107
|
+
d=$T/s6; mkrepo "$d"
|
|
108
|
+
printf '# full reference\n%s' "$BODY" > "$d/$REF"; git -C "$d" add -A; git -C "$d" commit -q -m ref
|
|
109
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"
|
|
110
|
+
git -C "$d" add -A
|
|
111
|
+
run_lane "S6 unchanged sibling does not mask a CLAUDE.md loss" "$d" "$GUARD" block
|
|
112
|
+
|
|
113
|
+
# S7: both files lose the content in the same commit -> blocks
|
|
114
|
+
d=$T/s7; mkrepo "$d"
|
|
115
|
+
printf '# hub\n%s%s' "$BODY" "$BODY" > "$d/CLAUDE.md"; printf '# full reference\n%s%s' "$BODY" "$BODY" > "$d/$REF"; git -C "$d" add -A; git -C "$d" commit -q -m two
|
|
116
|
+
printf '# hub\n%s' "$BODY" > "$d/CLAUDE.md"; printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
117
|
+
git -C "$d" add -A
|
|
118
|
+
run_lane "S7 simultaneous loss in both files" "$d" "$GUARD" block
|
|
119
|
+
|
|
120
|
+
# S8: reverse direction — reference content moved back into CLAUDE.md -> move (reference side examined)
|
|
121
|
+
d=$T/s8; mkrepo "$d"
|
|
122
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"; printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
123
|
+
git -C "$d" add -A; git -C "$d" commit -q -m split
|
|
124
|
+
printf '# hub\n%s' "$BODY" > "$d/CLAUDE.md"; printf '# full reference\nmoved back.\n' > "$d/$REF"
|
|
125
|
+
git -C "$d" add -A
|
|
126
|
+
out=$(cd "$d" && bash "$GUARD" --staged 2>&1)
|
|
127
|
+
sec=$(grep -A60 "claude_md_full_reference.md" <<<"$out"); if [[ "$sec" == *"moved to"* ]] && [[ "$sec" != *"M-TIER"* ]]; then
|
|
128
|
+
echo " ✅ S8 reference -> CLAUDE.md reverse move recognised"
|
|
129
|
+
else echo " ❌ S8 reverse move not recognised on the reference side"; FAIL=1; fi
|
|
130
|
+
|
|
131
|
+
# S9 (F2 isolated): the sibling already holds a «## Trigger Phrases» heading, unchanged; CLAUDE.md drops
|
|
132
|
+
# its own. No F4 token is involved, so only the section check can catch it.
|
|
133
|
+
d=$T/s9; mkrepo "$d"
|
|
134
|
+
printf '# hub\n## Trigger Phrases\n- say hi\n' > "$d/CLAUDE.md"; printf '# full reference\n## Trigger Phrases\n- say hi\n' > "$d/$REF"
|
|
135
|
+
git -C "$d" add -A; git -C "$d" commit -q -m trig
|
|
136
|
+
printf '# hub\nno triggers.\n- say hi\n' > "$d/CLAUDE.md"; git -C "$d" add -A
|
|
137
|
+
out=$(cd "$d" && bash "$GUARD" --staged 2>&1)
|
|
138
|
+
if grep -q "'Triggers' section group dropped" <<<"$out"; then echo " ✅ S9 F2: unchanged sibling heading does not excuse a dropped section"
|
|
139
|
+
else echo " ❌ S9 F2: dropped section was excused (no «section group dropped» line)"; FAIL=1; fi
|
|
140
|
+
|
|
141
|
+
# S10 (F3 isolated): sibling already holds fences, unchanged; CLAUDE.md loses all of its fences
|
|
142
|
+
d=$T/s10; mkrepo "$d"
|
|
143
|
+
F6=$(printf '```bash\nx\n```\n```bash\ny\n```\n```bash\nz\n```\n')
|
|
144
|
+
printf '# hub\n%s\n' "$F6" > "$d/CLAUDE.md"; printf '# full reference\n%s\n' "$F6" > "$d/$REF"
|
|
145
|
+
git -C "$d" add -A; git -C "$d" commit -q -m fences
|
|
146
|
+
printf '# hub\nno code.\n' > "$d/CLAUDE.md"; git -C "$d" add -A
|
|
147
|
+
out=$(cd "$d" && bash "$GUARD" --staged 2>&1)
|
|
148
|
+
if grep -q "code blocks reduced" <<<"$out"; then echo " ✅ S10 F3: unchanged sibling fences do not excuse lost code blocks"
|
|
149
|
+
else echo " ❌ S10 F3: lost code blocks were excused"; FAIL=1; fi
|
|
150
|
+
|
|
151
|
+
# R1: revert probe — delete the CLAUDE.md case from a copy of the guard; S1 must now block
|
|
152
|
+
G2=$T/guard_reverted.sh
|
|
153
|
+
grep -v '^ CLAUDE.md) ' "$GUARD" > "$G2"
|
|
154
|
+
if cmp -s "$GUARD" "$G2"; then echo " ❌ R1 revert probe: the mutation did not apply (pattern drift) — HARNESS-ERROR"; FAIL=1
|
|
155
|
+
else
|
|
156
|
+
d=$T/r1; mkrepo "$d"
|
|
157
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"
|
|
158
|
+
printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
159
|
+
git -C "$d" add -A
|
|
160
|
+
run_lane "R1 revert probe: without the pair, S1 blocks" "$d" "$G2" block
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# R2: revert probe — credit the sibling's whole total again (the old behaviour); S6 must turn green-wrong
|
|
164
|
+
G3=$T/guard_total.sh
|
|
165
|
+
sed 's/a=\${a:-0}; b=\${b:-0}; \[ "\$a" -gt "\$b" \] \&\& echo \$((a - b)) || echo 0/a=${a:-0}; echo "$a"/' "$GUARD" > "$G3"
|
|
166
|
+
if cmp -s "$GUARD" "$G3"; then echo " ❌ R2 revert probe: the mutation did not apply (pattern drift) — HARNESS-ERROR"; FAIL=1
|
|
167
|
+
else
|
|
168
|
+
d=$T/r2; mkrepo "$d"
|
|
169
|
+
printf '# full reference\n%s' "$BODY" > "$d/$REF"; git -C "$d" add -A; git -C "$d" commit -q -m ref
|
|
170
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"; git -C "$d" add -A
|
|
171
|
+
rc=0; out=$(cd "$d" && bash "$G3" --staged 2>&1) || rc=$?
|
|
172
|
+
if { [ "$rc" -eq 0 ] || [ "$rc" -eq 1 ]; } && grep -q "moved to" <<<"$out"; then echo " ✅ R2 revert probe: whole-total credit lets S6 through as a «move» (rc=$rc) — S6 is what catches it"
|
|
173
|
+
else echo " ❌ R2 revert probe: S6 still blocked with whole-total credit — S6 is not anchoring the gain rule"; FAIL=1; fi
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
# R3: revert probe — drop the reverse arm; S8 must fail
|
|
177
|
+
G4=$T/guard_noreverse.sh
|
|
178
|
+
grep -v 'claude_md_full_reference.md) sib="CLAUDE.md"' "$GUARD" > "$G4"
|
|
179
|
+
if cmp -s "$GUARD" "$G4"; then echo " ❌ R3 revert probe: the mutation did not apply (pattern drift) — HARNESS-ERROR"; FAIL=1
|
|
180
|
+
else
|
|
181
|
+
d=$T/r3; mkrepo "$d"
|
|
182
|
+
printf '# hub\nresident core only.\n' > "$d/CLAUDE.md"; printf '# full reference\n%s' "$BODY" > "$d/$REF"
|
|
183
|
+
git -C "$d" add -A; git -C "$d" commit -q -m split
|
|
184
|
+
printf '# hub\n%s' "$BODY" > "$d/CLAUDE.md"; printf '# full reference\nmoved back.\n' > "$d/$REF"; git -C "$d" add -A
|
|
185
|
+
rc=0; out=$(cd "$d" && bash "$G4" --staged 2>&1) || rc=$?
|
|
186
|
+
if [ "$rc" -gt 2 ] || ! grep -q "claude_md_full_reference.md" <<<"$out"; then echo " ❌ R3 revert probe: mutated guard did not run or never examined the reference (rc=$rc) — HARNESS-ERROR"; FAIL=1
|
|
187
|
+
elif sec=$(grep -A60 "claude_md_full_reference.md" <<<"$out"); [[ "$sec" == *"moved to"* ]]; then echo " ❌ R3 revert probe: reverse move still recognised without the reverse arm"; FAIL=1
|
|
188
|
+
else echo " ✅ R3 revert probe: without the reverse arm the reference side no longer sees a move"; fi
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
echo
|
|
192
|
+
if [ "$FAIL" -eq 0 ]; then echo "ALL regression_guard sibling lanes behave."; exit 0; fi
|
|
193
|
+
echo "regression_guard sibling lanes: FAIL"; exit 1
|
|
@@ -425,11 +425,29 @@ print('OK')
|
|
|
425
425
|
# too, the reverse consolidation (detail → SKILL.md, e.g. un-splitting a skill) would otherwise
|
|
426
426
|
# read as content loss in the detail file and fire a false positive on exactly the refactor
|
|
427
427
|
# salience-splitter is designed to reverse.
|
|
428
|
-
|
|
428
|
+
# The resident/reference pair (2026-10-16): CLAUDE.md keeps a ~95-line resident core and the full
|
|
429
|
+
# ruleset lives in claude_md_full_reference.md with section names unchanged — the same split
|
|
430
|
+
# shape as SKILL.md/SKILL_detail.md, so it gets the same symmetric lookup. Only these two exact
|
|
431
|
+
# paths pair; any other file keeps an empty sibling, so this does not widen what counts as a move.
|
|
432
|
+
#
|
|
433
|
+
# 🟥 Credit only what the sibling GAINED in this change (2026-10-16, cross-family codex HIGH).
|
|
434
|
+
# The lookup used to compare against the sibling's CURRENT total, so a sibling that already held
|
|
435
|
+
# the content excused any later deletion — reproduced: an unchanged reference with matching tokens
|
|
436
|
+
# let CLAUDE.md lose its rules and PASS, and «both files lose half» (2+2 → 1+1) also passed. The
|
|
437
|
+
# SKILL pair had the same hole. Now every count below is after(sibling) − before(sibling), floored
|
|
438
|
+
# at 0: content counts as moved only if it arrived in the sibling in this same change.
|
|
439
|
+
detail_content=""; detail_before=""; sib=""
|
|
429
440
|
case "$f" in
|
|
430
|
-
*/SKILL.md)
|
|
431
|
-
*/SKILL_detail.md)
|
|
441
|
+
*/SKILL.md) sib="$(dirname "$f")/SKILL_detail.md" ;;
|
|
442
|
+
*/SKILL_detail.md) sib="$(dirname "$f")/SKILL.md" ;;
|
|
443
|
+
CLAUDE.md) sib="knowledge/shared/harness-core/claude_md_full_reference.md" ;;
|
|
444
|
+
knowledge/shared/harness-core/claude_md_full_reference.md) sib="CLAUDE.md" ;;
|
|
432
445
|
esac
|
|
446
|
+
if [ -n "$sib" ]; then detail_content=$(read_after "$sib"); detail_before=$(read_before "$sib"); fi
|
|
447
|
+
_gain() { # $1=counter fn $2=pattern -> max(0, count in sibling after − count in sibling before)
|
|
448
|
+
local a b; a=$("$1" "$detail_content" "$2"); b=$("$1" "$detail_before" "$2")
|
|
449
|
+
a=${a:-0}; b=${b:-0}; [ "$a" -gt "$b" ] && echo $((a - b)) || echo 0
|
|
450
|
+
}
|
|
433
451
|
|
|
434
452
|
# Deprecation/tombstone exemption (stub-shaped): a file soft-deleted into a small pointer
|
|
435
453
|
# stub. Content loss is the INTENT (mirrors the file-deletion skip above), so content-
|
|
@@ -489,14 +507,14 @@ print('OK')
|
|
|
489
507
|
before=$(count_regex_in "$before_content" "$pattern")
|
|
490
508
|
after=$(count_regex_in "$after_content" "$pattern")
|
|
491
509
|
detail=0
|
|
492
|
-
[ -n "$detail_content" ] && detail=$(count_regex_in "$
|
|
510
|
+
[ -n "$detail_content" ] && detail=$(_gain count_regex_in "$pattern")
|
|
493
511
|
combined=$((after + detail))
|
|
494
512
|
if [ "$before" -gt 0 ] && [ "$combined" -lt "$before" ]; then
|
|
495
513
|
echo " ❌ M-TIER '$label' section group dropped ($before → $combined)"
|
|
496
514
|
M_TIER=$((M_TIER + 1))
|
|
497
515
|
elif [ "$before" -gt 0 ] && [ "$after" -lt "$before" ]; then
|
|
498
516
|
if [ "$detail" -gt 0 ]; then
|
|
499
|
-
echo " ℹ️ '$label' section moved to
|
|
517
|
+
echo " ℹ️ '$label' section moved to ${sib##*/} ($before → $after + $detail in detail)"
|
|
500
518
|
verbose "suppressed section loss: sibling SKILL_detail.md preserves '$label' section header count"
|
|
501
519
|
else
|
|
502
520
|
echo " ℹ️ '$label' section heading renamed within known synonym group ($before → $after)"
|
|
@@ -513,7 +531,7 @@ print('OK')
|
|
|
513
531
|
group_before=$(count_regex_in "$before_content" "$group_pattern")
|
|
514
532
|
group_after=$(count_regex_in "$after_content" "$group_pattern")
|
|
515
533
|
group_detail=0
|
|
516
|
-
[ -n "$detail_content" ] && group_detail=$(count_regex_in "$
|
|
534
|
+
[ -n "$detail_content" ] && group_detail=$(_gain count_regex_in "$group_pattern")
|
|
517
535
|
group_combined=$((group_after + group_detail))
|
|
518
536
|
[ "$group_before" -gt 0 ] && [ "$group_combined" -ge "$group_before" ] || return
|
|
519
537
|
for name in "$@"; do
|
|
@@ -521,7 +539,7 @@ print('OK')
|
|
|
521
539
|
before=$(count_regex_in "$before_content" "$exact_pattern")
|
|
522
540
|
after=$(count_regex_in "$after_content" "$exact_pattern")
|
|
523
541
|
detail=0
|
|
524
|
-
[ -n "$detail_content" ] && detail=$(count_regex_in "$
|
|
542
|
+
[ -n "$detail_content" ] && detail=$(_gain count_regex_in "$exact_pattern")
|
|
525
543
|
if [ "$before" -gt 0 ] && [ $((after + detail)) -lt "$before" ]; then
|
|
526
544
|
verbose "suppressed dropped heading '$name': '$group_label' known-synonym group is preserved ($group_before → $group_combined)"
|
|
527
545
|
fi
|
|
@@ -547,7 +565,7 @@ print('OK')
|
|
|
547
565
|
[ -n "$header" ] || continue
|
|
548
566
|
before=$(count_exact_line_in "$before_content" "$header")
|
|
549
567
|
after=$(count_exact_line_in "$after_content" "$header")
|
|
550
|
-
detail=$(count_exact_line_in "$
|
|
568
|
+
detail=$(_gain count_exact_line_in "$header")
|
|
551
569
|
if [ "$before" -gt 0 ] && [ "$after" -lt "$before" ] && [ $((after + detail)) -ge "$before" ]; then
|
|
552
570
|
verbose "suppressed section-header reduction: '$header' moved to sibling SKILL_detail.md"
|
|
553
571
|
fi
|
|
@@ -560,12 +578,12 @@ print('OK')
|
|
|
560
578
|
before_code=$(count_in "$before_content" '^```')
|
|
561
579
|
after_code=$(count_in "$after_content" '^```')
|
|
562
580
|
detail_code=0
|
|
563
|
-
[ -n "$detail_content" ] && detail_code=$(count_in
|
|
581
|
+
[ -n "$detail_content" ] && detail_code=$(_gain count_in '^```')
|
|
564
582
|
if [ "$before_code" -gt 0 ]; then
|
|
565
583
|
combined_code=$((after_code + detail_code))
|
|
566
584
|
delta=$((before_code - combined_code))
|
|
567
585
|
if [ "$after_code" -lt "$before_code" ] && [ "$combined_code" -ge "$before_code" ]; then
|
|
568
|
-
echo " ℹ️ code blocks moved to
|
|
586
|
+
echo " ℹ️ code blocks moved to ${sib##*/} ($before_code → $after_code + $detail_code in detail)"
|
|
569
587
|
verbose "suppressed code-block reduction: sibling SKILL_detail.md preserves fenced-block count"
|
|
570
588
|
fi
|
|
571
589
|
if [ "$delta" -gt 4 ]; then
|
|
@@ -588,9 +606,9 @@ print('OK')
|
|
|
588
606
|
after=$(count_in "$after_content" "$token")
|
|
589
607
|
if [ "$before" -gt 0 ] && [ "$after" -lt "$before" ]; then
|
|
590
608
|
if [ -n "$detail_content" ]; then
|
|
591
|
-
in_detail=$(count_in "$
|
|
609
|
+
in_detail=$(_gain count_in "$token")
|
|
592
610
|
if [ $((after + in_detail)) -ge "$before" ]; then
|
|
593
|
-
echo " ℹ️ token '$token' moved to
|
|
611
|
+
echo " ℹ️ token '$token' moved to ${sib##*/} ($before → $after + $in_detail in detail)"
|
|
594
612
|
verbose "suppressed token reduction: sibling SKILL_detail.md preserves '$token' count"
|
|
595
613
|
continue
|
|
596
614
|
fi
|