-
Notifications
You must be signed in to change notification settings - Fork 0
feat(browser): retain cleanup evidence for failed Agent Tasks #139
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
13
commits into
test/agent-task-pristine-profile-admission
Choose a base branch
from
test/agent-task-failure-cleanup-evidence
base: test/agent-task-pristine-profile-admission
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
13 commits
Select commit
Hold shift + click to select a range
6a0c4c9
test(browser): require failed Agent Task cleanup evidence
seonghobae 519faff
merge: align failed-cleanup test with pristine-profile base
seonghobae 7e1db77
test(browser): align cleanup RED with current pristine-profile contract
seonghobae c6c491f
fix(browser): retain Agent Task cleanup evidence on failure
seonghobae 56ed81c
merge: align failed-cleanup implementation with current profile base
seonghobae b6583d5
test(browser): require forced-close failure cleanup evidence
seonghobae 4b47426
fix(browser): retain forced-close cleanup evidence on failure
seonghobae 499a649
docs(changelog): record failed Agent Task cleanup evidence
seonghobae e41d27a
docs: inherit browser stack release notes
seonghobae 1a6c27c
merge: align pristine profile prerequisite
seonghobae 0e66b24
test(browser): reproduce teardown timeout cleanup gap
seonghobae 10a60f5
fix(browser): retain teardown timeout failure evidence
seonghobae b7ea5bf
fix(browser): preserve inherited documentation contracts
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
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,132 @@ | ||
| """Contract for Agent Task profile cleanup evidence on failed browser trials.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import runpy | ||
| import subprocess | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskFailureCleanupContractTests(unittest.TestCase): | ||
| """Require failed trials to retain credential-free teardown evidence.""" | ||
|
|
||
| def _namespace(self, name: str) -> dict[str, object]: | ||
| return runpy.run_path(str(RUNNER), run_name=name) | ||
|
|
||
| def test_failed_browser_pass_returns_profile_cleanup_evidence(self) -> None: | ||
| """A browser-pass failure must not discard proof that its task profile was removed.""" | ||
|
|
||
| namespace = self._namespace("agent_task_failure_cleanup_behavior") | ||
| run_trial = namespace["_run_agent_task_trial"] | ||
|
|
||
| def fail_browser_pass(*_args: object, **_kwargs: object) -> dict[str, object]: | ||
| raise RuntimeError("synthetic controlled browser failure") | ||
|
|
||
| run_trial.__globals__["_run_agent_task_browser_pass"] = fail_browser_pass | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 7, | ||
| ) | ||
|
|
||
| self.assertEqual(result["trial_number"], 7) | ||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "RuntimeError") | ||
| self.assertIs(result["profile_cleaned"], True) | ||
| self.assertNotIn("synthetic controlled browser failure", repr(result)) | ||
|
|
||
| def test_teardown_timeout_returns_profile_cleanup_evidence(self) -> None: | ||
| """A reviewed process teardown timeout must become one failed trial, not abort the run.""" | ||
|
|
||
| namespace = self._namespace("agent_task_teardown_timeout_cleanup_behavior") | ||
| run_trial = namespace["_run_agent_task_trial"] | ||
|
|
||
| def timeout_browser_pass(*_args: object, **_kwargs: object) -> dict[str, object]: | ||
| raise subprocess.TimeoutExpired( | ||
| cmd="private-controlled-chromedriver-path", | ||
| timeout=5, | ||
| ) | ||
|
|
||
| run_trial.__globals__["_run_agent_task_browser_pass"] = timeout_browser_pass | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 8, | ||
| ) | ||
|
|
||
| self.assertEqual(result["trial_number"], 8) | ||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "TimeoutExpired") | ||
| self.assertIs(result["profile_cleaned"], True) | ||
| self.assertNotIn("private-controlled-chromedriver-path", repr(result)) | ||
|
|
||
| def test_failed_forced_close_pass_returns_profile_cleanup_evidence(self) -> None: | ||
| """A forced-close probe failure must still prove that its task profile was removed.""" | ||
|
|
||
| namespace = self._namespace("agent_task_forced_close_cleanup_behavior") | ||
| run_trial = namespace["_run_agent_task_forced_close_trial"] | ||
|
|
||
| def fail_browser_pass(*_args: object, **_kwargs: object) -> dict[str, object]: | ||
| raise RuntimeError("synthetic forced-close browser failure") | ||
|
|
||
| run_trial.__globals__["_run_agent_task_forced_close_browser_pass"] = fail_browser_pass | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 9, | ||
| ) | ||
|
|
||
| self.assertEqual(result["trial_number"], 9) | ||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "RuntimeError") | ||
| self.assertIs(result["profile_cleaned"], True) | ||
| self.assertNotIn("synthetic forced-close browser failure", repr(result)) | ||
|
|
||
| def test_forced_close_teardown_timeout_returns_profile_cleanup_evidence(self) -> None: | ||
| """Forced-close teardown timeout must retain cleanup evidence without raw command text.""" | ||
|
|
||
| namespace = self._namespace("agent_task_forced_close_teardown_timeout_behavior") | ||
| run_trial = namespace["_run_agent_task_forced_close_trial"] | ||
|
|
||
| def timeout_browser_pass(*_args: object, **_kwargs: object) -> dict[str, object]: | ||
| raise subprocess.TimeoutExpired( | ||
| cmd="private-forced-close-chromedriver-path", | ||
| timeout=5, | ||
| ) | ||
|
|
||
| run_trial.__globals__["_run_agent_task_forced_close_browser_pass"] = timeout_browser_pass | ||
| result = run_trial( | ||
| pathlib.Path("controlled-chrome"), | ||
| pathlib.Path("controlled-chromedriver"), | ||
| "http://127.0.0.1/controlled-fixture", | ||
| 10, | ||
| ) | ||
|
|
||
| self.assertEqual(result["trial_number"], 10) | ||
| self.assertIs(result["passed"], False) | ||
| self.assertEqual(result["failure_type"], "TimeoutExpired") | ||
| self.assertIs(result["profile_cleaned"], True) | ||
| self.assertNotIn("private-forced-close-chromedriver-path", repr(result)) | ||
|
|
||
| def test_acceptance_gate_requires_cleanup_evidence_for_every_trial(self) -> None: | ||
| """Failed trials must not be filtered out of either profile-cleanup gate.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| self.assertIn("agent_task_profiles_cleaned = all(", runner) | ||
| self.assertIn("forced_close_profiles_cleaned = all(", runner) | ||
| self.assertIn('trial.get("profile_cleaned") is True', runner) | ||
| self.assertIn('"profiles_cleaned": agent_task_profiles_cleaned', runner) | ||
| self.assertIn('"profiles_cleaned": forced_close_profiles_cleaned', runner) | ||
| self.assertIn("Agent Task profile cleanup gate failed", runner) | ||
| self.assertIn("Agent Task forced-close profile cleanup gate failed", runner) | ||
|
|
||
|
|
||
| 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.