Skip to content

Web Fetch: isolated CPU, memory and network benchmark reporting - #14

Merged
lanyue-llk merged 3 commits into
mainfrom
codex/webfetch-resource-profile-report
Sep 15, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
codex/webfetch-resource-profile-report

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Summary

  • Add reusable per-run Docker and cgroup resource accounting for CPU, peak memory, and network traffic; keep Browser Use on the shared accounting layer.
  • Bind the required resource cohort to the current report matrix, retain Moli 1.1.1 only, and validate frozen evidence before report build.
  • Show metric-specific resource winners and grouped comparisons on the home and interpretation pages in both languages; keep resource leadership separate from task pass rate.

Verification

  • make test: 629 Python tests passed (38 skipped), 66 Browser Use tests passed (2 skipped), UI tests passed.
  • make report and make report-check: 150 tasks, 750 records, 1832 routes, 0 broken local links; bilingual table and revision checks passed.
  • Rebuilt key report pages match the currently published artifact byte-for-byte.

Raw measured evidence and provider artifacts remain outside Git. This PR does not merge or republish the report.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 2m 10s —— View job


PR Review: Web Fetch isolated resource profiling

  • Gather context
  • Read key new files
  • Review for bugs and security issues
  • Post findings

Findings

1. Security: apt packages downloaded without integrity verification — examples/web_fetch/docker/download_apt_uris.py

The apt --print-uris output includes a checksum field (MD5 or SHA) for each package, but download_apt_uris.py ignores it entirely. Combined with the non-default mirror baked into resource.Dockerfile:

ARG DEBIAN_MIRROR=https://mirrors.aliyun.com/debian          # line 76
ARG DEBIAN_SECURITY_MIRROR=https://mirrors.aliyun.com/debian-security  # line 77

Any build that doesn't override those ARGs pulls packages from a third-party CDN with no post-download verification. A compromised mirror response would install silently.

The --print-uris output format is '<url>' <filename> <size> MD5Sum:<hash>. The hash is already available in fields[3] — it's just never consumed.

Fix this →


2. Bug: fragile positional unpacking via __dict__.values() — harness/resource_accounting.py:67

return ResourceSample(elapsed_ms, memory, len(pids), *counters.__dict__.values())

This relies on CounterSnapshot.__dict__ insertion order matching the tail of ResourceSample's constructor signature (cpu_usage_usec, network_rx_bytes, network_tx_bytes). If either dataclass's fields are reordered, the values silently map to wrong metrics — CPU goes to network, etc. — with no type error.

The fix is a single line:

return ResourceSample(elapsed_ms, memory, len(pids),
                      counters.cpu_usage_usec, counters.network_rx_bytes, counters.network_tx_bytes)

Fix this →


3. Minor: no path sanitisation on the filename field — examples/web_fetch/docker/download_apt_uris.py:19

items.append((fields[0], archives / fields[1]))

fields[1] from the apt plan output is used directly as a Path component. A crafted or tampered plan (possible with a compromised mirror — see #1) could include ../../etc/cron.d/evil as the filename. Running inside a Docker build limits blast radius, but a path-separator check costs nothing:

name = Path(fields[1]).name
if not name:
    continue
items.append((fields[0], archives / name))

Fix this →


No other bugs or security issues found. The cgroup path traversal check in LinuxContainerResources.__init__ is correct, the API token is passed via stdin (not argv), and the container is forced-removed in a finally block.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 5m 12s —— View job


任务列表

  • 读取 AGENTS.md
  • 读取 benchmark-report SKILL.md
  • 读取关键变更文件
  • 分析 PR diff
  • 输出审查结论

Review 结论

有条件通过

核心逻辑正确:资源采集(cgroup-v2 + Docker Stats)、evidence 完整性校验、双语报告构建、check_report.py 验证均已实现;browser_use/metrics.py 的重构为 re-export 而非重写,共享同一合约(test_resource_accounting.py 有测试保证)。Moli 版本收敛及 current-report.json 更新一致。


问题及建议

  • [P1] harness/web_fetch/report_resources.py:102:'本轮资源效率并列领先' 未在 report_i18n.py TEXT 词典中定义('本轮资源效率领先' 有对应翻译,但并列变体缺失)。若四种本地方法出现资源领先分值相同,英文页面将直接展示未翻译中文,违反 AGENTS.md "两种语言须一一对应" 要求。建议:在 TEXT 中补充 "本轮资源效率并列领先": "Resource-efficiency co-leaders in this run"。Fix this →

  • [P2] harness/resource_accounting.py:57:ResourceSample(elapsed_ms, memory, len(pids), *counters.__dict__.values()) 依赖 CounterSnapshot 字段的声明顺序隐式传参,重排字段会静默产生错误数据。建议改为具名参数:ResourceSample(elapsed_ms, memory, len(pids), cpu_usage_usec=counters.cpu_usage_usec, network_rx_bytes=counters.network_rx_bytes, network_tx_bytes=counters.network_tx_bytes)。

  • [P2] scripts/project_headless_providers.py:155, 160:两处硬编码字符串("same four cases for Moli 1.1.1; projected from reviewed three-version final-round correction" 和 "current report removes historical Moli 1.0.6 and 1.1.3 rows")与具体版本号强耦合,日后 provider 变更会导致描述失真。建议改为动态生成,利用 removed_providers 列表构造描述。

  • [P2] harness/web_fetch/container_resources.py:162:subprocess.run(["docker", "exec", ...]) 调用 docker CLI,但 validate() 只检查 Docker SDK 连接,不验证 docker CLI 二进制是否在 PATH 中。若 CLI 缺失,运行时会抛出 FileNotFoundError,诊断困难。建议在 validate() 中加入 shutil.which("docker") 检查。

  • [P2] tests/test_resource_accounting.py:仅1个测试,只验证 re-export 身份,未覆盖 delta_counters/ResourceSampler.summary 的实际计算逻辑(如 CPU 比率换算 scale=0.1、time-weighted mean 等)。

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Claude review completed. Review run: https://github.com/lexmount/browser-eval/actions/runs/34943127471. Please check Claude's inline feedback and summary comment for details.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review follow-up (4fbdbc1): confirmed defects fixed: apt plan download now rejects unsafe filenames and verifies size/checksum before cache replacement; cgroup sample maps counters explicitly; Docker CLI requirement fails early; tied resource winners and split RX/TX labels localize correctly; provider projection receipts no longer hard-code Moli versions. I also found and fixed a reader-visible stale methodology claim: the current five-browser report has 4 retained Moli 1.1.1 latency corrections, not 12 across three versions. Shared accounting calculations already had tests in tests/browser_use/test_metrics.py; the claim that they were untested was incorrect, and an uneven-interval memory test was added.

Main-sync warning: origin/main advanced to d59eee1 (#9), a different 10-method Web Fetch report bound by evaluation/current-report.json to site RSdbALdbdNG6. This PR binds the five-browser report to UUAhhQMnrGwm. A merge preflight finds 13 conflicting files; GitHub reports CONFLICTING. I fetched and audited main but did not force a merge/rebase that would overwrite the new report matrix or publication target. Under the repository single-current-report contract, #14 is not safe to merge as-is. Keep the 10-method report authoritative on main; the five-browser report needs an explicitly separate maintenance/release scope before its feature branch can be integrated. No merge or publication was performed.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 9m 26s —— View job


PR Review: Web Fetch isolated resource profiling

  • 读取 AGENTS.md
  • 读取 benchmark-report SKILL.md
  • 读取关键变更文件
  • 分析 PR diff
  • 输出审查结论

Review 结论

有条件通过

前两轮审查的 P0/P1 缺陷已全部修复,经逐文件核验:download_apt_uris.py 已验证文件名安全性与 size/checksum;resource_accounting.py:67 已改用具名字段;container_resources.py:validate() 已加 shutil.which("docker") 检查;i18n "并列领先" 变体(3373 行)已补充;provider projection 描述已动态生成;tests/browser_use/test_metrics.py 已覆盖 ResourceSampler.summary、delta_counters、LinuxContainerResources、DockerStatsResources。

合并状态:b24bb24 已将 origin/main(d59eee1e,10 方法报告)合入分支,git merge-base 确认无冲突。evaluation/current-report.json 正确指向 RSdbALdbdNG6(10 方法报告)。资源比较代码以文件存在性门控(resource-cohort/resource-comparison.json),对 10 方法报告无副作用。


问题及建议

  • [P2] harness/web_fetch/report_explainer.py:617:当 leader_tied=True 时,interpretation 字符串仍使用 "是本轮资源效率领先者"(单数形式),而 headline 已正确使用 "并列领先"。英文 REGEX(report_i18n.py:3428)将其翻译为 "X、Y is the resource-efficiency leader",多领先者时语法欠佳。当前证据只有单一领先者,不影响实际输出,但建议在产生绑定值时统一判断 winner_tied 并分支:tied 场景使用 "共同领先" 描述语。

未发现其他影响合并的问题。残余风险:解读文章的 _digest 绑定(report_explainer.py)固定指向特定速度证据哈希,若 5 浏览器报告复盘时速度证据变动,需同步更新该哈希。此项不影响当前 10 方法报告构建。

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 1m 58s —— View job


PR Review: Web Fetch isolated resource profiling (post-fix)

  • Gather context
  • Read key changed files
  • Review diff for bugs and security issues
  • Post findings

All three previously reported defects are confirmed fixed in this revision:

Security — apt checksum verification (download_apt_uris.py): parse_plan now validates the algorithm/digest field, rejects unknown hash types, and verifies digest length. download() checks both file size and digest before temporary.replace(destination). ✅

Security/Bug — path traversal on apt filenames (download_apt_uris.py): filename is now rejected if it equals "", ".", "..", contains \\, or if Path(name).name != name. ✅

Bug — fragile *counters.__dict__.values() unpacking (resource_accounting.py): ResourceSample is now constructed with named keyword arguments throughout both LinuxContainerResources.sample() and DockerStatsResources.sample(). ✅

Bug — Docker CLI not detected early (container_resources.py:validate()): shutil.which("docker") check is now present and raises a clear RuntimeError before the first docker exec call. ✅

i18n — tied-winner variant missing (report_i18n.py): "本轮资源效率并列领先": "Resource-efficiency co-leaders in this run" is now in the TEXT dictionary and is selected when leader_tied is true. ✅

No new bugs or security issues found in the additional changed files (container_resources.py, storage.py, providers/headless.py, headless_worker.py, run_headless_benchmark.py).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Claude review completed. Review run: https://github.com/lexmount/browser-eval/actions/runs/34951274671. Please check Claude's inline feedback and summary comment for details.

@lanyue-llk
lanyue-llk merged commit 6b4a1ea into main Sep 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant