Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

chore: opt loop fixes

Mario41a97f8e8928
diff --git a/tests/optimization/group-10.md b/tests/optimization/group-10.md
index a948108e..6a3f4688 100644
--- a/tests/optimization/group-10.md
+++ b/tests/optimization/group-10.md
@@ -1,12 +1,12 @@
# Group 10: Nested Interactions & Modal Dialogs
### 10.1 Open and interact with modal on dashboard
-Navigate to `http://fixtures/dashboard.html`. Find and click the Settings button (selector: `#settings-btn`) to open the modal dialog.
+Navigate to `http://fixtures/dashboard.html`. Find and click the Settings button to open the modal dialog.
**Verify**: Modal appeared — snapshot contains "Dashboard Settings".
### 10.2 Modify settings and close modal
-In the modal, select "Dark" from the theme dropdown (`#theme-select`), then click the Save button (`#modal-save`). After the modal closes, check the page content.
+In the modal, select "Dark" from the theme dropdown, then click the Save button. After the modal closes, check the page content.
**Verify**: Page contains `THEME_DARK_APPLIED`.
diff --git a/tests/optimization/group-15.md b/tests/optimization/group-15.md
index 2a50beae..ca0b3e1a 100644
--- a/tests/optimization/group-15.md
+++ b/tests/optimization/group-15.md
@@ -21,7 +21,7 @@ Navigate to `http://fixtures/article.html` and extract the HTML of the main `art
**Verify**: Extracted HTML contains `VERIFY_ARTICLE_PAGE_41414`.
### 15.4 Inspect a stable computed CSS property
-Navigate to `http://fixtures/pricing.html` and inspect the computed CSS for `#plan-pro`. Report the computed `display` value.
+Navigate to `http://fixtures/pricing.html` and inspect the computed CSS for the Pro plan card. Report the computed `display` value.
**Verify**: The computed value is `flex`.
diff --git a/tests/optimization/group-19.md b/tests/optimization/group-19.md
index bf8517a0..08b657df 100644
--- a/tests/optimization/group-19.md
+++ b/tests/optimization/group-19.md
@@ -5,8 +5,8 @@ Navigate to `http://fixtures/iframe.html` and extract content from inside the em
**Verify**: The iframe's inner content includes `IFRAME_INNER_CONTENT_LOADED`.
-### 19.2 Type into iframe input (native frame scope)
-Use `pinchtab frame '#content-frame'` to scope into the iframe, then `fill` the input with "Hello World" and `click` the Save button. Verify via a scoped `snap` — `text --full` doesn't pierce iframes. Reset with `pinchtab frame main` afterwards.
+### 19.2 Interact with iframe form
+Scope into the embedded iframe, fill the input with "Hello World" and submit. Note that `text` does not pierce iframes — use a scoped observation instead. Reset frame scope when done.
**Verify**: Scoped snapshot contains `IFRAME_INPUT_RECEIVED_HELLO_WORLD`.
diff --git a/tests/optimization/group-22.md b/tests/optimization/group-22.md
index d069d637..a3dc03ff 100644
--- a/tests/optimization/group-22.md
+++ b/tests/optimization/group-22.md
@@ -1,7 +1,7 @@
# Group 22: Mouse Drag & Drop
### 22.1 Drag a piece into Zone A
-Navigate to `http://fixtures/drag.html`. The page contains a draggable square (`#piece`) and three target zones (`#zone-a`, `#zone-b`, `#zone-c`). Drag the piece so its center ends up over **Zone A**.
+Navigate to `http://fixtures/drag.html`. The page contains a draggable square and three labeled target zones. Drag the piece so it ends up over **Zone A**.
**Verify**: The page shows `LAST_DROP=DROP_ZONE_A_OK`.
diff --git a/tests/optimization/group-27.md b/tests/optimization/group-27.md
index 5b974508..1fe1f5e8 100644
--- a/tests/optimization/group-27.md
+++ b/tests/optimization/group-27.md
@@ -1,7 +1,7 @@
# Group 27: Contenteditable editor
### 27.1 Type into the rich-text editor
-Navigate to `http://fixtures/editor.html`. Type the text `Hello rich text` into the `#editor` div. `contenteditable` elements don't have `.value`, so use `type` (keyboard events), not `fill`.
+Navigate to `http://fixtures/editor.html`. Type the text `Hello rich text` into the editor area. Note that contenteditable elements don't have `.value`, so use keyboard events rather than fill.
**Verify**: Page text contains `EDITOR_CHARS=15` and the mirror shows `Hello rich text`.
diff --git a/tests/optimization/group-28.md b/tests/optimization/group-28.md
index 5f352fae..38d0ad17 100644
--- a/tests/optimization/group-28.md
+++ b/tests/optimization/group-28.md
@@ -1,7 +1,7 @@
# Group 28: Range slider
### 28.1 Move slider into HIGH bucket
-Navigate to `http://fixtures/range.html`. Set the `#volume` range slider to 90.
+Navigate to `http://fixtures/range.html`. Set the volume range slider to 90.
**Verify**: Page text contains both `RANGE_VALUE_90` and `BUCKET_HIGH`.
diff --git a/tests/optimization/group-30.md b/tests/optimization/group-30.md
index 69c78d4a..7131d814 100644
--- a/tests/optimization/group-30.md
+++ b/tests/optimization/group-30.md
@@ -1,7 +1,7 @@
# Group 30: Custom dropdown menu
### 30.1 Pick the "Beta" item
-Navigate to `http://fixtures/dropdown.html`. The page has a custom dropdown — click the toggle button (`#dropdown-toggle`) to open the menu, then click the "Beta" item.
+Navigate to `http://fixtures/dropdown.html`. The page has a custom dropdown — click the toggle button to open the menu, then click the "Beta" item.
**Verify**: Page text contains `DROPDOWN_SELECTED=BETA`.
diff --git a/tests/optimization/group-31.md b/tests/optimization/group-31.md
index 030c91cb..0028cf07 100644
--- a/tests/optimization/group-31.md
+++ b/tests/optimization/group-31.md
@@ -1,7 +1,7 @@
# Group 31: Nested iframes (3 levels deep)
### 31.1 Click a button in the deepest frame
-Navigate to `http://fixtures/iframe-nested.html`. The outer page embeds `#level-2`, which in turn embeds `#level-3`, which contains `#deep-button`. Drill through the two frame hops and click the button. Verify via a scoped `snap` before resetting to `main`.
+Navigate to `http://fixtures/iframe-nested.html`. The page has nested iframes three levels deep — drill through the frame hops to reach the innermost button and click it. Verify via a scoped observation before resetting to the main frame.
**Verify**: Scoped snapshot contains `DEEP_CLICKED=YES_LEVEL_3`.
diff --git a/tests/optimization/group-32.md b/tests/optimization/group-32.md
index d46bbb7e..8675a296 100644
--- a/tests/optimization/group-32.md
+++ b/tests/optimization/group-32.md
@@ -1,7 +1,7 @@
# Group 32: Dynamic iframe (inserted after load)
### 32.1 Wait for a late iframe, then interact with it
-Navigate to `http://fixtures/iframe-dynamic.html`. The iframe is inserted ~1.2 s after load (use `wait --text "IFRAME_DYNAMIC_ATTACHED"`). Then scope into `#late-frame`, fill `#iframe-input` with "Late World", click `#iframe-submit`, and verify the inner result marker.
+Navigate to `http://fixtures/iframe-dynamic.html`. The iframe is inserted dynamically after page load — wait for it to appear. Then scope into it, fill the input with "Late World", submit, and verify the inner result marker.
**Verify**: Scoped snapshot contains `IFRAME_INPUT_RECEIVED_LATE_WORLD`.
diff --git a/tests/optimization/group-33.md b/tests/optimization/group-33.md
index abe79613..6b455a20 100644
--- a/tests/optimization/group-33.md
+++ b/tests/optimization/group-33.md
@@ -1,7 +1,7 @@
# Group 33: srcdoc iframe
### 33.1 Interact with an inline-content iframe
-Navigate to `http://fixtures/iframe-srcdoc.html`. The iframe's content is inlined via `srcdoc`; it has no `src` URL. Scope into `#srcdoc-frame`, fill `#inline-input` with `srcdoc`, click `#inline-submit`, and verify.
+Navigate to `http://fixtures/iframe-srcdoc.html`. The iframe's content is inlined via `srcdoc`; it has no `src` URL. Scope into the iframe, fill the input with `srcdoc`, submit, and verify.
**Verify**: Scoped snapshot contains `INLINE_RECEIVED_SRCDOC`.
diff --git a/tests/optimization/group-34.md b/tests/optimization/group-34.md
index 27adab4f..8ef1e296 100644
--- a/tests/optimization/group-34.md
+++ b/tests/optimization/group-34.md
@@ -1,7 +1,7 @@
# Group 34: Sandboxed iframe
### 34.1 Click inside a sandboxed iframe
-Navigate to `http://fixtures/iframe-sandbox.html`. The iframe has `sandbox="allow-scripts allow-same-origin"`. Scope into `#sandboxed`, click `#sandbox-button`, and verify.
+Navigate to `http://fixtures/iframe-sandbox.html`. The iframe has `sandbox="allow-scripts allow-same-origin"`. Scope into the sandboxed iframe, click the button inside it, and verify.
**Verify**: Scoped snapshot contains `SANDBOX_CLICKED=YES`.
diff --git a/tests/optimization/group-36.md b/tests/optimization/group-36.md
index 8cd88cb7..8bee00ef 100644
--- a/tests/optimization/group-36.md
+++ b/tests/optimization/group-36.md
@@ -1,14 +1,14 @@
# Group 36: Search results page (SERP)
-### 36.1 Find a specific result by id
-Navigate to `http://fixtures/serp.html`. The page has 6 result cards (`#r-1`..`#r-6`). Extract just the third card's content. A scoped snapshot (`snap --selector "#r-3"`) is the direct path.
+### 36.1 Find a specific result
+Navigate to `http://fixtures/serp.html`. The page has 6 search result cards. Extract just the third result's content using a scoped observation.
**Verify**: The scoped output contains `RESULT_3_TITLE` and `RESULT_3_SNIPPET_MARKER`.
### 36.2 Count all result cards
-Use a full text extraction to verify all six results are present in one pass.
+Extract the full page content to verify all six results are present in one pass. Note that Readability may trim repetitive card layouts.
-**Verify**: Output contains all of `RESULT_1_TITLE` through `RESULT_6_TITLE` and the summary `SERP_RESULT_COUNT_6`. Default Readability trims SERPs — use `text --full`.
+**Verify**: Output contains all of `RESULT_1_TITLE` through `RESULT_6_TITLE` and the summary `SERP_RESULT_COUNT_6`.
---
diff --git a/tests/optimization/group-37.md b/tests/optimization/group-37.md
index 67d2b2d3..636b1302 100644
--- a/tests/optimization/group-37.md
+++ b/tests/optimization/group-37.md
@@ -1,14 +1,14 @@
# Group 37: Q&A thread (Stack-Overflow style)
### 37.1 Find the accepted answer id
-Navigate to `http://fixtures/qa.html`. The accepted answer carries `data-accepted="true"` on its `<div>` wrapper. Use `eval` to return that element's `id`.
+Navigate to `http://fixtures/qa.html`. Find the accepted answer on the page and determine its element id.
-**Verify**: The `eval` result equals `"a-2"`.
+**Verify**: The accepted answer's id is `a-2`.
### 37.2 Extract the accepted answer's body
-Scope a snapshot to `#a-2` and verify the body content.
+Scope an observation to the accepted answer element and verify the body content.
-**Verify**: Scoped snapshot contains `ANSWER_2_BODY_MARKER` and `ACCEPTED_ANSWER_ID_A2`.
+**Verify**: Scoped output contains `ANSWER_2_BODY_MARKER` and `ACCEPTED_ANSWER_ID_A2`.
---
diff --git a/tests/optimization/group-38.md b/tests/optimization/group-38.md
index 81917733..d93d02a8 100644
--- a/tests/optimization/group-38.md
+++ b/tests/optimization/group-38.md
@@ -1,11 +1,11 @@
# Group 38: Pricing table
### 38.1 Read just the Pro plan
-Navigate to `http://fixtures/pricing.html`. The page has three plan cards (`#plan-free`, `#plan-pro`, `#plan-enterprise`). Read only the Pro plan using a scoped snapshot.
+Navigate to `http://fixtures/pricing.html`. The page has three plan cards (Free, Pro, Enterprise). Read only the Pro plan using a scoped observation.
-**Verify**: Scoped snapshot contains `PLAN_PRO_PRICE_29` and `PLAN_PRO_LIMIT_5000_requests per day`.
+**Verify**: Scoped output contains `PLAN_PRO_PRICE_29` and `PLAN_PRO_LIMIT_5000_requests per day`.
### 38.2 Compare all three plans
-Extract the full page (pricing grids are a Readability anti-pattern — reach for `--full`).
+Extract the full page content to see all three plans. Note that Readability may trim repetitive pricing grids.
**Verify**: Output contains `PLAN_FREE_PRICE_0`, `PLAN_PRO_PRICE_29`, and `PLAN_ENTERPRISE_PRICE_CUSTOM`.
diff --git a/tests/optimization/index.md b/tests/optimization/index.md
index 27f90db6..e3b17015 100644
--- a/tests/optimization/index.md
+++ b/tests/optimization/index.md
@@ -6,7 +6,7 @@ Read this index first, then read the relevant group files.
## How to use this directory
-- `setup-pinchtab.md` and `setup-agent-browser.md` define lane-specific setup, wrapper usage, recording, and Group 0 behavior.
+- `setup-pinchtab.md` defines lane-specific setup, wrapper usage, and recording.
- This directory defines the shared task groups.
- Each group lives in its own file: `group-00.md` through `group-38.md`.
- When running a subset, read only the selected group files.
diff --git a/tests/optimization/subagent-context.md b/tests/optimization/subagent-context.md
new file mode 100644
index 00000000..7ce4e986
--- /dev/null
+++ b/tests/optimization/subagent-context.md
@@ -0,0 +1,53 @@
+# Subagent Context
+
+You are running PinchTab optimization tasks. You will be given a set of group files, each containing numbered steps to execute using the PinchTab browser automation tool.
+
+## What to read
+
+1. **PinchTab skill**: `skills/pinchtab/SKILL.md` — full command reference and patterns.
+2. **Group files**: `tests/optimization/group-XX.md` — task descriptions and verification markers.
+
+## What NOT to read
+
+- `tests/tools/scripts/baseline.sh` — deterministic baseline; reading it defeats the purpose.
+- `tests/tools/scripts/run-optimization.sh` — infrastructure script, not relevant.
+- `tests/benchmark/` — separate benchmark lane, not your concern.
+
+## Environment
+
+- PinchTab server: `http://localhost:9867`, token: `benchmark-token`
+- Fixtures: `http://fixtures/` (Docker hostname)
+- Available fixture pages: `/`, `/wiki.html`, `/wiki-go.html`, `/wiki-python.html`, `/wiki-rust.html`, `/articles.html`, `/search.html`, `/form.html`, `/dashboard.html`, `/ecommerce.html`, `/spa.html`, `/login.html` — plus additional fixture pages referenced in specific group steps.
+
+## Wrapper
+
+Always use `./scripts/pt ...` — never call `pinchtab` directly.
+
+The wrapper executes pinchtab inside the Docker service and forwards `PINCHTAB_TOKEN` and `PINCHTAB_SERVER` automatically.
+
+Tab state is automatic — `nav` persists the tab ID to a state file, and subsequent commands read it. No need to manage tab IDs manually.
+
+## Recording
+
+Record every step result immediately after completion:
+
+```bash
+./scripts/runner step-end <group> <step> answer "<what you observed>" <pass|fail|skip> "verification notes"
+```
+
+For failures:
+
+```bash
+./scripts/runner step-end <group> <step> fail "<what went wrong>" skip ""
+```
+
+- `<group>` is the group number (e.g., `0`, `15`, `38`)
+- `<step>` is the step number within the group (e.g., `1`, `2`, `3`)
+- Keep answers factual — do not self-grade in the answer payload.
+
+## Execution approach
+
+1. Read the PinchTab skill to learn available commands.
+2. Read the assigned group files.
+3. For each step: navigate to the fixture, interact using PinchTab commands, verify the expected markers appear, and record the result.
+4. Use your judgment to figure out the right commands — the group files describe WHAT to achieve, not HOW.
diff --git a/tests/tools/scripts/run-optimization.sh b/tests/tools/scripts/run-optimization.sh
index 5225a265..85910719 100755
--- a/tests/tools/scripts/run-optimization.sh
+++ b/tests/tools/scripts/run-optimization.sh
@@ -36,7 +36,8 @@ cd "${TOOLS_DIR}"
# so we don't clobber that setup by force-recreating without the overlay.
if [[ -z "${BENCHMARK_SKIP_PINCHTAB_RESTART:-}" ]]; then
echo "Ensuring pinchtab is running with pinchtab.json (production-faithful, idpi.wrapContent=true)..."
- docker compose -f docker-compose.yml up -d --build --force-recreate --no-deps pinchtab
+ docker compose -f docker-compose.yml down --remove-orphans 2>/dev/null || true
+ docker compose -f docker-compose.yml up -d --build --force-recreate pinchtab
sleep 15
# Verify PinchTab is healthy