安装

本版本接受 FastSim >=0.1.0a15,<0.2 兼容契约列车;一致性检查仍会精确选择 待测插件的发行版本和入口点:

bash
python -m pip install fastsim-control-source-conformance==0.1.8

在本仓库中开发时:

bash
python -m pip install -e './packages/fastsim-control-source-conformance[dev]'

测试一个已安装控制源

请填写插件 Manifest 和已安装发行包真正发布的值。manifest_sha256 应来自 FastSim 解析后的 lock 或 Registry index,不能随意填写。

python
from fastsim_control_source_conformance import (
    InstalledControlSourceSpec,
    make_control_source_binding,
    run_installed_control_source_conformance,
)

spec = InstalledControlSourceSpec(
    plugin_id="plugin://example/my-source",
    plugin_version="1.0.0",
    distribution="example-fastsim-source",
    distribution_version="1.0.0",
    entry_point="example.my-source",
    entry_point_value="example_fastsim_source:plugin_factory",
)

binding = make_control_source_binding(
    spec,
    manifest_sha256="0123456789abcdef" * 4,
    bindings={"actor": "robot"},
    config={"enabled": True},
)

report = run_installed_control_source_conformance(spec, binding=binding)
print(report.to_json())
report.raise_for_failure()

report.passedTrue,表示 Core 精确找到了指定的已安装 Factory,身份信息 一致,并且插件完成了公开生命周期且没有遗留受管任务。失败原因在 report.failures 中,以稳定检查码表示;raise_for_failure() 可把所有失败转换 成一个类型明确的聚合异常,便于 CI 直接判定。

这个测试不证明什么

测试器会在当前进程中执行可信插件代码,它不是操作系统沙箱,也不验证物理效果、 任务成功率或性能。未知或不可信的发行包应放到独立进程或容器中测试。

本包的开发检查

bash
python -m pytest packages/fastsim-control-source-conformance
python -m ruff check packages/fastsim-control-source-conformance
python -m mypy packages/fastsim-control-source-conformance/src/fastsim_control_source_conformance