An open source design system that's fully customizable and agent ready
TypeScript
fix(rtl-audit): D5 grades declared chart overlays as physical (DR5) (#9323)
Cindy Zhang26a1b0989a24
diff --git a/.github/scripts/rtl-audit-coverage.test.mjs b/.github/scripts/rtl-audit-coverage.test.mjsindex 243a51ecd2..ab5301a6e8 100644--- a/.github/scripts/rtl-audit-coverage.test.mjs+++ b/.github/scripts/rtl-audit-coverage.test.mjs@@ -20,11 +20,14 @@ import {classifyLogicalInlinePair,collectDirectionalDecorations,filterStoryRoutesByPackages,- glyphRendersOnBlockAxis,+ assertSelectorParses,+ bindDetectorValue,d1GlyphKey,d1PairKey,+ glyphRendersOnBlockAxis,isUnchangedBlockAxisPair,finishFiniteAnimations,+ gradePositionedPair,orderD1StoryCandidates,resolveD1Applicability,resolveFilterRoutes,@@ -1020,6 +1023,108 @@ describe('finishFiniteAnimations', () => {});});+describe('gradePositionedPair', () => {+ const ltr = (physical = null) => ({parentW: 1000, relCenterX: 200, physical});+ const at = relCenterX => ({parentW: 1000, relCenterX});++ it('requires an unmarked element to mirror about its parent center', () => {+ expect(gradePositionedPair(ltr(), at(800), 3)).toMatchObject({+ expectation: 'mirror',+ pass: true,+ });+ expect(gradePositionedPair(ltr(), at(200), 3).pass).toBe(false);+ });++ it('requires a chart overlay to keep its physical position (DR5)', () => {+ expect(gradePositionedPair(ltr('chart'), at(200), 3)).toMatchObject({+ expectation: 'physical',+ pass: true,+ });+ });++ it('fails a mirrored chart tooltip', () => {+ expect(gradePositionedPair(ltr('chart'), at(800), 3)).toMatchObject({+ expectation: 'physical',+ pass: false,+ });+ });++ it('fails closed on an unknown physical kind', () => {+ expect(gradePositionedPair(ltr('map'), at(200), 3)).toMatchObject({+ expectation: 'invalid-marker',+ pass: false,+ });+ });+});++describe('rtlAudit.D5 physical-region metadata', () => {+ const within = '[aria-label="Quarterly performance chart"]';++ it('admits a chart plot declaration', () => {+ expect(+ validateStoryRtlAuditParameters({D5: {physical: 'chart', within}}, 's'),+ ).toEqual({D5: {physical: 'chart', within}});+ });++ it('rejects an unknown physical kind', () => {+ expect(() =>+ validateStoryRtlAuditParameters({D5: {physical: 'map', within}}, 's'),+ ).toThrow(/D5.physical/);+ });++ it('rejects a declaration without a plot selector', () => {+ expect(() =>+ validateStoryRtlAuditParameters({D5: {physical: 'chart'}}, 's'),+ ).toThrow(/D5.within/);+ expect(() =>+ validateStoryRtlAuditParameters(+ {D5: {physical: 'chart', within: ' '}},+ 's',+ ),+ ).toThrow(/D5.within/);+ });+});++describe('assertSelectorParses', () => {+ const doc = {+ querySelector(selector) {+ if (selector.includes('[[')) {+ throw new SyntaxError('not a valid selector');+ }+ return null;+ },+ };++ it('accepts a selector the page can parse, matched or not', () => {+ expect(() =>+ assertSelectorParses(doc, '[aria-label="Plot"]'),+ ).not.toThrow();+ });++ it('fails closed on a selector the page cannot parse', () => {+ expect(() => assertSelectorParses(doc, '[[aria-label')).toThrow(+ /rtlAudit.D5.within/,+ );+ });+});++describe('bindDetectorValue', () => {+ it('binds a selector containing $ patterns verbatim', () => {+ const physical = {physical: 'chart', within: "[data-plot='q$']"};+ expect(bindDetectorValue('run(__P__)', '__P__', physical)).toBe(+ `run(${JSON.stringify(physical)})`,+ );+ const tricky = {physical: 'chart', within: "[data-plot='$&$1$$']"};+ expect(bindDetectorValue('run(__P__)', '__P__', tricky)).toBe(+ `run(${JSON.stringify(tricky)})`,+ );+ });++ it('binds null when no region is declared', () => {+ expect(bindDetectorValue('run(__P__)', '__P__', null)).toBe('run(null)');+ });+});+describe('glyphRendersOnBlockAxis', () => {// CSS matrix(a, b, c, d) order: rotate(90deg) is [0, 1, -1, 0].const identity = [1, 0, 0, 1];diff --git a/.github/scripts/rtl-scorecard-summary.mjs b/.github/scripts/rtl-scorecard-summary.mjsindex 1e83c431fa..f1cb9c80ae 100644--- a/.github/scripts/rtl-scorecard-summary.mjs+++ b/.github/scripts/rtl-scorecard-summary.mjs@@ -4,7 +4,7 @@/*** @file Markdown scorecard for one package's RTL audit report.* @input --report <rtl-audit-report.json> --scope <audited components label>,- * including any declared D1 exclusions.+ * including any declared D1 exclusions and D5 physical regions.* @output The job-summary section on stdout, with review-facing exclusion* disclosure.* @position Shared by the pr-rtl package legs and the sharded-package merge@@ -85,6 +85,23 @@ if (!fs.existsSync(reportPath)) {out.push('_No declared D1 exclusions in this audit scope._');}out.push('');+ // Story-declared plots whose overlays D5 grades as physical (DR5) get the+ // same review-facing disclosure as D1 exclusions (INV16).+ const declaredD5PhysicalRegions = r.declaredD5PhysicalRegions ?? [];+ out.push('### Declared D5 physical regions (human review required)');+ out.push('');+ if (declaredD5PhysicalRegions.length > 0) {+ out.push('| Component | Story | Kind | Plot selector |');+ out.push('|-----------|-------|------|---------------|');+ for (const region of declaredD5PhysicalRegions) {+ out.push(+ `| ${markdownCell(region.component)} | ${markdownCell(region.storyId)} | ${markdownCell(region.physical)} | ${markdownCell(region.within)} |`,+ );+ }+ } else {+ out.push('_No declared D5 physical regions in this audit scope._');+ }+ out.push('');const pm = r.positionalMirror;if (pm) {out.push('### Positional-mirror (D5, all scoped stories)');diff --git a/.github/scripts/rtl-scorecard-summary.test.mjs b/.github/scripts/rtl-scorecard-summary.test.mjsindex c2c0a2233a..d8c55bb306 100644--- a/.github/scripts/rtl-scorecard-summary.test.mjs+++ b/.github/scripts/rtl-scorecard-summary.test.mjs@@ -88,3 +88,33 @@ describe('RTL scorecard D1 exclusion disclosure', () => {expect(result.stdout).toContain('RTL-ready (D1 pass): —.');});});++describe('RTL scorecard D5 physical-region disclosure', () => {+ it('lists every declared physical region with its story and selector', () => {+ const report = reportWith([]);+ report.declaredD5PhysicalRegions = [+ {+ component: 'lab/charttheming-recharts',+ storyId: 'lab-charttheming-recharts--theme-tokens',+ physical: 'chart',+ within: '[aria-label="Quarterly performance chart"]',+ },+ ];+ const result = runSummary(report);++ expect(result.status).toBe(0);+ expect(result.stdout).toContain(+ '### Declared D5 physical regions (human review required)',+ );+ expect(result.stdout).toContain(+ '| lab/charttheming-recharts | lab-charttheming-recharts--theme-tokens | chart | [aria-label="Quarterly performance chart"] |',+ );+ });++ it('says so when no physical region is declared', () => {+ const result = runSummary(reportWith([]));+ expect(result.stdout).toContain(+ '_No declared D5 physical regions in this audit scope._',+ );+ });+});diff --git a/apps/storybook/rtl-audit/rtl-audit-coverage.mjs b/apps/storybook/rtl-audit/rtl-audit-coverage.mjsindex 2bdb937076..fb7a6380db 100644--- a/apps/storybook/rtl-audit/rtl-audit-coverage.mjs+++ b/apps/storybook/rtl-audit/rtl-audit-coverage.mjs@@ -353,7 +353,7 @@ export function withD1CompletionIdentity(result, plannedStoryId) {};}-const STORY_RTL_AUDIT_DIMENSIONS = new Set(['D1']);+const STORY_RTL_AUDIT_DIMENSIONS = new Set(['D1', 'D5']);/** Validate resolved Storybook RTL-audit applicability metadata. */export function validateStoryRtlAuditParameters(value, storyId) {@@ -367,6 +367,10 @@ export function validateStoryRtlAuditParameters(value, storyId) {if (!STORY_RTL_AUDIT_DIMENSIONS.has(dimension)) {throw new Error(`${storyId} rtlAudit has unknown dimension ${dimension}`);}+ if (dimension === 'D5') {+ result.D5 = validatePhysicalPosition(applicability, storyId);+ continue;+ }if (applicability == null ||typeof applicability !== 'object' ||@@ -397,6 +401,25 @@ export function validateStoryRtlAuditParameters(value, storyId) {return result;}+// rtlAudit.D5 declares a region whose positioned elements stay physical+// (DR5); it never turns D5 off for the story.+function validatePhysicalPosition(value, storyId) {+ if (value == null || typeof value !== 'object' || Array.isArray(value)) {+ throw new Error(`${storyId} rtlAudit.D5 must be an object`);+ }+ if (!PHYSICAL_POSITION_MARKERS.includes(value.physical)) {+ throw new Error(+ `${storyId} rtlAudit.D5.physical must be one of ${PHYSICAL_POSITION_MARKERS.join(', ')}`,+ );+ }+ if (typeof value.within !== 'string' || !value.within.trim()) {+ throw new Error(+ `${storyId} rtlAudit.D5.within must name the plot with a non-empty selector`,+ );+ }+ return {physical: value.physical, within: value.within.trim()};+}+/** Selected owners for which the canonical Storybook route has no story. */export function unresolvedComponentFilters(routes, filters) {return filters.filter(@@ -588,6 +611,61 @@ export function finishFiniteAnimations(doc) {return finished;}+/**+ * Declared position semantics a story's `rtlAudit.D5.physical` may name.+ * `chart`: elements inside the declared plot sit in chart coordinates, which+ * stay physical in RTL (`design:bidirectionality` DR5), such as a tooltip that+ * follows a plotted bar.+ */+export const PHYSICAL_POSITION_MARKERS = Object.freeze(['chart']);++/**+ * Fail closed on a `rtlAudit.D5.within` selector the page cannot parse, so a+ * typo cannot silently grade every overlay as mirrored. Runs in the page: keep+ * it self-contained.+ */+export function assertSelectorParses(doc, selector) {+ try {+ doc.querySelector(selector);+ } catch {+ throw new Error(`rtlAudit.D5.within "${selector}" is not a valid selector`);+ }+}++/**+ * Bind a JSON value into an in-page detector's placeholder. A replacer+ * function is used so `$` sequences in the value (`[data-plot='q$']`) are not+ * read as replacement patterns.+ */+export function bindDetectorValue(source, placeholder, value) {+ return source.replace(placeholder, () => JSON.stringify(value));+}++/**+ * Grade one LTR/RTL pair of D5 positioned elements. By default the RTL center+ * must mirror the LTR center about the parent's center. Under a declared+ * `chart` marker it must keep the same physical position instead, and a+ * mirrored chart overlay fails. An unknown marker fails closed rather than+ * being guessed at.+ */+export function gradePositionedPair(ltr, rtl, tolerance) {+ const marker = ltr.physical ?? null;+ if (marker != null && !PHYSICAL_POSITION_MARKERS.includes(marker)) {+ return {+ expectation: 'invalid-marker',+ expected: null,+ delta: null,+ pass: false,+ reason: `unknown rtlAudit.D5 physical kind "${marker}"`,+ };+ }+ const expectation = marker === 'chart' ? 'physical' : 'mirror';+ const expected =+ expectation === 'physical' ? ltr.relCenterX : ltr.parentW - ltr.relCenterX;+ const delta = Math.abs(rtl.relCenterX - expected);+ return {expectation, expected, delta, pass: delta <= tolerance};+}+/*** Does a left- or right-pointing glyph render pointing up or down? `matrix` is* the glyph's composed 2x2 transform (CSS `matrix(a, b, c, d)` order). Adiff --git a/apps/storybook/rtl-audit/rtl-audit.mjs b/apps/storybook/rtl-audit/rtl-audit.mjsindex 93f7f2fd70..74e6b7b41d 100644--- a/apps/storybook/rtl-audit/rtl-audit.mjs+++ b/apps/storybook/rtl-audit/rtl-audit.mjs@@ -66,11 +66,14 @@ import {componentFromTarget,evaluateDirectionalDecorations,filterStoryRoutesByPackages,+ assertSelectorParses,+ bindDetectorValue,resolveFilterRoutes,finishFiniteAnimations,d1GlyphKey,d1PairKey,glyphRendersOnBlockAxis,+ gradePositionedPair,isUnchangedBlockAxisPair,orderD1StoryCandidates,resolveD1Applicability,@@ -547,7 +550,7 @@ function decorationCard(component, storyId, ltr, rtl) {// or "wildly off" reading that is pure noise — the spike's single false// positive came from exactly this, and the guard removes it.const PM_DETECTOR = /* js */ `-(() => {+((PHYSICAL) => {function parseMatrixX(t) {if (!t || t === 'none') return null;let m = t.match(/^matrix\\(([^)]+)\\)/);@@ -603,14 +606,25 @@ const PM_DETECTOR = /* js */ `cls: (el.className && el.className.toString().slice(0, 48)) || '',parentW: pr.width,relCenterX,+ // Inside the story-declared plot (rtlAudit.D5), chart coordinates stay+ // physical (DR5).+ physical: PHYSICAL && el.closest(PHYSICAL.within) ? PHYSICAL.physical : null,});}return out;-})()+})(__RTL_PHYSICAL__)`;-async function detectPositioned(page) {- return page.evaluate(PM_DETECTOR).catch(() => []);+async function detectPositioned(page, physical = null) {+ // An unparsable plot selector errors the story rather than being skipped+ // (INV13); it is checked outside the catch below.+ if (physical) {+ await page.evaluate(+ `(${assertSelectorParses.toString()})(document, ${JSON.stringify(physical.within)})`,+ );+ }+ const detector = bindDetectorValue(PM_DETECTOR, '__RTL_PHYSICAL__', physical);+ return page.evaluate(detector).catch(() => []);}// Auto-discovery D5 for one story: compare LTR vs RTL positioned-element@@ -621,6 +635,10 @@ const PM_TOL = Number(process.env.PM_TOL || 3); // px tolerance (signal gap wasfunction positionalCard(component, storyId, ltrMeasure, rtlMeasure) {const card = {component, storyId, dim: 'D5-positional', verdict: 'N-A', notes: [], candidates: 0, fails: []};+ // Disclose every declared physical region (INV16), whatever the verdict.+ if (ltrMeasure.physical) {+ card.declaredD5Physical = {component, storyId, ...ltrMeasure.physical};+ }const ltr = ltrMeasure.positioned;const revealedL = PM_REVEAL && ltrMeasure.revealed;@@ -654,25 +672,29 @@ function positionalCard(component, storyId, ltrMeasure, rtlMeasure) {// parent's horizontal center.const n = Math.min(ltr.length, rtl.length);let anyFail = false;+ let anyPhysical = false;const perEl = [];for (let i = 0; i < n; i++) {const L = ltr[i], R = rtl[i];- const expectedRtlCX = L.parentW - L.relCenterX; // mirror about parent center- const delta = Math.abs(R.relCenterX - expectedRtlCX);- const mirrored = delta <= PM_TOL;- if (!mirrored) {+ // Mirror about the parent center, or keep the physical position under a+ // declared chart marker (DR5); an unknown marker fails closed.+ const grade = gradePositionedPair(L, R, PM_TOL);+ if (grade.expectation === 'physical') anyPhysical = true;+ if (!grade.pass) {anyFail = true;card.fails.push({cls: L.cls,tag: L.tag,+ expectation: grade.expectation,parentW: Math.round(L.parentW),ltrRelCenterX: Math.round(L.relCenterX * 10) / 10,rtlRelCenterX: Math.round(R.relCenterX * 10) / 10,- expectedRtlCenterX: Math.round(expectedRtlCX * 10) / 10,- delta: Math.round(delta * 10) / 10,+ expectedRtlCenterX: grade.expected == null ? null : Math.round(grade.expected * 10) / 10,+ delta: grade.delta == null ? null : Math.round(grade.delta * 10) / 10,+ reason: grade.reason,});}- perEl.push({idx: i, cls: L.cls, delta: Math.round(delta * 10) / 10, mirrored});+ perEl.push({idx: i, cls: L.cls, expectation: grade.expectation, delta: grade.delta == null ? null : Math.round(grade.delta * 10) / 10, pass: grade.pass});}card.perEl = perEl;if (anyFail) {@@ -680,12 +702,18 @@ function positionalCard(component, storyId, ltrMeasure, rtlMeasure) {card.notes.push(`positioned element(s) land on the wrong side in RTL: ` +card.fails- .map(f => `${f.cls || f.tag} (LTR cx ${f.ltrRelCenterX} → RTL cx ${f.rtlRelCenterX}, expected ~${f.expectedRtlCenterX}, Δ${f.delta}px)`)+ .map(f => f.reason+ ? `${f.cls || f.tag} (${f.reason})`+ : `${f.cls || f.tag} (${f.expectation === 'physical' ? 'chart position should stay physical; ' : ''}LTR cx ${f.ltrRelCenterX} → RTL cx ${f.rtlRelCenterX}, expected ~${f.expectedRtlCenterX}, Δ${f.delta}px)`).join('; '),);} else {card.verdict = 'pass';- card.notes.push(`every positioned candidate mirrors about its parent center (≤${PM_TOL}px)`);+ card.notes.push(+ anyPhysical+ ? `every positioned candidate holds its expected position (mirrored, or physical in a declared chart plot) (≤${PM_TOL}px)`+ : `every positioned candidate mirrors about its parent center (≤${PM_TOL}px)`,+ );}return card;}@@ -699,12 +727,18 @@ async function measureAutoStory(page, port, storyId, rtl, {positioned, decoratioawait page.goto(storyUrl(port, storyId, rtl), {waitUntil: 'domcontentloaded'});await settle(page);const measure = {positioned: [], decorations: [], revealed: false};- if (positioned && !PM_REVEAL) measure.positioned = await detectPositioned(page);+ // A story may declare a plot whose overlays stay physical (rtlAudit.D5);+ // D5 still scans it. Malformed metadata throws (INV13).+ const physical = positioned+ ? (await readStoryRtlAuditParameters(page, storyId)).D5 ?? null+ : null;+ if (positioned && !PM_REVEAL) measure.positioned = await detectPositioned(page, physical);if (decorations || (positioned && PM_REVEAL)) {measure.revealed = await revealInteractionGated(page);}- if (positioned && PM_REVEAL) measure.positioned = await detectPositioned(page);+ if (positioned && PM_REVEAL) measure.positioned = await detectPositioned(page, physical);if (decorations) measure.decorations = await detectDirectionalDecorations(page);+ measure.physical = physical;return measure;}@@ -1616,6 +1650,9 @@ async function cleanupRuntime() {const surprises = autoFails;const pmFails = pmResults.filter(r => r.verdict === 'fail' || r.verdict === 'ERROR');const decorationFails = decorationResults.filter(r => r.verdict === 'fail' || r.verdict === 'ERROR');+ const declaredD5PhysicalRegions = pmResults.flatMap(result =>+ result.declaredD5Physical ? [result.declaredD5Physical] : [],+ );const declaredD1Exclusions = autoResults.flatMap(result => result.declaredD1Exclusions ?? []).sort(@@ -1661,6 +1698,8 @@ async function cleanupRuntime() {// fresh page.pageRecoveries,declaredD1Exclusions,+ // Story-declared plots whose overlays D5 grades as physical (DR5).+ declaredD5PhysicalRegions,autoDiscovery: {total: autoResults.length,applicable: autoResults.filter(r => r.verdict !== 'N-A').length,@@ -1698,6 +1737,7 @@ async function cleanupRuntime() {console.error(`DEC : ${report.directionalDecorations.pass} pass / ${report.directionalDecorations.fail} fail / ${report.directionalDecorations.na} N-A`);console.error(`POOL: ${pageRecoveries.length} page replacement(s) after a failed story`);console.error(`COV : ${coverage.measured} measured / ${coverage.verifiedNa} verified N-A / ${coverage.gaps} gap / ${coverage.staleVerifiedNa} stale`);+ if (declaredD5PhysicalRegions.length > 0) console.error(`D5P : ${declaredD5PhysicalRegions.length} declared physical region(s): ${declaredD5PhysicalRegions.map(r => `${r.storyId} (${r.physical} within ${r.within})`).join('; ')}`);// Non-zero exit only signals CI (which is soft/continue-on-error). Surface a// signal but never let it hard-block during the stability window.const anySignal =diff --git a/apps/storybook/rtl-audit/story-parameters.ts b/apps/storybook/rtl-audit/story-parameters.tsindex ebf42b3c7a..ef2db01720 100644--- a/apps/storybook/rtl-audit/story-parameters.ts+++ b/apps/storybook/rtl-audit/story-parameters.ts@@ -1,7 +1,7 @@// Copyright (c) Meta Platforms, Inc. and affiliates./**- * @file Typed Storybook parameters for per-dimension RTL audit applicability.+ * @file Typed Storybook parameters for per-dimension RTL audit applicability and declared physical regions.* @input A story's dimension-specific applicability and rationale.* @output Storybook's `{rtlAudit: ...}` parameter shape.* @position Authoring boundary between story fixtures and the external RTL audit.@@ -11,9 +11,18 @@export type RtlAuditApplicability ={applicable: true; reason?: string} | {applicable: false; reason: string};+/**+ * A story-declared region whose positioned elements stay physical in RTL:+ * `chart` marks a plot whose overlays follow chart coordinates+ * (`design:bidirectionality` DR5). D5 still scans the story; it expects those+ * overlays to keep their position instead of mirroring.+ */+export type RtlAuditPhysicalPosition = {physical: 'chart'; within: string};+/** Storybook parameters consumed by the rendered RTL audit. */export type RtlAuditParameters = {D1?: RtlAuditApplicability;+ D5?: RtlAuditPhysicalPosition;};/** Type-check RTL audit parameters while preserving Storybook's parameter shape. */diff --git a/apps/storybook/stories/ChartThemingRecharts.stories.tsx b/apps/storybook/stories/ChartThemingRecharts.stories.tsxindex 4d012e5991..bfd4fd9e77 100644--- a/apps/storybook/stories/ChartThemingRecharts.stories.tsx+++ b/apps/storybook/stories/ChartThemingRecharts.stories.tsx@@ -8,6 +8,7 @@ import {Button, Card, Stack, Text} from '@astryxdesign/core';import {Theme, defineTheme, useTheme} from '@astryxdesign/core/theme';import {Heading} from '@astryxdesign/core/Text';import {useCssLengthInPixels} from './chartThemingUtils';+import {rtlAuditParameters} from '../rtl-audit/story-parameters';import {dataVars} from '@astryxdesign/core/theme/dataTokens.stylex';import {colorVars,@@ -32,6 +33,14 @@ import {const meta: Meta = {title: 'Lab/ChartTheming/Recharts',parameters: {+ // The plot stays physical in RTL (design:bidirectionality DR5), so its+ // tooltip keeps beside the bar it describes instead of mirroring.+ ...rtlAuditParameters({+ D5: {+ physical: 'chart',+ within: '[aria-label="Quarterly performance chart"]',+ },+ }),docs: {description: {component:diff --git a/docs/architecture/rtl-audit-evidence.md b/docs/architecture/rtl-audit-evidence.mdindex d616429c11..3c3aef00b9 100644--- a/docs/architecture/rtl-audit-evidence.md+++ b/docs/architecture/rtl-audit-evidence.md@@ -62,15 +62,15 @@ deciding_specs: []## Contract at a glance-| Area | Contract |-| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Governing contract | `design:bidirectionality` owns what correct RTL behavior means; component contracts own local semantics, exceptions, and verification. No product contract changes; this record owns evidence admission and freshness. |-| System behavior | Every component in the live roster is accounted for; available in-scope stories are rendered LTR and RTL. Results distinguish measured, verified N/A, coverage gap, and behavior failure. Lint and rendered audit prove different claims. |-| End-user impact | People reading RTL interfaces are protected by evidence that actually observed mirroring, ordering, placement, geometry, and behavior, rather than by a green report that measured nothing. |-| Builder impact | A new or changed component must either be measured by an applicable check or carry an explicit gap; behavior failures have no allowlist. Verified-N/A and pre-existing-debt admission await owner decisions (OQ1, OQ2). |-| Compatibility/readiness | INV12–INV16 specify D1 fixture metadata and stable selection, not shipped enforcement. Component-wide N/A admission, historical debt, and required-check rollout remain unresolved; D7 enforces each configured native target minimum. |-| Review checks | Reject lint standing in for rendered evidence (INV1); an allowlist that relabels a behavior failure (INV3); all-N/A credited as RTL-ready (INV4); a component dropping from the roster because its story moved (INV5); a new dimension without a red/green mutation receipt (INV9); a D1 exclusion on directional controls/cues or missing review-facing disclosure (INV12, INV16). |-| Governing rules | No deciding system spec; `architecture:knowledge-contracts` evidence-freshness and human-decision rules apply. |+| Area | Contract |+| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| Governing contract | `design:bidirectionality` owns what correct RTL behavior means; component contracts own local semantics, exceptions, and verification. No product contract changes; this record owns evidence admission and freshness. |+| System behavior | Every component in the live roster is accounted for; available in-scope stories are rendered LTR and RTL. Results distinguish measured, verified N/A, coverage gap, and behavior failure. Lint and rendered audit prove different claims. |+| End-user impact | People reading RTL interfaces are protected by evidence that actually observed mirroring, ordering, placement, geometry, and behavior, rather than by a green report that measured nothing. |+| Builder impact | A new or changed component must either be measured by an applicable check or carry an explicit gap; behavior failures have no allowlist. Verified-N/A and pre-existing-debt admission await owner decisions (OQ1, OQ2). |+| Compatibility/readiness | INV12–INV16 specify D1 fixture metadata and stable selection, plus the D5 chart-plot declaration (`rtlAudit.D5`), not shipped enforcement. Component-wide N/A admission, historical debt, and required-check rollout remain unresolved; D7 enforces each configured native target minimum. |+| Review checks | Reject lint standing in for rendered evidence (INV1); an allowlist that relabels a behavior failure (INV3); all-N/A credited as RTL-ready (INV4); a component dropping from the roster because its story moved (INV5); a new dimension without a red/green mutation receipt (INV9); a D1 exclusion on directional controls/cues, or a D1 exclusion or D5 chart declaration missing review-facing disclosure (INV12, INV13, INV16). |+| Governing rules | No deciding system spec; `architecture:knowledge-contracts` evidence-freshness and human-decision rules apply. |This table is a review projection; the body below is authoritative.@@ -184,7 +184,9 @@ Lint and rendered audit are complementary:human review and disclosure requirements in INV16 apply to explicit exclusions.- **INV13 — Story exclusions are typed, resolved, and fail closed.** The admittedstory metadata is `rtlAudit.D1` with `applicable: false` and a nonempty `reason`- explaining INV12. The audit reads resolved Storybook parameters, including normal+ explaining INV12, and `rtlAudit.D5` with `physical: 'chart'` and a nonempty+ `within` plot selector, which declares a plot whose overlays stay physical+ (`design:bidirectionality` DR5) without turning D5 off. The audit reads resolved Storybook parameters, including normalstory-over-meta precedence. Missing rendered metadata, malformed parameters,unsupported dimension keys, and an exclusion without a rationale MUST producean error rather than silently skip a check. An empty resolved `rtlAudit` object@@ -210,7 +212,10 @@ Lint and rendered audit are complementary:A nonempty reason proves only valid metadata, not valid non-applicability.Review-facing audit output MUST list every declared D1 exclusion in the auditedscope with its canonical component, story id, dimension, and rationale, including stories not- selected as the D1 representative. Reports MUST NOT call the absence of a D1+ selected as the D1 representative. A `rtlAudit.D5` physical-region declaration+ receives the same review and disclosure: adding or widening one is reviewed,+ and the output lists every declaration with its component, story id, kind, and+ plot selector. Reports MUST NOT call the absence of a D1measurement proof that directional behavior is correct. Automatic N/A becauseno directional icons were found requires no extra human approval; an unchangedexemption is not reapproved on every audit run. This rule does not admit@@ -240,17 +245,17 @@ The audit's `D` identifiers name repository-specific checks, not an externalinternationalization standard. Automatic discovery covers D1, D5, and D6; curatedstory targets supply the other dimensions.-| ID | Observed relationship |-| --- | ------------------------------------------------------------------------------------------------- |-| D1 | Directional icons mirror or swap once. |-| D2 | Previous/next controls exchange horizontal order. |-| D3 | Directional interaction or scroll behavior follows the active direction. |-| D4 | An overlay or positioned affordance follows its logical side. |-| D5 | Positioned elements mirror relative to their parent. |-| D6 | Contextual directional decorations receive exactly one bidi treatment. |-| D7 | Coarse-pointer native input dimensions, centers, and hit-testing meet the owning target contract. |-| D8 | Logical inline padding resolves to mirrored physical edges. |-| D9 | Grouped corners follow the declared logical inline side. |+| ID | Observed relationship |+| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| D1 | Directional icons mirror or swap once. |+| D2 | Previous/next controls exchange horizontal order. |+| D3 | Directional interaction or scroll behavior follows the active direction. |+| D4 | An overlay or positioned affordance follows its logical side. |+| D5 | Positioned elements mirror relative to their parent; inside a story-declared chart plot (`rtlAudit.D5`) they keep their physical position (`design:bidirectionality` DR5). |+| D6 | Contextual directional decorations receive exactly one bidi treatment. |+| D7 | Coarse-pointer native input dimensions, centers, and hit-testing meet the owning target contract. |+| D8 | Logical inline padding resolves to mirrored physical edges. |+| D9 | Grouped corners follow the declared logical inline side. |D7 retains both the native input box and the visible wrapper box. Its`minimumTargetSize` width and height come from the curated target's owning@@ -302,16 +307,17 @@ this record narrows the remaining decision to the options below.## Verification-| Invariant | Evidence | Failure signal |-| ---------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| INV1, INV2, INV6 | focused audit fixtures plus real built Storybook mutations | A source-only rule claims rendered correctness, or a relationship defect stays green |-| INV3 | automatic/curated failure tests and RTL scorecard tests | A known bad RTL outcome is suppressed as expected or N/A |-| INV4, INV5 | coverage fixtures with missing/no-applicable stories | A component disappears or all-N/A reports as RTL-ready |-| INV7 | PR workflow scope tests and release-check workflow tests | A changed component is skipped or full-roster debt is mistaken for PR-only evidence |-| INV8 | automatic/curated applicability tests | A newly applicable dimension leaves a verified-N/A declaration current |-| INV9 | red/green mutation receipts for each new dimension | A new dimension has only passing self-confirming tests |-| INV10 | native width/height mutation fixtures plus D7 center/hit checks in LTR/RTL, sm/md | An undersized native target stays green despite conforming wrapper geometry |-| INV12–INV16 | candidate fixture-policy tests and built Storybook mutations; not enforced by the base implementation | reordering the generated story index changes D1; malformed/missing metadata silently skips; a fixture opt-out skips D5/D6 or closes a component gap; an exclusion on directional controls/cues survives semantic review or is omitted from the summary |+| Invariant | Evidence | Failure signal |+| ---------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| INV1, INV2, INV6 | focused audit fixtures plus real built Storybook mutations | A source-only rule claims rendered correctness, or a relationship defect stays green |+| INV3 | automatic/curated failure tests and RTL scorecard tests | A known bad RTL outcome is suppressed as expected or N/A |+| INV4, INV5 | coverage fixtures with missing/no-applicable stories | A component disappears or all-N/A reports as RTL-ready |+| INV7 | PR workflow scope tests and release-check workflow tests | A changed component is skipped or full-roster debt is mistaken for PR-only evidence |+| INV8 | automatic/curated applicability tests | A newly applicable dimension leaves a verified-N/A declaration current |+| INV9 | red/green mutation receipts for each new dimension | A new dimension has only passing self-confirming tests |+| INV10 | native width/height mutation fixtures plus D7 center/hit checks in LTR/RTL, sm/md | An undersized native target stays green despite conforming wrapper geometry |+| INV12–INV16 | candidate fixture-policy tests and built Storybook mutations; not enforced by the base implementation | reordering the generated story index changes D1; malformed/missing metadata silently skips; a fixture opt-out skips D5/D6 or closes a component gap; an exclusion on directional controls/cues survives semantic review or is omitted from the summary |+| D5 (DR5) | positioned-pair grading and `rtlAudit.D5` validation tests, plus the declared Recharts theming stories in a real built Storybook | A mirrored chart tooltip passes, an undeclared overlay is graded as physical, or a malformed `rtlAudit.D5` declaration is accepted |### Implementation state