@chrono-meta/fh-gate 3.44.0 → 3.46.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/rules/fh_4axis_gate.md +50 -608
- package/.claude-plugin/marketplace.json +4 -4
- package/CATALOG.md +21 -0
- package/CHEATSHEET.md +13 -3
- package/docs/codex-compat.md +1 -1
- package/knowledge/shared/harness-core/fh_4axis_gate_detail.md +679 -0
- package/knowledge/shared/harness-core/fh_detail_protocols.md +1 -0
- package/knowledge/shared/harness-core/fh_integration_contract.md +1 -1
- package/knowledge/shared/harness-core/fh_module_contract.md +106 -3
- package/knowledge/shared/harness-core/heavy_skill_to_cartridge.md +185 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +209 -0
- package/package.json +19 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +9 -8
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +20 -0
- package/plugins/fh-commons/skills/mcp-circuit-breaker/SKILL.md +12 -6
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +122 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +13 -0
- package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -0
- package/plugins/fh-meta/skills/deep-clarify/SKILL.md +76 -22
- package/plugins/fh-meta/skills/harvest-loop/SKILL.md +2 -2
- package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +4 -0
- package/plugins/fh-meta/skills/memory-hygiene/SKILL.md +6 -0
- package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +2 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/agy_launch_guard.sh +117 -1
- package/scripts/below_floor_scan.sh +30 -0
- package/scripts/codex_launch_guard.sh +38 -2
- package/scripts/correction_moments.py +23 -2
- package/scripts/fh-gate.sh +612 -14
- package/scripts/fh-goal.sh +56 -12
- package/scripts/fh-run.sh +1 -1
- package/scripts/fh_gate_exec.sh +272 -0
- package/scripts/fh_session_load.sh +17 -0
- package/scripts/finding_fleet.sh +2 -1
- package/scripts/finding_verifier.sh +2 -1
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/README.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py +24 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/SKILL.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/fh-module.yaml +20 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/hooks/hooks.json +7 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/check_links.py +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish.sh +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish_guard.py +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/setup.sh +5 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/hooks/hooks.json +10 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/guard_push.py +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/install.sh +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/ship.sh +9 -0
- package/scripts/heavy_skill_smell.py +311 -0
- package/scripts/job_heartbeat.py +186 -0
- package/scripts/live_eval_matrix.py +128 -0
- package/scripts/live_eval_trace.py +197 -4
- package/scripts/package_coverage_check.sh +18 -0
- package/scripts/pr_merge_verified.sh +14 -4
- package/scripts/prepush_guard_check.sh +8 -0
- package/scripts/probe_live_eval.sh +32 -0
- package/scripts/probe_live_eval_lib.py +8 -2
- package/scripts/selfcheck.sh +113 -0
- package/scripts/selfcheck_shard_weights.txt +2 -0
- package/scripts/sidecar_calibrate.sh +7 -5
- package/scripts/sim_isolated_run.sh +20 -0
- package/scripts/test_agy_launch_guard_lanes.sh +120 -0
- package/scripts/test_below_floor_scan_lanes.sh +85 -0
- package/scripts/test_codex_launch_guard_lanes.sh +45 -0
- package/scripts/test_correction_moments_lanes.sh +37 -0
- package/scripts/test_deep_clarify_interview_lanes.sh +108 -0
- package/scripts/test_deep_clarify_spec_path_lanes.sh +91 -0
- package/scripts/test_fh_gate_absorb_lanes.sh +255 -0
- package/scripts/test_fh_gate_defaults_lanes.sh +188 -0
- package/scripts/test_fh_gate_exec_lanes.sh +244 -0
- package/scripts/test_fh_gate_fusion_lanes.sh +202 -0
- package/scripts/test_fh_gate_regressions.sh +92 -1
- package/scripts/test_fh_goal_change_detection_lanes.sh +103 -3
- package/scripts/test_finding_pipeline_lanes.sh +35 -1
- package/scripts/test_guard_anchor_override_env_lanes.sh +84 -0
- package/scripts/test_heavy_skill_smell_lanes.sh +160 -0
- package/scripts/test_job_heartbeat_lanes.sh +96 -0
- package/scripts/test_live_eval_construct_lanes.sh +29 -6
- package/scripts/test_live_eval_matrix_lanes.sh +53 -0
- package/scripts/test_live_eval_trace_lanes.sh +132 -5
- package/scripts/test_name_boundary_locale_lanes.sh +36 -5
- package/scripts/test_pr_merge_verified_lanes.sh +15 -2
- package/scripts/test_prepush_marker_lookup_lanes.sh +143 -0
- package/scripts/test_probe_live_eval_lanes.sh +44 -0
- package/scripts/test_regression_guard_sibling_lanes.sh +52 -1
- package/scripts/test_sidecar_calibrate_lanes.sh +1 -1
- package/scripts/test_sim_isolated_run_lanes.sh +43 -0
- package/scripts/universal_guard_check.sh +8 -0
- package/scripts/worktree_reclaim.sh +1 -1
- package/templates/.claude/rules/mcp_tool_gating.md +27 -0
- package/templates/.git-hooks/pre-push +60 -3
- package/templates/PRE-PUBLISH-CHECKLIST.md +22 -0
- package/templates/regression_guard.sh +8 -4
- package/templates/settings.LaneGap.snippet.json +27 -0
package/scripts/fh-goal.sh
CHANGED
|
@@ -119,7 +119,7 @@ fi
|
|
|
119
119
|
if [[ -z "${FH_MODEL:-}" ]]; then
|
|
120
120
|
case "$FH_BACKEND" in
|
|
121
121
|
codex) FH_MODEL="gpt-5.5" ;;
|
|
122
|
-
claude) FH_MODEL="claude-sonnet-
|
|
122
|
+
claude) FH_MODEL="claude-sonnet-5-5" ;;
|
|
123
123
|
esac
|
|
124
124
|
fi
|
|
125
125
|
|
|
@@ -144,7 +144,8 @@ START_COMMIT="$(git -C "$WORK_ROOT" rev-parse HEAD 2>/dev/null || true)"
|
|
|
144
144
|
PROMPT_FILE=$(mktemp "${_TMPDIR}/fh_goal_prompt_XXXXXX")
|
|
145
145
|
OUTPUT_FILE=$(mktemp "${_TMPDIR}/fh_goal_output_XXXXXX")
|
|
146
146
|
ERR_FILE=$(mktemp "${_TMPDIR}/fh_goal_err_XXXXXX")
|
|
147
|
-
|
|
147
|
+
_fg_lst=""
|
|
148
|
+
cleanup() { rm -f "$PROMPT_FILE" "$OUTPUT_FILE" "$ERR_FILE"; [[ -n "$_fg_lst" ]] && rm -f "$_fg_lst" "$_fg_lst.dropped"; return 0; }
|
|
148
149
|
trap cleanup EXIT
|
|
149
150
|
|
|
150
151
|
cat > "$PROMPT_FILE" <<PROMPT
|
|
@@ -197,6 +198,27 @@ fi
|
|
|
197
198
|
[[ "$FH_VERBOSE" == "1" ]] && cat "$ERR_FILE" >&2
|
|
198
199
|
cat "$OUTPUT_FILE"
|
|
199
200
|
|
|
201
|
+
# NUL-delimited git listing on stdin → newline-delimited names. $1 = name | porcelain (strip «XY », skip the
|
|
202
|
+
# old-path field after a rename/copy). A name holding a newline cannot travel in the list: a WARN names it.
|
|
203
|
+
_FG_DROPPED=0
|
|
204
|
+
_fg_z_to_lines() {
|
|
205
|
+
local _n _skip=0
|
|
206
|
+
while IFS= read -r -d '' _n; do
|
|
207
|
+
if [[ "$_skip" -eq 1 ]]; then _skip=0; continue; fi
|
|
208
|
+
if [[ "$1" == porcelain ]]; then
|
|
209
|
+
case "${_n:0:2}" in R*|C*|?R|?C) _skip=1 ;; esac
|
|
210
|
+
_n="${_n:3}"
|
|
211
|
+
fi
|
|
212
|
+
[[ -z "$_n" ]] && continue
|
|
213
|
+
if [[ "$_n" == *$'\n'* ]]; then
|
|
214
|
+
echo "WARN: changed file name contains a newline and is not reviewed: $(printf '%q' "$_n")" >&2
|
|
215
|
+
echo x >>"$_fg_lst.dropped" # the caller runs this in a subshell; the count goes through a file
|
|
216
|
+
continue
|
|
217
|
+
fi
|
|
218
|
+
printf '%s\n' "$_n"
|
|
219
|
+
done
|
|
220
|
+
}
|
|
221
|
+
|
|
200
222
|
if [[ -z "$TARGET_FILES" ]]; then
|
|
201
223
|
# No git → no change detection → no basis for "nothing changed". Say so and fail closed
|
|
202
224
|
# instead of reporting the clean-run exit the caller reads as "gate passed".
|
|
@@ -216,31 +238,53 @@ if [[ -z "$TARGET_FILES" ]]; then
|
|
|
216
238
|
# Capture the git rc SEPARATELY from the transform — `|| true` on the whole pipeline is what
|
|
217
239
|
# ate it, and `pipefail` had been faithfully propagating it right up to that point.
|
|
218
240
|
if [[ -n "$START_COMMIT" ]]; then
|
|
219
|
-
|
|
241
|
+
# -z (AQ-20261119-8): git prints every name raw, NUL-delimited. The old path joined names with `xargs`,
|
|
242
|
+
# which aborts on a quote in a name; `|| true` folded that into an empty list → «no changed files» → exit 0,
|
|
243
|
+
# fh-gate never ran. Names now go to fh-gate newline-delimited (fh-gate's multi-line form); command
|
|
244
|
+
# substitution drops NUL bytes, so the raw listing goes through a temp file.
|
|
245
|
+
_fg_lst=$(mktemp "${_TMPDIR}/fh_goal_list_XXXXXX")
|
|
246
|
+
if ! git -C "$WORK_ROOT" -c core.quotePath=false diff -z "$START_COMMIT"..HEAD --name-only >"$_fg_lst" 2>/dev/null; then
|
|
247
|
+
rm -f "$_fg_lst"
|
|
220
248
|
echo "ERROR: cannot detect changed files (git diff failed in ${WORK_ROOT})." >&2
|
|
221
249
|
echo " The backend may well have changed code; fh-gate never ran. Pass --files explicitly." >&2
|
|
222
250
|
exit 10
|
|
223
251
|
fi
|
|
224
|
-
TARGET_FILES=$(
|
|
252
|
+
TARGET_FILES=$(_fg_z_to_lines name <"$_fg_lst")
|
|
253
|
+
[[ -f "$_fg_lst.dropped" ]] && _FG_DROPPED=$((_FG_DROPPED + $(wc -l <"$_fg_lst.dropped")))
|
|
254
|
+
rm -f "$_fg_lst" "$_fg_lst.dropped"
|
|
225
255
|
fi
|
|
226
|
-
if [[ -z "$TARGET_FILES" ]]; then
|
|
227
|
-
# `--porcelain
|
|
228
|
-
#
|
|
229
|
-
|
|
256
|
+
if [[ -z "$TARGET_FILES" && "$_FG_DROPPED" -eq 0 ]]; then
|
|
257
|
+
# `--porcelain -z`: each entry is «XY path»; a rename/copy entry is followed by its OLD path as a separate
|
|
258
|
+
# field, which is skipped (the new path is the one to review).
|
|
259
|
+
_fg_lst=$(mktemp "${_TMPDIR}/fh_goal_list_XXXXXX")
|
|
260
|
+
if ! git -C "$WORK_ROOT" -c core.quotePath=false status --porcelain -z >"$_fg_lst" 2>/dev/null; then
|
|
261
|
+
rm -f "$_fg_lst"
|
|
230
262
|
echo "ERROR: cannot detect changed files (git status failed in ${WORK_ROOT})." >&2
|
|
231
263
|
echo " The backend may well have changed code; fh-gate never ran. Pass --files explicitly." >&2
|
|
232
264
|
exit 10
|
|
233
265
|
fi
|
|
234
|
-
TARGET_FILES=$(
|
|
235
|
-
|
|
236
|
-
|
|
266
|
+
TARGET_FILES=$(_fg_z_to_lines porcelain <"$_fg_lst")
|
|
267
|
+
[[ -f "$_fg_lst.dropped" ]] && _FG_DROPPED=$((_FG_DROPPED + $(wc -l <"$_fg_lst.dropped")))
|
|
268
|
+
rm -f "$_fg_lst" "$_fg_lst.dropped"
|
|
237
269
|
fi
|
|
238
270
|
fi
|
|
239
271
|
|
|
272
|
+
if [[ -z "$TARGET_FILES" && "$_FG_DROPPED" -gt 0 ]]; then
|
|
273
|
+
echo "ERROR: every changed file name holds a newline (${_FG_DROPPED}) — fh-gate cannot review them." >&2
|
|
274
|
+
echo " Failing closed rather than reporting «no changed files». Rename the file(s) or pass --files." >&2
|
|
275
|
+
exit 10
|
|
276
|
+
fi
|
|
277
|
+
# Beside other names, a dropped one would make fh-gate's verdict cover part of the change (security review 2026-11-20).
|
|
278
|
+
if [[ "$_FG_DROPPED" -gt 0 ]]; then
|
|
279
|
+
echo "ERROR: ${_FG_DROPPED} changed file name(s) hold a newline — fh-gate would review only the rest." >&2
|
|
280
|
+
echo " Failing closed rather than reporting a verdict on part of the change. Rename the file(s) or pass --files." >&2
|
|
281
|
+
exit 10
|
|
282
|
+
fi
|
|
283
|
+
|
|
240
284
|
if [[ -z "$TARGET_FILES" ]]; then
|
|
241
285
|
echo "→ fh-goal: no changed files detected in ${WORK_ROOT}; skipping fh-gate" >&2
|
|
242
286
|
exit 0
|
|
243
287
|
fi
|
|
244
288
|
|
|
245
|
-
echo "→ fh-goal: running fh-gate on $
|
|
289
|
+
echo "→ fh-goal: running fh-gate on $(printf '%s' "$TARGET_FILES" | tr '\n' ' ')" >&2
|
|
246
290
|
FH_BACKEND="$FH_BACKEND" "$FH_ROOT/scripts/fh-gate.sh" "$TARGET_FILES" "$FH_GATE_LEVEL" "$FH_CALLER"
|
package/scripts/fh-run.sh
CHANGED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# fh_gate_exec.sh — fh-gate's execution layer. Token-free: no model is called here.
|
|
3
|
+
#
|
|
4
|
+
# E0 static class scanners FH already has, run against this change (today: pipefail_earlyexit_scan.sh,
|
|
5
|
+
# the «producer | early-exit consumer under pipefail» class — P04 of the 2026-11-19 /code-review
|
|
6
|
+
# comparison, a defect every reviewer arm missed).
|
|
7
|
+
# E1 the target lanes of this change, run in a COPY of the tree — never in the caller's work tree.
|
|
8
|
+
#
|
|
9
|
+
# Why this exists: the 2026-11-19 comparison (lab evidence/cr) measured fh-gate as a one-pass reader and
|
|
10
|
+
# found it at best tied with the built-in /code-review. Its two structural misses were defects that only
|
|
11
|
+
# show when something RUNS. This layer is the part of fh-gate a reader cannot replace. Whether it catches
|
|
12
|
+
# what /code-review misses is a hypothesis until the pre-registered before/after measurement says so.
|
|
13
|
+
#
|
|
14
|
+
# Usage: fh_gate_exec.sh <work_root> <base_ref> [--plan]
|
|
15
|
+
# <base_ref> the state this change is measured against (fh-gate passes FH_GATE_BASE or its default)
|
|
16
|
+
# --plan list what would run; run nothing
|
|
17
|
+
# Output: one JSON object on stdout:
|
|
18
|
+
# {"e0":{"status":"ran|not-run|planned","detail":"…"},"e1":{…},"findings":[{grade,location,title,evidence,fix,source}]}
|
|
19
|
+
# Grades (the caller turns them into a verdict; this script judges nothing else):
|
|
20
|
+
# A a lane this change turns red (green, or absent, at the base)
|
|
21
|
+
# B a lane that did not finish in time · a scanner that flags a NEW site · a scanner whose own check failed
|
|
22
|
+
# · a copy that could not be built — a step that did not finish is never green
|
|
23
|
+
# C a lane that was red at the base too (not introduced by this change)
|
|
24
|
+
# Exit: 0 = the object was emitted (a step that could not run says so in its status/detail, never as 0 hits)
|
|
25
|
+
# 10 = the object could not be produced (jq missing)
|
|
26
|
+
#
|
|
27
|
+
# Environment:
|
|
28
|
+
# FH_GATE_LANES newline-separated lane commands, run from the copy's root. Declared lanes replace
|
|
29
|
+
# discovery.
|
|
30
|
+
# FH_LANE_TIMEOUT seconds per lane run (default 600)
|
|
31
|
+
# FH_GATE_MAX_LANES most lanes run per change (default 6); a cap that bites is stated in the detail
|
|
32
|
+
# FH_GATE_E0_SCANNER scanner path override (lanes only)
|
|
33
|
+
#
|
|
34
|
+
# Lane discovery (when nothing is declared): FH's own convention. A changed file named scripts/test_*.sh
|
|
35
|
+
# or *_lanes.sh is a lane itself; otherwise a lane is a scripts/test_*.sh or scripts/*_lanes.sh file in
|
|
36
|
+
# the copy whose text names the changed file's basename. Order (it decides which lanes a cap keeps): changed
|
|
37
|
+
# lanes first, then lanes whose own name carries the changed file's stem, then the rest, each in sort order. Lanes run with FH_GATE_EXEC=off so a gate a lane runs does not start this layer again.
|
|
38
|
+
#
|
|
39
|
+
# 🟥 TRUST: E1 runs the reviewed change's own lane scripts — the same trust as running its test suite.
|
|
40
|
+
# Where the change is not trusted, set FH_GATE_EXEC=off on the fh-gate call. The copy keeps the caller's tree
|
|
41
|
+
# out of the lanes' working directory; it is NOT a sandbox — lane code that writes to an absolute path, or
|
|
42
|
+
# through a symlink the change carries, reaches wherever that path points.
|
|
43
|
+
# Lanes run one after another in the same copy: a lane that leaves state behind can change what a later lane sees.
|
|
44
|
+
# FH's lanes keep their state in their own temp folders, so this is a named residual, not a guarantee.
|
|
45
|
+
# «NOT RUN» comes in two kinds. Not applicable (not a git repository, no change, no lane, scanner not shipped):
|
|
46
|
+
# a status line, no finding. Could not run (base ref missing, copy failed, scanner instrument error, a lane or
|
|
47
|
+
# its base run that did not finish): a B finding, so the verdict cannot be PASS on a step that did not happen.
|
|
48
|
+
set -uo pipefail
|
|
49
|
+
export LC_ALL=C
|
|
50
|
+
|
|
51
|
+
WORK="${1:-}"; BASE_REF="${2:-}"; MODE="${3:-run}"
|
|
52
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
53
|
+
SCANNER="${FH_GATE_E0_SCANNER:-$HERE/pipefail_earlyexit_scan.sh}"
|
|
54
|
+
LANE_TIMEOUT="${FH_LANE_TIMEOUT:-600}"
|
|
55
|
+
MAX_LANES="${FH_GATE_MAX_LANES:-6}"
|
|
56
|
+
case "$LANE_TIMEOUT" in ''|*[!0-9]*) LANE_TIMEOUT=600 ;; esac
|
|
57
|
+
case "$MAX_LANES" in ''|*[!0-9]*) MAX_LANES=6 ;; esac
|
|
58
|
+
[ "$MODE" = "--plan" ] && MODE=plan
|
|
59
|
+
|
|
60
|
+
command -v jq >/dev/null 2>&1 || { echo "ERROR: fh_gate_exec: jq not found" >&2; exit 10; }
|
|
61
|
+
|
|
62
|
+
FINDINGS='[]'
|
|
63
|
+
E0_STATUS="not-run"; E0_DETAIL=""; E1_STATUS="not-run"; E1_DETAIL=""
|
|
64
|
+
|
|
65
|
+
add_finding() { # grade source location title evidence fix
|
|
66
|
+
FINDINGS=$(jq -c --arg g "$1" --arg s "$2" --arg l "$3" --arg t "$4" --arg e "$5" --arg f "$6" \
|
|
67
|
+
'. + [{grade:$g, source:$s, location:$l, title:$t, evidence:$e, fix:$f}]' <<<"$FINDINGS")
|
|
68
|
+
}
|
|
69
|
+
emit() {
|
|
70
|
+
jq -cn --arg e0s "$E0_STATUS" --arg e0d "$E0_DETAIL" --arg e1s "$E1_STATUS" --arg e1d "$E1_DETAIL" \
|
|
71
|
+
--argjson f "$FINDINGS" '{e0:{status:$e0s,detail:$e0d}, e1:{status:$e1s,detail:$e1d}, findings:$f}'
|
|
72
|
+
exit 0
|
|
73
|
+
}
|
|
74
|
+
not_run_both() { E0_STATUS="not-run"; E0_DETAIL="$1"; E1_STATUS="not-run"; E1_DETAIL="$1"; emit; }
|
|
75
|
+
|
|
76
|
+
_TMO=""
|
|
77
|
+
if command -v gtimeout >/dev/null 2>&1; then _TMO="gtimeout"; elif command -v timeout >/dev/null 2>&1; then _TMO="timeout"; fi
|
|
78
|
+
|
|
79
|
+
# ── what is the change? ──────────────────────────────────────────────────────────────────────────
|
|
80
|
+
could_not_run() { # a step that could not run is a B, never a silent NOT RUN
|
|
81
|
+
add_finding B exec "(setup)" "execution layer did not run — $1" "" "${2:-run fh_gate_exec.sh by hand to see why}"
|
|
82
|
+
not_run_both "NOT RUN ($1)"
|
|
83
|
+
}
|
|
84
|
+
[ -n "$WORK" ] && [ -d "$WORK" ] || could_not_run "work root '${WORK}' is not a directory"
|
|
85
|
+
git -C "$WORK" rev-parse --is-inside-work-tree >/dev/null 2>&1 || not_run_both "NOT RUN (not a git repository)"
|
|
86
|
+
WORK="$(git -C "$WORK" rev-parse --show-toplevel)"
|
|
87
|
+
if ! BASE_SHA=$(git -C "$WORK" rev-parse -q --verify "${BASE_REF}^{commit}" 2>/dev/null); then
|
|
88
|
+
# Not «not applicable»: there is a repository and a change, and this layer could not tell what the change is.
|
|
89
|
+
# That must not leave the verdict free to be PASS — B, with how to fix it.
|
|
90
|
+
add_finding B exec "(base)" "execution layer did not run — base ref '${BASE_REF}' not found" \
|
|
91
|
+
"fh-gate measures the change against FH_GATE_BASE, else merge-base(FH_BASE_BRANCH, HEAD)" "set FH_GATE_BASE (or FH_BASE_BRANCH) to a ref this repository has"
|
|
92
|
+
not_run_both "NOT RUN (base ref '${BASE_REF}' not found)"
|
|
93
|
+
fi
|
|
94
|
+
HEAD_SHA=$(git -C "$WORK" rev-parse -q --verify 'HEAD^{commit}' 2>/dev/null) \
|
|
95
|
+
|| not_run_both "NOT RUN (no HEAD commit)"
|
|
96
|
+
|
|
97
|
+
TMP=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_exec_XXXXXX") || could_not_run "could not create a temporary folder (mktemp failed)" "check TMPDIR and free space"
|
|
98
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
99
|
+
|
|
100
|
+
# The copy = HEAD + the caller's uncommitted tracked changes + untracked, non-ignored files.
|
|
101
|
+
AFTER="$TMP/after"
|
|
102
|
+
copy_fail() {
|
|
103
|
+
E0_STATUS="not-run"; E0_DETAIL="NOT RUN (could not build the copy: $1)"; E1_STATUS="not-run"; E1_DETAIL="$E0_DETAIL"
|
|
104
|
+
add_finding B exec "(copy)" "execution layer did not run — the copy could not be built" "$1" "check the work tree; or set FH_GATE_EXEC=off and say so"
|
|
105
|
+
emit
|
|
106
|
+
}
|
|
107
|
+
git clone -q --shared --no-checkout "$WORK" "$AFTER" >/dev/null 2>&1 || copy_fail "git clone failed"
|
|
108
|
+
git -C "$AFTER" -c advice.detachedHead=false checkout -q --detach "$HEAD_SHA" >/dev/null 2>&1 || copy_fail "checkout of HEAD failed"
|
|
109
|
+
git -C "$WORK" -c core.quotePath=false diff --binary HEAD > "$TMP/overlay.patch" 2>/dev/null || copy_fail "git diff HEAD failed"
|
|
110
|
+
if [ -s "$TMP/overlay.patch" ]; then
|
|
111
|
+
git -C "$AFTER" apply --whitespace=nowarn "$TMP/overlay.patch" >/dev/null 2>&1 || copy_fail "the uncommitted changes did not apply to the copy"
|
|
112
|
+
fi
|
|
113
|
+
( cd "$WORK" && git ls-files -o --exclude-standard -z | tar --null -T - -cf - 2>/dev/null ) | ( cd "$AFTER" && tar -xf - 2>/dev/null ) \
|
|
114
|
+
|| copy_fail "copying untracked files failed"
|
|
115
|
+
|
|
116
|
+
CHANGED=$( { git -C "$AFTER" -c core.quotePath=false diff --name-only "$BASE_SHA" 2>/dev/null
|
|
117
|
+
git -C "$AFTER" -c core.quotePath=false ls-files -o --exclude-standard 2>/dev/null; } | sed '/^$/d' | sort -u)
|
|
118
|
+
[ -n "$CHANGED" ] || not_run_both "NOT RUN (no change against base ${BASE_SHA:0:12})"
|
|
119
|
+
|
|
120
|
+
# ── E0: static class scanners ────────────────────────────────────────────────────────────────────
|
|
121
|
+
if [ ! -f "$SCANNER" ]; then
|
|
122
|
+
E0_STATUS="not-run"; E0_DETAIL="NOT RUN (scanner not shipped here: ${SCANNER##*/})"
|
|
123
|
+
elif [ "$MODE" = plan ]; then
|
|
124
|
+
E0_STATUS="planned"; E0_DETAIL="would run 1 scanner (${SCANNER##*/}) against base ${BASE_SHA:0:12}"
|
|
125
|
+
else
|
|
126
|
+
_e0out=$(cd "$AFTER" && PIPESCAN_REPO="$AFTER" bash "$SCANNER" changed "$BASE_SHA" 2>&1 < /dev/null); _e0rc=$?
|
|
127
|
+
case "$_e0rc" in
|
|
128
|
+
0)
|
|
129
|
+
E0_STATUS="ran"
|
|
130
|
+
if printf '%s\n' "$_e0out" | grep -q 'SKIP'; then
|
|
131
|
+
E0_DETAIL="ran 1 scanner (${SCANNER##*/}) — no changed file in its scope"
|
|
132
|
+
else
|
|
133
|
+
E0_DETAIL="ran 1 scanner (${SCANNER##*/}) — 0 new sites"
|
|
134
|
+
fi ;;
|
|
135
|
+
1)
|
|
136
|
+
E0_STATUS="ran"; _n=0
|
|
137
|
+
# « 🟥 <file> — …» starts a file; « · <line>» are its new sites
|
|
138
|
+
_file=""; _lines=""
|
|
139
|
+
flush() {
|
|
140
|
+
if [ -n "$_file" ]; then
|
|
141
|
+
_n=$((_n + 1))
|
|
142
|
+
add_finding B E0 "$_file" "pipefail early-exit consumer introduced (class scanner ${SCANNER##*/})" \
|
|
143
|
+
"$(printf '%s' "$_lines" | head -c 1500)" \
|
|
144
|
+
"give grep the file directly, use a consumer that reads to EOF (grep -c), or bound the producer (sed -n '1,50p')"
|
|
145
|
+
fi
|
|
146
|
+
}
|
|
147
|
+
while IFS= read -r _l; do
|
|
148
|
+
case "$_l" in
|
|
149
|
+
" 🟥 "*) flush; _file="${_l# 🟥 }"; _file="${_file%% — *}"; _lines="" ;;
|
|
150
|
+
*"· "*) [ -n "$_file" ] && _lines="${_lines}${_l#*· }"$'\n' ;;
|
|
151
|
+
esac
|
|
152
|
+
done <<<"$_e0out"
|
|
153
|
+
flush
|
|
154
|
+
E0_DETAIL="ran 1 scanner (${SCANNER##*/}) — new sites in ${_n} file(s)"
|
|
155
|
+
if [ "$_n" -eq 0 ]; then # rc 1 but nothing parsed: say so, never «0 new»
|
|
156
|
+
add_finding B E0 "(scanner)" "scanner reported new sites this layer could not read" "$(printf '%s' "$_e0out" | tail -c 1200)" "run the scanner by hand"
|
|
157
|
+
E0_DETAIL="ran 1 scanner (${SCANNER##*/}) — rc 1 with output this layer could not read"
|
|
158
|
+
fi ;;
|
|
159
|
+
*)
|
|
160
|
+
E0_STATUS="ran"; E0_DETAIL="ran 1 scanner (${SCANNER##*/}) — INSTRUMENT ERROR rc ${_e0rc}, not measured"
|
|
161
|
+
add_finding B E0 "(scanner)" "class scanner instrument error — E0 not measured" "$(printf '%s' "$_e0out" | tail -c 1200)" \
|
|
162
|
+
"run the scanner's self-test by hand; an instrument error is never «0 new»" ;;
|
|
163
|
+
esac
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
# ── E1: target lanes ─────────────────────────────────────────────────────────────────────────────
|
|
167
|
+
# Each entry is «L<TAB>path» (a discovered lane file, run as `bash -- path`, never through a shell string — a file
|
|
168
|
+
# name is part of the reviewed change and must not be able to run code by its spelling) or «C<TAB>command» (a lane
|
|
169
|
+
# the caller declared in FH_GATE_LANES, run with `bash -c`: the caller wrote it).
|
|
170
|
+
LANES_FILE="$TMP/lanes"; : > "$LANES_FILE"
|
|
171
|
+
DECLARED=0
|
|
172
|
+
TAB=$(printf '\t')
|
|
173
|
+
if [ -n "${FH_GATE_LANES:-}" ]; then
|
|
174
|
+
DECLARED=1
|
|
175
|
+
printf '%s\n' "$FH_GATE_LANES" | sed '/^[[:space:]]*$/d; s/^/C /' > "$LANES_FILE"
|
|
176
|
+
else
|
|
177
|
+
is_lane() { case "$1" in scripts/test_*.sh|*_lanes.sh) return 0 ;; esac; return 1; }
|
|
178
|
+
{ while IFS= read -r f; do
|
|
179
|
+
[ -n "$f" ] && is_lane "$f" && [ -f "$AFTER/$f" ] && printf 'L\t%s\n' "$f"
|
|
180
|
+
done <<<"$CHANGED"
|
|
181
|
+
# rank: 0 = the lane's own name carries the changed file's stem (test_foo_*.sh for foo.sh), 1 = it only names it
|
|
182
|
+
_others=$( while IFS= read -r f; do
|
|
183
|
+
[ -n "$f" ] || continue
|
|
184
|
+
is_lane "$f" && continue
|
|
185
|
+
b="${f##*/}"; stem="${b%.*}"
|
|
186
|
+
for L in "$AFTER"/scripts/test_*.sh "$AFTER"/scripts/*_lanes.sh; do
|
|
187
|
+
[ -f "$L" ] || continue
|
|
188
|
+
rel="${L#"$AFTER"/}"
|
|
189
|
+
[ "$rel" = "$f" ] && continue
|
|
190
|
+
grep -qF -- "$b" "$L" 2>/dev/null || continue
|
|
191
|
+
# (an `if`, not `case`: bash 3.2 misreads a case pattern's `)` inside $( ))
|
|
192
|
+
_rk=1; [[ "${rel##*/}" == *"$stem"* ]] && _rk=0
|
|
193
|
+
printf '%s\t%s\n' "$_rk" "$rel"
|
|
194
|
+
done
|
|
195
|
+
done <<<"$CHANGED" | sort -t "$TAB" -k1,1n -k2,2 | awk -F '\t' '!seen[$2]++ {print "L\t" $2}' )
|
|
196
|
+
[ -n "$_others" ] && printf '%s\n' "$_others"
|
|
197
|
+
} | awk -F '\t' '!seen[$2]++' > "$LANES_FILE"
|
|
198
|
+
fi
|
|
199
|
+
TOTAL=$(grep -c . "$LANES_FILE" 2>/dev/null || true); TOTAL=${TOTAL:-0}
|
|
200
|
+
CAPNOTE=""
|
|
201
|
+
if [ "$TOTAL" -gt "$MAX_LANES" ]; then
|
|
202
|
+
head -n "$MAX_LANES" "$LANES_FILE" > "$TMP/lanes.cap" && mv "$TMP/lanes.cap" "$LANES_FILE"
|
|
203
|
+
CAPNOTE=" (capped at ${MAX_LANES} of ${TOTAL} — FH_GATE_MAX_LANES)"
|
|
204
|
+
fi
|
|
205
|
+
KIND="discovered"; [ "$DECLARED" = 1 ] && KIND="declared"
|
|
206
|
+
RUN_N=$(grep -c . "$LANES_FILE" 2>/dev/null || true); RUN_N=${RUN_N:-0}
|
|
207
|
+
|
|
208
|
+
if [ "$RUN_N" -eq 0 ]; then
|
|
209
|
+
E1_STATUS="not-run"; E1_DETAIL="NOT RUN (no target lane found for this change — declare one with FH_GATE_LANES)"
|
|
210
|
+
elif [ "$MODE" = plan ]; then
|
|
211
|
+
E1_STATUS="planned"; E1_DETAIL="would run ${RUN_N} lane(s), ${KIND}${CAPNOTE}: $(cut -f2- "$LANES_FILE" | paste -sd ';' -)"
|
|
212
|
+
else
|
|
213
|
+
BASECOPY=""
|
|
214
|
+
run_lane() { # dir kind value log → rc (124/137 = did not finish)
|
|
215
|
+
if [ "$2" = L ]; then
|
|
216
|
+
( cd "$1" && env FH_GATE_EXEC=off FH_GATE_NESTED=1 ${_TMO:+$_TMO "$LANE_TIMEOUT"} bash -- "$3" < /dev/null > "$4" 2>&1 )
|
|
217
|
+
else
|
|
218
|
+
( cd "$1" && env FH_GATE_EXEC=off FH_GATE_NESTED=1 ${_TMO:+$_TMO "$LANE_TIMEOUT"} bash -c "$3" < /dev/null > "$4" 2>&1 )
|
|
219
|
+
fi
|
|
220
|
+
}
|
|
221
|
+
dnf_rc() { [ "$1" -eq 124 ] || [ "$1" -eq 137 ]; }
|
|
222
|
+
red=0; pre=0; dnf=0; nocmp=0; n=0
|
|
223
|
+
while IFS="$TAB" read -r kind val; do
|
|
224
|
+
[ -n "$val" ] || continue
|
|
225
|
+
n=$((n + 1)); log="$TMP/lane_$n.log"
|
|
226
|
+
label="$val"; [ "$kind" = L ] && label="bash $val"
|
|
227
|
+
run_lane "$AFTER" "$kind" "$val" "$log"; rc=$?
|
|
228
|
+
[ "$rc" -eq 0 ] && continue
|
|
229
|
+
tailtxt=$(tail -n 15 "$log" 2>/dev/null | head -c 1500)
|
|
230
|
+
if dnf_rc "$rc"; then
|
|
231
|
+
dnf=$((dnf + 1))
|
|
232
|
+
add_finding B E1 "$label" "lane did not finish within ${LANE_TIMEOUT}s — not green" "$tailtxt" "raise FH_LANE_TIMEOUT or run the lane by hand"
|
|
233
|
+
continue
|
|
234
|
+
fi
|
|
235
|
+
# red after the change: was it red at the base too?
|
|
236
|
+
if [ -z "$BASECOPY" ]; then
|
|
237
|
+
BASECOPY="$TMP/base"
|
|
238
|
+
git clone -q --shared --no-checkout "$WORK" "$BASECOPY" >/dev/null 2>&1 \
|
|
239
|
+
&& git -C "$BASECOPY" -c advice.detachedHead=false checkout -q --detach "$BASE_SHA" >/dev/null 2>&1 \
|
|
240
|
+
|| BASECOPY="FAILED"
|
|
241
|
+
fi
|
|
242
|
+
if [ "$BASECOPY" = "FAILED" ]; then
|
|
243
|
+
red=$((red + 1))
|
|
244
|
+
add_finding A E1 "$label" "lane red after this change (the base copy could not be built, so not compared)" "$tailtxt" "fix the change or the lane"
|
|
245
|
+
elif [ "$kind" = L ] && [ ! -f "$BASECOPY/$val" ]; then
|
|
246
|
+
red=$((red + 1))
|
|
247
|
+
add_finding A E1 "$label" "new lane, red after this change (rc $rc)" "$tailtxt" "fix the change or the lane"
|
|
248
|
+
else
|
|
249
|
+
run_lane "$BASECOPY" "$kind" "$val" "$TMP/lane_${n}_base.log"; brc=$?
|
|
250
|
+
if [ "$brc" -eq 0 ]; then
|
|
251
|
+
red=$((red + 1))
|
|
252
|
+
add_finding A E1 "$label" "this change turns the lane red (rc $rc; green at base ${BASE_SHA:0:12})" "$tailtxt" "fix the change, or the lane if the lane is wrong"
|
|
253
|
+
elif [ "$brc" -eq 127 ]; then
|
|
254
|
+
# a declared lane whose command does not exist at the base (bash: 127) is new with this change, not «red before»
|
|
255
|
+
red=$((red + 1))
|
|
256
|
+
add_finding A E1 "$label" "new lane (not found at base ${BASE_SHA:0:12}), red after this change (rc $rc)" "$tailtxt" "fix the change or the lane"
|
|
257
|
+
elif dnf_rc "$brc"; then
|
|
258
|
+
# red now, and the base run did not finish: «red before» is not established — never C
|
|
259
|
+
nocmp=$((nocmp + 1))
|
|
260
|
+
add_finding B E1 "$label" "lane red after this change (rc $rc); the base run did not finish within ${LANE_TIMEOUT}s, so not compared" "$tailtxt" "raise FH_LANE_TIMEOUT or run the lane at the base by hand"
|
|
261
|
+
else
|
|
262
|
+
pre=$((pre + 1))
|
|
263
|
+
add_finding C E1 "$label" "lane red before this change too (rc $rc here, rc $brc at base ${BASE_SHA:0:12})" "$tailtxt" "pre-existing — not introduced by this change"
|
|
264
|
+
fi
|
|
265
|
+
fi
|
|
266
|
+
done < "$LANES_FILE"
|
|
267
|
+
E1_STATUS="ran"
|
|
268
|
+
E1_DETAIL="ran ${n} lane(s), ${KIND}${CAPNOTE} — ${red} red, ${pre} red before, ${dnf} did not finish"
|
|
269
|
+
[ "$nocmp" -gt 0 ] && E1_DETAIL="${E1_DETAIL}, ${nocmp} red but not compared (base did not finish)"
|
|
270
|
+
[ -z "$_TMO" ] && E1_DETAIL="${E1_DETAIL} (no timeout binary — lanes were not time-bounded)"
|
|
271
|
+
fi
|
|
272
|
+
emit
|
|
@@ -227,6 +227,23 @@ if [ -d "$_AUDIT_DIR" ] && fh_cadence_due "$_FH_HOOK_SRC"; then
|
|
|
227
227
|
fi
|
|
228
228
|
fi
|
|
229
229
|
|
|
230
|
+
# 1-b1) Nightly-job heartbeat (2026-11-20 weekly audit) — an installed nightly job that left no output
|
|
231
|
+
# file says nothing: frontier-digest's autopilot went 25 nights SKIPPED unread (10-11..11-04), and on
|
|
232
|
+
# 11-18 live-eval + selfdev produced nothing (a planned pause recorded only in the lease archive, so the
|
|
233
|
+
# audit first read it as a failure). Dates only, days in a recorded pause (tracks/_meta/job_pauses.tsv)
|
|
234
|
+
# set apart; advisory, silent when every day has output or no job is installed (a fresh clone or a
|
|
235
|
+
# machine without the plists prints nothing). frontier-digest is checked by its own block above.
|
|
236
|
+
# No --meta: the script reads the MAIN checkout's tracks/_meta, so a worktree session (empty tracks/)
|
|
237
|
+
# does not report every job missing. Bounded by a 5 s perl alarm (macOS has no coreutils timeout);
|
|
238
|
+
# without perl it runs unbounded rather than not at all.
|
|
239
|
+
if [ -f "$FH/scripts/job_heartbeat.py" ] && fh_cadence_due "$_FH_HOOK_SRC"; then
|
|
240
|
+
if command -v perl >/dev/null 2>&1; then
|
|
241
|
+
perl -e 'alarm shift @ARGV; exec @ARGV' 5 python3 "$FH/scripts/job_heartbeat.py" 2>/dev/null || true
|
|
242
|
+
else
|
|
243
|
+
python3 "$FH/scripts/job_heartbeat.py" 2>/dev/null || true
|
|
244
|
+
fi
|
|
245
|
+
fi
|
|
246
|
+
|
|
230
247
|
# 1-b2) 흡수 대기열 (2026-10-28) — 바깥에서 온 «가져올 것» (digest 후보 · 외부 자산 감사의 가져올
|
|
231
248
|
# 목록 · 운영자가 건넨 링크) 이 열린 채 남아 있으면 한 줄. MEASURED: techwriting 감사의 «가져올 것 5»
|
|
232
249
|
# 가 하루 동안 아무도 안 집었고, 다음 날 운영자가 직접 발표 요약을 들고 와서야 ko-tech-writer 가
|
package/scripts/finding_fleet.sh
CHANGED
|
@@ -34,7 +34,8 @@ CODEX="${FH_CODEX_BIN:-$(command -v codex 2>/dev/null || echo "$HOME/.npm-global
|
|
|
34
34
|
# A function named agy (exported into this shell) would outrank PATH and fool `command -v`: drop it first.
|
|
35
35
|
unset -f agy codex 2>/dev/null || true
|
|
36
36
|
AGY="${FH_AGY_BIN:-$(command -v agy 2>/dev/null || echo "$HOME/.local/bin/agy")}"
|
|
37
|
-
# Every agy launch goes through the isolation guard (refuses unless FH_AGY_ISOLATION=container|os-user
|
|
37
|
+
# Every agy launch goes through the isolation guard (refuses unless FH_AGY_ISOLATION=container|os-user, or
|
|
38
|
+
# no-tools-agent — a tools: [] agent whose every run is checked; see agy_launch_guard.sh).
|
|
38
39
|
# How: a shim named `agy` in a private temp dir is put FIRST on PATH, and the fleet token AGY_BIN
|
|
39
40
|
# becomes that shim's path. So a default row, a custom row that writes AGY_BIN (quoted or not, under
|
|
40
41
|
# `timeout`/`env`), and a custom row that calls `agy` by name all reach the guard; and no path chosen by
|
|
@@ -20,7 +20,8 @@ set -uo pipefail
|
|
|
20
20
|
|
|
21
21
|
CODEX="${FH_CODEX_BIN:-$(command -v codex 2>/dev/null || echo "$HOME/.npm-global/bin/codex")}"
|
|
22
22
|
AGY="${FH_AGY_BIN:-$(command -v agy 2>/dev/null || echo "$HOME/.local/bin/agy")}"
|
|
23
|
-
# Every agy launch goes through the isolation guard (refuses unless FH_AGY_ISOLATION=container|os-user
|
|
23
|
+
# Every agy launch goes through the isolation guard (refuses unless FH_AGY_ISOLATION=container|os-user, or
|
|
24
|
+
# no-tools-agent — a tools: [] agent whose every run is checked; see agy_launch_guard.sh).
|
|
24
25
|
AGY_GUARD="$(cd "$(dirname "$0")" && pwd)/agy_launch_guard.sh"
|
|
25
26
|
# codex goes through the lighter guard: refused when the prompt, an argument or the cwd names a company root
|
|
26
27
|
CODEX_GUARD="$(cd "$(dirname "$0")" && pwd)/codex_launch_guard.sh"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# tidy-notes (cartridge)
|
|
2
|
+
|
|
3
|
+
Release notes from a git range. Refactored from an invented heavy skill (`../../heavy/release-notes-pro/`).
|
|
4
|
+
Kind: activity — the request names the job, so the skill description routes it.
|
|
5
|
+
|
|
6
|
+
| Piece of the old skill | Where it went |
|
|
7
|
+
|---|---|
|
|
8
|
+
| grouping commits, PR citations, the BREAKING CHANGE rule | craft — `skills/tidy-notes/SKILL.md` |
|
|
9
|
+
| cited PRs must exist in the log (`check_refs.py`) | check — known pair in `scripts/test_check_refs.py` |
|
|
10
|
+
| no hand-off unless the check exited 0 | craft — step 5 (the cartridge's own rule, stricter than the core) |
|
|
11
|
+
| its own permission hook and the script that installed it (P1 P2 P3) | deleted — the core owns permissions and settings |
|
|
12
|
+
| its own confirm before shipping, and the ship script (P4 P5) | deleted — the skill ends with a ready: hand-off; the session ships under the core gate |
|
|
13
|
+
| tool missing stops it, data stays in, unmeasured is not a pass (P6) | deleted — general floor rules the core holds |
|
|
14
|
+
| its verdict is final, skipping the other hooks (P7) | deleted — a cartridge only adds |
|
|
15
|
+
|
|
16
|
+
Without the core, this loses the gate on the hand-off: a standalone user runs the ready: commands with nothing asking.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Every (#N) cited in the notes must appear in the git log text. rc 0 all found, 1 missing, 2 unreadable.
|
|
3
|
+
import re, sys
|
|
4
|
+
try:
|
|
5
|
+
notes = open(sys.argv[1], encoding="utf-8").read()
|
|
6
|
+
log = open(sys.argv[2], encoding="utf-8").read()
|
|
7
|
+
except (IndexError, OSError) as e:
|
|
8
|
+
print("UNMEASURED: %s" % e); sys.exit(2)
|
|
9
|
+
missing = sorted(set(re.findall(r"\(#(\d+)\)", notes)) - set(re.findall(r"#(\d+)", log)), key=int)
|
|
10
|
+
for n in missing:
|
|
11
|
+
print("MISSING #%s" % n)
|
|
12
|
+
sys.exit(1 if missing else 0)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Known pair for check_refs.py: one input that must pass (rc 0), one that must fail (rc 1), plus unreadable (rc 2).
|
|
3
|
+
import os, subprocess, sys, tempfile
|
|
4
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
5
|
+
CHECK = os.path.join(HERE, "check_refs.py")
|
|
6
|
+
LOG = "a1b2c3 feat: export button (#12)\nd4e5f6 fix: crash on empty list (#15)\n"
|
|
7
|
+
def run(notes, log=LOG):
|
|
8
|
+
d = tempfile.mkdtemp()
|
|
9
|
+
n, l = os.path.join(d, "notes.md"), os.path.join(d, "log.txt")
|
|
10
|
+
open(n, "w").write(notes); open(l, "w").write(log)
|
|
11
|
+
return subprocess.run([sys.executable, CHECK, n, l], capture_output=True, text=True)
|
|
12
|
+
cases = [
|
|
13
|
+
("pass: every cited PR is in the log", run("- Export button (#12)\n- Crash fix (#15)\n"), 0, ""),
|
|
14
|
+
("fail: #99 is not in the log", run("- Export button (#12)\n- Ghost (#99)\n"), 1, "MISSING #99"),
|
|
15
|
+
]
|
|
16
|
+
bad = 0
|
|
17
|
+
for name, r, rc, needle in cases:
|
|
18
|
+
ok = r.returncode == rc and needle in r.stdout
|
|
19
|
+
bad += not ok
|
|
20
|
+
print("%s %s (rc=%d)" % ("PASS" if ok else "FAIL", name, r.returncode))
|
|
21
|
+
r = subprocess.run([sys.executable, CHECK, "/nonexistent/notes.md", "/nonexistent/log.txt"], capture_output=True, text=True)
|
|
22
|
+
ok = r.returncode == 2; bad += not ok
|
|
23
|
+
print("%s unreadable input is UNMEASURED (rc=%d)" % ("PASS" if ok else "FAIL", r.returncode))
|
|
24
|
+
sys.exit(1 if bad else 0)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tidy-notes
|
|
3
|
+
description: Writes release notes from a git range — «write the release notes for v2.4», «does every bullet in these notes cite a real PR?», «how many bullets have no PR number?»
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Release notes from a git range
|
|
7
|
+
|
|
8
|
+
1. Read `git log <prev-tag>..HEAD --oneline` and group commits by type: Features, Fixes, Breaking changes.
|
|
9
|
+
2. Every bullet cites its PR number as `(#123)`. A bullet without a PR number is moved to «Other».
|
|
10
|
+
3. A commit whose body says `BREAKING CHANGE:` goes under Breaking changes even when its type is `fix`.
|
|
11
|
+
4. Run `python3 <this cartridge>/scripts/check_refs.py notes.md log.txt`. rc 0 = every cited PR is in the log,
|
|
12
|
+
rc 1 = it prints each `MISSING #N` (fix the bullet and run it again), rc 2 = the check did not run: say the notes are
|
|
13
|
+
not checked.
|
|
14
|
+
5. Only when step 4 exited 0, end with one hand-off line and stop:
|
|
15
|
+
`ready: git tag <tag> && git push origin <tag> && gh release create <tag> --notes-file notes.md`
|
|
16
|
+
This cartridge does not run those commands or ask about them; every other check stays in place.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Worked example for knowledge/shared/harness-core/heavy_skill_to_cartridge.md — the «after» of the invented
|
|
2
|
+
# release-notes-pro heavy skill (scripts/fixtures/heavy_skill_smell/heavy/). Not an installed module.
|
|
3
|
+
id: tidy-notes
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
provides:
|
|
6
|
+
skills: [tidy-notes]
|
|
7
|
+
agents: []
|
|
8
|
+
hooks: []
|
|
9
|
+
verdicts: [] # check_refs.py exits 0 only when every cited PR is found — but it reports, the caller decides
|
|
10
|
+
adds_constraints: []
|
|
11
|
+
touches_irreversible: none # shape (b): ends with a ready: hand-off, runs nothing irreversible
|
|
12
|
+
data_class: public
|
|
13
|
+
requires:
|
|
14
|
+
modules: []
|
|
15
|
+
core_min: 3.0.0
|
|
16
|
+
calibration:
|
|
17
|
+
command: python3 scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py
|
|
18
|
+
files:
|
|
19
|
+
- scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/check_refs.py
|
|
20
|
+
- scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docs-publisher-pro
|
|
3
|
+
description: Builds the product docs from markdown and publishes them as an npm package — «build the docs», «publish the docs for 3.1», «are there broken links in the docs?»
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Docs, built and published
|
|
7
|
+
|
|
8
|
+
## Building
|
|
9
|
+
1. Every page in `docs/` needs a front-matter `title:`. A page without one is listed and the build stops there.
|
|
10
|
+
2. Stamp the version: replace `{{version}}` in every page with the value of `package.json` `version`.
|
|
11
|
+
3. Run `python3 scripts/check_links.py docs/` — every relative link `[x](path.md)` must point to a file that exists.
|
|
12
|
+
Anchors (`#section`) are checked against the headings of the target page.
|
|
13
|
+
4. Bundle `docs/` into `dist/docs/`.
|
|
14
|
+
|
|
15
|
+
## House rules (enforced by this skill)
|
|
16
|
+
- Before `npm publish`, confirm with the user and wait for an explicit «yes».
|
|
17
|
+
- If the link checker tool is unavailable, abort the release — fail closed.
|
|
18
|
+
- Internal data must never go outside the company: strip internal hostnames from every page before bundling.
|
|
19
|
+
- Our link check is the final verdict: disable other pre-push checks while publishing (`git push --no-verify`).
|
|
20
|
+
|
|
21
|
+
## Publishing
|
|
22
|
+
`bash scripts/publish.sh` — asks, bumps nothing, runs `npm publish`, pushes the docs tag.
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
`bash scripts/setup.sh` registers our guard so nobody publishes with broken links.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Relative links in docs/*.md must point to existing files; #anchors must match a heading in the target.
|
|
3
|
+
# rc 0 all good, 1 broken links listed, 2 could not read the folder.
|
|
4
|
+
import os, re, sys
|
|
5
|
+
root = sys.argv[1] if len(sys.argv) > 1 else "docs"
|
|
6
|
+
if not os.path.isdir(root):
|
|
7
|
+
print("UNMEASURED: no folder %s" % root); sys.exit(2)
|
|
8
|
+
def slug(h): return re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-")
|
|
9
|
+
bad = []
|
|
10
|
+
for d, _, fs in os.walk(root):
|
|
11
|
+
for f in fs:
|
|
12
|
+
if not f.endswith(".md"):
|
|
13
|
+
continue
|
|
14
|
+
p = os.path.join(d, f)
|
|
15
|
+
for m in re.finditer(r"\]\(([^)#:]+\.md)?(#[^)]+)?\)", open(p, encoding="utf-8").read()):
|
|
16
|
+
target = os.path.normpath(os.path.join(d, m.group(1))) if m.group(1) else p
|
|
17
|
+
if not os.path.exists(target):
|
|
18
|
+
bad.append("%s -> %s (missing file)" % (p, m.group(1))); continue
|
|
19
|
+
if m.group(2):
|
|
20
|
+
heads = [slug(h) for h in re.findall(r"^#+\s+(.*)$", open(target, encoding="utf-8").read(), re.M)]
|
|
21
|
+
if m.group(2)[1:] not in heads:
|
|
22
|
+
bad.append("%s -> %s%s (missing anchor)" % (p, m.group(1) or "", m.group(2)))
|
|
23
|
+
for b in bad:
|
|
24
|
+
print("BROKEN " + b)
|
|
25
|
+
sys.exit(1 if bad else 0)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
v="$(node -p 'require("./package.json").version')"
|
|
4
|
+
read -p "Publish docs $v? [y/N] " ok
|
|
5
|
+
[ "$ok" = "y" ] || exit 1
|
|
6
|
+
python3 scripts/check_links.py docs/ || { touch .linkcheck_failed; exit 1; }
|
|
7
|
+
rm -f .linkcheck_failed
|
|
8
|
+
npm publish --access public
|
|
9
|
+
git push origin "docs-$v"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Refuses `npm publish` when the last link check failed. Our own gate.
|
|
3
|
+
import json, os, sys
|
|
4
|
+
cmd = json.load(sys.stdin).get("tool_input", {}).get("command", "")
|
|
5
|
+
if "npm publish" in cmd and os.path.exists(".linkcheck_failed"):
|
|
6
|
+
print(json.dumps({"decision": "block", "reason": "broken links — fix them before publishing"}))
|