Skip to content

fix(trajectory-replay): show absent timing samples as a dash in English - #222

Merged
lanyue-llk merged 2 commits into
mainfrom
fix/replay-absent-timing-dash
Nov 4, 2026
Merged

lanyue-llk merged 2 commits into
mainfrom
fix/replay-absent-timing-dash

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #213

Summary

The English replay result page showed a missing end-to-end time or CPU time as 0.0 s, which reads as a measurement. It now shows a dash, as the Chinese edition already did, and the zh branch is gone from both values. A measured zero still renders as 0.0 s.

One related case stays out of this PR. Per-step durations in the trajectory section still turn an absent sample into 0.00 s in both languages. #213 covers only the two page-level facts and fixing the step value also changes Chinese output, so it is tracked in #221.

Moved snapshots

Only English result routes moved. Each replay fixture attempt has duration_ms: 100 and resource: {}, so its CPU sample is absent.

Snapshot Route Before After
trajectory-replay-pass en/result/chromium-29.html CPU time 0.0 s CPU time —
trajectory-replay-pass en/result/moli-fixed-29.html CPU time 0.0 s CPU time —
trajectory-replay-pass en/result/moli-old-29.html CPU time 0.0 s CPU time —
trajectory-replay-fail en/result/chromium-29.html CPU time 0.0 s CPU time —
trajectory-replay-fail en/result/moli-fixed-29.html CPU time 0.0 s CPU time —
trajectory-replay-fail en/result/moli-old-29.html CPU time 0.0 s CPU time —

I built the base and fixed revisions with GOLDEN_KEEP and compared them with diff -r. These six routes differ, each on one line, and that CPU time value is the only fact that changes. End-to-end time stays 0.1 s because the fixtures record it.

Test plan

  • New test_detail_page_shows_absent_timing_as_dash_and_real_zero_as_zero covers missing, null and null-resource samples, a measured zero and a measured value, in both languages.
  • Negative control: against the base renderer, the three absent-sample cases fail in English and pass in Chinese. The zero and measured cases pass.
  • pytest tests/test_golden_reports.py tests/trajectory_replay -n 2: 2279 passed, 5 skipped.
  • Before regenerating, tests/test_golden_reports.py failed only on the two replay snapshots. The other 14 passed unchanged.
  • ruff check (both lint gate commands): passed.
  • CI on Linux runs the full suite.

@lexmount-ocr lexmount-ocr 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.

✅ Review complete · 8c513a6

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 1

Reviewed head 8c513a6d against main 332084e5. One finding, P3. No defects in the renderer change.

Findings

P3, tests/trajectory_replay/test_webarena_report.py:1130: the measured-zero case takes its expected value from the function it is guarding.

  • Problem: the test computes value = "—" if milliseconds is None else _format_ms(milliseconds, lang). If _format_ms starts treating zero as absent, both sides of the assertion become — and the test still passes. I changed if value is None: to if not value: in _format_ms and all 10 parametrized cases passed. The route snapshots do not catch this either, because the fixtures contain no measured zero. So the half of the contract that says a measured zero stays 0.0 s is not protected against that regression, although the test name and PR summary claim it.
  • Fix: put literal expected strings in the parametrization, for example "0.0 s" / "0.0 秒" and "1.5 s" / "1.5 秒", or compare against report_text(lang)("unit.seconds", ...) directly. Remove the _format_ms import from the test if it is no longer used.

What I verified

  • Semantics of the swap: the old English values were attempt.get("duration_ms", 0) and cpu_ms or 0. The new code passes the raw value to _format_ms, which returns — only for None. Measured 0 still gives 0.0 s in English and 0.0 秒 in Chinese. Absent, null and null-resource samples give —. Chinese output is unchanged, since the new expressions match its old branch.
  • New test: against the base renderer, exactly the three absent-sample English cases fail, and the other 7 pass. This matches the negative control in the PR.
  • Snapshots: I built base and head with GOLDEN_KEEP and ran diff -r. Exactly the six English result routes listed in the PR differ, each on one line, and the only change is 0.0 s to — for CPU time. No other route moved, and the PR explanation is accurate.
  • Scope: both zh branches named in #213 are gone. The remaining or 0 at webarena_report.py:914 (per-step duration) is outside #213 and is tracked in open issue #221, so Closes #213 is correct.
  • Repository rules: the change has no alias or parallel implementation, touches no hash-bound evidence, and adds only English text.
  • Local runs on this head:
    • tests/test_golden_reports.py: 16 passed.
    • tests/trajectory_replay: 2263 passed, 5 skipped. Together with the golden tests this matches the PR's 2279.
    • Both ruff gate commands passed.
  • CI on this head: all checks pass, including "Tests and static checks", "Installation and packaging", and "Rendered reference and report checks".

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 results.

Fixed

  • P3, tests/trajectory_replay/test_webarena_report.py: the measured-zero case took its expected value from _format_ms, the function it guards. The parametrization now expects literal strings (0.0 s / 0.0 秒, 1.5 s / 1.5 秒, 2.5 s / 2.5 秒), and the _format_ms test import is gone. Commit 333f99a.

Negative control: with if value is None: changed to if not value: in _format_ms, the two measured-zero cases (en, zh) now fail and the other 8 pass. I reverted the change afterwards.

Disputed
None.

Checks run locally

  • pytest tests/trajectory_replay/test_webarena_report.py tests/test_golden_reports.py -n 2: 81 passed. No snapshots changed, because this commit only touches the test.
  • ruff check (both lint gate commands): passed.

@lexmount-ocr lexmount-ocr 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.

ℹ️ Review skipped · 333f99a

No reviewable content was selected for this run.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 2

Reviewed head 333f99a5 against main 332084e5. There are no defects in this PR's code, test or snapshots. One finding remains: "Tests and static checks" is red on this head because of a flaky test that this PR does not touch.

Findings

P2, tests/test_native_cdp_port.py:226: the required CI gate is red on the current head, and the cause is not this PR.

  • Problem: run 41769409883 finished with 1 failed, 19864 passed. The failure is test_port_check_ignores_the_log_of_an_earlier_attempt with DID NOT RAISE RuntimeError, and it also fails the "Python 3.11" aggregate check.
  • Why this PR is not the cause:
    • The PR changes only webarena_report.py, two golden files and test_webarena_report.py. The commit added since the last green run changes only that test file.
    • The previous head 8c513a6d passed CI.
    • The same test fails with the same error on the unrelated branch codex/web-scraper-zyte140 (run 41769479060).
    • It passed 8 of 8 local repeats on this head.
  • Likely mechanism: the test's stand-in server calls listen() and only then exits with code 3.
    • If _connect_native_cdp connects inside that short window, the fake handshake accepts it, because the restarted port is not in taken.
    • The caller then returns at once, the server is still alive at the check after the yield, and no error is raised.
    • I reproduced the same DID NOT RAISE message by adding a 2-second sleep before the exit in a throwaway copy of the test. The no-delay control passed. This widens the window rather than capturing the CI timing, so the mechanism is well supported but not observed directly on the runner.
  • Fix:
    • For this PR, rerun the failed job and confirm it goes green. No change to this PR's code is needed.
    • Separately, open a follow-up issue to remove the race, for example by having this test's script bind and exit without calling listen(), so no connection can succeed.

What I verified

  • Round 1 fix: the test now expects the literal strings 0.0 s / 0.0 秒, 1.5 s / 1.5 秒 and 2.5 s / 2.5 秒. The _format_ms test import is gone.
  • Negative controls, rerun on this head:
    • With the base renderer, exactly the 3 absent-sample English cases fail and the other 7 pass.
    • With if not value: in _format_ms, exactly the 2 measured-zero cases (en, zh) fail and the other 8 pass.
    • I reverted both mutations, and the worktree stayed clean.
  • Semantics: _format_ms returns — only for None. Absent, null and null-resource samples give a dash, and a measured zero stays zero. No zh branch remains on either value.
  • Snapshots: only the six English result route hashes listed in the PR moved, three per replay snapshot. The golden files and renderer have not changed since the diff -r comparison in round 1, so I did not repeat it.
  • Scope: both values named in #213 are fixed, so Closes #213 is correct. The remaining per-step or 0 at webarena_report.py:914 is tracked in open issue #221.
  • Repository rules: the change has no alias or parallel implementation and touches no hash-bound evidence. The text it adds is English, apart from the Chinese expected strings for the Chinese edition.
  • Local runs on this head:
    • tests/test_golden_reports.py plus tests/trajectory_replay/test_webarena_report.py: 81 passed.
    • tests/trajectory_replay: 2263 passed, 5 skipped.
    • Both ruff gate commands passed.
  • CI on this head:
    • Passed: "Installation and packaging", "Rendered reference and report checks".
    • Failed: "Tests and static checks", "Python 3.11" (the aggregate of the others), for the reason above.
    • I did not rerun any jobs.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2: one finding, no code change and no new commit. The head is still 333f99a5.

Fixed: red required gate (tests/test_native_cdp_port.py, P2). I reran run 41769409883. Attempt 1 failed with test_port_check_ignores_the_log_of_an_earlier_attempt (DID NOT RAISE RuntimeError, 1 failed, 19864 passed). Attempt 2 on the same head passed: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" are all green.

Follow-up issue: not opened, because #216 already tracks this race. It names the same test and the same listen() window, and proposes the same fix. It remains open and this PR does not close it, so the test can still fail at random on other branches until #216 lands.

Nothing disputed.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review, round 3

No defects found on head 333f99a5 (main is still 332084e5, the PR's base).

What I verified

  • Old and new semantics: the only inputs whose output changes are English attempts with a missing duration_ms, or a missing or null cpu_ms, including a null or missing resource. These now render a dash. Measured values and a measured zero render as before, and Chinese is unchanged.
  • New test, with the base renderer: the three absent-sample cases fail in English. The other 7 cases pass.
  • New test, with if value is None: changed to if not value: in _format_ms: the two measured-zero cases fail (en, zh), so the round 1 finding stays fixed.
  • Snapshots: I built the base and head renderers with GOLDEN_KEEP and compared them. Exactly the six routes listed in the PR differ, and replacing CPU time</span><strong>0.0 s with the dash turns each base route into the head route byte for byte. No other route, language or fact moved.
  • Scope: #213 asks for the two page-level values, the removal of the zh branch, and snapshot updates explained in the PR. All are done, so Closes #213 is accurate. The step-level 0.00 s at webarena_report.py:914 is outside #213 and is tracked in open issue #221.
  • Rules: the diff touches one renderer, one test file and two snapshot files. It adds no alias or parallel implementation, touches no evidence, and adds no attribution lines to the commits or PR text. No stale references to the old English zero remain in src, scripts, docs, .agents or tests/trajectory_replay.

Checks run locally

  • pytest tests/test_golden_reports.py tests/trajectory_replay -n 2: 2279 passed, 5 skipped.
  • ruff check (both lint gate commands): passed.

CI on this head
All checks pass, including "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11". The green result on run 41769409883 comes from a rerun. Attempt 1 failed on the native CDP port race tracked in #216, which this PR does not touch and which can still fail at random until #216 lands.

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
The English result page turned a missing duration or CPU sample into 0.0 s, while the Chinese edition showed a dash. Both editions now show the dash and a measured zero stays 0.0 s.
The measured-zero case took its expected value from the formatter it guards, so changing the formatter to treat zero as absent still passed. Expect literal strings in both editions.
@lanyue-llk
lanyue-llk force-pushed the fix/replay-absent-timing-dash branch from 333f99a to b69bd67 Compare November 4, 2026 04:34

@lexmount-ocr lexmount-ocr 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.

✅ Review complete · b69bd67

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 9c3903e into main Nov 4, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the fix/replay-absent-timing-dash branch November 4, 2026 04:40
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.

Show absent replay timing samples as a dash in English

1 participant