Skip to content

feat(browser): uid-addressable AX snapshots; prompt-cache break-even gate - #237

Merged
Patel230 merged 2 commits into
mainfrom
feat/browser-a11y-cache
Aug 23, 2026
Merged

feat(browser): uid-addressable AX snapshots; prompt-cache break-even gate#237
Patel230 merged 2 commits into
mainfrom
feat/browser-a11y-cache

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

The final two caveman-family adoptions, completing the approved set.

A. Accessibility snapshots — internal/a11y + Browser tool

  • Compress Chrome's real accessibility tree (CDP getFullAXTree) into a compact indented tree; actionable roles carry stable uid handles, layout containers drop, iframes render as leaves under site isolation.
  • Query mode: ranks actionable nodes against the query, keeps ≤12 matches + ancestor chains; non-matching branches pruned wholesale via subtree-containment marking.
  • Fail-closed (caveman-browse fix: update alpine base image to 3.23.5 for Trivy scan compliance #140 rule): when compression does not shrink the representation the raw tree is never dumped — prior uids stay valid; ignored nodes never leak; canonical raw payload retained for recovery.
  • Integration: new ax_snapshot action; click/type accept uid (CDP DOM.resolveNodeRuntime.callFunctionOn: scrollIntoView+click / focus+execCommand-insertText with direct-value fallback) alongside legacy selectors; non-wait actions report settled:false.

B-lite. Prompt-cache break-even gate — internal/engine/cache_gate.go

  • Caching follows measured economics rather than a hardcoded provider check: enabled only for anthropic when system+tools prefix ≥ ~8 KiB (~2k tokens) — where one reuse beats paying the write premium twice. Below break-even it stays OFF. Full segment planning/key-sharding remains future eyrie work.

Testing

  • New: a11y suite (6 tests: uid assignment, query pruning, fail-closed, iframe leaf rule, ignored-skip, raw-retention), cache-gate suite (5)
  • Existing BuildOptions test updated to the break-even contract
  • Full tool/engine suites pass; golangci-lint 0 issues; go build ./... clean

…gate

Two final caveman-family adoptions:

Accessibility snapshots (internal/a11y + Browser tool):
- Compresses Chrome's real accessibility tree (CDP getFullAXTree) into a
  compact indented tree where actionable nodes (button/link/textbox/
  checkbox/menuitem/tab/...) carry stable uid handles; layout containers
  are dropped, iframes render as leaves under site isolation.
- Query mode ranks actionable nodes against the query and keeps at most
  12 matches plus ancestor chains, pruning whole non-matching branches
  via subtree-containment marking.
- Fail-closed per caveman-browse issue #140: when compression does not
  actually shrink the representation the raw tree is NEVER dumped — the
  previous uid map stays valid and an error explains why. Ignored nodes
  never leak; raw canonical payload is retained for recovery.
- New ax_snapshot action; click/type accept uid (resolved through CDP
  DOM.resolveNode + Runtime.callFunctionOn: scrollIntoView+click /
  focus+execCommand insertText with direct-value fallback) alongside the
  legacy selector path. Non-wait actions report settled:false and ask
  for a confirming re-snapshot.

Prompt-cache break-even gate (internal/engine/cache_gate.go):
- Provider-native caching now follows measured economics instead of a
  hardcoded provider check: enabled only for anthropic when the stable
  prefix (system prompt + serialized tool catalog) reaches ~8 KiB (~2k
  tokens), the point where one reuse beats paying the write premium
  twice. Below break-even caching stays OFF. Full segment planning and
  key-sharding remain future eyrie work.

Existing BuildOptions test updated to the break-even contract.

Verification: new suites green (a11y 6, cache gate 5); tool/engine
suites pass; golangci-lint 0 issues; go build clean.
@Patel230
Patel230 merged commit 2809ddb into main Aug 23, 2026
26 checks passed
@Patel230
Patel230 deleted the feat/browser-a11y-cache branch August 23, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant