Repository navigation
refactor(reporting): share one publication client across track publishers - #144
Conversation
…hers Move request, response_json, multipart_archive and receipt writing into harness/reporting/publication.py. Web Fetch, WCXB, Browser Use and Browser Trajectory Replay select their User-Agent, timeouts, header order and HTTP failure handling through a PublicationClient value, so their requests stay byte-identical.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head 643d1460 against base b02de7ad. One finding (P2). I found no behavioural regression.
Findings
P2: the committed tests pin the client values, not the adapters' use of them (tests/test_reporting_publish_client.py:40, wiring at src/harness/web_fetch/wcxb_publication.py:146, src/harness/web_fetch/report_publish.py:153, src/harness/web_fetch/report_publish.py:366, src/harness/browser_use/report_publish.py:103, src/harness/trajectory_replay/webarena_report_publish.py:102)
The new test file calls web_fetch.CLIENT.request(...) and the other client constants directly. The Web Fetch and WCXB publish tests pass transport=, which bypasses the client, or (rename) check only the URL and receipt. The PR's wire comparison, which is what proves byte equality, is a local script that was not committed, so nothing guards these lines after merge.
I mutated each line below and ran 12 publication test files (255 tests: test_reporting_*, test_wcxb_publication, test_webfetch_report_publish, test_webarena_publish, web_search/test_publication, browser_use/test_publish, test_published_snapshot_report, public_webarena/test_trajectory_release). All 255 still passed for every mutation except the last row:
| Mutation | Effect on a real publish | Result |
|---|---|---|
WCXB: drop authenticated=auth |
Bearer credential sent on the anonymous share check | all pass |
WCXB: drop extra_headers=extra_headers |
No Idempotency-Key on start and commit |
all pass |
Web Fetch send: drop extra_headers |
No Idempotency-Key on package submission |
all pass |
Web Fetch send: use RENAME_CLIENT |
No User-Agent, 30 s timeout | all pass |
Web Fetch rename: use CLIENT |
Adds a User-Agent, wrong client | all pass |
Browser Use request: use PUBLIC_CLIENT |
HTTP failures raised instead of returned, 60 s timeout | all pass |
Browser Use share check: use CLIENT |
HTTP failures returned, 240 s timeout | all pass |
Replay request: drop authenticated=authenticated |
Credential sent on public share requests | all pass |
Browser Use share check: drop authenticated=False |
Credential loaded | 8 fail (caught) |
The credential and idempotency rows matter most. A later edit could send a token to a public route, or lose retry safety, with CI green.
Suggested fix: add one committed test that goes through each adapter's real path with urllib.request.urlopen faked and asserts ordered headers and timeout:
browser_use.requestandreplay.request, includingauthenticated=False.web_fetch.publish(config)withouttransport, in single-request and staged modes.wcxb.publish(...)withouttransport, including the/v/public-tokenrequest.rename_main.
The existing Service and Site fakes work for this behind a small urlopen adapter. I drove them that way for the comparison below, so it needs no new fake site.
What I verified
-
Wire comparison: I wrote my own script and ran it on an archive of
b02de7adand on this head withurlopenfaked. It covered the following:- WCXB full publish, including the public share and PATCH.
- Web Fetch create and update, both single-request and staged.
- Browser Use and Replay
request, including the 429 path, multipart bodies, package tree digests (withassets/xnext toassets.jsonto exercise sort order) and receipts.
Method, URL, ordered headers, body hash and timeout match. The only difference is PUT order in one staged update run, which comes from the existing
max_workers=4thread pool, not this change. -
By reading only: the Browser Use share and preview checks, the Replay public requests and
rename_main. I did not run these through the comparison. -
Exception type change: there is no
except ValueErrororJSONDecodeErroraroundresponse_jsonin the publishers or CLI entry points, so the PR's claim holds. Theexcept ValueErrorblocks inweb_fetch/publication.pyhandleRetry-Afterparsing only. -
Nested receipt secrets: no code reads a
tokenfield back from a saved receipt. -
Hash-bound sources: no edited file appears in
producer_sourcesorchecker_sources, or by name underevaluation/,configs/,research/or.agents/. -
Duplicates: there is no other
response_json, multipart oreditTokenreceipt implementation in the publish stack.web_search/publication.pyandpublic_webarena/publication.pyhave no HTTP client, as the PR says. -
Scope: "Part of #102" is accurate, and the remaining list covers the runner, release-check base,
esc(), HAR recorder and orchestration. -
Local checks: both ruff gates pass.
tests/test_golden_reports.pyand the publication tests gave 238 passed. I did not run the full suite locally. -
CI on
643d1460: all checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".
Drive browser_use.request, replay.request, every track's publish flow and rename_main with only urlopen faked, and assert the ordered headers, URL and timeout of each physical request. The expected requests also pass against the implementations these adapters replaced.
|
Review round 1: fixed in 79d4dcc. Nothing disputed. P2, adapter wire behaviour was not pinned.
Checks
This commit changes one test file and no source, so rendered output and hash-bound source lists are unaffected. |
There was a problem hiding this comment.
ℹ️ Review skipped · 79d4dcc
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 79d4dcc5 against base b02de7ad. No defects found.
What I verified
Round 1 finding. It is fixed.
- I ran the 8 new real-path tests against the
b02de7adpublish code, in a throwaway checkout with only the credential stub redirected to the old modules. All 8 pass, so they pin the old wire behaviour and not just the new code. - I reapplied six single mutations on this head, and the new test file fails on each:
- dropping
authenticated=authin WCXB - dropping
authenticated=authenticatedin Replay - using the wrong client in Web Fetch rename
- using the wrong client in the Browser Use share check
- changing the Replay PUT timeout
- keeping nested
tokenvalues in receipts
- dropping
Old and new semantics, read from the diff.
- Requests: User-Agent, header order,
Content-Typeand extra-header order, timeouts and PUT overrides, and raised versus returned HTTP failures all match for each track, including the urllib default User-Agent on rename. - WCXB: fake transports still get no credential, and the real path sends none on public requests.
- Multipart: boundary seeds, prefixes, filenames and body layout match.
- Tree digests:
reporting/visual.pyuses the same sort and serialization as both removedreport_package.pycopies. The only difference is the symlink rejection the PR discloses, andpackage_archivealready rejected symlinks on the same report tree. - Receipts: nothing in
src/harnessreads a nestedtoken,editTokenorclaimTokenfrom a receipt, so dropping them at every depth is safe. response_json: no publish path catchesValueErrororJSONDecodeErroraround it, so the newRuntimeErrorchanges no control flow.
Removed code and duplicates.
- No references remain to
request_timeout,_safe_receiptor the per-moduleload_tokenpatches. - The only remaining Artifact Site HTTP calls outside the shared client are in
publication_verify.py, which the PR discloses, andartifact_auth.py, which handles authorization. - There is no other copy of the multipart,
response_jsonor receipt-writing helpers.reporting/visual.pyhas a same-namedwrite_receipt; that file is bound and was not edited.
Hash-bound sources.
checker_sourcesandproducer_sourcesbind only the visual modules,web_search/pages.pyandreporting/visual.py, and none of those are edited.- A search of
src,scripts,evaluation,configs,docsand.agentsfinds no binding of an edited module. - No evidence, profile or receipt file is changed.
Scope. "Part of #102" is accurate. The remaining list covers the shared publish() owner, reviewer runner, release-check base, esc() and HAR recorder. The PR adds none of these.
Local runs.
- Both ruff gates pass.
- 215 tests passed across the new test file,
tests/test_golden_reports.py, the upload and recovery tests, the WCXB, Web Fetch and Replay publish tests, the Web Search publication tests, the public WebArena release tests and the published-snapshot report tests. - Golden snapshots are unchanged.
- I did not run the full suite locally, and no real site was contacted.
CI on 79d4dcc5. All checks pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".
Note, not a defect. The PR body's local test counts (442 passed, and the full-suite totals) don't mention the 8 tests added in 79d4dcc5. That commit changes only the test file, and CI covers it.
Issues
Closes #102. This is the first step only: the shared publication HTTP client and archive helpers.
Remaining work, moved to #156:
web_fetch/report_publish.publish) into a shared owner. Track flows stay track-owned here; only their HTTP, multipart, decoding and receipt code moved.esc()helper.Also not changed:
web_fetch/publication_verify.py, the read-only verifier, keeps its ownurlopencalls. It is not one of the publish modules the issue lists.Summary
harness/reporting/publication.py, the existing owner of the shared publication primitives, now also owns:PublicationClient: the request and its headers. User-Agent, timeouts, header order and HTTP failure handling are data.response_jsonmultipart_archivewrite_receiptEach publisher declares only what is specific to it:
WebFetch-Report-Publisher/1.0WCXB-Report-Publisher/1.0Browser-Use-Report-Publisher/1.0Trajectory-Replay-Artifact-Site-Publisher/1.0Multipart boundary seeds, prefixes and filenames stay per track, so a retried in-flight operation replays the same bytes.
Corrections to the issue, checked against the current code:
web_search/publication.pyandpublic_webarena/publication.pyhave no HTTP client. They already adaptweb_fetch/report_publish.publish, so there were four clients to swap, not six.tree_sha256already has one implementation, inreporting/visual.py. It stays there because that file is a bound source (see below). The two copies in thereport_package.pymodules are removed in favour of the framing wrapper each track's publisher already has.Behaviour changes
Requests are unchanged. These differences remain:
token,editTokenandclaimTokenat every depth, as Web Fetch already did. They previously dropped them at the top level only.response_jsonwording and types: there is now one version, the Browser Use one.RuntimeErrorinstead ofValueErrororJSONDecodeErroron malformed or non-object JSON, and include up to 500 characters of the response body on a non-2xx status.report_package.pymodules now goes through the sharedtree_sha256, which rejects symlinks. Digest bytes are unchanged for a tree without symlinks.Hash-bound sources
No bound file is edited:
reporting/visual.py,browser_use/report_visual.py,trajectory_replay/webarena_report_visual.py,web_search/visual.pyandweb_search/pages.py(thechecker_sourcesand visual source bindings) are untouched.docs/architecture.md, so no profile or binding names them.Test plan
Wire comparison (local script, not committed): I drove the publish flows against a fake site on both an untouched
b02de7adarchive and this branch. Flows covered:All 76 requests match on method, URL, ordered headers, body hash and timeout. Saved receipts and journals match too, except for the nested
tokenremoval above. No real site was contacted.New test file:
tests/test_reporting_publish_client.pypins per-track headers and timeouts, failure handling, exact multipart bodies, receipts and tree digests. Boundary and digest values were computed from theb02de7adcode.Existing tests: only fixtures changed. Fake transports stay;
load_tokenandatomic_writepatches now target the shared owner, and fake responses gainedheaders. Replay's timeout test now readsCLIENT.timeout_for, and itsresponse_jsontest uses the shared wording.Lint: both ruff gates pass.
Publish and golden tests: the publish, reporting and CLI scope targets plus
tests/test_golden_reports.pygave 442 passed in the worktree.Full local suite on an archive of this branch: 29 failed, 19238 passed, 60 skipped.
b02de7adarchive. The comparison covers every failing test file, run on both archives.test_moli_provider.py::test_zero_exit_empty_markdown_is_an_empty_response, failed once under the full run and passed on its own on both archives.Local caveats:
-o pythonpath='src .'rather than aPYTHONPATHenvironment variable, so subprocess tests can import a different checkout. That explains local failures such as a missingharness.web_search.cli.CI: Linux CI is the full-suite gate for this PR.