#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" DOC="$ROOT_DIR/docs/source-reuse-map.md" RUNTIME="$ROOT_DIR/runtime/core/linuxcnc_wrap/linuxcnc_task_hal_wasm.cpp" WASM_TEST="$ROOT_DIR/tests/wasm/node/verify_task_hal_wasm.mjs" fail() { printf 'task_hal_readiness_contract_status=fail\n' printf 'task_hal_readiness_contract_error=%s\n' "$1" exit 1 } expect_output_value() { local output="$1" local key="$2" local expected="$3" local actual actual="$(printf '%s\n' "$output" | awk -F= -v key="$key" '$1 == key {print $2; found=1} END {if (!found) exit 1}')" [[ "$actual" == "$expected" ]] || fail "$key expected $expected got $actual" printf 'task_hal_readiness_%s=%s\n' "$key" "$actual" } expect_file_contains() { local file="$1" local text="$2" local label="$3" grep -Fq "$text" "$file" || fail "$label missing" printf 'task_hal_readiness_%s=ok\n' "$label" } reject_file_contains() { local file="$1" local text="$2" local label="$3" if grep -Fq "$text" "$file"; then fail "$label present" fi printf 'task_hal_readiness_%s=absent\n' "$label" } manifest_output="$("$ROOT_DIR/tools/verify_task_hal_source_manifest.sh")" expect_output_value "$manifest_output" task_hal_runtime_promoted 0 expect_output_value "$manifest_output" nativeTaskReady false expect_output_value "$manifest_output" nativeHalSyncReady false expect_file_contains "$DOC" 'task_hal_runtime_promoted=0' doc_runtime_promoted_false expect_file_contains "$DOC" 'nativeTaskReady=false' doc_native_task_false expect_file_contains "$DOC" 'nativeHalSyncReady=false' doc_native_hal_false expect_file_contains "$DOC" 'fullLinuxCncProgramExecutionReady=false' doc_full_program_false expect_file_contains "$DOC" 'Runtime-edge adapter, not full native task/HAL promotion' doc_unpromoted_classification reject_file_contains "$DOC" 'nativeTaskReady=true' doc_native_task_true reject_file_contains "$DOC" 'nativeHalSyncReady=true' doc_native_hal_true reject_file_contains "$DOC" 'full boundary gates now validate' doc_full_boundary_promoted_claim reject_file_contains "$DOC" 'Native task/motion/HAL sync is complete for deterministic Web simulation' doc_complete_claim expect_file_contains "$RUNTIME" '"nativeTaskReady\":false' runtime_native_task_false expect_file_contains "$RUNTIME" '"nativeHalSyncReady\":false' runtime_native_hal_false expect_file_contains "$RUNTIME" '"fullLinuxCncProgramExecutionReady\":false' runtime_full_program_false expect_file_contains "$WASM_TEST" 'assert.equal(snapshot.fullLinuxCncProgramExecutionReady, false);' wasm_test_full_program_false printf 'task_hal_readiness_contract_status=ok\n'