trace: add execution route visibility + debug passthrough; phase2170 canaries; docs
- Add HAKO_TRACE_EXECUTION to trace executor route - Rust hv1_inline: stderr [trace] executor: hv1_inline (rust) - Hakovm dispatcher: stdout [trace] executor: hakovm (hako) - test_runner: trace lines for hv1_inline/core/hakovm routes - Add HAKO_VERIFY_SHOW_LOGS and HAKO_DEBUG=1 (enables both) - verify_v1_inline_file() log passthrough with numeric rc extraction - test_runner exports via HAKO_DEBUG - Canary expansion under phase2170 (state spec) - Array: push×5/10 → size, len/length alias, per‑recv/global, flow across blocks - Map: set dup-key non-increment, value_state get/has - run_all.sh: unify, remove SKIPs; all PASS - Docs - ENV_VARS.md: add Debug/Tracing toggles and examples - PLAN.md/CURRENT_TASK.md: mark 21.7 green, add Quickstart lines All changes gated by env vars; default behavior unchanged.
This commit is contained in:
@ -18,6 +18,12 @@ if [ -z "${NYASH_BIN:-}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Debug convenience: HAKO_DEBUG=1 enables execution trace and log passthrough
|
||||
if [ "${HAKO_DEBUG:-0}" = "1" ]; then
|
||||
export HAKO_TRACE_EXECUTION=1
|
||||
export HAKO_VERIFY_SHOW_LOGS=1
|
||||
fi
|
||||
|
||||
# グローバル変数
|
||||
export SMOKES_V2_LIB_LOADED=1
|
||||
export SMOKES_START_TIME=$(date +%s.%N)
|
||||
@ -280,6 +286,7 @@ verify_mir_rc() {
|
||||
# Allow forcing Core with HAKO_VERIFY_V1_FORCE_CORE=1
|
||||
if grep -q '"schema_version"' "$json_path" 2>/dev/null; then
|
||||
if [ "${HAKO_VERIFY_V1_FORCE_CORE:-0}" = "1" ]; then
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: core (rust)" >&2; fi
|
||||
"$NYASH_BIN" --mir-json-file "$json_path" >/dev/null 2>&1; return $?
|
||||
fi
|
||||
# hv1 直行(main.rs 早期経路)。成功時は rc を採用、失敗時は Core にフォールバック。
|
||||
@ -287,6 +294,7 @@ verify_mir_rc() {
|
||||
if [ "${HAKO_VERIFY_V1_FORCE_HAKOVM:-0}" != "1" ]; then
|
||||
local hv1_rc; hv1_rc=$(verify_v1_inline_file "$json_path" || true)
|
||||
if [[ "$hv1_rc" =~ ^-?[0-9]+$ ]]; then
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: hv1_inline (rust)" >&2; fi
|
||||
local n=$hv1_rc; if [ $n -lt 0 ]; then n=$(( (n % 256 + 256) % 256 )); else n=$(( n % 256 )); fi; return $n
|
||||
fi
|
||||
fi
|
||||
@ -294,11 +302,13 @@ verify_mir_rc() {
|
||||
if [ "${HAKO_VERIFY_V1_FORCE_HAKOVM:-0}" = "1" ]; then
|
||||
local hv1_rc_force; hv1_rc_force=$(verify_v1_inline_file "$json_path" || true)
|
||||
if [[ "$hv1_rc_force" =~ ^-?[0-9]+$ ]]; then
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: hv1_inline (rust)" >&2; fi
|
||||
local n=$hv1_rc_force; if [ $n -lt 0 ]; then n=$(( (n % 256 + 256) % 256 )); else n=$(( n % 256 )); fi; return $n
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
# No include+preinclude fallback succeeded → Core にフォールバック
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: core (rust)" >&2; fi
|
||||
"$NYASH_BIN" --mir-json-file "$json_path" >/dev/null 2>&1
|
||||
return $?
|
||||
fi
|
||||
@ -527,6 +537,7 @@ HCODE
|
||||
local mir_literal; mir_literal="$(printf '%s' "$mir_json" | jq -Rs .)"
|
||||
hv1_rc=$(run_hv1_inline_alias_wrapper "$mir_literal")
|
||||
if [[ "$hv1_rc" =~ ^-?[0-9]+$ ]]; then
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: hakovm (hako)" >&2; fi
|
||||
local n=$hv1_rc; if [ $n -lt 0 ]; then n=$(( (n % 256 + 256) % 256 )); else n=$(( n % 256 )); fi
|
||||
return $n
|
||||
fi
|
||||
@ -564,6 +575,7 @@ HCODE
|
||||
|
||||
# Write MIR JSON to temp file and execute via Core
|
||||
echo "$mir_json" > "$mir_json_path"
|
||||
if [ "${HAKO_TRACE_EXECUTION:-0}" = "1" ]; then echo "[trace] executor: core (rust)" >&2; fi
|
||||
"$NYASH_BIN" --mir-json-file "$mir_json_path" >/dev/null 2>&1
|
||||
local rc=$?
|
||||
|
||||
@ -771,8 +783,16 @@ verify_v1_inline_file() {
|
||||
return 2
|
||||
fi
|
||||
local out
|
||||
out=$(HAKO_ROUTE_HAKOVM=1 HAKO_VERIFY_V1_FORCE_HAKOVM=1 NYASH_VERIFY_JSON="$(cat "$json_path")" \
|
||||
"$NYASH_BIN" --backend vm /dev/null 2>/dev/null | tr -d '\r' | awk '/^-?[0-9]+$/{n=$0} END{if(n!="") print n}')
|
||||
# Optional: show full logs for debugging (default OFF)
|
||||
if [ "${HAKO_VERIFY_SHOW_LOGS:-0}" = "1" ]; then
|
||||
# Show all output to stderr, then extract numeric rc
|
||||
HAKO_ROUTE_HAKOVM=1 HAKO_VERIFY_V1_FORCE_HAKOVM=1 NYASH_VERIFY_JSON="$(cat "$json_path")" \
|
||||
"$NYASH_BIN" --backend vm /dev/null 2>&1 | tr -d '\r' | tee /tmp/hv1_debug.log >&2
|
||||
out=$(awk '/^-?[0-9]+$/{n=$0} END{if(n!="") print n}' /tmp/hv1_debug.log)
|
||||
else
|
||||
out=$(HAKO_ROUTE_HAKOVM=1 HAKO_VERIFY_V1_FORCE_HAKOVM=1 NYASH_VERIFY_JSON="$(cat "$json_path")" \
|
||||
"$NYASH_BIN" --backend vm /dev/null 2>/dev/null | tr -d '\r' | awk '/^-?[0-9]+$/{n=$0} END{if(n!="") print n}')
|
||||
fi
|
||||
if [[ "$out" =~ ^-?[0-9]+$ ]]; then
|
||||
# echo numeric rc and return success; caller normalizes/returns as exit code
|
||||
echo "$out"
|
||||
|
||||
Reference in New Issue
Block a user