fix: formula scripts broken on evolution box (#1006, #1007, #1008)

- red-team.sh: pipe prompt via stdin to avoid E2BIG (#1007)
- inject.sh: use tsx instead of ts-node for Node >= 22 ESM (#1008)
- evaluate.sh: add submodule init + forge build before kraiken-lib (#1006)
This commit is contained in:
openhands 2026-03-19 14:09:38 +00:00
parent 411c567cd6
commit fdf9338a86
3 changed files with 22 additions and 5 deletions

View file

@ -141,6 +141,19 @@ log "Creating worktree at $WORKTREE_DIR (branch: $PR_BRANCH)..."
git worktree add "$WORKTREE_DIR" "remotes/$REPO_REMOTE/$PR_BRANCH" \ git worktree add "$WORKTREE_DIR" "remotes/$REPO_REMOTE/$PR_BRANCH" \
|| infra_error "git worktree add failed for branch $PR_BRANCH" || infra_error "git worktree add failed for branch $PR_BRANCH"
# ── Initialize git submodules + install submodule npm deps ─────────────
log "Initializing submodules..."
(cd "$WORKTREE_DIR" && git submodule update --init --recursive 2>/dev/null) || true
# uni-v3-lib has its own node_modules (solidity deps via npm)
if [[ -f "$WORKTREE_DIR/onchain/lib/uni-v3-lib/package.json" ]]; then
(cd "$WORKTREE_DIR/onchain/lib/uni-v3-lib" && npm install --silent 2>/dev/null) || true
fi
# ── Compile Solidity contracts (needed by kraiken-lib for ABI imports) ──
log "Compiling contracts (forge build)..."
(cd "$WORKTREE_DIR/onchain" && forge build --silent) \
|| infra_error "forge build failed"
# ── Build kraiken-lib in the worktree ───────────────────────────────── # ── Build kraiken-lib in the worktree ─────────────────────────────────
log "Building kraiken-lib..." log "Building kraiken-lib..."
(cd "$WORKTREE_DIR" && ./scripts/build-kraiken-lib.sh) \ (cd "$WORKTREE_DIR" && ./scripts/build-kraiken-lib.sh) \

View file

@ -184,6 +184,7 @@ cleanup() {
if [[ -n "${SNAP:-}" ]]; then if [[ -n "${SNAP:-}" ]]; then
"$CAST" rpc anvil_revert "$SNAP" --rpc-url "$RPC_URL" >/dev/null 2>&1 || true "$CAST" rpc anvil_revert "$SNAP" --rpc-url "$RPC_URL" >/dev/null 2>&1 || true
fi fi
rm -f "${PROMPT_FILE:-}" 2>/dev/null || true
exit $rc exit $rc
} }
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM
@ -652,13 +653,15 @@ log "Spawning Claude red-team agent (timeout: ${CLAUDE_TIMEOUT}s)..."
log " Report will be written to: $REPORT" log " Report will be written to: $REPORT"
set +e set +e
# Write prompt to temp file to avoid "Argument list too long" (prompt can be 50KB+)
PROMPT_FILE=$(mktemp /tmp/red-team-prompt-XXXXXX.md)
printf '%s' "$PROMPT" > "$PROMPT_FILE"
# Note: --verbose is required by the claude CLI when --output-format stream-json is used; # Note: --verbose is required by the claude CLI when --output-format stream-json is used;
# omitting it causes the CLI to exit with an error, producing an empty stream log. # omitting it causes the CLI to exit with an error, producing an empty stream log.
timeout "$CLAUDE_TIMEOUT" claude -p --dangerously-skip-permissions \ # Run synchronously — timeout handles kill, no need to background
timeout "$CLAUDE_TIMEOUT" bash -c 'claude -p --dangerously-skip-permissions \
--verbose --output-format stream-json \ --verbose --output-format stream-json \
"$PROMPT" >"$STREAM_LOG" 2>&1 & <"$1" >"$2" 2>&1' _ "$PROMPT_FILE" "$STREAM_LOG"
CLAUDE_PID=$!
wait "$CLAUDE_PID"
AGENT_EXIT=$? AGENT_EXIT=$?
CLAUDE_PID="" CLAUDE_PID=""
set -e set -e

View file

@ -18,7 +18,8 @@ if [ ! -d "$SCRIPT_DIR/node_modules" ]; then
fi fi
# 1. Transpile Push3 → OptimizerV3Push3.sol (full contract) # 1. Transpile Push3 → OptimizerV3Push3.sol (full contract)
(cd "$SCRIPT_DIR" && npx ts-node src/index.ts "$PUSH3_FILE" "$TRANSPILER_OUT") || exit 1 # Use tsx (not ts-node) — ts-node ESM resolution is broken on Node ≥22.
(cd "$SCRIPT_DIR" && npx tsx src/index.ts "$PUSH3_FILE" "$TRANSPILER_OUT") || exit 1
# 2. Extract function body and inject between BEGIN/END markers in OptimizerV3.sol # 2. Extract function body and inject between BEGIN/END markers in OptimizerV3.sol
python3 - "$TRANSPILER_OUT" "$OPTIMIZERV3_SOL" <<'PYEOF' || exit 2 python3 - "$TRANSPILER_OUT" "$OPTIMIZERV3_SOL" <<'PYEOF' || exit 2