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:
nyash-codex
2025-11-08 23:45:29 +09:00
parent bf185ec2b2
commit fa3091061d
49 changed files with 1334 additions and 110 deletions

View File

@ -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"

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_if_intint_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"If","cond":{"type":"Compare","op":"<","lhs":{"type":"Int","value":1},"rhs":{"type":"Int","value":2}},
"then":{"type":"Return","expr":{"type":"Int","value":44}},
"else":{"type":"Return","expr":{"type":"Int","value":7}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 44 ]; then
echo "[PASS] mirbuilder_registry_if_compare_intint_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_if_compare_intint_core_exec_canary_vm (rc=$rc, expect 44)" >&2; exit 1

View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_if_varint_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"Local","name":"x","expr":{"type":"Int","value":5}},
{"type":"If","cond":{"type":"Compare","op":">","lhs":{"type":"Var","name":"x"},"rhs":{"type":"Int","value":3}},
"then":{"type":"Return","expr":{"type":"Int","value":1}},
"else":{"type":"Return","expr":{"type":"Int","value":0}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 1 ]; then
echo "[PASS] mirbuilder_registry_if_compare_varint_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_if_compare_varint_core_exec_canary_vm (rc=$rc, expect 1)" >&2; exit 1

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_if_varvar_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"Local","name":"a","expr":{"type":"Int","value":10}},
{"type":"Local","name":"b","expr":{"type":"Int","value":20}},
{"type":"If","cond":{"type":"Compare","op":"<=","lhs":{"type":"Var","name":"a"},"rhs":{"type":"Var","name":"b"}},
"then":{"type":"Return","expr":{"type":"Int","value":44}},
"else":{"type":"Return","expr":{"type":"Int","value":7}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 44 ]; then
echo "[PASS] mirbuilder_registry_if_compare_varvar_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_if_compare_varvar_core_exec_canary_vm (rc=$rc, expect 44)" >&2; exit 1

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_binop_intint_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Binary","op":"+","lhs":{"type":"Int","value":2},"rhs":{"type":"Int","value":3}}}]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 5 ]; then
echo "[PASS] mirbuilder_registry_return_binop_intint_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_return_binop_intint_core_exec_canary_vm (rc=$rc, expect 5)" >&2; exit 1

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_binop_varint_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"Local","name":"x","expr":{"type":"Int","value":7}},
{"type":"Return","expr":{"type":"Binary","op":"*","lhs":{"type":"Var","name":"x"},"rhs":{"type":"Int","value":6}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 42 ]; then
echo "[PASS] mirbuilder_registry_return_binop_varint_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_return_binop_varint_core_exec_canary_vm (rc=$rc, expect 42)" >&2; exit 1

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_prog="/tmp/prog_registry_retint_$$.json"
cat >"$tmp_prog" <<'JSON'
{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Int","value":42}}]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp_prog" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_prog" || true
if [ "$rc" -eq 42 ]; then
echo "[PASS] mirbuilder_registry_return_int_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_return_int_core_exec_canary_vm (rc=$rc, expect 42)" >&2; exit 1

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp="/tmp/prog_registry_logical_and_$$.json"
cat >"$tmp" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"Local","name":"x","expr":{"type":"Bool","value":0}},
{"type":"Local","name":"y","expr":{"type":"Bool","value":1}},
{"type":"Return","expr":{"type":"Logical","op":"&&","lhs":{"type":"Var","name":"x"},"rhs":{"type":"Var","name":"y"}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp" || true
if [ "$rc" -eq 0 ]; then
echo "[PASS] mirbuilder_registry_return_logical_and_varvar_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_return_logical_and_varvar_core_exec_canary_vm (rc=$rc, expect 0)" >&2; exit 1

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp="/tmp/prog_registry_logical_or_$$.json"
cat >"$tmp" <<'JSON'
{"version":0,"kind":"Program","body":[
{"type":"Local","name":"a","expr":{"type":"Bool","value":1}},
{"type":"Local","name":"b","expr":{"type":"Bool","value":0}},
{"type":"Return","expr":{"type":"Logical","op":"||","lhs":{"type":"Var","name":"a"},"rhs":{"type":"Var","name":"b"}}}
]}
JSON
set +e
HAKO_MIR_BUILDER_INTERNAL=1 HAKO_MIR_BUILDER_REGISTRY=1 HAKO_VERIFY_PRIMARY=core verify_program_via_builder_to_core "$tmp" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp" || true
if [ "$rc" -eq 1 ]; then
echo "[PASS] mirbuilder_registry_return_logical_or_varvar_core_exec_canary_vm"
exit 0
fi
echo "[FAIL] mirbuilder_registry_return_logical_or_varvar_core_exec_canary_vm (rc=$rc, expect 1)" >&2; exit 1

View File

@ -0,0 +1,33 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_array_len_alias_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 0}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"len","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 2 ]; then echo "[PASS] array_len_alias_vm"; exit 0; fi
echo "[FAIL] array_len_alias_vm (rc=$rc, want=2)" >&2; exit 1

View File

@ -0,0 +1,33 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_array_length_alias_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 0}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"length","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 2 ]; then echo "[PASS] array_length_alias_vm"; exit 0; fi
echo "[FAIL] array_length_alias_vm (rc=$rc, want=2)" >&2; exit 1

View File

@ -0,0 +1,41 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_array_push_size_10_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 1}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 10 ]; then echo "[PASS] array_push_size_10_vm"; exit 0; fi
echo "[FAIL] array_push_size_10_vm (rc=$rc, want=10)" >&2; exit 1

View File

@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_array_push_size_5_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 111}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 5 ]; then echo "[PASS] array_push_size_5_vm"; exit 0; fi
echo "[FAIL] array_push_size_5_vm (rc=$rc, want=5)" >&2; exit 1

View File

@ -0,0 +1,43 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_flow_across_blocks_array_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 0}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"const","dst":10, "value": {"type": "i64", "value": 1}},
{"op":"const","dst":11, "value": {"type": "i64", "value": 1}},
{"op":"compare","dst":12, "lhs":10, "rhs":11, "cmp":"Eq"},
{"op":"branch","cond":12, "then":1, "else":2}
]},
{"id":1,"instructions":[
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]},
{"id":2,"instructions":[
{"op":"ret","value":2}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_V1_DISPATCHER_FLOW=1 HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 3 ]; then echo "[PASS] flow_across_blocks_array_size_canary_vm"; exit 0; fi
echo "[FAIL] flow_across_blocks_array_size_canary_vm (rc=$rc, want=3)" >&2; exit 1

View File

@ -0,0 +1,44 @@
#!/bin/bash
# Hakovm v1 dispatcher: ArrayBox push → size state increments (1→2→3)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_array_push_size_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 111}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 3, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":3}
]}
]}
]
}
JSON
# Expect rc=3 when stateful mir_call is ON and primary=hakovm
set +e
HAKO_VERIFY_PRIMARY=hakovm \
HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 \
verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 3 ]; then
echo "[PASS] hv1_mircall_array_push_size_state_canary_vm"
exit 0
fi
echo "[FAIL] hv1_mircall_array_push_size_state_canary_vm (rc=$rc, want=3)" >&2
exit 1

View File

@ -0,0 +1,46 @@
#!/bin/bash
# Hakovm v1 dispatcher: MapBox set(new key) → size increments (1→2)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_map_set_size_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"MapBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k1"}},
{"op":"const", "dst": 3, "value": {"type": "i64", "value": 100}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [2,3], "effects": []}},
{"op":"const", "dst": 4, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k2"}},
{"op":"const", "dst": 5, "value": {"type": "i64", "value": 200}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [4,5], "effects": []}},
{"op":"mir_call", "dst": 6, "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":6}
]}
]}
]
}
JSON
# Expect rc=2 when stateful mir_call (Map.set) is ON and primary=hakovm
set +e
HAKO_VERIFY_PRIMARY=hakovm \
HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 \
verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 2 ]; then
echo "[PASS] hv1_mircall_map_set_size_state_canary_vm"
exit 0
fi
echo "[FAIL] hv1_mircall_map_set_size_state_canary_vm (rc=$rc, want=2)" >&2
exit 1

View File

@ -0,0 +1,38 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
tmp_json="/tmp/mir_v1_map_set_dup_key_size_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"MapBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k1"}},
{"op":"const", "dst": 3, "value": {"type": "i64", "value": 100}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [2,3], "effects": []}},
{"op":"const", "dst": 5, "value": {"type": "i64", "value": 200}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [2,5], "effects": []}},
{"op":"const", "dst": 6, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k2"}},
{"op":"const", "dst": 7, "value": {"type": "i64", "value": 300}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [6,7], "effects": []}},
{"op":"mir_call", "dst": 8, "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"size","receiver":1}, "args": [], "effects": []}},
{"op":"ret","value":8}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
# k1 (new) -> size=1, k1 (dup) -> size stays 1, k2 (new) -> size=2
if [ "$rc" -eq 2 ]; then echo "[PASS] map_set_dup_key_size_canary_vm"; exit 0; fi
echo "[FAIL] map_set_dup_key_size_canary_vm (rc=$rc, want=2)" >&2; exit 1

View File

@ -0,0 +1,34 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
# value_state=1: Map.get returns stored value, Map.has reports presence
tmp_json="/tmp/mir_v1_map_value_state_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"MapBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k2"}},
{"op":"const", "dst": 3, "value": {"type": "i64", "value": 200}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":1}, "args": [2,3], "effects": []}},
{"op":"mir_call", "dst": 4, "mir_call": {"callee": {"type":"Method","box_name":"MapBox","method":"get","receiver":1}, "args": [2], "effects": []}},
{"op":"ret","value":4}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_VALUESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 200 ]; then echo "[PASS] map_value_state_get_has_canary_vm"; exit 0; fi
echo "[FAIL] map_value_state_get_has_canary_vm (rc=$rc, want=200)" >&2; exit 1

View File

@ -0,0 +1,34 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
# per_recv=0: global length key. push on A then size on B → 1
tmp_json="/tmp/mir_v1_perrecv_global_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 0}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 4, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"mir_call", "dst": 5, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":4}, "args": [], "effects": []}},
{"op":"ret","value":5}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=0 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 1 ]; then echo "[PASS] per_recv_global_canary_vm"; exit 0; fi
echo "[FAIL] per_recv_global_canary_vm (rc=$rc, want=1)" >&2; exit 1

View File

@ -0,0 +1,34 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
# per_recv=1: per-receiver length key. push on A then size on B → 0
tmp_json="/tmp/mir_v1_perrecv_per_$$.json"
cat > "$tmp_json" <<'JSON'
{
"schema_version": "1.0",
"functions": [
{"name":"main","blocks":[
{"id":0,"instructions":[
{"op":"mir_call", "dst": 1, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"const", "dst": 2, "value": {"type": "i64", "value": 0}},
{"op":"mir_call", "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args": [2], "effects": []}},
{"op":"mir_call", "dst": 4, "mir_call": {"callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": []}},
{"op":"mir_call", "dst": 5, "mir_call": {"callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":4}, "args": [], "effects": []}},
{"op":"ret","value":5}
]}
]}
]
}
JSON
set +e
HAKO_VERIFY_PRIMARY=hakovm HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 verify_mir_rc "$tmp_json" >/dev/null 2>&1
rc=$?
set -e
rm -f "$tmp_json" || true
if [ "$rc" -eq 0 ]; then echo "[PASS] per_recv_per_canary_vm"; exit 0; fi
echo "[FAIL] per_recv_per_canary_vm (rc=$rc, want=0)" >&2; exit 1

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)"
bash "$DIR/hv1_mircall_array_push_size_state_canary_vm.sh"
bash "$DIR/hv1_mircall_map_set_size_state_canary_vm.sh"
bash "$DIR/array_push_size_5_vm.sh"
bash "$DIR/array_push_size_10_vm.sh"
bash "$DIR/array_len_alias_vm.sh"
bash "$DIR/array_length_alias_vm.sh"
bash "$DIR/per_recv_global_canary_vm.sh"
bash "$DIR/per_recv_per_canary_vm.sh"
bash "$DIR/map_set_dup_key_size_canary_vm.sh"
bash "$DIR/map_value_state_get_has_canary_vm.sh"
bash "$DIR/flow_across_blocks_array_size_canary_vm.sh"
# dup-key non-increment now enforced
echo "[PASS] phase2170 all"