-
Notifications
You must be signed in to change notification settings - Fork 0
feat(browser): prove pristine Agent Task profile admission #136
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
9
commits into
test/agent-task-forced-close-recovery
Choose a base branch
from
test/agent-task-pristine-profile-admission
base: test/agent-task-forced-close-recovery
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
9 commits
Select commit
Hold shift + click to select a range
c9016da
test(browser): define pristine Agent Task isolation contract
seonghobae a805af6
feat(browser): prove pristine Agent Task isolation
seonghobae 5fac5b5
docs(changelog): record pristine Agent Task admission
seonghobae 8845dbd
docs(changelog): correct pristine profile evidence scope
seonghobae 83e02cc
test(browser): keep post-condition diagnostics credential-safe
seonghobae 1deca80
test(browser): restore feasible pristine-profile contract
seonghobae 37b3186
Merge current forced-close recovery into pristine profile admission
seonghobae 5a2f98f
docs: inherit bounded observation and forced-close release notes
seonghobae 1cffb2e
merge: align forced-close recovery prerequisite
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,110 @@ | ||
| """Contract for pristine, credential-free Agent Task browser profile admission.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import runpy | ||
| import tempfile | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| class AgentTaskPristineProfileContractTests(unittest.TestCase): | ||
| """Require explicit isolation proof before the pinned browser task can pass.""" | ||
|
|
||
| def _namespace(self, name: str) -> dict[str, object]: | ||
| return runpy.run_path(str(RUNNER), run_name=name) | ||
|
|
||
| def test_runner_exposes_pristine_profile_and_ambient_state_boundaries(self) -> None: | ||
| """Profile admission and ambient-state inspection must be explicit boundaries.""" | ||
|
|
||
| namespace = self._namespace("agent_task_pristine_profile_contract") | ||
| self.assertIn("_require_pristine_agent_task_profile", namespace) | ||
| self.assertIn("_probe_agent_task_ambient_state", namespace) | ||
|
|
||
| def test_profile_admission_rejects_preexisting_state(self) -> None: | ||
| """Any pre-existing profile entry must fail closed before Chromium starts.""" | ||
|
|
||
| namespace = self._namespace("agent_task_pristine_profile_behavior") | ||
| require_pristine = namespace["_require_pristine_agent_task_profile"] | ||
| with tempfile.TemporaryDirectory(prefix="originweave-pristine-profile-") as profile_dir: | ||
| require_pristine(profile_dir) | ||
| pathlib.Path(profile_dir, "Cookies").write_text("preexisting", encoding="utf-8") | ||
| with self.assertRaisesRegex(RuntimeError, "not pristine"): | ||
| require_pristine(profile_dir) | ||
|
|
||
| def test_ambient_state_probe_rejects_cookies_or_web_storage(self) -> None: | ||
| """Browser-visible cookie or Web Storage state must not be normalized as isolated.""" | ||
|
|
||
| namespace = self._namespace("agent_task_ambient_state_behavior") | ||
| probe = namespace["_probe_agent_task_ambient_state"] | ||
|
|
||
| def no_cookies_request( | ||
| _driver_port: int, | ||
| method: str, | ||
| path: str, | ||
| _payload: object | None = None, | ||
| **_kwargs: object, | ||
| ) -> dict[str, object]: | ||
| self.assertEqual(method, "GET") | ||
| self.assertTrue(path.endswith("/cookie")) | ||
| return {"value": []} | ||
|
|
||
| probe.__globals__["_json_request"] = no_cookies_request | ||
| probe.__globals__["_execute"] = lambda *_args, **_kwargs: { | ||
| "localStorageLength": 0, | ||
| "sessionStorageLength": 0, | ||
| } | ||
| self.assertEqual( | ||
| probe(4444, "session-a"), | ||
| { | ||
| "ambient_cookies_absent": True, | ||
| "ambient_web_storage_absent": True, | ||
| }, | ||
| ) | ||
|
|
||
| def ambient_cookie_request( | ||
| _driver_port: int, | ||
| _method: str, | ||
| _path: str, | ||
| _payload: object | None = None, | ||
| **_kwargs: object, | ||
| ) -> dict[str, object]: | ||
| return {"value": [{"name": "ambient", "value": "redacted-test"}]} | ||
|
|
||
| probe.__globals__["_json_request"] = ambient_cookie_request | ||
| with self.assertRaisesRegex(RuntimeError, "ambient cookies"): | ||
| probe(4444, "session-a") | ||
|
|
||
| probe = self._namespace("agent_task_ambient_storage_behavior")[ | ||
| "_probe_agent_task_ambient_state" | ||
| ] | ||
| probe.__globals__["_json_request"] = no_cookies_request | ||
| probe.__globals__["_execute"] = lambda *_args, **_kwargs: { | ||
| "localStorageLength": 1, | ||
| "sessionStorageLength": 0, | ||
| } | ||
| with self.assertRaisesRegex(RuntimeError, "ambient Web Storage"): | ||
| probe(4444, "session-a") | ||
|
|
||
| def test_agent_task_disables_saved_credential_services_and_gates_evidence(self) -> None: | ||
| """The acceptance runner must configure and require credential-free isolation evidence.""" | ||
|
|
||
| runner = RUNNER.read_text(encoding="utf-8") | ||
| for expected in ( | ||
| '"credentials_enable_service": False', | ||
| '"profile.password_manager_enabled": False', | ||
| '"profile_pristine_before_launch"', | ||
| '"ambient_cookies_absent"', | ||
| '"ambient_web_storage_absent"', | ||
| '"saved_credential_services_disabled"', | ||
| "Agent Task isolation gate failed", | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, 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.
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: Ambient-state probe is origin-scoped only
_probe_agent_task_ambient_statereads cookies via GET /cookie and Web Storage from the current document, both scoped to the fixture origin. State belonging to other origins in a reused profile goes undetected. Harmless here since the profile is a fresh empty tempdir enforced by_require_pristine_agent_task_profile, and the PR's Truth boundary acknowledges this limit.Was this helpful? React with 👍 or 👎 to provide feedback.