-
Notifications
You must be signed in to change notification settings - Fork 0
fix(browser): retain forced-close teardown evidence on failure #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
33
commits into
test/agent-task-failure-process-set-termination-evidence
Choose a base branch
from
test/agent-task-forced-close-failure-teardown-evidence
base: test/agent-task-failure-process-set-termination-evidence
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b4c1aa7
test(browser): require forced-close failure teardown evidence
seonghobae fbada6a
Merge current forced-close teardown prerequisite
seonghobae e0737d6
fix(browser): retain forced-close failure teardown proof
seonghobae 36f6d6f
chore(stack): absorb corrected late-failure prerequisite
seonghobae 171f365
test(browser): prevent state diagnostic reflection
seonghobae 830be53
fix(mv3): redact agent task state failures
seonghobae 371ce49
test(mv3): expose wedged driver teardown escape
seonghobae 7f7a4ec
fix(mv3): bound forced-close driver teardown failures
seonghobae 7e4a867
test(mv3): require bounded driver teardown evidence
seonghobae 1731883
test(browser): require kill fallback evidence
seonghobae c3291dc
fix(browser): retain kill fallback evidence
seonghobae ae0789b
test(browser): preserve kill fallback evidence
seonghobae cb2b887
test(browser): expose forced-close session cleanup loss
seonghobae dab7248
fix(browser): retain forced-close session cleanup failures
seonghobae 5887d66
test(browser): decouple teardown ordering contract from condition for…
seonghobae 0cafe07
test(browser): accept multiline bounded session cleanup call
seonghobae 27a3761
test(stack): restack forced-close failure contracts on live teardown …
seonghobae 7a7923e
fix(browser): restore typed forced-close cleanup envelope
seonghobae 52bd685
fix(browser): preserve parent teardown contracts after restack
seonghobae 152ca36
test(mv3): reject untyped cleanup suppression
seonghobae b0aabe0
fix(mv3): preserve typed cleanup failures
seonghobae a1ed848
test(mv3): preserve primary failure precedence contract
seonghobae 618fee1
test(mv3): retain WebDriver HTTP cleanup failures
seonghobae d4cf106
fix(mv3): classify WebDriver HTTP cleanup failures
seonghobae 4749131
test(mv3): retry transient startup HTTP protocol failure
seonghobae fb5a9c3
fix(mv3): retry malformed startup status line
seonghobae 3f77c75
test(browser): fail closed on terminal startup errors
seonghobae 5bc6044
fix(browser): keep terminal startup errors fail closed
seonghobae 34ab98e
docs(browser): restore generic WebDriver path contract
seonghobae f96e55f
test(browser): reproduce truncated startup response
seonghobae 86b174b
fix(browser): retry truncated startup responses
seonghobae a3df28d
test(browser): reject WebDriver response detail leakage
seonghobae 48435b9
fix(browser): redact WebDriver response diagnostics
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
120 changes: 120 additions & 0 deletions
120
tests/test_agent_task_forced_close_session_cleanup_contract.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| """Contract for truthful WebDriver session cleanup in the forced-close Agent Task lane.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import pathlib | ||
| import runpy | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskForcedCloseSessionCleanupContractTests(unittest.TestCase): | ||
| """Require reviewed session-delete failures to remain explicit failure evidence.""" | ||
|
|
||
| def test_session_delete_helper_is_bounded_typed_and_source_free(self) -> None: | ||
| """A reviewed WebDriver cleanup failure must return only its stable exception type.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_session_cleanup_contract" | ||
| ) | ||
| cleanup = namespace["_delete_webdriver_session_bounded"] | ||
| original_request = cleanup.__globals__["_json_request"] | ||
| calls: list[tuple[int, str, str, dict[str, object]]] = [] | ||
|
|
||
| def successful_request( | ||
| driver_port: int, | ||
| method: str, | ||
| path: str, | ||
| payload: dict[str, object], | ||
| ) -> dict[str, object]: | ||
| calls.append((driver_port, method, path, payload)) | ||
| return {"value": None} | ||
|
|
||
| cleanup.__globals__["_json_request"] = successful_request | ||
| try: | ||
| self.assertIsNone(cleanup(9515, "session-1")) | ||
| finally: | ||
| cleanup.__globals__["_json_request"] = original_request | ||
| self.assertEqual(calls, [(9515, "DELETE", "/session/session-1", {})]) | ||
|
|
||
| for exception in ( | ||
| OSError("raw-io-detail"), | ||
| ValueError("raw-value-detail"), | ||
| RuntimeError("raw-runtime-detail"), | ||
| json.JSONDecodeError("raw-json-detail", "x", 0), | ||
| ): | ||
| with self.subTest(exception_type=type(exception).__name__): | ||
| def failing_request(*_args: object, **_kwargs: object) -> dict[str, object]: | ||
| raise exception | ||
|
|
||
| cleanup.__globals__["_json_request"] = failing_request | ||
| try: | ||
| failure_type = cleanup(9515, "session-1") | ||
| finally: | ||
| cleanup.__globals__["_json_request"] = original_request | ||
| self.assertEqual(failure_type, type(exception).__name__) | ||
| self.assertNotIn("raw-", failure_type) | ||
|
|
||
| def test_forced_close_pass_does_not_suppress_session_cleanup_failure(self) -> None: | ||
| """The forced-close failure envelope must consume typed session cleanup evidence.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| start = runner.index("def _run_agent_task_forced_close_browser_pass(") | ||
| end = runner.index("\ndef _run_agent_task_forced_close_trial(", start) | ||
| browser_pass = runner[start:end] | ||
|
|
||
| self.assertNotIn("contextlib.suppress(Exception)", browser_pass) | ||
| self.assertIn("session_cleanup_failure_type", browser_pass) | ||
| cleanup_call = browser_pass.index("_delete_webdriver_session_bounded(") | ||
| self.assertIn("driver_port, session_id", browser_pass[cleanup_call:cleanup_call + 160]) | ||
| self.assertIn('"session_cleanup_failure_type"', browser_pass) | ||
| self.assertIn('"WebDriverSessionCleanupError"', browser_pass) | ||
|
|
||
| def test_trial_preserves_session_cleanup_failure_separately_from_driver_cleanup(self) -> None: | ||
| """Browser, session-delete, and driver-process failures must remain distinguishable.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_session_cleanup_trial_contract" | ||
| ) | ||
| trial = namespace["_run_agent_task_forced_close_trial"] | ||
|
|
||
| def fake_browser_pass( | ||
| _chrome_bin: pathlib.Path, | ||
| _chromedriver_bin: pathlib.Path, | ||
| _fixture_url: str, | ||
| _profile_dir: str, | ||
| ) -> dict[str, object]: | ||
| return { | ||
| "failure_type": "RuntimeError", | ||
| "session_cleanup_failure_type": "OSError", | ||
| "cleanup_failure_type": "TimeoutExpired", | ||
| "driver_process_terminated": False, | ||
| "driver_kill_fallback_used": True, | ||
| "browser_process_terminated": True, | ||
| "chromium_process_set_terminated": True, | ||
| } | ||
|
|
||
| trial.__globals__["_run_agent_task_forced_close_browser_pass"] = fake_browser_pass | ||
| result = trial( | ||
| pathlib.Path("/unused/chrome"), | ||
| pathlib.Path("/unused/chromedriver"), | ||
| "http://127.0.0.1/fixture", | ||
| 4, | ||
| ) | ||
|
|
||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "RuntimeError") | ||
| self.assertEqual(result["session_cleanup_failure_type"], "OSError") | ||
| self.assertEqual(result["cleanup_failure_type"], "TimeoutExpired") | ||
| self.assertIs(result["driver_process_terminated"], False) | ||
| self.assertIs(result["driver_kill_fallback_used"], True) | ||
| self.assertIs(result["browser_process_terminated"], True) | ||
| self.assertIs(result["chromium_process_set_terminated"], True) | ||
| self.assertIs(result["profile_cleaned"], True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Dead no-such-window HTTP branch after redaction
_is_no_such_window_runtime_errorstill parses aWebDriver HTTP 404: <json>message, but_json_requestno longer emits that shape: no-such-window now raises the redactedWebDriver error:string and other HTTP errors raiseWebDriver HTTP {status}with no detail. The HTTP-prefix branch is now unreachable; detection still works via the direct-prefix branch.(Refers to this code)
Was this helpful? React with 👍 or 👎 to provide feedback.