Skip to content

fix(trajectory-replay): close the local CDP port race and align Browser Use P95 - #140

Merged
lanyue-llk merged 6 commits into
mainfrom
fix/replay-port-browser-use-percentile-lexbench-summaries
Nov 3, 2026
Merged

lanyue-llk merged 6 commits into
mainfrom
fix/replay-port-browser-use-percentile-lexbench-summaries

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #94. This PR fixes the replay port race and the Browser Use percentile. It deliberately does not change the LexBench resource summaries (reasons below).

Still open in #94:

  • LexBench resource summaries: needs an owner decision and a re-summary (see below).
  • WCXB evidence rescore: carried over from fix(web-fetch): bound worker reaping and unify P50/P95 percentiles #127.
  • Port races outside replay: web_fetch/providers/headless.py::native_cdp_browser still reserves a port and then releases it. environments/webarena/backend.py::find_free_port has the same pattern, but nothing under src/ calls it. lexbench/resource_matrix.py calls the find_free_port of the frozen external runner.
  • Other percentile definitions: trajectory_replay/webarena_report.py::_catalog_percentile still interpolates linearly and is rendered as P95 in the catalog acceptance report. I did not check whether anything frozen for that report depends on the old value, so this PR leaves it alone.
  • Other suspected items: environments/webarena/har.py:420 still keys requests by id(request). webarena_replay.py still calls the private service._submit and still uses locals().get("readiness_retries", 0) at line 742. I only checked these by searching the code; this PR does not touch them.
    web_search/review.py (the job loop around validate_result) still has no try/finally, and its except covers only TimeoutExpired, ValueError and OSError, so any other exception type would skip the kill and active.pop. It looks unreachable through malformed result JSON, because validate_result runs a strict schema check first and four malformed payloads tried in review all raised ValueError. That is a limited check, not proof, so the item stays open. This PR does not change it.

Summary

Each of the three items was still present at the base commit.

Replay port race (fixed)

catalog_runner.py and remote_execution.py bound port 0, closed the socket and then started the browser. Another process could take the port in that window. _wait_cdp would then accept the other listener's 200, and the replay would drive the wrong browser.

Waiting for our browser to exit does not reliably expose this, as I found by running the pinned binaries on an occupied port:

Engine Behaviour when the port is taken
Lightpanda Logs a fatal "address already in use" but was still running after 3 s
Moli Exits after about 0.8 s, which is long after a foreign listener has answered
Obscura Exits after about 0.5 s, with the same problem

The new remote_execution.start_local_browser() passes port 0, so the browser binds its own port and there is no window. It then reads the port from the listening loopback sockets of that browser's own process tree. This works the same way for every engine, and Obscura logs no address when its output is not a terminal, so parsing logs would not have worked.

Effects of the change:

  • A catalog restart now gets a new port, so the catalog runner re-reads the endpoint for each task.
  • _stop_browser moved to remote_execution.py so both runners share it. The cohort runner's own teardown copy, which had an unbounded wait() after kill(), is gone.
  • psutil>=7,<8 joins the browser-use-eval extra. The lock already resolved 7.2.2 through crawl4ai, so only the lock's dependency metadata for this project changes.

Browser Use percentile (fixed)

browser_use/report.py::_percentile still interpolated linearly. The report now calls lexbench_webfetch.metrics.percentile.

Reported values that change. On the next rebuild, every P95 in the Browser Use summary moves to an observed value: Agent duration, BrowserTool duration, tokens and the resource metrics. All P50 and P95 values are also rounded to 2 decimals. For example, [1000, 3000] ms gives a P95 of 3000 instead of 2900. These summaries are recomputed from attempts.jsonl on every build and no check compares them with stored values, so no evidence changes.

Golden snapshots: no route hash changed, because the synthetic fixtures have too few samples for the two definitions to differ. I did not regenerate them.

For the next release: authored prose stored with the report assets is outside Git and was not available here. If it quotes a Browser Use P95, recheck it when the report is next rebuilt.

LexBench resource summaries (not changed)

resource_summary.py::stats and resource_evidence.py::validate_measurements still use statistics.quantiles(..., method="inclusive"). I left them alone because:

  1. Existing evidence would stop verifying. validate_measurements recomputes the P95 of the stored lexbench_moli_macos_fixed_resource_summary/1 files, and nothing in this repository produces those files. validate_summary does the same for linux-resource-profiles.json in a built site. With a new formula, both would reject existing artifacts as differing from the physical measurements.
  2. Changing only the Linux path would mix definitions in one table. The unified resource table in verification.py and app.js compares the four Linux builds with rows from the hash-bound version-resource-measurements.json, and it marks a single winner per column. Those frozen rows cannot be recomputed here, so they would keep their stored P95 next to nearest-rank values.

Decision needed: either keep the frozen definition and state it on the report, or re-summarize all of these artifacts under a new schema with a correction receipt that discloses the old and new values.

No LexBench evidence is available on this machine, so this reasoning comes from reading the code and was not tested against real artifacts.

Test plan

  • ruff check --config 'include=["*.py"]' --select F,TID252 . and ruff check both pass.
  • uv lock --check --offline passes with the hand-edited lock metadata.
  • Locally, on macOS with -n 2: tests/trajectory_replay, tests/browser_use, tests/test_golden_reports.py and the LexBench resource and report tests give 2392 passed, 5 skipped, no failures. Golden snapshots are unchanged. After the latest review fixes, rebased on current main, I reran tests/trajectory_replay, tests/browser_use and tests/test_golden_reports.py: 2351 passed, 5 skipped, golden snapshots unchanged.
  • This branch is not rebased on a26f6ede (build(packaging): bundle package data and move package gate to Python #135), which merged after the last push; this round made no code change. A test merge of the two is clean. On that merge, locally on macOS: tests/test_packaging_hygiene.py, tests/test_golden_reports.py, test_remote_execution_contracts.py and tests/browser_use/test_report.py give 138 passed. The full suite was not run on the merge.
  • New regression tests, each confirmed to fail when the old behaviour is restored temporarily:
    • test_remote_execution_contracts.py::test_local_browser_endpoint_cannot_be_taken_by_another_process starts a foreign CDP listener on any port requested before the spawn, then checks that the endpoint answers from the spawned process.
    • test_report.py::test_summary_percentiles_use_the_shared_nearest_rank_definition (the old code gives 2900.0).
    • test_remote_execution_contracts.py::test_local_browser_is_stopped_when_startup_is_interrupted checks that an interrupt during startup stops the browser. This came from review round 1.
    • test_uninspectable_child_does_not_hide_the_browser_listener and test_exiting_browser_that_denies_inspection_is_reported_as_exited cover a process that cannot be inspected, and fail on the previous scan. They came from review round 2 and from a Linux CI failure.
    • test_run_webarena_catalog.py::test_local_catalog_restart_replays_on_the_new_browser_endpoint drives the local catalog path through a poisoned runtime, an exited browser and a setup failure, and checks that the next task gets the new endpoint. All three cases fail if the first endpoint is kept. This came from the latest review.
    • test_remote_execution_contracts.py::test_cohort_teardown_never_waits_without_a_bound fails on the old teardown copy. This also came from the latest review.
  • test_local_browser_that_exits_before_binding_is_reported covers a browser that exits before it binds. It was not part of the old-behaviour check. On Linux CI this test failed once with psutil.AccessDenied on /proc/<pid>/fd, because the process was exiting during the scan. It passed on the earlier CI run, so that failure was timing-dependent. d19827f fixes the cause.
  • Manually on macOS, start_local_browser started Chromium, Moli, Lightpanda and Obscura from pinned binaries, and each webSocketDebuggerUrl carried the assigned port.
  • Not tested: a real browser on Linux. test_playwright_tool.py now uses the new launcher, but that test only runs on macOS, and the local run does not show whether it ran or was among the 5 skipped. The Linux CI browser job does not run it either. The regression tests above do run on Linux, using a stand-in server process.

@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 · 7135b96

This review found 1 issue(s), including 1 blocking issue(s).

Comment on lines +334 to +336
except Exception:
_stop_browser(process)
raise

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
P2: Clean up the spawned browser on interruption as well as ordinary startup failures. _execute_cohort now calls this helper before entering its try/finally, whereas previously _wait_cdp ran inside that cleanup scope. If Ctrl-C interrupts port discovery or readiness polling, KeyboardInterrupt bypasses this except Exception and the browser is left running (it was launched in a separate session). Catch BaseException for this cleanup-and-rethrow block, or otherwise guarantee cleanup until ownership is transferred to the caller.

Suggestion:

Suggested change
except Exception:
_stop_browser(process)
raise
except BaseException:
_stop_browser(process)
raise

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 follow-up: the P2 finding on interrupted startup is accepted and fixed in 594e6ab. start_local_browser() now stops the browser on any exception, including KeyboardInterrupt, before ownership passes to the caller. The new test test_local_browser_is_stopped_when_startup_is_interrupted fails with the old except clause and passes with the fix.

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

⚠️ Re-review complete · 594e6ab

This review found 1 issue(s), including 1 blocking issue(s).

Comment on lines +293 to +295
except psutil.NoSuchProcess:
# A process left the tree during this scan, so scan it again.
ports.clear()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
P2: Isolate exited/zombie descendants instead of discarding the entire scan. psutil.ZombieProcess subclasses NoSuchProcess; on platforms such as macOS, enumerating a retained zombie child's sockets can therefore enter this handler on every iteration. Even if the live browser's CDP listener was already found, ports.clear() discards it, and a healthy browser times out after 30 seconds. Catch these exceptions per descendant and continue scanning healthy members, while treating loss of the owner separately. Add a regression case with a healthy listener and a child whose socket enumeration repeatedly raises ZombieProcess.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2 follow-up: the P2 finding on zombie children is accepted and fixed in d19827f. Each process is now scanned separately, so one that cannot be inspected no longer hides a listener already found. The same commit fixes the Linux CI failure in test_local_browser_that_exits_before_binding_is_reported, where an exiting process raised psutil.AccessDenied on /proc//fd instead of the exit error. The new tests fail on the previous scan and pass on this commit.

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

✅ Re-review complete · d19827f

No findings in this incremental 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 d19827fb against base 27401304. There are no correctness defects in the port or percentile fixes. Two P2 findings and one P3 finding are below.

Findings

P2: src/harness/trajectory_replay/catalog_runner.py:747-751. The per-restart endpoint refresh has no regression test.
A restart now gets a new port, so start_browser must rebind endpoint. This is the one new failure mode the change adds to the catalog runner: a stale endpoint would point every later task at a dead port, or at another process that has since bound that port, which is the race this PR closes. The code is correct today. However, I mutated it to keep the first endpoint across restarts (endpoint = endpoint or fresh), and all of tests/trajectory_replay still passed (2056 passed, 5 skipped). The only test that calls catalog_runner.main() exits before the local browser starts.
Suggested fix: add a test that drives the local path with a fake start_local_browser returning a different endpoint per call and a fake _run_task. Force a restart through a dead process or a pre-evidence setup failure, then assert the next _run_task call receives the new endpoint.

P2: PR body, "Still open in #94". The remaining-work list omits two items that are still in the code.

  • src/harness/trajectory_replay/webarena_report.py:2239: _catalog_percentile still interpolates linearly. :2481 renders it as P95 in the catalog acceptance report (scripts/build_webarena_catalog_report.py, a supported make target). #94 says "Use the upstream definition everywhere", so another reader would conclude from this PR that Browser Use and the LexBench resource summaries were the last percentile outliers.
  • src/harness/trajectory_replay/webarena_replay.py:742: locals().get("readiness_retries", 0) is still there. The body names only the _submit half of that #94 suspected item.

Suggested fix: add both to the list. If you port _catalog_percentile instead, first check that nothing frozen for the catalog report depends on the old value. "Part of #94" remains the correct claim either way.

P3: src/harness/trajectory_replay/remote_execution.py:1196-1201. The cohort teardown still duplicates _stop_browser.
The PR body says _stop_browser moved so both runners share it, but _execute_cohort only reaches it through a failed startup. Its finally keeps a separate copy with a 5 s timeout and an unbounded process.wait() after kill(), the same pattern #94 lists elsewhere.
Suggested fix: replace the block with _stop_browser(process).

What I verified

  • Port race: both runners now pass port 0, and the port comes only from the browser's own process tree, so no reserve-and-release window remains in the replay paths. _execute_cohort and all catalog restart paths read the current endpoint. start_local_browser stops the browser on BaseException.
  • Multiple listeners: no test covers the branch, so I ran a stand-in process with two loopback listeners. It raises the "several loopback ports" error and the process is stopped.
  • Real browser: test_playwright_backend_executes_portable_and_snapshot_ref_calls ran and passed on this macOS machine, not skipped, so real Chromium works through the new launcher. This answers the question left open in the PR's "Not tested" note. Linux with a real browser is still untested. I did not independently run Moli, Lightpanda or Obscura; the only Moli build available here is not executable on this host.
  • Percentile: lexbench_webfetch.metrics.percentile keeps the median for P50 and uses nearest rank for P95, with 2-decimal rounding. The empty-list result is still None. The new test would fail on the old code, which gives 2900. Nothing outside browser_use/report.py reads these summary values, so the "no stored evidence changes" claim holds.
  • LexBench deferral: validate_measurements (resource_evidence.py:64) and validate_summary (resource_summary.py:257) both recompute the inclusive-method P95 and compare it with stored artifacts, so changing the formula would reject existing evidence. Deferring it for an owner decision is justified. The issue's wcxb_scoring.py and lexbench/report.py definitions already use the shared helper.
  • Dependency: psutil is in the same browser-use-eval extra as webarena-verified, which remote_execution.py already imports. The lock resolves 7.2.2 and its diff is metadata only.
  • Rule checks: no evidence, profile or receipt binds these source files by hash. Golden snapshots are unchanged. The configs/report-templates.json reference to browser_use/report.py is only a renderer path.
  • Local runs on this head: both ruff gates pass. test_golden_reports.py, test_remote_execution_contracts.py, test_remote_cohort_execution.py, browser_use/test_report.py and test_playwright_tool.py gave 158 passed.
  • CI on d19827fb: all checks pass, including "Tests and static checks" and "Installation and packaging".

@lanyue-llk
lanyue-llk force-pushed the fix/replay-port-browser-use-percentile-lexbench-summaries branch from d19827f to a9f91e7 Compare November 3, 2026 05:02
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review findings addressed on head a9f91e7. The branch is rebased on current main (52da9ca), so earlier SHAs changed.

Fixed

  • P2, no test for the per-restart endpoint refresh (a9b3a0c): test_local_catalog_restart_replays_on_the_new_browser_endpoint drives catalog_runner.main() on the local path through a poisoned runtime, an exited browser and a setup failure. It checks that the next _run_task call gets the new endpoint. With endpoint = endpoint or fresh restored temporarily, all three cases fail. No production code changed in this commit.
  • P2, incomplete remaining-work list (PR body): the body now lists _catalog_percentile and locals().get("readiness_retries", 0) at webarena_replay.py:742. I did not port _catalog_percentile, and I did not check whether anything frozen for the catalog report depends on the old value. The body says so.
  • P3, separate cohort teardown (a9f91e7): _execute_cohort now calls _stop_browser(process). test_cohort_teardown_never_waits_without_a_bound fails when the old block is restored. The Process stand-in in test_remote_cohort_execution.py gained a poll() method because the shared helper calls it.

Behaviour to note: _stop_browser raises TimeoutExpired if a killed browser still has not exited after its bounded wait. Inside the finally block, that exception replaces any error already in flight. The new test records this for a readiness failure. The catalog runner already behaves the same way.

Disputed: none.

Local checks: both ruff gates pass. tests/trajectory_replay, tests/browser_use and tests/test_golden_reports.py give 2351 passed, 5 skipped. Golden snapshots are unchanged.

@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 · a9f91e7

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 2

Reviewed head a9f91e72 against base 52da9caa. I found no correctness defects in the code or tests. There is one P3 finding, about the PR body.

Findings

P3: PR body, "Still open in #94" (code at src/harness/web_search/review.py:787-812). The list omits one item from #94. The issue's suspected web_search/review.py item is unchanged at this head: the block still has no try/finally, and except covers only TimeoutExpired, ValueError and OSError. So an exception of another type would skip active.pop.

The item may not be reachable through a malformed result. validate_result first runs a strict schema check, and the four malformed payloads I tried all raised ValueError. That is a limited check, not proof. The body currently gives no status for this item, although "Part of" requires listing what remains.

Suggested fix: add it to the "Other suspected items" list, with a note that it looks unreachable through result JSON but has not been changed. No code change is needed in this PR.

I checked every other unticked #94 item at this head. Each one is either fixed by the merged #124, #125 or #127, or already named in the PR body.

What I verified

  • Round 1 fixes: all three are present. _execute_cohort now calls _stop_browser, the body lists both added items, and the endpoint refresh test exists.
  • Regression tests, by temporary mutation:
    • Keeping the first endpoint across restarts fails all 3 cases of test_local_catalog_restart_replays_on_the_new_browser_endpoint.
    • Requesting a fixed port instead of port 0 fails test_local_browser_endpoint_cannot_be_taken_by_another_process, plus the interrupted-startup test.
    • Narrowing except BaseException to except Exception fails test_local_browser_is_stopped_when_startup_is_interrupted.
    • Restoring linear interpolation fails test_summary_percentiles_use_the_shared_nearest_rank_definition.
  • Real browsers on macOS: start_local_browser started Chromium, Moli, Lightpanda and Obscura, 3 times each on a reused profile directory. Each start got a new port, and each webSocketDebuggerUrl carried that port.
  • test_playwright_backend_executes_portable_and_snapshot_ref_calls: it ran and passed here. The body says it could not tell whether this test ran locally.
  • Endpoint handling: run_task reads endpoint from the closure when it runs, so setup recovery, an exited browser and a poisoned runtime all use the new endpoint.
  • Percentile swap: the report now calls the shared percentile. The median at 0.5 is unchanged, P95 is nearest rank, and results are rounded to 2 decimals. Empty input still returns None. No other code or check reads the summary P95 fields, and the rounding does not matter at the scale of these metrics.
  • Other percentile code: wcxb_scoring.py and lexbench/report.py already use the shared function. _catalog_percentile is the only remaining linear one, and it is already listed.
  • LexBench deferral: the first reason holds. validate_measurements and validate_summary recompute against stored values, and those artifacts are not available to re-summarize here. I did not trace the second reason (the mixed-definition table) through to rendered output. "Part of #94" is the correct claim.
  • Dependency: psutil sits in the same extra as webarena-verified, which remote_execution.py also imports at the top level. The lock resolves 7.2.2.
  • Local checks: both ruff gates pass. tests/test_golden_reports.py plus the remote execution, cohort, catalog and Browser Use report tests give 163 passed, with snapshots unchanged. I did not rerun the full suite locally.
  • Evidence: the diff touches no evidence, profiles or receipts.
  • CI at this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass.
  • Main has moved: main is now one commit ahead (#135). A trial merge has no conflicts, but CI has not run on that combination.

Not tested: a real browser on Linux, which the PR body already discloses.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2 follow-up on head a9f91e7. This finding needed only a PR body change, so there is no new commit.

Fixed

  • P3, web_search/review.py item missing from the remaining-work list: it is now under "Other suspected items" in the PR body. The note says the item looks unreachable through malformed result JSON, that this is not proven, and that this PR does not change the code.

Disputed: none.

Not rebased: main moved to a26f6ed (#135) after the last push. GitHub reports the PR as mergeable and clean, so I did not push a rebase. The test plan in the PR body gives the local result on a test merge.

@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

Reviewed head a9f91e72 against base 52da9caa. No defects were found, and there are no findings at any severity.

What I verified

  • Port race, startup: start_local_browser passes port 0 for all four engines and reads the port only from the spawned process tree. Nothing else in src/ or scripts/ calls _browser_command or _wait_cdp. Restoring reserve-then-release makes test_local_browser_endpoint_cannot_be_taken_by_another_process fail.
  • Port race, callers: the catalog runner reads endpoint when each task runs, so a retry or restart uses the new port. The cohort runner has no uses of endpoint before the assignment. _stop_browser differs from the old cohort teardown only in its longer bound (10 s instead of 5 s), its bounded wait() after kill() and its early return for an exited process.
  • Real browser: test_playwright_backend_executes_portable_and_snapshot_ref_calls ran against Chrome through the new launcher on macOS and passed. This settles the open question in the test plan for macOS. A real browser on Linux is still untested, as the PR body says.
  • Percentile: I compared lexbench_webfetch.metrics.percentile with the removed helper. Empty input still gives None. P50 stays the median, now rounded to 2 decimals. P95 changes to nearest rank, as the PR body says. _primary_summary output is consumed only inside browser_use/report.py, and I found no check there that compares it with stored values. Restoring linear interpolation makes test_summary_percentiles_use_the_shared_nearest_rank_definition fail.
  • Packaging: remote_execution.py already needed the browser-use-eval extra through webarena_verified, and only catalog_runner.py and scripts import it from outside tests. So the top-level import psutil adds no new import requirement.
  • Evidence and rules: nothing under evaluation/ names the changed source files by path, and the diff touches no evidence or profile. Commits carry no attribution lines, and the added lines contain no private paths or hostnames.
  • Scope claim: "Part of #94" is correct. I checked the deferred LexBench reasoning against the code: resource_summary.py::validate_summary and resource_evidence.py::validate_measurements both recompute P95 with the inclusive formula and compare it with stored values, so changing the formula would make existing artifacts fail. I confirmed the listed open port-race and percentile sites at this head, plus har.py:420 and webarena_replay.py:742. A pattern search of src/harness found no other linear percentile.

Test results

  • Lint: both ruff gates pass.
  • At this head, macOS, -n 2: tests/test_golden_reports.py, tests/trajectory_replay, tests/browser_use and the LexBench report, resource and verification tests give 2418 passed, 5 skipped. Golden snapshots are unchanged.
  • Merged with current main (a26f6ede): the merge is clean and uv lock --check --offline passes. tests/test_golden_reports.py, tests/test_packaging_hygiene.py, tests/trajectory_replay and tests/browser_use give 2386 passed, 5 skipped. I did not run the full suite on the merge.
  • CI at this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" all pass. GitHub reports the PR as mergeable and clean.

Not checked

  • I did not run the Moli, Lightpanda or Obscura binaries; the PR body's manual results for them are not reproduced here.
  • No real LexBench evidence is available here, so the deferred reasoning is confirmed from the code only.

lanyue-llk added a commit that referenced this pull request Nov 3, 2026
…ries

The Browser Use report interpolated P95 linearly while Web Fetch, WCXB and
the Lexbench call statistics use lexbench_webfetch.metrics.percentile. The
summary now calls the shared definition, so P95 is an observed value rounded
to 2 decimals. Summaries are recomputed from attempts on every build, so no
stored evidence changes.
Both replay runners reserved a port, released it and then started the
browser. Another process could take the port in that window. The readiness
probe would accept that listener and the replay would drive the wrong
browser, and Lightpanda stays alive after losing the bind so its exit could
not expose the conflict.

start_local_browser() now passes port 0 and reads the port from the listening
sockets of the browser's own process tree. This declares psutil, which the
lock already resolves, in the browser-use-eval extra. A restart gets a new
endpoint, so the catalog runner re-reads it for each task.
…upted

start_local_browser() runs before the caller's cleanup scope and the browser
has its own session, so an interrupt during port discovery or readiness
polling left it running. Clean up on any exception before ownership passes to
the caller.
…port

Linux denies /proc/<pid>/fd while a process exits, so a browser that exited
during the scan raised psutil.AccessDenied instead of the exit error. A child
that could not be inspected also discarded a listener already found, and a
retained zombie child could time out a healthy browser. Skip the process that
cannot be inspected and keep scanning; the poll still reports the owner's exit.
@lanyue-llk
lanyue-llk force-pushed the fix/replay-port-browser-use-percentile-lexbench-summaries branch from a9f91e7 to 74d6173 Compare November 3, 2026 06:49

@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 · 74d6173

No findings in this review.

@lanyue-llk
lanyue-llk merged commit b02de7a into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the fix/replay-port-browser-use-percentile-lexbench-summaries branch November 3, 2026 07:10
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.

Fix confirmed runtime bugs found in the codebase audit

1 participant