types

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package types provides shared types used across the accessibility audit service. This package exists to break import cycles between packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentFinding added in v0.4.0

type AgentFinding struct {
	// Core finding information
	Finding Finding `json:"finding"`

	// Detailed element context
	Element ElementContext `json:"element"`

	// Agent-actionable remediation
	Remediation AgentRemediation `json:"remediation"`
}

AgentFinding is the agent-optimized finding format. This is the default output format for coding agents.

type AgentRemediation added in v0.4.0

type AgentRemediation struct {
	// Inherit standard remediation
	Remediation

	// Actionable fix patterns (ordered by priority)
	FixPatterns []FixPattern `json:"fixPatterns"`

	// Project-specific fix patterns (from ~/.plexusone/a11y/fixes.yaml)
	ProjectPatterns []ProjectPattern `json:"projectPatterns,omitempty"`

	// Design system token suggestions (if design system loaded)
	TokenSuggestions []TokenSuggestion `json:"tokenSuggestions,omitempty"`

	// Affected component from design system (if detected)
	DesignSystemComponent string `json:"designSystemComponent,omitempty"`

	// Confidence that this fix will resolve the issue (0-1)
	FixConfidence float64 `json:"fixConfidence"`
}

AgentRemediation extends Remediation with agent-actionable guidance.

type AgentResult added in v0.4.0

type AgentResult struct {
	// Audit metadata
	URL       string `json:"url"`
	Timestamp string `json:"timestamp"`
	Duration  string `json:"duration"`
	Level     string `json:"level"` // Target WCAG level

	// Design system info (if loaded)
	DesignSystem *DesignSystemInfo `json:"designSystem,omitempty"`

	// Agent-optimized findings
	Findings []AgentFinding `json:"findings"`

	// Summary statistics
	Summary AgentSummary `json:"summary"`

	// Overall status for multi-agent workflows
	Status string `json:"status"` // "GO", "WARN", "NO-GO"
}

AgentResult is the agent-optimized audit result. This is the default output format.

type AgentSummary added in v0.4.0

type AgentSummary struct {
	Total      int `json:"total"`
	Critical   int `json:"critical"`
	Serious    int `json:"serious"`
	Moderate   int `json:"moderate"`
	Minor      int `json:"minor"`
	Fixable    int `json:"fixable"`    // Issues with fix patterns
	NeedsToken int `json:"needsToken"` // Issues that need design tokens
}

AgentSummary provides aggregate statistics.

type BoundingBox added in v0.4.0

type BoundingBox struct {
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

BoundingBox represents element position and size.

type DeltaStatus added in v0.4.0

type DeltaStatus string

DeltaStatus represents the overall change status.

const (
	// DeltaStatusFixed means all issues were resolved.
	DeltaStatusFixed DeltaStatus = "FIXED"

	// DeltaStatusImproved means some issues were fixed, none regressed.
	DeltaStatusImproved DeltaStatus = "IMPROVED"

	// DeltaStatusNoChange means nothing changed.
	DeltaStatusNoChange DeltaStatus = "NO_CHANGE"

	// DeltaStatusRegressed means new issues were introduced.
	DeltaStatusRegressed DeltaStatus = "REGRESSED"

	// DeltaStatusMixed means some fixed, some regressed.
	DeltaStatusMixed DeltaStatus = "MIXED"
)

type DeltaSummary added in v0.4.0

type DeltaSummary struct {
	TotalBefore int     `json:"totalBefore"`
	TotalAfter  int     `json:"totalAfter"`
	FixedCount  int     `json:"fixedCount"`
	NewCount    int     `json:"newCount"`    // Regressions
	Improvement float64 `json:"improvement"` // Percentage
	StatusEmoji string  `json:"statusEmoji"` // GO/WARN/NO-GO style
	StatusText  string  `json:"statusText"`  // Human readable
}

DeltaSummary provides a human-readable summary of changes.

type DesignSystemInfo added in v0.4.0

type DesignSystemInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Path    string `json:"path"`
}

DesignSystemInfo contains loaded design system metadata.

type ElementContext added in v0.4.0

type ElementContext struct {
	// CSS selector (most specific)
	Selector string `json:"selector"`

	// XPath (for complex selections)
	XPath string `json:"xpath"`

	// HTML snippet
	HTML string `json:"html"`

	// Tag name
	TagName string `json:"tagName"`

	// Computed styles relevant to the issue
	ComputedStyles map[string]string `json:"computedStyles,omitempty"`

	// Parent context (for structural issues)
	ParentHTML string `json:"parentHtml,omitempty"`

	// Bounding box (for visual issues)
	BoundingBox *BoundingBox `json:"boundingBox,omitempty"`

	// Design system component ID (if detected)
	ComponentID string `json:"componentId,omitempty"`

	// Component variant (if detected)
	ComponentVariant string `json:"componentVariant,omitempty"`

	// Source code location (if source maps available)
	Source *SourceLocation `json:"source,omitempty"`
}

ElementContext provides detailed context about the affected element.

type Finding

type Finding struct {
	// Core identification
	ID          string `json:"id"`
	RuleID      string `json:"ruleId"`      // Rule that found this issue
	Description string `json:"description"` // Human-readable description
	Help        string `json:"help"`        // Help text for fixing

	// WCAG mapping
	SuccessCriteria []string  `json:"successCriteria"` // e.g., ["1.1.1", "4.1.2"]
	Level           WCAGLevel `json:"level"`           // Highest level affected
	Impact          Impact    `json:"impact"`

	// Element information
	Selector   string `json:"selector"`   // CSS selector
	XPath      string `json:"xpath"`      // XPath
	HTML       string `json:"html"`       // HTML snippet
	Element    string `json:"element"`    // Element tag name
	PageURL    string `json:"pageUrl"`    // URL where found
	PageTitle  string `json:"pageTitle"`  // Page title
	Screenshot string `json:"screenshot"` // Base64 screenshot (optional)

	// Context
	JourneyStep string `json:"journeyStep,omitempty"` // Which journey step
	Component   string `json:"component,omitempty"`   // UI component name

	// Severity (for easier sorting/filtering)
	Severity Severity `json:"severity,omitempty"`

	// Remediation guidance
	Remediation *Remediation `json:"remediation,omitempty"`

	// LLM evaluation (if enabled)
	LLMEvaluation *LLMEvaluation `json:"llmEvaluation,omitempty"`

	// Timestamps
	FoundAt time.Time `json:"foundAt"`
}

Finding represents an individual accessibility finding.

func (*Finding) Fingerprint added in v0.4.0

func (f *Finding) Fingerprint() string

Fingerprint generates a stable ID for a finding across audits. This allows matching the same issue in before/after comparisons even if minor details change (like line numbers in HTML).

type FixAction added in v0.4.0

type FixAction string

FixAction specifies the action to perform.

const (
	FixActionAdd     FixAction = "add"     // Add new attribute/element
	FixActionModify  FixAction = "modify"  // Change existing value
	FixActionRemove  FixAction = "remove"  // Remove attribute/element
	FixActionReplace FixAction = "replace" // Replace element entirely
	FixActionWrap    FixAction = "wrap"    // Wrap in new element
	FixActionUnwrap  FixAction = "unwrap"  // Remove wrapper
)

type FixPattern added in v0.4.0

type FixPattern struct {
	// Type of change required
	Type FixType `json:"type"`

	// Action to perform
	Action FixAction `json:"action"`

	// What to target (attribute name, CSS property, etc.)
	Target string `json:"target"`

	// Suggested value (generic, may need design system token)
	Value string `json:"value,omitempty"`

	// Pseudo-code example of the fix
	Example string `json:"example"`

	// Priority for this fix (when multiple options exist)
	Priority int `json:"priority,omitempty"`
}

FixPattern provides actionable guidance for coding agents. Maps WCAG techniques to concrete implementation patterns.

type FixType added in v0.4.0

type FixType string

FixType categorizes the type of code change needed.

const (
	FixTypeAttribute FixType = "attribute" // Add/modify HTML attribute
	FixTypeStyle     FixType = "style"     // CSS style change
	FixTypeStructure FixType = "structure" // DOM structure change
	FixTypeContent   FixType = "content"   // Text content change
	FixTypeARIA      FixType = "aria"      // ARIA attribute change
	FixTypeFocus     FixType = "focus"     // Focus management
	FixTypeOrder     FixType = "order"     // DOM/reading order
	FixTypeSemantic  FixType = "semantic"  // Semantic HTML change
)

type FixedFinding added in v0.4.0

type FixedFinding struct {
	// The original finding that was fixed
	Finding AgentFinding `json:"finding"`

	// Which fix pattern likely resolved this (if determinable)
	FixedBy string `json:"fixedBy,omitempty"`

	// Whether fix was verified via element fingerprint match
	Verified bool `json:"verified"`

	// Fingerprint used for matching
	Fingerprint string `json:"fingerprint"`
}

FixedFinding represents an issue that was resolved.

type Framework added in v0.4.0

type Framework string

Framework identifies the frontend framework in use.

const (
	FrameworkReact   Framework = "react"
	FrameworkVue     Framework = "vue"
	FrameworkSvelte  Framework = "svelte"
	FrameworkAngular Framework = "angular"
	FrameworkVanilla Framework = "vanilla"
	FrameworkUnknown Framework = "unknown"
)

type Impact

type Impact string

Impact represents the WCAG impact level.

const (
	ImpactBlocker  Impact = "blocker"  // Prevents access entirely
	ImpactCritical Impact = "critical" // Significant barrier
	ImpactSerious  Impact = "serious"  // Moderate barrier
	ImpactModerate Impact = "moderate" // Minor barrier
	ImpactMinor    Impact = "minor"    // Inconvenience
)

type LLMEvaluation

type LLMEvaluation struct {
	// Evaluation result
	Confirmed   bool    `json:"confirmed"`   // LLM confirms the issue
	Confidence  float64 `json:"confidence"`  // 0.0-1.0
	Reasoning   string  `json:"reasoning"`   // Why the LLM made this decision
	Severity    string  `json:"severity"`    // LLM-assessed severity
	Remediation string  `json:"remediation"` // Suggested fix

	// For manual review items
	NeedsManualReview bool   `json:"needsManualReview"`
	ReviewGuidance    string `json:"reviewGuidance,omitempty"`

	// Metadata
	Model     string    `json:"model"`
	EvalTime  time.Time `json:"evalTime"`
	TokensIn  int       `json:"tokensIn"`
	TokensOut int       `json:"tokensOut"`
}

LLMEvaluation contains LLM-as-a-Judge evaluation results.

type ProjectPattern added in v0.4.0

type ProjectPattern struct {
	// Source indicates where this pattern came from
	Source string `json:"source"` // "project", "library", "language"

	// Component name (for component-specific fixes)
	Component string `json:"component,omitempty"`

	// Import statement to add (if needed)
	Import string `json:"import,omitempty"`

	// The fix pattern/example
	Pattern string `json:"pattern"`

	// Priority for ordering (higher = more preferred)
	Priority int `json:"priority,omitempty"`
}

ProjectPattern is a fix pattern from project configuration.

type ReferenceURL

type ReferenceURL struct {
	Title  string `json:"title"`  // e.g., "WCAG Understanding 1.1.1"
	URL    string `json:"url"`    // Full URL
	Source string `json:"source"` // "w3c", "deque", "webaim"
}

ReferenceURL contains a reference link with metadata.

type Remediation

type Remediation struct {
	// Brief inline summary (1-2 sentences)
	Summary string `json:"summary"`

	// WCAG Technique references (e.g., H37, G94, ARIA6)
	Techniques []TechniqueRef `json:"techniques,omitempty"`

	// ACT Rule ID (W3C standardized test methodology)
	ACTRuleID string `json:"actRuleId,omitempty"`

	// axe-core rule ID (Deque)
	AxeRuleID string `json:"axeRuleId,omitempty"`

	// Reference URLs
	References []ReferenceURL `json:"references,omitempty"`

	// LLM-generated context-specific guidance (optional)
	ContextualFix string `json:"contextualFix,omitempty"`
}

Remediation contains standardized remediation references. Uses WCAG techniques and ACT rules similar to how SAST tools use CWE IDs.

type Severity

type Severity string

Severity represents the severity of an accessibility issue.

const (
	SeverityCritical Severity = "critical"
	SeveritySerious  Severity = "serious"
	SeverityModerate Severity = "moderate"
	SeverityMinor    Severity = "minor"
)

type SourceLocation added in v0.4.0

type SourceLocation struct {
	// Source file path relative to project root
	File string `json:"file"` // e.g., "src/components/Hero.tsx"

	// Line number in source file (1-indexed)
	Line int `json:"line"`

	// Column number in source file (1-indexed)
	Column int `json:"column,omitempty"`

	// Component name (if framework detected)
	Component string `json:"component,omitempty"` // e.g., "Hero"

	// Detected framework
	Framework Framework `json:"framework,omitempty"`

	// Source map file used for mapping (for debugging)
	SourceMapFile string `json:"sourceMapFile,omitempty"`

	// Confidence that mapping is accurate (0-1)
	Confidence float64 `json:"confidence,omitempty"`
}

SourceLocation maps a DOM element to its source code location. Enables coding agents to locate and fix issues in source files.

type TechniqueRef

type TechniqueRef struct {
	ID    string `json:"id"`    // e.g., "H37"
	Type  string `json:"type"`  // "sufficient", "advisory", "failure"
	Title string `json:"title"` // e.g., "Using alt attributes on img elements"
	URL   string `json:"url"`   // W3C documentation URL
}

TechniqueRef references a WCAG technique.

type TokenSuggestion added in v0.4.0

type TokenSuggestion struct {
	// CSS property this applies to
	Property string `json:"property"`

	// Current value in the code
	CurrentValue string `json:"currentValue"`

	// Suggested design token name
	TokenName string `json:"tokenName"`

	// Resolved token value
	TokenValue string `json:"tokenValue"`

	// Why this token is suggested
	Rationale string `json:"rationale"`

	// Contrast ratio (for color tokens)
	ContrastRatio float64 `json:"contrastRatio,omitempty"`
}

TokenSuggestion suggests a design system token for a fix.

type ValidationDelta added in v0.4.0

type ValidationDelta struct {
	// Original audit results
	Before *AgentResult `json:"before,omitempty"`
	After  *AgentResult `json:"after,omitempty"`

	// Summary counts
	BeforeTotal int `json:"beforeTotal"`
	AfterTotal  int `json:"afterTotal"`

	// Categorized changes
	Fixed       []FixedFinding `json:"fixed"`       // Issues that were resolved
	Remaining   []AgentFinding `json:"remaining"`   // Issues still present
	Regressions []AgentFinding `json:"regressions"` // New issues introduced

	// Overall status
	Status      DeltaStatus `json:"status"`      // Overall change status
	Improvement float64     `json:"improvement"` // Percentage improvement (can be negative)

	// Metadata
	BaselineURL string `json:"baselineUrl,omitempty"` // URL that was compared
	Timestamp   string `json:"timestamp"`             // When comparison was made
}

ValidationDelta compares two audit results to track fix progress. This enables the autonomous fix loop: audit → fix → validate → repeat.

func (*ValidationDelta) HasRegressions added in v0.4.0

func (d *ValidationDelta) HasRegressions() bool

HasRegressions returns true if new issues were introduced.

func (*ValidationDelta) IsImproved added in v0.4.0

func (d *ValidationDelta) IsImproved() bool

IsImproved returns true if the situation is better (or same).

func (*ValidationDelta) IsPassing added in v0.4.0

func (d *ValidationDelta) IsPassing() bool

IsPassing returns true if suitable for CI pass (no regressions).

func (*ValidationDelta) Summary added in v0.4.0

func (d *ValidationDelta) Summary() DeltaSummary

Summary generates a human-readable summary of the delta.

type WCAGLevel

type WCAGLevel string

WCAGLevel represents WCAG conformance levels.

const (
	WCAGLevelA   WCAGLevel = "A"
	WCAGLevelAA  WCAGLevel = "AA"
	WCAGLevelAAA WCAGLevel = "AAA"
)

type WCAGVersion

type WCAGVersion string

WCAGVersion represents WCAG version.

const (
	WCAG20 WCAGVersion = "2.0"
	WCAG21 WCAGVersion = "2.1"
	WCAG22 WCAGVersion = "2.2"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL