-
Notifications
You must be signed in to change notification settings - Fork 0
fix(browser): preserve late-failure teardown evidence #145
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
11
commits into
test/agent-task-process-set-termination-evidence
Choose a base branch
from
test/agent-task-failure-process-set-termination-evidence
base: test/agent-task-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
11 commits
Select commit
Hold shift + click to select a range
f65d1ba
test(browser): require failure process-set teardown evidence
seonghobae 69b43c0
fix(browser): preserve failure process-set teardown evidence
seonghobae 77baa95
test(browser): avoid dict-shape coupling in teardown contract
seonghobae dda9e4a
test(browser): require forced-close process termination evidence
seonghobae f2da8d8
fix(browser): verify forced-close process termination
seonghobae 5ee7684
docs: record forced-close process termination proof
seonghobae 312cd4a
chore(stack): absorb corrected process-set prerequisite
seonghobae 0dcd388
test(stack): rebase teardown evidence contract onto live process-set …
seonghobae 8f3b804
fix(browser): preserve exact teardown evidence on failure
seonghobae a1341e9
Merge remote-tracking branch 'origin/test/agent-task-process-set-term…
seonghobae bb5e8f8
fix(browser): adopt current process-set evidence parent
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
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
94 changes: 94 additions & 0 deletions
94
tests/test_agent_task_failure_process_set_termination_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,94 @@ | ||
| """Contract for Chromium process-set termination evidence after Agent Task failure.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import runpy | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskFailureProcessSetTerminationContractTests(unittest.TestCase): | ||
| """Retain sampled descendant teardown evidence when controlled browser work fails.""" | ||
|
|
||
| def _namespace(self, name: str) -> dict[str, object]: | ||
| return runpy.run_path(str(RUNNER), run_name=name) | ||
|
|
||
| def test_browser_pass_retains_sampled_process_set_teardown_after_failure(self) -> None: | ||
| """Late failure must not discard identities already captured before shutdown.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| start = runner.index("def _run_agent_task_browser_pass(") | ||
| end = runner.index("\ndef _run_agent_task_trial(", start) | ||
| browser_pass = runner[start:end] | ||
| for expected in ( | ||
| "if chromium_process_identities is not None:", | ||
| "chromium_process_set_terminated = _wait_for_linux_process_identity_set_exit(", | ||
| 'failure_evidence["chromium_process_set_terminated"]', | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, browser_pass) | ||
|
|
||
| def test_trial_preserves_failed_process_set_teardown_evidence(self) -> None: | ||
| """Profile cleanup must preserve both root and sampled-set termination outcomes.""" | ||
|
|
||
| namespace = self._namespace("agent_task_failure_process_set_termination_trial") | ||
| run_trial = namespace["_run_agent_task_trial"] | ||
|
|
||
| def fail_after_sampled_set_shutdown( | ||
| *_args: object, **_kwargs: object | ||
| ) -> dict[str, object]: | ||
| return { | ||
| "failure_type": "RuntimeError", | ||
| "browser_process_terminated": True, | ||
| "chromium_process_set_terminated": False, | ||
| } | ||
|
|
||
| run_trial.__globals__["_run_agent_task_browser_pass"] = ( | ||
| fail_after_sampled_set_shutdown | ||
| ) | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 13, | ||
| ) | ||
|
|
||
| self.assertEqual(result["trial_number"], 13) | ||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "RuntimeError") | ||
| self.assertIs(result["browser_process_terminated"], True) | ||
| self.assertIs(result["chromium_process_set_terminated"], False) | ||
| self.assertIs(result["profile_cleaned"], True) | ||
|
|
||
| def test_failure_before_process_set_capture_does_not_invent_set_evidence(self) -> None: | ||
| """A failure without sampled identities must remain explicit rather than fabricated.""" | ||
|
|
||
| namespace = self._namespace("agent_task_failure_before_process_set_capture") | ||
| run_trial = namespace["_run_agent_task_trial"] | ||
|
|
||
| def fail_before_process_set_capture( | ||
| *_args: object, **_kwargs: object | ||
| ) -> dict[str, object]: | ||
| return { | ||
| "failure_type": "RuntimeError", | ||
| "browser_process_terminated": True, | ||
| } | ||
|
|
||
| run_trial.__globals__["_run_agent_task_browser_pass"] = fail_before_process_set_capture | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 14, | ||
| ) | ||
|
|
||
| self.assertIs(result["passed"], False) | ||
| self.assertNotIn("chromium_process_set_terminated", result) | ||
| self.assertIs(result["profile_cleaned"], True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
84 changes: 84 additions & 0 deletions
84
tests/test_agent_task_forced_close_process_termination_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,84 @@ | ||
| """Contract for post-shutdown process termination in the Agent Task forced-close lane.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import runpy | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskForcedCloseProcessTerminationContractTests(unittest.TestCase): | ||
| """Require interruption evidence to include bounded Chromium teardown proof.""" | ||
|
|
||
| def test_forced_close_browser_pass_binds_and_waits_for_process_identities(self) -> None: | ||
| """The forced-close pass must prove its sampled browser process set terminates.""" | ||
|
|
||
| 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] | ||
| for expected in ( | ||
| 'capabilities.get("goog:processID")', | ||
| "_read_linux_proc_stat_process_identity", | ||
| "_snapshot_linux_process_evidence", | ||
| "_read_linux_process_identity_set", | ||
| "_wait_for_linux_process_identity_exit", | ||
| "_wait_for_linux_process_identity_set_exit", | ||
| '"browser_process_terminated"', | ||
| '"chromium_process_set_terminated"', | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, browser_pass) | ||
|
|
||
| def test_forced_close_trial_preserves_false_teardown_evidence(self) -> None: | ||
| """A failed teardown proof must not be omitted or normalized into success.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_process_termination_trial" | ||
| ) | ||
| 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 { | ||
| "browser_version": namespace["PINNED_CHROME_VERSION"], | ||
| "forced_close_detected": True, | ||
| "session_survived": True, | ||
| "browser_process_terminated": False, | ||
| "chromium_process_set_terminated": False, | ||
| } | ||
|
|
||
| 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", | ||
| 1, | ||
| ) | ||
| self.assertIs(result["browser_process_terminated"], False) | ||
| self.assertIs(result["chromium_process_set_terminated"], False) | ||
|
|
||
| def test_main_forced_close_gate_requires_process_termination(self) -> None: | ||
| """Compatibility success must reject a live forced-close browser identity.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| start = runner.index("forced_close_surfaces_complete = all(") | ||
| end = runner.index("\n\n evidence = {", start) | ||
| gate = runner[start:end] | ||
| for expected in ( | ||
| 'trial.get("browser_process_terminated") is True', | ||
| 'trial.get("chromium_process_set_terminated") is True', | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, gate) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.
Uh oh!
There was an error while loading. Please reload this page.