Skip to content

Compare five browsers on Web Fetch with bounded adapters and reference gates - #5

Closed
lanyue-llk wants to merge 10 commits into
mainfrom
codex/headless-webfetch-code
Closed

lanyue-llk wants to merge 10 commits into
mainfrom
codex/headless-webfetch-code

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

范围

补齐 Kitesurf、Lightpanda、Obscura、Moli、Chromium 的统一 HTML → pyhtml2md 适配器,使用仓库共享评分规则与唯一报告生成器。五种浏览器均完成全部 150 题,主选结果 750 条,所有参考核验已完成。四题因参考封存失败重跑完整五方批次,保留旧调用与失败证书,不按分数择优。

本 PR 仅含代码、测试与诊断摘要,不含新增抓取原文或任何令牌。完整原始证据保留本地;发布副本将 14 份辅助 HTML 中的 114 处密钥格式字符串脱敏,750 份评分输出逐字节不变,并保留脱敏前后哈希清单。

Artifact Hub 发布凭据支持显式环境/仓库覆盖及用户目录复用。替换旧令牌需明确参数,旧文件备份、新文件权限 0600,令牌不进入 HTML 或 Git。评测服务凭据仍仅使用仓库配置。报告仅列账号要求与官方申请入口。

验证

  • Python:476 tests,11 skipped,其余通过(含逐文件发布校验回归测试)。
  • 两组 JavaScript UI/加载器测试通过。
  • 全部 750 条结果哈希、调用身份、规则、参考证书及重算指标一致。
  • 报告完整性、三态筛选默认失败、所有登记接口和采用统计检查通过。
  • 915 个 HTML 页面本地链接检查通过。
  • 发布包独立还原 3354 个文件,750 份评分输出不变,凭据模式扫描通过。
  • 桌面、390px 手机阅读、独立 HTML 及打印样式检查通过。

发布状态

用户明确要求另建站点、不覆盖旧报告。五浏览器报告已发布到独立站点 bWkRP157EtF6:公开报告。原站点 UeZE1vfcEOrM 保留不动。

新站点首页、报告解读及默认失败筛选已通过线上检查,免登录分享返回 200。整站 ZIP 导出两次返回 502,因此改用逐文件核验:120 个线上文件与提交包哈希全部一致,核验前后版本均为 ver_f77ea35e11f54984b4b85bce5ef08194。入口 HTML 使用原始源码接口核对,避免平台运行时注入造成误报;其余文件从公开预览路径读取。3354 个逻辑文件及全部 750 份评分输出通过发布包还原校验。

解释边界

普通网页通过数:Moli 90/100,Chromium 与 Lightpanda 89/100,Kitesurf 83/100,Obscura 70/100。动态任务分别为 Kitesurf 6/10、Obscura 5/10、Chromium 与 Lightpanda 1/10、Moli 0/10。六类不合成总分。

Kitesurf 是远程公共 CDP,其余为本地;本轮测冷调用客户端耗时和任务交付,不是等硬件 CPU/RSS 或吞吐比较。普通网页延迟按共同通过 URL 配对。未启用专用文档/媒体理解链路,相关失败不能外推为产品能力缺失。

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

View job run

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

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


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

Three issues found; no style/naming feedback per custom instructions.


1. Security — headless_worker.py has no URL validation when run standalone

headless_worker.py:71 runs json.load(sys.stdin) and passes request['url'] directly to browser engines with no validation. The guard validate_http_url() only runs inside HeadlessProvider.fetch() before spawning the subprocess. Because the script has a __main__ entry point and its README-visible usage is as a standalone tool, an operator can trivially SSRF internal services by feeding it crafted JSON:

echo '{"engine":"chromium","binary":"/usr/bin/chromium","url":"http://169.254.169.254/latest/meta-data/","timeout":10}' | python scripts/headless_worker.py

Fix: call validate_http_url(request['url']) at the top of fetch() in the worker, mirroring what the provider already does. Fix this →


2. Bug — postcheck_headless.py swallows JSON errors on all lines, not just the in-progress final one

scripts/postcheck_headless.py:55-57:

for line in (args.run_dir/'results.jsonl').read_text().splitlines():
    try:records.append(json.loads(line))
    except json.JSONDecodeError:pass  # a writer may be flushing the final line

The comment says the handler is for the final line being concurrently flushed. In practice the handler fires for every line, so a corrupted completed line is silently dropped and the loop continues with a shorter records list. certify_case() catches the count mismatch downstream, but only after a full polling cycle, and the root cause is invisible in logs.

Fix: restrict the silent swallow to the last line only:

lines = (args.run_dir/'results.jsonl').read_text().splitlines()
for i, line in enumerate(lines):
    try:
        records.append(json.loads(line))
    except json.JSONDecodeError:
        if i < len(lines) - 1:
            raise  # only the last line may be partially flushed

Fix this →


3. Bug — check_headless_evidence.py integrity checks are assert-only and disabled by python -O

scripts/check_headless_evidence.py uses assert for all integrity checks (hash verification, task-rule equality, coverage counts, attempt-ID uniqueness). Running with python -O — a common CI optimisation flag — silently skips every check and prints PASS regardless. The script is the primary evidence audit tool referenced in the PR validation steps.

Replace with explicit if … raise ValueError(…) or at minimum document that this script must not be run with -O. Fix this →


No other bugs or security issues found in the diff. The regex backtracking fix in metrics.py is correct and equivalence is exhaustively tested.

@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/33770459093. Please check Claude's inline feedback and summary comment for details.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

View job run

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

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


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

The three issues flagged in the previous review cycle remain unfixed, and two of them now have additional occurrences in newly added files.


1. Security — headless_worker.py still has no URL validation (unfixed)

headless_worker.py imports nothing from harness.web_fetch.safety and its fetch() function passes request['url'] directly to browser engines with no validation. The __main__ entry point calls fetch(json.load(sys.stdin)) with no guard, making SSRF trivial when the script is run standalone:

echo '{"engine":"chromium","binary":"/usr/bin/chromium","url":"http://169.254.169.254/latest/meta-data/","timeout":10}' | python scripts/headless_worker.py

HeadlessProvider.fetch() calls validate_http_url(case.url) before spawning the subprocess, but an operator invoking the script directly bypasses that layer entirely.

Fix: add validate_http_url(request['url']) as the first statement in fetch() in the worker.
Fix this →


2. Bug — Silent JSON error swallowing now in two files (unfixed + new occurrence)

postcheck_headless.py:53-55 (unfixed from prior review) and new file certify_headless_cases.py at its results-reading loop both contain:

for line in (run_dir/'results.jsonl').read_text().splitlines():
    try: records.append(json.loads(line))
    except json.JSONDecodeError: pass

The comment says this handles a partially flushed final line, but the handler fires for every line. A corrupted completed record is silently dropped and downstream count checks discover the mismatch only after a full polling cycle with no root-cause logged.

Fix for both files: only swallow the error on the last line, re-raise on any earlier line.
Fix this →


3. Bug — assert-only integrity checks now in two files (unfixed + new occurrence)

check_headless_evidence.py (unfixed from prior review) still uses assert for all integrity checks. New file scripts/run_headless_benchmark.py:55 also uses:

assert len(records) == len(cases)*len(providers)

Both are silently skipped when Python is run with -O, causing the scripts to print PASS or proceed with no error despite a coverage shortfall. These are the primary evidence audit and benchmark completion checks.

Fix: replace assert with explicit if … raise ValueError(…) in both files.
Fix this →


No other bugs or security issues found in the new diff.

@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/33835579700. Please check Claude's inline feedback and summary comment for details.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Addressed the review findings in c2c5ac2: standalone worker now applies the shared HTTP(S) URL syntax validator before launching any engine; both postcheck and certification use one JSONL reader that only tolerates an unterminated final fragment and rejects corrupted completed lines; evidence audit and runner completion checks no longer depend on assert. Important correction: validate_http_url checks scheme/syntax only; it does not block private IPs, redirects or DNS rebinding, so this is not claimed as full SSRF mitigation. The worker remains a local benchmark helper, not a service for untrusted URL submissions. Validation: 13 targeted tests passed; the full suite before the final shared-reader extraction passed 466 tests (11 skipped); python -O audit with --rescore verified all 750 persisted calls and reproduced all metrics. The remaining web-retail-returns reference verification is still explicitly blocked; no historical evidence or scores were rewritten.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

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


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

All three issues from the prior review cycles are fixed. No new bugs or security issues found in the new diff.


Fix verification

1. URL validation in headless_worker.py — Fixed.
validate_http_url(request['url']) is now the first statement in fetch(). The inline comment correctly scopes it: scheme/syntax only, not network isolation. That limitation is accurately disclosed in the PR.

2. Silent JSON error swallowing — Fixed.
Both postcheck_headless.py and certify_headless_cases.py now delegate to read_completed_records() in harness/web_fetch/record_io.py. The implementation is stricter than the original suggestion: it only swallows a JSONDecodeError on the last line and only when that line is unterminated (does not end with \n or \r). A terminated-but-corrupt last line is correctly re-raised.

3. assert-only integrity checks — Fixed.
check_headless_evidence.py introduces a require(condition, message) helper that raises ValueError unconditionally, replacing all prior assert calls. run_headless_benchmark.py uses an explicit if len(records) != ...: raise ValueError(...). Both are safe under python -O.


No other bugs or security issues found in the new diff. The assemble_headless.py read_records() local function uses bare splitlines() (not read_completed_records) but correctly applies only to completed assembled data, not actively writing runs.

@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/33836005291. Please check Claude's inline feedback and summary comment for details.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 3m 6s —— View job


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

No new bugs or security issues found in the new diff.

Fix verification (prior cycle)

All three previously flagged issues remain fixed in this sync:

  • URL validation in headless_worker.py — validate_http_url(request['url']) is the first statement in fetch().
  • Silent JSON error swallowing — postcheck_headless.py and certify_headless_cases.py both delegate to read_completed_records() in harness/web_fetch/record_io.py, which only tolerates an unterminated final line and re-raises on terminated corrupt lines.
  • assert-only integrity checks — check_headless_evidence.py uses require() raising ValueError; run_headless_benchmark.py uses explicit if … raise ValueError.

New code in this sync

  • artifact_auth.py — token write uses O_EXCL for creation and os.replace for atomic update; symlink destination is explicitly rejected; backup on conflict is correctly isolated.
  • publication_privacy.py — redaction applies to bytes, pattern order is correct (OTHER_SECRET checked before GOOGLE_KEY, path restriction checked after match), and scored artifact paths are guarded against redaction in package_artifact_hub.py.
  • record_io.py — the unterminated-line check (line.endswith(('\n', '\r'))) correctly uses keepends=True in splitlines so the condition is meaningful.

@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/33837232334. Please check Claude's inline feedback and summary comment for details.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

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


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

All three issues from prior review cycles remain fixed. One new bug found in the newly added summarize_headless.py.


Bug — summarize_headless.py crashes on None P50 values

scripts/summarize_headless.py:43:

for pair in evidence['pairs']:
    text.append(f'| {pair["provider"]} | {len(pair["both_pass_ids"])} | {pair["provider_p50_ms"]:.2f} | {pair["chromium_p50_ms"]:.2f} |')

headless_evidence() sets provider_p50_ms and chromium_p50_ms to None when no URLs pass in both browsers (common is empty). Applying :.2f to None raises TypeError at runtime. The report renderer _render_headless() has a num() helper that handles None correctly, but summarize_headless.py does not use it.

Fix: guard with a formatter before formatting:

def fmt(v): return f'{v:.2f}' if v is not None else '—'
for pair in evidence['pairs']:
    text.append(f'| {pair["provider"]} | {len(pair["both_pass_ids"])} | {fmt(pair["provider_p50_ms"])} | {fmt(pair["chromium_p50_ms"])} |')

Fix this →


No other bugs or security issues found in the new diff. The three previously flagged issues (URL validation, JSON error swallowing, assert-only checks) remain fixed.

@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/33837940130. Please check Claude's inline feedback and summary comment for details.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

已复现并修复最新审查发现的共同通过集合为空时的 P50 格式化错误(b1fa741)。None 显示为 —,真实零耗时保留 0.00;新增两项回归测试。完整 Python 测试 472 项、11 skipped,其余通过。重新生成本次 150 题摘要后与原文件逐字节一致,评分和报告数据没有变化。发布仍等待并发站点目标确认,未覆盖另一任务的新版本。

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

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


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

The bug flagged in the previous cycle is fixed. No new bugs or security issues found.

Fix verification

summarize_headless.py — None P50 crash — Fixed.
paired_latency_row() wraps the format spec in a milliseconds() helper that returns '—' for None and f'{value:.2f}' for numeric values. Tests covering the None case and a measured-zero case are added in tests/test_headless_summary.py.

All four previously flagged issues remain fixed:

  • URL validation in headless_worker.py — validate_http_url(request['url']) is the first statement in fetch().
  • Silent JSON error swallowing — postcheck_headless.py and certify_headless_cases.py both delegate to read_completed_records() in record_io.py, which only tolerates an unterminated final line.
  • assert-only integrity checks — check_headless_evidence.py uses require() raising ValueError; run_headless_benchmark.py uses explicit if … raise ValueError.

@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/33838269319. Please check Claude's inline feedback and summary comment for details.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 4m 50s —— View job


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

No new bugs or security issues found in the new diff.

Fix verification (all four prior issues)

  • URL validation in headless_worker.py — validate_http_url(request['url']) is the first statement in fetch().
  • Silent JSON error swallowing — postcheck_headless.py and certify_headless_cases.py both delegate to read_completed_records() in record_io.py, which only tolerates an unterminated final line and re-raises on terminated corrupt lines.
  • assert-only integrity checks — check_headless_evidence.py uses require() raising ValueError; run_headless_benchmark.py uses explicit if … raise ValueError.
  • summarize_headless.py None P50 crash — paired_latency_row() uses a milliseconds() helper that returns '—' for None.

New code in this sync

  • headless_evidence() in report_explainer.py — statistics.median() calls are all guarded against empty sequences (skipping provider via if not rows: continue; paired P50 uses if common else None). _mean() already filters None values before passing to statistics.mean(). No crash path found.
  • artifact_auth.py — O_EXCL creation, atomic os.replace for updates, symlink rejection, UUID-based backup naming. Correct.
  • publication_privacy.py — OTHER_SECRET checked before GOOGLE_KEY (correct order); scored artifact paths are guarded against redaction in package_artifact_hub.py via scored_paths set.
  • record_io.py — splitlines(keepends=True) makes the line.endswith(('\n','\r')) check meaningful. Correct.

@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/33842205778. Please check Claude's inline feedback and summary comment for details.

@lanyue-llk
lanyue-llk marked this pull request as ready for review September 4, 2026 06:04
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Claude finished @lanyue-llk's task in 4m 24s —— View job


PR Review

  • Read CLAUDE.md for repo guidelines
  • Review PR diff for bugs and security issues
  • Post findings

Findings

All four previously flagged issues remain fixed. One new bug found in the newly added check_publication_bundle.py.


Bug — check_publication_bundle.py reads local files using paths from inside the ZIP without contained_path() validation

scripts/check_publication_bundle.py:38,44:

rows=[json.loads(line) for line in data('results.jsonl').splitlines()]
for row in rows:
    raw=data(row['artifact_path'])
    ...
    if raw!=(source/row['artifact_path']).read_bytes():raise ValueError('Scored bytes differ from local source')
...
for row in privacy['files']:
    if hashlib.sha256((source/row['path']).read_bytes()).hexdigest()!=row['original_sha256']:

row['artifact_path'] and row['path'] are taken from inside the ZIP (results.jsonl and publication-privacy.json respectively) and used directly in source / row[...] path joins without validation. A crafted archive with artifact_path: "../../etc/passwd" would cause the check to read arbitrary local files and compare their bytes against ZIP content, leaking their contents indirectly (the comparison succeeds or fails, revealing whether bytes match). The rest of the codebase uses contained_path() for exactly this pattern — for example assemble_headless.py uses contained_path(root, relative) for every artifact path derived from records.

Fix: wrap both path joins with contained_path():

if raw!=contained_path(source, row['artifact_path']).read_bytes():raise ValueError('Scored bytes differ from local source')
if hashlib.sha256(contained_path(source, row['path']).read_bytes()).hexdigest()!=row['original_sha256']:

Import contained_path from harness.web_fetch.safety (already imported in harness/web_fetch/safety.py:13).

Fix this →


Fix verification (all four prior issues)

  • URL validation in headless_worker.py — validate_http_url(request['url']) is the first statement in fetch().
  • Silent JSON error swallowing — both files delegate to read_completed_records() in record_io.py, which only tolerates an unterminated final line.
  • assert-only integrity checks — check_headless_evidence.py uses require() raising ValueError; run_headless_benchmark.py uses explicit if … raise ValueError.
  • summarize_headless.py None P50 crash — paired_latency_row() uses a milliseconds() helper returning '—' for None.

No other bugs or security issues found in the new diff.

@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/33842896887. Please check Claude's inline feedback and summary comment for details.

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