-
Notifications
You must be signed in to change notification settings - Fork 0
fix(browser): bound forced-close teardown to one deadline #147
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
10
commits into
test/agent-task-forced-close-failure-teardown-evidence
Choose a base branch
from
test/agent-task-forced-close-shared-teardown-deadline
base: test/agent-task-forced-close-failure-teardown-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
10 commits
Select commit
Hold shift + click to select a range
2abcfac
test(browser): require shared forced-close teardown deadline
seonghobae 9b52c53
fix(browser): share forced-close teardown deadline
seonghobae edc5ba5
test(browser): align forced-close teardown contract
seonghobae c876a44
docs(browser): record shared teardown deadline
seonghobae 4ab438b
chore(stack): absorb corrected forced-close prerequisite
seonghobae 9891711
test(browser): reproduce shared teardown deadline on current parent
seonghobae 308dbe8
fix(browser): share forced-close teardown deadline
seonghobae 11ed14a
chore(stack): realign shared teardown deadline on current parent
seonghobae 53a9292
test(browser): reproduce shared teardown deadline on live base
seonghobae 962e179
fix(browser): reconcile shared teardown with live base hardening
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
90 changes: 90 additions & 0 deletions
90
tests/test_agent_task_forced_close_shared_teardown_deadline_contract.py
|
devin-ai-integration[bot] marked this conversation as resolved.
|
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,90 @@ | ||
| """Contract for one total post-shutdown teardown deadline in the 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 AgentTaskForcedCloseSharedTeardownDeadlineContractTests(unittest.TestCase): | ||
| """Prevent root and process-set teardown polling from multiplying the budget.""" | ||
|
|
||
| def test_runner_exposes_one_combined_teardown_waiter(self) -> None: | ||
| """Root and sampled-set evidence must be observed under one timeout authority.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_shared_teardown_deadline" | ||
| ) | ||
| self.assertIn("_wait_for_linux_process_teardown", namespace) | ||
|
|
||
| def test_combined_waiter_preserves_partial_evidence_at_one_deadline(self) -> None: | ||
| """A root may exit while a descendant remains live when the one deadline expires.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_shared_teardown_behavior" | ||
| ) | ||
| waiter = namespace["_wait_for_linux_process_teardown"] | ||
|
|
||
| class FakeTime: | ||
| def __init__(self) -> None: | ||
| self.now = 0.0 | ||
|
|
||
| def monotonic(self) -> float: | ||
| return self.now | ||
|
|
||
| def sleep(self, seconds: float) -> None: | ||
| self.now += seconds | ||
|
|
||
| fake_time = FakeTime() | ||
| root_identity = (101, 1_001) | ||
| child_identity = (202, 2_002) | ||
|
|
||
| def fake_read(process_id: int) -> tuple[int, int] | None: | ||
| if process_id == root_identity[0]: | ||
| return None if fake_time.now >= 0.05 else root_identity | ||
| if process_id == child_identity[0]: | ||
| return child_identity | ||
| raise AssertionError(f"unexpected process id: {process_id}") | ||
|
|
||
| waiter.__globals__["time"] = fake_time | ||
| waiter.__globals__["_read_linux_proc_stat_process_identity"] = fake_read | ||
|
|
||
| root_terminated, process_set_terminated = waiter( | ||
| root_identity[0], | ||
| root_identity[1], | ||
| (root_identity, child_identity), | ||
| timeout_seconds=0.10, | ||
| ) | ||
| self.assertIs(root_terminated, True) | ||
| self.assertIs(process_set_terminated, False) | ||
| self.assertLessEqual(fake_time.now, 0.1000001) | ||
|
|
||
| def test_combined_waiter_requires_root_identity_in_the_sampled_set(self) -> None: | ||
| """A separate root identity may not be paired with an unrelated process set.""" | ||
|
|
||
| namespace = runpy.run_path( | ||
| str(RUNNER), run_name="forced_close_shared_teardown_identity" | ||
| ) | ||
| waiter = namespace["_wait_for_linux_process_teardown"] | ||
| with self.assertRaises(ValueError): | ||
| waiter(101, 1_001, ((202, 2_002),), timeout_seconds=0) | ||
|
|
||
| def test_forced_close_browser_pass_uses_only_the_combined_waiter(self) -> None: | ||
| """The forced-close pass must not run independent root and set timeout windows.""" | ||
|
|
||
| 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.assertIn("_wait_for_linux_process_teardown(", browser_pass) | ||
| self.assertNotIn("_wait_for_linux_process_identity_exit(", browser_pass) | ||
| self.assertNotIn("_wait_for_linux_process_identity_set_exit(", browser_pass) | ||
|
|
||
|
|
||
| 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.
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: Two-deadline teardown remains in the non-forced-close pass
The non-forced-close pass still calls
_wait_for_linux_process_identity_exitthen_wait_for_linux_process_identity_set_exitin sequence (run_mv3_compatibility.py), each with its own fullPROCESS_EXIT_TIMEOUT_SECONDS. This is the same double-budget shape the PR fixes for forced-close, left unchanged here. Out of scope for this partial PR, but a candidate for the same combined-waiter treatment.(Refers to this code)
Was this helpful? React with 👍 or 👎 to provide feedback.