@chrono-meta/fh-gate 3.39.1 → 3.40.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 +9 -2
- package/.claude-plugin/marketplace.json +4 -4
- package/CLAUDE.md +2 -2
- package/README.ja.md +20 -18
- package/README.zh.md +20 -18
- package/knowledge/shared/harness-core/claude_md_full_reference.md +8 -1
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
- package/knowledge/shared/harness-core/fh_module_contract.md +55 -1
- package/knowledge/shared/harness-core/lease_record_channel.md +26 -2
- package/knowledge/shared/harness-core/onboarding_acceleration_autopilot.md +7 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
- package/knowledge/shared/rules/operations.md +1 -0
- package/package.json +10 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +35 -0
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/agent_tools_pin.txt +16 -0
- package/scripts/catch_tally.py +215 -0
- package/scripts/claim_precision_report.py +138 -0
- package/scripts/fh_module_check.py +182 -1
- package/scripts/generated_harness_check.py +4 -0
- package/scripts/package_coverage_check.sh +5 -0
- package/scripts/post_squash_verify.sh +53 -1
- package/scripts/pr_merge_verified.sh +56 -0
- package/scripts/probe_live_eval.sh +61 -0
- package/scripts/probe_live_eval_lib.py +47 -4
- package/scripts/selfcheck.sh +5 -0
- package/scripts/selfdev_merge_tier.sh +153 -0
- package/scripts/session_checklist.py +38 -1
- package/scripts/session_close_check.sh +67 -1
- package/scripts/sim_isolated_run.sh +62 -1
- package/scripts/test_agent_tools_pin_lanes.sh +73 -0
- package/scripts/test_catch_tally_lanes.sh +10 -0
- package/scripts/test_claim_precision_report_lanes.sh +77 -0
- package/scripts/test_fh_module_check_lanes.sh +106 -1
- package/scripts/test_generated_harness_check_lanes.sh +8 -0
- package/scripts/test_post_squash_verify_lanes.sh +23 -2
- package/scripts/test_pr_merge_verified_lanes.sh +55 -3
- package/scripts/test_probe_live_eval_lanes.sh +160 -5
- package/scripts/test_selfdev_merge_tier_lanes.sh +128 -0
- package/scripts/test_session_checklist_lanes.sh +57 -0
- package/scripts/test_session_close_chain_lanes.sh +93 -0
- package/scripts/test_sim_isolated_run_lanes.sh +67 -0
- package/templates/harness_birth_core.md +57 -0
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
# --rerun run with `bash -c` inside a throwaway detached worktree at --merge. Cwd = that worktree.
|
|
27
27
|
#
|
|
28
28
|
# EXIT 0 both halves pass · 1 content mismatch or ② failed · 2 usage (incl. missing --rerun)
|
|
29
|
-
# 3 trivial ② refused
|
|
29
|
+
# 3 trivial or statically quiet ② refused (`grep -q …` alone — add `&& echo …`) · 4 instrument/harness
|
|
30
|
+
# error (② silent at run time, worktree not creatable, bad sha)
|
|
30
31
|
#
|
|
31
32
|
# Labels for ①, per path the branch changed (merge-base(tip, merge^) .. tip, machine-listed):
|
|
32
33
|
# SAME blob on --merge == blob on --tip (incl. both absent = deletion carried)
|
|
@@ -83,6 +84,57 @@ if [ "$_noop" -eq 1 ]; then
|
|
|
83
84
|
echo "🟥 --rerun '$RERUN' only echoes / no-ops — refused. Printing is not exercising the change." >&2
|
|
84
85
|
exit 3
|
|
85
86
|
fi
|
|
87
|
+
# 🟥 2026-11-09 (verify-incomplete root cause, tracks/_meta/verify_incomplete_root_cause_2026-11-09.md):
|
|
88
|
+
# 7 of 7 non-verified merges in the receipts carried a QUIET ② (`grep -q`, `>/dev/null`, a python -c
|
|
89
|
+
# with no print). Content was intact every time; the silence guard below (rc=0 + no output → rc=4)
|
|
90
|
+
# fired AFTER the merge, so each ended verify-incomplete. Refuse before merging instead, when every
|
|
91
|
+
# segment is statically a silent check. The silence guard stays as it is for what this cannot see.
|
|
92
|
+
# Quoted text is blanked before splitting so a `;` inside `python3 -c "…"` does not split it.
|
|
93
|
+
# 🟥 cross-family R1 (codex, 11 findings): over-refusal is the costly direction (a printing command
|
|
94
|
+
# refused before merging). Fixed: quote blanking is one left-to-right pass (a `"` inside '…' no longer
|
|
95
|
+
# pairs with a later quote) · a lone `&` separates · `>&2` anywhere in a segment means output reaches
|
|
96
|
+
# ② (captured 2>&1) · only fd-less/1/& redirects to /dev/null count · grep options stop at `--` ·
|
|
97
|
+
# python -c is quiet only with no print/stdout/write anywhere. Named residual (fail-open → rc=4 after
|
|
98
|
+
# the merge, guard unchanged): a quoted option (`grep '-q'`), a comment containing «print», a quiet
|
|
99
|
+
# check piped into a printer of nothing (`… | cat`), and any wrapper (`bash -c '…'`).
|
|
100
|
+
_quiet_seg() { # $1 = one segment; rc 0 = prints nothing on success
|
|
101
|
+
local s="$1" w1 w
|
|
102
|
+
case "$s" in *'>&2'*) return 1 ;; esac # stdout sent to stderr — ② captures both
|
|
103
|
+
s="${s##*|}" # judge the last element of a pipeline
|
|
104
|
+
printf '%s' "$s" | grep -Eq '(^|[[:space:]])(1|&)?>[[:space:]]*/dev/null' && return 0
|
|
105
|
+
set -f; set -- $s; set +f; w1="${1:-}"
|
|
106
|
+
case "$w1" in
|
|
107
|
+
:|true|/bin/true|/usr/bin/true|exit|return|test|'['|'[[') return 0 ;;
|
|
108
|
+
grep|egrep|fgrep|rg)
|
|
109
|
+
for w in "$@"; do case "$w" in --) break ;; --quiet|--silent) return 0 ;; --*) : ;; -*q*) return 0 ;; esac; done ;;
|
|
110
|
+
git) for w in "$@"; do case "$w" in --) break ;; -q|--quiet|--is-ancestor) return 0 ;; esac; done
|
|
111
|
+
case " $s " in *" cat-file "*" -e "*) return 0 ;; esac ;; # bare -e only for cat-file (git grep -e prints)
|
|
112
|
+
cmp) for w in "$@"; do [ "$w" = -s ] && return 0; done ;;
|
|
113
|
+
python|python3) for w in "$@"; do [ "$w" = -c ] && { case "$RERUN" in *print*|*stdout*|*write*) return 1 ;; esac; return 0; }; done ;;
|
|
114
|
+
esac
|
|
115
|
+
return 1
|
|
116
|
+
}
|
|
117
|
+
_bl=""; _q=""; _esc=0; _i=0
|
|
118
|
+
while [ "$_i" -lt "${#RERUN}" ]; do
|
|
119
|
+
_c="${RERUN:$_i:1}"; _i=$((_i+1))
|
|
120
|
+
if [ "$_q" = "'" ]; then [ "$_c" = "'" ] && { _q=""; _bl="$_bl'"; }; continue; fi
|
|
121
|
+
if [ "$_q" = '"' ]; then
|
|
122
|
+
if [ "$_esc" -eq 1 ]; then _esc=0; elif [ "$_c" = '\' ]; then _esc=1; elif [ "$_c" = '"' ]; then _q=""; _bl="$_bl\""; fi
|
|
123
|
+
continue; fi
|
|
124
|
+
if [ "$_esc" -eq 1 ]; then _esc=0; _bl="$_bl$_c"; continue; fi
|
|
125
|
+
case "$_c" in '\') _esc=1; _bl="$_bl$_c" ;; "'"|'"') _q="$_c"; _bl="$_bl$_c" ;; *) _bl="$_bl$_c" ;; esac
|
|
126
|
+
done
|
|
127
|
+
_quiet=1; _nseg=0
|
|
128
|
+
while IFS= read -r _seg; do
|
|
129
|
+
_t=$(printf '%s' "$_seg" | tr -d '[:space:]'); [ -z "$_t" ] && continue
|
|
130
|
+
_nseg=$((_nseg+1)); _quiet_seg "$_seg" || { _quiet=0; break; }
|
|
131
|
+
done <<< "$(printf '%s' "$_bl" | sed -E -e 's/&&/;/g' -e 's/[|][|]/;/g' -e 's/([^>&<0-9])&([^>&]|$)/\1;\2/g' | tr ';' '\n')"
|
|
132
|
+
if [ "$_quiet" -eq 1 ] && [ "$_nseg" -gt 0 ]; then
|
|
133
|
+
echo "🟥 --rerun '$RERUN' prints nothing when it passes (every segment is a quiet check) — refused before merging." >&2
|
|
134
|
+
echo " A silent ② reads as an instrument failure (rc=4), so the merge would end verify-incomplete." >&2
|
|
135
|
+
echo " Make it say what passed, e.g. <your check> && echo '<what passed>'" >&2
|
|
136
|
+
exit 3
|
|
137
|
+
fi
|
|
86
138
|
|
|
87
139
|
[ "$PRECHECK" -eq 0 ] || { echo "✅ --rerun accepted (precheck)"; exit 0; }
|
|
88
140
|
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
# 2 usage (nothing merged) · 3 trivial --rerun refused (nothing merged)
|
|
29
29
|
# 4 harness error (see message: before or after the merge)
|
|
30
30
|
# 6 merge accepted but not completed (queue/lag) — NOT verified, nothing claimed
|
|
31
|
+
# 7 lease merge refused: a --lease other than «operator…» and selfdev_merge_tier.sh did not say AUTO, or the tier
|
|
32
|
+
# could not be read (nothing merged)
|
|
31
33
|
# 5 merge NOT observed (gh failed and GitHub still reports OPEN/CLOSED after bounded re-reads —
|
|
32
34
|
# an observation, not proof: stale state can outlast the re-reads)
|
|
33
35
|
# (gh non-zero but GitHub says MERGED → continue to verify; state unreadable → 4, outcome UNKNOWN)
|
|
@@ -104,6 +106,60 @@ if [ -n "$EXPECT_HEAD" ] && [ "$HEAD_OID" != "$EXPECT_HEAD" ]; then
|
|
|
104
106
|
echo "🟥 PR #$PR head is $HEAD_OID, not the checked $EXPECT_HEAD — not merging" >&2; exit 2
|
|
105
107
|
fi
|
|
106
108
|
echo "── PR #$PR head recorded: $HEAD_OID"
|
|
109
|
+
# 1a. no --lease → say so, before the merge (AQ-20261109-5). The receipt still records NONE and the merge still runs:
|
|
110
|
+
# most merges rest on the operator's per-PR answer, which is fine to leave unnamed. What must not stay silent is a merge
|
|
111
|
+
# that rested on a STANDING approval and recorded none — #1063 was merged on the self-dev lease with lease=NONE and the
|
|
112
|
+
# receipt said nothing. Advisory only; never changes rc.
|
|
113
|
+
if [ "$LEASE" = "NONE" ]; then
|
|
114
|
+
echo "⚠️ no --lease: the receipt will record lease=NONE. If this merge rests on a standing approval (the self-dev" >&2
|
|
115
|
+
echo " lease, a session lease), stop and rerun with --lease '<its label>'; if it rests on the operator's answer for" >&2
|
|
116
|
+
echo " THIS PR, NONE is right. Advisory only; merging continues." >&2
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# 1c. a lease only covers what the merge tier allows (AQ-20261109-4). The self-dev lease (CLAUDE.local.md 2026-11-04) is
|
|
120
|
+
# grade (가): reversible changes merge on their own, anything gate-shaped waits for the operator. selfdev_loop.sh asks
|
|
121
|
+
# selfdev_merge_tier.sh before calling here; an interactive session merging «under the lease» did not (#1063: TIER=HOLD,
|
|
122
|
+
# merged as (가)). So every --lease is checked against the tier here, before the merge, EXCEPT a label that starts with
|
|
123
|
+
# «operator» — the operator's answer for THIS PR, which is what a HOLD asks for. Default-on, not a list of standing-lease
|
|
124
|
+
# spellings (codex R1: «STANDING», «self-dev», «session lease» each slipped a substring list).
|
|
125
|
+
# The tier reads the RECORDED head through local git (merge-base with origin/main .. $HEAD_OID), not the live PR, so what
|
|
126
|
+
# it judged is what --match-head-commit merges (codex R1: a head swapped during the check). Unreadable → refuse (rc 7).
|
|
127
|
+
# only the literal default skips («--lease none» is a label someone typed — codex R2); «operator…» in any case
|
|
128
|
+
_lease_lc=$(printf '%s' "$LEASE" | tr '[:upper:]' '[:lower:]')
|
|
129
|
+
[ "$LEASE" = "NONE" ] && _lease_lc="__default_none__"
|
|
130
|
+
case "$_lease_lc" in
|
|
131
|
+
__default_none__|operator*) ;;
|
|
132
|
+
*)
|
|
133
|
+
_tier="$(dirname "$PSV")/selfdev_merge_tier.sh"
|
|
134
|
+
_tw=$(mktemp -d "${TMPDIR:-/tmp}/pmv-tier-XXXXXX") || _tw=""
|
|
135
|
+
_tok=0
|
|
136
|
+
# the diff must not depend on the caller's git config (codex R2: diff.ignoreSubmodules · diff.relative hid changes;
|
|
137
|
+
# noprefix / color would break the tier's parser), and the base is the live main, fetched now
|
|
138
|
+
_gd() { git -c core.quotepath=off -c diff.noprefix=false -c diff.mnemonicPrefix=false -c diff.relative=false \
|
|
139
|
+
-c diff.ignoreSubmodules=none diff --no-color --no-ext-diff --no-textconv --no-renames --ignore-submodules=none "$@"; }
|
|
140
|
+
if [ -f "$_tier" ] && [ -n "$_tw" ] && git fetch -q origin main < /dev/null 2>/dev/null \
|
|
141
|
+
&& _mb=$(git merge-base origin/main "$HEAD_OID" < /dev/null 2>/dev/null) && [ -n "$_mb" ] \
|
|
142
|
+
&& _gd --name-status "$_mb" "$HEAD_OID" < /dev/null > "$_tw/ns" 2>/dev/null \
|
|
143
|
+
&& _gd --numstat "$_mb" "$HEAD_OID" < /dev/null > "$_tw/num" 2>/dev/null \
|
|
144
|
+
&& _gd "$_mb" "$HEAD_OID" < /dev/null > "$_tw/diff" 2>/dev/null \
|
|
145
|
+
&& awk -F'\t' 'NR==FNR { st[$2]=$1; next } { print st[$3] "\t" $3 "\t" $1 "\t" $2 }' "$_tw/ns" "$_tw/num" > "$_tw/files" 2>/dev/null; then
|
|
146
|
+
_tok=1
|
|
147
|
+
fi
|
|
148
|
+
if [ "$_tok" -ne 1 ]; then
|
|
149
|
+
[ -n "$_tw" ] && rm -rf "$_tw"
|
|
150
|
+
echo "🟥 lease «$LEASE»: the merge tier could not be read for head $HEAD_OID (tier script, merge-base or diff) — not merging" >&2
|
|
151
|
+
exit 7
|
|
152
|
+
fi
|
|
153
|
+
_tout=$(bash "$_tier" --files "$_tw/files" --diff "$_tw/diff" < /dev/null 2>&1); _trc=$?
|
|
154
|
+
rm -rf "$_tw"
|
|
155
|
+
if [ "$_trc" -ne 0 ] || [ "$(printf '%s\n' "$_tout" | tail -1)" != "TIER=AUTO" ]; then
|
|
156
|
+
printf '%s\n' "$_tout" | sed 's/^/ /' >&2
|
|
157
|
+
echo "🟥 lease «$LEASE» is not the operator's answer for this PR, and selfdev_merge_tier.sh did not say AUTO (rc=$_trc) — not merging." >&2
|
|
158
|
+
echo " Ask the operator for THIS PR, then merge with --lease 'operator: «<their words>» <date>'." >&2
|
|
159
|
+
exit 7
|
|
160
|
+
fi
|
|
161
|
+
echo "── lease «$LEASE»: selfdev_merge_tier.sh says TIER=AUTO for head $HEAD_OID" ;;
|
|
162
|
+
esac
|
|
107
163
|
|
|
108
164
|
# 1b. coverage advisory — WARNING ONLY (never changes rc, never merges or refuses). post_squash_verify's precheck rejects a
|
|
109
165
|
# command that is trivially empty; it cannot see a command that is real but never touches this PR's files. Static, pre-merge,
|
|
@@ -375,6 +375,67 @@ python3 "$LIB" score ${SCORE_EXTRA[@]+"${SCORE_EXTRA[@]}"} \
|
|
|
375
375
|
--reps "$REPS"
|
|
376
376
|
score_rc=$?
|
|
377
377
|
|
|
378
|
+
# State fingerprint (2026-11-11, arXiv:2611.11216 — record only, never read by the scorer above).
|
|
379
|
+
# Two arms can print the same output while leaving their isolated clones in different states. The
|
|
380
|
+
# runner already writes `<arm>_r<n>.treediff.txt` (porcelain lines the arm added); this appends, in
|
|
381
|
+
# the same execution as the verdict, one line per rep: changed-path count + a hash over the treediff
|
|
382
|
+
# and the current bytes of every path it lists. A rep with no treediff file says MISSING — not 0.
|
|
383
|
+
# Appended AFTER score so no verdict row can move; score_rc is untouched.
|
|
384
|
+
{
|
|
385
|
+
echo ""
|
|
386
|
+
echo "## State fingerprint (record only — not scored)"
|
|
387
|
+
echo ""
|
|
388
|
+
while IFS= read -r id; do
|
|
389
|
+
[ -z "$id" ] && continue
|
|
390
|
+
for arm in primary control control_b; do
|
|
391
|
+
[ "$arm" = control_b ] && [ ! -f "$SPEC_DIR/$id.control_b.txt" ] && continue
|
|
392
|
+
r=1
|
|
393
|
+
while [ "$r" -le "$REPS" ]; do
|
|
394
|
+
td="$OUTDIR/$id/${arm}_r${r}.treediff.txt"
|
|
395
|
+
if [ ! -f "$td" ]; then
|
|
396
|
+
echo "state-fingerprint: $id $arm r$r treediff=MISSING"
|
|
397
|
+
elif [ ! -r "$td" ]; then
|
|
398
|
+
echo "state-fingerprint: $id $arm r$r treediff=UNREADABLE"
|
|
399
|
+
else
|
|
400
|
+
n=$(grep -c . "$td" 2>/dev/null); n=${n:-0}
|
|
401
|
+
# A listed path we cannot read as bytes is counted as unhashed and the line says how many,
|
|
402
|
+
# so «same hash» never silently covers it: git-quoted paths (spaces, non-ASCII — not decoded
|
|
403
|
+
# here), rename records («a -> b»), unreadable files, directories holding unreadable files.
|
|
404
|
+
# Directories (?? dir/) are otherwise hashed over their files in sorted order.
|
|
405
|
+
uh=0; body="$(mktemp "${TMPDIR:-/tmp}/fh-sfp.XXXXXX")"; cat "$td" > "$body"
|
|
406
|
+
while IFS= read -r p; do
|
|
407
|
+
f="$OUTDIR/$id/w_${arm}_r${r}/repo/$p"
|
|
408
|
+
case "$p" in
|
|
409
|
+
(\"*|*" -> "*) uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body" ;;
|
|
410
|
+
(*)
|
|
411
|
+
if [ -d "$f" ]; then
|
|
412
|
+
# find output and rc captured apart: a failing find counts the path as unhashed,
|
|
413
|
+
# never as «no unreadable files» (pipefail class-lock lane L12c).
|
|
414
|
+
_bad="$(find "$f" -type f ! -perm -u=r 2>/dev/null)"; _brc=$?
|
|
415
|
+
_all="$(find "$f" -type f 2>/dev/null)"; _arc=$?
|
|
416
|
+
if [ "$_brc" -ne 0 ] || [ "$_arc" -ne 0 ] || [ -n "$_bad" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
|
|
417
|
+
else
|
|
418
|
+
_sorted="$(printf '%s\n' "$_all" | LC_ALL=C sort)"
|
|
419
|
+
while IFS= read -r g; do
|
|
420
|
+
[ -n "$g" ] || continue
|
|
421
|
+
echo "<f:${g#"$f"}>" >> "$body"
|
|
422
|
+
cat "$g" >> "$body" || { uh=$((uh + 1)); echo "<unhashed:$g>" >> "$body"; }
|
|
423
|
+
done <<< "$_sorted"
|
|
424
|
+
fi
|
|
425
|
+
elif [ -e "$f" ] && [ ! -r "$f" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
|
|
426
|
+
elif [ -f "$f" ]; then cat "$f" >> "$body"
|
|
427
|
+
else echo "<absent:$p>" >> "$body"; fi ;;
|
|
428
|
+
esac
|
|
429
|
+
done < <(cut -c4- "$td")
|
|
430
|
+
h=$(shasum -a 256 < "$body" | cut -c1-16); rm -f "$body"
|
|
431
|
+
echo "state-fingerprint: $id $arm r$r changed=$n unhashed=$uh sha256=$h"
|
|
432
|
+
fi
|
|
433
|
+
r=$((r + 1))
|
|
434
|
+
done
|
|
435
|
+
done
|
|
436
|
+
done < "$SPEC_DIR/selected_ids.txt"
|
|
437
|
+
} >> "$REPORT_PATH"
|
|
438
|
+
|
|
378
439
|
if [ -n "$EVIDENCE_DIR" ]; then
|
|
379
440
|
# The report is part of the evidence: a preserved body set with no verdict beside it forces the
|
|
380
441
|
# next reader to re-derive what the run concluded.
|
|
@@ -344,6 +344,13 @@ def _failure_reason(base, arm):
|
|
|
344
344
|
(sim_isolated_run.sh prints "(rc=<n>, ...)" there) and bytes from the actual output file's
|
|
345
345
|
size (0 for a file that was never written). Purely a diagnostic label for the report/console —
|
|
346
346
|
never used by score_probe, which stays unchanged."""
|
|
347
|
+
rc = _runner_rc(base, arm, 1)
|
|
348
|
+
said = _read_first_line(os.path.join(base, '%s_r1.txt' % arm)) if rc is not None else None
|
|
349
|
+
if said:
|
|
350
|
+
# The arm wrote text but the runner says it did not finish (a usage-limit reply) — show
|
|
351
|
+
# the rc AND what it said, since the text is exactly what the old scorer mistook for an answer.
|
|
352
|
+
# Empty text falls through to stderr, which then holds the real error.
|
|
353
|
+
return 'rc=%s (runner): %s' % (rc, said)
|
|
347
354
|
stderr_line = _read_first_line(os.path.join(base, '%s_r1.stderr.txt' % arm))
|
|
348
355
|
if stderr_line:
|
|
349
356
|
return stderr_line
|
|
@@ -402,6 +409,25 @@ def _read_meta_tsv(path):
|
|
|
402
409
|
return out
|
|
403
410
|
|
|
404
411
|
|
|
412
|
+
def _runner_rc(base, arm, i):
|
|
413
|
+
"""The runner's recorded exit code for <arm>_r<i> when it is NONZERO, else None. A nonzero rc
|
|
414
|
+
means the rep did not finish (measured 2026-11-10/11: every usage-limit reply — 156 files across
|
|
415
|
+
a model-arms run and nightly 2026-10-27 — carried rc=1, every normal reply rc=0). The reply text
|
|
416
|
+
is never inspected: a normal answer that quotes limit wording must still be scored. No meta.tsv
|
|
417
|
+
(older runs) or no rc key -> None, i.e. scored exactly as before."""
|
|
418
|
+
m = _read_meta_tsv(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)))
|
|
419
|
+
rc = (m or {}).get('rc', '')
|
|
420
|
+
return rc if rc not in ('', '0') else None
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def _rep_text(base, arm, i):
|
|
424
|
+
"""Text of <arm>_r<i>, or None when the runner recorded a nonzero rc for it — so score_probe
|
|
425
|
+
returns FAILED-TO-RUN for a reply that exists but came from a run that did not finish."""
|
|
426
|
+
if _runner_rc(base, arm, i) is not None:
|
|
427
|
+
return None
|
|
428
|
+
return _read_text(os.path.join(base, '%s_r%d.txt' % (arm, i)))
|
|
429
|
+
|
|
430
|
+
|
|
405
431
|
def budget_line(base, arms_reps):
|
|
406
432
|
"""BUDGET LINE (2026-10-17): the cap each verdict row ran under and whether any episode ENDED
|
|
407
433
|
AT it. Read from the runner's per-episode meta.tsv (written from the real invocation) — never
|
|
@@ -409,7 +435,7 @@ def budget_line(base, arms_reps):
|
|
|
409
435
|
its cap; otherwise UNKNOWN when any episode's value is UNKNOWN or its meta/field is missing
|
|
410
436
|
(an older run, or a stub that wrote none — not measured is not `no`); otherwise no.
|
|
411
437
|
Returns (ended_at_cap, text, n_yes, n_eps)."""
|
|
412
|
-
ends, caps = [], set()
|
|
438
|
+
ends, caps, walls, wall_missing = [], set(), [], 0
|
|
413
439
|
for arm, i in arms_reps:
|
|
414
440
|
m = _read_meta_tsv(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)))
|
|
415
441
|
if m is None:
|
|
@@ -418,8 +444,14 @@ def budget_line(base, arms_reps):
|
|
|
418
444
|
# let 2 `no` + 1 missing read as `no`).
|
|
419
445
|
if os.path.exists(os.path.join(base, '%s_r%d.txt' % (arm, i))):
|
|
420
446
|
ends.append('UNKNOWN')
|
|
447
|
+
wall_missing += 1
|
|
421
448
|
continue
|
|
422
449
|
ends.append(m.get('ended_at_cap', 'UNKNOWN') or 'UNKNOWN')
|
|
450
|
+
w = m.get('wall_s', '') or ''
|
|
451
|
+
if re.fullmatch(r'[0-9]{1,9}', w): # ASCII digits only — '²'.isdigit() is True (codex R1)
|
|
452
|
+
walls.append(int(w))
|
|
453
|
+
else:
|
|
454
|
+
wall_missing += 1
|
|
423
455
|
caps.add('timeout=%ss max_turns=%s tokens=%s' % (
|
|
424
456
|
m.get('timeout_s', '?'), m.get('max_turns', '?'), m.get('token_cap', '?')))
|
|
425
457
|
if not caps:
|
|
@@ -433,6 +465,17 @@ def budget_line(base, arms_reps):
|
|
|
433
465
|
end = 'no'
|
|
434
466
|
text = '%s ended_at_cap=%s%s' % ('; '.join(sorted(caps)), end,
|
|
435
467
|
' (%d/%d episodes)' % (n_yes, len(ends)) if n_yes else '')
|
|
468
|
+
# COST AXIS (2026-11-12, arXiv:2611.13541 / 2611.12122): a separate record next to the 1-bit
|
|
469
|
+
# verdict, never folded into it. Wall seconds only; tokens are not captured by the single-shot
|
|
470
|
+
# runner (plain-text output) and are printed as UNMEASURED, not 0.
|
|
471
|
+
if walls:
|
|
472
|
+
text += ' wall_s=%d..%d' % (min(walls), max(walls))
|
|
473
|
+
if wall_missing:
|
|
474
|
+
text += ' (%d/%d episodes unmeasured)' % (wall_missing, len(walls) + wall_missing)
|
|
475
|
+
else:
|
|
476
|
+
text += ' wall_s=UNMEASURED'
|
|
477
|
+
text += ' tokens_used=UNMEASURED'
|
|
478
|
+
|
|
436
479
|
return end, text, n_yes, len(ends)
|
|
437
480
|
|
|
438
481
|
|
|
@@ -475,15 +518,15 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
|
|
|
475
518
|
ctrl_b_absent = False # rep-1 only, diagnostic: which arm actually produced nothing
|
|
476
519
|
per_rep = [] # [(verdict, phit, chit, primary_text, control_text)]
|
|
477
520
|
for i in range(1, reps + 1):
|
|
478
|
-
pt =
|
|
479
|
-
ct =
|
|
521
|
+
pt = _rep_text(base, 'primary', i)
|
|
522
|
+
ct = _rep_text(base, 'control', i)
|
|
480
523
|
ct_first_arm_ran = bool(ct)
|
|
481
524
|
if has_ctrl_b:
|
|
482
525
|
# A declared second control that produced nothing did NOT run — and a probe whose
|
|
483
526
|
# calibration arm did not run has not been calibrated. Collapsing that into "the
|
|
484
527
|
# control stayed silent, so the pattern discriminates" is the not-found-is-not-zero
|
|
485
528
|
# defect pointed at the calibration channel instead of the measurement channel.
|
|
486
|
-
ctb =
|
|
529
|
+
ctb = _rep_text(base, 'control_b', i)
|
|
487
530
|
if not ctb:
|
|
488
531
|
ct = None
|
|
489
532
|
if i == 1 and ct_first_arm_ran:
|
package/scripts/selfcheck.sh
CHANGED
|
@@ -1184,6 +1184,8 @@ for _pair in \
|
|
|
1184
1184
|
"scripts/ablation_nominate.py|scripts/test_ablation_nominate_lanes.sh" \
|
|
1185
1185
|
`# 리스 기록 채널(2026-11-07). 세션은 초안, 기록은 운영자 — 에이전트 셸 거부 · 코드 불일치 무기록 · 원자적 교체.` \
|
|
1186
1186
|
"scripts/lease_line_apply.sh|scripts/test_lease_line_apply_lanes.sh" \
|
|
1187
|
+
`# 공유 세션 장부(2026-11-11 시범). 실무 세션이 쓰고 루트가 읽는다 — 안 적은 세션은 NOT-WRITTEN, 깨진 줄은 MALFORMED.` \
|
|
1188
|
+
"scripts/session_ledger_read.py|scripts/test_session_ledger_lanes.sh" \
|
|
1187
1189
|
`# 맥락 유지 읽는 절반(2026-11-07). 상태 주장 뒤 리스 줄 한 줄 · 착지 판정 — 못 읽음은 OK 가 아니다.` \
|
|
1188
1190
|
"scripts/state_claim_recheck_hook.sh|scripts/test_state_claim_recheck_lanes.sh" \
|
|
1189
1191
|
"scripts/governor_landing_check.py|scripts/test_governor_landing_check_lanes.sh" \
|
|
@@ -1236,6 +1238,7 @@ for _pair in \
|
|
|
1236
1238
|
`# ── mutation_probe (2026-10-07) — revert_probe 의 «저자가 고른 변이 1개» 를 연산자 생성 변이로 넓힌 것. 앵커가 고정하는 것은 생성기 보정(리다이렉트 비변이)과 «못 잰 것은 2» 다 ──` \
|
|
1237
1239
|
"scripts/mutation_probe.py|scripts/test_mutation_probe_lanes.sh" \
|
|
1238
1240
|
"scripts/cartridge_admit.py|scripts/test_cartridge_admit_lanes.sh" \
|
|
1241
|
+
"scripts/agent_tools_pin.txt|scripts/test_agent_tools_pin_lanes.sh" \
|
|
1239
1242
|
`# ── live-eval — the live twin of the static /prompt-regression probe check (2026-09-04) ──` \
|
|
1240
1243
|
"scripts/probe_live_eval.sh|scripts/test_probe_live_eval_lanes.sh" \
|
|
1241
1244
|
"scripts/probe_live_eval_lib.py|scripts/test_probe_live_eval_lanes.sh" \
|
|
@@ -1251,6 +1254,7 @@ for _pair in \
|
|
|
1251
1254
|
# 운영자 지적: «내 발화가 도중에 열화되었다 … 테스트 한 차례 끝날 때마다 들여다봐야 할 것 같다».
|
|
1252
1255
|
# SUBJECT 를 session_checklist.py 로 잡는다 — 이 레인이 재는 것은 그 도구의 판정이다.` \
|
|
1253
1256
|
"scripts/session_checklist.py|scripts/test_checklist_unblocked_lanes.sh" \
|
|
1257
|
+
"scripts/claim_precision_report.py|scripts/test_claim_precision_report_lanes.sh" \
|
|
1254
1258
|
"templates/.git-hooks/pre-commit|scripts/test_hook_leg_wiring_lanes.sh" \
|
|
1255
1259
|
".claude/soul_tenets.txt|scripts/test_marker_soul_tenet_lanes.sh" \
|
|
1256
1260
|
"docs/map/fh_assets.architecture.json|scripts/test_fh_map_paths_lanes.sh" \
|
|
@@ -1282,6 +1286,7 @@ for _pair in \
|
|
|
1282
1286
|
"scripts/proposal_hook.sh|scripts/test_proposal_hook_lanes.sh" \
|
|
1283
1287
|
"plugins/fh-commons/skills/ko-tech-writer/SKILL.md|scripts/test_ko_tech_writer_lanes.sh" \
|
|
1284
1288
|
"scripts/absorption_queue.py|scripts/test_absorption_queue_lanes.sh" \
|
|
1289
|
+
"scripts/catch_tally.py|scripts/test_catch_tally_lanes.sh" \
|
|
1285
1290
|
"scripts/digest_slow_leg.py|scripts/test_digest_slow_leg_lanes.sh" \
|
|
1286
1291
|
"scripts/script_caller_ratchet.sh|scripts/test_script_caller_ratchet_lanes.sh" \
|
|
1287
1292
|
"scripts/script_caller_ratchet.sh|scripts/test_runner_surface_index_lanes.sh" \
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# selfdev_merge_tier.sh — may an unattended self-dev PR merge on its own, or does it wait for the
|
|
3
|
+
# operator? A CLASSIFIER OF THE CHANGED FILE LIST, not a judgment of the change.
|
|
4
|
+
#
|
|
5
|
+
# WHY (operator, 2026-11-04 — «가로 ㄱㄱ», CLAUDE.local.md §FH 자체개발 자율화): reversible changes
|
|
6
|
+
# (doc lines, new lanes) merge unattended once CI is green + 4-axis + cross-family; anything that
|
|
7
|
+
# touches a gate, a verdict enum or an irreversible path waits for the morning report. The split is
|
|
8
|
+
# decided HERE by path, mechanically, so the unattended session that wrote the change never grades
|
|
9
|
+
# its own merge (author ≠ judge — CLAUDE.md §Mechanization Boundary: a check asserts a property of
|
|
10
|
+
# the record, not a conclusion).
|
|
11
|
+
#
|
|
12
|
+
# ALLOW-LIST, NOT DENY-LIST. A path is AUTO-eligible only if it matches a class below; every other
|
|
13
|
+
# path — including any path nobody thought of yet — is HOLD. A deny-list would fail open on the
|
|
14
|
+
# first new file type; this fails closed.
|
|
15
|
+
# AUTO-eligible (all must hold for EVERY changed path):
|
|
16
|
+
# docs/**/*.md
|
|
17
|
+
# knowledge/**/*.md except knowledge/shared/rules/** (relocated protocol rules)
|
|
18
|
+
# except knowledge/shared/harness-core/*gate*.md · *irreversib*.md
|
|
19
|
+
# plugins/*/skills/*/SKILL.md · SKILL_detail.md unless a CHANGED line (+ or −) carries verdict /
|
|
20
|
+
# scoring vocabulary (VERDICT_RE below) — a skill's rubric IS its
|
|
21
|
+
# instrument, and loosening it is the #1063 shape (AQ-20261109-6).
|
|
22
|
+
# Needs the diff: --pr fetches it, --files takes --diff <file>; a
|
|
23
|
+
# skill path whose lines cannot be read is HOLD, never AUTO.
|
|
24
|
+
# CATALOG.md
|
|
25
|
+
# scripts/test_*.sh ADDED only (status A) — a new lane cannot change what ships;
|
|
26
|
+
# an edited lane can silently weaken a gate, so M → HOLD
|
|
27
|
+
# plus: total changed lines ≤ SELFDEV_MAX_LINES (default 300).
|
|
28
|
+
# Everything else → HOLD: CLAUDE.md · AGENTS.md · .claude/** · templates/** (git hooks, field rules)
|
|
29
|
+
# · scripts/** (other than an added lane) · .github/** · package.json · plugins/*/hooks/** · etc.
|
|
30
|
+
#
|
|
31
|
+
# 🟥 EMPTY INPUT IS NOT «ALL ALLOWED». `all()` over an empty set is true; an empty file list here
|
|
32
|
+
# means the instrument did not see the change, so it is HARNESS-ERROR (rc 2), never AUTO.
|
|
33
|
+
# (feedback_not_found_is_not_zero_family — 7th face, the empty set passing a universal check.)
|
|
34
|
+
#
|
|
35
|
+
# INPUT one line per changed path: «<status>\t<path>\t<added>\t<deleted>» (status A/M/D/R…)
|
|
36
|
+
# from a file (--files <f>) or from a PR (--pr <n> [--repo owner/name], via gh).
|
|
37
|
+
# OUTPUT TIER=AUTO|HOLD|HARNESS-ERROR on the last line; one «reason:» line per HOLD path.
|
|
38
|
+
# RC 0 AUTO · 3 HOLD · 2 HARNESS-ERROR
|
|
39
|
+
#
|
|
40
|
+
# NAMED RESIDUALS: ⓐ a SKILL.md edit is reversible but changes behaviour — allowed on the operator's
|
|
41
|
+
# «문서 줄» wording; the 4-axis gate and cross-family review are what stand behind it, not this
|
|
42
|
+
# script. Since AQ-20261109-6 the verdict-vocabulary edits among them are HOLD; a rubric loosened in
|
|
43
|
+
# words the list does not carry still reaches AUTO, and so does a rubric living in docs/ or
|
|
44
|
+
# knowledge/ (only skill files are line-checked). Measured 2026-11-09 on the last 273 SKILL commits
|
|
45
|
+
# on main: 155 (57%, case-sensitive) carry the vocabulary in a changed line — the over-hold cost, paid in the morning
|
|
46
|
+
# report, not in an unattended merge. Case-insensitive since codex R1: 185 (68%). ⓑ CI-green and the cross-family marker are checked by the caller (selfdev_loop.sh), not
|
|
47
|
+
# here — this script sees paths only.
|
|
48
|
+
|
|
49
|
+
set -u
|
|
50
|
+
# the ceiling may be LOWERED by env, never raised, and a non-number is HARNESS-ERROR (codex R1 #6)
|
|
51
|
+
MAX_LINES="${SELFDEV_MAX_LINES:-300}"
|
|
52
|
+
case "$MAX_LINES" in ''|*[!0-9]*) echo "reason: SELFDEV_MAX_LINES=«$MAX_LINES» is not a number"; echo "TIER=HARNESS-ERROR"; exit 2 ;; esac
|
|
53
|
+
[ "${#MAX_LINES}" -gt 4 ] || [ "$((10#$MAX_LINES))" -gt 300 ] && MAX_LINES=300
|
|
54
|
+
MAX_LINES=$((10#$MAX_LINES))
|
|
55
|
+
FILES=""; PR=""; DIFF=""; REPO="chrono-meta/forge-harness"
|
|
56
|
+
# verdict / scoring vocabulary: the enum words FH verdicts use, plus the words a rubric is written in
|
|
57
|
+
VERDICT_RE='\b(PASS|FAIL|BLOCKED|HOLD|ESCALATE|PENDING|UNCALIBRATED|UNMEASURED|HARNESS[-_ ]ERROR|INCONCLUSIVE)\b|verdict|threshold|expect_re|rubric|판정|채점|문턱'
|
|
58
|
+
while [ $# -gt 0 ]; do
|
|
59
|
+
case "$1" in
|
|
60
|
+
--files) FILES="$2"; shift 2 ;;
|
|
61
|
+
--pr) PR="$2"; shift 2 ;;
|
|
62
|
+
--repo) REPO="$2"; shift 2 ;;
|
|
63
|
+
--diff) DIFF="$2"; shift 2 ;;
|
|
64
|
+
*) echo "unknown arg: $1" >&2; echo "TIER=HARNESS-ERROR"; exit 2 ;;
|
|
65
|
+
esac
|
|
66
|
+
done
|
|
67
|
+
|
|
68
|
+
TMP="$(mktemp)"; DTMP="$(mktemp)"; trap 'rm -f "$TMP" "$DTMP"' EXIT
|
|
69
|
+
DIFF_OK=0
|
|
70
|
+
if [ -n "$PR" ]; then
|
|
71
|
+
if ! out="$(gh pr view "$PR" -R "$REPO" --json files \
|
|
72
|
+
-q '.files[] | "\(.changeType)\t\(.path)\t\(.additions)\t\(.deletions)"' 2>&1)"; then
|
|
73
|
+
echo "reason: gh pr view failed — $out"; echo "TIER=HARNESS-ERROR"; exit 2
|
|
74
|
+
fi
|
|
75
|
+
# gh changeType words → git status letters
|
|
76
|
+
printf '%s\n' "$out" | sed -E 's/^ADDED\t/A\t/; s/^MODIFIED\t/M\t/; s/^DELETED\t/D\t/; s/^RENAMED\t/R\t/; s/^CHANGED\t/M\t/; s/^COPIED\t/C\t/' > "$TMP"
|
|
77
|
+
# the diff is only needed for skill files; a failed fetch leaves DIFF_OK=0 and those paths HOLD
|
|
78
|
+
gh pr diff "$PR" -R "$REPO" > "$DTMP" 2>/dev/null && [ -s "$DTMP" ] && DIFF_OK=1
|
|
79
|
+
elif [ -n "$FILES" ] && [ -f "$FILES" ]; then
|
|
80
|
+
cp "$FILES" "$TMP"
|
|
81
|
+
if [ -n "$DIFF" ] && [ -s "$DIFF" ]; then cp "$DIFF" "$DTMP"; DIFF_OK=1; fi
|
|
82
|
+
else
|
|
83
|
+
echo "reason: no input (--files <existing file> or --pr <n>)"; echo "TIER=HARNESS-ERROR"; exit 2
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
n=0; hold=0; total=0
|
|
87
|
+
while IFS=$'\t' read -r st path add del; do
|
|
88
|
+
[ -z "${path:-}" ] && continue
|
|
89
|
+
n=$((n+1))
|
|
90
|
+
# bounded decimals only: a 19-digit count wraps the sum negative, «08» is octal to bash (codex R1 #9)
|
|
91
|
+
case "${add:-x}${del:-x}" in *[!0-9]*) echo "reason: $path — line counts unreadable ($add/$del)"; hold=1; continue ;; esac
|
|
92
|
+
if [ "${#add}" -gt 6 ] || [ "${#del}" -gt 6 ]; then echo "reason: $path — line count out of range ($add/$del)"; hold=1; continue; fi
|
|
93
|
+
total=$((total + 10#$add + 10#$del))
|
|
94
|
+
ok=0
|
|
95
|
+
# a rename/copy is classified by its destination only, so a protected SOURCE path could leave the
|
|
96
|
+
# tree unseen — every R/C is HOLD (codex R1 #4)
|
|
97
|
+
case "$st" in R*|C*) echo "reason: $path — status $st (rename/copy: source path not classified)"; hold=1; continue ;; esac
|
|
98
|
+
case "$path" in
|
|
99
|
+
knowledge/shared/rules/*) ok=0 ;;
|
|
100
|
+
knowledge/shared/harness-core/*gate*.md|knowledge/shared/harness-core/*irreversib*.md) ok=0 ;;
|
|
101
|
+
docs/*.md|docs/*/*.md|docs/*/*/*.md) ok=1 ;;
|
|
102
|
+
knowledge/*.md|knowledge/*/*.md|knowledge/*/*/*.md|knowledge/*/*/*/*.md) ok=1 ;;
|
|
103
|
+
plugins/*/skills/*/SKILL.md|plugins/*/skills/*/SKILL_detail.md)
|
|
104
|
+
if [ "$DIFF_OK" -ne 1 ]; then
|
|
105
|
+
echo "reason: $path — skill file, but its changed lines could not be read (no --diff / gh pr diff failed)"; hold=1; continue
|
|
106
|
+
fi
|
|
107
|
+
# changed lines of THIS file only: its «diff --git» section, header lines skipped only BEFORE the first
|
|
108
|
+
# @@ (a removed content line «-- x» shows as «--- x» inside a hunk — codex R1), +/− lines printed with
|
|
109
|
+
# their sign so an empty changed line still counts
|
|
110
|
+
vlines="$(awk -v p="$path" '
|
|
111
|
+
/^diff --git / { on = ($0 == "diff --git a/" p " b/" p); hdr = 1; next }
|
|
112
|
+
on && hdr && /^@@/ { hdr = 0; next }
|
|
113
|
+
on && hdr { next }
|
|
114
|
+
on && /^@@/ { next }
|
|
115
|
+
on && /^[-+]/ { print }' "$DTMP")"
|
|
116
|
+
# the diff must carry every changed line the file list counts — a partial diff is not the change (codex R1)
|
|
117
|
+
vn="$(printf '%s' "$vlines" | grep -c '^[-+]')"
|
|
118
|
+
case "$vn" in ''|*[!0-9]*) vn=-1 ;; esac # grep failed → a count nobody read, never a match
|
|
119
|
+
if [ -z "$vlines" ] || [ "$vn" -ne $((10#$add + 10#$del)) ]; then
|
|
120
|
+
echo "reason: $path — the diff shows ${vn:-0} changed line(s) for this skill, the file list counts $((10#$add + 10#$del)) (instrument did not see all its lines)"; hold=1; continue
|
|
121
|
+
fi
|
|
122
|
+
# case-insensitive: «pass when any check succeeds» is a rubric too (codex R1). grep rc 2 (error) is HOLD, not «no match».
|
|
123
|
+
# no other command in this pipe: a failing `cut` once handed grep nothing and the rc said «no match» (codex R2)
|
|
124
|
+
printf '%s\n' "$vlines" | grep -Eiq "$VERDICT_RE"; grc=$?
|
|
125
|
+
if [ "$grc" -eq 0 ]; then
|
|
126
|
+
echo "reason: $path — a changed line carries verdict/scoring vocabulary («$(printf '%s\n' "$vlines" | cut -c2- | grep -Eio "$VERDICT_RE" | head -1)»): a skill's rubric is its instrument"; hold=1; continue
|
|
127
|
+
elif [ "$grc" -ne 1 ]; then
|
|
128
|
+
echo "reason: $path — vocabulary check failed (grep rc=$grc); unread is not clean"; hold=1; continue
|
|
129
|
+
fi
|
|
130
|
+
ok=1 ;;
|
|
131
|
+
CATALOG.md) ok=1 ;;
|
|
132
|
+
scripts/test_*.sh) [ "$st" = "A" ] && ok=1 ;;
|
|
133
|
+
esac
|
|
134
|
+
if [ "$ok" -ne 1 ]; then
|
|
135
|
+
hold=1
|
|
136
|
+
if [ "${path#scripts/test_}" != "$path" ]; then
|
|
137
|
+
echo "reason: $path — status $st (only an ADDED lane is auto-eligible; an edited lane can weaken a gate)"
|
|
138
|
+
else
|
|
139
|
+
echo "reason: $path — outside the auto-merge allow-list"
|
|
140
|
+
fi
|
|
141
|
+
fi
|
|
142
|
+
done < "$TMP"
|
|
143
|
+
|
|
144
|
+
if [ "$n" -eq 0 ]; then
|
|
145
|
+
echo "reason: changed-file list is empty — the instrument saw no change, which is not «all allowed»"
|
|
146
|
+
echo "TIER=HARNESS-ERROR"; exit 2
|
|
147
|
+
fi
|
|
148
|
+
if [ "$total" -gt "$MAX_LINES" ]; then
|
|
149
|
+
echo "reason: $total changed lines > $MAX_LINES (SELFDEV_MAX_LINES)"; hold=1
|
|
150
|
+
fi
|
|
151
|
+
echo "files=$n lines=$total"
|
|
152
|
+
if [ "$hold" -eq 1 ]; then echo "TIER=HOLD"; exit 3; fi
|
|
153
|
+
echo "TIER=AUTO"; exit 0
|
|
@@ -177,8 +177,42 @@ EXCLUDE_ENVELOPES = (
|
|
|
177
177
|
("<local-command-caveat>", "</local-command-caveat>", "end"),
|
|
178
178
|
("<command-name>", "<command-message>", "in"),
|
|
179
179
|
("Caveat: The messages below were generated by the user while running local commands", "", ""), # v6: the synthetic caveat sentence itself
|
|
180
|
+
# v12 (2026-11-08 harvest H1): the desktop app's side-session event, measured 70× in one governor transcript
|
|
181
|
+
# behind leading reminder blocks (origin absent · promptSource=sdk) — only reachable after the leading strip below
|
|
182
|
+
("<side-sessions-event>", "</side-sessions-event>", "end"),
|
|
180
183
|
)
|
|
181
184
|
|
|
185
|
+
# v12 (2026-11-08 harvest H1): the desktop app PREPENDS complete `<system-reminder>…</system-reminder>` blocks (up to 9
|
|
186
|
+
# measured, stacked) to the operator's own words in the same entry. Strip only LEADING, COMPLETE blocks — the opening
|
|
187
|
+
# tag may carry attributes (no `<` inside them: an unclosed opener must not swallow a later block — codex R2); a block whose body holds another opening tag is not complete (an unclosed look-alike
|
|
188
|
+
# before a real block is kept); a mid-text tag is never touched. If nothing but blocks remains, the text is returned
|
|
189
|
+
# unchanged, so L39 (a human entry that is only an envelope stays a row) and the full-envelope exclusion still hold.
|
|
190
|
+
LEADING_REMINDER_RE = re.compile(
|
|
191
|
+
r"\A\s*<system-reminder(?:\s[^<>]*)?>(?:(?!<system-reminder(?:\s|>)).)*?</system-reminder>", re.S)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _leading_reminder_split(text):
|
|
195
|
+
rest, n = text, 0
|
|
196
|
+
while True:
|
|
197
|
+
m = LEADING_REMINDER_RE.match(rest)
|
|
198
|
+
if not m:
|
|
199
|
+
return n, rest
|
|
200
|
+
rest, n = rest[m.end():], n + 1
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def only_reminder_blocks(text):
|
|
204
|
+
n, rest = _leading_reminder_split(text or "")
|
|
205
|
+
return n > 0 and not rest.strip()
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def strip_leading_reminders(text):
|
|
209
|
+
if not text:
|
|
210
|
+
return text
|
|
211
|
+
n, rest = _leading_reminder_split(text)
|
|
212
|
+
if n and rest.strip():
|
|
213
|
+
return rest.lstrip()
|
|
214
|
+
return text
|
|
215
|
+
|
|
182
216
|
COMPACTION_PREFIX = "This session is being continued from a previous conversation"
|
|
183
217
|
|
|
184
218
|
# v4 (codex round 3): the compaction heading is localized in Korean sessions — an alias table, not one spelling.
|
|
@@ -243,6 +277,8 @@ def is_excluded(text, entry):
|
|
|
243
277
|
return True
|
|
244
278
|
if has_metadata(entry) and origin_kind(entry) == "":
|
|
245
279
|
pass # metadata present but no origin — fall through to the text validators
|
|
280
|
+
if only_reminder_blocks(text):
|
|
281
|
+
return True # v12 (codex R1): an envelope-only entry whose opener carries attributes, or several stacked blocks
|
|
246
282
|
stripped = text.lstrip()
|
|
247
283
|
for p, companion, where in EXCLUDE_ENVELOPES:
|
|
248
284
|
if not stripped.startswith(p):
|
|
@@ -414,7 +450,7 @@ def read_hook_channel(path):
|
|
|
414
450
|
if not parse_ts_candidates(d.get("ts")):
|
|
415
451
|
bad += 1 # the hook always writes ts; without it the time window cannot apply, so the row is not trusted
|
|
416
452
|
continue
|
|
417
|
-
rows.append({"ts": d.get("ts"), "text": d["text"], "truncated": d.get("truncated") is True})
|
|
453
|
+
rows.append({"ts": d.get("ts"), "text": strip_leading_reminders(d["text"]), "truncated": d.get("truncated") is True}) # v12: same text as the transcript row it pairs with
|
|
418
454
|
except OSError as e:
|
|
419
455
|
return "error", [], 0, e.strerror or "unreadable"
|
|
420
456
|
return "read", rows, bad, ""
|
|
@@ -485,6 +521,7 @@ def do_extract(transcript_path, out_path, utterances_path=None):
|
|
|
485
521
|
if not has_text or text is None or text.strip() == "":
|
|
486
522
|
continue
|
|
487
523
|
text = text.lstrip("\ufeff") # v5: a BOM before the compaction prefix hid the summary channel
|
|
524
|
+
text = strip_leading_reminders(text) # v12: the operator's words, not the prepended reminder blocks
|
|
488
525
|
if entry.get("isCompactSummary") is True:
|
|
489
526
|
# v11: the flag Claude Code sets on compaction entries — primary signal; the text shape is the fallback
|
|
490
527
|
summary_texts.append(text)
|