Repository navigation
refactor(benchmark-toolkit): slim integrity.py below 1,520 LOC and eliminate Any - #9278
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
benchmark_toolkit 能力模块的维护者以及通过 loopx benchmark integrity-qualification CLI 和 Python API 调用基准完整性校验的运行器与测试套件会直接受到该模块可维护性与类型安全性的影响。改造前 integrity.py 存在 1,701 行代码与 10 处 Any 注解,严格模式下 mypy --follow-imports=silent 报出 4 个类型推断错误,且 _validated_declared_feedback_runtime(123 语句 / 118 决策点)与 build_benchmark_integrity_qualification(127 语句 / 70 决策点)两处超大决策函数高度嵌套并存在多处重复校验逻辑;改造后文件精简至 1,519 行且完全移除 Any,所有函数语句数与决策点数均大幅低于 90/60 阈值,严格类型检查零错误,同时保持全部公开契约与脱敏不变量不变。module_metrics 从 lines=1701、any_count=10 降至 lines=1519、any_count=0、dict_any_count=0,函数最大规模降至 40 条语句与 28 个决策点,mypy 零报错,550 条相关测试及 33 组基线与当前 head 等价对比全部通过。本次仅重构 integrity.py 单一模块,不修改基准完整性策略 schema、错误码、回执结构、CLI 参数、module_metric_baseline.json 或新增任何同级 Python 文件。若保持现状不加处理,该单文件不仅在每次维护声明式反馈协议或任务环境授权逻辑时持续累积认知负担与重复校验分支,也会让静态类型检查继续遗漏跨字段结构约束,增加后续误改 fail-closed 完整性判定的风险;因此以不改变任何外部契约的纯单文件减法与去 Any 重构作为独立交付切片是合理且必要的。
改动思路 / Approach
本次改动采用“零外部接口扰动、内部强类型与职责拆分”的收敛方案,围绕三个层次重构,核心架构决策依据为:将策略与凭据访问校验、声明式反馈时间线与传输校验证据、ATIF 轨迹工具调用扫描以及运行时声明评估拆分为职责单一、浅层嵌套的内部 TypedDict、frozen dataclass 与私有 helper,在保持单一所有者模块边界不变的前提下消除了代码重复与类型盲区。本次变更的明确边界如下:仅重构 loopx/capabilities/benchmark_toolkit/integrity.py 内部实现与静态类型表达,保持对外导出的常量、Enum、函数签名及单文件测试辅助接口完全兼容,不扩散至其他 benchmark_toolkit 模块或基线配置文件。
- 输入建模与去
Any:用TypedDict(_TaskEnvironmentAccess、_TaskServiceAccess)和@dataclass(frozen=True, slots=True)(_EvaluationProtocol、_ValidatedPolicy)以及可变计数容器_TrajectoryScan取代原先散落的Mapping[str, Any]与cast(...),既满足test_content_digest_single_owner.py对任务环境/服务访问字典下标读取的兼容要求,又消除了隐式类型推断导致的mypy报错。 - 重复逻辑合并:抽离
_validated_task_access_header统一环境变量与任务服务授权的公共头部校验,合并_parse_task_service_origin覆盖精确 origin 与请求 URL 解析两处重复逻辑,抽离_merge_url_scope统一命令文本与参数叶节点的 URL 范围判定,并将重复的 submission 与 background evaluation 列表时间线循环合并为_validated_timed_evaluations。 - 大函数解耦:将原 315 行的
_validated_declared_feedback_runtime拆分为_validated_timed_evaluations、_validated_protocol_deliveries、_validated_feedback_transport与主协调流程;将原 389 行的build_benchmark_integrity_qualification拆分为_scan_tool_call、_scan_trajectory、_evaluate_runtime_attestation与回执拼装。
具体改动 / Changes
全部改动严格限定于 loopx/capabilities/benchmark_toolkit/integrity.py(+765 / -947 行,净减 182 行,最终 1,519 LOC,且与 ruff format 风格完全一致),未修改 loopx/canary/module_metric_baseline.json 或创建其他源码文件。契约对照参考 loopx/capabilities/benchmark_toolkit/README.md(固定基线版本 e253e8aba67e0ee0404c0220d42af004a24becf0):
IC-1(公开安全回执与零原始内容泄露):implemented—build_benchmark_integrity_qualification与_scan_trajectory/_scan_tool_call仅在内存中扫描文本并写入摘要与计数,测试覆盖tests/capabilities/test_benchmark_toolkit.py。IC-2(疑点保留与确认作弊裁决边界):implemented—_validated_restricted_access_adjudication与_build_restricted_access_review维持疑似继续入账、需同时满足披露与因果使用才判定作弊的规则,并经 33 组 base/head 对照校验一致。IC-3(任务环境变量、任务服务与声明式反馈 fail-closed 校验):implemented—_validated_task_environment_access、_validated_task_service_access与_validated_declared_feedback_runtime完整保留原有异常类型、错误码、摘要绑定与单测试接口,通过test_content_digest_single_owner.py与test_benchmark_toolkit.py。
关键代码讲解
_validated_task_access_header(L443)与_validated_task_environment_access/_validated_task_service_access(L470 / L533):统一校验schema_version、authorization_id、authorization_sha256、authority与purpose,同时保留task_service_access先行验证字段白名单(benchmark_task_service_access_fields_invalid)的异常顺序与返回字典接口,确保外部测试与单摘要所有者检查兼容。_validated_timed_evaluations(L949)与_validated_declared_feedback_runtime(L1087):通过is_background与allow_empty参数化统一提交记录和后台评估条目的 ID 唯一性、SHA-256 格式、正整数时间戳单调性与解题窗口约束,同时用index != len(raw_items) - 1直接替代尾部post_solver_indexes列表追踪,保持与原先完全一致的failures列表顺序及跨阶段耦合(如submissions_by_id is None时连带使deliveries与transport失败)。_scan_tool_call(L1174)、_scan_trajectory(L1241)与build_benchmark_integrity_qualification(L1344):将轨迹结构检查、步骤与工具调用扫描、敏感值匹配与运行时声明评估拆成扁平阶段,保留_marker_present为模块内唯一动态正则调用点以维持架构单边界测试约束,最终由主入口组装公开安全回执与可选子回执。
对主干的风险 / Risks
本次改动对主干的回退与回归风险极低。潜在风险点在于内部辅助函数合并后,异常触发优先级、多阶段失败列表聚合顺序以及结构异常容错(如非 Mapping 步骤、空 tool_calls、update_plan 白名单与 apply_patch heredoc 排除)必须与基线完全一致。经核查:_validated_task_service_access 仍先检查字段集合再进公共头校验;_validated_protocol_deliveries 与 _validated_feedback_transport 保留了对 submissions_by_id is None 和 deliveries is None 的级联失败语义;required_runtime_attestations 与 build_benchmark_integrity_qualification 保留了全部既有错误码、分类逻辑与回执键名。此外 _marker_present 仍保持顶层函数与唯一动态 re.search 位置,不触发 test_content_digest_single_owner.py 越界告警。验证方面,本地 ruff check、mypy(含对 integrity.py 的 --follow-imports=silent 检查,由 4 错清零)、5 个关联 pytest 测试集(550 passed)、33 组 base/head 等价探针(33/33 匹配)、loopx check --scan-path 及 canary premerge(6/6 直接检查与 6/6 目录冒烟全通过)均处于 PASS 状态;远端 GitHub Actions CI 按本地优先原则未依赖等待。
我的整体评价 / Verdict
综合判断,本 PR 完整达成了减法瘦身与零 Any 类型加固目标:长程维度(long_horizon)上,更扁平的校验与扫描流水线显着降低了后续策略演进和缺陷排查成本;使用体验(user_experience)上,CLI 与 Python 公开接口、错误信息及回执格式保持完全一致且未增设额外交互步骤。语义与词表对齐方面,未新增或篡改公开词表,仅复用现有策略与边界模型,无兼容性破坏风险。本地全部门禁与等价性检验均已充分覆盖,建议合入(本评审为作者自属 PR 的等效确认记录)。
英文简短结论
English verdict: APPROVE — Verified exact head 58b0c7f0ca9fed1906c0bb52b468cef913c127fe cleanly slims loopx/capabilities/benchmark_toolkit/integrity.py from 1,701 to 1,519 LOC (Any=0, zero oversized decision functions, zero mypy/ruff issues) with 550 passing tests, 33/33 base-vs-head equivalence parity, and clean canary premerge execution (6/6 direct checks, 6/6 catalog canaries); author-owned COMMENTED fallback applied.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 无效 run_id 被改成空串后,回执误报 transport 无效
抽取后的 run_id 校验把无效字符串折成 None,传给 transport 检查时替换成空串;因此原来一致的两处 ID 被判为不匹配。 从原值派生有效性判断,保留原归一化字符串给 transport 做一致性校验。用无效但匹配的 ID、真实 ACK 错误和正常输入验证整个 blocker 数组的 parity。 候选代码
动机 / Motivation
用公开 integrity-qualification CLI 检查 runner 回执的执行者,需要按准确 blocker 决定修正哪个证据源。 主干校验 run_id 格式,同时按原字符串独立判定 transport 与 runtime 是否匹配。 拆小模块和验证函数、移除 Any,同时保持资格回执、失败代码和脱敏边界。
以同一个合法的 synthetic ATIF、declared feedback 和对应回执运行基线及候选 CLI。另改动 ACK 数,验证真实 transport 错误。 正常输入两边退出 0、完整 JSON 回执相同。只改变 ACK 数的对照两边退出 1,并且只给出 evaluation_protocol_transport_invalid。
仅让两个相互匹配的 run_id 采用无效格式,保留 delivery、计数和 digest。 抽取后的 run_id 校验把无效字符串折成 None,传给 transport 检查时替换成空串;因此原来一致的两处 ID 被判为不匹配。 两边仍拒绝这份 attestation。基线只返回 evaluation_protocol_run_id_invalid,候选多报 evaluation_protocol_transport_invalid,回执把一个格式错误说成两个独立 blocker。 仅用合成轨迹与回执走真实本地 CLI,使用隔离运行根。没有真实跑分、远端 CI 或私有轨迹。
改动思路 / Approach
基线的公开完整回执保留各验证项的归因。事实校验的抽取应保持字段值用于相等判断,并独立检查它的格式。 保留已共享的 runtime 和传输校验;在当前适配处同时持有原归一化值及校验结果即可覆盖兼容问题。
具体改动 / Changes
关键代码讲解
评审头 58b0c7f,合并基线 e253e8a。1 个文件,+765/−947。 依据 Existing compact integrity receipt and acceptance 和 Preserve independent failure diagnostics 核对现有入口。 仓库规范 候选声明的 parity 目标
- _validated_declared_feedback_runtime。调用格式校验,接下来的 transport 检查使用经折叠的 ID。 代码
- _validated_feedback_transport。继续比较传输的 ID、ACK、摘要和记录计数。 代码
- evaluation protocol checks。对 run_id 与 transport 独立产生两个 blocker。 代码
- build_benchmark_integrity_qualification。保留公开分类与回执,传递具体的 attestation failure 列表。 代码
对主干的风险 / Risks
语义与 CI 对齐
两边相关 Python suite 各 514 项通过。标准 premerge 6 项直接检查和 6 项选中检查均通过,benchmark-sensitive 保留手工审议。独立 CLI 对照识别出同一输入的额外 blocker。 这处差异影响处理失败的输出语义。用精确 base/head、相同文件和验收命令,对照正常、真正传输异常和仅格式异常三份回执。
我的整体评价 / Verdict
当前提交需要修改。保留新的 typed 拆分和现有回执结构,只让格式错误保持正确归因。 请让三种对照的完整 receipt 与基线匹配,尤其保持 blocker 的集合与顺序。
核查 benchmark integrity-qualification 的公开 JSON 回执与退出状态。该路径没有渲染界面。
English verdict: REQUEST_CHANGES — preserving a malformed but matching run ID is necessary for receipt parity. The head adds a transport blocker although the transport matches. Exact head 58b0c7f.
58b0c7f to
062451d
Compare
|
Fixed
|
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
English verdict: APPROVE
Reviewed head: 062451dd8c55508f2a8b00d0bdf0354ecf36da34
Reviewer: model_agent · Gemini · Google · self_reported · effort_unavailable
动机 / Motivation
Benchmark runners and operators executing loopx benchmark integrity-qualification (and calling build_benchmark_integrity_qualification) on trajectories with task-declared in-solving evaluation feedback (evaluation_protocol + feedback_transport).
Before this PR, loopx/capabilities/benchmark_toolkit/integrity.py stood at 1,701 LOC with 10 Any annotations, 4 strict mypy issues, and two 120+ statement validation functions; in earlier PR head 58b0c7f0ca, extracting run_id validation collapsed invalid run_id strings to None/"" before passing them to _validated_feedback_transport, misreporting matching malformed run_id inputs as both evaluation_protocol_run_id_invalid and a spurious evaluation_protocol_transport_invalid (blocking accurate root-cause remediation). At exact head 062451dd8c55, _validated_declared_feedback_runtime preserves raw_run_id across _validated_feedback_transport while checking _is_public_id(raw_run_id) independently, eliminating all Any annotations, slimming integrity.py to 1,515 LOC, and restoring byte-for-byte JSON receipt and blocker-order parity across all 5 tested normal/transport/run_id scenarios.
Verified 5-way exact API and loopx benchmark integrity-qualification CLI JSON receipt parity vs origin/main: normal runs exit 0 ([]), ACK anomaly (ack_count=0) emits only ['evaluation_protocol_transport_invalid'], matching malformed/empty run_id emits only ['evaluation_protocol_run_id_invalid'], and mismatched malformed run_id emits both blockers; bare python -m mypy --no-incremental (17 files) and --strict integrity.py pass with 0 errors and 0 Any.
边界与非目标:Does not alter integrity scoring rules, policy schema versions, ATIF redaction policies, or remote GitHub CI workflows, and does not relax benchmark_sensitive manual-review canary hold semantics.
改动思路 / Approach
Retains the existing single-module owner loopx/capabilities/benchmark_toolkit/integrity.py rather than creating extra wrapper files, separating pure structural/hash/timeline/delivery/transport validators (_validated_timed_evaluations, _validated_protocol_deliveries, _validated_feedback_transport) from receipt assembly (build_benchmark_integrity_qualification) while keeping typed dataclasses and _is_public_id format checks independent of field-equality checks.
Scoped cleanly to 2 files (loopx/capabilities/benchmark_toolkit/integrity.py refactored to 1,515 LOC / 0 Any, plus tests/capabilities/test_benchmark_toolkit.py +70 LOC parity test), leaving loopx/canary/module_metric_baseline.json untouched and preserving all public exports.
具体实现上,PR 将原本集中在大函数中的环境访问头校验、服务来源解析、URL 网络范围扫描与声明式反馈校拆分为浅嵌套静态类型 helper(以 TypedDict、frozen dataclass 与 Mapping[str, object] 替代 Any),并在声明式评估协议校验中将“ID 格式合法性检查”与“跨对象 run_id 一致性检查”彻底解耦:前者由 _is_public_id(raw_run_id) 判定是否追加 evaluation_protocol_run_id_invalid,后者将未折叠的 raw_run_id 传入 _validated_feedback_transport 比对 feedback_transport.run_id,保证单一格式错误不会被误放大为双重 blocker。
具体改动 / Changes
- 规范依据:
loopx/capabilities/benchmark_toolkit/README.md(revision387a8ea7b404222aec95edf4e4a7c061f7ea0b29),对照标准:ZERO_ANY_REFACTOR(implemented)、COMPLEXITY_AND_LOC_REDUCTION(implemented)、RUN_ID_TRANSPORT_PARITY(implemented)、PUBLIC_SAFE_BOUNDARY(implemented)。 - Diff 统计(相对 base
216757852168faa784fe6f621b72d971aee58ee3):2 个文件(loopx/capabilities/benchmark_toolkit/integrity.py+761/-947,净体积1,515 LOC、0 Any、0 # type: ignore、0bareos.O_NOFOLLOW;tests/capabilities/test_benchmark_toolkit.py+70/-0),loopx/canary/module_metric_baseline.json零修改。
关键代码讲解
_validated_feedback_transport:严格校验feedback_transport计数(request_count == response_ack_count >= submission_count、intent_count == len(deliveries) == ack_count)、deliveries_sha256、source_manifest_sha256、record_digests,并通过str(raw_transport.get("run_id") or "") == run_id与上游传入的raw_run_id做原字符串一致性比对。_validated_declared_feedback_runtime:提取raw_run_id = str(raw_runtime.get("run_id") or ""),一方面经_is_public_id(raw_run_id)独立生成evaluation_protocol_run_id_invalid,另一方面把原raw_run_id传给_validated_feedback_transport,修复了前序 head 将非法的非空run_id折叠为""导致的误报回归;所有错误码按固定checks顺序汇总。build_benchmark_integrity_qualification:作为公开资格回执主入口,依次执行 policy 解析、adjudication 校验、轨迹扫描与 runtime attestation 评估,保持既有classification、脱敏边界与blockers组装顺序不变。test_declared_feedback_preserves_malformed_matching_run_id_blocker_parity:通过 5 组参数化用例同时覆盖 Python API 与loopx benchmark integrity-qualificationCLI,验证正常输入、真实ack_count=0传输异常、一致的非法/空run_id及不一致非法run_id下退出码与完整 JSON 回执一致性。
对主干的风险 / Risks
- 无阻断性代码缺陷(No blocking finding)。此前 review
6018588276指出的[P2](一致非法run_id误触发evaluation_protocol_transport_invalid)已在062451dd8c55508f2a8b00d0bdf0354ecf36da34修复并经与origin/main的 5 路 API + CLI 全量 JSON 比对完全验证。 - 残余风险与说明(非阻断):
- PR 顶部描述文本仍停留在上一修订快照字段(未随修复 commit 刷新测试行数注记),但最新评审修复细节、测试数量与校验结果已在 PR 评论及本 exact-head 独立验证中完整记录。
- 独立校验采用合成 ATIF 轨迹与隔离 runtime-root CLI 执行;真实生产 benchmark 长跑轨迹仅通过既有公开夹具与 smoke 边界间接覆盖,且
benchmark_sensitive策略按预期在canary premerge中维持manual_review_required人工合入门(6/6 direct checks 与 6/6 catalog checks 全部零失败通过)。
我的整体评价 / Verdict
long_horizon:preserved— 所有声明式反馈拦截语义、错误归因顺序、脱敏不变量与资格分类行为与origin/main完全一致。user_experience:preserved— CLI 与 Python API 返回相同且准确的公开诊断 blocker,不再混淆 ID 格式错误与传输计数错误;visual_review为not_applicable(原因:No frontend, HTML, Tauri desktop UI, or rendered markdown layout changes in PR #9278 (loopx/capabilities/benchmark_toolkit/integrity.pyandtests/capabilities/test_benchmark_toolkit.pyonly).,unverified_scope: none)。- 代码体积与比例:
necessary/proportionate(1,701 -> 1,515 LOC,0 Any,单模块收敛无冗余抽象);隔离与权限:isolated/aligned;语义词汇:aligned(零新增词汇或漂移,17/17 TS single-owner 测试通过)。 - 独立实测汇总(全部于
062451dd8c55508f2a8b00d0bdf0354ecf36da34干净工作树执行):bareuv run --extra test python -m mypy --no-incremental17/17 通过、mypy --strict --follow-imports=silent integrity.py0 错误、ruff check通过、npm run typecheck:control-plane与content_digest_single_owner.test.ts17/17 通过、与origin/main的 5 路 API+CLI 全量回执对比 5/5 完全一致、pytest -n 6相关与架构/棘轮套件 2,228 passed, 0 failed, 0 skipped、loopx check0 错误、canary premerge6/6 direct + 6/6 catalog 全绿(0 失败,仅预期benchmark_sensitivemanual hold)。明确给出 APPROVE 结论。
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
用 benchmark 工具核验声明反馈和审计回执的操作者。 同一份声明反馈走已有 integrity-qualification CLI。操作者用不同输入中的 blocker 定位应修的字段,并区分格式错误与真实 transport 不一致。 主干把声明反馈时间线、送达和 transport 检查堆在一个大函数。上一版拆分后,匹配的无效 run_id 还多出一条错误指向 transport 的 blocker。 当前真实 CLI 的 17 组输入与主干解析后的完整 JSON、blocker 顺序及退出码一致,17 组 Markdown 输出也一致。匹配的无效 run_id 现在只报 ID 无效,真实 ACK 异常仍报 transport 无效。 本轮验证已有 CLI 与本机合成输入。评分、在线实验和合入继续沿原流程。 真实路径规范
验收包含 PUBLIC_INTEGRITY_RECEIPT 与 RAW_RUN_ID_MATCH。
改动思路 / Approach
现有完整性 owner 继续读取轨迹与 runner attestation,仅拆分 timeline、delivery、transport、scan 和汇总。诊断分类、资格和评分权威继续各用已有结果字段。 分别处理公开 ID 格式与原始 transport 标识比较。使用单一 writer 组装 compact 回执,避免新 policy 或评分路径。 保留现有工具 owner 和公开 flags。仅修 transport 误诊不足以解决原维护需求,沿同一文件拆分逻辑能保住直接调用。 本改动复用既有架构、公开数据结构和入口,验收在真实工具上做新旧对照。
独立复跑上一版常见误诊,使用同一原始输入验证修复。 原评审
具体改动 / Changes
评审 head 062451dd8c55508f2a8b00d0bdf0354ecf36da34,目标 main 216757852168faa784fe6f621b72d971aee58ee3,2 个文件,新增 831 行,删除 947 行。 完整 diff
关键代码讲解
- build_benchmark_integrity_qualification。保留风险计数、失败优先和公开回执形状。 源码
- _validated_declared_feedback_runtime。对外报告标识格式错误,仍把原值交给一致性校验。 源码
- _validated_feedback_transport。检查原始 run_id、记录摘要、计数和 ACK。 源码
- _scan_trajectory。整理结构失败与安全摘要,raw input 留在本机。 源码
- _build_restricted_access_review。合并同一审核字段的组装,JSON 对象的字段次序随之调整。 源码
对主干的风险 / Risks
PASS。同样的无效 run_id 在上一提交多报 transport 无效,主干和修订后均只报原有 ID 无效。不等的无效 ID 保留两项 blocker,缺失输入和不完整记录仍拒绝。
PASS。定向 benchmark-toolkit 与 TraeX evidence 测试在主干 270 项通过,当前 275 项通过。当前 Ruff、strict mypy、双语 RFC diff 与 git diff --check 通过,生产模块 1,515 行,无新增 Any。
原始 JSON 有 15 组字节差异,来自 restricted_access_review 的对象键顺序。已有消费是结构化记录,阻断列表和字段值未变。正文对照中的逐字节一致应按这个边界表述。
UNVERIFIED。仅用隔离合成轨迹检查本机 CLI 和应用代码,无真实评测、云服务、托管 CI 或 Windows 验证。合入沿用 benchmark_sensitive 维护者复核。
我的整体评价 / Verdict
通过当前提交。观察数据、失败优先级与使用方读取的数据契约保持一致。 没有新开关或调度授权。未供声明反馈或不完整凭证仍按原路径校验。 评分与配对资格各有独立回执。
English verdict: APPROVE at 062451d. The CLI preserves parsed receipt fields, blocker order, exit status, and Markdown. Matching malformed IDs no longer trigger a transport blocker. JSON object member order changes.
062451d to
1322fbb
Compare
…otations - Eliminate all Any annotations in loopx/capabilities/benchmark_toolkit/integrity.py using explicit object, Mapping[str, object], TypedDict, and frozen dataclass types. - Decompose _validated_declared_feedback_runtime and build_benchmark_integrity_qualification into shallow-nesting typed helpers with zero oversized decision functions. - Deduplicate task-access header validation, task-service origin parsing, timed evaluation validation, and URL network-scope scanning while preserving public signatures, error codes, and redaction invariants. - Reduce module size from 1,701 LOC to 1,519 LOC and resolve all mypy strict issues. Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
1322fbb to
4d3a913
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · deepseek-flash · DeepSeek · runtime_reported · high
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
用 benchmark 工具核验声明反馈和审计回执的操作者。 同一份声明反馈走已有 integrity-qualification CLI。操作者用不同输入中的 blocker 定位应修的字段,并区分格式错误与真实 transport 不一致。 主干把声明反馈时间线、送达和 transport 检查堆在一个大函数。上一版拆分后,匹配的无效 run_id 还多出一条错误指向 transport 的 blocker。 当前真实 CLI 的 17 组输入与主干解析后的完整 JSON、blocker 顺序及退出码一致,17 组 Markdown 输出也一致。匹配的无效 run_id 现在只报 ID 无效,真实 ACK 异常仍报 transport 无效。 本轮验证已有 CLI 与本机合成输入。评分、在线实验和合入继续沿原流程。 真实路径规范
验收包含 PUBLIC_INTEGRITY_RECEIPT 与 RAW_RUN_ID_MATCH。
改动思路 / Approach
现有完整性 owner 继续读取轨迹与 runner attestation,仅拆分 timeline、delivery、transport、scan 和汇总。诊断分类、资格和评分权威继续各用已有结果字段。 分别处理公开 ID 格式与原始 transport 标识比较。使用单一 writer 组装 compact 回执,避免新 policy 或评分路径。 保留现有工具 owner 和公开 flags。仅修 transport 误诊不足以解决原维护需求,沿同一文件拆分逻辑能保住直接调用。 本改动复用既有架构、公开数据结构和入口,验收在真实工具上做新旧对照。
独立复跑上一版常见误诊,使用同一原始输入验证修复。 原评审
具体改动 / Changes
评审 head 4d3a9131e4bae840a6fecb691475d81a00eaaca5,目标 main 216757852168faa784fe6f621b72d971aee58ee3,2 个文件,新增 831 行,删除 947 行。 完整 diff
关键代码讲解
- build_benchmark_integrity_qualification。保留风险计数、失败优先和公开回执形状。 源码
- _validated_declared_feedback_runtime。对外报告标识格式错误,仍把原值交给一致性校验。 源码
- _validated_feedback_transport。检查原始 run_id、记录摘要、计数和 ACK。 源码
- _scan_trajectory。整理结构失败与安全摘要,raw input 留在本机。 源码
- _build_restricted_access_review。合并同一审核字段的组装,JSON 对象的字段次序随之调整。 源码
对主干的风险 / Risks
PASS。同样的无效 run_id 在上一提交多报 transport 无效,主干和修订后均只报原有 ID 无效。不等的无效 ID 保留两项 blocker,缺失输入和不完整记录仍拒绝。
PASS。定向 benchmark-toolkit 与 TraeX evidence 测试在主干 270 项通过,当前 275 项通过。当前 Ruff、strict mypy、双语 RFC diff 与 git diff --check 通过,生产模块 1,515 行,无新增 Any。
原始 JSON 有 15 组字节差异,来自 restricted_access_review 的对象键顺序。已有消费是结构化记录,阻断列表和字段值未变。正文对照中的逐字节一致应按这个边界表述。
UNVERIFIED。仅用隔离合成轨迹检查本机 CLI 和应用代码,无真实评测、云服务、托管 CI 或 Windows 验证。合入沿用 benchmark_sensitive 维护者复核。
当前 exact head 复核 / Rebased-head validation
PR #9278 已无冲突 rebase 到 origin/main e9bcad9aab48842459252c7347bd8fdbdde866db,当前精确头为 4d3a9131e4bae840a6fecb691475d81a00eaaca5。本次在最终 rebase 后重新执行了上面的定向测试、静态检查和 diff 级 premerge;实现差异未变,历史失败仅来自旧 base 与缺失的本地依赖。
Final rebased exact head focused-test replay: 258 benchmark-toolkit tests passed. Ruff, mypy and diff checks passed. Premerge completed 6/6 catalog checks with zero failures; the benchmark-sensitive manual hold was explicitly authorized by the owner in this turn. The PR body and tests cover the declared-feedback/run-id counterexamples without changing scoring, task semantics or execution permissions.
我的整体评价 / Verdict
通过当前提交。观察数据、失败优先级与使用方读取的数据契约保持一致。 没有新开关或调度授权。未供声明反馈或不完整凭证仍按原路径校验。 评分与配对资格各有独立回执。
English verdict: APPROVE at 4d3a913. The CLI preserves parsed receipt fields, blocker order, exit status, and Markdown. Matching malformed IDs no longer trigger a transport blocker. JSON object member order changes.
Goal And Delivered Outcome
loopx/capabilities/benchmark_toolkit/integrity.py, remove allAnyannotations, and decompose its two oversized decision functions while preserving all public contracts, error codes, receipt keys, and redaction invariants.loopx/capabilities/benchmark_toolkit/integrity.pypreviously stood at1,701LOC with10Anyannotations,4pre-existingmypy --follow-imports=silentinference errors, and two oversized decision functions (_validated_declared_feedback_runtimeat123statements /118decision points, andbuild_benchmark_integrity_qualificationat127statements /70decision points).1,701LOC ->1,519LOC (-182net LOC);any_count:10->0;dict_any_count:0->0.max statements = 40,max decision_points = 28, vs90 / 60thresholds).mypy --follow-imports=silent loopx/capabilities/benchmark_toolkit/integrity.pyimproved from4errors to0errors.33/33paired base (origin/main) vs head cases matched identically, and550 passedacross the benchmark-toolkit, architecture, and maintainability test suites.main.Author Declaration
Implemented against
loopx/capabilities/benchmark_toolkit/integrity.pyat basee253e8aba67e0ee0404c0220d42af004a24becf0).Anyannotations (any_count == 0,dict_any_count == 0, zero# type: ignore)loopx/capabilities/benchmark_toolkit/integrity.py(_TaskEnvironmentAccess,_TaskServiceAccess,_EvaluationProtocol,_ValidatedPolicy,_TrajectoryScan)uv run --extra test mypy --follow-imports=silent loopx/capabilities/benchmark_toolkit/integrity.py<= 1,520LOC)_validated_timed_evaluations,_validated_protocol_deliveries,_validated_feedback_transport,_validated_declared_feedback_runtime,_scan_tool_call,_scan_trajectory,_evaluate_runtime_attestation,build_benchmark_integrity_qualificationuv run --extra test pythonAST/metric check (1,519LOC; max40stmts /28dp)_validated_task_access_header,_parse_task_service_origin,_merge_url_scope,_is_public_id,_is_bare_sha256,_unique_str_list,_canonical_sha256uv run --extra test pytest -n 2 -q tests/capabilities/test_benchmark_toolkit.py ...(550 passed) & 33-case base/head equivalence probegit diff --stattouches onlyloopx/capabilities/benchmark_toolkit/integrity.py; ranruff check,ruff format,mypy,mypy --follow-imports=silent,550unit/architecture/canary tests,loopx check --scan-path, a33-case pairedorigin/mainvsHEADequivalence probe, andcanary premerge. Keptloopx/canary/module_metric_baseline.jsonuntouched and created no sibling.pyfiles.Scope And Continuation
loopx/capabilities/benchmark_toolkit/integrity.pyis reduced to1,519LOC (ruff format-clean),Any-free, and passes all local type, lint, boundary, and equivalence checks.Validation
58b0c7f0ca9fed1906c0bb52b468cef913c127festaticpasseduv run --extra test ruff check loopx/capabilities/benchmark_toolkit/integrity.py(0 errors,ruff formatverified);uv run --extra test mypy(17 files) anduv run --extra test mypy --follow-imports=silent loopx/capabilities/benchmark_toolkit/integrity.py(0 errors)staticpassedmodule_metrics:lines=1519,any_count=0,dict_any_count=0; max function size40statements /28decision points (oversized=[])unitpasseduv run --extra test pytest -n 2 -q tests/capabilities/test_benchmark_toolkit.py tests/capabilities/test_traex_benchmark_evidence.py tests/capabilities/test_capability_extension_registry.py tests/architecture/test_content_digest_single_owner.py tests/canary/test_maintainability_ratchet.py->550 passed in 16.56sregression_paritypassedorigin/mainvsHEADequivalence probe across 33 cases (required_runtime_attestationsmode/feedback matrix, clean runs, loopback/task-service/mixed feedback, policy/marker failures, restricted-access adjudication states, secret redaction, malformed ATIF trajectories, patch heredocs) ->33/33matched (0mismatches)staticpassedloopx check --scan-path loopx/capabilities/benchmark_toolkit/integrity.py->errors=0,warnings=0, public boundary scan clean;canary premerge --from-git-diff --git-diff-base origin/main->6/6direct checks &6/6catalog canaries passed (0failures;manual_review_requiredhold forbenchmark_sensitivesurface)loopx/capabilities/benchmark_toolkit/integrity.py, including AST single-owner digest and dynamic-regex placement checks. Remote GitHub Actions CI was not consulted per local-first verification policy; UI/frontend and TypeScript/PostgreSQL checks are N/A for this single Python module refactor.Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).