fix: lazy-load CLI execution helpers#340
Open
honor2030 wants to merge 1 commit into
Open
Conversation
e59a2b1 to
4a38ed6
Compare
4a38ed6 to
3f7116d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
browser_harness.helpersonly when executingbrowser-harness -c ...--versionand--helpfrom importing user-editableBH_AGENT_WORKSPACE/agent_helpers.py-chelper availability, including agent workspace helpers, via a dedicated execution namespaceRoot cause
run.pyimportedfrom .helpers import *at module import time. Sincehelpers.pyimmediately loadsBH_AGENT_WORKSPACE/agent_helpers.py, even safe maintenance commands could fail or trigger user helper side effects beforemain()handled--version/--help.Test Plan
uv run --with pytest --with-editable . python -m pytest tests/unit/test_run.py::test_maintenance_commands_do_not_load_agent_helpers tests/unit/test_run.py::test_execution_globals_load_agent_workspace_helpers -qfailed before the fix because--versionloaded the raisingagent_helpers.pyand_execution_globalsdid not exist.uv run --with pytest --with-editable . python -m pytest tests/unit/test_run.py::test_maintenance_commands_do_not_load_agent_helpers tests/unit/test_run.py::test_execution_globals_load_agent_workspace_helpers -q→2 passeduv run --with pytest --with-editable . python -m pytest tests/unit/test_run.py -q→14 passeduv run --with pytest --with-editable . python -m pytest tests -q→96 passeduv run --with-editable . python -m compileall -q src testsuv run --with pip --with-editable . python -m pip check→No broken requirements found.uv run --with pip-audit --with-editable . pip-audit→No known vulnerabilities found(local package skipped because it is not on PyPI)uv run --with ruff --with-editable . ruff check --select B src/browser_harness/run.py tests/unit/test_run.py→All checks passed!Summary by cubic
Lazy-load CLI helpers so
--helpand--versionrun without importing user workspace code. Scripts run via stdin or-cstill get access tobrowser_harness.helpersand workspace helpers._execution_globals()only during code execution.BH_AGENT_WORKSPACE/agent_helpers.py.browser_harness.helpers.Written for commit 3f7116d. Summary will update on new commits.