fix: address review feedback on evolution-daemon.sh (#748)

- Stream evolve.sh output directly to stderr instead of buffering in a
  command substitution; long runs (tens of minutes) are now visible live.
- Use an array (EVOLVE_ARGS) for evolve.sh arguments instead of an
  unquoted DIVERSE_FLAG string variable.
- Abort the current run (continue to next loop iteration) when the patch
  fails to apply, rather than silently running with wrong evaluation semantics.
- Fix notify() to pass the message via stdin to avoid SSH single-quote
  interpolation breakage on messages containing special characters.
- Fix step comment/counter mismatch: "Step 7" comment now reads "Step 6"
  to match the [6/7] log label for the summary-write step.
- Clarify in evolution.conf that GAS_LIMIT and ANCHOR_WIDTH_UNBOUNDED are
  documentation-only (they document what evolution.patch does); editing
  them has no runtime effect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-14 17:39:20 +00:00
parent bbf3b871b3
commit 524a05286e
2 changed files with 32 additions and 30 deletions

View file

@ -121,7 +121,9 @@ ts() {
notify() {
local msg="$*"
if [ -n "$OPENCLAW_SSH_TARGET" ]; then
ssh "$OPENCLAW_SSH_TARGET" "openclaw system event '$msg'" 2>/dev/null || true
# Pass message via stdin to avoid shell-quoting issues with special characters.
printf '%s\n' "$msg" | \
ssh "$OPENCLAW_SSH_TARGET" 'read -r _msg; openclaw system event "$_msg"' 2>/dev/null || true
fi
}
@ -190,7 +192,9 @@ while true; do
PATCH_APPLIED=true
log " Patches applied OK"
else
log " WARNING: patch failed to apply — running without evolution-specific overrides"
log " ERROR: patch failed to apply — skipping run (evaluation semantics would differ from intended)"
log " Hint: evolution.patch may need regeneration if onchain/ files changed upstream."
continue
fi
else
log "[2/7] No patch file — skipping"
@ -211,27 +215,24 @@ while true; do
log "[4/7] Starting evolve.sh…"
DIVERSE_FLAG=""
[ "$DIVERSE_SEEDS" = "true" ] && DIVERSE_FLAG="--diverse-seeds"
# Build argument array — avoids unquoted variable word-splitting.
EVOLVE_ARGS=(
--seed "$SEED"
--population "$POPULATION"
--generations "$GENERATIONS"
--mutation-rate "$MUTATION_RATE"
--elites "$ELITES"
--output "$OUTPUT_DIR"
)
[ "$DIVERSE_SEEDS" = "true" ] && EVOLVE_ARGS+=(--diverse-seeds)
# Stream evolve.sh output directly — do NOT buffer via $(...).
# A full run can take tens of minutes; buffering would make the daemon
# appear hung with no generation-level progress visible.
EVOLVE_EC=0
EVOLVE_OUT=""
EVOLVE_OUT=$(
EVAL_MODE="$EVAL_MODE" \
BASE_RPC_URL="$BASE_RPC_URL" \
bash "$EVOLVE_SH" \
--seed "$SEED" \
--population "$POPULATION" \
--generations "$GENERATIONS" \
--mutation-rate "$MUTATION_RATE" \
--elites "$ELITES" \
--output "$OUTPUT_DIR" \
$DIVERSE_FLAG \
2>&1
) || EVOLVE_EC=$?
# Always print evolve.sh output for visibility.
printf '%s\n' "$EVOLVE_OUT" >&2
EVAL_MODE="$EVAL_MODE" \
BASE_RPC_URL="$BASE_RPC_URL" \
bash "$EVOLVE_SH" "${EVOLVE_ARGS[@]}" || EVOLVE_EC=$?
if [ "$EVOLVE_EC" -ne 0 ]; then
log " WARNING: evolve.sh exited $EVOLVE_EC — results may be incomplete"
@ -293,7 +294,7 @@ PYEOF
# ── Steps 6 (seed admission already done by evolve.sh) ──────────────────────
# evolve.sh step 5 handles pool admission automatically.
# ── Step 7: Write summary report ────────────────────────────────────────────
# ── Step 6: Write summary report ────────────────────────────────────────────
RUN_END="$(date +%s)"
DURATION=$(( RUN_END - RUN_START ))

View file

@ -17,14 +17,15 @@ MUTATION_RATE=1
ELITES=2
DIVERSE_SEEDS=true
# ── Evolution-specific overrides (applied via evolution.patch) ──────────────────
# GAS_LIMIT: production cap is 200 000; evolution uses 500 000 to allow larger
# programs that are still worth exploring before gas optimisation.
GAS_LIMIT=500000
# ANCHOR_WIDTH_UNBOUNDED: removes the MAX_ANCHOR_WIDTH=100 production cap so
# programs can explore the full uint24 tick-width space.
ANCHOR_WIDTH_UNBOUNDED=true
# ── Evolution-specific overrides — DOCUMENTATION ONLY ──────────────────────────
# These two variables are NOT read by evolution-daemon.sh at runtime.
# They document the semantic intent of evolution.patch, which is the actual
# mechanism that changes the compiled Solidity constants before each run.
# Editing these values here has NO runtime effect; to change the overrides,
# regenerate evolution.patch (see the patch file for instructions).
#
# GAS_LIMIT=500000 (patch raises CALCULATE_PARAMS_GAS_LIMIT 200k→500k)
# ANCHOR_WIDTH_UNBOUNDED=true (patch sets MAX_ANCHOR_WIDTH to type(uint24).max)
# ── Notification (openclaw) ─────────────────────────────────────────────────────
# SSH target for `openclaw system event` notifications.