@chrono-meta/fh-gate 3.10.0 → 3.12.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 (34) hide show
  1. package/.claude/regression/probes_live.yaml +13 -5
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/AGENTS.md +1 -1
  4. package/CHEATSHEET.md +1 -1
  5. package/CLAUDE.md +8 -4
  6. package/bin/fh-codex-doctor.js +223 -25
  7. package/docs/codex-compat.md +1 -1
  8. package/knowledge/shared/harness-core/claude_md_gate_details.md +8 -4
  9. package/knowledge/shared/harness-core/governance_engineering_definition.md +403 -7
  10. package/knowledge/shared/harness-core/harness_terminal_correlation_and_recommendations.md +22 -6
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +107 -0
  12. package/package.json +11 -2
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-commons/README.md +1 -1
  15. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +269 -26
  16. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  17. package/plugins/fh-meta/CHANGELOG.md +44 -0
  18. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  19. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  20. package/scripts/citation_key_check.py +357 -0
  21. package/scripts/claim_propagation_scan.py +499 -0
  22. package/scripts/ko_tech_writer_calibrate.py +13 -4
  23. package/scripts/numeric_token_diff.py +389 -0
  24. package/scripts/probe_live_eval_lib.py +19 -1
  25. package/scripts/section_ref_check.py +591 -0
  26. package/scripts/selfcheck.sh +72 -0
  27. package/scripts/session_checklist.py +704 -0
  28. package/scripts/test_claim_propagation_lanes.sh +573 -0
  29. package/scripts/test_codex_doctor_root_lanes.sh +384 -0
  30. package/scripts/test_ko_tech_writer_lanes.sh +5 -1
  31. package/scripts/test_paper_integrity_lanes.sh +1473 -0
  32. package/scripts/test_probe_live_eval_lanes.sh +25 -4
  33. package/scripts/test_session_checklist_lanes.sh +746 -0
  34. package/templates/predelete_check.sh +28 -4
@@ -0,0 +1,384 @@
1
+ #!/usr/bin/env bash
2
+ # test_codex_doctor_root_lanes.sh — regression lanes for bin/fh-codex-doctor.js's ROOT PREDICATE.
3
+ #
4
+ # WHY THIS FILE EXISTS (measured 2026-09-17): the doctor required `package.json` at the root — in
5
+ # `looksLikeFHRoot()` and again as a hard `process.exit(11)` gate in `main()`. Those were the only
6
+ # two references to it in the whole file; nothing downstream ever OPENED it. So the gate asserted a
7
+ # property no consumer of the report consumes, and it made a shipped npm binary structurally
8
+ # unusable for every non-npm consumer harness. Live repro before the fix:
9
+ # node bin/fh-codex-doctor.js --root <a consumer harness checkout> --strict
10
+ # → rc=11 "ERROR: root does not look like a package/repo root"
11
+ # while that consumer carries every surface the tool actually audits (AGENTS.md with 3 tier rows,
12
+ # plugins/ with 41 SKILL.md, 8 agent .md, .claude/registry/agent_cards.json — counts hand-verified
13
+ # with `find`, not inferred). After the fix that same command returns rc=0 with 41 skills / 8 agents.
14
+ #
15
+ # 🟥 THE LANE'S JOB IS BOTH DIRECTIONS. Loosening a fail-closed gate is only correct if the
16
+ # loosening cannot manufacture a confident empty report — "not found is not zero" is this repo's
17
+ # named failure family. So every POSITIVE arm below is paired with a NEGATIVE arm on the same axis,
18
+ # and two of the negatives (L4, L6) are arms that the UNFIXED code passed with rc=0.
19
+ #
20
+ # FAIL-BEFORE: the subject is injectable, so the whole suite can be run against the pre-fix file.
21
+ # FH_CODEX_DOCTOR=/path/to/fh-codex-doctor.ORIG.js bash scripts/test_codex_doctor_root_lanes.sh
22
+ # A lane suite that is green both ways is decorative.
23
+ #
24
+ # Usage: bash scripts/test_codex_doctor_root_lanes.sh
25
+ # Exit: 0 = all lanes pass; 1 = at least one lane failed (prints which and why).
26
+
27
+ set -uo pipefail
28
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # 픽스처는 실레포에 쓰지 않는다
29
+
30
+ FH_REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
31
+ DOCTOR="${FH_CODEX_DOCTOR:-$FH_REPO/bin/fh-codex-doctor.js}"
32
+ TMP="$(fh_fixture_root "$(mktemp -d)")"
33
+ : "${TMP:?fixture root unset — refusing to write fixtures in cwd}"
34
+ trap 'rm -rf "$TMP"' EXIT
35
+
36
+ PASS=0; FAIL=0
37
+ ok() { PASS=$((PASS+1)); printf ' ✅ %s\n' "$1"; }
38
+ bad() { FAIL=$((FAIL+1)); printf ' ❌ %s\n got: %s\n' "$1" "$(printf '%s' "$2" | tr '\n' '|' | cut -c1-260)"; }
39
+
40
+ if [ ! -f "$DOCTOR" ]; then
41
+ bad "subject missing: $DOCTOR (HARNESS-ERROR — nothing below was measured)" "absent"
42
+ printf '\ncodex-doctor root lanes: %d passed, %d failed\n' "$PASS" "$FAIL"; exit 1
43
+ fi
44
+ command -v node >/dev/null 2>&1 || {
45
+ bad "node unavailable (HARNESS-ERROR — SKIP is not PASS, so this is a failure)" "no node"
46
+ printf '\ncodex-doctor root lanes: %d passed, %d failed\n' "$PASS" "$FAIL"; exit 1
47
+ }
48
+
49
+ # run <root> → sets RC (exit code) and OUT (stdout+stderr).
50
+ # 🟥 NOT `out="$(run x)"`. Command substitution runs the function in a SUBSHELL, so an `RC=$?`
51
+ # assigned inside it is discarded and the caller keeps its stale RC — the first draft of this file
52
+ # did exactly that and four negative arms reported `rc=0` while node had actually exited 11,
53
+ # i.e. the lanes were grading a value the instrument never produced
54
+ # ([[feedback_broken_parser_reports_a_verdict]]). Redirect to a file and keep both in THIS shell.
55
+ RC=0
56
+ OUT=''
57
+ _RUN_OUT="$TMP/.lastrun"
58
+ run() {
59
+ node "$DOCTOR" --root "$1" --strict > "$_RUN_OUT" 2>&1
60
+ RC=$?
61
+ OUT="$(cat "$_RUN_OUT")"
62
+ }
63
+
64
+ # ── fixture builders ─────────────────────────────────────────────────────────────────────────
65
+ # The tier table's SHAPE is taken from the regex the subject actually uses
66
+ # (`/\|\s*\*\*(M[123])\b/` + a backtick-quoted lowercase name), not from a mental model of
67
+ # "an AGENTS.md" — a fixture whose row does not match would make every positive arm a false red.
68
+ mk_agents_md() { # $1 = dir, $2 = "table" | "no-table"
69
+ if [ "$2" = "table" ]; then
70
+ cat > "$1/AGENTS.md" <<'EOF'
71
+ # Fixture AGENTS.md
72
+
73
+ | Tier | Skill | Note |
74
+ |---|---|---|
75
+ | **M1** | `demo-native` | runs under codex exec directly |
76
+ | **M2** | `demo-adapter` | needs adapter substitution |
77
+ EOF
78
+ else
79
+ printf '# Fixture AGENTS.md\n\nNo tier table here on purpose.\n' > "$1/AGENTS.md"
80
+ fi
81
+ }
82
+
83
+ mk_skill() { # $1 = dir(root), $2 = plugin namespace, $3 = skill name
84
+ mkdir -p "$1/plugins/$2/skills/$3"
85
+ cat > "$1/plugins/$2/skills/$3/SKILL.md" <<EOF
86
+ ---
87
+ name: $3
88
+ description: fixture skill for codex-doctor root lanes
89
+ ---
90
+
91
+ Body. Nothing Claude-native here.
92
+ EOF
93
+ }
94
+
95
+ mk_agent() { # $1 = dir(root), $2 = plugin namespace, $3 = agent name
96
+ mkdir -p "$1/plugins/$2/agents"
97
+ printf -- '---\nname: %s\n---\n\nFixture agent.\n' "$3" > "$1/plugins/$2/agents/$3.md"
98
+ }
99
+
100
+ # The plugin MANIFEST is the shape discriminator pluginNamespaces() uses. Its path is taken from the
101
+ # real tree (all 4 FH plugins, and both plugins of a consumer harness measured off-tree, carry
102
+ # .claude-plugin/plugin.json — verified by
103
+ # `ls`, not assumed), because a fixture whose manifest sat anywhere else would make the shape lanes
104
+ # green for the wrong reason.
105
+ mk_plugin_manifest() { # $1 = dir(root), $2 = plugin namespace
106
+ mkdir -p "$1/plugins/$2/.claude-plugin"
107
+ printf '{"name":"%s","version":"0.0.0"}\n' "$2" > "$1/plugins/$2/.claude-plugin/plugin.json"
108
+ }
109
+
110
+ echo "── codex-doctor root lanes ── subject: $DOCTOR"
111
+
112
+ # ── LANE 1 — KNOWN POSITIVE. A non-npm consumer root that HAS every audited surface.
113
+ # This is that consumer shape reduced to its essentials: AGENTS.md tier table + plugins/**/SKILL.md,
114
+ # and deliberately NO package.json. It must produce a report, not exit 11.
115
+ # 🟥 rc alone is not the assertion. `rc != 11` is also satisfied by a crash, by usage output, or by
116
+ # a stub that prints nothing — so the arm pins the REPORT and a non-zero skill count too.
117
+ P1="$TMP/nonnpm"; mkdir -p "$P1"
118
+ mk_agents_md "$P1" table
119
+ mk_skill "$P1" xx-meta demo-native
120
+ mk_skill "$P1" xx-commons demo-adapter
121
+ run "$P1"; out="$OUT"
122
+ if [ "$RC" -eq 11 ]; then
123
+ bad "lane1 KNOWN-POSITIVE: non-npm root with every audited surface was still gated out" "rc=$RC | $out"
124
+ elif [ "$RC" -ne 0 ]; then
125
+ bad "lane1 KNOWN-POSITIVE: expected a clean report (rc=0), got another non-pass" "rc=$RC | $out"
126
+ else
127
+ case "$out" in
128
+ *"Skills scanned: 0"*) bad "lane1 KNOWN-POSITIVE: passed the gate but classified NOTHING — a confident empty report" "rc=$RC | $out" ;;
129
+ *"Skills scanned: "*) ok "lane1 KNOWN-POSITIVE: non-npm root (no package.json) audited, skills classified (rc=$RC)" ;;
130
+ *) bad "lane1 KNOWN-POSITIVE: rc=0 but no report on stdout — a stub would pass on rc alone" "rc=$RC | $out" ;;
131
+ esac
132
+ fi
133
+
134
+ # ── LANE 2 — KNOWN NEGATIVE. An empty directory. Genuinely nothing to audit → still rc=11.
135
+ # The message assertion is the positive control: `exit 11` with no explanation would pass on rc.
136
+ N2="$TMP/empty"; mkdir -p "$N2"
137
+ run "$N2"; out="$OUT"
138
+ if [ "$RC" -eq 11 ] && case "$out" in *"missing: AGENTS.md"*) true ;; *) false ;; esac \
139
+ && case "$out" in *"missing: plugins/"*) true ;; *) false ;; esac; then
140
+ ok "lane2 KNOWN-NEGATIVE: empty dir → rc=11, and BOTH missing surfaces named"
141
+ else
142
+ bad "lane2 KNOWN-NEGATIVE: empty dir must fail closed at 11 naming each missing surface" "rc=$RC | $out"
143
+ fi
144
+
145
+ # ── LANE 3 — one leg at a time, so lane2 cannot pass on the other's behalf.
146
+ # 3a: the skills exist, the instrument (AGENTS.md) does not.
147
+ N3A="$TMP/no_agents_md"; mkdir -p "$N3A"; mk_skill "$N3A" xx-meta demo-native
148
+ run "$N3A"; out="$OUT"
149
+ if [ "$RC" -eq 11 ] && case "$out" in *"missing: AGENTS.md"*) true ;; *) false ;; esac; then
150
+ ok "lane3a KNOWN-NEGATIVE: plugins present, AGENTS.md absent → rc=11 (no instrument, no report)"
151
+ else
152
+ bad "lane3a: AGENTS.md absence must gate at 11" "rc=$RC | $out"
153
+ fi
154
+ # 3b: the instrument exists, the subject does not.
155
+ N3B="$TMP/no_plugins"; mkdir -p "$N3B"; mk_agents_md "$N3B" table
156
+ run "$N3B"; out="$OUT"
157
+ if [ "$RC" -eq 11 ] && case "$out" in *"missing: plugins/"*) true ;; *) false ;; esac; then
158
+ ok "lane3b KNOWN-NEGATIVE: AGENTS.md present, plugins/ absent → rc=11"
159
+ else
160
+ bad "lane3b: plugins/ absence must gate at 11" "rc=$RC | $out"
161
+ fi
162
+
163
+ # ── LANE 4 — THE INVERSE ERROR, and the arm the UNFIXED code passed with rc=0.
164
+ # plugins/ EXISTS but holds no SKILL.md. Every surface-existence check says yes; there is still
165
+ # nothing to classify. Before the fix this root (package.json + plugins/ + AGENTS.md all present)
166
+ # sailed through and printed `Skills scanned: 0` / `Findings: none` / `Status: OK` / rc=0 —
167
+ # a measurement of nothing rendered as a clean bill of health.
168
+ # 🟥 package.json is PRESENT in this fixture on purpose: without it the unfixed code would gate on
169
+ # the old predicate and the arm would be green both ways, i.e. decorative about the axis it names.
170
+ N4="$TMP/empty_plugins"; mkdir -p "$N4/plugins"
171
+ mk_agents_md "$N4" table
172
+ printf '{"name":"fixture","version":"0.0.0"}\n' > "$N4/package.json"
173
+ run "$N4"; out="$OUT"
174
+ if [ "$RC" -eq 11 ] && case "$out" in *"missing: plugins/**/SKILL.md"*) true ;; *) false ;; esac; then
175
+ ok "lane4 INVERSE-ERROR: empty plugins/ → rc=11, not a confident empty report"
176
+ else
177
+ bad "lane4 INVERSE-ERROR: an empty plugins/ produced a report — not-found rendered as zero" "rc=$RC | $out"
178
+ fi
179
+
180
+ # ── LANE 5 — the pre-existing fail-closed channel must survive the gate rewrite.
181
+ # AGENTS.md is readable but has NO tier table → documentedTiers() yields 0 rows → INSTRUMENT_ERROR,
182
+ # exit 10 (harness error), distinct from 1 (drift) and 11 (wrong root). If the new predicate had
183
+ # been written as "AGENTS.md must contain a tier table", this arm would collapse into an 11 and the
184
+ # two failure classes — wrong root vs broken instrument — would stop being distinguishable.
185
+ N5="$TMP/no_tier_table"; mkdir -p "$N5"
186
+ mk_agents_md "$N5" no-table
187
+ mk_skill "$N5" xx-meta demo-native
188
+ run "$N5"; out="$OUT"
189
+ if [ "$RC" -eq 10 ] && case "$out" in *INSTRUMENT_ERROR*) true ;; *) false ;; esac; then
190
+ ok "lane5 INSTRUMENT-ERROR preserved: readable AGENTS.md with 0 tier rows → rc=10, not 11 and not 0"
191
+ else
192
+ bad "lane5: the instrument-failure channel changed class (expected rc=10 + INSTRUMENT_ERROR)" "rc=$RC | $out"
193
+ fi
194
+
195
+ # ── LANE 6 — the second silent zero, isolated from lane1.
196
+ # collectAgents() used to iterate a HARDCODED ['fh-meta','fh-commons'], so a consumer whose plugins
197
+ # carry any other prefix got `Agents scanned: 0` — the same not-found-is-zero family, and the first
198
+ # thing a newly-unblocked consumer would have seen. package.json is present here so the UNFIXED
199
+ # code reaches the report: it printed rc=0 with `Agents scanned: 0` while 2 agent files existed.
200
+ N6="$TMP/other_prefix"; mkdir -p "$N6"
201
+ mk_agents_md "$N6" table
202
+ mk_skill "$N6" zz-meta demo-native
203
+ mk_agent "$N6" zz-meta fixture-agent-one
204
+ mk_agent "$N6" zz-commons fixture-agent-two
205
+ # 🟥 Both namespaces are given a real plugin manifest so this lane exercises the SHAPE-FILTERED
206
+ # discovery path rather than the manifest-less fallback (lane10b owns that). The lane's axis is
207
+ # unchanged and in fact sharper: a non-`fh-` prefix must resolve THROUGH the filter, never by
208
+ # accident of the filter being bypassed. A name-based filter would redden exactly here.
209
+ mk_plugin_manifest "$N6" zz-meta
210
+ mk_plugin_manifest "$N6" zz-commons
211
+ printf '{"name":"fixture","version":"0.0.0"}\n' > "$N6/package.json"
212
+ run "$N6"; out="$OUT"
213
+ if [ "$RC" -ne 0 ]; then
214
+ bad "lane6: fixture root did not produce a report at all" "rc=$RC | $out"
215
+ else
216
+ case "$out" in
217
+ *"Agents scanned: 2"*) ok "lane6 NAMESPACE: agents under non-fh- plugin prefixes are discovered (2/2)" ;;
218
+ *"Agents scanned: 0"*) bad "lane6 NAMESPACE: 2 agent files on disk reported as 0 — hardcoded plugin list" "rc=$RC | $out" ;;
219
+ *) bad "lane6 NAMESPACE: unexpected agent count" "rc=$RC | $out" ;;
220
+ esac
221
+ fi
222
+
223
+ # ── LANE 7 — CONTROL, against the live repo. The suite must not be satisfiable by a subject that
224
+ # has simply stopped gating (lanes 1/6) or by one that gates everything (lanes 2/3/4). FH's own root
225
+ # is the known-good reference: it must still audit clean, with the counts the shipped tree has.
226
+ run "$FH_REPO"; out="$OUT"
227
+ if [ "$RC" -eq 0 ] \
228
+ && case "$out" in *"Status: OK"*) true ;; *) false ;; esac \
229
+ && case "$out" in *"Skills scanned: 0"*) false ;; *) true ;; esac \
230
+ && case "$out" in *"Agents scanned: 0"*) false ;; *) true ;; esac; then
231
+ ok "lane7 CONTROL: the live FH root still audits clean and non-empty ($(printf '%s' "$out" | sed -n 's/^- \(Skills scanned: [0-9]*\)$/\1/p'), $(printf '%s' "$out" | sed -n 's/^- \(Agents scanned: [0-9]*\)$/\1/p'))"
232
+ else
233
+ bad "lane7 CONTROL: regression on the live FH root" "rc=$RC | $out"
234
+ fi
235
+
236
+ # ═══════════════════════════════════════════════════════════════════════════════════════════════
237
+ # LANES 8–11 — EXIT-CODE COLLAPSE. Added 2026-09-17 after a cross-family review of the lanes above.
238
+ # The gate rewrite stopped asserting several surface properties, and every property it stopped
239
+ # asserting reached raw fs calls that THROW. An uncaught node exception is rc=1 — the code already
240
+ # owned by "--strict found HIGH drift". So a caller could not distinguish "the harness broke" from
241
+ # "the harness found drift", which is the same class of defect as the silent zeros above, only
242
+ # wearing an exit code. The three non-zero classes must stay separable:
243
+ # 11 wrong root · 10 instrument/input error · 1 --strict with HIGH findings
244
+ # ═══════════════════════════════════════════════════════════════════════════════════════════════
245
+
246
+ # ── LANE 8 — `plugins` PRESENT BUT NOT A DIRECTORY. exists() says yes (it uses F_OK, which is
247
+ # blind to node type), then readdirSync threw ENOTDIR. Measured before the fix:
248
+ # Error: ENOTDIR: not a directory, scandir '.../plugins' → rc=1
249
+ # A wrong-shaped root surface belongs with an absent one: rc=11, naming it.
250
+ N8="$TMP/plugins_is_a_file"; mkdir -p "$N8"
251
+ mk_agents_md "$N8" table
252
+ printf 'this is a file, not a directory\n' > "$N8/plugins"
253
+ run "$N8"; out="$OUT"
254
+ if [ "$RC" -eq 11 ] && case "$out" in *"plugins/ — present but NOT a directory"*) true ;; *) false ;; esac; then
255
+ ok "lane8 SHAPE: plugins/ present as a FILE → rc=11 naming the shape fault (not an uncaught rc=1)"
256
+ else
257
+ bad "lane8 SHAPE: a non-directory plugins/ must exit 11, not collapse into 1" "rc=$RC | $out"
258
+ fi
259
+
260
+ # ── LANE 9 — UNREADABLE SUBJECT, deterministic arm. A broken symlink named SKILL.md: walk() lists
261
+ # it (readdirSync sees the link; exists() follows it and reports the TARGET absent), then readText()
262
+ # threw ENOENT out of collectSkills(). Measured before the fix:
263
+ # Error: ENOENT: no such file or directory, open '.../broken/SKILL.md' → rc=1
264
+ # The subject being unusable is an INPUT fault: rc=10 + INSTRUMENT_ERROR + the path named.
265
+ N9="$TMP/broken_symlink_skill"; mkdir -p "$N9"
266
+ mk_agents_md "$N9" table
267
+ mk_skill "$N9" xx-meta demo-native
268
+ mkdir -p "$N9/plugins/xx-meta/skills/broken"
269
+ ln -s /nonexistent/definitely-not-here.md "$N9/plugins/xx-meta/skills/broken/SKILL.md"
270
+ run "$N9"; out="$OUT"
271
+ if [ "$RC" -eq 10 ] \
272
+ && case "$out" in *INSTRUMENT_ERROR*) true ;; *) false ;; esac \
273
+ && case "$out" in *"skills/broken/SKILL.md"*) true ;; *) false ;; esac; then
274
+ ok "lane9 INPUT-ERROR: broken-symlink SKILL.md → rc=10 + INSTRUMENT_ERROR + path named"
275
+ else
276
+ bad "lane9 INPUT-ERROR: an unreadable skill input must be 10, not an uncaught 1 and not 0" "rc=$RC | $out"
277
+ fi
278
+
279
+ # ── LANE 9b — the permissions arm of the same axis. Kept SEPARATE from lane9 because it is the only
280
+ # arm in this suite whose fixture can be silently defeated by the environment: a user who can read a
281
+ # chmod 000 file (root, or some CI images) makes the fixture non-potent. That is a SKIP with a stated
282
+ # reason — 🟥 SKIP IS NOT PASS, so it increments neither counter and says so out loud.
283
+ N9B="$TMP/eacces_skill"; mkdir -p "$N9B"
284
+ mk_agents_md "$N9B" table
285
+ mk_skill "$N9B" xx-meta demo-native
286
+ mk_skill "$N9B" xx-meta locked
287
+ chmod 000 "$N9B/plugins/xx-meta/skills/locked/SKILL.md"
288
+ if cat "$N9B/plugins/xx-meta/skills/locked/SKILL.md" >/dev/null 2>&1; then
289
+ printf ' ⚠️ lane9b SKIPPED (not PASS, not counted): this user (%s) can read a chmod 000 file, so the EACCES fixture is not potent here. The same code path is covered deterministically by lane9.\n' "$(id -un)"
290
+ else
291
+ run "$N9B"; out="$OUT"
292
+ if [ "$RC" -eq 10 ] \
293
+ && case "$out" in *INSTRUMENT_ERROR*) true ;; *) false ;; esac \
294
+ && case "$out" in *"skills/locked/SKILL.md"*) true ;; *) false ;; esac; then
295
+ ok "lane9b INPUT-ERROR: chmod 000 SKILL.md (EACCES) → rc=10 + INSTRUMENT_ERROR + path named"
296
+ else
297
+ bad "lane9b INPUT-ERROR: an EACCES skill input must be 10, not an uncaught 1" "rc=$RC | $out"
298
+ fi
299
+ fi
300
+
301
+ # ── LANE 10 — NAMESPACE OVER-COLLECTION. pluginNamespaces() accepted every directory under
302
+ # plugins/, so a stray dir (a stale copy, node_modules, a scratch tree) INFLATED `Agents scanned`.
303
+ # Measured before the fix, with one real plugin plus plugins/not-a-plugin/agents/ghost.md:
304
+ # Status: OK · Skills scanned: 1 · Agents scanned: 1 · Findings: none
305
+ # The ghost is now excluded by plugin SHAPE — and 🟥 the exclusion is asserted to be VISIBLE, not
306
+ # silent: a quiet drop and a quiet over-count are the same defect pointing opposite ways.
307
+ N10="$TMP/ghost_namespace"; mkdir -p "$N10"
308
+ mk_agents_md "$N10" table
309
+ mk_skill "$N10" real demo-native
310
+ mk_agent "$N10" real fixture-real-agent
311
+ mk_plugin_manifest "$N10" real
312
+ mkdir -p "$N10/plugins/not-a-plugin/agents"
313
+ printf -- '---\nname: ghost\n---\n\nGhost agent in a directory that is not a plugin.\n' > "$N10/plugins/not-a-plugin/agents/ghost.md"
314
+ run "$N10"; out="$OUT"
315
+ if [ "$RC" -ne 0 ]; then
316
+ bad "lane10 NAMESPACE-SHAPE: fixture root did not produce a report at all" "rc=$RC | $out"
317
+ elif case "$out" in *"Agents scanned: 1"*) false ;; *) true ;; esac; then
318
+ bad "lane10 NAMESPACE-SHAPE: expected exactly the 1 real agent (the ghost must not be counted)" "rc=$RC | $out"
319
+ elif case "$out" in *PLUGIN_NAMESPACE_NOT_PLUGIN_SHAPED*) true ;; *) false ;; esac; then
320
+ ok "lane10 NAMESPACE-SHAPE: unshaped plugins/not-a-plugin/ excluded (Agents scanned: 1) AND the drop is named in a WARN"
321
+ else
322
+ bad "lane10 NAMESPACE-SHAPE: count is right but the exclusion is SILENT — a drop must be visible" "rc=$RC | $out"
323
+ fi
324
+
325
+ # ── LANE 10b — THE PAIRED NEGATIVE for lane10, and the reason the shape filter is not absolute.
326
+ # A consumer whose plugins/ carries NO manifest anywhere has no shape signal at all. Filtering
327
+ # strictly there would report `Agents scanned: 0` for a tree that visibly holds agents — the exact
328
+ # not-found-is-zero failure this whole suite was built around, re-introduced by the fix for lane10.
329
+ # So discovery falls back to an UNFILTERED scan and says so. Both halves are asserted: the agent is
330
+ # found, and the report admits the count is unfiltered.
331
+ # 🟥 Honest scope: on such a root lane10's ghost WOULD still be counted. That residual is structural
332
+ # (with zero manifests nothing distinguishes a plugin from a stray dir) and it is LABELLED, not silent.
333
+ N10B="$TMP/no_manifest_anywhere"; mkdir -p "$N10B"
334
+ mk_agents_md "$N10B" table
335
+ mk_skill "$N10B" qq-meta demo-native
336
+ mk_agent "$N10B" qq-meta fixture-agent-one
337
+ run "$N10B"; out="$OUT"
338
+ if [ "$RC" -ne 0 ]; then
339
+ bad "lane10b FALLBACK: manifest-less root did not produce a report" "rc=$RC | $out"
340
+ elif case "$out" in *"Agents scanned: 1"*) false ;; *) true ;; esac; then
341
+ bad "lane10b FALLBACK: the shape filter manufactured a silent zero on a manifest-less root" "rc=$RC | $out"
342
+ elif case "$out" in *PLUGIN_SHAPE_UNDETECTABLE*) true ;; *) false ;; esac; then
343
+ ok "lane10b FALLBACK: manifest-less root still discovers agents (1/1) AND labels the count unfiltered"
344
+ else
345
+ bad "lane10b FALLBACK: fell back correctly but did not LABEL the count as unfiltered" "rc=$RC | $out"
346
+ fi
347
+
348
+ # ── LANE 11 — EMPTY SKILL.md. A zero-byte SKILL.md was counted as a skill and the report said
349
+ # `Status: OK · Findings: none`; the only trace was `unclassified=1`, which is also where a
350
+ # merely-undocumented-but-real skill lands, so the two were indistinguishable.
351
+ # 🟥 Strength is deliberately WARN. The run DID measure the surface — it measured an empty one — so
352
+ # escalating to 10 or HIGH would fix one exit-code collapse by creating another. rc must stay 0.
353
+ N11="$TMP/empty_skill_md"; mkdir -p "$N11"
354
+ mk_agents_md "$N11" table
355
+ mk_skill "$N11" ee-meta demo-native
356
+ mk_plugin_manifest "$N11" ee-meta
357
+ mkdir -p "$N11/plugins/ee-meta/skills/emptyskill"
358
+ : > "$N11/plugins/ee-meta/skills/emptyskill/SKILL.md"
359
+ run "$N11"; out="$OUT"
360
+ if [ "$RC" -ne 0 ]; then
361
+ bad "lane11 EMPTY-SKILL: a WARN-class observation must NOT change the exit class (expected rc=0)" "rc=$RC | $out"
362
+ elif case "$out" in *SKILL_MD_HAS_NO_CLASSIFIABLE_CONTENT*) true ;; *) false ;; esac; then
363
+ ok "lane11 EMPTY-SKILL: empty SKILL.md is named in a WARN, and rc stays 0 (no new exit-code collapse)"
364
+ else
365
+ bad "lane11 EMPTY-SKILL: an empty SKILL.md still reports a clean bill of health" "rc=$RC | $out"
366
+ fi
367
+
368
+ # ── LANE 11b — CONTROL for lane11. The WARN must fire on the empty input, not on every skill.
369
+ # Without this, a rule that warned unconditionally would pass lane11 while making the signal useless.
370
+ N11B="$TMP/normal_skills_only"; mkdir -p "$N11B"
371
+ mk_agents_md "$N11B" table
372
+ mk_skill "$N11B" ee-meta demo-native
373
+ mk_skill "$N11B" ee-meta demo-adapter
374
+ mk_plugin_manifest "$N11B" ee-meta
375
+ run "$N11B"; out="$OUT"
376
+ if [ "$RC" -eq 0 ] && case "$out" in *SKILL_MD_HAS_NO_CLASSIFIABLE_CONTENT*) false ;; *) true ;; esac; then
377
+ ok "lane11b CONTROL: two well-formed SKILL.md files raise NO empty-input WARN"
378
+ else
379
+ bad "lane11b CONTROL: the empty-input WARN fires on well-formed skills — the signal is worthless" "rc=$RC | $out"
380
+ fi
381
+
382
+ printf '\ncodex-doctor root lanes: %d passed, %d failed\n' "$PASS" "$FAIL"
383
+ [ "$FAIL" -eq 0 ] || exit 1
384
+ exit 0
@@ -35,8 +35,12 @@
35
35
  # 확인이라는 점이 핵심 — known-negative 가 없으면 "오탐이 있나" 조차 못 재고, 그러면
36
36
  # PASS 는 "늘 잡는 계기" 와 구분되지 않는다.
37
37
  #
38
+ # ⚠️ 아래 인용문은 **사문(死文)이다** — 2026-08-25 에 SKILL.md 에서 삭제됐다.
39
+ # 그 파일은 이제 「앞 몇 줄」식 위치 열거를 안 쓰고 표의 `check-class` 열로 채점한다
40
+ # (위치 서술이 행 추가 때마다 조용히 어긋났다). 판정 자체는 유효하므로 남긴다.
41
+ # 🟥 **「둘뿐」도 그 시점 상태다** — 같은 날 SKILL.md 에 C2 패턴이 실렸다.
38
42
  # 🟥 첫 캘리브레이션이 정본의 과장을 드러냈다: SKILL.md 는 Step 2 의 "앞 다섯 줄은 기계
39
- # 검출 가능" 이라 적었는데, 실제로 grep 을 싣고 있는 것은 C1·C5 둘뿐이고 C2·C3·C4 의
43
+ # 검출 가능" 이라 적었는데, 당시 grep 을 싣고 있던 것은 C1·C5 둘뿐이고 C2·C3·C4 의
40
44
  # 검출 힌트 칸은 산문 서술이다. 특히 C4 는 패턴이 없어서, 내가 임의로 지은 패턴이
41
45
  # 양성을 0건으로 놓쳤다 — 계기를 세우자마자 대상의 결함이 나온 형태다.
42
46
  #