Tests for public-mode grounding order and toggle reveal; manifest refresh
Browse files- DEPLOY_MANIFEST.txt +3 -3
- tests/test_app.py +109 -4
DEPLOY_MANIFEST.txt
CHANGED
|
@@ -11,7 +11,7 @@ Dockerfile 1691
|
|
| 11 |
README.md 5169
|
| 12 |
app.py 12519
|
| 13 |
requirements.txt 229
|
| 14 |
-
runner.py
|
| 15 |
static/app.js 31596
|
| 16 |
static/index.html 10913
|
| 17 |
static/style.css 30670
|
|
@@ -68,10 +68,10 @@ system/src/agent.py 9966
|
|
| 68 |
system/src/public_mode.py 5518
|
| 69 |
system/src/snapshot.py 2720
|
| 70 |
system/src/tasks.py 41301
|
| 71 |
-
tests/test_app.py
|
| 72 |
traces/adversarial_rename_under_overlay.json 109497
|
| 73 |
traces/crm_record_update.json 326349
|
| 74 |
traces/portal_edit_and_verify.json 262494
|
| 75 |
|
| 76 |
Files: 69
|
| 77 |
-
Total size:
|
|
|
|
| 11 |
README.md 5169
|
| 12 |
app.py 12519
|
| 13 |
requirements.txt 229
|
| 14 |
+
runner.py 26484
|
| 15 |
static/app.js 31596
|
| 16 |
static/index.html 10913
|
| 17 |
static/style.css 30670
|
|
|
|
| 68 |
system/src/public_mode.py 5518
|
| 69 |
system/src/snapshot.py 2720
|
| 70 |
system/src/tasks.py 41301
|
| 71 |
+
tests/test_app.py 22802
|
| 72 |
traces/adversarial_rename_under_overlay.json 109497
|
| 73 |
traces/crm_record_update.json 326349
|
| 74 |
traces/portal_edit_and_verify.json 262494
|
| 75 |
|
| 76 |
Files: 69
|
| 77 |
+
Total size: 1270137 bytes
|
tests/test_app.py
CHANGED
|
@@ -19,10 +19,15 @@ Boots the real server on a scratch port, then verifies over HTTP:
|
|
| 19 |
7. The three stored traces play back with the results-panel figures
|
| 20 |
of their recorded runs, verified over SSE and again in a headless
|
| 21 |
browser (panel totals + trace strip).
|
| 22 |
-
8. The public-page loop end-to-end, in-process, against
|
| 23 |
-
test
|
| 24 |
type and click intents pass for real; a password field is
|
| 25 |
-
refused; a cross-domain navigation is a reported hard stop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
Run with the web-agent system's venv Python (provides Playwright):
|
| 28 |
|
|
@@ -103,6 +108,69 @@ PUBLIC_PAGE = """<!doctype html><html><body>
|
|
| 103 |
<input id="pw" name="pw" type="password"><button type="submit">Sign in</button></form>
|
| 104 |
</body></html>"""
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
def public_loop_checks():
|
| 108 |
"""Public-page mode end-to-end, in-process. The page is served on
|
|
@@ -128,7 +196,7 @@ def public_loop_checks():
|
|
| 128 |
hits.append(self.path)
|
| 129 |
body = b"ok"
|
| 130 |
else:
|
| 131 |
-
body = PUBLIC_PAGE.encode()
|
| 132 |
self.send_response(200)
|
| 133 |
self.send_header("Content-Type", "text/html")
|
| 134 |
self.send_header("Content-Length", str(len(body)))
|
|
@@ -167,6 +235,43 @@ def public_loop_checks():
|
|
| 167 |
check("rail: password field refused, nothing typed",
|
| 168 |
v["success"] is False and "password field" in v["error"]
|
| 169 |
and v["attempts"] == 0, str(v))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
v = run(url=url, intent="click", label="Leave site", text="",
|
| 171 |
recovery=True)
|
| 172 |
check("rail: cross-domain navigation is a reported hard stop",
|
|
|
|
| 19 |
7. The three stored traces play back with the results-panel figures
|
| 20 |
of their recorded runs, verified over SSE and again in a headless
|
| 21 |
browser (panel totals + trace strip).
|
| 22 |
+
8. The public-page loop end-to-end, in-process, against local
|
| 23 |
+
test pages (guard resolution layer stubbed in the test only):
|
| 24 |
type and click intents pass for real; a password field is
|
| 25 |
+
refused; a cross-domain navigation is a reported hard stop; a
|
| 26 |
+
field hidden behind a same-purpose toggle (Wikipedia's header
|
| 27 |
+
search structure) is revealed and typed into; the grounding
|
| 28 |
+
order (label > aria-label > placeholder > name) picks the
|
| 29 |
+
right field; a toggle-hidden password field is refused before
|
| 30 |
+
anything is clicked.
|
| 31 |
|
| 32 |
Run with the web-agent system's venv Python (provides Playwright):
|
| 33 |
|
|
|
|
| 108 |
<input id="pw" name="pw" type="password"><button type="submit">Sign in</button></form>
|
| 109 |
</body></html>"""
|
| 110 |
|
| 111 |
+
# Wikipedia's header structure, reduced to the load-bearing parts:
|
| 112 |
+
# the search input has NO <label> (it is named by placeholder and
|
| 113 |
+
# aria-label, name="search") and its container is display:none until
|
| 114 |
+
# the same-widget search toggle is used — exactly what the app's
|
| 115 |
+
# 1100px viewport gets from the real site (its stylesheet collapses
|
| 116 |
+
# the search box below 1120px).
|
| 117 |
+
WIKI_LIKE_PAGE = """<!doctype html><html><body>
|
| 118 |
+
<header><div id="p-search">
|
| 119 |
+
<a href="#" class="search-toggle" onclick="event.preventDefault();
|
| 120 |
+
document.getElementById('typeahead').style.display = 'block';">Search</a>
|
| 121 |
+
<div id="typeahead" style="display:none">
|
| 122 |
+
<form id="searchform" onsubmit="event.preventDefault();
|
| 123 |
+
fetch('/record?searched=' + encodeURIComponent(document.getElementById('searchInput').value));">
|
| 124 |
+
<div><input id="searchInput" type="search" name="search"
|
| 125 |
+
placeholder="Search Wikipedia" aria-label="Search Wikipedia"></div>
|
| 126 |
+
<button class="end-button">Search</button>
|
| 127 |
+
</form></div>
|
| 128 |
+
</div></header>
|
| 129 |
+
</body></html>"""
|
| 130 |
+
|
| 131 |
+
# Grounding order: a name-tier field and a placeholder-tier field,
|
| 132 |
+
# both visible; the placeholder tier must win.
|
| 133 |
+
ORDER_PAGE = """<!doctype html><html><body>
|
| 134 |
+
<form id="fa" onsubmit="event.preventDefault();
|
| 135 |
+
fetch('/record?form=A:' + encodeURIComponent(document.getElementById('qa').value));">
|
| 136 |
+
<input id="qa" name="Search Wikipedia" type="text">
|
| 137 |
+
<button type="submit">Search A</button></form>
|
| 138 |
+
<form id="fb" onsubmit="event.preventDefault();
|
| 139 |
+
fetch('/record?form=B:' + encodeURIComponent(document.getElementById('qb').value));">
|
| 140 |
+
<input id="qb" name="qb" type="text" placeholder="Search Wikipedia">
|
| 141 |
+
<button type="submit">Search B</button></form>
|
| 142 |
+
</body></html>"""
|
| 143 |
+
|
| 144 |
+
# Grounding order: an aria-tier field and a label-tier field, both
|
| 145 |
+
# visible; the label tier must win.
|
| 146 |
+
ORDER2_PAGE = """<!doctype html><html><body>
|
| 147 |
+
<form id="fc" onsubmit="event.preventDefault();
|
| 148 |
+
fetch('/record?form=C:' + encodeURIComponent(document.getElementById('qc').value));">
|
| 149 |
+
<input id="qc" name="qc" type="text" aria-label="Site search">
|
| 150 |
+
<button type="submit">Send C</button></form>
|
| 151 |
+
<form id="fd" onsubmit="event.preventDefault();
|
| 152 |
+
fetch('/record?form=D:' + encodeURIComponent(document.getElementById('qd').value));">
|
| 153 |
+
<label for="qd">Site search</label><input id="qd" name="qd" type="text">
|
| 154 |
+
<button type="submit">Send D</button></form>
|
| 155 |
+
</body></html>"""
|
| 156 |
+
|
| 157 |
+
# A password field hidden behind a toggle: the refusal must land
|
| 158 |
+
# before anything is clicked (the run never starts).
|
| 159 |
+
HIDDEN_PASSWORD_PAGE = """<!doctype html><html><body>
|
| 160 |
+
<div id="login-box">
|
| 161 |
+
<a href="#" onclick="event.preventDefault();
|
| 162 |
+
document.getElementById('login-form').style.display = 'block';">Sign in</a>
|
| 163 |
+
<form id="login-form" style="display:none">
|
| 164 |
+
<label for="pw2">Password</label>
|
| 165 |
+
<input id="pw2" name="pw2" type="password">
|
| 166 |
+
<button type="submit">Sign in</button></form>
|
| 167 |
+
</div>
|
| 168 |
+
</body></html>"""
|
| 169 |
+
|
| 170 |
+
PUBLIC_PAGES = {"/page": PUBLIC_PAGE, "/wiki-like": WIKI_LIKE_PAGE,
|
| 171 |
+
"/order": ORDER_PAGE, "/order2": ORDER2_PAGE,
|
| 172 |
+
"/hidden-password": HIDDEN_PASSWORD_PAGE}
|
| 173 |
+
|
| 174 |
|
| 175 |
def public_loop_checks():
|
| 176 |
"""Public-page mode end-to-end, in-process. The page is served on
|
|
|
|
| 196 |
hits.append(self.path)
|
| 197 |
body = b"ok"
|
| 198 |
else:
|
| 199 |
+
body = PUBLIC_PAGES.get(self.path, PUBLIC_PAGE).encode()
|
| 200 |
self.send_response(200)
|
| 201 |
self.send_header("Content-Type", "text/html")
|
| 202 |
self.send_header("Content-Length", str(len(body)))
|
|
|
|
| 235 |
check("rail: password field refused, nothing typed",
|
| 236 |
v["success"] is False and "password field" in v["error"]
|
| 237 |
and v["attempts"] == 0, str(v))
|
| 238 |
+
# Grounding: a field hidden behind a same-purpose toggle is
|
| 239 |
+
# revealed and used (Wikipedia's header search at this app's
|
| 240 |
+
# viewport); the field is named by placeholder/aria-label.
|
| 241 |
+
hits.clear()
|
| 242 |
+
v = run(url=url.replace("/page", "/wiki-like"), intent="type",
|
| 243 |
+
label="Search Wikipedia", text="ClinVar", recovery=True)
|
| 244 |
+
check("grounding: toggle-hidden field is revealed and typed into",
|
| 245 |
+
v["success"] is True and v["steps_completed"] == 2
|
| 246 |
+
and v["attempts"] == 2, str(v))
|
| 247 |
+
check("grounding: the typed text really reached the hidden field",
|
| 248 |
+
any(h.startswith("/record?searched=ClinVar") for h in hits),
|
| 249 |
+
str(hits))
|
| 250 |
+
# Grounding order: placeholder tier beats name tier.
|
| 251 |
+
hits.clear()
|
| 252 |
+
v = run(url=url.replace("/page", "/order"), intent="type",
|
| 253 |
+
label="Search Wikipedia", text="xyz", recovery=True)
|
| 254 |
+
check("grounding order: placeholder match beats name match",
|
| 255 |
+
v["success"] is True
|
| 256 |
+
and any(h.startswith("/record?form=B:xyz") for h in hits)
|
| 257 |
+
and not any(h.startswith("/record?form=A") for h in hits),
|
| 258 |
+
str(v) + " " + str(hits))
|
| 259 |
+
# Grounding order: label tier beats aria tier.
|
| 260 |
+
hits.clear()
|
| 261 |
+
v = run(url=url.replace("/page", "/order2"), intent="type",
|
| 262 |
+
label="Site search", text="xyz", recovery=True)
|
| 263 |
+
check("grounding order: label match beats aria-label match",
|
| 264 |
+
v["success"] is True
|
| 265 |
+
and any(h.startswith("/record?form=D:xyz") for h in hits)
|
| 266 |
+
and not any(h.startswith("/record?form=C") for h in hits),
|
| 267 |
+
str(v) + " " + str(hits))
|
| 268 |
+
# Rail: a hidden password field is refused before any click.
|
| 269 |
+
v = run(url=url.replace("/page", "/hidden-password"),
|
| 270 |
+
intent="type", label="Password", text="nope",
|
| 271 |
+
recovery=True)
|
| 272 |
+
check("rail: hidden password field refused, run never starts",
|
| 273 |
+
v["success"] is False and "password field" in v["error"]
|
| 274 |
+
and v["attempts"] == 0, str(v))
|
| 275 |
v = run(url=url, intent="click", label="Leave site", text="",
|
| 276 |
recovery=True)
|
| 277 |
check("rail: cross-domain navigation is a reported hard stop",
|