diff --git a/AGENTS.md b/AGENTS.md index de32247d..f3d70bd2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -73,6 +73,7 @@ font-renaming stage is separate and does not ship. review, so a stealth drift can never land silently. (It was originally captured byte-for-byte from the now-removed Python oracle.) +- Only `internal/cli/jevbrowse.go` may import `internal/jev` (depguard); cli code keeps its own aria parser - see [jev is a removable module](docs/knowledge/decisions/jev-is-a-removable-module.md). - Conventional Commits (`type(scope): description`). Everything the release process needs follows from the title and the `## Release notes` section of a PR body; see "Releasing" below. diff --git a/docs/knowledge/decisions/jev-is-a-removable-module.md b/docs/knowledge/decisions/jev-is-a-removable-module.md new file mode 100644 index 00000000..7b664d3d --- /dev/null +++ b/docs/knowledge/decisions/jev-is-a-removable-module.md @@ -0,0 +1,38 @@ +--- +type: Decision +title: jev is a removable module +description: Only internal/cli/jevbrowse.go (and its test) may import internal/jev, enforced by depguard, so the experimental jev-browse loop can be cut out at any time; cli code that needs aria parsing keeps its own small parser. +tags: [jev-browse, architecture, lint] +status: stable +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:30:00+01:00" } +sources: + - id: maintainer + resource: "maintainer decision, 2026-09-19: jev is experimental and must be removable at any time" + title: Maintainer decision + - id: lint + resource: /packages/cuttle/.golangci.yml + title: depguard rule jev-only-behind-jev-browse + - id: pr + resource: https://github.com/glim-sh/cuttle/pull/99 + title: "fix(cli): name the in-page dialog behind a pw click timeout (added the rule)" +--- + +# Decision + +`internal/jev` is imported only by `internal/cli/jevbrowse.go` and its +test. A depguard rule in `packages/cuttle/.golangci.yml` +(`jev-only-behind-jev-browse`) fails `just check` on any other +import.[^lint][^pr] + +Why: jev-browse is experimental. Removing it must stay a matter of deleting +`internal/jev`, `jevbrowse.go` and its docs, with nothing else in the cli +depending on it.[^maintainer] + +Consequence: cli code that needs aria-snapshot parsing - `cuttle pw`'s +dialog hint in `playwright.go` is the first case - keeps its own small +parser instead of importing jev's. The duplication is the price of +removability and is accepted.[^maintainer][^pr] + +[^maintainer]: Maintainer decision +[^lint]: depguard rule jev-only-behind-jev-browse +[^pr]: fix(cli): name the in-page dialog behind a pw click timeout (added the rule) diff --git a/docs/knowledge/decisions/playwright-cli-is-the-driver-interface.md b/docs/knowledge/decisions/playwright-cli-is-the-driver-interface.md index d58c3cb2..8d6f3d68 100644 --- a/docs/knowledge/decisions/playwright-cli-is-the-driver-interface.md +++ b/docs/knowledge/decisions/playwright-cli-is-the-driver-interface.md @@ -43,6 +43,7 @@ Why: roughly 200-600ms. Speed of action is explicitly not the product's goal - see [Humanized input is the value proposition](/decisions/humanize-over-speed.md) - so this overhead buys nothing worth reimplementing the driver for.[^maintainer] + Measured breakdown: [cost of one cuttle pw call](/findings/pw-call-cost-breakdown.md). A detection argument reinforces it: a survey of 12 browser-agent repos in the jev-browse style found every one hand-rolling page perception with diff --git a/docs/knowledge/findings/aria-snapshot-focus-and-modal-shape.md b/docs/knowledge/findings/aria-snapshot-focus-and-modal-shape.md new file mode 100644 index 00000000..a0310597 --- /dev/null +++ b/docs/knowledge/findings/aria-snapshot-focus-and-modal-shape.md @@ -0,0 +1,46 @@ +--- +type: Finding +title: "aria snapshot: focus and modal shape" +description: In playwright's aria snapshot [active] marks only the focused element and there is no [modal] marker, so an open modal is recognized as a dialog whose subtree holds [active]; background elements stay listed, and keys containing a colon-space are single-quoted whole. +tags: [playwright-cli, snapshot, jev-browse, cuttle-pw] +status: stable +stale_after: "2027-03-19T00:00:00+00:00" +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:30:00+01:00" } +sources: + - id: renderer + resource: "playwright-core bundled with @playwright/cli 0.1.20: the aria snapshot renderer and its yaml key escaping" + title: playwright's aria snapshot renderer + - id: live + resource: "live validation against local cuttle containers, 2026-09-18/19: snapshots taken with an in-page modal open (session record, no durable link)" + title: Live validation +--- + +# Finding + +Shape facts anything parsing the aria snapshot has to handle:[^renderer][^live] + +- **`[active]` marks only the focused element** - it is set when the node + is `document.activeElement` and `document.hasFocus()` is true. It is not + a "this subtree is live" marker. +- **There is no `[modal]` marker.** An open modal shows as a `dialog` or + `alertdialog` node; the working test for "a modal is open" is such a node + whose subtree contains `[active]`. +- **Background elements stay listed.** Everything behind the modal is still + in the tree with working-looking refs; clicking one times out on the + driver's 5000ms actionability wait because the overlay intercepts it. + A consumer offering elements must scope to the dialog itself. +- **Keys containing ": " are single-quoted whole**, with `''` for a literal + quote: + + ```yaml + - 'dialog "Step 1: Sign in" [ref=e4]': + ``` + +The value-rendering side of the same quoting rules is in +[the aria snapshot renders field values](/findings/aria-snapshot-renders-secret-values.md). +jev-browse's modal scoping and `cuttle pw`'s dialog hint on a click timeout +both rest on these facts - see +[jev-browse slowness was the driver path](/findings/jev-browse-slowness-was-the-driver-path.md). + +[^renderer]: playwright's aria snapshot renderer +[^live]: Live validation diff --git a/docs/knowledge/findings/jev-browse-slowness-was-the-driver-path.md b/docs/knowledge/findings/jev-browse-slowness-was-the-driver-path.md new file mode 100644 index 00000000..53bd328b --- /dev/null +++ b/docs/knowledge/findings/jev-browse-slowness-was-the-driver-path.md @@ -0,0 +1,51 @@ +--- +type: Finding +title: jev-browse slowness was the driver path, not the model +description: jev-browse ran a multi-page flow at nearly twice plain cuttle pw's time because of how it drove the page - modal-blind offers, dead-click repeats, missing Enter, redundant snapshots and spawns, section-less labels - and reached parity once those were fixed. +tags: [jev-browse, benchmark, performance, snapshot] +status: stable +stale_after: "2027-03-19T00:00:00+00:00" +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:40:00+01:00" } +sources: + - id: bench + resource: "benchmark harness runs on 2026-09-18/19 against a signed-in site: the same flow as the orchestrator-effort benchmark, humanize on, jev-browse driven in chunks by a claude -p orchestrator, plus one one-shot scripted run (session record, no durable link)" + title: jev-browse benchmark runs + - id: pr + resource: https://github.com/glim-sh/cuttle/pull/102 + title: "feat(jev): withhold write actions and halve jev-browse run time (branch feat/jev-browse-speed)" +--- + +# Finding + +Before the fixes, an LLM orchestrating `cuttle jev-browse` in chunks took +282-348s on the flow that plain `cuttle pw` did in 158-187s at the same +effort; a one-shot scripted run failed at 1007s with 135 of 138 clicks +failing.[^bench] The model's decision time was not the cause. The root +causes were all in how jev drove the page:[^bench] + +1. **Modal-blind offers.** With an in-page modal open, jev still offered + the elements behind it; every such click timed out after 5000ms. +2. **Dead-click repeats.** It re-picked an autocomplete option whose click + had just failed, on an unchanged page. +3. **No Enter after typing** into a combobox, so a search never submitted. +4. **Driver cost per step.** About 2 snapshots and 3-8 process spawns per + step, ~4.3s/step before any humanized action. +5. **Section-less labels.** Offered labels did not name the page section, + so search values went to the site-wide search box instead of the form's. + +Fixes, one per cause: scope offers to the open modal, exclude a click that +left the page unchanged, offer Enter after typing, take one snapshot after a +navigation and keep one persistent driver client per run, and label options +with their section and filled state.[^pr] The same change also withholds +write-shaped actions behind a deny gate - a safety fix, not a speed one. +After them: 157s/170s at high effort - +level with plain pw at about half its cost - and 111s/120s at low effort, +against pw's 101s/103s.[^bench] + +The modal facts behind fix 1 are in +[aria snapshot: focus and modal shape](/findings/aria-snapshot-focus-and-modal-shape.md); +the per-spawn cost behind fix 4 in +[cost of one cuttle pw call](/findings/pw-call-cost-breakdown.md). + +[^bench]: jev-browse benchmark runs +[^pr]: feat(jev): withhold write actions and halve jev-browse run time (branch feat/jev-browse-speed) diff --git a/docs/knowledge/findings/orchestrator-effort-is-the-browse-time-lever.md b/docs/knowledge/findings/orchestrator-effort-is-the-browse-time-lever.md new file mode 100644 index 00000000..3b630f9d --- /dev/null +++ b/docs/knowledge/findings/orchestrator-effort-is-the-browse-time-lever.md @@ -0,0 +1,49 @@ +--- +type: Finding +title: Orchestrator reasoning effort is the largest browse-time lever +description: On a humanized multi-page flow driven through cuttle pw by a headless claude -p orchestrator, reasoning effort moved wall time more than model choice or context size; most of a run is tool execution and turn overhead, not LLM time. +tags: [benchmark, performance, cuttle-pw, orchestrator, humanize] +status: stable +stale_after: "2027-03-19T00:00:00+00:00" +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:40:00+01:00" } +sources: + - id: bench + resource: "benchmark harness runs on 2026-09-18/19 against a signed-in site: one fixed flow, humanize on, headless claude -p orchestrator with a fresh context per run, plain cuttle pw (session record, no durable link)" + title: Browse benchmark runs +--- + +# Finding + +The flow: a filtered search -> open 3 results -> drill into a related page +-> open 3 linked entries, about 12 clicks on a signed-in site, humanized input +on, driven by a headless `claude -p` orchestrator with a fresh context, +through plain `cuttle pw`.[^bench] + +| Arm | Wall time | Turns | Cost | +|---|---|---|---| +| effort low | 101s, 103s | 12 | ~$1.00 | +| effort high (default), 4 runs | 158-187s | 20-29 | $1.9-4.0 | +| effort max | 162s, 235s | 26-32 | - | +| Haiku 4.5 | 140s, 301s (unstable) | - | - | +| Sonnet 5 | 207s | - | - | + +What the numbers say:[^bench] + +- **Effort is the lever.** Low effort did the same flow in about 60% of + the high-effort time at a half to a quarter of the cost, mostly by taking + fewer turns. Max effort bought nothing over high. +- **LLM time is the minority of a run.** At high effort, API time was + 50-66s of a ~170s run; the rest was tool execution and CLI turn overhead. +- **A large prepended context did not slow turns.** A 140k-token context + ran ~2.9s per turn against ~2.5s without it. That arm is confounded - the + context contained the route - so it says nothing about whether context + helps, only that it did not hurt latency. +- **Humanized input sets the floor.** Each humanized click costs ~3.5s + including the page's reaction, which puts this flow at a 60-80s floor + whatever the orchestrator does. That floor stays; see + [Humanized input is the value proposition](/decisions/humanize-over-speed.md). + +Related: [jev-browse slowness was the driver path](/findings/jev-browse-slowness-was-the-driver-path.md), +[cost of one cuttle pw call](/findings/pw-call-cost-breakdown.md). + +[^bench]: Browse benchmark runs diff --git a/docs/knowledge/findings/playwright-cli-action-verbs-snapshot-to-file.md b/docs/knowledge/findings/playwright-cli-action-verbs-snapshot-to-file.md new file mode 100644 index 00000000..12bd2cb5 --- /dev/null +++ b/docs/knowledge/findings/playwright-cli-action-verbs-snapshot-to-file.md @@ -0,0 +1,36 @@ +--- +type: Finding +title: playwright-cli action verbs always write their snapshot to a file +description: In playwright-cli 0.1.20 every action verb writes the post-action aria snapshot to .playwright-cli/page-.yml and prints only a link; nothing configurable makes it print inline - only the snapshot verb does. +tags: [playwright-cli, cuttle-pw, snapshot] +status: stable +stale_after: "2027-03-19T00:00:00+00:00" +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:40:00+01:00" } +sources: + - id: core + resource: "playwright-core 1.64.0-alpha-2026-09-14 as pinned by @playwright/cli 0.1.20 (lib/coreBundle.js): the snapshot response path (snapshotToFile) and resolveCLIConfigForCLI's daemon overrides" + title: playwright-core cli source at the pinned version +--- + +# Finding + +After an action verb (click, fill, type, goto, ...), playwright-cli 0.1.20 +writes the page's aria snapshot to `.playwright-cli/page-.yml` +in the working directory and prints only a link to it, never the tree:[^core] + +```js +const snapshotToFile = this._includeSnapshot !== "explicit" || !!this._includeSnapshotFileName; +``` + +and `resolveCLIConfigForCLI` hard-codes `snapshotMode: "full"` in the daemon +overrides, which are merged last. So no config file and no environment +variable can make an action verb print its snapshot inline. Only the +`snapshot` verb prints inline.[^core] + +Consequence: a consumer that wants the tree after an action either reads +the linked file (inside the container, where the driver runs) or issues a +`snapshot` verb - one more call. Re-verify on every driver pin bump. + +Related: [playwright-cli attach and session model](/findings/playwright-cli-attach-model.md). + +[^core]: playwright-core cli source at the pinned version diff --git a/docs/knowledge/findings/pw-call-cost-breakdown.md b/docs/knowledge/findings/pw-call-cost-breakdown.md new file mode 100644 index 00000000..77831ec1 --- /dev/null +++ b/docs/knowledge/findings/pw-call-cost-breakdown.md @@ -0,0 +1,61 @@ +--- +type: Finding +title: Cost of one cuttle pw call +description: A cuttle pw verb pays a flat ~250-320ms for docker exec, node start and the playwright-cli bundle load before the browser does anything, while cuttle's own wrapper cost 30-80ms until it shrank to one exec; a persistent in-container client removes most of the fixed cost at a maintenance price. +tags: [cuttle-pw, performance, playwright-cli, docker] +status: stable +stale_after: "2027-03-19T00:00:00+00:00" +generated: { by: claude-code/claude-opus-5, at: "2026-09-19T11:40:00+01:00" } +sources: + - id: bench + resource: "timing measurements against a local cuttle container, 2026-09-18/19: per-stage timings of single pw verbs and a 20-verb flow (session record, no durable link)" + title: pw call timing measurements + - id: onexec + resource: https://github.com/glim-sh/cuttle/pull/100 + title: "perf(cli): run a pw verb in one docker exec, lease check included (merged)" + - id: client + resource: https://github.com/glim-sh/cuttle/pull/101 + title: "perf(cli): serve-hosted pw client (experiment, draft; branch exp/pw-serve-client)" +--- + +# Finding + +Where the time in one `cuttle pw` call goes: + +| Stage | Cost | +|---|---| +| `docker exec` + node start + playwright-cli bundle load | ~250-320ms, flat per verb[^client] | +| of which one `docker exec` process | ~42ms[^onexec] | +| daemon round trip for a snapshot | ~45ms[^bench] | +| cuttle's own wrapper, before the one-exec change | 30-80ms[^onexec] | + +The wrapper's share was extra docker processes: a `docker inspect` state +check (~26ms) before every verb and a lease-check `docker exec` (~42ms) +before a driving one. The one-exec change asks for state only after a failed +exec and runs the lease check inside the verb's own exec, taking a verb from +2-3 docker processes to one.[^onexec] + +The bigger fixed cost is the exec plus node start, paid on every verb. A +serve-hosted persistent client, kept alive and talking to the session +daemon's socket, measured:[^client][^bench] + +| Measure | Per-exec | Persistent client | +|---|---|---| +| snapshot | 321ms | 77ms | +| goto | 439ms | 122ms | +| click (humanized) | 1119ms | 823ms | +| 20-verb flow | 14.2s | 9.1s | +| container CPU, 20 snapshots | 5.4s | 0.16s | + +Its costs: ~370 lines of code, reliance on playwright-cli's internal client +modules (not a public API, so every pin bump must re-check them), and a +second path that has to stay behaviorally equivalent to the exec path.[^client] +Against a humanized flow's floor the saving is a fraction of the run - see +[orchestrator effort is the browse-time lever](/findings/orchestrator-effort-is-the-browse-time-lever.md). + +Refines the rough 200-600ms per verb in +[playwright-cli is the driver interface](/decisions/playwright-cli-is-the-driver-interface.md). + +[^bench]: pw call timing measurements +[^onexec]: perf(cli): run a pw verb in one docker exec, lease check included (merged) +[^client]: perf(cli): serve-hosted pw client (experiment, draft; branch exp/pw-serve-client) diff --git a/docs/knowledge/index.md b/docs/knowledge/index.md index 9e3c8bd2..9336e52e 100644 --- a/docs/knowledge/index.md +++ b/docs/knowledge/index.md @@ -25,6 +25,7 @@ lists below (title, link, the concept's `description` verbatim). - [Humanized input is the value proposition](decisions/humanize-over-speed.md) - Human-paced input is core to cuttle's stealth promise; decision-loop optimizations must never trade it away for action speed. - [One driver at a time, enforced by a lease in the daemon](decisions/session-lease-in-the-daemon.md) - Exclusive driving of a browser is a TTL lease held in cuttle serve, keyed by seed, with explicit takeover - not a host file lock and not a second browser. - [playwright-cli is the driver interface for higher-level automation](decisions/playwright-cli-is-the-driver-interface.md) - cuttle composes the bundled playwright-cli for all higher-level browsing automation (cuttle pw, cuttle jev-browse) - never raw CDP, never its own snapshot or ref semantics - and it is the only driver cuttle documents or routes agents to. +- [jev is a removable module](decisions/jev-is-a-removable-module.md) - Only internal/cli/jevbrowse.go (and its test) may import internal/jev, enforced by depguard, so the experimental jev-browse loop can be cut out at any time; cli code that needs aria parsing keeps its own small parser. ## Findings @@ -34,6 +35,11 @@ lists below (title, link, the concept's `description` verbatim). - [TypeSafe Jev API transports and answer shapes](findings/jev-api-transports.md) - The Jev client routes one API key to OpenRouter or the first-party API by its prefix, and OpenRouter sends a confidence on choice answers despite documenting only probabilities. - [The aria snapshot renders field values, password inputs included](findings/aria-snapshot-renders-secret-values.md) - playwright-cli's aria snapshot prints current field values in plaintext - type=password too, in several yaml shapes - so snapshot text must be filtered on the parsed tree before it leaves the host. - [playwright-cli go-back leaves the snapshot emitting dead refs](findings/playwright-cli-go-back-ref-poisoning.md) - In the bundled playwright-cli 0.1.20, after go-back every snapshot ref is from the pre-navigation frame and clicks on it fail; only a fresh goto re-mints working refs. +- [Orchestrator reasoning effort is the largest browse-time lever](findings/orchestrator-effort-is-the-browse-time-lever.md) - On a humanized multi-page flow driven through cuttle pw by a headless claude -p orchestrator, reasoning effort moved wall time more than model choice or context size; most of a run is tool execution and turn overhead, not LLM time. +- [jev-browse slowness was the driver path, not the model](findings/jev-browse-slowness-was-the-driver-path.md) - jev-browse ran a multi-page flow at nearly twice plain cuttle pw's time because of how it drove the page - modal-blind offers, dead-click repeats, missing Enter, redundant snapshots and spawns, section-less labels - and reached parity once those were fixed. +- [Cost of one cuttle pw call](findings/pw-call-cost-breakdown.md) - A cuttle pw verb pays a flat ~250-320ms for docker exec, node start and the playwright-cli bundle load before the browser does anything, while cuttle's own wrapper cost 30-80ms until it shrank to one exec; a persistent in-container client removes most of the fixed cost at a maintenance price. +- [playwright-cli action verbs always write their snapshot to a file](findings/playwright-cli-action-verbs-snapshot-to-file.md) - In playwright-cli 0.1.20 every action verb writes the post-action aria snapshot to .playwright-cli/page-.yml and prints only a link; nothing configurable makes it print inline - only the snapshot verb does. +- [aria snapshot: focus and modal shape](findings/aria-snapshot-focus-and-modal-shape.md) - In playwright's aria snapshot [active] marks only the focused element and there is no [modal] marker, so an open modal is recognized as a dialog whose subtree holds [active]; background elements stay listed, and keys containing a colon-space are single-quoted whole. ## References