Architectural Invariant Design: Compose Multiplatform Shared Accessibility Semantics & Platform-Native A11y Bridge
Compose Multiplatform Shared Accessibility Semantics & Platform-Native A11y Bridge defines an industrial-grade behavioral standard for mobile engineering. Enforces deterministic declarative-to-native accessibility mapping across Compose Multiplatform (Android AccessibilityNodeInfo and iOS UIAccessibilityElement/NSAccessibilityElement). Ensures semantics trees are explicitly merged, roles and state descriptions are bound to platform-safe actions, and custom interactive nodes eliminate screen-reader desynchronization and focus trapping across platforms. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.
Hazard Analysis: What Breaks Without This Rule
The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:
| Failure Mode | AI Symptom (The Anti-Pattern) | Severity | Production Impact & Remedy |
|---|---|---|---|
| AI Hallucination & Deprecation Drift | Ad-Hoc Gesture Handling Without Semantic Node Merging and Platform A11y Action Bridging | Critical | Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production. Enforce explicit behavioral system directives across all AI coding assistants in your repository. |
| Silent Architecture Inconsistency | AI assistants produce mixed paradigms across files, creating fragmented codebase conventions. | Medium | Increases cognitive load during code reviews and leads to maintenance debt across engineering teams. Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails. |
Step-by-Step Production Directives
Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:
Engineers MUST ALWAYS declare interactive elements using Modifier.semantics(mergeDescendants = true) when grouping compound composables (e.g., custom checkboxes, list items with action badges) to prevent split focus rects in iOS VoiceOver.
Engineers MUST ALWAYS declare interactive elements using Modifier.semantics(mergeDescendants = true) when grouping compound composables (e.g., custom checkboxes, list items with action badges) to prevent split focus rects in iOS VoiceOver.
Engineers MUST NOT attach raw Modifier.pointerInput or clickable without explicitly setting semantic Role, onClick label, and stateDescription/toggleableState.
Engineers MUST NOT attach raw Modifier.pointerInput or clickable without explicitly setting semantic Role, onClick label, and stateDescription/toggleableState.
Components NEVER expose headless non-text decorative iconography to the accessibility tree
Components NEVER expose headless non-text decorative iconography to the accessibility tree; Modifier.semantics { invisibleToUser() } or contentDescription = null must be explicitly assigned.
Custom components exposing swipe, dismiss, or custom interactions MUST declare customActions via SemanticsPropertyReceiver to allow platform-native accessibility rotors and TalkBack local context menus to discover them.
Custom components exposing swipe, dismiss, or custom interactions MUST declare customActions via SemanticsPropertyReceiver to allow platform-native accessibility rotors and TalkBack local context menus to discover them.
Dynamic state mutations affecting accessibility (e.g., error banners, real-time counters) MUST emit liveRegion semantics (LiveRegionMode.Polite or LiveRegionMode.Assertive) to prevent screen-reader desynchronization during asynchronous rendering.
Dynamic state mutations affecting accessibility (e.g., error banners, real-time counters) MUST emit liveRegion semantics (LiveRegionMode.Polite or LiveRegionMode.Assertive) to prevent screen-reader desynchronization during asynchronous rendering.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is Compose Multiplatform Shared Accessibility Semantics & Platform-Native A11y Bridge critical for AI coding assistants?
Enforces deterministic declarative-to-native accessibility mapping across Compose Multiplatform (Android AccessibilityNodeInfo and iOS UIAccessibilityElement/NSAccessibilityElement). Ensures semantics trees are explicitly merged, roles and state descriptions are bound to platform-safe actions, and custom interactive nodes eliminate screen-reader desynchronization and focus trapping across platforms. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.
Q:How does adopting this rule prevent AI hallucinations?
This rule explicitly declares what the AI must avoid (Ad-Hoc Gesture Handling Without Semantic Node Merging and Platform A11y Action Bridging) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.
Q:Which AI coding environments are supported?
This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).
Q:Can I combine this rule with other technology stacks?
Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.