@chrono-meta/fh-gate 3.42.0 → 3.44.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/regression/probes_live.yaml +16 -8
- package/.claude/rules/fh_4axis_gate.md +8 -0
- package/.claude-plugin/marketplace.json +4 -4
- package/AGENTS.md +9 -0
- package/README.ja.md +2 -0
- package/README.ko.md +2 -0
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/docs/HOW_FH_DIFFERS.en.md +37 -0
- package/docs/HOW_FH_DIFFERS.md +39 -0
- package/docs/USER_GUIDE.md +208 -2
- package/docs/model_tier_expectations.md +8 -4
- package/knowledge/shared/harness-core/claude_md_full_reference.md +10 -0
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +18 -0
- package/knowledge/shared/harness-core/fh_module_contract.md +19 -0
- package/knowledge/shared/harness-core/governance_engineering_definition.md +16 -0
- package/knowledge/shared/harness-core/measurement-integrity-checklist.md +24 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +42 -0
- package/knowledge/shared/plugin-catalog/recommended_plugins.md +53 -9
- package/package.json +13 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +49 -14
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +60 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_negative.md +30 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_positive.md +56 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +55 -2
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +45 -1
- package/plugins/fh-meta/skills/edit-manifest/SKILL.md +14 -1
- package/plugins/fh-meta/skills/harvest-loop/SKILL.md +1 -1
- package/plugins/fh-meta/skills/meta-prompt-builder/SKILL.md +19 -0
- package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
- package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +8 -4
- 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 +49 -0
- package/scripts/agy_remote_run.sh +187 -0
- package/scripts/capability_registry_check.sh +15 -2
- package/scripts/codex_launch_guard.sh +87 -0
- package/scripts/finding_fleet.sh +35 -2
- package/scripts/finding_verifier.sh +6 -2
- package/scripts/ko_tech_writer_calibrate.py +88 -1
- package/scripts/live_eval_trace.py +141 -0
- package/scripts/package_coverage_check.sh +7 -0
- package/scripts/pr_merge_verified.sh +7 -0
- package/scripts/prepush_guard_check.sh +33 -20
- package/scripts/probe_live_eval.sh +6 -3
- package/scripts/probe_live_eval_lib.py +92 -2
- package/scripts/remote_marker_gate.sh +56 -0
- package/scripts/selfcheck.sh +58 -2
- package/scripts/session_checklist.py +109 -5
- package/scripts/session_close_check.sh +16 -0
- package/scripts/sidecar_calibrate.sh +10 -2
- package/scripts/sidecar_wait.sh +21 -1
- package/scripts/sim_isolated_run.sh +17 -2
- package/scripts/test_agy_launch_guard_lanes.sh +227 -0
- package/scripts/test_agy_remote_run_lanes.sh +228 -0
- package/scripts/test_codex_launch_guard_lanes.sh +138 -0
- package/scripts/test_finding_pipeline_lanes.sh +6 -2
- package/scripts/test_fixture_guard_coverage_lanes.sh +71 -10
- package/scripts/test_live_eval_trace_lanes.sh +191 -0
- package/scripts/test_meta_prompt_restate_lanes.sh +36 -0
- package/scripts/test_mutation_probe_lanes.sh +26 -6
- package/scripts/test_pr_merge_verified_lanes.sh +23 -0
- package/scripts/test_preprep_speech_coach_lanes.sh +18 -2
- package/scripts/test_prepush_guard_failure_visibility_lanes.sh +152 -0
- package/scripts/test_remote_marker_gate_lanes.sh +96 -0
- package/scripts/test_session_checklist_lanes.sh +205 -0
- package/scripts/test_session_close_lanes.sh +7 -0
- package/scripts/test_sidecar_calibrate_lanes.sh +4 -0
- package/scripts/test_sidecar_wait_stdin.sh +18 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Read a `claude -p --output-format stream-json --verbose` trace — stdlib only.
|
|
3
|
+
|
|
4
|
+
Why (2026-11-14, FH-3): every live-eval scorer grepped the reply TEXT. A reply that says «I will read
|
|
5
|
+
CATALOG.md first» and a session that actually read it scored the same, so the 12/12 PASS measured
|
|
6
|
+
mentions. The runner now keeps the event stream (`<arm>_r<n>.stream.jsonl`, opt-in `--trace` in
|
|
7
|
+
sim_isolated_run.sh), and a probe may declare `behave:` — an observable tool call — next to its
|
|
8
|
+
`expect_re`.
|
|
9
|
+
|
|
10
|
+
Two uses:
|
|
11
|
+
extract <stream.jsonl> <out.txt> <tools.txt> (runner) write the final result text and the init
|
|
12
|
+
tool/MCP/plugin inventory. Exit 3 on a stream that has no parseable result event — never an empty
|
|
13
|
+
«the session said nothing» (same rule as sim_isolated_run.sh's turns path).
|
|
14
|
+
library: parse_stream(path) · behave_hit(trace, spec) · inventory(trace)
|
|
15
|
+
|
|
16
|
+
`behave:` grammar (one per probe, value is an ERE, no colon by probes_live.yaml convention):
|
|
17
|
+
read=<re> some SUCCESSFUL Read (file_path) or Grep (path) call matches — Python `re`, not POSIX
|
|
18
|
+
first_read=<re> the FIRST Read/Grep/Glob call of the top-level session is that successful call
|
|
19
|
+
Credited calls: top-level only (a subagent's call, parent_tool_use_id set, is not the arm's action),
|
|
20
|
+
with a matching tool_result that is not is_error (a denied or failed Read did not read anything).
|
|
21
|
+
Glob and a Grep `pattern` never count as reading a file. Residual: «first» is emission order; two
|
|
22
|
+
calls issued in one parallel batch are not ordered by completion.
|
|
23
|
+
"""
|
|
24
|
+
import json, re, sys
|
|
25
|
+
|
|
26
|
+
FILE_TOOLS = ('Read', 'Grep', 'Glob')
|
|
27
|
+
READ_KEYS = {'Read': ('file_path',), 'Grep': ('path',)}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def parse_stream(path):
|
|
31
|
+
"""{'result': str|None, 'tools': [..]|None, 'mcp': [..]|None, 'calls': [(name, input)]}.
|
|
32
|
+
None when the file is absent/unreadable. A missing init event leaves tools=None (UNKNOWN,
|
|
33
|
+
never «no tools»)."""
|
|
34
|
+
try:
|
|
35
|
+
lines = open(path, encoding='utf-8').read().splitlines()
|
|
36
|
+
except (OSError, UnicodeDecodeError):
|
|
37
|
+
return None
|
|
38
|
+
out = {'result': None, 'tools': None, 'mcp': None, 'plugins': None, 'calls': [], 'damaged': 0, 'ok_ids': set()}
|
|
39
|
+
inits = [] # plugin set of every init event, in order
|
|
40
|
+
for ln in lines:
|
|
41
|
+
ln = ln.strip()
|
|
42
|
+
if not ln:
|
|
43
|
+
continue
|
|
44
|
+
try:
|
|
45
|
+
ev = json.loads(ln)
|
|
46
|
+
except ValueError:
|
|
47
|
+
out['damaged'] += 1 # a skipped line could hide the real first call
|
|
48
|
+
continue
|
|
49
|
+
if not isinstance(ev, dict):
|
|
50
|
+
continue
|
|
51
|
+
t = ev.get('type')
|
|
52
|
+
if t == 'system' and ev.get('subtype') == 'init':
|
|
53
|
+
if isinstance(ev.get('tools'), list):
|
|
54
|
+
out['tools'] = sorted(str(x) for x in ev['tools'])
|
|
55
|
+
if isinstance(ev.get('mcp_servers'), list):
|
|
56
|
+
out['mcp'] = sorted(('%s:%s' % (s.get('name'), s.get('status'))) if isinstance(s, dict) else str(s)
|
|
57
|
+
for s in ev['mcp_servers'])
|
|
58
|
+
# Plugins (2026-11-15): arms load the operator's user/builtin/synced plugins from the real
|
|
59
|
+
# HOME, and the set can change between reps (a builtin rolled out mid-run; an auto-update
|
|
60
|
+
# moved a version). name, source and version — never the path (it carries the home directory).
|
|
61
|
+
# Key absent → None (UNKNOWN, never «no plugins»).
|
|
62
|
+
# Each entry is a JSON array [name, source, version] so no separator inside a name can make
|
|
63
|
+
# two different sets render alike; a non-object entry is {"raw": ...}, which never equals
|
|
64
|
+
# an array. A set: duplicates and order do not matter. Every init is kept (see below).
|
|
65
|
+
inits.append(None if not isinstance(ev.get('plugins'), list) else sorted(set(
|
|
66
|
+
json.dumps([p.get('name'), p.get('source'), p.get('version')], ensure_ascii=False)
|
|
67
|
+
if isinstance(p, dict) else json.dumps({'raw': p}, ensure_ascii=False)
|
|
68
|
+
for p in ev['plugins'])))
|
|
69
|
+
elif t == 'assistant':
|
|
70
|
+
if ev.get('parent_tool_use_id'):
|
|
71
|
+
continue
|
|
72
|
+
for c in (ev.get('message') or {}).get('content') or []:
|
|
73
|
+
if isinstance(c, dict) and c.get('type') == 'tool_use':
|
|
74
|
+
out['calls'].append((str(c.get('name', '')), c.get('input') or {}, c.get('id')))
|
|
75
|
+
elif t == 'user':
|
|
76
|
+
for c in (ev.get('message') or {}).get('content') or []:
|
|
77
|
+
if isinstance(c, dict) and c.get('type') == 'tool_result' and not c.get('is_error'):
|
|
78
|
+
out['ok_ids'].add(c.get('tool_use_id'))
|
|
79
|
+
elif t == 'result':
|
|
80
|
+
if ev.get('subtype') not in (None, 'success') or ev.get('is_error'):
|
|
81
|
+
out['damaged'] += 1 # an error result is not a finished session
|
|
82
|
+
r = ev.get('result')
|
|
83
|
+
out['result'] = r if isinstance(r, str) else ('' if r is None else json.dumps(r, ensure_ascii=False))
|
|
84
|
+
# One init (the normal single-shot stream): its set. Several inits that agree: that set. Several
|
|
85
|
+
# that disagree: the whole sequence, so a later init can never erase an earlier mismatch (codex R1).
|
|
86
|
+
if inits:
|
|
87
|
+
out['plugins'] = inits[0] if all(x == inits[0] for x in inits) else \
|
|
88
|
+
[json.dumps({'inits': inits}, ensure_ascii=False)]
|
|
89
|
+
return out
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def inventory(trace):
|
|
93
|
+
"""One comparable string for the arm's tool/MCP/plugin surface, or None when the init event was
|
|
94
|
+
absent. An init without a plugin list reads plugins=UNKNOWN, so it never equals an arm that has one."""
|
|
95
|
+
if trace is None or trace['tools'] is None:
|
|
96
|
+
return None
|
|
97
|
+
plug = 'UNKNOWN' if trace.get('plugins') is None else ','.join(trace['plugins'])
|
|
98
|
+
return 'tools=' + ','.join(trace['tools']) + ' | mcp=' + ','.join(trace['mcp'] or []) + ' | plugins=' + plug
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _read_hit(call, trace, pat):
|
|
102
|
+
name, inp, cid = call
|
|
103
|
+
if cid not in trace['ok_ids'] or not isinstance(inp, dict):
|
|
104
|
+
return False
|
|
105
|
+
return any(pat.search(str(inp[k])) for k in READ_KEYS.get(name, ()) if k in inp)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def parse_behave(spec):
|
|
109
|
+
"""'first_read=CATALOG' -> ('first_read', compiled). ValueError on anything else (a typo must
|
|
110
|
+
not silently become «no behaviour declared»)."""
|
|
111
|
+
m = re.match(r'^(read|first_read)=(.+)$', (spec or '').strip())
|
|
112
|
+
if not m:
|
|
113
|
+
raise ValueError('behave %r is not read=<re> or first_read=<re>' % spec)
|
|
114
|
+
return m.group(1), re.compile(m.group(2))
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def behave_hit(trace, spec):
|
|
118
|
+
"""True/False whether the trace shows the declared action. Caller handles trace None."""
|
|
119
|
+
kind, pat = parse_behave(spec)
|
|
120
|
+
file_calls = [c for c in trace['calls'] if c[0] in FILE_TOOLS]
|
|
121
|
+
if kind == 'first_read':
|
|
122
|
+
return bool(file_calls) and _read_hit(file_calls[0], trace, pat)
|
|
123
|
+
return any(_read_hit(c, trace, pat) for c in file_calls)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _extract(src, dst_txt, dst_tools):
|
|
127
|
+
tr = parse_stream(src)
|
|
128
|
+
if tr is None or tr['result'] is None or tr['damaged']:
|
|
129
|
+
open(dst_txt, 'w', encoding='utf-8').write('')
|
|
130
|
+
open(dst_tools, 'w', encoding='utf-8').write('UNKNOWN (no result event, error result or damaged stream)\n')
|
|
131
|
+
return 3
|
|
132
|
+
open(dst_txt, 'w', encoding='utf-8').write(tr['result'])
|
|
133
|
+
open(dst_tools, 'w', encoding='utf-8').write((inventory(tr) or 'UNKNOWN (no init event)') + '\n')
|
|
134
|
+
return 0
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if __name__ == '__main__':
|
|
138
|
+
if len(sys.argv) == 5 and sys.argv[1] == 'extract':
|
|
139
|
+
sys.exit(_extract(*sys.argv[2:5]))
|
|
140
|
+
print(__doc__, file=sys.stderr)
|
|
141
|
+
sys.exit(2)
|
|
@@ -55,6 +55,13 @@ ACCEPTED_ABSENT=(
|
|
|
55
55
|
# public cycle (docs/ABLATION_CYCLE.md, not shipped either) goes to npm is an open operator decision.
|
|
56
56
|
"scripts/ablation_nominate.py"
|
|
57
57
|
"scripts/test_ablation_nominate_lanes.sh"
|
|
58
|
+
# 2026-11-14 — the verdict renderer the loop's ABLATION_STEPS points at. Same loop, same scope.
|
|
59
|
+
"scripts/ablation_verdict.py"
|
|
60
|
+
"scripts/test_ablation_verdict_lanes.sh"
|
|
61
|
+
# 2026-11-15 — builder Context Card file-role check (FH-6). Hub pilot: whether consumers get it is a §7 ship
|
|
62
|
+
# decision for the operator, and the dispatch doc that names it is hub-local practice today.
|
|
63
|
+
"scripts/builder_card_files_check.py"
|
|
64
|
+
"scripts/test_builder_card_files_lanes.sh"
|
|
58
65
|
"docs/ABLATION_CYCLE.md"
|
|
59
66
|
# 2026-11-07 — lease-record channel (AQ-20261107-11). It writes this hub's operator-local lease file; a consumer
|
|
60
67
|
# has no such file and no such convention, so shipping it would ship a tool with nothing to act on.
|
|
@@ -183,6 +183,13 @@ if [ -n "$_changed" ]; then
|
|
|
183
183
|
[ "$_hit" -eq 1 ] || echo "⚠️ --rerun mentions none of this PR's $(printf '%s\n' "$_changed" | wc -l | tr -d ' ') changed file(s) (nor any script it names) — it may not exercise the change. Advisory only; merging continues." >&2
|
|
184
184
|
fi
|
|
185
185
|
|
|
186
|
+
# 1c. defect-path prompt — ONE LINE, PRINT ONLY (never changes rc, runs nothing, checks nothing). The script cannot know
|
|
187
|
+
# the path a defect travels, so it does not judge coverage; it asks the merging session to say it (2026-11-14 harvest H2:
|
|
188
|
+
# #316's control was green on main because HOME held a space and the lane ran elsewhere). Quiet when every changed file is
|
|
189
|
+
# a doc (*.md / docs/) or a lane (scripts/test_*) — those PRs have no defect path to name, and the line would be noise.
|
|
190
|
+
_code=$(printf '%s\n' "$_changed" | grep -vE '(\.md$|^docs/|(^|/)test_[^/]*$)' | grep -c . )
|
|
191
|
+
[ "${_code:-0}" -gt 0 ] && echo "🔎 before merging: name the path the defect travels — does this --rerun lane traverse it, and was its control red on the UNFIXED target via that same path? (prompt only — nothing was checked; merging continues)" >&2
|
|
192
|
+
|
|
186
193
|
# 2. merge
|
|
187
194
|
# 🟥 cross-family W1: pin the merge to the head we RECORDED. Without it, a push landing between the
|
|
188
195
|
# record and the merge gets squashed in unverified, and «merged and verified» describes a commit
|
|
@@ -41,6 +41,18 @@ esac
|
|
|
41
41
|
HOOK="$WORK/hook"
|
|
42
42
|
|
|
43
43
|
FAILED=0
|
|
44
|
+
# Each pair's name, exit code and elapsed time when it breaks. The BLOCKED line at the end names them,
|
|
45
|
+
# because a caller that shows only the last lines of this output (selfcheck did: tail -12) otherwise
|
|
46
|
+
# reads «a known pair broke» with the pair itself cut off above. A downstream consumer hit exactly that
|
|
47
|
+
# under heavy load and could not say which pair broke, or whether it timed out. Elapsed is per pair
|
|
48
|
+
# (whole seconds, $SECONDS): a pair that ran long points at a timeout, a short one at a wrong verdict.
|
|
49
|
+
FAILED_LIST=()
|
|
50
|
+
_t0=$SECONDS
|
|
51
|
+
_el() { printf '%ss' "$((SECONDS - _t0))"; }
|
|
52
|
+
_pair_fail() { # called inside check/sb_check: reads their locals name and rc
|
|
53
|
+
FAILED=1
|
|
54
|
+
FAILED_LIST+=("$(printf '%s' "$name" | tr -s ' ') (rc=${rc:-?}, $(_el))")
|
|
55
|
+
}
|
|
44
56
|
# Fixtures assembled at runtime so this file's own bytes carry no matching credential shape
|
|
45
57
|
# (same rule as universal_guard_check.sh — a fixture file excluded from scanning would be a hole).
|
|
46
58
|
AWSK="AKIA""1234567890ABCDEF"
|
|
@@ -67,14 +79,14 @@ newrepo() { # echoes a fresh repo path with the pattern layers in place and one
|
|
|
67
79
|
# check <name> <repo> <expect: block|pass> <refline...>
|
|
68
80
|
check() {
|
|
69
81
|
local name="$1" repo="$2" expect="$3"; shift 3
|
|
70
|
-
local out rc got
|
|
82
|
+
local out rc got; _t0=$SECONDS
|
|
71
83
|
out=$(printf '%s\n' "$@" | ( cd "$repo" && bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
72
84
|
# A runtime fault is its own failure mode, checked BEFORE the verdict: an aborted hook that exits 0
|
|
73
85
|
# would otherwise be scored as a clean pass — the exact defect this anchor was written for.
|
|
74
86
|
if printf '%s' "$out" | grep -qiE 'bad substitution|unbound variable|syntax error|command not found'; then
|
|
75
|
-
echo " ❌ $name — RUNTIME FAULT in the hook (a hook that aborts is not a hook that passed)"
|
|
87
|
+
echo " ❌ $name [$(_el)] — RUNTIME FAULT in the hook (a hook that aborts is not a hook that passed)"
|
|
76
88
|
printf '%s\n' "$out" | grep -iE 'bad substitution|unbound|syntax error|command not found' | sed 's/^/ /' | head -3
|
|
77
|
-
|
|
89
|
+
_pair_fail; return
|
|
78
90
|
fi
|
|
79
91
|
# A hook killed by a signal, or one that dies printing nothing, produces no fault TEXT — the grep
|
|
80
92
|
# above cannot see it, and rc alone would score it as a pass (R7 audit, 2026-07-26). So a `pass`
|
|
@@ -88,23 +100,23 @@ check() {
|
|
|
88
100
|
if printf '%s' "$out" | grep -qE '(leak —|leak in pushed|incomplete confidentiality instrument|unusable pattern)'; then
|
|
89
101
|
got=block
|
|
90
102
|
else
|
|
91
|
-
echo " ❌ $name — blocked, but for a HARNESS reason, not a confidentiality finding"
|
|
103
|
+
echo " ❌ $name [$(_el)] — blocked, but for a HARNESS reason, not a confidentiality finding"
|
|
92
104
|
printf '%s\n' "$out" | sed 's/^/ | /' | head -6
|
|
93
|
-
|
|
105
|
+
_pair_fail; return
|
|
94
106
|
fi
|
|
95
107
|
elif printf '%s' "$out" | grep -qF 'FH Pre-Publish'; then
|
|
96
108
|
got=pass
|
|
97
109
|
else
|
|
98
|
-
echo " ❌ $name — hook exited 0 without reaching the publish check (silent abort is not a pass)"
|
|
110
|
+
echo " ❌ $name [$(_el)] — hook exited 0 without reaching the publish check (silent abort is not a pass)"
|
|
99
111
|
printf '%s\n' "$out" | sed 's/^/ | /' | head -5
|
|
100
|
-
|
|
112
|
+
_pair_fail; return
|
|
101
113
|
fi
|
|
102
114
|
if [ "$got" = "$expect" ]; then
|
|
103
|
-
echo " ✅ $name (expected $expect)"
|
|
115
|
+
echo " ✅ $name [$(_el)] (expected $expect)"
|
|
104
116
|
else
|
|
105
|
-
echo " ❌ $name — expected $expect, got $got"
|
|
117
|
+
echo " ❌ $name [$(_el)] — expected $expect, got $got"
|
|
106
118
|
printf '%s\n' "$out" | sed 's/^/ | /' | head -8
|
|
107
|
-
|
|
119
|
+
_pair_fail
|
|
108
120
|
fi
|
|
109
121
|
}
|
|
110
122
|
|
|
@@ -256,10 +268,10 @@ sb_check() { # sb_check <name> <repo> <expect: warn|skip|none> <refline> [must-
|
|
|
256
268
|
# [must-name]: a branch the warning MUST name. "a warning appeared" is too weak an assertion —
|
|
257
269
|
# under a mutation that broke the self-exclusion, the advisory still warned, but about the
|
|
258
270
|
# pushed branch ITSELF. The leg went green while the defect was live (measured 2026-07-27).
|
|
259
|
-
local name="$1" repo="$2" expect="$3" refline="$4" mustname="${5:-}" out rc got
|
|
271
|
+
local name="$1" repo="$2" expect="$3" refline="$4" mustname="${5:-}" out rc got; _t0=$SECONDS
|
|
260
272
|
out=$(printf '%s\n' "$refline" | ( cd "$repo" && bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
261
273
|
if printf '%s' "$out" | grep -qiE 'bad substitution|unbound variable|syntax error|command not found'; then
|
|
262
|
-
echo " ❌ $name — RUNTIME FAULT in the hook";
|
|
274
|
+
echo " ❌ $name [$(_el)] — RUNTIME FAULT in the hook"; _pair_fail; return
|
|
263
275
|
fi
|
|
264
276
|
if printf '%s' "$out" | grep -qF "$SB_MARK"; then
|
|
265
277
|
# Key on a machine token, not prose. Measured 2026-07-27: this classifier first grepped the
|
|
@@ -270,23 +282,23 @@ sb_check() { # sb_check <name> <repo> <expect: warn|skip|none> <refline> [must-
|
|
|
270
282
|
got=none
|
|
271
283
|
fi
|
|
272
284
|
if [ "$got" != "$expect" ]; then
|
|
273
|
-
echo " ❌ $name — expected $expect, got $got"
|
|
285
|
+
echo " ❌ $name [$(_el)] — expected $expect, got $got"
|
|
274
286
|
printf '%s\n' "$out" | sed 's/^/ | /' | head -8
|
|
275
|
-
|
|
287
|
+
_pair_fail; return
|
|
276
288
|
fi
|
|
277
289
|
# The advisory must not move the verdict. These legs are otherwise-clean pushes, so a non-zero
|
|
278
290
|
# exit means the advisory (or something it perturbed) started blocking.
|
|
279
291
|
if [ "$rc" -ne 0 ]; then
|
|
280
|
-
echo " ❌ $name — advisory changed the verdict (exit $rc); it must be advisory only"
|
|
292
|
+
echo " ❌ $name [$(_el)] — advisory changed the verdict (exit $rc); it must be advisory only"
|
|
281
293
|
printf '%s\n' "$out" | sed 's/^/ | /' | head -6
|
|
282
|
-
|
|
294
|
+
_pair_fail; return
|
|
283
295
|
fi
|
|
284
296
|
if [ -n "$mustname" ] && ! printf '%s' "$out" | grep -qF "$mustname"; then
|
|
285
|
-
echo " ❌ $name — warned, but never named '$mustname' (warning for the wrong reason)"
|
|
297
|
+
echo " ❌ $name [$(_el)] — warned, but never named '$mustname' (warning for the wrong reason)"
|
|
286
298
|
printf '%s\n' "$out" | grep -F "$SB_MARK" -A5 | sed 's/^/ | /' | head -8
|
|
287
|
-
|
|
299
|
+
_pair_fail; return
|
|
288
300
|
fi
|
|
289
|
-
echo " ✅ $name ($expect, verdict unchanged${mustname:+, named $mustname})"
|
|
301
|
+
echo " ✅ $name [$(_el)] ($expect, verdict unchanged${mustname:+, named $mustname})"
|
|
290
302
|
}
|
|
291
303
|
# ⚠️ 계기 주의 (실측): 처음엔 remote_sha 를 all-zero(=신규 브랜치)로 줬는데, 그러면 push 범위에
|
|
292
304
|
# 샌드박스의 base 커밋(= templates/.git-hooks/pre-push 사본을 담고 있다)이 들어가 이 훅의 **기존**
|
|
@@ -382,7 +394,8 @@ if [ "$FAILED" -eq 0 ]; then
|
|
|
382
394
|
echo "[prepush-guard] ✅ all known pairs hold"
|
|
383
395
|
exit 0
|
|
384
396
|
fi
|
|
385
|
-
|
|
397
|
+
_broken=""; for _b in ${FAILED_LIST[@]+"${FAILED_LIST[@]}"}; do _broken="${_broken:+$_broken; }$_b"; done
|
|
398
|
+
echo "[prepush-guard] ❌ BLOCKED — ${#FAILED_LIST[@]} known pair(s) broke after ${SECONDS}s: ${_broken:-<unnamed>}"
|
|
386
399
|
echo " BLOCK→PASS = the publish boundary stopped covering something it claims to cover."
|
|
387
400
|
echo " PASS→BLOCK = over-blocking, which trains PUBLIC_SURFACE_OK into reflex and disarms the gate."
|
|
388
401
|
echo " RUNTIME FAULT = the hook aborted; that is never a pass, however it exited."
|
|
@@ -137,6 +137,9 @@ MODEL="sonnet"
|
|
|
137
137
|
# 그대로 남긴다(3/3 과 2/3 은 다른 사실이다).
|
|
138
138
|
# ⚠️ 비용: reps=3 이면 프로브당 `claude -p` 호출이 2 → 6 이다(12 프로브 = 24 → 72).
|
|
139
139
|
REPS=1
|
|
140
|
+
# §TRACE (2026-11-14, FH-3): arms keep their event stream so the scorer can read tool calls and the
|
|
141
|
+
# init tool/MCP/plugin lists (behave: probes · INVALID-COMPARISON). FH_LIVE_TRACE=0 restores text-only runs.
|
|
142
|
+
if [ "${FH_LIVE_TRACE:-1}" = 0 ]; then FH_LIVE_TRACE_ARG=""; else FH_LIVE_TRACE_ARG="--trace"; fi
|
|
140
143
|
DRYRUN=0
|
|
141
144
|
SUBSET=""
|
|
142
145
|
IDS=""
|
|
@@ -287,7 +290,7 @@ while IFS= read -r id; do
|
|
|
287
290
|
echo ""
|
|
288
291
|
echo "▶ $id — primary"
|
|
289
292
|
bash "$SIM_RUNNER" --arm primary --reps "$REPS" --prompt "$input_text" \
|
|
290
|
-
--mode observe --model "$MODEL" --out "$probe_out" \
|
|
293
|
+
--mode observe --model "$MODEL" --out "$probe_out" ${FH_LIVE_TRACE_ARG:+"$FH_LIVE_TRACE_ARG"} \
|
|
291
294
|
> "$probe_out/_runner_primary.log" 2>&1
|
|
292
295
|
runner_rc=$?
|
|
293
296
|
tail -n 6 "$probe_out/_runner_primary.log"
|
|
@@ -308,7 +311,7 @@ while IFS= read -r id; do
|
|
|
308
311
|
|
|
309
312
|
echo "▶ $id — control"
|
|
310
313
|
bash "$SIM_RUNNER" --arm control --reps "$REPS" --prompt "$control_text" \
|
|
311
|
-
--mode observe --model "$MODEL" --out "$probe_out" \
|
|
314
|
+
--mode observe --model "$MODEL" --out "$probe_out" ${FH_LIVE_TRACE_ARG:+"$FH_LIVE_TRACE_ARG"} \
|
|
312
315
|
> "$probe_out/_runner_control.log" 2>&1
|
|
313
316
|
runner_rc=$?
|
|
314
317
|
tail -n 6 "$probe_out/_runner_control.log"
|
|
@@ -329,7 +332,7 @@ while IFS= read -r id; do
|
|
|
329
332
|
control_b_text="$(cat "$SPEC_DIR/$id.control_b.txt")"
|
|
330
333
|
echo "▶ $id — control_b"
|
|
331
334
|
bash "$SIM_RUNNER" --arm control_b --reps "$REPS" --prompt "$control_b_text" \
|
|
332
|
-
--mode observe --model "$MODEL" --out "$probe_out" \
|
|
335
|
+
--mode observe --model "$MODEL" --out "$probe_out" ${FH_LIVE_TRACE_ARG:+"$FH_LIVE_TRACE_ARG"} \
|
|
333
336
|
> "$probe_out/_runner_control_b.log" 2>&1
|
|
334
337
|
runner_rc=$?
|
|
335
338
|
tail -n 6 "$probe_out/_runner_control_b.log"
|
|
@@ -312,6 +312,13 @@ FAILED_TO_RUN = 'FAILED-TO-RUN'
|
|
|
312
312
|
UNCALIBRATED = 'UNCALIBRATED'
|
|
313
313
|
PASS = 'PASS'
|
|
314
314
|
FAIL = 'FAIL'
|
|
315
|
+
INVALID_COMPARISON = 'INVALID-COMPARISON' # arms ran with different tool/MCP/plugin surfaces (FH-3 2026-11-14; plugins 2026-11-15)
|
|
316
|
+
|
|
317
|
+
try: # §TRACE — sibling module; absent = every probe is scored on text only and labelled MENTION-ONLY
|
|
318
|
+
import live_eval_trace as _trace
|
|
319
|
+
except ImportError: # pragma: no cover
|
|
320
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
321
|
+
import live_eval_trace as _trace
|
|
315
322
|
|
|
316
323
|
|
|
317
324
|
def _read_text(path):
|
|
@@ -515,6 +522,14 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
515
522
|
adv_re = spec.get('advisory_re')
|
|
516
523
|
adv_pat = re.compile(adv_re) if adv_re else None
|
|
517
524
|
adv_hits = 0
|
|
525
|
+
behave, behave_err = spec.get('behave'), None
|
|
526
|
+
if behave:
|
|
527
|
+
try:
|
|
528
|
+
_trace.parse_behave(behave)
|
|
529
|
+
except (ValueError, re.error) as e:
|
|
530
|
+
behave_err, behave = str(e), None
|
|
531
|
+
inventories, inv_unknown, traces, no_trace, b_reps = set(), 0, {}, 0, []
|
|
532
|
+
damaged, any_trace = 0, False
|
|
518
533
|
ctrl_b_absent = False # rep-1 only, diagnostic: which arm actually produced nothing
|
|
519
534
|
per_rep = [] # [(verdict, phit, chit, primary_text, control_text)]
|
|
520
535
|
for i in range(1, reps + 1):
|
|
@@ -544,6 +559,31 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
544
559
|
# without re-deriving this; none currently does.
|
|
545
560
|
ct = ct + '\n----- control_b -----\n' + ctb
|
|
546
561
|
v, ph, ch = score_probe(pt, ct, spec['polarity'], spec['expect_re'])
|
|
562
|
+
# §TRACE — what each arm's session had (init tools/MCP) and, for a `behave:` probe, did.
|
|
563
|
+
for arm in ['primary', 'control'] + (['control_b'] if has_ctrl_b else []):
|
|
564
|
+
tr = _trace.parse_stream(os.path.join(base, '%s_r%d.stream.jsonl' % (arm, i)))
|
|
565
|
+
if tr is not None and tr['damaged']:
|
|
566
|
+
damaged += 1
|
|
567
|
+
tr = None
|
|
568
|
+
any_trace = any_trace or tr is not None
|
|
569
|
+
inv = _trace.inventory(tr)
|
|
570
|
+
if inv is not None:
|
|
571
|
+
inventories.add(inv)
|
|
572
|
+
elif tr is not None:
|
|
573
|
+
inv_unknown += 1
|
|
574
|
+
traces[(arm, i)] = tr
|
|
575
|
+
if behave and v in (PASS, FAIL):
|
|
576
|
+
arms_i = ['primary', 'control'] + (['control_b'] if has_ctrl_b else [])
|
|
577
|
+
if any(traces[(a, i)] is None for a in arms_i):
|
|
578
|
+
no_trace += 1
|
|
579
|
+
else:
|
|
580
|
+
bp = _trace.behave_hit(traces[('primary', i)], behave)
|
|
581
|
+
bc = any(_trace.behave_hit(traces[(a, i)], behave) for a in arms_i[1:])
|
|
582
|
+
b_reps.append((bp, bc))
|
|
583
|
+
if bc:
|
|
584
|
+
v = UNCALIBRATED # the control arm did the action too: it cannot discriminate
|
|
585
|
+
elif v == PASS and not bp:
|
|
586
|
+
v = FAIL # said it, did not do it
|
|
547
587
|
if adv_pat is not None and pt:
|
|
548
588
|
if adv_pat.search(pt):
|
|
549
589
|
adv_hits += 1
|
|
@@ -555,6 +595,10 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
555
595
|
|
|
556
596
|
if not ran_reps:
|
|
557
597
|
verdict = FAILED_TO_RUN
|
|
598
|
+
elif len(inventories) > 1 or (inventories and inv_unknown):
|
|
599
|
+
verdict = INVALID_COMPARISON # different surfaces, or one arm's surface unknown
|
|
600
|
+
elif behave_err or (behave and any_trace and (no_trace or damaged)):
|
|
601
|
+
verdict = UNCALIBRATED # bad spec, or traces expected but some arm's is missing/damaged
|
|
558
602
|
elif uncal:
|
|
559
603
|
verdict = UNCALIBRATED
|
|
560
604
|
else:
|
|
@@ -573,8 +617,28 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
573
617
|
'reps_requested': reps,
|
|
574
618
|
'silent': silent,
|
|
575
619
|
'rep_verdicts': [r[0] for r in per_rep]}
|
|
620
|
+
# scored_by: BEHAVIOUR only when every rep that ran carried both traces and a behave spec.
|
|
621
|
+
# A probe with no `behave:` or a rep with no trace is MENTION-ONLY — its PASS reads a text.
|
|
622
|
+
row['scored_by'] = ('BEHAVIOUR' if behave and ran_reps and len(b_reps) == len(ran_reps)
|
|
623
|
+
else 'MENTION-ONLY')
|
|
624
|
+
row['behave'] = ('%d/%d did · control %d/%d' % (sum(1 for b in b_reps if b[0]), len(b_reps),
|
|
625
|
+
sum(1 for b in b_reps if b[1]), len(b_reps))) if b_reps else ('no trace' if behave else '-')
|
|
626
|
+
row['inventory'] = (('%d distinct' % len(inventories)) if inventories else 'UNMEASURED (no trace)') + \
|
|
627
|
+
((' · %d trace(s) without init' % inv_unknown) if inv_unknown else '')
|
|
628
|
+
row['_inventories'] = sorted(inventories)
|
|
629
|
+
if behave_err:
|
|
630
|
+
row['reason'] = 'BAD-BEHAVE: ' + behave_err
|
|
631
|
+
elif inventories and inv_unknown and len(inventories) == 1:
|
|
632
|
+
row['reason'] = 'INVALID-COMPARISON: %d trace(s) carry no init tool list — surfaces not comparable' % inv_unknown
|
|
633
|
+
elif behave and any_trace and (no_trace or damaged):
|
|
634
|
+
row['reason'] = 'TRACE-INCOMPLETE: %d rep(s) missing an arm trace · %d damaged stream(s)' % (no_trace, damaged)
|
|
635
|
+
elif len(inventories) > 1:
|
|
636
|
+
row['reason'] = 'INVALID-COMPARISON: arms saw %d different tool/MCP/plugin lists — %s' % (
|
|
637
|
+
len(inventories), ' ≠ '.join(sorted(inventories)))
|
|
576
638
|
if len(ran_reps) > 1 and 0 < len(pass_reps) < len(ran_reps):
|
|
577
|
-
|
|
639
|
+
flaky = 'FLAKY across reps (%s)' % ','.join(r[0] for r in per_rep)
|
|
640
|
+
# an INVALID-COMPARISON reason must survive: the surface mismatch is why there is no number
|
|
641
|
+
row['reason'] = (row['reason'] + '; ' + flaky) if verdict == INVALID_COMPARISON and row['reason'] else flaky
|
|
578
642
|
if adv_pat is not None:
|
|
579
643
|
row['advisory'] = '%d/%d' % (adv_hits, len(ran_reps) if ran_reps else 0)
|
|
580
644
|
row['advisory_re'] = adv_re
|
|
@@ -643,11 +707,19 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
643
707
|
r['reason'] = (r['reason'] + '; ' + note) if r.get('reason') else note
|
|
644
708
|
|
|
645
709
|
failed_to_run = [r for r in rows if r['verdict'] == FAILED_TO_RUN]
|
|
710
|
+
invalid = [r for r in rows if r['verdict'] == INVALID_COMPARISON]
|
|
711
|
+
run_inv = set(x for r in rows for x in r.get('_inventories', []))
|
|
712
|
+
behaviour_backed = [r for r in rows if r['verdict'] == PASS and r.get('scored_by') == 'BEHAVIOUR']
|
|
713
|
+
mention_only_pass = [r for r in rows if r['verdict'] == PASS and r.get('scored_by') != 'BEHAVIOUR']
|
|
646
714
|
uncalibrated = [r for r in rows if r['verdict'] == UNCALIBRATED]
|
|
647
715
|
ran = [r for r in rows if r['verdict'] in (PASS, FAIL)]
|
|
648
716
|
passed = [r for r in rows if r['verdict'] == PASS]
|
|
649
717
|
|
|
650
|
-
if
|
|
718
|
+
if invalid or len(run_inv) > 1:
|
|
719
|
+
overall = INVALID_COMPARISON # no number: the arms were not the same instrument
|
|
720
|
+
rc = 2
|
|
721
|
+
pass_rate = None
|
|
722
|
+
elif uncalibrated:
|
|
651
723
|
overall = 'UNCALIBRATED'
|
|
652
724
|
rc = 2
|
|
653
725
|
pass_rate = None
|
|
@@ -681,6 +753,10 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
681
753
|
'silent_fraction': silent_fraction,
|
|
682
754
|
'blackout': blackout,
|
|
683
755
|
'blackout_suspect': blackout_suspect,
|
|
756
|
+
'invalid_comparison': len(invalid),
|
|
757
|
+
'run_inventories': len(run_inv),
|
|
758
|
+
'behaviour_backed': len(behaviour_backed),
|
|
759
|
+
'mention_only_pass': len(mention_only_pass),
|
|
684
760
|
}
|
|
685
761
|
|
|
686
762
|
|
|
@@ -904,6 +980,11 @@ def render_report_md(select_result, score_result, run_date, instrument=None):
|
|
|
904
980
|
% (score_result['overall'], score_result['ran'], score_result['failed_to_run'],
|
|
905
981
|
score_result['uncalibrated'], score_result['passed'], pr_s))
|
|
906
982
|
lines.append("")
|
|
983
|
+
lines.append("- scored by behaviour: **%d** of %d PASS · MENTION-ONLY: **%d** (a MENTION-ONLY PASS read the "
|
|
984
|
+
"reply text; it is not evidence the rule acted) · tool/MCP/plugin surfaces in this run: %s"
|
|
985
|
+
% (score_result.get('behaviour_backed', 0), score_result['passed'],
|
|
986
|
+
score_result.get('mention_only_pass', 0),
|
|
987
|
+
score_result.get('run_inventories') or 'UNMEASURED (no trace)'))
|
|
907
988
|
sf = score_result.get('silent_fraction')
|
|
908
989
|
if sf is not None:
|
|
909
990
|
lines.append("- instrument-silent probes: %d/%d (%.2f) — a probe is *silent* when its "
|
|
@@ -923,6 +1004,15 @@ def render_report_md(select_result, score_result, run_date, instrument=None):
|
|
|
923
1004
|
"instrument failure produce this shape, and this file cannot tell them "
|
|
924
1005
|
"apart; the preserved response bodies can.")
|
|
925
1006
|
lines.append("")
|
|
1007
|
+
if score_result is not None:
|
|
1008
|
+
lines.extend(["## Scored by — behaviour or mention", "",
|
|
1009
|
+
"`BEHAVIOUR` = the probe's `behave:` action was read from the event stream in every rep "
|
|
1010
|
+
"(primary did it, control did not). `MENTION-ONLY` = the verdict rests on reply text.", "",
|
|
1011
|
+
"| Probe | scored_by | behave (primary did · control did) | tool/MCP/plugin lists |", "|---|---|---|---|"])
|
|
1012
|
+
for r in score_result['rows']:
|
|
1013
|
+
lines.append("| %s | %s | %s | %s |" % (r['id'], r.get('scored_by', 'MENTION-ONLY'),
|
|
1014
|
+
_md_escape(r.get('behave', '-')), _md_escape(r.get('inventory', '-'))))
|
|
1015
|
+
lines.append("")
|
|
926
1016
|
lines.extend(render_construct_md(select_result['selected']))
|
|
927
1017
|
if score_result is not None and score_result.get('target'):
|
|
928
1018
|
lines.extend(render_target_md(score_result['target']))
|
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
# 하나로 묶어 뒀더니 실물 PR 재현이 **전부 SKIP** 으로 떨어졌다(조용한 통과).
|
|
48
48
|
# RMG_BASE_REF 비교 기준 (기본: origin/main)
|
|
49
49
|
# RMG_BODY_FILE PR 본문이 담긴 파일 (선택 — 없으면 커밋 메시지만 본다)
|
|
50
|
+
# RMG_PR_LOOKUP 1 이면 BODY_FILE 이 없을 때 그 커밋의 PR 본문을 `gh api` 로 읽는다(push 실행용)
|
|
51
|
+
# 조회 실패 = rc=10 · 이 채널의 PR 없음 = 커밋 메시지만
|
|
52
|
+
# RMG_REPO owner/name (RMG_PR_LOOKUP=1 일 때 필수) · RMG_GH gh 실행 파일 (기본: gh — 레인이 가짜를 꽂는다)
|
|
50
53
|
# RMG_CHANNEL_RE 플로어 없는 채널 패턴 (기본: '^claude/')
|
|
51
54
|
# RMG_GUARD_FILE GUARD_PATHSPEC 정본 (기본: templates/regression_guard.sh)
|
|
52
55
|
set -u
|
|
@@ -134,6 +137,59 @@ fi
|
|
|
134
137
|
say "📄 FH 자산 $NCH 개를 건드렸다:"
|
|
135
138
|
printf '%s\n' "$CHANGED" | sed 's/^/ /'
|
|
136
139
|
|
|
140
|
+
# ── 3-a. push 실행: 그 커밋의 PR 본문을 API 로 읽는다 (2026-11-15, AQ-20261114-10) ──
|
|
141
|
+
# `pull_request` 실행은 본문을 이벤트에서 받지만 `push` 실행에는 본문이 없다. 그래서 같은
|
|
142
|
+
# HEAD 에 push 실행만 빨갛고 pull_request 실행은 초록인 두 판정이 났다(#1095 · #1103).
|
|
143
|
+
# 🟥 조회 실패는 «PR 없음» 이 아니다 → rc=10(빨강). PR 이 정말 없으면 커밋 메시지만 본다 —
|
|
144
|
+
# 그때 마커가 없으면 아래 4 가 rc=1 로 막는다. 정본 기록면은 여전히 커밋 메시지다(:172 처방).
|
|
145
|
+
if [ -z "$BODY_FILE" ] && [ "${RMG_PR_LOOKUP:-0}" = "1" ]; then
|
|
146
|
+
GH_BIN="${RMG_GH:-gh}"
|
|
147
|
+
if [ -z "${RMG_REPO:-}" ] || [ -z "$_h" ]; then
|
|
148
|
+
say "❌ HARNESS-ERROR — PR 조회에 필요한 값이 없다(RMG_REPO='${RMG_REPO:-}' · sha='$_h')."
|
|
149
|
+
exit 10
|
|
150
|
+
fi
|
|
151
|
+
LOOKUP_DIR=$(mktemp -d 2>/dev/null) || { say "❌ HARNESS-ERROR — 임시 폴더를 못 만든다"; exit 10; }
|
|
152
|
+
if ! "$GH_BIN" api "repos/$RMG_REPO/commits/$_h/pulls" > "$LOOKUP_DIR/pulls.json" 2> "$LOOKUP_DIR/err.txt"; then
|
|
153
|
+
say "❌ HARNESS-ERROR — 커밋 $_h 의 PR 조회가 실패했다:"
|
|
154
|
+
sed 's/^/ /' "$LOOKUP_DIR/err.txt" | head -5
|
|
155
|
+
say " 🟥 조회 실패를 «PR 없음» 으로 읽지 않는다. 다시 돌리거나 커밋 메시지에 마커를 실어라."
|
|
156
|
+
rm -rf "$LOOKUP_DIR"; exit 10
|
|
157
|
+
fi
|
|
158
|
+
# 이 채널(head ref)의 PR 만 받는다 — 같은 커밋을 품은 남의 PR 본문으로 통과하지 않게.
|
|
159
|
+
# head 레포까지 맞춘다 — 같은 브랜치 이름의 포크 PR 본문으로 통과하지 않게(codex R1).
|
|
160
|
+
if ! python3 - "$LOOKUP_DIR/pulls.json" "$CHANNEL_NAME" "$LOOKUP_DIR/body.txt" "$RMG_REPO" > "$LOOKUP_DIR/n.txt" 2>> "$LOOKUP_DIR/err.txt" <<'PY'
|
|
161
|
+
import json, sys
|
|
162
|
+
src, ref, out, repo = sys.argv[1:5]
|
|
163
|
+
data = json.load(open(src, encoding="utf-8"))
|
|
164
|
+
if not isinstance(data, list):
|
|
165
|
+
raise SystemExit("not a list")
|
|
166
|
+
bodies = []
|
|
167
|
+
for p in data:
|
|
168
|
+
# a malformed entry is an unreadable answer, not «no PR» (codex R1)
|
|
169
|
+
h = p.get("head") if isinstance(p, dict) else None
|
|
170
|
+
r = h.get("repo") if isinstance(h, dict) else None
|
|
171
|
+
if not (isinstance(h, dict) and isinstance(h.get("ref"), str)
|
|
172
|
+
and isinstance(r, dict) and isinstance(r.get("full_name"), str)):
|
|
173
|
+
raise SystemExit("malformed PR entry (head.ref / head.repo.full_name)")
|
|
174
|
+
if h["ref"] == ref and r["full_name"] == repo:
|
|
175
|
+
bodies.append(p.get("body") or "")
|
|
176
|
+
open(out, "w", encoding="utf-8").write("\n".join(bodies))
|
|
177
|
+
print(len(bodies))
|
|
178
|
+
PY
|
|
179
|
+
then
|
|
180
|
+
say "❌ HARNESS-ERROR — PR 조회 응답을 못 읽는다:"
|
|
181
|
+
sed 's/^/ /' "$LOOKUP_DIR/err.txt" | head -5
|
|
182
|
+
rm -rf "$LOOKUP_DIR"; exit 10
|
|
183
|
+
fi
|
|
184
|
+
NPR=$(cat "$LOOKUP_DIR/n.txt")
|
|
185
|
+
if [ "${NPR:-0}" -gt 0 ] 2>/dev/null; then
|
|
186
|
+
BODY_FILE="$LOOKUP_DIR/body.txt"
|
|
187
|
+
say "🔎 push 실행: 커밋 $_h 의 PR($CHANNEL_NAME) ${NPR} 개 본문을 API 로 읽었다."
|
|
188
|
+
else
|
|
189
|
+
say "🔎 push 실행: 커밋 $_h 를 품은 '$CHANNEL_NAME' PR 이 없다 — 커밋 메시지만 본다."
|
|
190
|
+
fi
|
|
191
|
+
fi
|
|
192
|
+
|
|
137
193
|
# ── 3. 기록면 = 커밋 메시지 (+ 선택적 PR 본문) ────────────────────────────────
|
|
138
194
|
RECORD=$(git log --format='%B' "$BASE_REF".."$HEAD_REF" 2>/dev/null)
|
|
139
195
|
if [ -n "$BODY_FILE" ] && [ -r "$BODY_FILE" ]; then
|