OAuth browser-consent DRIVER: the deterministic replay of the consent clicks (classify_page + next_action + to_screen), driving browser-test for observation and xdotool for hardware actuation. Token minting is NOT this tool's job — the consent URL comes in, the driver clicks through, and completion is the tab reaching the loopback redirect; the token is minted by the existing adapters-google-gmail authorize flow (examples/authorize.rs). Design: docs/architecture/oauth-consent-tool-plan.md. Live run is operator-gated.
| Tier | tools |
| Role | unclassified (baselined) |
| Path | crates/tools/oauth-consent |
| Edition | 2021 |
| Targets | tools-oauth-consent, tools_oauth_consent |
| Public items | 17 across 0 modules |
| Tests | 15 |
What it is for
tools-oauth-consent — the pure perception core of the browser-consent tool.
Two functions, both I/O-free and deterministic, are the seam between the model-derived flow and the deterministic replay (design: docs/architecture/oauth-consent-tool-plan.md, §8):
to_screen— turn an element's viewport rectangle plus the window
geometry into a screen-device-pixel click point (§8.1). The transform was solved from three click/rect pairs captured live, not tuned by eye.
classify_page— turn an observation of a page (its visible text, a
checkbox-present flag, and whether the loopback listener already has the code) into one PageState (§8.2). Exact, ordered predicates.
Everything here is observation → decision. Actuation (the click), transport (tools-browser-test, the loopback listener), and the authorize protocol live in the driver, not this crate.
Capabilities
crate root
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
fn to_screen(r : & Rect, w : & WindowGeom) ->(i64, i64) |
fn classify_page(obs : & PageObservation) -> PageState |
fn consent_host(url : & str) -> & str |
fn tab_id_for_host(list_data : & Value, host : & str) -> Option <i64> |
fn url_of_tab(list_data : & Value, tab_id : i64) -> String |
Action
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub enum Action |
fn next_action(state : PageState) -> Action |
ElementRect
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub struct ElementRect |
ElementRect :: fn rect(& self) -> Rect |
fn find_button <'a>(els : & 'a ElementRect, label : & str) -> Option <& 'a ElementRect> |
PageObservation
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub struct PageObservation<'a> |
PageState
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub enum PageState |
Rect
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub struct Rect |
fn rect_center(r : & Rect) ->(f64, f64) |
fn parse_rects(data : & Value) -> Option <(Vec <ElementRect>, WindowGeom)> |
WindowGeom
tools-oauth-consent — the pure perception core of the browser-consent tool.
| Item |
|---|
pub struct WindowGeom |
fn to_screen_point(vx : f64, vy : f64, w : & WindowGeom) ->(i64, i64) |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct Rect | An element's viewport rectangle in CSS pixels, as reported by the element_rects browser command. |
pub struct WindowGeom | Browser window geometry, reported alongside the rects |
fn rect_center(r : & Rect) ->(f64, f64) | Center of a rect in viewport CSS pixels. |
fn to_screen_point(vx : f64, vy : f64, w : & WindowGeom) ->(i64, i64) | Screen device-pixel point for a viewport CSS-pixel point, given the window geometry (design §8.1) |
fn to_screen(r : & Rect, w : & WindowGeom) ->(i64, i64) | Screen device-pixel click point for an element rect: its center, transformed by to_screen_point. |
pub enum PageState | The page states the consent driver distinguishes |
pub struct PageObservation<'a> | What the driver observes about a page: the joined visible text, whether a checkbox role is present, and whether the loopback listener has already received the authorization code (decided out of band). |
fn classify_page(obs : & PageObservation) -> PageState | Classify a page from its observation (design §8.2) |
pub enum Action | The action the driver takes for a page state (design §8.2/§8.3) |
fn next_action(state : PageState) -> Action | Map a classified page state to the driver's next action |
pub struct ElementRect | One element from a get_element_rects response: its trimmed text and viewport rect |
ElementRect :: fn rect(& self) -> Rect | The rect (drops the text) for to_screen. |
fn find_button <'a>(els : & 'a ElementRect, label : & str) -> Option <& 'a ElementRect> | The element whose trimmed text is exactly label (case-insensitive), never the "Back to safety" decoy (design §8.3) |
fn consent_host(url : & str) -> & str | Host (authority) of a URL — the part between // and the next / |
fn tab_id_for_host(list_data : & Value, host : & str) -> Option <i64> | From a list_tabs data object, the id of the LAST tab whose url contains host (or google.com) — most recent match wins. |
fn url_of_tab(list_data : & Value, tab_id : i64) -> String | From a list_tabs data object, the url of the tab with tab_id ("" if absent). |
fn parse_rects(data : & Value) -> Option <(Vec <ElementRect>, WindowGeom)> | Parse a get_element_rects data object into (elements, window geometry) |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | tools |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/tools/oauth-consent |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
anyhow | ^1 | — | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| bin | tools-oauth-consent | `src/main.rs` |
| lib | tools_oauth_consent | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
API_KEY | src/main.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 15 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 16 | 0 | 0 |
What the tests establish, by name:
consent_host_slices_the_authority—src/lib.rsdpr_scales_css_to_device_px—src/lib.rsfind_button_matches_exact_label_and_skips_back_to_safety—src/lib.rsinterstitial_and_chooser_signatures—src/lib.rsloopback_code_outranks_any_page_text—src/lib.rsnext_action_is_total_over_states—src/lib.rsno_signature_is_unknown_and_matching_is_case_insensitive—src/lib.rsparse_rects_needs_window_and_defaults_empty_elements—src/lib.rsrect_center_and_to_screen_compose—src/lib.rsscopes_requires_both_text_and_checkbox—src/lib.rssign_in_actions_map—src/lib.rssign_in_pages_classify_by_field_password_before_email—src/lib.rstab_id_takes_the_last_match_and_url_lookup_is_exact—src/lib.rsto_screen_point_matches_the_three_derived_vectors—src/lib.rstransform_decomposes_into_border_and_chrome—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 17 | 17 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 17
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 861 |
| Code lines | 660 |
| Public API items | 17 |
| Public modules | 0 |
| Tests | 15 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"enum" : 2
"function" : 10
"method" : 1
"struct" : 4
pie showData
title Rust source composition
"Code" : 660
"Blank or comment" : 201
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.