HWE-Bench · MagicBox (X5) + 服务器侧 5020 题 v2 行为判据
服务器侧 5020 题 v2 行为判据(2026-08-11):
h-hw-*5020 题适配服务器侧 Docker 沙箱评测,判据从词法(ORACLE_RIGOROUS)升级为行为判据(harness/hwe_judge.py,judges 薄壳一处升级)。M7 对抗回归实证:7a882c1e 真实 agent 解 86.5% → 21.5% PASS(杀 ~65pp 虚高)。M4 完成:974/974 ros2 static.py 真属性断言强化(12 批多 Agent)。判据链:
RUN_RC==0(M0) +expected.out行为比对(M2) + 相关性粗筛(M6) + 防硬编码 + property 模式(timing/无 seed 随机) + 硬件排除(hbm_runtime/torch/onnxruntime env_skip)。板侧 21 题 MagicBox 严格判据 v2 见下方(gold×3 过 + 44 cheats 全拒,板上双重实证)。
快速开始(Quick Start)
目标:把项目跑起来。以下命令在服务器
114.111.19.128(8核16G,仓库在/opt/hwe-bench)执行。本地仓库~/Desktop/HWE-Bench改完rsync同步到服务器。
0. 前置:构建沙箱镜像(一次性)
新镜像 hwe-sandbox:x86-ros2-v1(ROS2 Humble + tros 消息包 + scipy/PIL + rclcpp C++ 头)——不动现有 hwe-sandbox:x86(server_bridge 在用)。
# 本地改 image/ 后,rsync 到服务器
rsync -az image/ root@114.111.19.128:/opt/hwe-bench/image/
# 服务器侧构建(全离线:ros.key + hobot_msgs_src 已 COPY 进 context)
ssh root@114.111.19.128 'cd /opt/hwe-bench/image && bash build_sandbox_x86.sh'
# 验证镜像
ssh root@114.111.19.128 'docker run --rm --entrypoint bash hwe-sandbox:x86-ros2-v1 -c "source /opt/ros/humble/setup.bash; python3 -c \"import rclpy,ai_msgs,hbm_img_msgs,tf2_ros;print(\\\"ROS2+tros OK\\\")\""'
# 镜像存数据盘
ssh root@114.111.19.128 'docker save hwe-sandbox:x86-ros2-v1 | gzip > /data/images/hwe-sandbox_x86-ros2-v1.tar.gz'
1. 体验用例(单题,看闭环跑通)
用例 A:ros2 -mut- 题走 static 判据收敛(debug-diag「修 buggy ros2 节点」,不跑节点、源码断言「是否补了 shutdown」):
ssh root@114.111.19.128 'cd /opt/hwe-bench && \
echo h-hw-ros2-action-fibonacci-client-mut-py_missing_shutdown-0 > /tmp/one.txt && \
TMPDIR=/data/tmp HWE_DOCKER=1 SANDBOX_IMAGE=hwe-sandbox:x86-ros2-v1 \
python3 tests/run_fast_sweep.py --cids-file /tmp/one.txt --jobs 1'
# 预期:[CONV] 该题 gold=fixed 过 static(has rclpy.shutdown)+ cheat(buggy 无 shutdown) 被拒 → converged
用例 B:板侧 MagicBox 单题(GPIO/音频/相机,真硬件闭环):
ssh root@192.168.127.10 'cd /opt/hwe-bench && python3 harness/runner.py --task a1 --mode gold --exec container --k 3'
# 预期:gold×3 全过(a1=GPIO 点灯,trace_ok + live_probe 双验)
# 判据 CI(gold 全过 ∧ cheats 全拒)
ssh root@192.168.127.10 'cd /opt/hwe-bench && python3 tests/ci_judges.py --only a1,d3,g1 --k 3 --exec container'
用例 C:单个 LLM agent 跑一题(端到端 agent→容器→judge):
ssh root@114.111.19.128 'cd /opt/hwe-bench && \
TMPDIR=/data/tmp HWE_DOCKER=1 SANDBOX_IMAGE=hwe-sandbox:x86-ros2-v1 \
python3 harness/server_bridge.py & # 起 :8091 bridge
# 平台侧 POST /hwe/run {run_id,task_id,agent:"opencode",k:1,callback_url} → 202 → async 跑 + 回调 verdict
'
2. 全量 sweep(5020 题,收敛率)
ssh root@114.111.19.128 'cd /opt/hwe-bench && \
TMPDIR=/data/tmp HWE_DOCKER=1 SANDBOX_IMAGE=hwe-sandbox:x86-ros2-v1 \
python3 tests/run_fast_sweep.py --all --jobs 8'
# ~30-40min;产出 tests/fastsweep_<ts>.jsonl + 末行 "=== FAST SWEEP: N+M/5020 conv+skip, K fail ==="
# 单 category:--category ros2-node / debug-diag / model-deploy
3. 改判据/gold 后必跑(回归护栏)
ssh root@114.111.19.128 'cd /opt/hwe-bench && python3 tests/ci_judges.py --only <cid1>,<cid2> --k 3 --exec host'
# gold×k 全过 ∧ cheats 全拒 才准合并;重生 judges:python3 harness/regen_judges.py
4. 关键文件(2026-08-14 新增)
image/Dockerfile.sandbox_x86 # x86 沙箱(ROS2+tros+scipy/PIL+rclcpp),全离线 build
image/ros2_install.sh # ROS2 apt 装(本地 ros.key + set -e + set+u 守卫)
image/tros_build.sh # tros ai_msgs/hbm_img_msgs colcon build(COPY hobot_msgs_src)
image/build_sandbox_x86.sh # 构建脚本(新 tag + docker save 到 /data/images)
harness/static_checkers/ # 4 族 -mut- static 判据(missing_shutdown/resource_leak/exception_swallow/qos_mismatch)
harness/ros2_runtime_harness.py# A:ros2 节点行为 harness(发布者喂 input + 捕 output topic)
harness/extract_topic_config.py# A:AST 抽 per-task input/output topic 配置 → gold/<cid>/topic_config.json
harness/ros2_output_compare.py # A:output topic 容差比对(剥 stamp + 浮点 6 位定标)
harness/gen_test_assets.py # W2:per-task 输入资产生成(image/npy/onnx/csv)
harness/auto_pin.py # W2:argparse 值型 pin + body-seed 注入 prompt
服务器侧 v2 行为判据架构(5020 题)
harness/hwe_judge.py # 判据核心(M0/M2/M6/property/防硬编码/硬件排除)——5020 judge 薄壳调此
harness/server_bridge.py # 服务器侧 bridge:make_scaffold(跑 gold→expected + agent→actual + static + relevance)
harness/oracle_relevance.py # 相关性粗筛(agent 源码与 gold ref distinctive 标识符 ≥20% 重叠)
harness/auto_pin.py # P0-A 钉输入(argparse 默认 + body seed 注入 prompt/run_args.txt)
harness/batch_gen_expected.py# 批量预生成 gold/<cid>/expected.out
harness/per_category_report.py # M8 分项报数(按 category PASS 率 + 行为/词法标签)
harness/regen_judges.py # 重生 5020 judges/<cid>.py 为 hwe_judge 薄壳
harness/schema.py # TaskCard(+long_running 标记)
judges/h-hw-*.py # 5020 薄壳(一行调 hwe_judge.make_judge(cid))
gold/h-hw-*/static.py # 974 ros2 强化后的真属性断言(M4 多 Agent)
gold/h-hw-*/<ref>.py|.c # gold 参考实现
tasks/h-hw-*.json # 5020 题卡(+long_running + 评测参数注入)
tests/per_task_judge_ci.py # P0 对抗矩阵(每题 gold×k + 5 作弊 + 误杀回归)
tests/cheat_gen.py # 5 类对抗解自动生成(noop/startup_fail/hardcoded/on_topic_wrong/deadloop)
tests/run_fast_sweep.py # 快速 sweep(1 docker/题批量, jobs=16)
tests/rejudge_run.py # M7 对抗回归(用 v2 重判 7a882c1e 真实 agent 解)
tests/run_full_sweep.py # 全量逐题迭代收敛 sweep
判据机制(hwe_judge.py)
- M0:非长驻题
RUN_RC==0(堵"启动即败却 PASS") - M2:
expected.out(gold) vsactual(agent) 归一化逐行精确比对(浮点 6 位定标);timing/无 seed 随机题用property模式(结构精确 + 数值合理区间) - M6:
REL_RC相关性作前置粗筛(no-op/off-topic 快速拒) - 防硬编码:agent 源码不得把期望输出当字面量写死(
HARDCODED_OUTPUT) - 硬件排除:gold import hbm_runtime/torch/onnxruntime →
HARDWARE_REQUIREDenv_skip(交板) - 长驻题(ros2-node 974):豁免 RUN_RC==0,走
static.py真属性断言(M4 强化)
快速运行(服务器 /opt/hwe-bench,8 核 16G)
# 全量 sweep(5020,jobs=16,~16min)
TMPDIR=/data/tmp HWE_DOCKER=1 python3 tests/run_fast_sweep.py --all --jobs 16
# 单 category
python3 tests/run_fast_sweep.py --category ros2-node --jobs 16
# M7 对抗回归(重判 7a882c1e)
TMPDIR=/data/tmp HWE_DOCKER=1 python3 tests/rejudge_run.py --run hwe_7a882c1e446a42109906ec020286ff12 --jobs 8
# 分项报数
python3 harness/per_category_report.py --run hwe_7a882c1e446a42109906ec020286ff12
# P0 对抗矩阵(单题)
python3 tests/per_task_judge_ci.py --cid h-hw-bpu-activation-clip-ratio
# 重生 judges(判据改后)
python3 harness/regen_judges.py
沙箱镜像依赖
hwe-sandbox:x86-ros2-v1(2.57GB,ROS2 Humble + tros ai_msgs/hbm_img_msgs + tf2_ros + rclcpp C++ 头 + scipy/PIL/onnx,全离线 build)——2026-08-17 已建 + docker save 到 /data/images/。现有 hwe-sandbox:x86(server_bridge 在用)未动。镜像构建配方 image/Dockerfile.sandbox_x86 + ros2_install.sh + tros_build.sh(见「快速开始 §0」)。
M0–M8 终态 + 2026-08-14~17 新增
- ✅ M0/M1/M2/M6/M8/M7(85%→21.5%)/M4(974/974 ros2) 完成部署
- ✅ M3 全量 sweep 完(1165/5020=23.3% 收敛,2026-08-11)
- ✅ W1 容器化镜像(ROS2+tros+rclcpp+scipy/PIL,全离线 build)2026-08-17
- ✅ B static 判据 + 数据修复:1813 ros2
-mut-题(4 族:missing_shutdown/resource_leak/exception_swallow/qos_mismatch)走 AST 源码断言,200 题跨族样本 sweep 191/200=95.5% 收敛(vs 8/11 时 0)。完整修复链 7 处见 §7.9。 - ⏳ 残留:model-deploy BPU 345 交板、真硅 89、argparse 资产 145(gen_test_assets 就绪待逐题跑)、C 编译 434(-dev 清单已出待装)、全量 sweep 重跑定终态。详见同级研究报告 §7。
板侧 MagicBox 严格判据 v2(21 题,原版)
直线最短 + 事实驱动:21 题 active,判据全部升级为严格判据 v2(板上双重实证:gold 容器内 ×3 = 63/63 全过,对抗用例 44/44 全拒)。 裁判方法论(威胁模型/T 分级/P 模式库/漏洞分类学/quirk 库)见《HWE-Bench_评测任务定义与严谨裁判方法论_v1.md》。
范式与板况见同级
HWE-Bench_*系列文档(范式 SOP / 裸板实测 / 工作开展方案)。
仓库结构
tasks/<id>.json #1 题库 —— 每题一张任务卡(题面/输入/设备/依赖/live_probe/pre_reset)
gold/<id>/solution.* #2 Gold 标定解 —— 跑通 judge 必判 True(校准 judge)
judges/<id>.py #3 Judge 裁判 v2 —— 判据唯一事实源(P 模式库,见各文件 docstring)
harness/judge_lib.py #3 判据原语库 —— trace/网格解析/asound/PSNR/复制检测/env 探针
image/Dockerfile.base #4 考场镜像 —— ubuntu22.04 arm64 + ffmpeg/i2c-tools/alsa-utils/gpiod
image/eval.sh #4 容器入口 —— 原生 bash -x 落 /work/trace.log + TRACE_RC(P8 执行轨迹)
image/build-offline.sh #4 离线镜像构建(debootstrap→import→分层 build,避开 1GB-tar OOM)
harness/runner.py #5 监考系统 —— preflight→P0 复位→eval→执行窗探针→judge→P2P→pass@k
harness/run_all.py #5 批量 gold 校验 → results/baseline.json
harness/gen_docs.py #5 文档生成器 —— f2p_spec 与 docs/tasks 从 judge docstring 重生(§3.7 单一事实源)
tests/cheats/ #6 对抗用例 ×44(fabricate/copy/wrong-source/near-miss 四类/题)
tests/ci_judges.py #6 判据 CI 协议 —— gold×k 全过 ∧ cheats 全拒才准改判据
docs/tasks/<id>.md # 每题任务说明(gen_docs.py 生成,禁止手改)
docs/LIMITATIONS.md # 已知残留与判据限制登记(R1-R6,禁止静默放宽判据)
docs/agent_integration.md # W2 被测 Agent 接入契约
results/baseline.json #7 标尺读数
闭环形状
任务卡(题面+输入资产) → Agent 产程序 → 容器内跑(bash -x trace) → 严格 judge → P2P → resolved?
gold 铁律:每题参考解跑出来 judge 必须 100% 判 True,否则是 judge 有 bug,题不进数据集(标 not_in_v0 并写明根因)。
判据铁律(方法论军规):锚点必须"不真做就产生不了"——硬件回读/judge 活体复跑/参考产出比对/执行轨迹,
不接受自报文本;抗非确定 = 噪声维度放松、信号维度收紧,阈值一律板上实测标定。
执行环境
--exec container(CI 默认,已实证):docker run 设备透传(harness/devices.py从 live/dev探测派生,禁写死)。 eval.sh 用仓库版本 bind-mount 覆盖镜像内烤入版(trace 契约随仓库演进,免重打镜像——重 tar 会 OOM 重启板)。--exec host:板上原生跑,trace 契约与容器一致(runner 侧 bash -x 落 trace.log)。- 执行窗活体探针(task.live_probe):
h4_url=窗口内 judge 侧真拉流;asound:<wav>:capture|duplex=驱动级流 RUNNING。 - P0 前置复位(task.pre_reset):跑前清陈旧硬件状态(如 a1 unexport gpio401),防遗留 false-pass。
快速运行(板上 /opt/hwe-bench)
# 单题 gold 校验(容器模式)
python3 harness/runner.py --task h7 --mode gold --exec container
# pass@k(k=3 串行)
python3 harness/runner.py --task d3 --mode gold --exec container --k 3
# 判据 CI 协议(改判据/judge/gold/runner 后必跑):gold×3 全过 ∧ 44 cheats 全拒
python3 tests/ci_judges.py --exec container # 全量 ~107 容器跑
python3 tests/ci_judges.py --only a1,d3 --k 3 # 指定题
# 文档重生(judge docstring 改了之后)
python3 harness/gen_docs.py
25 题状态(MagicBox X5 3.3.3,零配件)
| 区 | active(严格判据 v2,gold×3 过 + cheats 全拒) | not_in_v0(根因) |
|---|---|---|
| A GPIO | a1 a6 a7 a8 | — |
| C UART | c3 | — |
| D I2C | d1 d2 d3 | — |
| F 摄像头 | f3 | f1 f4(取帧路径未通:pydev03 channel 错 + cdev capture 参数拒收) |
| G 音频 | g1 g2 g3 g4 g5 | — |
| H 多媒体 | h4 h5 h7 h8 h9 h10 h11 | h1 h2(cdev 运行时/VPF 管线占用) |
详见各 docs/tasks/<id>.md(生成物)与 docs/LIMITATIONS.md(判据限制登记)。