Repository navigation
fix(trajectory-replay): show absent timing samples as a dash in English - #222
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
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_msstarts treating zero as absent, both sides of the assertion become—and the test still passes. I changedif value is None:toif not value:in_format_msand 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 stays0.0 sis 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 againstreport_text(lang)("unit.seconds", ...)directly. Remove the_format_msimport 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)andcpu_ms or 0. The new code passes the raw value to_format_ms, which returns—only forNone. Measured0still gives0.0 sin English and0.0 秒in Chinese. Absent, null and null-resourcesamples 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_KEEPand randiff -r. Exactly the six English result routes listed in the PR differ, each on one line, and the only change is0.0 sto—for CPU time. No other route moved, and the PR explanation is accurate. - Scope: both
zhbranches named in #213 are gone. The remainingor 0atwebarena_report.py:914(per-step duration) is outside #213 and is tracked in open issue #221, soCloses #213is 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".
|
Review round 1 results. Fixed
Negative control: with Disputed Checks run locally
|
There was a problem hiding this comment.
ℹ️ Review skipped · 333f99a
No reviewable content was selected for this run.
lanyue-llk
left a comment
There was a problem hiding this comment.
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_attemptwithDID 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 andtest_webarena_report.py. The commit added since the last green run changes only that test file. - The previous head
8c513a6dpassed 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.
- The PR changes only
- Likely mechanism: the test's stand-in server calls
listen()and only then exits with code 3.- If
_connect_native_cdpconnects inside that short window, the fake handshake accepts it, because the restarted port is not intaken. - 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 RAISEmessage 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.
- If
- 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 秒and2.5 s/2.5 秒. The_format_mstest 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_msreturns—only forNone. Absent, null and null-resourcesamples give a dash, and a measured zero stays zero. Nozhbranch 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 -rcomparison in round 1, so I did not repeat it. - Scope: both values named in #213 are fixed, so
Closes #213is correct. The remaining per-stepor 0atwebarena_report.py:914is 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.pyplustests/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.
|
Review round 2: one finding, no code change and no new commit. The head is still Fixed: red required gate ( Follow-up issue: not opened, because #216 already tracks this race. It names the same test and the same Nothing disputed. |
lanyue-llk
left a comment
There was a problem hiding this comment.
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 nullcpu_ms, including a null or missingresource. 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 toif 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_KEEPand compared them. Exactly the six routes listed in the PR differ, and replacingCPU time</span><strong>0.0 swith 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
zhbranch, and snapshot updates explained in the PR. All are done, soCloses #213is accurate. The step-level0.00 satwebarena_report.py:914is 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,.agentsortests/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.
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.
333f99a to
b69bd67
Compare
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 thezhbranch is gone from both values. A measured zero still renders as0.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 sin 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: 100andresource: {}, so its CPU sample is absent.trajectory-replay-passen/result/chromium-29.html0.0 s—trajectory-replay-passen/result/moli-fixed-29.html0.0 s—trajectory-replay-passen/result/moli-old-29.html0.0 s—trajectory-replay-failen/result/chromium-29.html0.0 s—trajectory-replay-failen/result/moli-fixed-29.html0.0 s—trajectory-replay-failen/result/moli-old-29.html0.0 s—I built the base and fixed revisions with
GOLDEN_KEEPand compared them withdiff -r. These six routes differ, each on one line, and that CPU time value is the only fact that changes. End-to-end time stays0.1 sbecause the fixtures record it.Test plan
test_detail_page_shows_absent_timing_as_dash_and_real_zero_as_zerocovers missing, null and null-resourcesamples, a measured zero and a measured value, in both languages.pytest tests/test_golden_reports.py tests/trajectory_replay -n 2: 2279 passed, 5 skipped.tests/test_golden_reports.pyfailed only on the two replay snapshots. The other 14 passed unchanged.ruff check(both lint gate commands): passed.