Menu
GitHub Engineering·August 24, 2026

Designing an Automated Accessibility Checker: Trade-offs in Alt Text Validation

This article discusses the architectural and design decisions behind building an automated accessibility checker, specifically for validating alt text quality. It highlights the challenges of automating qualitative checks, the trade-offs between false positives and reliability, and how to integrate AI models while managing privacy, cost, and consistency. The discussion on deterministic rules versus AI-driven heuristics, and the handling of data flow, is particularly relevant to system design.

Read original on GitHub Engineering

The Challenge of Automated Quality Checks

Automating the quality assessment of something subjective, like alt text, presents a significant system design challenge. While simply checking for the *presence* of an `alt` attribute is trivial, determining if the text is *useful* or *accurate* requires more sophisticated logic. The core design philosophy here is to distinguish between what can be proven deterministically and what can only be suspected or inferred, often requiring human-like judgment or contextual understanding.

Deterministic vs. Heuristic Rules

The checker employs a two-tiered approach to alt text validation. The first tier consists of deterministic rules that run by default, are cheap, predictable, and don't require external calls. These rules target objective flaws in alt text strings themselves, without needing image content or page context. Examples include checking for absent/whitespace-only alt text, raw filenames, placeholders (e.g., "TODO"), generic words ("image", "logo"), or repeated alt text on adjacent images.

  • Absence/Whitespace-only: The attribute is missing or contains only whitespace.
  • Filenames: The alt text is a raw filename like `hero.png`.
  • Placeholders: Generic placeholders such as `TODO` or `tbd`.
  • Generic words: Undescriptive terms like `image`, `logo`, `chart`.
  • Repeated alt text: The same alt text across visually adjacent images.
💡

Design Principle: Reliability over Completeness

A key design decision was to prioritize reliability and low false positives over catching every possible issue. A checker that frequently flags correct content will be disabled by users. This means deliberately missing some bad alt text to ensure the rules that *are* enabled provide high-confidence findings. This trade-off is crucial in any automated quality gate.

Integrating AI Models for Contextual Judgments

For subjective quality checks that require understanding the image content and surrounding page context, an opt-in AI vision model is utilized. This model receives the image, its alt text, and relevant page context (headings, page title, captions, nearby prose, link status). The system design for integrating this model addresses several critical aspects:

  • Privacy and Cost: Sending images and page content to an external model necessitates careful data flow design. URLs are redacted, and sensitive information is stripped before transmission. It's an opt-in feature due to privacy concerns and the computational cost associated with external API calls.
  • Model Consistency: Early versions suffered from the model's tendency to always suggest improvements. This was mitigated by implementing a strict decision procedure (e.g., decorative, redundant, functional, informative), explicit anti-nitpick rules, and structured output to force reasoned verdicts.
  • Context Gathering: Extracting accurate context is vital. The system gathers data like nearest headings, page title, `figcaption` content, and whether the image is within a link, as the latter changes the expected alt text's purpose (destination vs. description).

Handling Layout for 'Repeated Alt Text' Rule

A notable architectural choice was realizing that detecting repeated alt text isn't a DOM traversal problem but a layout problem. Simply checking `img` tags in document order can lead to false positives if images are far apart visually but close in the markup. The solution involves checking the bounding boxes of images on the screen and only flagging repetitions where images are visually close (gap between bounding boxes is small relative to image dimensions), demonstrating a design focus on user experience over raw data representation.

accessibilityautomated testingstatic analysisAI integrationsystem designarchitecturequality gatestrade-offs

Comments

Loading comments...