4.1 Stage 1: Deterministic DOM Geometry Gate
chinwag ui-gate --url http://localhost:8080 --surfaces 16How chinwag ui-gate evaluates 11 mathematical bounding-box, typography, and contrast invariants across 8 viewports and 2 themes in under 900ms locally at 0 Cr.
4.1 Stage 1: Deterministic DOM Geometry Gate
chinwag ui-gate --url http://localhost:8080 --surfaces 16
✅ Available Now (
v0.1.0·CHWG-PUB-105): Stage 1 (verify-ui-geometry.py·176/176deterministic 12-tuple DOM physics assertions across8viewports and2color themes in<900msat0 Credits) is shipped and verified inv0.1.0. See/api/reality-matrixand the Chinwag Public Roadmap.
AI coding agents write valid JSX, Vue, and CSS that compiles without warnings and passes unit tests · yet renders broken layouts in a real browser. Hero headings wrap to four lines at 1024px, navigation pills collide on 768px tablets, sticky topbars obscure anchor targets, and light-mode muted text drops below WCAG AA contrast.
chinwag ui-gate solves this with a three-stage visual verification pipeline (WP-12). Stage 1 runs locally inside headless Chromium in under 900ms at 0 Cr (free), evaluating 11 deterministic DOM physics invariants across 8 standard viewports and 2 color themes (Midnight + Daylight) = 176 / 176 cell assertions.
chinwag ui-gate --url http://localhost:3000 --matrix 8x2 --stage 1
The 12-Tuple DOM Element Descriptor
Before evaluating layout invariants, Stage 1 injects a zero-dependency measurement probe into the live Chromium layout tree (document.querySelectorAll('*')) and extracts a compact 12-tuple geometric descriptor for every visible interactive, typographic, and container node:
pub struct DomGeometryTupleV1 {
pub selector_hash: u64, // 1. Canonical CSS path hash (BLAKE3-64)
pub role_class: ElementRoleV1, // 2. Heading | Body | Interactive | Nav | Sticky | Card | Media
pub x: f32, // 3. Sub-pixel clientRect.left
pub y: f32, // 4. Sub-pixel clientRect.top
pub width: f32, // 5. Sub-pixel clientRect.width
pub height: f32, // 6. Sub-pixel clientRect.height
pub scroll_width: f32, // 7. scrollWidth (horizontal overflow detector)
pub line_box_count: u16, // 8. Exact rendered text line count via getClientRects()
pub font_size_px: f32, // 9. Computed font-size in CSS pixels
pub contrast_apca_wcag: f32, // 10. Effective foreground/background WCAG 2.2 contrast ratio
pub z_stack_tier: i32, // 11. Effective stacking context & z-index tier
pub hit_target_min_px: f32, // 12. Minimum interactive touch/click dimension (min(w, h))
}
The 8 × 2 Viewport & Theme Matrix (16 Render Surfaces)
Every run sweeps 8 canonical device viewports across both Midnight (dark) and Daylight (light) color schemes:
| Viewport ID | Dimensions (W × H) | Device Class | Primary Failure Modes Caught |
|---|---|---|---|
V1_ULTRAWIDE | 1920 × 1080 | 27" Desktop Monitor | Unbounded prose measure (> 75ch), stretched flex cards |
V2_DESKTOP | 1440 × 900 | 15"/16" Laptop | Sticky header height overflow (> 56px), multi-column card baseline drift |
V3_LAPTOP_SM | 1280 × 800 | 13" Laptop | Topbar nav item collisions, sidebar + TOC squeeze |
V4_TABLET_LAND | 1024 × 768 | Tablet Landscape | Grid-to-stack breakpoint orphans, 4-line hero wrapping |
V5_TABLET_PORT | 768 × 1024 | Tablet Portrait | Horizontal table overflow (scrollWidth > innerWidth) |
V6_MOBILE_LG | 430 × 932 | Large Phone | Fixed CTA bar covering footer links, clipped code blocks |
V7_MOBILE_STD | 390 × 844 | Standard Phone | Touch targets < 32px, clipped modal dialogs |
V8_MOBILE_SE | 375 × 812 | Compact Phone | Long unbroken tokens/URLs forcing horizontal scrollbars |
The 11 Deterministic Invariants (16 Surfaces × 11 Invariants = 176/176)
For each of the 16 viewport-theme surfaces, Stage 1 verifies all 11 mathematical invariants:
| # | Invariant ID | Mathematical Contract | Default Threshold |
|---|---|---|---|
| 1 | GEO-01-ZERO-HORIZ-BLEED | document.documentElement.scrollWidth <= window.innerWidth | 0px tolerance across all 8 viewports |
| 2 | GEO-02-TOPBAR-BUDGET | Sticky <header> height H_header <= 56px and line_box_count == 1 on desktop | <= 56px |
| 3 | GEO-03-SIBLING-DISJOINT | Sibling interactive controls (a, button, input) have intersection area Area(A ∩ B) == 0 | 0 sq px overlap |
| 4 | GEO-04-HEADING-LINE-CAP | Display <h1> line count <= 3 (>= 1024px) and <= 4 (< 1024px) | 3 / 4 lines max |
| 5 | GEO-05-PROSE-MEASURE | Body copy <p> and <li> line width stays within readable measure [45ch, 78ch] on desktop | 45ch .. 78ch |
| 6 | GEO-06-CONTRAST-FLOOR | Body text contrast >= 4.5:1 (WCAG AA) and large display text >= 3.0:1 in both Midnight and Daylight | 4.5:1 / 3.0:1 |
| 7 | GEO-07-HIT-TARGET-MIN | Interactive buttons, nav links, and toggles meet minimum target bounds (height >= 32px desktop, >= 36px mobile) | 32px / 36px |
| 8 | GEO-08-CARD-GRID-ALIGNMENT | Equal-row CSS Grid / Flex sibling cards align top/bottom edges within <= 1.5px sub-pixel tolerance | <= 1.5px |
| 9 | GEO-09-STICKY-OCCLUSION | Focused elements and :target anchors are never occluded by `position: sticky | fixed chrome (scroll-margin-top` verified) |
| 10 | GEO-10-CODE-TABLE-SCROLL | Wide <pre> and <table> containers capture horizontal scroll internally (overflow-x: auto) without stretching the page viewport | Contained scroll |
| 11 | GEO-11-TABULAR-NUMERALS | Numeric badges, prices, metrics, and table cells enforce font-variant-numeric: tabular-nums to prevent jitter | tabular-nums |
Stage 1 CLI Output Example
When a layout bug occurs on a single breakpoint, chinwag ui-gate pinpoints the exact selector, viewport, theme, and sub-pixel coordinates:
$ chinwag ui-gate --url http://localhost:3000/pricing --stage 1
[ui-gate] Sweeping 8 viewports × 2 themes (16 surfaces × 11 invariants = 176 checks)...
✗ FAIL [GEO-01-ZERO-HORIZ-BLEED] at V8_MOBILE_SE (375×812 · Daylight)
Selector: section.pricing-matrix > table.credit-schedule
Measured: document.scrollWidth = 442px > window.innerWidth = 375px (+67px overflow)
✗ FAIL [GEO-06-CONTRAST-FLOOR] at V2_DESKTOP (1440×900 · Daylight)
Selector: .tier-card .muted-footnote
Measured: contrast = 3.41:1 < 4.50:1 required (#7A8291 on #F4F2ED)
[ui-gate] Result: 174/176 PASSED (2 deterministic geometry failures in 640ms · 0 Cr)
Next Step: Multimodal Vision-3 Inspection & Auto-Patch
Once Stage 1 (176/176) passes, chinwag ui-gate advances to Stage 2 and Stage 3 (Chinwag Vision-3 visual geometry audit and CSS auto-patch synthesis).
- Next: Stage 2 & 3: Chinwag Vision-3 Visual Geometry & CSS Auto-Patch
- Ready to automate UI verification across your repo? Reserve Your Organization Credit Pack →
3.4 Trusted Handoff Hooks & Independent Verification
Deep dive into Hooks H1..H5, why a 1-byte post-review edit triggers WP-04 Stale Evidence, and why Policy Satisfied never grants automatic merge authority (WP-06).
Vision-3 Geometry & Auto-Patch
Patent-pending 3-stage visual bug detection and autonomous CSS/HTML patch synthesis powered by Chinwag Vision-3.