|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +import { execFileSync } from 'node:child_process'; |
| 4 | +import { existsSync, readFileSync } from 'node:fs'; |
| 5 | +import path from 'node:path'; |
| 6 | +import { fileURLToPath } from 'node:url'; |
| 7 | + |
| 8 | +const __filename = fileURLToPath(import.meta.url); |
| 9 | +const __dirname = path.dirname(__filename); |
| 10 | +const defaultRepoRoot = path.resolve(__dirname, '..'); |
| 11 | + |
| 12 | +function read(root, relativePath) { |
| 13 | + return readFileSync(path.join(root, relativePath), 'utf8'); |
| 14 | +} |
| 15 | + |
| 16 | +function fileExists(root, relativePath) { |
| 17 | + return existsSync(path.join(root, relativePath)); |
| 18 | +} |
| 19 | + |
| 20 | +function git(root, args) { |
| 21 | + return execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim(); |
| 22 | +} |
| 23 | + |
| 24 | +function assertCheck(failures, condition, message) { |
| 25 | + if (!condition) failures.push(message); |
| 26 | +} |
| 27 | + |
| 28 | +function parseArgs(argv) { |
| 29 | + const args = { |
| 30 | + skipBranchCheck: false, |
| 31 | + repoRoot: defaultRepoRoot, |
| 32 | + }; |
| 33 | + |
| 34 | + for (let index = 0; index < argv.length; index += 1) { |
| 35 | + const arg = argv[index]; |
| 36 | + if (arg === '--skip-branch-check') args.skipBranchCheck = true; |
| 37 | + else if (arg === '--repo-root') args.repoRoot = path.resolve(argv[++index]); |
| 38 | + else if (arg === '--help' || arg === '-h') args.help = true; |
| 39 | + else throw new Error(`Unknown argument ${arg}`); |
| 40 | + } |
| 41 | + |
| 42 | + return args; |
| 43 | +} |
| 44 | + |
| 45 | +function printHelp() { |
| 46 | + process.stdout.write( |
| 47 | + [ |
| 48 | + 'Usage: node scripts/check-v31-gate8-auxillaries-ux-accessibility-responsive-proof.mjs [--skip-branch-check] [--repo-root <path>]', |
| 49 | + '', |
| 50 | + 'Checks V31 Gate 8 Auxillaries low-detail UX, named landmarks, skip navigation, active-pane state announcements, responsive CSS, reduced-motion posture, tests, docs, and workflow coverage.', |
| 51 | + ].join('\n'), |
| 52 | + ); |
| 53 | + process.stdout.write('\n'); |
| 54 | +} |
| 55 | + |
| 56 | +function main() { |
| 57 | + const args = parseArgs(process.argv.slice(2)); |
| 58 | + if (args.help) { |
| 59 | + printHelp(); |
| 60 | + return; |
| 61 | + } |
| 62 | + |
| 63 | + const root = args.repoRoot; |
| 64 | + const failures = []; |
| 65 | + const pointer = read(root, 'BITCODE_SPEC.txt').trim(); |
| 66 | + |
| 67 | + assertCheck( |
| 68 | + failures, |
| 69 | + pointer === 'V30', |
| 70 | + `BITCODE_SPEC.txt must remain V30 during V31 gate work. Observed ${pointer || 'empty'}.`, |
| 71 | + ); |
| 72 | + |
| 73 | + if (!args.skipBranchCheck) { |
| 74 | + const branch = git(root, ['branch', '--show-current']); |
| 75 | + assertCheck( |
| 76 | + failures, |
| 77 | + branch === 'version/v31' || /^v31\/gate-(?:8|9|10)-[a-z0-9][a-z0-9-]*$/u.test(branch), |
| 78 | + `V31 Gate 8+ work must occur on version/v31 or v31/gate-8+ branches. Observed ${branch || 'detached HEAD'}.`, |
| 79 | + ); |
| 80 | + } |
| 81 | + |
| 82 | + for (const relativePath of [ |
| 83 | + 'uapi/app/auxillaries/components/AuxillariesContent.tsx', |
| 84 | + 'uapi/app/auxillaries/components/shared/AuxillariesWorkspacePanels.tsx', |
| 85 | + 'uapi/app/auxillaries/auxillaries-ux-accessibility-proof.ts', |
| 86 | + 'uapi/styles/auxillaries-bitcode.css', |
| 87 | + 'uapi/tests/auxillariesContent.access.test.tsx', |
| 88 | + 'uapi/tests/auxillariesWorkspacePanels.access.test.tsx', |
| 89 | + 'BITCODE_SPEC_V31.md', |
| 90 | + 'BITCODE_SPEC_V31_DELTA.md', |
| 91 | + 'BITCODE_SPEC_V31_NOTES.md', |
| 92 | + 'BITCODE_SPEC_V31_PARITY_MATRIX.md', |
| 93 | + 'SPECIFICATIONS_ROADMAP.md', |
| 94 | + 'uapi/app/auxillaries/README.md', |
| 95 | + ]) { |
| 96 | + assertCheck(failures, fileExists(root, relativePath), `Missing V31 Gate 8 file: ${relativePath}`); |
| 97 | + } |
| 98 | + |
| 99 | + const content = read(root, 'uapi/app/auxillaries/components/AuxillariesContent.tsx'); |
| 100 | + const workspacePanels = read(root, 'uapi/app/auxillaries/components/shared/AuxillariesWorkspacePanels.tsx'); |
| 101 | + const proofContract = read(root, 'uapi/app/auxillaries/auxillaries-ux-accessibility-proof.ts'); |
| 102 | + const css = read(root, 'uapi/styles/auxillaries-bitcode.css'); |
| 103 | + const contentTest = read(root, 'uapi/tests/auxillariesContent.access.test.tsx'); |
| 104 | + const panelsTest = read(root, 'uapi/tests/auxillariesWorkspacePanels.access.test.tsx'); |
| 105 | + const spec = read(root, 'BITCODE_SPEC_V31.md'); |
| 106 | + const delta = read(root, 'BITCODE_SPEC_V31_DELTA.md'); |
| 107 | + const notes = read(root, 'BITCODE_SPEC_V31_NOTES.md'); |
| 108 | + const parity = read(root, 'BITCODE_SPEC_V31_PARITY_MATRIX.md'); |
| 109 | + const roadmap = read(root, 'SPECIFICATIONS_ROADMAP.md'); |
| 110 | + const auxReadme = read(root, 'uapi/app/auxillaries/README.md'); |
| 111 | + const packageJson = read(root, 'package.json'); |
| 112 | + const workflow = read(root, '.github/workflows/bitcode-gate-quality.yml'); |
| 113 | + const jestConfig = read(root, 'uapi/jest.config.cjs'); |
| 114 | + |
| 115 | + for (const contentPhrase of [ |
| 116 | + 'aria-label="Bitcode Auxillaries support plane"', |
| 117 | + 'Skip to active support pane', |
| 118 | + 'href="#auxillaries-active-pane"', |
| 119 | + 'role="navigation"', |
| 120 | + 'aria-label="Auxillaries pane navigation"', |
| 121 | + 'role="region"', |
| 122 | + 'aria-live="polite"', |
| 123 | + 'aria-busy', |
| 124 | + 'role="status"', |
| 125 | + 'auxillaries-active-pane-summary', |
| 126 | + 'auxillaries-audit-detail', |
| 127 | + 'source-safe summary only', |
| 128 | + ]) { |
| 129 | + assertCheck(failures, content.includes(contentPhrase), `AuxillariesContent must expose ${contentPhrase}.`); |
| 130 | + } |
| 131 | + |
| 132 | + for (const panelPhrase of ['aria-current', 'aria-disabled', 'aria-describedby', 'sr-only']) { |
| 133 | + assertCheck(failures, workspacePanels.includes(panelPhrase), `Workspace panels must expose ${panelPhrase}.`); |
| 134 | + } |
| 135 | + |
| 136 | + for (const proofPhrase of [ |
| 137 | + 'AUXILLARIES_UX_ACCESSIBILITY_PROOF_CONTRACT', |
| 138 | + 'summarizeAuxillariesUxAccessibilityProofContract', |
| 139 | + 'auxillariesMain', |
| 140 | + 'auxillariesPaneNavigation', |
| 141 | + 'auxillariesActivePane', |
| 142 | + 'phone', |
| 143 | + 'tablet', |
| 144 | + 'laptop', |
| 145 | + 'widescreen', |
| 146 | + ]) { |
| 147 | + assertCheck(failures, proofContract.includes(proofPhrase), `Auxillaries UX proof contract must include ${proofPhrase}.`); |
| 148 | + } |
| 149 | + |
| 150 | + for (const cssPhrase of [ |
| 151 | + '.auxillaries-skip-link', |
| 152 | + 'focus-visible', |
| 153 | + 'overflow-wrap: anywhere', |
| 154 | + '@media (max-width: 1023px)', |
| 155 | + '@media (max-width: 640px)', |
| 156 | + '@media (prefers-reduced-motion: reduce)', |
| 157 | + 'scroll-behavior: auto', |
| 158 | + ]) { |
| 159 | + assertCheck(failures, css.includes(cssPhrase), `Auxillaries CSS must include ${cssPhrase}.`); |
| 160 | + } |
| 161 | + |
| 162 | + for (const testPhrase of [ |
| 163 | + "getByRole('main'", |
| 164 | + "getByRole('link'", |
| 165 | + "getByRole('navigation'", |
| 166 | + "getByRole('region'", |
| 167 | + 'aria-live', |
| 168 | + 'aria-busy', |
| 169 | + 'auxillaries-audit-detail', |
| 170 | + 'source-safe summary only', |
| 171 | + 'queryByText(/\"currentStep\"/)', |
| 172 | + 'summarizeAuxillariesUxAccessibilityProofContract', |
| 173 | + ]) { |
| 174 | + assertCheck(failures, contentTest.includes(testPhrase), `Auxillaries content accessibility tests must cover ${testPhrase}.`); |
| 175 | + } |
| 176 | + |
| 177 | + for (const panelTestPhrase of ['aria-current', 'aria-disabled', 'Locked auxillary']) { |
| 178 | + assertCheck(failures, panelsTest.includes(panelTestPhrase), `Workspace panel accessibility tests must cover ${panelTestPhrase}.`); |
| 179 | + } |
| 180 | + |
| 181 | + for (const docPhrase of [ |
| 182 | + 'Gate 8', |
| 183 | + 'low-detail', |
| 184 | + 'expandable audit', |
| 185 | + 'named main landmark', |
| 186 | + 'skip link', |
| 187 | + 'active pane', |
| 188 | + 'keyboard', |
| 189 | + 'focus', |
| 190 | + 'labels', |
| 191 | + 'state announcement', |
| 192 | + 'contrast', |
| 193 | + 'reduced-motion', |
| 194 | + 'responsive', |
| 195 | + ]) { |
| 196 | + assertCheck( |
| 197 | + failures, |
| 198 | + spec.includes(docPhrase) || |
| 199 | + delta.includes(docPhrase) || |
| 200 | + notes.includes(docPhrase) || |
| 201 | + parity.includes(docPhrase) || |
| 202 | + roadmap.includes(docPhrase) || |
| 203 | + auxReadme.includes(docPhrase), |
| 204 | + `V31 Gate 8 docs/spec must describe ${docPhrase}.`, |
| 205 | + ); |
| 206 | + } |
| 207 | + |
| 208 | + assertCheck( |
| 209 | + failures, |
| 210 | + /Current working gate: V31 Gate (?:8|9|10)\b/u.test(roadmap), |
| 211 | + 'Roadmap must track V31 Gate 8 or a later V31 gate as current working gate.', |
| 212 | + ); |
| 213 | + assertCheck(failures, packageJson.includes('"check:v31-gate8"'), 'package.json must expose check:v31-gate8.'); |
| 214 | + assertCheck( |
| 215 | + failures, |
| 216 | + workflow.includes('check-v31-gate8-auxillaries-ux-accessibility-responsive-proof.mjs'), |
| 217 | + 'Gate quality workflow must run the V31 Gate 8 checker.', |
| 218 | + ); |
| 219 | + assertCheck( |
| 220 | + failures, |
| 221 | + workflow.includes('tests/auxillariesContent.access.test.tsx') && jestConfig.includes('auxillariesContent.access.test.tsx'), |
| 222 | + 'Gate quality and Jest config must include Auxillaries content accessibility tests.', |
| 223 | + ); |
| 224 | + |
| 225 | + if (failures.length) { |
| 226 | + process.stderr.write('V31 Gate 8 Auxillaries UX/accessibility closure check failed:\n'); |
| 227 | + for (const failure of failures) process.stderr.write(`- ${failure}\n`); |
| 228 | + process.exit(1); |
| 229 | + } |
| 230 | + |
| 231 | + process.stdout.write('V31 Gate 8 Auxillaries UX/accessibility closure check passed.\n'); |
| 232 | +} |
| 233 | + |
| 234 | +main(); |
0 commit comments