mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(docker): B5 tighten bash-guard denial message to 2 lines
Smoke run 3 showed the bash-guard hook emitting 8+ lines on every blocked shell-git op — enumerating every alternative MCP verb across roboco-flow / roboco-do / roboco-git-readonly. That's repeated token spend on every refused retry; the LLM doesn't need the full alt-list inline, it has the role prompt + the MCP tool schema for that. Trimmed to 2 lines: denial reason + a one-line pointer to the role's State→Verb table. Test asserts <= 3 echo lines in any denial block. Spec ref: docs/superpowers/specs/2026-05-12-post-smoke-3-fixes-design.md section B5.
This commit is contained in:
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke: bash-guard denial message is <= 3 lines (was 8+).
|
||||
# Smoke run 3 (2026-05-12) showed agents getting an 8-line refusal on
|
||||
# every blocked shell-git op. Tighter messages save tokens on retries.
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
HOOK=docker/scripts/bash-guard-hook.sh
|
||||
|
||||
# Count lines in the longest heredoc denial block (cat <<'EOF' ... EOF style).
|
||||
# The first git-network denial used a heredoc; awk counts echo-or-content
|
||||
# lines inside it.
|
||||
HEREDOC_LINES=$(awk '
|
||||
/cat <<'"'"'EOF'"'"'/ { in_block = 1; count = 0; next }
|
||||
in_block && /^EOF$/ { print count; in_block = 0; count = 0; next }
|
||||
in_block { count++ }
|
||||
END { if (in_block && count > 0) print count }
|
||||
' "$HOOK" | sort -n | tail -1)
|
||||
|
||||
# Also count contiguous echo-based denial blocks (other denial paths).
|
||||
ECHO_LINES=$(awk '
|
||||
/Denied/ { in_block = 1; count = 0 }
|
||||
in_block && /^[[:space:]]*echo/ { count++ }
|
||||
in_block && /^[[:space:]]*$/ && count > 0 { print count; in_block = 0; count = 0 }
|
||||
END { if (in_block && count > 0) print count }
|
||||
' "$HOOK" | sort -n | tail -1)
|
||||
|
||||
MAX_LINES=0
|
||||
[[ -n "$HEREDOC_LINES" && "$HEREDOC_LINES" -gt "$MAX_LINES" ]] && MAX_LINES=$HEREDOC_LINES
|
||||
[[ -n "$ECHO_LINES" && "$ECHO_LINES" -gt "$MAX_LINES" ]] && MAX_LINES=$ECHO_LINES
|
||||
|
||||
if [ "$MAX_LINES" -eq 0 ]; then
|
||||
echo "FAIL: could not find any denial message block in $HOOK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$MAX_LINES" -gt 3 ]; then
|
||||
echo "FAIL: bash-guard denial message has $MAX_LINES lines (max 3)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS: denial message has $MAX_LINES lines"
|
||||
Reference in New Issue
Block a user