Generated banner for Accessibility
Generated logo for Accessibility

Accessibility

MicrosoftOfficialPublished by Microsoft

  • Skill
  • Tool integration
  • Software development
  • MIT
  • Low risk
  • Has scripts

From the author

Consolidated accessibility skill entrypoint for WCAG 2.2, ARIA Authoring Practices, cognitive accessibility, Section 508, EN 301 549, design intent verification, and the Accessibility Planner workflow.
— the description by Microsoft

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The accessibility skill provides a structured approach to managing accessibility requirements across the development lifecycle. It includes a six-phase Accessibility Planner workflow, a command-line scanner for static analysis, and a runtime probe harness for verifying interaction-based accessibility. The skill enforces a doctrine of method adequacy, ensuring that verification methods are only used to decide criteria they are capable of observing, and supports the generation of evidence bundles for review.

What it does

  • Provides a six-phase workflow for accessibility discovery, planning, and backlog handoff.
  • Wraps the axe-core CLI to perform static accessibility scans on web pages.
  • Executes Playwright-based runtime probes to verify interaction behavior and screen-reader announcements.
  • Enforces method adequacy rules to distinguish between static findings and interaction-based verification.
  • Generates deterministic evidence bundles for accessibility reviews and reporting.
  • Maps findings to WCAG 2.2, ARIA Authoring Practices, and other accessibility standards.

When to use it

  • When planning accessibility requirements for a new project or feature.
  • When performing automated static scans of web content for common accessibility defects.
  • When verifying complex interaction behaviors that static analysis cannot fully evaluate.
  • When building an evidence register to track accessibility conformance across development phases.

Advantages

  • Standardizes accessibility verification across different projects and teams.
  • Prevents over-reliance on static analysis for complex interaction-based criteria.
  • Supports tiered enforcement postures to match project risk and maturity.
  • Integrates with standard CI workflows for automated accessibility testing.

Usage examples

“Scan my local file index.html for accessibility violations.”
The skill runs the axe-core scanner against the file and outputs a normalized JSON report of findings.
“Run the accessibility runtime probes for my project.”
The skill executes the configured Playwright probes and aggregates the results into a coverage matrix.

Install

Documentation by Microsoft

Accessibility — Skill Entry

This skill is the canonical accessibility reference contract for HVE Core. Agents and instructions invoke this skill by name and rely on it to own framework reference resolution, phase guidance resolution, and the scanner CLI entrypoint.

Framework references

Assessment reference (cross-cutting, not a conformance framework):

  • Assistive-technology announcement model — read this when deciding the announcement-class criteria (WCAG 1.3.1, 4.1.2, 4.1.3): what a screen-reader user should hear, and how to decide it with an accessibility-tree assertion or a manual AT pass.

Accessibility Planner workflow

The Accessibility Planner runs six phases, each keyed to a state id:

  1. Phase 1 — Discovery (discovery)

  2. Phase 2 — Framework Selection (framework-selection)

  3. Phase 3 — Standards Mapping (standards-mapping)

  4. Phase 4 — Plan Risk Assessment (plan-risk-assessment)

  5. Phase 5 — Impact and Evidence (impact-evidence)

  6. Phase 6 — Backlog Handoff (backlog-handoff)

Phase reference index

  • Phase 1 — Discovery: capture-coaching.md — read this when running exploration-first capture questioning.

  • Phase 2 — Framework Selection: framework-selection.md — read this when choosing which frameworks and conformance level apply.

  • Phase 3 — Standards Mapping: walk the framework references roll-up tables to emit controlMappings; consumed by Phase 5. No dedicated file — mapping is driven by the framework roll-ups.

  • Phase 4 — Plan Risk Assessment: capture-coaching.md governs the questioning posture when escalation triggers reopen scoping; tier criteria are applied per the Accessibility Planner identity instructions and recorded as riskClassification.tier. No dedicated file — the accessibility risk surface is narrow enough to stay inline.

  • Phase 5 — Impact and Evidence: impact-assessment.md — read this when building the evidence register, tradeoff log, and seed work-items.

  • Phase 6 — Backlog Handoff: backlog-handoff.md — read this when rendering work items and validating handoff gates.

Method adequacy (decide vs inform)

Method adequacy is the doctrine that a verification method may only be recorded as satisfying a success criterion when that method can actually decide the criterion. A method that can observe a related signal but cannot confirm the user-facing outcome only informs the criterion; it raises or lowers suspicion but never closes it. This section is the canonical definition; the planner evidence register, the reviewer verdict logic, and the runtime probe harness all resolve adequacy through it.

The machine-readable adequacy source is scripts/runtime_a11y/probe-criteria-map.json. Each probe entry lists the criteria it decides and the criteria it only informs. A result counts as adequate only when the winning method appears in the decides list for that criterion and state.

Failure classes and adequate methods

Accessibility defects generalize into five classes. Static analysis (axe, eslint-plugin-jsx-a11y, snapshot structure counts) can decide only the first class; the remaining four require an interaction-state probe or an assistive-technology (AT) pass to be decided rather than merely informed.

ClassRepresentative WCAG SCWhat static analysis can doAdequate method to decide
Static-decidable structure1.1.1, 1.4.3, 4.1.2 (name present), 2.4.2, 3.1.1Decideaxe / static scan
Interaction behavior2.1.1, 2.1.2, 2.4.3, 2.4.7, 2.4.11Inform onlyKeyboard/interaction probe driving keys across focus/open states, or manual keyboard pass
Announcement correctness1.3.1, 4.1.2 (computed name/role), 4.1.3Inform onlyAccessibility-tree assertion of computed name/role/live, or manual AT pass (Windows NVDA or human-led JAWS)
Adaptive rendering1.4.4, 1.4.10, 1.4.12, 2.4.11Inform onlyRendered probe at 200% zoom, 320px reflow, and text-spacing states
Faux semantics1.3.1 (faux headings), 2.4.3 (faux controls)Cannot seeHeuristic source pass plus accessibility-tree assertion; no element exists for a rule engine to flag

For the announcement class, the assistive-technology announcement model specifies what the user should hear per criterion and how to decide it. For the interaction and faux-semantics classes, the focus-management anti-pattern catalog enumerates the defects that pass a static scan yet break keyboard and screen-reader users.

Adequacy rule
  • A control in the interaction, announcement, adaptive-rendering, or faux-semantics classes cannot be recorded as fully satisfied on static evidence alone. Static evidence caps such a control at a partial state until an adequate method is attached.

  • A criterion whose winning method only informs it is never a conformance verdict; it is a lead that routes to an adequate method or a manual pass.

  • Preserve the adequacy determination alongside the status so downstream planners and reviewers do not re-promote an inadequately verified control.

This doctrine and its class taxonomy are repository-original content licensed under CC BY 4.0; the underlying success-criterion definitions remain with WCAG 2.2 as cited in wcag-22.md.

Calibration is evidence quality, not a conformance verdict

Calibration establishes that the assistive-technology stack behaves as expected before its output is trusted. Its checkpoints record driver identity, profile fingerprint, and artifact hashes for a journey that passed.

A checkpoint is deliberately not a matrix input. Nothing in the coverage or outcome pipeline reads one, and that separation is intended rather than unfinished. A passing calibration says the harness was working; it does not say the surface satisfies a success criterion. Wiring checkpoints into coverage would turn a statement about the tool into a statement about the product.

If calibration evidence should ever influence coverage, that is new design work requiring its own review: it needs an explicit mapping from a journey to a criterion, surface, and state, and it must respect the same method-adequacy rules as any other evidence.

Gate strictness by assessment tier

The enforcement posture for the interaction, announcement, adaptive-rendering, and faux-semantics classes graduates with the assessment depth tier recorded in riskClassification.tier, so the gate inherits the rigor a project opted into rather than applying one global switch:

  • basic — the adequate-method probes (keyboard, widget-keyboard, live-region, aria-tree, virtual-sr) report advisory (warn-only); the always-decidable core probes still block.

  • standard (default) — ratchet: the adequate-method probes block on new or changed surfaces and stay advisory over the existing backlog, so no new defect in these classes ships while legacy content is surfaced without freezing the project.

  • comprehensive — the adequate-method probes block on every in-scope surface.

The always-decidable core probes (axe, DOM hygiene, broken links, console errors, target size, contrast, reflow/resize) block at every tier. The CI workflow template implements this dial through the A11Y_TIER and A11Y_RATCHET_SURFACES inputs; the Accessibility Reviewer applies the same graduation to its FAIL and PARTIAL verdicts.

Tooling

The scanner CLI (scripts/scan.py) wraps the Node-based axe-core scanner and normalizes its findings into a stable JSON shape.

Prerequisites
  • Python 3.11+ with uv available on PATH.

  • Node.js with npx available on PATH.

  • Network access on first run so npx can fetch @axe-core/cli.

Quick Start
uv run scripts/scan.py https://example.com --allow-host example.com
uv run scripts/scan.py ./page.html --output results.json
uv run scripts/scan.py file:///path/to/page.html

Loopback HTTP(S) targets need no additional option. Every other remote host requires either a matching, repeatable --allow-host HOST value or the broader --allow-external confirmation. Local paths and local file: URIs must resolve to existing regular files. Network shares, remote file authorities, directories, missing files, credentials, leading-dash targets, and non-HTTP(S) remote schemes are rejected before the axe CLI starts.

Parameters Reference
ParameterRequiredDefaultDescription
targetYes—Authorized HTTP(S) URL or existing regular local file to scan.
--outputNostdoutPath to write the normalized JSON results.
--allow-hostNononeAuthorize one non-loopback HTTP(S) host; repeat as needed.
--allow-externalNofalseConfirm access to any non-loopback HTTP(S) host.

Remote authorization applies to the initial scanner target only. It does not constrain browser redirects, DNS address changes, subresources, WebSockets, Service Workers, downloads, or other browser-derived requests. Run the scanner only from a workstation whose network reach matches the target's trust level.

Script Reference
  • Entrypoint: scripts/scan.py

  • Output shape:

    {
      "target": "<scanned target>",
      "summary": {
        "violations": 0,
        "passes": 0,
        "incomplete": 0,
        "inapplicable": 0
      },
      "violations": [
        { "id": "", "impact": "", "description": "", "nodes": 0 }
      ]
    }
  • Exit codes:

    • 0 — scan completed successfully.

    • 1 — scan failed or returned invalid output.

    • 2 — scanner unavailable (Node.js or @axe-core/cli missing).

Troubleshooting
SymptomLikely causeActionExit code
scanner unavailable errorNode.js or npx not on PATHInstall Node.js so npx resolves, then re-run.2
Long pause or download on first runnpx is fetching @axe-core/cliAllow network access on the first run; later runs use the cache.—
Refusing to probe non-loopback hostRemote host was not explicitly authorizedAdd --allow-host HOST or confirm with --allow-external.2
Local scan target does not existLocal path or file URI cannot be resolvedSupply an existing regular local file, not a directory or share.2
scan failed or returned invalid outputaxe-core CLI errored or emitted non-JSONConfirm the target URL or file is reachable and well-formed.1
Empty violations but issues expectedPage rendered after the scan, or rules N/AConfirm the target fully loads; check summary.inapplicable.0
Mapping findings to frameworks

Each violation's impact is one of minor, moderate, serious, or critical. axe rule tags decode to WCAG success criteria by stripping the wcag prefix and inserting decimals:

axe tagWCAG success criterion
wcag1111.1.1 Non-text Content
wcag1431.4.3 Contrast (Minimum)

WCAG success criteria are normative; the axe techniques that surface them are informative. Treat scanner output as evidence pointing at a criterion, not a conformance verdict.

Runtime probe harness

The runtime probe harness (scripts/runtime_a11y) runs Playwright-based accessibility probes against a project-specific surface inventory and aggregates the results into a coverage matrix. For workflow orchestration, ask the user to run the manual-only accessibility-coverage-matrix skill (/accessibility-coverage-matrix); it is not model-invocable. Use the Accessibility Surface Inventory subagent as the canonical producer of the runtime config. Activate it by name; when it does not resolve, warn the user that the capability is unavailable and stop the dependent step.

Harness prerequisites

Complete these once before any runtime-harness command. They are separate from the scan.py prerequisites above.

  • Python 3.11+ with uv available on PATH.

  • Node.js available on PATH, plus system Google Chrome, because the probes target channel: 'chrome'.

  • Skill-local Node dependencies installed under scripts/runtime_a11y. The CLI fails fast with an install hint when they are missing.

  • Automated Windows NVDA runs additionally require the manifest-selected Guidepup NVDA asset. Machine setup and asset installation are separate actions from npm ci.

Install the harness dependencies from the scripts/runtime_a11y directory:

PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = '1'; npm ci

PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 avoids downloading bundled browsers that the harness never uses.

For automated NVDA runs, prepare the Windows machine once, then install the asset selected by the skill-local Guidepup package. Run the asset command again after updating Guidepup:

Set-Location <skill-root>/scripts/runtime_a11y
npx --yes --registry=https://registry.npmjs.org/ @guidepup/[email protected] setup
npx --yes --registry=https://registry.npmjs.org/ @guidepup/[email protected] install nvda

The commands configure the machine and write versioned assets to the Guidepup user cache. They are not part of ordinary dependency installation. Run the prerequisite-only probe before a calibration session:

uv run scripts/runtime_a11y/__main__.py run-calibration --config <path-to>/a11y-runtime.config.json --prerequisite-only

The preflight reports the skill-local library, manifest-selected NVDA asset, and any conflicting NVDA process independently. Do not start a personal NVDA instance before an automated run; the harness starts an isolated session and rejects an existing process.

Product-neutral screen-reader cases live in scripts/runtime_a11y/screen-reader-cases.json. A downstream binding supplies named routes, targets, states, and explicit execution recipes. Catalog digest drift, missing target closure, duplicate identities, unsupported commands, secret-bearing binding keys, and inferred actions fail before browser startup.

Use repeatable run-calibration --journey <id> arguments for an authorized live subset. Run the downstream integrity recipe before product cases and keep real NVDA advisory/manual. For deterministic evidence, use run-all --probe <probe-id> with surface/state filters or a reviewed probeScoping configuration; ordinary run-all must not be treated as permission to start a real screen reader.

Invocation

Run the harness through its script entrypoint. Invoke it from the skill root, which is the directory holding pyproject.toml, so uv resolves the skill's own environment. This matches the invocation convention used by scan.py and the other Python skills, and it needs no PYTHONPATH.

uv run scripts/runtime_a11y/__main__.py run-all --config a11y-runtime.config.json --out results.json
uv run scripts/runtime_a11y/__main__.py probe <probeId> --config a11y-runtime.config.json
uv run scripts/runtime_a11y/__main__.py render-artifacts --matrix coverage-matrix-repo.json --output-dir .copilot-tracking/accessibility/coverage --repo-slug repo
uv run scripts/runtime_a11y/__main__.py compose-evidence --help

To run from any other working directory, pin the skill as the uv project and use the same script path:

uv run --project <skill-root> <skill-root>/scripts/runtime_a11y/__main__.py run-all --config a11y-runtime.config.json --out results.json
  • --config resolves relative to the current working directory.

  • --out writes the aggregated JSON document to disk.

  • --base-url overrides the configured base URL. It must remain a loopback origin unless the host is allowlisted or --allow-external is supplied.

  • --trace captures Playwright traces and screenshots.

  • --allow-external confirms intentional probing of a non-loopback host.

  • render-artifacts turns a rendered matrix JSON document into the complete coverage evidence bundle.

Evidence bundle composition

compose-evidence combines downstream-owned catalogs, cadence scope, run context, normalized source envelopes, state proofs, and optional qualified-reviewer supplements into one deterministic evidence bundle. It is separate from render-artifacts: rendering creates coverage, EARL, and manual-plan views from a matrix, while composition creates a revision-bound trust envelope across evidence producers.

The command requires explicit input paths and never infers product scope, Git state, time, retention, branch policy, or a release verdict. A consuming project owns those decisions. The composer validates artifact bytes beneath --artifact-root, preserves conflicts and quarantined results, and always emits non-attestation metadata. Automation, reviewer evidence, and release evidence have separate completeness states.

For pull requests, a valid initial bundle may report reviewer evidence as pending. A qualified reviewer can later provide a privacy-minimized, digest-bound supplement and registry snapshot for deterministic recomposition against the prior bundle. Recomposition supplies both --prior-bundle and its independently retained --prior-bundle-digest; omission or mutation of prior history fails closed. Missing required reviewer evidence blocks release completeness, not ordinary bundle production. Raw screen-reader phrases and restricted transcript paths are forbidden in ordinary bundles; only approved counts, redacted metadata, and digests cross this boundary.

Use --require-completeness automated, reviewer, or release only when the downstream workflow intends that dimension to gate. Valid incomplete bundles are still written for diagnosis. The additional exits are:

Exit codeMeaning
5Automated evidence is incomplete.
6Reviewer evidence is pending or invalid.
7Release evidence is incomplete.

Existing exits 0 through 4 retain their meanings. The JSON contracts live beside the runtime at evidence-bundle.schema.json, evidence-source.schema.json, evidence-scope.schema.json, screen-reader-method-cell.schema.json, and qualified-human-result.schema.json.

For a complete adopter path from an inactive template to a first retained bundle and deterministic recomposition, including schema-valid examples for every authored input, read references/evidence-composition-adoption.md.

Visual review capture

capture-visual-review records deterministic screenshot evidence for the configured surfaces and states. It requires visualReview.enabled to be true in the runtime config.

uv run scripts/runtime_a11y/__main__.py capture-visual-review \
  --config <path-to>/a11y-runtime.config.json \
  --run-root .copilot-tracking/accessibility/local-runs/<run-name>
  • --run-root selects the evidence directory. It resolves relative to the repository root and must land on a child path inside .copilot-tracking/accessibility/local-runs. Paths outside that root, and traversal segments, are rejected.

  • Omitting --run-root allocates a timestamped run directory beneath that same root.

  • --visual-surface and --visual-state narrow the capture to specific configured ids.

  • The server the command targets follows serveMode. See Server modes.

Server modes

serveMode in the runtime config decides whether the harness manages a server for capture-visual-review.

serveModeBehavior
autoReuses a healthy server at the configured loopback origin, otherwise builds and starts one it owns and stops afterward.
servedRequires a server already answering the configured loopback origin, and fails with the expected origin and start command when none responds.
externalNever probes or starts a server. The configured target must already be reachable.
offNever probes or starts a server.

auto and served accept only loopback origins, because the harness will not manage or health-probe a remote server. A non-loopback target still requires the allowlist or --allow-external, and is only valid with external or off.

Under auto, starting an owned server builds the site first, so a capture that has to start its own server takes several minutes before the first screenshot. Leave a server running at the configured origin to skip that cost, which is the reuse path.

The Docusaurus site in this repository is configured for auto at http://127.0.0.1:3001, which is the same production-build origin the Playwright end-to-end suite uses. Capturing against the production build keeps visual evidence consistent with what continuous integration verifies.

Config summary

The harness loads scripts/runtime_a11y/config-schema.json and expects a runtime config with fields such as baseUrl, serveMode, allowlist, routes, surfaces, and probeScoping. The config defines the surfaces and interaction states the probes execute. A runtime guard blocks non-loopback targets unless the host is allowlisted or the caller supplies --allow-external. serveMode controls server ownership for visual review capture, described under Server modes.

Real-NVDA journeys support three capture modes:

  • single reads the cumulative speech log after commands and the configured settle interval.

  • clear-and-capture clears earlier speech before the settle interval, then reads the cumulative log.

  • action wraps an existing post-start declarative trigger with Guidepup action capture. Assertions can select actionSpeech or actionNormalizedSpeech to evaluate only output attributed to that trigger.

Action capture waits for Guidepup's one-second speech quiet window. It is appropriate for immediate interaction-driven announcements but does not extend to arbitrary delayed updates and cannot create speech that NVDA does not emit. Keep single, clear-and-capture, accessibility-tree evidence, and manual AT evidence available for those cases. Action mode fails closed when the journey lacks triggerAfterDriverStart, a declarative trigger, a real Guidepup driver, or action-capture support.

Probe inventory and adequacy map

The harness currently includes these probes under scripts/runtime_a11y/runner:

WCAG and ARIA APG probes:

  • probe-axe

  • probe-keyboard-traversal

  • probe-focus-visible

  • probe-focus-obscured

  • probe-live-region

  • probe-aria-tree

  • probe-widget-keyboard

  • probe-reflow-resize

  • probe-target-size

  • probe-contrast

  • probe-forced-colors

  • probe-reduced-motion

  • probe-structure-crawl

  • probe-name-in-label

  • probe-use-of-color (1.4.1)

  • probe-text-spacing (1.4.12)

  • probe-hover-focus (1.4.13)

  • probe-link-purpose (2.4.4)

  • probe-input-purpose (1.3.5)

  • probe-forms (3.3.2, informs 3.3.1/3.3.3)

  • probe-context-change (3.2.1, 3.2.2)

  • probe-orientation (1.3.4)

  • probe-audio-control (1.4.2)

  • probe-timing (2.2.1)

  • probe-zoom-blocker (1.4.4, informs 1.4.10)

  • probe-virtual-sr (4.1.2 name/role announcement captured from a virtual screen reader's spoken-phrase log; informs 1.3.1)

  • probe-real-sr (real Windows NVDA announcement assertions through a Guidepup adapter; only decides when configured expectations are present and the AT stack is available)

Non-WCAG defect-scan probes (framework defect-scan):

  • probe-console-errors (console/page errors)

  • probe-broken-links (same-origin 404s)

  • probe-dom-hygiene (duplicate ids, positive tabindex, missing/duplicate landmarks)

  • probe-title-lang (empty title, invalid lang)

Method adequacy is encoded in scripts/runtime_a11y/probe-criteria-map.json. Each entry records which criteria a probe can decide and which criteria it can only inform. A result only counts as adequate when the winning method is allowed by that mapping.

Coverage engine outputs

The matrix engine in scripts/runtime_a11y/matrix expands the criterion x surface x state grid, merges updates deterministically, and preserves human-confirmed findings over lower-priority automation. It computes adequate-coverage percentages by framework and overall. The render-artifacts command emits a deterministic bundle containing coverage-matrix-{repo-slug}.json, coverage-matrix-{repo-slug}.md, accessibility-results-{repo-slug}.earl.jsonld, manual-at-testplan-{repo-slug}.md, manual-at-testplan-{repo-slug}.yaml, and accessibility-artifacts-{repo-slug}.json.

The EARL (Evaluation and Report Language) JSON-LD export is the normalized results contract for interoperability with the ACT Rules ecosystem and downstream VPAT or EAA review. Each evaluated cell becomes one stable earl:Assertion that records subject, criterion, state, method, method adequacy, result date, and evidence. A result whose winning method only informs its criterion is earl:cantTell, never a false earl:passed. Inapplicable cells are earl:inapplicable; unevaluated cells are omitted. The paired manual plans contain cells that still require a human-deciding method and provide blank result fields for evidence writeback.

Public ARIA-AT and execution contract

The catalog in scripts/runtime_a11y/aria-at-catalog.json is the repository's documented source of truth for generated AT-oriented cases. Its provenance fields are strict and immutable: each mapping records a local catalog version, a canonical upstream URL, a commit-pinned upstream URL, and the upstream commit SHA used for the reviewed refresh. The repository does not copy upstream assertion tables or prose; it paraphrases official W3C and ARIA-AT intent and cites the source in the generated artifacts.

The current public posture is intentionally conservative. The five starter defaults (modal dialog, checkbox, select-only combobox, menu button, and tabs) are citation-bearing manual-only mappings because the richer AT-mode and quick-navigation semantics that these patterns can require are not faithfully modeled by the current structured command boundary. Runtime overrides may create explicit synthetic contract tests, but those are always non-pass candidate evidence and never accessibility conformance evidence. The resolver uses the documented fallback order of state -> surface -> catalog; commands and assertions are stored as atomic arrays, and an explicit empty array intentionally disables execution for a given case.

Unknown patterns remain generic manual drafts or project-refinement markers rather than a fake automation pass. Equally specific ambiguity is treated as a configuration error before rendering or driver startup. The public CLI exposes render-artifacts as an optional mapping configuration step and run-at-plan as the supported path for listing, selecting, executing, and reporting generated AT cases. The real-driver boundary currently supports Guidepup-backed Windows NVDA automation plus manual-only JAWS and other operator-led flows; synthetic execution is a separate evidence channel and never claims a pass. The generated manual plans stay linked to the shared real screen reader testing runbook, while case-specific commands remain inside the generated plan output rather than being written back into the matrix or coverage artifacts.

The generated manual cases, synthetic or real execution evidence, ACT-style result reasoning, EARL outcomes, and later qualified-human review are distinct layers. The public workflow renders representative fixtures through the documented CLI and inspects the six generated artifacts, but it does not commit golden outputs for the inspection bundle.

Exit codes
  • 0 indicates the harness completed successfully, even when probes reported findings.

  • Non-zero exit codes indicate a harness error such as invalid config, a failed probe, missing Node.js, uninstalled harness dependencies, missing browser support, or a blocked target.

verify-intent adds two design-intent codes that a consuming project's CI can distinguish:

Exit codeMeaningTypical response
3A blocking expectation resolved failedTreat as intent drift; the surface regressed
4A blocking expectation was never evaluatedTreat as coverage drift; the check did not run

The two are separate because a failed check and an unrun check call for different responses. Reusing one code would let missing coverage read as a regression, or pass silently.

Runtime dependencies

The harness resolves its Node dependencies from a skill-local package under scripts/runtime_a11y (package.json plus committed package-lock.json), pinning [email protected], @axe-core/[email protected], @guidepup/[email protected], and optional real-AT integration through @guidepup/[email protected]. Install the Node dependencies and the separately managed NVDA asset as described under Harness prerequisites. The probes then resolve their dependencies from the local node_modules; the CLI fails fast with an install hint when node_modules is absent, before it probes or starts any server.

Testing

The harness is tested in two tiers. Browserless verdict and pure-helper unit tests run under node --test (repo script test:node) and cover the decision logic in runner/_core.mjs (for example virtualSrNameRoleStatus and liveRegionStatus). Browser smoke tests under tests/runtime_a11y/runner/probe-smoke/ launch system Chrome and drive the real capture path against inline fixtures to prove the DOM-to-verdict pipeline, including nameless controls, live-region firing, forced-color computed styles, and CDP accessibility-node structure. They are named *.smoke.mjs so the default browserless run skips them. PR Validation runs them through the CI-owned npm run ci:test:a11y:smoke entry point. Local reproduction requires system Chrome and the skill-local node_modules.

CI regression gate

Use the ready-to-copy workflow template at references/ci/accessibility-coverage.workflow-template.yml as the documentation-first integration point for a target project. Copy it into the target repository's GitHub Actions workflow directory only after the target project commits an a11y-runtime.config.json and has a build/serve path that the template can invoke. Once authored *.intent.yaml records exist, the template fails closed if the config or current-run results are missing.

The template mirrors the Docusaurus workflow recipe by provisioning system Chrome, setting up Node 24 plus Python and uv, building the target, serving it under a configurable base URL, and running the harness script entrypoint with uv run --project pinned at the vendored skill root. The core high-confidence probes always block: probe-axe, probe-dom-hygiene, probe-broken-links, probe-console-errors, probe-target-size, probe-contrast, and probe-reflow-resize. The interaction-state and announcement probes (probe-keyboard-traversal, probe-widget-keyboard, probe-live-region, probe-aria-tree, probe-virtual-sr, probe-real-sr) are the adequate method for the classes static analysis only informs, and their blocking posture follows the A11Y_TIER dial defined under Gate strictness by assessment tier: basic reports them advisory, standard ratchets (blocking on the surfaces listed in A11Y_RATCHET_SURFACES), and comprehensive blocks them everywhere. The remaining heuristic probes such as use-of-color, hover-focus, link-purpose, name-in-label, and focus-* are surfaced as informational results so they can guide follow-up work without blocking initial adoption. The real-screen-reader probe stays advisory by default unless a project opts into it through configured expected assertions and a supported OS/AT stack; it returns candidate when the platform or AT is unavailable rather than pretending a pass or failure. Decisive coverage of the adaptive-rendering class depends on the target committing the zoom-200, reflow-320, and text-spacing states in its a11y-runtime.config.json.

The parity reference at references/ci/probe-spec-parity.md maps each runtime probe to the closest existing Docusaurus e2e spec and highlights gaps where no equivalent spec currently exists.

The references/ci/act-rule-format.md reference documents how the harness's probes, generated test cases, and EARL results align to the W3C ACT Rules Format (applicability, expectation, passed/failed/inapplicable) so results interoperate with the ACT Rules ecosystem and conformance reporting.

Design intent verification

A consuming project can declare what a surface must convey and have CI check that what shipped still matches. The declaration is a Design Intent Record, human-authored and committed at design-intent/<surface-id>.intent.yaml in that project. Each intent states what the surface must communicate, why, and for whom, and binds every claim to a named check.

The authored-record field contract is in references/design-intent/record-contract.md. Read it when authoring or reviewing a record. This section covers verification.

This skill supplies the step that turns a probe run into a verdict against that declaration.

Invocation
uv run --project <skill-root> <skill-root>/scripts/runtime_a11y/__main__.py verify-intent \
  --record design-intent/<surface-id>.intent.yaml \
  --results results.json
  • --record is the authored record. It is never read for anything but its declarations and never rewritten.

  • --results is a results document from run-all.

  • --out overrides the output path, which defaults to design-intent/.verification/<surface-id>.earl.json beside the record.

How results resolve to outcomes

A result row matches an expectation when its surface, state, emitting probe, and criterion all match what the record declares. Because criterion coverage overlaps across probes, the emitting probe is part of the join.

SituationOutcomeMode
Every matched criterion passedpassedautomatic
Any matched criterion failedfailedautomatic
Evidence gathered but not decisivecantTellautomatic
No result row matched the expectationuntestedautomatic
The expectation uses assert: customuntestedmanual

An expectation is one claim over one or more criteria, so the worst criterion outcome governs. Expectations the run did not cover report untested rather than being omitted, which keeps a missing check visible instead of silently absent.

Expectations whose criteria a probe only informs resolve to cantTell in normal operation. That is expected: the probe gathered evidence without settling the claim.

A custom expectation reports untested whether or not the record carries a human override. The adapter records only observed runtime outcome in the artifact. Human override remains authoritative in the record itself and is not merged into the generated artifact outcome.

Interpretation is two-layered by contract, and the generated artifact now carries both layers on every assertion:

  • observedOutcome is the generated artifact field outcome. An override never replaces it.

  • effectiveOutcome applies fail-safe precedence. Either an observed or human failed outcome yields failed; human passed settles only untested, cantTell, or inapplicable; otherwise the observed outcome remains. This is the value the gate applies.

  • overrideConflict is true only when the observed and authored override outcomes are each passed or failed and differ. An override that settles an untested, cantTell, or inapplicable expectation is the documented use, not a conflict.

A conclusive conflict fails closed. verify-intent writes one Warning: line to stderr for each conflicting assertion, names the intent, expectation, observed outcome, and override outcome, and returns design-intent drift when the conflicting expectation blocks.

The shipped Python verifier rejects duplicate YAML keys, validates the complete authored schema, and enforces semantic checks for dates, filename and runtime-config bindings, duplicate identifiers, method pairing, and probe adequacy before writing an artifact. This repository's PowerShell validator independently enforces the same contract for source and generated-artifact validation.

Exit codes
  • 0 — the artifact was written and no blocking expectation failed.

  • 1 — the record or results document was malformed. Nothing is written.

  • 2 — the record or results document could not be read.

  • 3 — the artifact was written and a blocking expectation failed.

  • 4 — the artifact was written and a blocking expectation was never evaluated.

Exit codes 3 and 4 are enforcement signals. A consuming project's CI step fails its build on either non-zero exit, exactly as it would for any other command. The artifact is still written so the run can publish it. Which expectations block is the record's decision, through each expectation's blocking flag.

Graphics and diagram semantics have no runtime probe. Those expectations use assert: custom and resolve through human review; see the Graphics ARIA and SVG-AAM reference for the boundary between what automation can decide and what it cannot.

Rendering a record for review

A record states what must be true and how it is checked, but carries no implementation or delivery scope. Reviewers who want prose rather than YAML can render one:

uv run --project <skill-root> <skill-root>/scripts/runtime_a11y/__main__.py project-intent \
  --record design-intent/<surface-id>.intent.yaml \
  --out handoff.md

Output is deterministic and renders only what the record already says, adding no analysis and no verification results. Generate it on demand rather than committing it, so it cannot drift from the record it describes. Without --out the Markdown goes to stdout.

Usage notes

  • Treat this skill as the default accessibility entrypoint for planning and review workflows.

  • Resolve framework and phase guidance through this skill instead of duplicating its internal reference paths in agents or instructions.

  • Use the scanner CLI when you need normalized findings from an accessibility scan.

Files

tests/runtime_a11y/test_intent.py

# Copyright (c) 2026 Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT

"""Tests for the design-intent verification adapter."""

from __future__ import annotations

import json
import os
from collections.abc import Iterator
from pathlib import Path
from typing import Any

import pytest
from pytest_mock import MockerFixture

import runtime_a11y.__main__ as cli
from runtime_a11y import _intent as intent
from runtime_a11y._errors import (
    EXIT_INTENT_DRIFT,
    EXIT_INTENT_UNCOVERED,
    EXIT_SUCCESS,
    EXIT_USAGE,
    ScriptError,
)

_REPO_ROOT = Path(__file__).resolve().parents[6]
_FIXTURE_REPO = _REPO_ROOT / "scripts/tests/fixtures/design-intent/valid-repo"
_FIXTURE_RECORD = _FIXTURE_REPO / "design-intent/valid-surface.intent.yaml"
_FIXTURE_RESULTS = _FIXTURE_REPO / "harness-results.json"
_FIXTURE_ARTIFACT = (
    _FIXTURE_REPO / "design-intent/.verification/valid-surface.earl.json"
)
_FIXTURE_DIGEST = (
    "sha256:02e31c5823b0044fe1d5c4ea90b74fe679f2af29cdd8bc51016d9a4abab4de02"
)

# The shared contract fixture lives in the hve-core repository, not in the
# skill. When the skill is packaged into a consuming project those files are
# absent, so tests that assert parity with the reference validator skip rather
# than fail. Adapter behavior itself is covered by the self-contained tests.
_requires_contract_fixture = pytest.mark.skipif(
    not _FIXTURE_RECORD.exists(),
    reason="shared design-intent contract fixture is not present",
)


@pytest.fixture()
def preserve_fixture_artifact() -> Iterator[None]:
    """Restore the committed fixture sidecar after a generation test."""
    before = _FIXTURE_ARTIFACT.read_bytes()
    yield
    _FIXTURE_ARTIFACT.write_bytes(before)


@pytest.fixture()
def portable_artifact_writer(mocker: MockerFixture) -> None:
    """Isolate portable verification behavior from POSIX-only artifact writes."""

    def write_artifact(
        _record: Path, destination: Path, document: dict[str, Any]
    ) -> Path:
        destination.parent.mkdir(parents=True, exist_ok=True)
        destination.write_text(json.dumps(document, indent=2) + "\n", encoding="utf-8")
        return destination

    mocker.patch.object(
        intent, "_write_verification_artifact", side_effect=write_artifact
    )


def _write_record(tmp_path: Path, body: str, surface_id: str = "s1") -> Path:
    record_dir = tmp_path / "design-intent"
    record_dir.mkdir(parents=True, exist_ok=True)
    path = record_dir / f"{surface_id}.intent.yaml"
    path.write_text(body, encoding="utf-8")
    return path


def _write_results(tmp_path: Path, rows: list[dict[str, object]]) -> Path:
    path = tmp_path / "results.json"
    path.write_text(json.dumps({"results": rows}), encoding="utf-8")
    return path


def _build_document(record_path: Path, results_path: Path) -> dict[str, Any]:
    raw = intent.read_record_text(record_path)
    record = intent.parse_record(raw, record_path)
    return intent.build_verification(record, raw, intent.load_results(results_path))


_SIMPLE_RECORD = """
schemaVersion: "1.1"
surfaceId: s1
title: Simple surface
owner: Team
status: accepted
decidedOn: "2026-01-01"
decidedBy:
  - A. Person
version: 1
intents:
  - id: INT-001
    conveys: Controls are reachable by keyboard.
    rationale: Keyboard users must reach every control.
    audience:
      - Keyboard users
    evidence: observed
    binding:
      state: default
    expectations:
      - id: EXP-001
        method: runtime-automation
        assert: probe-keyboard-traversal
        detail: Tab order reaches every control.
        criteria:
          - wcag-22:2.1.1
        role: decides
        blocking: true
"""


def _row(**overrides: object) -> dict[str, object]:
    base: dict[str, object] = {
        "criterionId": "2.1.1",
        "framework": "wcag-22",
        "surfaceId": "s1",
        "state": "default",
        "status": "pass",
        "probeId": "probe-keyboard-traversal",
    }
    base.update(overrides)
    return base


class TestDigest:
    @_requires_contract_fixture
    def test_given_fixture_record_when_digest_then_matches_validator_value(
        self,
    ) -> None:
        raw = intent.read_record_text(_FIXTURE_RECORD)
        assert intent.compute_intent_digest(raw) == _FIXTURE_DIGEST

    def test_given_crlf_content_when_digest_then_equals_lf_digest(self) -> None:
        assert intent.compute_intent_digest("a\r\nb") == intent.compute_intent_digest(
            "a\nb"
        )

    def test_given_mutated_record_when_digest_then_differs(
        self, tmp_path: Path
    ) -> None:
        path = _write_record(tmp_path, _SIMPLE_RECORD)
        before = intent.compute_intent_digest(intent.read_record_text(path))
        path.write_text(_SIMPLE_RECORD + "\n# drift\n", encoding="utf-8")
        after = intent.compute_intent_digest(intent.read_record_text(path))
        assert before != after


class TestCriterionReference:
    def test_given_plain_reference_when_split_then_returns_pair(self) -> None:
        assert intent.split_criterion_reference("wcag-22:2.1.1") == ("wcag-22", "2.1.1")

    def test_given_reference_with_inner_colon_when_split_then_keeps_remainder(
        self,
    ) -> None:
        assert intent.split_criterion_reference(
            "aria-apg:APG:notification-live-region"
        ) == ("aria-apg", "APG:notification-live-region")

    @pytest.mark.parametrize("value", ["nocolon", ":missing", "missing:"])
    def test_given_malformed_reference_when_split_then_raises(self, value: str) -> None:
        with pytest.raises(ScriptError):
            intent.split_criterion_reference(value)


class TestAuthoredContract:
    @pytest.mark.parametrize(
        ("replacement", "message"),
        [
            ('schemaVersion: "2.0"', "authored schema"),
            ('decidedOn: "2026-02-30"', "real calendar date"),
            ("version: 1\nunexpectedField: value", "authored schema"),
        ],
    )
    def test_given_invalid_record_contract_when_parse_then_raises(
        self, tmp_path: Path, replacement: str, message: str
    ) -> None:
        body = _SIMPLE_RECORD
        if replacement.startswith("schemaVersion"):
            body = body.replace('schemaVersion: "1.1"', replacement)
        elif replacement.startswith("decidedOn"):
            body = body.replace('decidedOn: "2026-01-01"', replacement)
        else:
            body = body.replace("version: 1", replacement)
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match=message):
            intent.parse_record(body, path)

    def test_given_duplicate_yaml_key_when_parse_then_raises(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace("owner: Team", "owner: Team\nowner: Other")
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match="duplicate key"):
            intent.parse_record(body, path)

    def test_given_empty_intents_when_parse_then_schema_error(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD[: _SIMPLE_RECORD.index("intents:")] + "intents: []\n"
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match="authored schema"):
            intent.parse_record(body, path)

    def test_given_invalid_method_pairing_when_parse_then_raises(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "method: runtime-automation", "method: screen-reader"
        )
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match="authored schema|requires method"):
            intent.parse_record(body, path)

    def test_given_undeclared_surface_when_parse_then_rejects_binding(
        self, tmp_path: Path
    ) -> None:
        path = tmp_path / "s1.intent.yaml"
        config = {"surfaces": [{"id": "other", "states": [{"state": "default"}]}]}

        with pytest.raises(ScriptError, match="not declared in the runtime config"):
            intent.parse_record(_SIMPLE_RECORD, path, config)

    def test_given_undeclared_state_when_parse_then_rejects_binding(
        self, tmp_path: Path
    ) -> None:
        path = tmp_path / "s1.intent.yaml"
        body = _SIMPLE_RECORD.replace("state: default", "state: editing")
        config = {"surfaces": [{"id": "s1", "states": [{"state": "default"}]}]}

        with pytest.raises(ScriptError, match="binds undeclared state"):
            intent.parse_record(body, path, config)

    def test_given_unknown_probe_when_parse_then_rejects_expectation(
        self, tmp_path: Path, mocker: MockerFixture
    ) -> None:
        path = tmp_path / "s1.intent.yaml"
        mocker.patch.object(intent, "_load_probe_adequacy", return_value={})

        with pytest.raises(ScriptError, match="unknown probe"):
            intent.parse_record(_SIMPLE_RECORD, path)

    def test_given_duplicate_intent_id_when_parse_then_raises(
        self, tmp_path: Path
    ) -> None:
        duplicate = _SIMPLE_RECORD[_SIMPLE_RECORD.index("  - id: INT-001") :]
        body = _SIMPLE_RECORD + duplicate.replace("EXP-001", "EXP-002")
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match="Duplicate intent id"):
            intent.parse_record(body, path)

    @pytest.mark.parametrize(
        "override",
        [
            "        override:\n          outcome: passed\n",
            (
                "        override:\n"
                "          outcome: unknown\n"
                "          rationale: Reviewed manually.\n"
                "          reviewedBy: C. Reviewer\n"
                '          reviewedOn: "2026-08-07"\n'
            ),
            (
                "        override:\n"
                "          outcome: passed\n"
                "          rationale: Reviewed manually.\n"
                "          reviewedBy: C. Reviewer\n"
                '          reviewedOn: "2026-02-30"\n'
            ),
        ],
    )
    def test_given_invalid_override_when_parse_then_raises(
        self, tmp_path: Path, override: str
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "        blocking: true\n", "        blocking: true\n" + override
        )
        path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match="authored schema|real calendar date"):
            intent.parse_record(body, path)


@pytest.mark.usefixtures("portable_artifact_writer")
class TestOutcomeMapping:
    @pytest.mark.parametrize(
        ("status", "expected"),
        [("pass", "passed"), ("fail", "failed"), ("candidate", "cantTell")],
    )
    def test_given_status_when_build_then_maps_to_outcome(
        self, tmp_path: Path, status: str, expected: str
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status=status)])
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == expected

    def test_given_unknown_status_when_build_then_reports_cant_tell(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="weird")])
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == "cantTell"

    def test_given_partial_status_when_build_then_maps_explicitly_to_cant_tell(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="partial")])
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == "cantTell"


@pytest.mark.usefixtures("portable_artifact_writer")
class TestJoin:
    @pytest.mark.parametrize(
        "override",
        [
            {"surfaceId": "other"},
            {"state": "error"},
            {"probeId": "probe-axe"},
            {"criterionId": "9.9.9"},
            {"framework": "other-framework"},
        ],
    )
    def test_given_non_matching_row_when_build_then_untested(
        self, tmp_path: Path, override: dict[str, object]
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(**override)])
        _, document = intent.generate(record_path, results_path)
        assertion = document["assertions"][0]
        assert assertion["outcome"] == "untested"
        assert assertion["info"]

    def test_given_non_dict_row_when_build_then_ignored(self, tmp_path: Path) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = tmp_path / "results.json"
        results_path.write_text(json.dumps({"results": ["junk"]}), encoding="utf-8")
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == "untested"

    def test_given_non_list_results_when_build_then_all_untested(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = tmp_path / "results.json"
        results_path.write_text(json.dumps({"results": "nope"}), encoding="utf-8")
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == "untested"


@pytest.mark.usefixtures("portable_artifact_writer")
class TestAggregation:
    def test_given_mixed_criteria_when_build_then_worst_outcome_wins(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "          - wcag-22:2.1.1",
            "          - wcag-22:2.1.1\n          - wcag-22:2.1.2",
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(
            tmp_path,
            [
                _row(criterionId="2.1.1", status="pass"),
                _row(criterionId="2.1.2", status="fail"),
            ],
        )
        _, document = intent.generate(record_path, results_path)
        assert document["assertions"][0]["outcome"] == "failed"

    def test_given_pass_and_candidate_when_build_then_cant_tell_wins(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "          - wcag-22:2.1.1",
            "          - wcag-22:2.1.1\n          - wcag-22:2.1.2",
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(
            tmp_path,
            [
                _row(criterionId="2.1.1", status="pass"),
                _row(criterionId="2.1.2", status="candidate"),
            ],
        )
        _, document = intent.generate(record_path, results_path)
        assertion = document["assertions"][0]
        assert assertion["outcome"] == "cantTell"
        assert assertion["info"]


class TestFixtureRecord:
    @_requires_contract_fixture
    def test_given_fixture_when_build_then_one_assertion_per_expectation(
        self,
    ) -> None:
        document = _build_document(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        assert len(document["assertions"]) == 5
        ids = [item["expectationId"] for item in document["assertions"]]
        assert ids == ["EXP-001", "EXP-002", "EXP-003", "EXP-004", "EXP-005"]

    @_requires_contract_fixture
    def test_given_fixture_when_build_then_outcomes_are_mixed(self) -> None:
        document = _build_document(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        outcomes = {item["outcome"] for item in document["assertions"]}
        # Every outcome the adapter can produce from a probe run appears here,
        # so a stub emitting one blanket outcome cannot pass.
        assert outcomes == {"passed", "failed", "cantTell", "untested"}

    @_requires_contract_fixture
    def test_given_fixture_when_build_then_each_expectation_resolves_as_declared(
        self,
    ) -> None:
        document = _build_document(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        by_id = {item["expectationId"]: item for item in document["assertions"]}
        assert by_id["EXP-001"]["outcome"] == "passed"
        # Worst-wins: a single failing criterion fails the whole expectation.
        assert by_id["EXP-002"]["outcome"] == "failed"
        # Worst-wins again, with one criterion passing and one undecided.
        assert by_id["EXP-003"]["outcome"] == "cantTell"
        assert by_id["EXP-004"]["outcome"] == "untested"
        assert by_id["EXP-005"]["outcome"] == "untested"

        # Every assertion without an override reports the observed outcome as
        # its effective outcome and never claims a conflict, so a branch that
        # forgets the derivation cannot pass on the conclusive cases alone.
        for expectation_id in ("EXP-001", "EXP-002", "EXP-003", "EXP-004"):
            assertion = by_id[expectation_id]
            assert assertion["effectiveOutcome"] == assertion["outcome"]
            assert assertion["overrideConflict"] is False
        # EXP-005 carries a human override settling an untested expectation.
        assert by_id["EXP-005"]["effectiveOutcome"] == "passed"
        assert by_id["EXP-005"]["overrideConflict"] is False

    @_requires_contract_fixture
    def test_given_fixture_when_only_non_blocking_fails_then_no_blocking_failure(
        self,
    ) -> None:
        raw = intent.read_record_text(_FIXTURE_RECORD)
        record = intent.parse_record(raw, _FIXTURE_RECORD)
        results = intent.load_results(_FIXTURE_RESULTS)
        assertions = intent.build_assertions(record, results)
        # EXP-002 fails but is declared non-blocking, so no blocking failure.
        verdict = intent.evaluate_blocking(record, assertions)
        assert verdict != intent.BLOCKING_FAILED
        # The fixture is not clean either: blocking EXP-003 declares two criteria
        # and the run settled only part of them, so its claim is unproven. The
        # old boolean gate reported success here, which is the silent pass this
        # contract now refuses. Blocking EXP-005 is untested but carries a human
        # override, so it does not contribute.
        assert verdict == intent.BLOCKING_UNCOVERED

    @_requires_contract_fixture
    def test_given_custom_assert_when_build_then_untested_and_manual(self) -> None:
        document = _build_document(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        custom = next(
            item
            for item in document["assertions"]
            if item["expectationId"] == "EXP-004"
        )
        assert custom["outcome"] == "untested"
        assert custom["mode"] == "manual"
        assert custom["info"]

    @_requires_contract_fixture
    def test_given_fixture_when_build_then_digest_matches_record(self) -> None:
        document = _build_document(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        assert document["intentDigest"] == _FIXTURE_DIGEST

    @pytest.mark.skipif(
        os.name != "posix", reason="secure verification writes require POSIX dir_fd"
    )
    @_requires_contract_fixture
    def test_given_committed_fixture_sidecar_then_generation_does_not_touch_it(
        self, preserve_fixture_artifact: None
    ) -> None:
        intent.generate(_FIXTURE_RECORD, _FIXTURE_RESULTS)
        assert _FIXTURE_ARTIFACT.exists()


@pytest.mark.usefixtures("portable_artifact_writer")
class TestBlockingEvaluation:
    def test_given_blocking_failure_when_checked_then_true(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="fail")])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)
        assert (
            intent.evaluate_blocking(record, document["assertions"])
            == intent.BLOCKING_FAILED
        )

    def test_given_non_blocking_failure_when_checked_then_false(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace("blocking: true", "blocking: false").replace(
            "role: decides", "role: informs"
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [_row(status="fail")])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)
        verdict = intent.evaluate_blocking(record, document["assertions"])
        assert verdict == intent.BLOCKING_OK

    def test_given_passing_run_when_checked_then_false(self, tmp_path: Path) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="pass")])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)
        verdict = intent.evaluate_blocking(record, document["assertions"])
        assert verdict == intent.BLOCKING_OK

    def test_given_partial_coverage_for_blocking_when_checked_then_uncovered(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "          - wcag-22:2.1.1",
            "          - wcag-22:2.1.1\n          - wcag-22:2.1.2",
        )
        record_path = _write_record(tmp_path, body)
        rows = [_row(criterionId="2.1.1", status="pass")]
        results_path = _write_results(tmp_path, rows)
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)
        assert (
            intent.evaluate_blocking(record, document["assertions"])
            == intent.BLOCKING_UNCOVERED
        )

    def test_given_duplicate_expectation_id_across_intents_when_parsed_then_raises(
        self, tmp_path: Path
    ) -> None:
        body = """
schemaVersion: "1.1"
surfaceId: s1
title: Multi intent
owner: Team
status: accepted
decidedOn: "2026-01-01"
decidedBy:
  - A. Person
version: 1
intents:
  - id: INT-001
    conveys: Blocking expectation.
    rationale: r1
    audience: [A]
    evidence: observed
    binding: { state: default }
    expectations:
      - id: EXP-001
        method: runtime-automation
        assert: probe-keyboard-traversal
        detail: d1
        criteria: [wcag-22:2.1.1]
        role: decides
        blocking: true
  - id: INT-002
    conveys: Informing expectation with same id.
    rationale: r2
    audience: [B]
    evidence: observed
    binding: { state: default }
    expectations:
      - id: EXP-001
        method: runtime-automation
        assert: probe-keyboard-traversal
        detail: d2
        criteria: [wcag-22:2.1.2]
        role: informs
        blocking: false
"""
        record_path = _write_record(tmp_path, body)
        raw = intent.read_record_text(record_path)
        with pytest.raises(ScriptError, match="Duplicate expectation id"):
            intent.parse_record(raw, record_path)

    def test_given_non_boolean_blocking_when_checked_then_raises(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace("blocking: true", "blocking: 'true'")
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [_row(status="pass")])
        with pytest.raises(ScriptError, match="authored schema"):
            intent.generate(record_path, results_path)

    def test_given_override_settles_uncovered_blocking_when_checked_then_ok(
        self, tmp_path: Path
    ) -> None:
        # A human review settled a blocking expectation the probe cannot drive.
        # The artifact still records 'untested', but the gate must not fire.
        body = _SIMPLE_RECORD.replace(
            "        blocking: true\n",
            "        blocking: true\n"
            "        override:\n"
            "          outcome: passed\n"
            "          rationale: Manual review on a platform the probe cannot drive.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-06"\n',
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)

        assert document["assertions"][0]["outcome"] == "untested"
        assert document["assertions"][0]["effectiveOutcome"] == "passed"
        # Settling an untested expectation is the documented use of an
        # override, so it must not register as a conflict.
        assert document["assertions"][0]["overrideConflict"] is False
        verdict = intent.evaluate_blocking(record, document["assertions"])
        assert verdict == intent.BLOCKING_OK

    def test_given_override_failed_when_checked_then_blocking_failed(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "        blocking: true\n",
            "        blocking: true\n"
            "        override:\n"
            "          outcome: failed\n"
            "          rationale: Manual review found the announcement missing.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-06"\n',
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [_row(status="pass")])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)

        assertion = document["assertions"][0]
        assert assertion["outcome"] == "passed", "observation is never overwritten"
        assert assertion["effectiveOutcome"] == "failed"
        assert assertion["overrideConflict"] is True
        verdict = intent.evaluate_blocking(record, document["assertions"])
        assert verdict == intent.BLOCKING_FAILED

    def test_given_override_passed_over_observed_failure_when_checked_then_failed(
        self, tmp_path: Path
    ) -> None:
        # A prior human pass must not mask a current failing probe.
        body = _SIMPLE_RECORD.replace(
            "        blocking: true\n",
            "        blocking: true\n"
            "        override:\n"
            "          outcome: passed\n"
            "          rationale: Manual review found the probe result spurious.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-06"\n',
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [_row(status="fail")])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)

        assertion = document["assertions"][0]
        assert assertion["outcome"] == "failed", "observation is never overwritten"
        assert assertion["effectiveOutcome"] == "failed"
        assert assertion["overrideConflict"] is True
        verdict = intent.evaluate_blocking(record, document["assertions"])
        assert verdict == intent.BLOCKING_FAILED

    def test_given_missing_expectation_id_when_generate_then_raises_before_write(
        self, tmp_path: Path
    ) -> None:
        body = _SIMPLE_RECORD.replace("      - id: EXP-001\n", "      -\n")
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [_row(status="pass")])
        out = tmp_path / "out.json"
        with pytest.raises(ScriptError, match="authored schema"):
            intent.generate(record_path, results_path, out)
        assert not out.exists()


class TestFailurePaths:
    @pytest.mark.parametrize(
        ("assertions", "message"),
        [
            ([{"intentId": "", "expectationId": "EXP-001"}], "needs an id"),
            (
                [
                    {"intentId": "INT-001", "expectationId": "EXP-001"},
                    {"intentId": "INT-001", "expectationId": "EXP-001"},
                ],
                "Duplicate expectation id",
            ),
        ],
    )
    def test_given_invalid_assertion_identity_when_validating_then_rejects(
        self, assertions: list[dict[str, Any]], message: str
    ) -> None:
        with pytest.raises(ScriptError, match=message):
            intent._validate_identifiers(assertions)

    @pytest.mark.parametrize(
        ("surface_id", "message"),
        [(None, "no surfaceId"), ("other", "does not match filename")],
    )
    def test_given_invalid_prepared_surface_when_generating_then_rejects_before_write(
        self, tmp_path: Path, surface_id: str | None, message: str
    ) -> None:
        record_path = tmp_path / "s1.intent.yaml"

        with pytest.raises(ScriptError, match=message):
            intent.generate(
                record_path,
                tmp_path / "missing.json",
                prepared=("", {"surfaceId": surface_id}),
            )

    def test_given_unsupported_platform_when_generate_then_fails_closed(
        self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        monkeypatch.setattr(intent.os, "supports_dir_fd", set())

        with pytest.raises(ScriptError, match="Secure verification artifact"):
            intent.generate(record_path, results_path)

    def test_given_missing_record_when_generate_then_usage_error(
        self, tmp_path: Path
    ) -> None:
        with pytest.raises(ScriptError) as excinfo:
            intent.generate(tmp_path / "absent.intent.yaml", tmp_path / "r.json")
        assert excinfo.value.exit_code == EXIT_USAGE

    def test_given_malformed_yaml_when_generate_then_raises_and_writes_nothing(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, "surfaceId: [unclosed\n")
        out = tmp_path / "out.json"
        with pytest.raises(ScriptError):
            intent.generate(record_path, tmp_path / "r.json", out)
        assert not out.exists()

    def test_given_non_mapping_record_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, "- just\n- a\n- list\n")
        with pytest.raises(ScriptError):
            intent.generate(record_path, tmp_path / "r.json")

    def test_given_record_without_surface_id_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, "title: no surface\n")
        with pytest.raises(ScriptError):
            intent.generate(record_path, tmp_path / "r.json")

    def test_given_surface_id_filename_mismatch_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(
            tmp_path, _SIMPLE_RECORD.replace("surfaceId: s1", "surfaceId: other")
        )
        with pytest.raises(ScriptError) as excinfo:
            intent.generate(record_path, tmp_path / "r.json")
        assert "does not match filename" in str(excinfo.value)

    def test_given_missing_results_when_generate_then_usage_error(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        with pytest.raises(ScriptError) as excinfo:
            intent.generate(record_path, tmp_path / "absent.json")
        assert excinfo.value.exit_code == EXIT_USAGE

    def test_given_invalid_results_json_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = tmp_path / "results.json"
        results_path.write_text("{not json", encoding="utf-8")
        with pytest.raises(ScriptError):
            intent.generate(record_path, results_path)

    def test_given_non_object_results_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = tmp_path / "results.json"
        results_path.write_text("[]", encoding="utf-8")
        with pytest.raises(ScriptError):
            intent.generate(record_path, results_path)


@pytest.mark.skipif(
    os.name != "posix", reason="secure verification writes require POSIX dir_fd"
)
class TestOutputLocation:
    def test_given_no_out_path_when_generate_then_writes_contract_location(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination, _ = intent.generate(record_path, results_path)
        assert destination == record_path.parent / ".verification" / "s1.earl.json"
        assert destination.exists()

    def test_given_explicit_out_path_when_generate_then_creates_parents(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        out = tmp_path / "nested" / "deeper" / "artifact.json"
        destination, _ = intent.generate(record_path, results_path, out)
        assert destination == out
        assert json.loads(out.read_text(encoding="utf-8"))["surfaceId"] == "s1"

    def test_given_generation_when_complete_then_timestamp_is_populated(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        _, document = intent.generate(record_path, results_path)
        assert document["timestamp"]
        assert document["assertedBy"] == intent.ASSERTED_BY
        assert document["schemaVersion"] == intent.SCHEMA_VERSION

    def test_given_symlinked_parent_when_generate_then_raises_without_overwrite(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        external = tmp_path / "external"
        external.mkdir()
        linked_parent = record_path.parent / "linked"
        linked_parent.symlink_to(external, target_is_directory=True)

        with pytest.raises(ScriptError, match="unsafe"):
            intent.generate(record_path, results_path, linked_parent / "artifact.json")

        assert not (external / "artifact.json").exists()

    def test_given_symlinked_final_when_generate_then_raises_without_overwrite(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        external = tmp_path / "external.json"
        external.write_text("keep", encoding="utf-8")
        destination = record_path.parent / "artifact.json"
        destination.symlink_to(external)

        with pytest.raises(ScriptError, match="not a regular file"):
            intent.generate(record_path, results_path, destination)

        assert external.read_text(encoding="utf-8") == "keep"

    def test_given_out_of_root_path_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        project_root = tmp_path / "project"
        record_path = _write_record(project_root, _SIMPLE_RECORD)
        results_path = _write_results(project_root, [_row()])

        with pytest.raises(ScriptError, match="escapes the record directory"):
            intent.generate(record_path, results_path, tmp_path / "outside.json")

    def test_given_first_run_when_generate_then_creates_verification_directory(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])

        destination, _ = intent.generate(record_path, results_path)

        assert destination.is_file()
        assert destination.parent.name == ".verification"

    def test_given_directory_destination_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        destination.mkdir()

        with pytest.raises(ScriptError, match="not a regular file"):
            intent.generate(record_path, results_path, destination)

    def test_given_fifo_destination_when_generate_then_raises(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        mkfifo = getattr(intent.os, "mkfifo", None)
        if not callable(mkfifo):
            pytest.skip("POSIX FIFO support required")
        mkfifo(destination)

        with pytest.raises(ScriptError, match="not a regular file"):
            intent.generate(record_path, results_path, destination)

    def test_given_parent_replaced_after_open_when_generate_then_not_redirected(
        self,
        tmp_path: Path,
        monkeypatch: pytest.MonkeyPatch,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "verified" / "artifact.json"
        original_open = intent._open_destination_directory

        def replace_parent(root_fd: int, parts: tuple[str, ...]) -> int:
            directory_fd = original_open(root_fd, parts)
            destination.parent.rename(record_path.parent / "retained")
            destination.parent.mkdir()
            return directory_fd

        monkeypatch.setattr(intent, "_open_destination_directory", replace_parent)

        written, _ = intent.generate(record_path, results_path, destination)

        assert written == destination
        assert (record_path.parent / "retained" / "artifact.json").is_file()
        assert not destination.exists()

    def test_given_temp_collision_when_generate_then_preserves_existing_entry(
        self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        collision = record_path.parent / ".artifact.json.fixed.tmp"
        collision.write_text("keep", encoding="utf-8")
        monkeypatch.setattr(intent.secrets, "token_hex", lambda _: "fixed")

        with pytest.raises(ScriptError, match="safely"):
            intent.generate(record_path, results_path, destination)

        assert collision.read_text(encoding="utf-8") == "keep"
        assert not destination.exists()

    def test_given_write_failure_when_generate_then_cleans_owned_temp_handle_relatively(
        self,
        tmp_path: Path,
        monkeypatch: pytest.MonkeyPatch,
        mocker: MockerFixture,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        unlink = mocker.spy(intent.os, "unlink")
        monkeypatch.setattr(
            intent.os,
            "supports_dir_fd",
            set(intent.os.supports_dir_fd) | {unlink},
        )
        mocker.patch.object(intent.os, "fsync", side_effect=OSError("write failed"))

        with pytest.raises(ScriptError, match="safely"):
            intent.generate(record_path, results_path, destination)

        cleanup = next(call for call in unlink.call_args_list if call.kwargs)
        assert cleanup.kwargs["dir_fd"] >= 0
        assert not destination.exists()

    def test_given_successful_write_when_generate_then_renames_handle_relatively(
        self,
        tmp_path: Path,
        monkeypatch: pytest.MonkeyPatch,
        mocker: MockerFixture,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        rename = mocker.spy(intent.os, "rename")
        monkeypatch.setattr(
            intent.os,
            "supports_dir_fd",
            set(intent.os.supports_dir_fd) | {rename},
        )

        intent.generate(record_path, results_path, destination)

        call = rename.call_args_list[-1]
        assert call.kwargs["src_dir_fd"] == call.kwargs["dst_dir_fd"]
        assert call.kwargs["src_dir_fd"] >= 0

    def test_given_stream_wrap_failure_when_generate_then_closes_raw_descriptor(
        self, tmp_path: Path, mocker: MockerFixture
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = record_path.parent / "artifact.json"
        captured: list[int] = []
        close = mocker.spy(intent.os, "close")

        def fail_to_wrap(descriptor: int, *_: object, **__: object) -> object:
            captured.append(descriptor)
            raise MemoryError("stream allocation failed")

        mocker.patch.object(intent.os, "fdopen", side_effect=fail_to_wrap)

        with pytest.raises(MemoryError, match="stream allocation failed"):
            intent.generate(record_path, results_path, destination)

        assert captured
        assert any(call.args == (captured[0],) for call in close.call_args_list)
        assert not destination.exists()


@pytest.mark.usefixtures("portable_artifact_writer")
class TestManualDecidingCustom:
    def _custom_record(self, override: str = "") -> str:
        return _SIMPLE_RECORD.replace(
            "        method: runtime-automation\n"
            "        assert: probe-keyboard-traversal\n",
            "        method: cognitive-walkthrough\n        assert: custom\n",
        ).replace("        blocking: true\n", "        blocking: true\n" + override)

    def test_given_deciding_custom_without_review_when_checked_then_uncovered(
        self, tmp_path: Path
    ) -> None:
        record_path = _write_record(tmp_path, self._custom_record())
        results_path = _write_results(tmp_path, [])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)

        assert document["assertions"][0]["outcome"] == "untested"
        assert (
            intent.evaluate_blocking(record, document["assertions"])
            == intent.BLOCKING_UNCOVERED
        )

    @pytest.mark.parametrize(
        ("outcome", "expected"),
        [("passed", intent.BLOCKING_OK), ("failed", intent.BLOCKING_FAILED)],
    )
    def test_given_deciding_custom_review_when_checked_then_applies_outcome(
        self, tmp_path: Path, outcome: str, expected: str
    ) -> None:
        override = (
            "        override:\n"
            f"          outcome: {outcome}\n"
            "          rationale: Human review settles the graphics meaning.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-07"\n'
        )
        record_path = _write_record(tmp_path, self._custom_record(override))
        results_path = _write_results(tmp_path, [])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)
        _, document = intent.generate(record_path, results_path)

        assert document["assertions"][0]["effectiveOutcome"] == outcome
        assert intent.evaluate_blocking(record, document["assertions"]) == expected

    def test_given_informational_custom_when_checked_then_remains_non_blocking(
        self, tmp_path: Path
    ) -> None:
        body = self._custom_record().replace(
            "        role: decides\n        blocking: true\n",
            "        role: informs\n        blocking: false\n",
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(tmp_path, [])
        raw = intent.read_record_text(record_path)
        record = intent.parse_record(raw, record_path)

        _, document = intent.generate(record_path, results_path)

        assert (
            intent.evaluate_blocking(record, document["assertions"])
            == intent.BLOCKING_OK
        )

    def test_given_existing_complete_override_when_parse_then_migration_preserves_it(
        self, tmp_path: Path
    ) -> None:
        override = (
            "        override:\n"
            "          outcome: passed\n"
            "          rationale: Existing review remains authoritative.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-07"\n'
        )
        record_path = _write_record(tmp_path, self._custom_record(override))
        raw = intent.read_record_text(record_path)

        record = intent.parse_record(raw, record_path)

        assert record["intents"][0]["expectations"][0]["override"] == {
            "outcome": "passed",
            "rationale": "Existing review remains authoritative.",
            "reviewedBy": "C. Reviewer",
            "reviewedOn": "2026-08-07",
        }


class TestCli:
    @pytest.mark.skipif(os.name != "nt", reason="native-Windows secure write refusal")
    def test_given_windows_when_verify_intent_then_rejects_without_artifact(
        self, tmp_path: Path, capsys: pytest.CaptureFixture[str]
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row()])
        destination = tmp_path / "verified.json"

        code = cli.main(
            [
                "verify-intent",
                "--record",
                str(record_path),
                "--results",
                str(results_path),
                "--out",
                str(destination),
            ]
        )

        assert code == EXIT_USAGE
        assert (
            "Secure verification artifact writes require POSIX"
            in capsys.readouterr().err
        )
        assert not destination.exists()

    @pytest.mark.parametrize(
        ("failure_marker", "explicit_output"),
        [
            ({"quarantined": True}, True),
            ({"operationalFailure": {"reason": "probe stopped"}}, False),
        ],
    )
    def test_given_incomplete_results_when_verify_intent_then_rejects_without_artifact(
        self,
        tmp_path: Path,
        failure_marker: dict[str, object],
        explicit_output: bool,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = tmp_path / "results.json"
        results_path.write_text(
            json.dumps({"results": [_row()], **failure_marker}),
            encoding="utf-8",
        )
        destination = (
            tmp_path / "explicit.json"
            if explicit_output
            else record_path.parent / ".verification" / "s1.earl.json"
        )
        argv = [
            "verify-intent",
            "--record",
            str(record_path),
            "--results",
            str(results_path),
        ]
        if explicit_output:
            argv.extend(["--out", str(destination)])

        code = cli.main(argv)

        assert code == EXIT_USAGE
        assert not destination.exists()

    def test_given_clean_run_when_verify_intent_then_exit_success(
        self,
        tmp_path: Path,
        capsys: pytest.CaptureFixture[str],
        portable_artifact_writer: None,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="pass")])
        out = tmp_path / "out.json"
        code = cli.main(
            [
                "verify-intent",
                "--record",
                str(record_path),
                "--results",
                str(results_path),
                "--out",
                str(out),
            ]
        )
        assert code == EXIT_SUCCESS
        assert "Wrote" in capsys.readouterr().out

    def test_given_override_conflict_when_verify_intent_then_warns_and_gates(
        self,
        tmp_path: Path,
        capsys: pytest.CaptureFixture[str],
        portable_artifact_writer: None,
    ) -> None:
        # A conclusive conflict is written to stderr and fails closed.
        # Settling an unreachable expectation is the documented use of an
        # override, so that path must stay silent.
        conflict_body = _SIMPLE_RECORD.replace(
            "        blocking: true\n",
            "        blocking: true\n"
            "        override:\n"
            "          outcome: passed\n"
            "          rationale: Manual review found the probe result spurious.\n"
            "          reviewedBy: C. Reviewer\n"
            '          reviewedOn: "2026-08-06"\n',
        )
        conflict_record = _write_record(tmp_path, conflict_body)
        conflict_results = _write_results(tmp_path, [_row(status="fail")])
        conflict_code = cli.main(
            [
                "verify-intent",
                "--record",
                str(conflict_record),
                "--results",
                str(conflict_results),
                "--out",
                str(tmp_path / "conflict.json"),
            ]
        )
        conflict_stderr = capsys.readouterr().err

        settled_dir = tmp_path / "settled"
        settled_record = _write_record(settled_dir, conflict_body)
        settled_results = _write_results(settled_dir, [])
        settled_code = cli.main(
            [
                "verify-intent",
                "--record",
                str(settled_record),
                "--results",
                str(settled_results),
                "--out",
                str(settled_dir / "settled.json"),
            ]
        )
        settled_stderr = capsys.readouterr().err

        assert conflict_code == EXIT_INTENT_DRIFT
        assert "Warning: design intent override conflict" in conflict_stderr
        assert "INT-001" in conflict_stderr and "EXP-001" in conflict_stderr
        assert "observed outcome 'failed'" in conflict_stderr
        assert "override outcome 'passed'" in conflict_stderr
        assert settled_code == EXIT_SUCCESS
        assert "Warning:" not in settled_stderr

    def test_given_blocking_failure_when_verify_intent_then_exit_drift(
        self,
        tmp_path: Path,
        capsys: pytest.CaptureFixture[str],
        portable_artifact_writer: None,
    ) -> None:
        record_path = _write_record(tmp_path, _SIMPLE_RECORD)
        results_path = _write_results(tmp_path, [_row(status="fail")])
        out = tmp_path / "out.json"
        code = cli.main(
            [
                "verify-intent",
                "--record",
                str(record_path),
                "--results",
                str(results_path),
                "--out",
                str(out),
            ]
        )
        assert code == EXIT_INTENT_DRIFT
        assert "blocking design intent expectation failed" in capsys.readouterr().err
        assert out.exists(), "the artifact is still written so CI can publish it"

    def test_given_blocking_uncovered_when_verify_intent_then_exit_uncovered(
        self,
        tmp_path: Path,
        capsys: pytest.CaptureFixture[str],
        portable_artifact_writer: None,
    ) -> None:
        body = _SIMPLE_RECORD.replace(
            "          - wcag-22:2.1.1",
            "          - wcag-22:2.1.1\n          - wcag-22:2.1.2",
        )
        record_path = _write_record(tmp_path, body)
        results_path = _write_results(
            tmp_path, [_row(criterionId="2.1.1", status="pass")]
        )
        out = tmp_path / "out.json"
        code = cli.main(
            [
                "verify-intent",
                "--record",
                str(record_path),
                "--results",
                str(results_path),
                "--out",
                str(out),
            ]
        )
        assert code == EXIT_INTENT_UNCOVERED
        assert (
            "blocking design intent expectation was never evaluated"
            in capsys.readouterr().err
        )
        assert out.exists(), "the artifact is still written so CI can publish it"

    def test_given_missing_record_when_verify_intent_then_usage_exit(
        self, tmp_path: Path
    ) -> None:
        code = cli.main(
            [
                "verify-intent",
                "--record",
                str(tmp_path / "absent.intent.yaml"),
                "--results",
                str(tmp_path / "absent.json"),
            ]
        )
        assert code == EXIT_USAGE

Requirements and compatibility

Written for: GitHub Copilot, Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter, Needs Python, Needs Node.js

The author says: Requires Python 3.11+ and uv; the scanner additionally needs Node.js and network access to fetch the pinned axe-core CLI from the public npm registry.

Security

What our scanner noticed· Low risk

  • Instructions that use the network
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Microsoft
Publisher
Microsoft (Official)
Source
microsoft/hve-core · .github/skills/accessibility/accessibility · commit f425e94
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Microsoft.

Get it from the source

1 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: microsoft/hve-core