fix(lib,reconcile,test): address Claude review findings and verify 100% PASS

- lib.sh: distinguish unobservable/headless (rc=2) from unsettled panes in _pane_quiescent; restore 10s quiescence window with early giveup (SKS_EMPTY_GIVEUP)
- reconcile.sh: fix SKILLS_DIR command substitution logic (&& pwd instead of || pwd)
- tests/test_b19_headless_reconcile_fixes.py: implement mutation-proven regression tests for headless prompt bypass, slow-settling panes with persistent counters, and real reconcile.sh SKILLS_DIR evaluation
- deploy/ & IMPROVEMENTS.md: document nats submodule access notes and B-19/B-20 evolution
- Promoted Reviewer Claude's final 100% PASS report (report-119b9f57.md)
This commit is contained in:
2026-08-23 20:57:38 +09:00
parent 6e2e9b1161
commit 31b2d70ffe
9 changed files with 428 additions and 95 deletions
+52 -30
View File
@@ -1575,18 +1575,31 @@ _wait_session_gone() {
return 1
}
# _pane_quiescent <sess> [tries=20] [interval=0.5]
# _pane_quiescent <sess> [tries=20] [interval=0.5] # empty_giveup: $SKS_EMPTY_GIVEUP (default: 3)
# Renderer settled = two consecutive identical non-empty captures.
# Defeats RC-A (Blessed/Ink renderer bottleneck) without a magic fixed sleep.
# Returns 0 if renderer settled (two identical non-empty captures).
# Returns 2 if unobservable/headless (consecutive empty captures reached empty_giveup without output).
# Returns 1 if output was observed but never stabilized within tries limit.
_pane_quiescent() {
local sess="$1" tries="${2:-20}" interval="${3:-0.5}" prev="__none__" cur i
local saw_output=0 empty_streak=0
local empty_giveup="${SKS_EMPTY_GIVEUP:-3}"
for ((i = 0; i < tries; i++)); do
cur=$(_pane_capture "$sess")
[ -z "$cur" ] && { sleep "$interval"; continue; }
if [ -z "$cur" ]; then
empty_streak=$((empty_streak + 1))
[ "$saw_output" = "0" ] && [ "$empty_streak" -ge "$empty_giveup" ] && return 2
sleep "$interval"
continue
fi
saw_output=1
empty_streak=0
[ "$cur" = "$prev" ] && return 0
prev="$cur"
sleep "$interval"
done
[ "$saw_output" = "0" ] && return 2
return 1
}
@@ -1599,17 +1612,50 @@ _pane_dialog_open() {
}
# send_keys_safe <sess> <text> [job_id]
# 1. Wait for renderer quiescence (RC-A).
# 1. Wait for renderer quiescence (RC-A). If unobservable (headless), bypass visual checks.
# 2. Refuse to paste while a dialog is open (RC-B/RC-C): wait up to
# SKS_DIALOG_TIMEOUT (default 30 s); if SKS_DIALOG_ESCAPE=1, send a single
# Escape per poll and re-check. NEVER a blind Enter.
# 3. Paste via unique buffer; verify the text landed (marker visible).
# 4. Submit C-m; verify submission (marker left the input area AND the pane
# 3. Native herdr 0.8+ RPC fast path: agent prompt handles atomic text + enter submission.
# 4. Paste via unique buffer; verify the text landed (marker visible).
# 5. Submit C-m; verify submission (marker left the input area AND the pane
# changed); retry up to 3 times.
send_keys_safe() {
local sess="$1" text="$2" job_id="${3:-adhoc}"
local pre_submit deadline try
local marker pre_submit deadline try
local _q_rc=0
_pane_quiescent "$sess" "${SKS_QUIESCENT_TRIES:-20}" "${SKS_QUIESCENT_INTERVAL:-0.5}" || _q_rc=$?
if [ "$_q_rc" = "1" ]; then
echo "send_keys_safe: pane never quiesced ($sess)" >&2
return 1
fi
if [ "$_q_rc" != "2" ]; then
deadline=$(( $(date +%s) + ${SKS_DIALOG_TIMEOUT:-30} ))
while _pane_dialog_open "$sess"; do
if [ "${SKS_DIALOG_ESCAPE:-0}" = "1" ]; then
_sks_herdr send-keys -t "$sess" Escape
sleep 1
fi
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "send_keys_safe: dialog blocking input ($sess)" >&2
return 2
fi
sleep 2
done
fi
local agent_target
agent_target=$(_sanitize_herdr_agent_name "$sess")
# Native herdr 0.8+ fast path: agent prompt handles atomic text + enter submission
# Gated behind quiescence and dialog checks; returns 0 on RPC success to prevent duplicate input
if _sks_herdr agent prompt "$agent_target" "$text" >/dev/null 2>&1 || _sks_herdr agent prompt "$sess" "$text" >/dev/null 2>&1; then
return 0
fi
# Fallback: paste buffer submission. Compute verification markers on demand.
local marker marker_norm
# Verification token: last 24 *characters* (not bytes — `tail -c` can split a
# multi-byte UTF-8 char, e.g. Korean, producing a marker that can never match
# the properly-decoded rendered pane text) of the last non-empty line.
@@ -1620,32 +1666,8 @@ send_keys_safe() {
# only '\n' still leaves an extra space that breaks an exact literal match.
# Matching with all whitespace collapsed out sidesteps wrap formatting
# entirely, whatever shape it takes.
local marker_norm
marker_norm=$(printf '%s' "$marker" | tr -d '[:space:]')
_pane_quiescent "$sess" || { echo "send_keys_safe: pane never quiesced ($sess)" >&2; return 1; }
deadline=$(( $(date +%s) + ${SKS_DIALOG_TIMEOUT:-30} ))
while _pane_dialog_open "$sess"; do
if [ "${SKS_DIALOG_ESCAPE:-0}" = "1" ]; then
_sks_herdr send-keys -t "$sess" Escape
sleep 1
fi
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "send_keys_safe: dialog blocking input ($sess)" >&2
return 2
fi
sleep 2
done
local agent_target
agent_target=$(_sanitize_herdr_agent_name "$sess")
# Native herdr 0.8+ fast path: agent prompt handles atomic text + enter submission
# Gated behind quiescence and dialog checks; returns 0 on RPC success to prevent duplicate input
if _sks_herdr agent prompt "$agent_target" "$text" >/dev/null 2>&1 || _sks_herdr agent prompt "$sess" "$text" >/dev/null 2>&1; then
return 0
fi
local sks_buf="sks_${sess}_${job_id}_$$_${RANDOM}_$(date +%s%N 2>/dev/null || date +%s)"
_sks_herdr set-buffer -b "$sks_buf" "$text"
_sks_herdr paste-buffer -b "$sks_buf" -t "$sess"