Repository navigation
refactor(reporting): share one reviewer runner and esc helper - #146
Conversation
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| from lexbench_webfetch.paths import contained_path, safe_identifier | ||
|
|
||
| from harness.record_io import file_sha256, load_jsonl, parse_jsonl, write_json | ||
| from harness.review_runner import run_reviewer |
There was a problem hiding this comment.
P2: Include the extracted runner in the review workspace implementation identity. bind_review_workspace() still hashes only the four original modules, although execution now depends on this import. Consequently, changing review_runner.py alone leaves review-session.json unchanged and permits reuse of judgments across different runner implementations. This weakens the documented contract in web_fetch/README.md:387–391 that changed review implementations require a new work directory; the changed hash of review_execution.py only invalidates pre-refactor workspaces once. Add the runner module to implementation_sha256 and a resume regression test that changes only its hash and verifies rejection before outputs are reused.
There was a problem hiding this comment.
✅ Re-review complete · fe299d1
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head fe299d18. No correctness regression found in the runner swaps. There are three findings on scope and issue tracking.
Findings
P2: src/harness/web_search/comparison.py:205 keeps a second copy of esc().
e = lambda value: html.escape(str(value), quote=True) has the same body as the old Web Search esc. #148 requires that no second copy remains in the two tracks.
Fix: use harness.reporting.presentation.esc with none="None", which keeps the rendered bytes. Importing from web_search/report.py would be circular, because that module imports comparison.
P2: PR body, "## Issues" points only at closed #102.
#102 was closed by #144, and its remaining work moved to #156. #148 is the open issue for exactly this step and is not linked, so merging will not update #148 or its checkbox in #156. The list of work that "remains" under #102 is tracked in #156.
Fix: link #148 (Closes only once its acceptance is met, including the first finding) and point the remaining items at #156. The workflow brief for this step said "Part of #102", so the orchestrator should confirm the wording.
P3: src/harness/web_fetch/report_changes.py:132,170 and src/harness/web_fetch/report_components.py:508 still import esc through harness.web_fetch.report.
tests/test_report_method_registry.py:41,109 and tests/test_public_report_language.py:37 do the same. #148 asks to migrate callers with no aliases, and these now rely on a name that report.py only re-exports.
Fix: import esc from harness.reporting.presentation directly.
Verified
run_revieweragainstsubprocess.run, by reading the code: same kill and wait on timeout, same handling of other exceptions, sameCompletedProcessfields and same inherited stdin.text=Trueis new at the content-packet site, but it has no effect there because that site opens no pipes.ReviewerSessionsagainst the old Web Search code, by reading the code: same lock around start, same group kill, same status transitions. The one difference is that aProcessLookupErrorduring a timeout kill in a worker is now swallowed, which is harmless.esc(): both tracks produce the same bytes as before, including forNone.- Bound files: the base-commit SHA-256 and blob hashes of the five edited source files do not appear anywhere in the repository.
web_search/review.pyandpresentation.pyare not incollection_implementation. - Local checks: both ruff commands pass.
tests/test_review_runner.py,test_review_execution.py,test_webmainbench_content_review.py,test_report_presentation_contract.py,web_search/test_review_runtime.pyandtest_golden_reports.pygave 82 passed. - CI on this head: all checks pass, including "Tests and static checks" and "Installation and packaging".
Not verified
- Test strength: a mutation run against the call sites and the runner had not finished when this review was written, so I make no claim about whether the tests catch those changes.
- Golden manifest: the golden test passes and only
manifest.jsonchanged, but I did not recompute the claim that restoring the base hash reproduces the old value. - Paired runs: I did not rerun the paired base-versus-branch scenarios, and the script is not committed.
- Local workspace comparison: I did not reproduce the comparison of local review workspaces with the base hash.
- Local full suite: I did not rerun it.
|
Review round 1 follow-up. All three findings are fixed and none are disputed.
Hash bindings: the two |
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Reviewed head 86147af4. I found no correctness regression, and all three round 1 fixes hold. There are two P3 findings: one test gap and one documentation gap.
Findings
P3: src/harness/review_runner.py:29: the non-timeout kill branch has no test.
_communicate catches BaseException, which matches the except: branch in subprocess.run and is what kills a reviewer on an interrupt or an OSError. I changed it to except subprocess.TimeoutExpired and tests/test_review_runner.py, tests/web_search/test_review.py, tests/web_search/test_review_runtime.py and tests/test_review_execution.py all still pass (113 passed).
The branch matters most for ReviewerSessions. web_search/review.py treats OSError as a recorded failure, while communicate's finally has already removed the process from _running. Without the kill, the reviewer group would keep running and stop() could no longer reach it. #148 asks for kill handling to be covered at the public boundary.
Fix: add two tests. In the first, Popen.communicate raises KeyboardInterrupt under run_reviewer, and the child must end with returncode -9. In the second, it raises OSError under ReviewerSessions.communicate, the error must propagate and the child must end with returncode -9. A throwaway version of both passed on this head and failed under the mutation above.
P3: docs/architecture.md:67: the new shared owner is not in the table.
The "Shared owner or boundary" table tells contributors which module to extend, and harness/review_runner.py is now shared by two tracks but has no row. trajectory_replay/public_webarena/diagnostics.py also launches codex and is outside this PR's scope, so another reviewer call site could plausibly be added without anyone finding this owner.
Fix: add one row, for example | Independent reviewer subprocess execution | src/harness/review_runner.py |.
Verified
Round 1 fixes
web_search/comparison.pynow uses the sharedesc.- An AST scan of
src,testsandscriptsfinds noescimport throughharness.web_fetch.reportand no.escattribute access. The only import fromharness.web_search.reportis the test that pins that track'sNonerendering. - The only remaining function named
escis therender_pricingtranslation wrapper, which the PR body discloses and which delegates to theescit receives. Closes #148matches that issue's acceptance, apart from the test gap above. #156 is open and is the follow-up for the remaining items.
esc bytes
- Web Fetch:
html.escapealready defaulted toquote=True, andNonestill renders as an empty string. - Web Search:
Nonestill renders as the literalNone, and the escaping is unchanged.
run_reviewer compared with subprocess.run, by reading the code
- The result fields, the direct-child kill and wait on timeout, and the kill on other exceptions all match.
- The added
text=Truehas no effect at the content-packet site, which has no pipes. - The
subprocess.check_outputatreview_execution.py:735only reads--version, so it is not a fourth reviewer call site.
ReviewerSessions compared with the old web_search/review.py code, by reading the code
Popenstill runs under the lock, and the stopping flag still flips under the lock before the running set is snapshotted.- The receipt fields and their write order are unchanged.
- The
interruptedversusfailedselection is unchanged. - There are two intended small differences. A process is removed from tracking right after
communicateinstead of after result parsing, which has no effect becausestop()skips exited processes.ProcessLookupErroris now tolerated on the timeout path, where it would previously have propagated.
Hash bindings
collection_implementationlists no edited file.- No
__file__orwith_namebinding namespresentation.py,report_changes.py,report_components.py,comparison.pyorweb_search/review.py. review_runner.pyis inimplementation_sha256, and removing it makes the new resume test fail.
Mutations that the existing tests caught
- Killing only the group leader
- Not tracking started processes
- Not starting a new session
- Removing
sessions.stop() - Removing the
interruptedstatus - Removing the runner from the binding
Removing process.wait() from _kill_child also passes, but that is not a gap, because Popen.__exit__ reaps the child.
Local gates
- Both lint commands pass.
tests/test_review_runner.py,tests/test_review_execution.py,tests/test_webmainbench_content_review.py,tests/web_search,tests/test_golden_reports.pyand theesccaller test files give 721 passed. I did not run the full local suite.- Golden snapshots are unchanged by the round 1 commits. The only snapshot change in this PR is the one
web-searchline the PR body explains.
CI on this head
- "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass.
- The PR is mergeable, and its base equals the current
main.
|
Review round 2 fixes. Both findings are fixed; none are disputed.
No runtime code changed, so no hash-bound source list is affected. Locally, ruff passed, and |
There was a problem hiding this comment.
ℹ️ Review skipped · 0e74faf
No reviewable content was selected for this run.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 3
Reviewed head 0e74faff, based on current main 335217ee. I found no correctness, scope or AGENTS.md defects in the code. There is one P3 finding, in the PR text.
Findings
P3: PR body, "## Test plan". The plan stops at the round 1 commits. It does not mention 0367a51d (the two non-timeout kill tests) or 0e74faff (the architecture row), and the tests/test_review_runner.py bullet still lists only the original coverage.
Suggested fix: add one bullet saying what was run on these two commits and its results, including the mutation result for narrowing the except clause. No code change is needed.
What I verified
Reviewer runner
run_reviewermatches CPython 3.11subprocess.runfor the three old call sites: arguments,CompletedProcessfields,TimeoutExpiredand kill then reap. The addedtext=Trueat the content-packet site has no effect, because that site's output goes to a log file andcommunicatereturnsNone.ReviewerSessionsmatches the old Web Search code for start refusal under the lock, thepoll()guard beforekillpg, and the status and return code written to receipts.- Three differences are stricter than the old code, and none changes a receipt on a normal path:
- A
ProcessLookupErrorduring a timeout kill is now swallowed. - A non-timeout
BaseExceptionnow kills the group. - The process leaves the running set as soon as
communicateends, which is safe because it has already exited or been killed.
- A
- A
text.encode()failure can no longer reach the kill handler, because it is now evaluated outside the runner. This is not a regression: the same expression already runs earlier, wheninput_sha256is computed, so it fails before any child starts.
esc()
- Bytes are unchanged for both tracks, including
None(empty in Web Fetch, literalNonein Web Search). - No
escdefinition or lambda copy remains in either track. The only otherescis the translation wrapper inrender_pricing, which adds behaviour around the helper it receives. - No import of
escthroughharness.web_fetch.reportturned up.
Hash bindings
collection_implementationlists none of the edited files.implementation_sha256has the stated five entries, and no other code inweb_fetchreads its keys.runtime_source_sha256globs onlyweb_fetch/*.py, as the PR describes.- No file under
evaluation/,research/orscripts/, and no workflow, is changed.
Scope
Closes #148holds: its three acceptance items are met.- The publish orchestration, release-check base and HAR recorder are untouched and listed as remaining.
Tests
- Both lint commands pass.
tests/test_review_runner.py,test_review_execution.py,test_webmainbench_content_review.py,web_search/test_review.py,web_search/test_review_runtime.py,web_search/test_comparison.py,test_report_presentation_contract.py,test_report_method_registry.py,test_report_methods.py,test_report_pricing.py,test_public_report_language.pyandtest_golden_reports.py: 292 passed. Golden snapshots are unchanged by the latest commits.- Mutation: narrowing
except BaseExceptiontosubprocess.TimeoutExpiredfails exactly the two new tests. tests/test_review_runner.pypassed three more times in a row with no flakes.- I did not run the full local suite and relied on CI for it.
CI
- Run
41619751880is on head0e74faffand concluded success. "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks" all pass. - The PR is mergeable.
PR hygiene
- Commits have no attribution trailers.
- The diff has no local paths or usernames.
|
Review round 3: the one finding is fixed, and none are disputed. This was a PR body change only, so there is no new commit and the head stays at Fixed (P3, test plan):
The full local suite was not re-run after these commits, so CI on |
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 4
Reviewed head 0e74faff. No defects found. This round made no findings at any severity.
What I verified
Runner semantics, compared with the old code
run_revieweragainst CPython'ssubprocess.run: samePopenoptions, timeout path (kill, wait, re-raise), result fields andwithcleanup. The content-packet site now passestext=True, but it has no pipes (stdout=log,stderr=STDOUT), so nothing is decoded and the log bytes do not change. The non-timeout path now waits inside theexceptinstead of in__exit__, which changes only the order.ReviewerSessionsagainst the oldweb_search/review.pyblock:- The start options and environment are the same, and the start still happens under the lock with the late-start refusal.
stoppingis still set under the lock, and interrupted receipts are still written.- The process now leaves the running set when
communicateends rather than after post-processing. By then the leader has exited, and the oldpoll()guard skipped those processes anyway, sostop()behaves the same. - A failed
save()between start andcommunicatestill leaves the process in the running set, sostop()still kills it. - Two differences are strict hardening:
ProcessLookupErroris now swallowed on the timeout path, and a non-timeoutBaseExceptionnow kills the group.
esc
- The body matches both old helpers. Web Fetch rendered
Noneas an empty string with defaultquote=True. Web Search rendered it asNone, and now bindsnone="None"inreport.pyandcomparison.py. - An AST scan of
src,testsandscriptsfinds noescimport throughharness.web_fetch.report. The one import fromharness.web_search.reportis the test that pins that track's binding. - The remaining
def escin the two tracks is therender_pricingtranslation wrapper, which the PR body discloses. The one inenvironments/webarena/map_detail.pyis outside the two tracks.
Hash bindings
implementation_sha256gainsreview_runner.py, and the changed-runner test rejects resume with the workspace untouched.web_search/review.py,web_search/comparison.pyandreporting/presentation.pyare not incollection_implementationor any other named source list I could find.- The assessment revision's
implementation_sha256hasheslexbench_websearch/*.py, which this PR does not edit. git diffshows no change underevaluation/,research/,configs/or.github/.
Golden snapshots
- Only the
web-searchmanifest.jsonhash changes, as the PR explains.tests/test_golden_reports.pypasses.
Local runs on this head
- Both lint commands pass.
tests/test_review_runner.py,test_review_execution.py,test_webmainbench_content_review.py,web_search/test_review.py,web_search/test_review_runtime.py,web_search/test_comparison.py,test_report_presentation_contract.py,test_documented_paths.pyandtest_golden_reports.pygive 183 passed.- I did not run the full suite locally; CI on this head is the full-suite result.
Mutations (each reverted afterwards; all detected)
| Mutation | Failing tests |
|---|---|
| Session path kills only the direct child | 2 |
| Foreground path kills by group | 1 |
start_new_session removed |
4 |
sessions.stop() removed from run |
2 |
stop() no longer sets _stopping |
3 |
| Interrupted status dropped | 1 |
Noted, not a finding
- Removing
cwd=workfrom the blind-batch call site fails no test intests/test_review_execution.pyortests/test_review_result_anomalies.py, so those two files do not execute that call path with a reviewer. I did not run this mutation against the base commit, but the swap keeps the argument visibly unchanged, and the PR's paired runs covered this site. The runner itself is tested at its public boundary, as #148 asks.
Scope
Closes #148holds: the runner andesceach have one owner in the two tracks, and timeout and kill behaviour are tested at the public boundary.- The publish orchestration, release-check base and HAR recorder are untouched and listed as remaining in #156.
CI on 0e74faff
- "Tests and static checks", "Installation and packaging", "Rendered reference and report checks", "Python 3.11", "Select check scope" and "OCR dispatch" all succeeded. The PR is mergeable and clean against main
335217ee.
Issues
Closes #148.
Part of #102, which is closed, and part of the refactor roadmap #87. Its remaining work moved to #156.
This PR does the reviewer runner and the
esc()helper only. These items remain, tracked in #156:web_fetch/report_publish.publishasharness/reporting/publish.py)Summary
The new
harness/review_runner.pyholds the wait, kill and reap logic. Callers pick behaviour by choosing one of two entry points. It extends the more complete Web Search implementation.web_fetch/review_execution.py(blind batches, anomaly groups, content packets)run_reviewersubprocess.rundidweb_search/review.pyReviewerSessionsReviewerSessionsalso keeps the Web Search cancellation contract: starting and stopping share one lock, so a late worker cannot start a child and cancellation cannot miss one.These stay with their callers because only one caller uses each, or because they are bound to receipts:
CODEX_HOMEsetupesc()now lives inharness/reporting/presentation.py, and every caller imports it from there, includingweb_fetch/report_changes.py,web_fetch/report_components.pyand the tests. The two old helpers differed only forNone: Web Fetch rendered an empty string and Web Search rendered the literalNone. The shared helper takes anone=parameter, and Web Search bindsnone="None"inweb_search/report.pyandweb_search/comparison.py. The comparison renderer held a second copy of the old Web Search body; it cannot import fromreport.pybecause that would be circular.Direct standard-library
html.escapecalls elsewhere in the two tracks stay as they are, since they are notesc()helpers. The wrapper insiderender_pricingalso stays, because it adds English translations around theescit receives. No test fixture passesNoneto Web Searchesc, but real report data was not checked, so the old rendering is kept. Whether to drop it is a separate decision.The issue cites
web_fetch/review_execution.py:590-660, but that file has three call sites. All three are swapped.Hash-bound files edited
web_fetch/review_execution.pyreview-session.jsonimplementation_sha256, compared exactly when a review workspace resumesweb_fetch/review_execution.py,web_fetch/report.pyruntime_source_sha256, a stamp over everyweb_fetch/*.pyweb_fetchedit.web_fetch/report.pypresentation_refresh.renderer_sha256report.pyedit.web_fetch/report_changes.py,web_fetch/report_components.pyruntime_source_sha256implementation_sha256or any other named source list.web_fetch/report.pyrescoringsource_sha256audit stampweb_search/report.pymanifest.jsonrenderer_sha256Not edited, or not bound:
web_search/review.pyandweb_search/comparison.pyare not incollection_implementation, so collection resumes are unaffected. Neitherweb_search/runner.pynor any other file in that list was edited.Added to a binding:
harness/review_runner.pyis now a fifth entry inreview-session.jsonimplementation_sha256. The reviewer process code was bound while it lived inreview_execution.py, and theweb_fetchREADME requires a new work directory when the review implementation changes. New session receipts therefore gain one key. Receipts already on disk are affected no further, because the edit toreview_execution.pyalready rejects them. A new test changes only the runner's hash and checks that resume is rejected before any work is touched, in both the blind and anomaly phases.No evidence, frozen profile or stored receipt was rewritten.
Golden snapshots
One route changed:
web-searchmanifest.json, because it recordsrenderer_sha256of the editedreport.py. The review-round commits did not change any snapshot. Putting the base commit's hash back into the new manifest reproduces the old golden hash exactly, so that is the only byte change. No HTML route changed. All other report snapshots are unchanged.Test plan
ruffcommands pass.tests/test_review_runner.py: uses real child processes. It compares results, the timeout message and log-file output againstsubprocess.run, and checks direct-child versus group kill, reaping, and refusal of late starts. It also checks non-timeout interruption: aKeyboardInterruptinrun_reviewerkills and reaps the child, and anOSErrorinReviewerSessions.communicatekills the whole group and propagates the same error.tests/test_report_presentation_contract.pynow pins each track'sNonerendering. Intests/test_review_execution.py, the "no reviewer calls" guards now patchsubprocess.Popen, which also catchessubprocess.run. Intests/test_webmainbench_content_review.py, the fakes now targetrun_reviewer.implementation_sha256block (which differs by design) and the sub-second jitter in the timeout message.real_smoke): 66 failed, 19239 passed, 55 skipped. Re-running the failing test files at the base commit also gives 66 failures, with no test failing only on this branch. 15 are on the known local list. The one sampled from the rest fails on a local dataset lock error (Historical benchmark source is not recorded in the dataset lock); the others were not inspected individually.This full run was on the first commit. After the second commit (the runner binding), I re-ran lint, the review tests, the golden snapshots and the paired runs locally, and all pass.
tests/web_search,tests/test_report_*.py,tests/test_public_report_language.pyandtests/test_golden_reports.pygive 1105 passed, 1 skipped, with golden snapshots unchanged. The full local suite was not re-run after these commits. A new test intests/web_search/test_comparison.pypins the comparison renderer's escaping, including aNonelabel. It also passes on the old lambda, which shows the bytes are the same.0367a51d(the two non-timeout kill tests) and0e74faff(the architecture row), run at0e74faff: both lint commands pass.tests/test_review_runner.py,tests/test_documented_paths.py,tests/test_review_execution.py,tests/test_webmainbench_content_review.pyandtests/test_golden_reports.pygive 101 passed, with golden snapshots unchanged. Mutating theexcept BaseExceptionclause in_communicate, with each mutation reverted afterwards:except subprocess.TimeoutExpiredmakes both new tests fail (2 failed, 7 passed intests/test_review_runner.py), andexcept Exceptionmakes theKeyboardInterrupttest fail (1 failed, 8 passed). The full local suite was not re-run after these commits; CI on0e74faffis the full-suite result.