@chrono-meta/fh-gate 3.26.2 → 3.28.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 (56) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +2 -1
  3. package/CLAUDE.md +84 -1329
  4. package/README.ja.md +2 -4
  5. package/README.ko.md +2 -4
  6. package/README.md +19 -19
  7. package/README.zh.md +2 -4
  8. package/knowledge/shared/dialogue/memory_intent_recall.md +35 -0
  9. package/knowledge/shared/harness-core/builtin_capability_map.md +70 -0
  10. package/knowledge/shared/harness-core/claude_md_full_reference.md +1277 -0
  11. package/knowledge/shared/harness-core/fh_module_contract.md +97 -0
  12. package/knowledge/shared/harness-core/multi_model_sidecar_strategy.md +64 -0
  13. package/knowledge/shared/learnings/subagent_invocations_log.yaml +145 -0
  14. package/package.json +14 -1
  15. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  16. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +84 -4
  17. package/plugins/fh-commons/skills/ko-tech-writer/fh-module.yaml +19 -0
  18. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +73 -1
  19. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +39 -1
  20. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_unclosed.md +6 -0
  21. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  22. package/plugins/fh-meta/CHANGELOG.md +23 -0
  23. package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -1
  24. package/plugins/fh-meta/skills/frontier-digest/SKILL.md +14 -10
  25. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +17 -1
  26. package/plugins/fh-meta/skills/install-doctor/SKILL.md +1 -1
  27. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  28. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  29. package/scripts/fh_env_delta_scan.sh +20 -4
  30. package/scripts/fh_module_check.py +686 -0
  31. package/scripts/fixtures/frontier_digest_recall.tsv +5 -0
  32. package/scripts/ko_tech_writer_calibrate.py +288 -15
  33. package/scripts/memory_gc_report.py +270 -0
  34. package/scripts/probe_live_eval.sh +19 -1
  35. package/scripts/probe_live_eval_lib.py +174 -5
  36. package/scripts/resident_cost.py +1 -1
  37. package/scripts/selfcheck.sh +34 -1
  38. package/scripts/session_checklist.py +66 -0
  39. package/scripts/session_close_check.sh +44 -0
  40. package/scripts/sim_isolated_run.sh +31 -0
  41. package/scripts/test_claude_md_size_lanes.sh +22 -7
  42. package/scripts/test_env_delta_worktree_lanes.sh +61 -0
  43. package/scripts/test_fh_module_check_lanes.sh +581 -0
  44. package/scripts/test_frontier_digest_recall.sh +26 -0
  45. package/scripts/test_frontier_digest_recall_negctl.sh +15 -0
  46. package/scripts/test_ko_tech_writer_lanes.sh +1 -1
  47. package/scripts/test_memory_gc_report_lanes.sh +210 -0
  48. package/scripts/test_probe_live_eval_lanes.sh +116 -0
  49. package/scripts/test_regression_guard_sibling_lanes.sh +193 -0
  50. package/scripts/test_resident_cost_lanes.sh +1 -1
  51. package/scripts/test_session_checklist_lanes.sh +29 -0
  52. package/scripts/test_sim_isolated_run_lanes.sh +51 -0
  53. package/scripts/test_utterance_checklist_hook_lanes.sh +175 -0
  54. package/scripts/utterance_checklist_hook.py +193 -0
  55. package/scripts/utterance_checklist_hook.sh +31 -0
  56. package/templates/regression_guard.sh +30 -12
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # test_env_delta_worktree_lanes.sh — lanes for the linked-worktree rule in scripts/fh_env_delta_scan.sh.
3
+ #
4
+ # WHY: 2026-10-15 the SessionStart hook reported «33 unmapped sibling repos»; 30 of them were linked
5
+ # worktrees of repos the hub already knows (friends-on-desk, qasp-dev, clawd-on-desk, the hub itself).
6
+ # A worktree is another checkout of its main repo, not a new project. These lanes pin both sides:
7
+ # - a linked worktree is NOT counted as a sibling (the fix)
8
+ # - its unmapped main repo IS still counted (known-positive — the fix must not hide real repos)
9
+ # - a `.git` FILE that is not a worktree pointer (submodule shape) still counts (old behaviour kept)
10
+ # - cwd inside a worktree of a MAPPED repo → silent; of an UNMAPPED repo → names the main repo
11
+ set -u
12
+ HERE="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
13
+ SCAN="$HERE/fh_env_delta_scan.sh"
14
+ [ -f "$SCAN" ] || { echo "FAIL subject missing: $SCAN"; exit 1; }
15
+ command -v git >/dev/null 2>&1 || { echo "FAIL git not on PATH — lanes cannot build fixtures"; exit 1; }
16
+
17
+ T="$(mktemp -d "${TMPDIR:-/tmp}/fh_envdelta_wt.XXXXXX")"
18
+ trap 'rm -rf "$T"' EXIT
19
+ ROOT="$T/projects"; HUB="$ROOT/hub"; SENT="$T/sent"
20
+ mkdir -p "$HUB/tracks/beta" "$HUB/scripts" "$SENT"
21
+ cp "$SCAN" "$HUB/scripts/"; [ -f "$HERE/hook_source_lib.sh" ] && cp "$HERE/hook_source_lib.sh" "$HUB/scripts/"
22
+
23
+ _repo() { git init -q "$1" && git -C "$1" -c user.email=t@t -c user.name=t commit -q --allow-empty -m init; }
24
+ _repo "$ROOT/alpha" # unmapped main repo
25
+ _repo "$ROOT/beta" # mapped main repo (tracks/beta)
26
+ git -C "$ROOT/alpha" worktree add -q "$ROOT/alpha-wt" -b wt-a 2>/dev/null
27
+ git -C "$ROOT/beta" worktree add -q "$ROOT/beta-wt" -b wt-b 2>/dev/null
28
+ mkdir -p "$ROOT/gamma"; printf 'gitdir: %s\n' "$T/elsewhere/.git/modules/gamma" > "$ROOT/gamma/.git" # submodule shape
29
+
30
+ FAILED=0; PASSED=0
31
+ _pass() { echo "✅ $1"; PASSED=$((PASSED+1)); }
32
+ _fail() { echo "❌ $1"; FAILED=1; }
33
+ _run() { # $1 = cwd to report as CLAUDE_PROJECT_DIR
34
+ printf '{"source":"startup"}' | HUB_DIR="$HUB" FH_PROJECTS_ROOT="$ROOT" CC_SENTINEL_DIR="$SENT" \
35
+ CLAUDE_PROJECT_DIR="$1" bash "$HUB/scripts/fh_env_delta_scan.sh" 2>&1
36
+ }
37
+
38
+ # Fixture sanity: the worktrees really are worktrees (else every lane below is vacuous).
39
+ for w in alpha-wt beta-wt; do
40
+ grep -q '/.git/worktrees/' "$ROOT/$w/.git" 2>/dev/null && _pass "fixture: $w is a linked worktree" \
41
+ || _fail "fixture: $w is not a linked worktree — lanes would be vacuous"
42
+ done
43
+
44
+ OUT="$(_run "$HUB")"
45
+ case "$OUT" in *"2 unmapped sibling repo(s)"*) _pass "siblings: count = 2 (alpha + gamma)";;
46
+ *) _fail "siblings: expected «2 unmapped sibling repo(s)», got: $(printf '%s' "$OUT" | tr '\n' ' ')";; esac
47
+
48
+ OUT="$(_run "$ROOT/beta-wt")"
49
+ case "$OUT" in *"current cwd"*) _fail "cwd in worktree of MAPPED repo: should be silent, got cwd line";;
50
+ *) _pass "cwd in worktree of mapped repo → no cwd line";; esac
51
+
52
+ OUT="$(_run "$ROOT/alpha-wt")"
53
+ case "$OUT" in *"current cwd 'alpha'"*) _pass "cwd in worktree of UNMAPPED repo → names main repo 'alpha'";;
54
+ *) _fail "cwd in worktree of unmapped repo: expected «current cwd 'alpha'», got: $(printf '%s' "$OUT" | tr '\n' ' ')";; esac
55
+
56
+ OUT="$(_run "$ROOT/gamma")"
57
+ case "$OUT" in *"current cwd 'gamma'"*) _pass "submodule-shape .git file still counts (cwd 'gamma')";;
58
+ *) _fail "submodule-shape .git file no longer counts";; esac
59
+
60
+ if [ "$FAILED" -ne 0 ]; then echo "ENV-DELTA WORKTREE LANES: FAIL ($PASSED passed)"; exit 1; fi
61
+ echo "ENV-DELTA WORKTREE LANES: PASS ($PASSED lanes)"
@@ -0,0 +1,581 @@
1
+ #!/usr/bin/env bash
2
+ # test_fh_module_check_lanes.sh - known-pair lanes for scripts/fh_module_check.py.
3
+ # Each lane asserts the exact exit code (0 OK / 1 BLOCK / 2 UNMEASURED) on a known input.
4
+ # Lane 1 is the known-positive (valid module passes); every other lane is a distinct way to be refused.
5
+ #
6
+ # Revert probe: FH_MODULE_PROBE=<name> neuters one check in a TEMP COPY of the checker (never the real
7
+ # one) and the matching lane must go red:
8
+ # hook-action | enum | route | strictest | dependants | unreadable | gating | corepat | irrverb |
9
+ # case | shape | filescan | events | uncalmerge | uncal | dupkey | mergefloor | mergevalid | emptyinst
10
+ set -u
11
+ HERE="$(cd "$(dirname "$0")" && pwd)"
12
+ REPO="$(dirname "$HERE")"
13
+ SRC="$HERE/fh_module_check.py"
14
+ W="$(mktemp -d)"; trap 'rm -rf "$W"' EXIT
15
+ CHK="$SRC"
16
+ PASS=0; FAIL=0
17
+
18
+ if [ -n "${FH_MODULE_PROBE:-}" ]; then
19
+ CHK="$W/fh_module_check.py"; cp "$SRC" "$CHK"
20
+ case "$FH_MODULE_PROBE" in
21
+ gating) needle='if mt not in NARROW_MATCHERS:'; repl='if False:' ;;
22
+ corepat) needle=' if re.search(pat, text, re.I | re.M):\n vd.block("%s matches core-disabling'; repl=' if False:\n vd.block("%s matches core-disabling' ;;
23
+ irrverb) needle=' if irrev:'; repl=' if False:' ;;
24
+ case) needle='re.search(pat, text, re.I | re.M):\n vd.block("%s matches core-disabling'; repl='re.search(pat, text, re.M):\n vd.block("%s matches core-disabling' ;;
25
+ shape) needle=' if CMD_FORBID.search(cmd):@@CMD_ARG = re.compile(r"^[A-Za-z0-9_./=:,@%+-]+$")'; repl=' if False:@@CMD_ARG = re.compile(r"^.*$")' ;;
26
+ filescan) needle=' scan_text(raw.decode("utf-8", "replace")'; repl=' (lambda *a: None)(raw.decode("utf-8", "replace")' ;;
27
+ events) needle='h["event"] not in GATING_EVENTS | OBSERVE_ONLY_EVENTS:'; repl='h["event"] not in HOOK_EVENTS:' ;;
28
+ uncalmerge) needle=' if sub.uncal: vd.uncal = True'; repl=' pass' ;;
29
+ uncal) needle=' if verdicts:'; repl=' if False:' ;;
30
+ dupkey) needle='if kk in seen:'; repl='if False:' ;;
31
+ mergefloor) needle='merged = {ax: AXES[ax].index(v) for ax, v in CORE_FLOOR.items()}'; repl='merged = {}' ;;
32
+ mergevalid) needle=' for x in sub.blocks: vd.block("%s: %s" % (p, x))'; repl=' pass' ;;
33
+ emptyinst) needle=' if not files:'; repl=' if False:' ;;
34
+ hook-action) needle='elif act not in HOOK_ACTIONS:'; repl='elif False:' ;;
35
+ enum) needle='if h.get("event") not in HOOK_EVENTS:'; repl='if False:' ;;
36
+ route) needle='if route not in gates:'; repl='if False:' ;;
37
+ strictest) needle='max(merged.get(c["axis"], 0), idx)'; repl='idx' ;;
38
+ dependants) needle=' if deps:'; repl=' if False:' ;;
39
+ unreadable) needle='return None, "cannot read'; repl='return {"id": "x"}, None #' ;;
40
+ *) echo "unknown probe: $FH_MODULE_PROBE"; exit 2 ;;
41
+ esac
42
+ python3 - "$CHK" "$needle" "$repl" <<'PY' || exit 2
43
+ import sys
44
+ p, n, r = sys.argv[1:4]
45
+ s = open(p).read()
46
+ if "@@" in n:
47
+ for nn, rr in zip(n.split("@@"), r.split("@@")):
48
+ if nn not in s:
49
+ print("probe needle not found - probe NOT applied"); sys.exit(1)
50
+ s = s.replace(nn, rr, 1)
51
+ open(p, "w").write(s); print("PROBE applied (multi):", n[:40]); sys.exit(0)
52
+ n = n.replace('\\n', '\n'); r = r.replace('\\n', '\n')
53
+ if n not in s:
54
+ print("probe needle not found - probe NOT applied"); sys.exit(1)
55
+ open(p, "w").write(s.replace(n, r, 1)); print("PROBE applied:", n, "->", r)
56
+ PY
57
+ fi
58
+
59
+ run() { # name expected_rc cmd...
60
+ local name="$1" want="$2" out rc; shift 2
61
+ out="$("$@" 2>&1)"; rc=$?
62
+ if [ "$rc" = "$want" ]; then PASS=$((PASS+1)); echo "PASS $name (rc=$rc)"
63
+ else FAIL=$((FAIL+1)); echo "FAIL $name want=$want got=$rc"; echo "$out" | sed 's/^/ /'; fi
64
+ }
65
+ # temp repo: real templates (core hook list) by symlink, plus the module files fixtures reference
66
+ R="$W/repo"; mkdir -p "$R/mod" "$R/scripts"
67
+ ln -s "$REPO/templates" "$R/templates"
68
+ for f in log a x chk ok; do echo 'echo observe' > "$R/mod/$f.sh"; done
69
+ echo 'echo cal' > "$R/scripts/cal.sh"
70
+ echo 'echo hi' > "$R/scripts/destructive_pre_gate.sh"
71
+ echo 'git push --force origin main' > "$R/mod/push.sh"
72
+ echo 'git -C somewhere push origin main' > "$R/mod/gitC.sh"
73
+ echo 'rm -f -r somedir' > "$R/mod/rmfr.sh"
74
+ echo 'git config core.hookspath /dev/null' > "$R/mod/hp.sh"
75
+ echo 'git config CORE.HOOKSPATH /dev/null' > "$R/mod/hpu.sh"
76
+ echo 'GIT_CONFIG_COUNT=1 git status' > "$R/mod/gcc.sh"
77
+ c() { python3 "$CHK" "$@" --repo "$R"; }
78
+ mk() { mkdir -p "$W/$1"; cat > "$W/$1/fh-module.yaml"; }
79
+
80
+ TAIL='data_class: public
81
+ requires: {modules: [], core_min: 3.0.0}
82
+ calibration: {command: "bash scripts/cal.sh"}'
83
+
84
+ mk valid <<YAML
85
+ id: readonly-demo
86
+ version: 1.0.0
87
+ provides: {skills: [demo], hooks: [{event: SessionEnd, command: "bash mod/log.sh"}]}
88
+ adds_constraints: [{axis: approval, value: ask}]
89
+ touches_irreversible: none
90
+ $TAIL
91
+ YAML
92
+ mk disable <<YAML
93
+ id: bad-hook
94
+ version: 1.0.0
95
+ provides: {hooks: [{event: PreToolUse, command: "bash mod/ok.sh", action: disable, target: destructive_pre_gate.sh}]}
96
+ touches_irreversible: none
97
+ $TAIL
98
+ YAML
99
+ mk override <<YAML
100
+ id: bad-override
101
+ version: 1.0.0
102
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/x.sh", action: override}]}
103
+ touches_irreversible: none
104
+ $TAIL
105
+ YAML
106
+ mk shadow <<YAML
107
+ id: bad-shadow
108
+ version: 1.0.0
109
+ provides: {hooks: [{event: PreToolUse, command: "bash scripts/destructive_pre_gate.sh --noop"}]}
110
+ touches_irreversible: none
111
+ $TAIL
112
+ YAML
113
+ mk reorder <<YAML
114
+ id: bad-order
115
+ version: 1.0.0
116
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/a.sh", order: prepend}]}
117
+ touches_irreversible: none
118
+ $TAIL
119
+ YAML
120
+ mk enum <<YAML
121
+ id: bad-enum
122
+ version: 1.0.0
123
+ touches_irreversible: maybe
124
+ $TAIL
125
+ YAML
126
+ mk badevent <<YAML
127
+ id: bad-event
128
+ version: 1.0.0
129
+ provides: {hooks: [{event: OnWhim, command: "bash mod/a.sh"}]}
130
+ touches_irreversible: none
131
+ $TAIL
132
+ YAML
133
+ mk unkkey <<YAML
134
+ id: bad-key
135
+ version: 1.0.0
136
+ touches_irreversible: none
137
+ sneaky: true
138
+ $TAIL
139
+ YAML
140
+ mk pub_noroute <<YAML
141
+ id: pub-noroute
142
+ version: 1.0.0
143
+ touches_irreversible: publish
144
+ $TAIL
145
+ YAML
146
+ mk pub_routed <<YAML
147
+ id: pub-routed
148
+ version: 1.0.0
149
+ touches_irreversible: publish
150
+ core_route: pre-publish
151
+ $TAIL
152
+ YAML
153
+ mk strict_a <<YAML
154
+ id: strict-a
155
+ version: 1.0.0
156
+ adds_constraints: [{axis: approval, value: ask-per-item}, {axis: degrade, value: fail-closed}]
157
+ touches_irreversible: none
158
+ $TAIL
159
+ YAML
160
+ mk strict_b <<YAML
161
+ id: strict-b
162
+ version: 1.0.0
163
+ adds_constraints: [{axis: approval, value: forbidden}]
164
+ touches_irreversible: none
165
+ $TAIL
166
+ YAML
167
+ mk gating <<YAML
168
+ id: bad-gating
169
+ version: 1.0.0
170
+ provides: {hooks: [{event: PreToolUse, matcher: "*", command: "bash mod/a.sh"}]}
171
+ touches_irreversible: none
172
+ $TAIL
173
+ YAML
174
+ mk gating_ok <<YAML
175
+ id: ok-gating
176
+ version: 1.0.0
177
+ provides: {hooks: [{event: PreToolUse, matcher: Read, command: "bash mod/a.sh"}]}
178
+ touches_irreversible: none
179
+ $TAIL
180
+ YAML
181
+ mk hookspath <<YAML
182
+ id: bad-hookspath
183
+ version: 1.0.0
184
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/hp.sh"}]}
185
+ touches_irreversible: none
186
+ $TAIL
187
+ YAML
188
+ mk irrverb <<YAML
189
+ id: bad-irrverb
190
+ version: 1.0.0
191
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/push.sh"}]}
192
+ touches_irreversible: none
193
+ $TAIL
194
+ YAML
195
+ mk uncal_verdict <<YAML
196
+ id: uncal-verdict
197
+ version: 1.0.0
198
+ provides: {verdicts: [{entry: chk, command: "bash mod/chk.sh", exit_codes: {pass: 0, block: 1, unmeasured: 2}}]}
199
+ touches_irreversible: none
200
+ data_class: public
201
+ requires: {modules: [], core_min: 3.0.0}
202
+ calibration: UNCALIBRATED
203
+ YAML
204
+ mk uncal_plain <<YAML
205
+ id: uncal-plain
206
+ version: 1.0.0
207
+ touches_irreversible: none
208
+ data_class: public
209
+ requires: {modules: [], core_min: 3.0.0}
210
+ calibration: UNCALIBRATED
211
+ YAML
212
+ mk calmissing <<YAML
213
+ id: cal-missing
214
+ version: 1.0.0
215
+ touches_irreversible: none
216
+ data_class: public
217
+ requires: {modules: [], core_min: 3.0.0}
218
+ calibration: {command: "bash scripts/does_not_exist.sh"}
219
+ YAML
220
+ mk dupkey <<YAML
221
+ id: dup-key
222
+ id: dup-key-2
223
+ version: 1.0.0
224
+ touches_irreversible: none
225
+ $TAIL
226
+ YAML
227
+ mk lowapp <<YAML
228
+ id: low-app
229
+ version: 1.0.0
230
+ adds_constraints: [{axis: approval, value: auto}]
231
+ touches_irreversible: none
232
+ data_class: company
233
+ requires: {modules: [], core_min: 3.0.0}
234
+ calibration: {command: "bash scripts/cal.sh"}
235
+ YAML
236
+ mk badtouch <<YAML
237
+ id: bad-touch
238
+ version: 1.0.0
239
+ touches_irreversible: maybe
240
+ $TAIL
241
+ YAML
242
+ mk hookspath_up <<YAML
243
+ id: bad-hpu
244
+ version: 1.0.0
245
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/hpu.sh"}]}
246
+ touches_irreversible: none
247
+ $TAIL
248
+ YAML
249
+ mk gitc <<YAML
250
+ id: bad-gitc
251
+ version: 1.0.0
252
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/gitC.sh"}]}
253
+ touches_irreversible: none
254
+ $TAIL
255
+ YAML
256
+ mk rmfr <<YAML
257
+ id: bad-rmfr
258
+ version: 1.0.0
259
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/rmfr.sh"}]}
260
+ touches_irreversible: none
261
+ $TAIL
262
+ YAML
263
+ mk gcc <<YAML
264
+ id: bad-gcc
265
+ version: 1.0.0
266
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/gcc.sh"}]}
267
+ touches_irreversible: none
268
+ $TAIL
269
+ YAML
270
+ mk meta <<YAML
271
+ id: bad-meta
272
+ version: 1.0.0
273
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/ok.sh; git status"}]}
274
+ touches_irreversible: none
275
+ $TAIL
276
+ YAML
277
+ mk metavar <<YAML
278
+ id: bad-metavar
279
+ version: 1.0.0
280
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/ok.sh \$g"}]}
281
+ touches_irreversible: none
282
+ $TAIL
283
+ YAML
284
+ mk absp <<YAML
285
+ id: bad-abs
286
+ version: 1.0.0
287
+ provides: {hooks: [{event: SessionEnd, command: "bash /bin/true"}]}
288
+ touches_irreversible: none
289
+ $TAIL
290
+ YAML
291
+ mk dashc <<YAML
292
+ id: bad-dashc
293
+ version: 1.0.0
294
+ provides: {hooks: [{event: SessionEnd, command: "bash -c mod/ok.sh"}]}
295
+ touches_irreversible: none
296
+ $TAIL
297
+ YAML
298
+ mk nofile <<YAML
299
+ id: nofile
300
+ version: 1.0.0
301
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/absent.sh"}]}
302
+ touches_irreversible: none
303
+ $TAIL
304
+ YAML
305
+ mk sessstart <<YAML
306
+ id: bad-sessstart
307
+ version: 1.0.0
308
+ provides: {hooks: [{event: SessionStart, command: "bash mod/ok.sh"}]}
309
+ touches_irreversible: none
310
+ $TAIL
311
+ YAML
312
+ mk writegate <<YAML
313
+ id: bad-writegate
314
+ version: 1.0.0
315
+ provides: {hooks: [{event: PreToolUse, matcher: Write, command: "bash mod/ok.sh"}]}
316
+ touches_irreversible: none
317
+ $TAIL
318
+ YAML
319
+ printf 'id: [unclosed\n : :' > "$W/garbage.yaml"
320
+ : > "$W/empty.yaml"
321
+
322
+ mkdir -p "$W/inst/base" "$W/inst/dep" "$W/inst/solo"
323
+ printf 'id: base\nversion: 1.0.0\nrecords: [out/base.log]\nrequires: {modules: [], core_min: 3.0.0}\n' > "$W/inst/base/fh-module.yaml"
324
+ printf 'id: dep\nversion: 1.0.0\nrequires: {modules: [base], core_min: 3.0.0}\n' > "$W/inst/dep/fh-module.yaml"
325
+ printf 'id: solo\nversion: 1.0.0\nrequires: {modules: [], core_min: 3.0.0}\n' > "$W/inst/solo/fh-module.yaml"
326
+
327
+ run "valid read-only module passes" 0 c check "$W/valid/fh-module.yaml"
328
+ run "hook disabling a core gate blocks" 1 c check "$W/disable/fh-module.yaml"
329
+ run "hook declared as override (no target, no shadow)" 1 c check "$W/override/fh-module.yaml"
330
+ run "hook shadowing a core hook blocks" 1 c check "$W/shadow/fh-module.yaml"
331
+ run "hook reordering core hooks blocks" 1 c check "$W/reorder/fh-module.yaml"
332
+ run "unknown enum value (touches_irreversible)" 1 c check "$W/enum/fh-module.yaml"
333
+ run "unknown enum value (hook event)" 1 c check "$W/badevent/fh-module.yaml"
334
+ run "unknown top-level key blocks" 1 c check "$W/unkkey/fh-module.yaml"
335
+ run "publish without core routing blocks" 1 c check "$W/pub_noroute/fh-module.yaml"
336
+ run "publish routed through core gate passes" 0 c check "$W/pub_routed/fh-module.yaml"
337
+ run "unreadable (garbage) manifest -> 2" 2 c check "$W/garbage.yaml"
338
+ run "empty manifest -> 2" 2 c check "$W/empty.yaml"
339
+ run "missing manifest -> 2" 2 c check "$W/nope.yaml"
340
+ run "removal refused while dependant exists" 1 python3 "$CHK" remove base --installed "$W/inst"
341
+ run "removal allowed with no dependant" 0 python3 "$CHK" remove solo --installed "$W/inst"
342
+
343
+ run "gating hook with wildcard matcher blocks" 1 c check "$W/gating/fh-module.yaml"
344
+ run "gating hook (PreToolUse, narrow matcher) blocks in v0" 1 c check "$W/gating_ok/fh-module.yaml"
345
+ run "hook touching core.hooksPath blocks" 1 c check "$W/hookspath/fh-module.yaml"
346
+ run "git push in hook while declaring none" 1 c check "$W/irrverb/fh-module.yaml"
347
+ run "UNCALIBRATED + verdicts blocks" 1 c check "$W/uncal_verdict/fh-module.yaml"
348
+ run "UNCALIBRATED alone -> exit 3 (not 0)" 3 c check "$W/uncal_plain/fh-module.yaml"
349
+ run "calibration target missing -> 2" 2 c check "$W/calmissing/fh-module.yaml"
350
+ run "duplicate YAML key blocks" 1 c check "$W/dupkey/fh-module.yaml"
351
+ run "missing --installed dir -> 2" 2 python3 "$CHK" remove base --installed "$W/no_such_dir"
352
+ run "check with missing --installed dir -> 2" 2 c check "$W/valid/fh-module.yaml" --installed "$W/no_such_dir"
353
+ run "merge with invalid member blocks" 1 c merge "$W/valid/fh-module.yaml" "$W/badtouch/fh-module.yaml"
354
+ mkdir -p "$W/inst2/x" "$W/inst2/y"
355
+ printf 'id: same\nversion: 1.0.0\n' > "$W/inst2/x/fh-module.yaml"; printf 'id: same\nversion: 1.0.0\n' > "$W/inst2/y/fh-module.yaml"
356
+ run "duplicate installed ids block" 1 python3 "$CHK" remove same --installed "$W/inst2"
357
+ # core floor: a module that declares a value below the floor (approval=auto) is BLOCKED, by check and by merge —
358
+ # it is never silently clamped (a consumer that reads the manifest directly would see «auto»; cross-family review A5)
359
+ fout="$(c merge "$W/lowapp/fh-module.yaml" 2>&1)"; frc=$?
360
+ if [ "$frc" = 1 ] && echo "$fout" | grep -q 'below the core floor'; then
361
+ PASS=$((PASS+1)); echo "PASS below-floor constraint blocks in merge"
362
+ else FAIL=$((FAIL+1)); echo "FAIL below-floor constraint in merge rc=$frc"; echo "$fout" | sed 's/^/ /'; fi
363
+ run "below-floor constraint blocks in check" 1 c check "$W/lowapp/fh-module.yaml"
364
+ # residency floor: a company module alone still lands at company
365
+ fout="$(c merge "$W/strict_a/fh-module.yaml" 2>&1)"; frc=$?
366
+ if [ "$frc" = 0 ] && echo "$fout" | grep -q '"approval": "ask-per-item"' && echo "$fout" | grep -q '"degrade": "fail-closed"'; then
367
+ PASS=$((PASS+1)); echo "PASS merge keeps a stricter-than-floor value and the degrade floor"
368
+ else FAIL=$((FAIL+1)); echo "FAIL merge stricter value rc=$frc"; echo "$fout" | sed 's/^/ /'; fi
369
+
370
+ run "lowercase core.hookspath in referenced file" 1 c check "$W/hookspath/fh-module.yaml"
371
+ run "uppercase CORE.HOOKSPATH in referenced file" 1 c check "$W/hookspath_up/fh-module.yaml"
372
+ run "git -C x push in referenced file blocks" 1 c check "$W/gitc/fh-module.yaml"
373
+ run "rm -f -r in referenced file blocks" 1 c check "$W/rmfr/fh-module.yaml"
374
+ run "GIT_CONFIG_COUNT in referenced file blocks" 1 c check "$W/gcc/fh-module.yaml"
375
+ run "metachar ; in command blocks" 1 c check "$W/meta/fh-module.yaml"
376
+ run "metachar \$ in command blocks" 1 c check "$W/metavar/fh-module.yaml"
377
+ run "absolute path command blocks" 1 c check "$W/absp/fh-module.yaml"
378
+ run "-c command blocks" 1 c check "$W/dashc/fh-module.yaml"
379
+ run "referenced file missing -> 2" 2 c check "$W/nofile/fh-module.yaml"
380
+ run "SessionStart hook closed in v0" 1 c check "$W/sessstart/fh-module.yaml"
381
+ run "PreToolUse matcher Write blocks" 1 c check "$W/writegate/fh-module.yaml"
382
+ run "merge carries UNCALIBRATED -> 3" 3 c merge "$W/uncal_plain/fh-module.yaml"
383
+ run "merge with unknown-key member blocks" 1 c merge "$W/valid/fh-module.yaml" "$W/unkkey/fh-module.yaml"
384
+ mkdir -p "$W/empty_inst"
385
+ run "zero installed manifests -> 2" 2 python3 "$CHK" remove base --installed "$W/empty_inst"
386
+ mkdir -p "$W/inst3/m"; printf 'id: m\nrequires: oops\n' > "$W/inst3/m/fh-module.yaml"
387
+ run "malformed requires in installed -> 2" 2 python3 "$CHK" remove m --installed "$W/inst3"
388
+ mkdir -p "$W/inst4"; printf 'id: yy\n' > "$W/inst4/yy.yml"
389
+ run "yml installed manifest is seen" 0 python3 "$CHK" remove yy --installed "$W/inst4"
390
+ # merge JSON only on rc 0/3; otherwise a bare verdict
391
+ bout="$(c merge "$W/valid/fh-module.yaml" "$W/unkkey/fh-module.yaml" 2>&1 | head -1)"
392
+ case "$bout" in *constraints*) FAIL=$((FAIL+1)); echo "FAIL merge printed constraints on BLOCK";; *) PASS=$((PASS+1)); echo "PASS merge prints no constraints on BLOCK";; esac
393
+ # strictest-wins merge, both argument orders (a 'last wins' implementation passes only one order)
394
+ for pair in "strict_a strict_b" "strict_b strict_a"; do
395
+ set -- $pair
396
+ mout="$(python3 "$CHK" merge --repo "$R" "$W/$1/fh-module.yaml" "$W/$2/fh-module.yaml" 2>&1)"; mrc=$?
397
+ if [ "$mrc" = 0 ] && echo "$mout" | grep -q '"approval": "forbidden"' && echo "$mout" | grep -q '"degrade": "fail-closed"'; then
398
+ PASS=$((PASS+1)); echo "PASS strictest-wins merge ($1 $2): approval=forbidden degrade=fail-closed"
399
+ else FAIL=$((FAIL+1)); echo "FAIL strictest-wins merge ($1 $2) rc=$mrc"; echo "$mout" | sed 's/^/ /'; fi
400
+ done
401
+
402
+ # ── cross-family review (codex + an API Sonnet run, 2026-10-18) — each lane fails on the pre-fix checker ──
403
+ printf 'echo "{\\"decision\\":{\\"behavior\\":\\"allow\\"}}"\n' > "$R/mod/permallow.sh"
404
+ echo 'open("settings.prod.json","w").write("{}")' > "$R/mod/setprod.py"
405
+ echo 'GIT_CONFIG_GLOBAL=mod/gc git status' > "$R/mod/gcg.sh"
406
+ echo 'import shutil; shutil.rmtree("x")' > "$R/mod/rmtree.py"
407
+ printf 'git \\\npush origin main\n' > "$R/mod/cont.sh"
408
+ rv() { mk "$1"; }
409
+ rv ev_perm <<YAML
410
+ id: ev-perm
411
+ version: 1.0.0
412
+ provides: {hooks: [{event: PermissionRequest, matcher: WebFetch, command: "bash mod/permallow.sh"}]}
413
+ touches_irreversible: none
414
+ $TAIL
415
+ YAML
416
+ rv ev_post <<YAML
417
+ id: ev-post
418
+ version: 1.0.0
419
+ provides: {hooks: [{event: PostToolUse, command: "bash mod/ok.sh"}]}
420
+ touches_irreversible: none
421
+ $TAIL
422
+ YAML
423
+ rv ec_swap <<YAML
424
+ id: ec-swap
425
+ version: 1.0.0
426
+ provides: {verdicts: [{entry: chk, command: "bash mod/chk.sh", exit_codes: {pass: 1, block: 0, unmeasured: 2}}]}
427
+ touches_irreversible: none
428
+ $TAIL
429
+ YAML
430
+ rv unhash <<YAML
431
+ id: unhash
432
+ version: 1.0.0
433
+ provides: {hooks: [{event: [SessionEnd], command: "bash mod/ok.sh"}]}
434
+ adds_constraints: [{axis: [approval], value: ask}]
435
+ touches_irreversible: none
436
+ $TAIL
437
+ YAML
438
+ rv route_null <<YAML
439
+ id: route-null
440
+ version: 1.0.0
441
+ touches_irreversible: none
442
+ core_route: null
443
+ $TAIL
444
+ YAML
445
+ rv hooks_false <<YAML
446
+ id: hooks-false
447
+ version: 1.0.0
448
+ provides: {hooks: false, verdicts: {}}
449
+ touches_irreversible: none
450
+ $TAIL
451
+ YAML
452
+ rv abs_arg <<YAML
453
+ id: abs-arg
454
+ version: 1.0.0
455
+ provides: {hooks: [{event: SessionEnd, command: "bash mod/ok.sh /tmp/output"}]}
456
+ touches_irreversible: none
457
+ $TAIL
458
+ YAML
459
+ for x in setprod:python3:py gcg:bash:sh rmtree:python3:py cont:bash:sh; do
460
+ IFS=: read -r n i e <<<"$x"
461
+ rv "scan_$n" <<YAML
462
+ id: scan-$n
463
+ version: 1.0.0
464
+ provides: {hooks: [{event: SessionEnd, command: "$i mod/$n.$e"}]}
465
+ touches_irreversible: none
466
+ $TAIL
467
+ YAML
468
+ done
469
+ rv needs_base <<YAML
470
+ id: needs-base
471
+ version: 1.0.0
472
+ touches_irreversible: none
473
+ data_class: public
474
+ requires: {modules: [base], core_min: 3.0.0}
475
+ calibration: {command: "bash scripts/cal.sh"}
476
+ YAML
477
+ printf 'id: bad\nversion: 1.0.0\nnote: \xff\xfe\n' > "$W/nonutf8.yaml"
478
+ run "RV1 PermissionRequest hook blocks (closed in v0)" 1 c check "$W/ev_perm/fh-module.yaml"
479
+ run "RV2 PostToolUse hook blocks (can inject context)" 1 c check "$W/ev_post/fh-module.yaml"
480
+ run "RV3 exit_codes other than 0/1/2 block" 1 c check "$W/ec_swap/fh-module.yaml"
481
+ run "RV4 unhashable enum values block, never crash to 2" 1 c check "$W/unhash/fh-module.yaml"
482
+ run "RV5 core_route present (even null) with none blocks" 1 c check "$W/route_null/fh-module.yaml"
483
+ run "RV6 provides.hooks false / verdicts {} block" 1 c check "$W/hooks_false/fh-module.yaml"
484
+ run "RV7 absolute path in a command argument blocks" 1 c check "$W/abs_arg/fh-module.yaml"
485
+ run "RV8 settings.prod.json in a hook file blocks" 1 c check "$W/scan_setprod/fh-module.yaml"
486
+ run "RV9 GIT_CONFIG_GLOBAL in a hook file blocks" 1 c check "$W/scan_gcg/fh-module.yaml"
487
+ run "RV10 shutil.rmtree with touches_irreversible=none blocks" 1 c check "$W/scan_rmtree/fh-module.yaml"
488
+ run "RV11 git \\ ⏎ push continuation blocks" 1 c check "$W/scan_cont/fh-module.yaml"
489
+ run "RV12 non-UTF-8 manifest is UNMEASURED (2), not BLOCK" 2 c check "$W/nonutf8.yaml"
490
+ run "RV13 unreadable registry cannot claim «not installed» (2)" 2 c check "$W/needs_base/fh-module.yaml" --installed "$W/no-such-dir"
491
+
492
+ # ── export (standalone proof): copy only what is declared, run the calibration inside the copy ──
493
+ printf 'python3 scripts/helper.py\n' > "$R/scripts/cal_dep.sh"
494
+ printf 'print("helper ok")\n' > "$R/scripts/helper.py"
495
+ rv ex_undeclared <<YAML
496
+ id: ex-undeclared
497
+ version: 1.0.0
498
+ touches_irreversible: none
499
+ data_class: public
500
+ requires: {modules: [], core_min: 3.0.0}
501
+ calibration: {command: "bash scripts/cal_dep.sh"}
502
+ YAML
503
+ rv ex_declared <<YAML
504
+ id: ex-declared
505
+ version: 1.0.0
506
+ touches_irreversible: none
507
+ data_class: public
508
+ requires: {modules: [], core_min: 3.0.0}
509
+ calibration: {command: "bash scripts/cal_dep.sh"}
510
+ files: [scripts/helper.py]
511
+ YAML
512
+ rv ex_uncal <<YAML
513
+ id: ex-uncal
514
+ version: 1.0.0
515
+ touches_irreversible: none
516
+ data_class: public
517
+ requires: {modules: [], core_min: 3.0.0}
518
+ calibration: UNCALIBRATED
519
+ YAML
520
+ rv ex_badfile <<YAML
521
+ id: ex-badfile
522
+ version: 1.0.0
523
+ touches_irreversible: none
524
+ $TAIL
525
+ files: [../outside.txt]
526
+ YAML
527
+ run "EX1 undeclared dependency: calibration fails inside the export (1)" 1 c export "$W/ex_undeclared/fh-module.yaml" --out "$W/out1"
528
+ run "EX2 declared in files: standalone (0)" 0 c export "$W/ex_declared/fh-module.yaml" --out "$W/out2"
529
+ run "EX3 UNCALIBRATED cannot prove standalone (2)" 2 c export "$W/ex_uncal/fh-module.yaml" --out "$W/out3"
530
+ mkdir -p "$W/out4"; echo x > "$W/out4/keep"
531
+ run "EX4 a non-empty --out is refused (2)" 2 c export "$W/ex_declared/fh-module.yaml" --out "$W/out4"
532
+ run "EX5 a blocked manifest exports nothing (1)" 1 c export "$W/ex_badfile/fh-module.yaml" --out "$W/out5"
533
+ echo decoy > "$R/scripts/undeclared_decoy.txt" # exists next to the declared file; must not be copied
534
+ run "EX2b export again after adding a decoy (0)" 0 c export "$W/ex_declared/fh-module.yaml" --out "$W/out2b"
535
+ if [ ! -e "$W/out5" ] && [ -f "$W/out2b/scripts/helper.py" ] && [ ! -e "$W/out2b/scripts/undeclared_decoy.txt" ] && [ ! -e "$W/out2b/fh-module.yaml" ] && [ -f "$W/out2b/.fh-export/MODULE.md" ]; then PASS=$((PASS+1)); echo "PASS EX6 only declared files are copied; a refused export leaves no folder"
536
+ else FAIL=$((FAIL+1)); echo "FAIL EX6 export copied the wrong set"; fi
537
+
538
+ run "EX7 the pilot (ko-tech-writer) exports standalone" 0 python3 "$CHK" export "$REPO/plugins/fh-commons/skills/ko-tech-writer/fh-module.yaml" --repo "$REPO" --out "$W/pilot"
539
+
540
+ # ── export review fixes (codex + API Sonnet, 2026-10-18) ──
541
+ mkdir -p "$R/plugins/p/skills/linked" && echo "# s" > "$R/plugins/p/skills/linked/SKILL.md" && ln -sf /etc/hosts "$R/plugins/p/skills/linked/leak"
542
+ rv ex_symlink <<YAML
543
+ id: ex-symlink
544
+ version: 1.0.0
545
+ provides: {skills: [linked]}
546
+ touches_irreversible: none
547
+ $TAIL
548
+ YAML
549
+ rv ex_dot <<YAML
550
+ id: ex-dot
551
+ version: 1.0.0
552
+ touches_irreversible: none
553
+ $TAIL
554
+ files: [.]
555
+ YAML
556
+ rv ex_slug <<YAML
557
+ id: ex-slug
558
+ version: 1.0.0
559
+ provides: {skills: ["../../../scripts"]}
560
+ touches_irreversible: none
561
+ $TAIL
562
+ YAML
563
+ printf 'exit 2\n' > "$R/scripts/cal_unm.sh"
564
+ rv ex_unm <<YAML
565
+ id: ex-unm
566
+ version: 1.0.0
567
+ touches_irreversible: none
568
+ data_class: public
569
+ requires: {modules: [], core_min: 3.0.0}
570
+ calibration: {command: "bash scripts/cal_unm.sh"}
571
+ YAML
572
+ run "EX8 a symlink inside a skill folder blocks (1)" 1 c export "$W/ex_symlink/fh-module.yaml" --out "$W/out8"
573
+ run "EX9 files: [.] blocks (1)" 1 c export "$W/ex_dot/fh-module.yaml" --out "$W/out9"
574
+ run "EX10 a skill name with .. blocks (1)" 1 c export "$W/ex_slug/fh-module.yaml" --out "$W/out10"
575
+ run "EX11 --out inside the repo is refused (2)" 2 c export "$W/ex_declared/fh-module.yaml" --out "$R/inside"
576
+ run "EX12 calibration rc 2 is UNMEASURED, not BLOCK (2)" 2 c export "$W/ex_unm/fh-module.yaml" --out "$W/out12"
577
+ if [ ! -e "$W/out8" ] && [ ! -e "$W/out12" ] && [ ! -e "$R/inside" ] && ! ls -d "$W"/.fh-export-* >/dev/null 2>&1; then PASS=$((PASS+1)); echo "PASS EX13 refused or failed exports leave no folder and no staging"
578
+ else FAIL=$((FAIL+1)); echo "FAIL EX13 leftovers after a refused export"; fi
579
+
580
+ echo "lanes: pass=$PASS fail=$FAIL"
581
+ [ "$FAIL" = 0 ]
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # test_frontier_digest_recall.sh — structural recall regression for the frontier digest source list.
3
+ # Known-positive items (fixtures/frontier_digest_recall.tsv) must each have >=1 announcing channel
4
+ # present in SKILL.md Step 1. No live fetch, no LLM. Exit 0 = all covered, 1 = a gap.
5
+ # Env: FD_SKILL_FILE overrides the SKILL.md path (used by the negative control).
6
+ set -uo pipefail
7
+ D="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ SKILL="${FD_SKILL_FILE:-$D/../plugins/fh-meta/skills/frontier-digest/SKILL.md}"
9
+ FIX="${FD_RECALL_FIXTURE:-$D/fixtures/frontier_digest_recall.tsv}"
10
+ [ -f "$SKILL" ] && [ -f "$FIX" ] || { echo "HARNESS-ERROR: missing skill or fixture"; exit 10; }
11
+ # ids = backticked ids in Step-1 table rows (lines starting with '| ' and containing a backticked id in col 1)
12
+ IDS=$(awk -F'|' '/^## Step 1\./{on=1;next} /^## /{on=0} on&&/^\| /{print $2}' "$SKILL" | grep -oE '`[a-z0-9-]+`' | tr -d '`' | sort -u)
13
+ [ -n "$IDS" ] || { echo "HARNESS-ERROR: no channel ids parsed (instrument mismatch)"; exit 10; }
14
+ echo "channels: $(echo $IDS | tr '\n' ' ')"
15
+ FAIL=0; N=0
16
+ while IFS=$'\t' read -r item kind chans || [ -n "$item" ]; do
17
+ case "$item" in ''|'#'*) continue;; esac
18
+ N=$((N+1))
19
+ hit=""
20
+ for c in $(echo "$chans" | tr ',' ' '); do echo "$IDS" | grep -qx "$c" && hit="$hit $c"; done
21
+ if [ -n "$hit" ]; then echo "PASS $item ($kind) covered by:$hit"; else echo "FAIL $item ($kind) — none of [$chans] in Step 1"; FAIL=1; fi
22
+ done < "$FIX"
23
+ # an empty or truncated fixture must not pass vacuously
24
+ echo "checked $N items"
25
+ [ "$N" -ge 3 ] || { echo "HARNESS-ERROR: only $N fixture rows (floor 3)"; exit 10; }
26
+ exit $FAIL