#!/usr/bin/env bash
# 微信 Hook 离线回归套件（WP-WX-01 / WP-WX-HOOK）
#
# 真机铁律口径：本套件**仅离线回归**，验证 hook JS 分支逻辑 + 矩阵诚实性 +
# ACTION→RPC 静态对齐；**不替代**真机 Frida attach E2E。全绿仅表示"代码逻辑/口径未回退"。
#
# 用法：bash sdk/tests/run_wx_hook_regression.sh
set -euo pipefail
cd "$(dirname "$0")/../.."   # 工作手机 仓根

fail=0
echo "════════ 微信 Hook 离线回归 ════════"

echo "▸ [1/4] 转发逻辑（forward / forwardMultiple / revoke 资格预检）"
node sdk/tests/test_forward_message_logic.mjs || fail=1

echo "▸ [2/4] 矩阵 companion 判定诚实性"
python3 sdk/tests/test_matrix_classifier_honesty.py || fail=1

echo "▸ [3/4] 防封限流逻辑（AB-02/03/06）"
python3 sdk/tests/test_rate_limiter_antiban.py || fail=1

echo "▸ [4/4] ACTION→RPC 静态对齐审计"
python3 sdk/scripts/wechat_interface_audit.py || fail=1

echo "════════════════════════════════════"
if [ "$fail" -ne 0 ]; then
  echo "❌ 微信 Hook 回归未通过（见上方）"
  exit 1
fi
echo "✅ 微信 Hook 离线回归全绿（仍须真机 Frida E2E 方可标功能 ✅）"
