diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml
index f556556..965345f 100644
--- a/.github/workflows/verify.yml
+++ b/.github/workflows/verify.yml
@@ -2,6 +2,8 @@ name: Reproduce and verify
on:
push:
+ branches: [main]
+ tags: ['**']
pull_request:
workflow_dispatch:
@@ -74,6 +76,7 @@ jobs:
python -m unittest discover -s scripts -p 'test_atlas*.py' -v
node scripts/check_atlas_ui.cjs
node scripts/check_atlas_map.cjs
+ node scripts/check_atlas_selection.cjs
node scripts/check_tm_atlas_ui.cjs
python scripts/check_tm_retrieval.py evidence/tm-retrieval-v1/answers.json
- name: Check N5 and Turing source context bindings
diff --git a/README.md b/README.md
index 6ca02ae..7caf066 100644
--- a/README.md
+++ b/README.md
@@ -1,40 +1,44 @@
# Finite Congruence Checks
-
-
[](https://github.com/Maverick0351a/finite-congruence-checks/actions/workflows/verify.yml)
[](docs/LEAN_VERIFICATION.md)
[](https://github.com/Maverick0351a/finite-congruence-checks/releases/tag/v0.1.0)
[](LICENSE)
[](#quick-start)
-A focused research toolkit for finite congruence lattices. Search colored graphs,
-verify every quantified condition with an independent implementation, recover
-the corresponding unary algebras, and find their smallest operation lists on a
-fixed representation. The core experiment uses only Python's standard library.
-
-In plain language, we build small systems whose rules permit exactly a chosen
-pattern of consistent groupings. Start with a three-object example in the
-**[illustrated introduction](docs/PLAIN_LANGUAGE_GUIDE.md)** to see what that means.
-
-The starting specification is the graph-witness criterion in
-[OpenAI's math corpus, family 206](reference/README.md), pinned to an exact commit.
-This is an independent companion project. The original graph experiment covers
-eight specified lattices on carriers of size **one through four**. The atlas
-classifies all representable grouping families through four objects, yielding
-22 abstract lattice shapes.
-
-**[Interactive demo](https://huggingface.co/spaces/Maverick03511/finite-congruence-checks)** ·
-**[Understand the math](docs/PLAIN_LANGUAGE_GUIDE.md)** ·
-**[Why the saved N5 rules work](docs/N5_SOURCE_CONTEXT.md)** ·
-**[Readable atlas](https://maverick03511-finite-congruence-checks.static.hf.space/atlas.html)** ·
-**[Quick start](#quick-start)** · **[Evidence gallery](docs/index.html)** ·
-**[Exact claims](docs/CLAIMS.md)** · **[Lean status](docs/LEAN_VERIFICATION.md)** ·
-**[Agent repair experiment](docs/REPAIR_BENCHMARK.md)** ·
-**[TM translation checks](docs/TM_TRANSLATION_CHECKS.md)** ·
-**[Compare Turing examples](docs/TM_ATLAS.md)** ·
-**[Snaky on finite boards](docs/SNAKY_FINITE_BOARD.md)** ·
-**[Changelog](CHANGELOG.md)** · **[Support](SUPPORT.md)**
+Research tools for exact mathematical claims: finite constructions, independent
+checks, and scoped Lean proofs. Compare representations, inspect their hypotheses,
+and trace a result back to its source and reproducible evidence.
+
+The project builds on selected results from **[OpenAI Math](reference/README.md)**,
+starting with the graph-witness criterion in family 206 and extending to exact
+Turing-machine examples and Snaky on finite boards. Source revisions and claim
+boundaries are recorded separately for each result. This is independent work;
+source attribution does not imply OpenAI affiliation or endorsement.
+
+The broader goal is to discover useful technical capabilities and foundational
+technology through sustained mathematical work. AI architectures are one possible
+direction. Mathematical progress, failed approaches and reusable methods inform
+what to investigate next; novelty and performance gains remain research goals.
+
+**[Explore the research atlas](https://huggingface.co/spaces/Maverick03511/finite-congruence-checks)** ·
+**[Inspect exact claims](docs/CLAIMS.md)** · **[Reproduce a result](#quick-start)** ·
+**[Read the Lean evidence](docs/LEAN_VERIFICATION.md)** · **[Research roadmap](docs/ROADMAP.md)**
+
+The repository is the canonical source. The hosted Space is a separate deployment;
+see the [publication record](docs/HUGGING_FACE_DEMO.md#publish) for its recorded revision.
+
+| Research capability | Evidence and limits |
+|:--|:--|
+| [Enumerate finite constructions](docs/ATLAS.md) | 39 representatives and 22 abstract shapes through four objects; independently checked finite computation. |
+| [Compare exact claims](docs/ATLAS_QUERY.md) | Stable entry IDs, fixed-carrier operation minima, hypotheses and source citations. A shared shape name does not transfer a proof. |
+| [Inspect proof correspondence](docs/CONTEXT_QUERY.md) | Exact saved N5/B3 constructions, proved N5 renamings and selected Turing claims; each has its own scope and binding. |
+| [Follow finite-board Snaky](docs/SNAKY_FINITE_BOARD.md) | The existing paper result is formalized for its 251-cell envelope and containing 17 × 17 square; an example play is separate from the 21-claim guarantee. |
+
+The original graph experiment searches eight specified lattices on carriers of
+size **one through four**, checks every quantified condition independently, and
+recovers minimum unary-operation lists for fixed representations. It uses only
+Python's standard library. Its totals below are separate from the atlas counts.
| Candidate colorings | Full witnesses | Vertex classes | Saved examples |
|:--|:--|:--|:--|
@@ -44,12 +48,14 @@ The HTML gallery is self-contained and works offline. Download the repository
and open `docs/index.html` in a browser; GitHub displays HTML source in its file
viewer. Each figure is also available as PNG and editable SVG in `charts/`.
-## Understand the math visually
+## Compare constructions and inspect evidence
-Start with **[the readable atlas](https://maverick03511-finite-congruence-checks.static.hf.space/atlas.html)**:
-three objects, one rule, and five possible groupings. Try a grouping, see why
-it works or fails, then explore the complete catalog through four objects.
-Every diagram explains what its nodes and lines mean; technical data is expandable.
+Use the **[interactive atlas](https://maverick03511-finite-congruence-checks.static.hf.space/atlas.html)**
+to move between the construction map, exact entry records and claim citations.
+The current source keeps map, catalog, detail and export selection synchronized.
+Its claim inspector separates saved finite computation from formal or model
+checks that are not supplied for that entry. The yellow/black interface emphasizes
+objects, rules and evidence; a worked example explains the diagram notation.
The catalog contains **39 grouping-family representatives** after renaming
objects, covering **22 abstract lattice shapes**. Compare two four-object
diff --git a/WORK_LOG.md b/WORK_LOG.md
index f1e3589..ad15d5b 100644
--- a/WORK_LOG.md
+++ b/WORK_LOG.md
@@ -1,5 +1,124 @@
# Finite graph search work log
+## 2026-10-20 - Repair contrast-checker false passes after independent review
+
+Independent controls exposed CR-R1 (first declaration incorrectly winning an
+equal-priority tie inside one rule) and CR-R2 (an unsupported `:not` color
+selector silently treated as inactive). Both failures were reproduced before
+repair. Cascade priority now includes declaration position after rule order.
+Selectors for modeled color/custom-property rules are validated before component
+matching, so unsupported syntax fails explicitly even without a matching fixture.
+Only the existing metrics separator pseudo-element is explicitly excluded.
+
+The original reviewer controls now pass. The CI selection checker retains all
+282 assertions and runs 224 color pairings, eight contrast regressions, four
+unsupported-selector rejection controls and two valid cascade controls, including
+earlier `!important`. Presentation CSS and selection code are unchanged from the
+first contrast handoff. The checker remains a bounded source fixture; its explicit
+subset and exclusions are documented in the repair handoff, with no browser or
+full CSS/accessibility acceptance claim.
+
+The original 87-file evidence manifest and every frozen artifact are preserved;
+four reviewed source snapshots and before/after control logs are retained in
+`runs/atlas-contrast-20261020/repairs/CR-v2/`. Focused syntax, source/selection checks
+and the reviewer's controls pass. No unchanged mathematical suite was repeated,
+and no proof/model, browser or remote action occurred. Independent repair review
+remains separate.
+
+## 2026-10-20 - Verify the full Atlas cascade and repair keyboard-link contrast
+
+The PR19 review named six pale surfaces, but later unconditional rules in
+`atlas.css` already replace those fills with theme tokens. Reading only the
+earlier minified rules reproduced neither their final colors nor the reported
+general failure. A source-level cascade audit instead found a real residual
+problem: the keyboard skip link inherited yellow text over a literal white
+background (1.293946:1). It now uses the dark surface and text tokens. SVG order
+edges also receive an explicit system-color fallback under forced colors.
+
+Added `check_atlas_contrast.cjs`, invoked by the existing CI selection checker.
+It resolves the checked stylesheet subset in actual load order against static
+HTML and generated claim/operation/SVG markup, including normal, hover, selected
+and keyboard-focus states at two widths and both color-scheme preferences.
+It retains the separate system-color checks and seven deliberately injected
+regressions. This closes the gap in the earlier token-only contrast checks.
+Unsupported solid-color values fail; this is a bounded source fixture, not a
+complete CSS engine, browser rendering, native-widget or accessibility audit.
+
+Author validation: 224 component pairings pass (minimum text 6.73:1 and checked
+SVG/focus 7.83:1), as do all 282 existing selection assertions and the other two
+Atlas checkers. All 33 root tests pass; the required finite reproduction and
+evidence comparison agree with the recorded results. Original sources, failing
+skip-link control, cascade diagnosis, commands, logs and exact handoff hashes are
+retained under `runs/atlas-contrast-20261020/`. No proof/data, remote publication,
+model execution or denied browser-preview workaround occurred. Independent
+review of these exact bytes remains a separate gate.
+
+## 2026-10-20 - Repair runtime reproduction commands after independent review
+
+Independent review found OR-R1: Atlas initialization replaced the corrected
+static reproduction list with an older string, so the displayed list and Copy
+commands omitted `node scripts/check_atlas_selection.cjs`. The earlier source
+checks did not cover this user path. Added the missing runtime command and four
+regression assertions for the runtime/static lists, complete clipboard API input,
+and reading the current displayed text on each copy action.
+
+The review also identified that filtering push branches alone suppressed tag
+pushes. Added `push.tags: ['**']` so release-tag verification is retained while
+feature-branch/PR duplication is removed. Every existing job and check remains.
+
+The new regression failed against the preserved original runtime source, then
+passed after repair. All three affected Atlas checkers pass; the selection suite
+now has 282 assertions. The reviewer's original focused control also passes.
+Clipboard writes are mocked in the DOM fixture: no actual browser clipboard,
+rendering or download acceptance is implied. No Python reproduction, proof or
+model job was repeated.
+
+Versioned repair evidence is in
+`runs/online-atlas-repair-20261020/repairs/OR-R1-v2/`. The original 97-artifact
+manifest, report, source snapshots and handoff remain byte-for-byte unchanged;
+failed-control output and original source are preserved. This repair awaits the
+same independent reviewer's clearance. No commit or remote action occurred.
+
+## 2026-10-20 - Prepare the research atlas for online delivery
+
+The map, catalog, detail and export previously maintained inconsistent selected
+entries. Reused the independently reviewed five-file Atlas integration on a
+separate worktree at main `0102845fc6a91c46e4b2def7455b6d418e671c01`; that tree
+matches the patch's original base. The implementation owner's retained dirty
+checkout, helper and log were not changed. The new source shares selection and
+shows exact construction/minimum records, hypotheses, citations and separate
+unknown formal/model evidence gates.
+
+Added the 278-assertion selection check to CI and reproduction guidance. All
+existing CI jobs, required contexts, commands, timeouts and permissions remain;
+push now targets main while pull-request and manual triggers remain, avoiding
+duplicate feature-branch and PR proof pipelines. Updated the research-first
+README, yellow/black Atlas and Space copy, and roadmap. The aim is mathematical
+progress and useful foundational technology, without predetermining AI
+architectures or asserting novelty. HF card colors use documented yellow/gray;
+the atlas stylesheet is yellow/black.
+
+All three Atlas checkers passed, including 39 entries, 518 grouping cases,
+304 rejection witnesses, 117 claim links, 115 map-filter combinations and 278
+selection/inspector assertions. All 50 Atlas query tests and 33 ordinary root
+unit tests passed. Standard finite reproduction also passed, including its own
+33-test stage; its totals match saved evidence: 143,685 candidates, 217 witnesses
+and 22 vertex classes. Atlas data/claim freshness, independent classification,
+saved-evidence validation and 111 local documentation targets passed.
+
+Evidence is retained in `runs/online-atlas-repair-20261020/`, including exact
+patch/base identities, original-checkout preservation hashes, command logs,
+source snapshots and review handoff. The first setup command was rejected by a
+transport disconnection before process creation; a read confirmed no directory
+or source mutation before retry. No product check failed in this allocation.
+
+These are local source/data/fixture checks. This change does not publish the
+Space, establish rendered/assistive-technology acceptance, execute Lean/model
+work, or alter mathematical evidence. At the recorded 20 October read, the
+Space was still at `63a85954e68f4e0202db2382c875267f9ae03f40`, predating Snaky.
+Exact-byte independent review, hosted CI and publication acceptance remain
+separate. Substantial AI assistance was used.
+
## 2026-10-19 — Fix a Linux process-disappearance race in the cleanup test
The push run for `4102fc1ec98a8516182270765e730a04ec626295` failed its
diff --git a/docs/ATLAS.md b/docs/ATLAS.md
index 78367d0..8981b45 100644
--- a/docs/ATLAS.md
+++ b/docs/ATLAS.md
@@ -76,6 +76,8 @@ python scripts/check_atlas.py --check-receipt evidence/atlas-review.json --out r
python scripts/query_atlas.py build-claims --check
python -m unittest discover -s scripts -p 'test_atlas*.py' -v
node scripts/check_atlas_ui.cjs
+node scripts/check_atlas_map.cjs
+node scripts/check_atlas_selection.cjs
```
The exporter starts from the complete small-family enumeration used by the
diff --git a/docs/ATLAS_MAP.md b/docs/ATLAS_MAP.md
index 6351f0a..263c98b 100644
--- a/docs/ATLAS_MAP.md
+++ b/docs/ATLAS_MAP.md
@@ -67,15 +67,19 @@ either minimum a universal lower bound for that abstract shape.
```sh
node scripts/check_atlas_ui.cjs
node scripts/check_atlas_map.cjs
+node scripts/check_atlas_selection.cjs
python scripts/query_atlas.py build-claims --check
```
-The new check loads the real vendored Cytoscape build in headless mode, checks
+The map check loads the real vendored Cytoscape build in headless mode, checks
all graph components and entry-to-claim links, exercises seven rejection
-controls, verifies library/license hashes, and checks light/dark theme contrast
-for the specified text, controls, and graph colors. These automated checks are
-supplemented by desktop and narrow-screen interaction review; they are not a
-complete accessibility certification.
+controls, verifies library/license hashes, and checks the base stylesheet's
+light/dark contrast tokens. The selection check exercises the actual Atlas
+scripts together in a DOM/headless fixture, including exact claims and export
+selection. Neither check establishes rendered behavior or contrast under every
+stylesheet override. The yellow/black presentation still needs browser, narrow-
+screen, keyboard and assistive-technology acceptance; no complete accessibility
+certification is claimed.
Cytoscape.js 3.34.4 is vendored with its MIT license and integrity manifest in
[`space/vendor/`](../space/vendor/README.md). No CDN or package installation is
diff --git a/docs/HUGGING_FACE_DEMO.md b/docs/HUGGING_FACE_DEMO.md
index 7773137..3a16e8b 100644
--- a/docs/HUGGING_FACE_DEMO.md
+++ b/docs/HUGGING_FACE_DEMO.md
@@ -7,8 +7,10 @@ seven passing witnesses, four connectivity obstructions, equivalence classes,
and minimal unary operations for each saved positive representation. Its
canonical source is `space/` in this repository.
-The Space now opens the [readable representation atlas](ATLAS.md), beginning
-with a three-object lesson. The original graph explorer remains at `index.html`.
+The configured entry point is the [representation atlas](ATLAS.md), with a
+construction map, exact claim inspector and worked example. The original graph
+explorer remains at `index.html`. The publication record below identifies the
+last recorded deployed revision; current source changes may be newer.
The atlas catalog covers all representable congruence families through four
objects and groups them by object renaming and abstract lattice shape. It has
separate generated data, exhaustive verification, and browser checks.
@@ -40,6 +42,7 @@ python scripts/query_atlas.py build-claims --check
python -m unittest discover -s scripts -p 'test_atlas*.py' -v
node scripts/check_atlas_ui.cjs
node scripts/check_atlas_map.cjs
+node scripts/check_atlas_selection.cjs
python scripts/query_atlas.py build-tm --check
node scripts/check_tm_atlas_ui.cjs
python scripts/build_n5_reuse.py --check
@@ -101,6 +104,16 @@ independent checks and formal extensions of selected results. This banner was
published through PR #17 from GitHub commit
`3632a58d80320e56a7a44c017a74746008b920d8` to Space commit
`63a85954e68f4e0202db2382c875267f9ae03f40`; all 44 published file hashes matched.
+A read of the Space README on 20 October 2026 still returned that commit in
+`X-Repo-Commit`. This recorded deployment predates the Snaky source merge and the
+yellow/black Atlas selection repair. No newer deployment is claimed here.
+
+The current source adds shared selection and exact claim inspection. Its local
+DOM/headless checks are distinct from browser rendering, responsive layout,
+keyboard/assistive-technology behavior and actual browser downloads. Complete
+those acceptance checks in a permitted context, retain exact-head independent
+review and required CI, then publish the accepted merged `space/` files and
+record their source/deployment revisions and file hashes.
Publish only the contents of `space/` to the static Space
`Maverick03511/finite-congruence-checks`. Its README declares `sdk: static` and
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index 0550406..fa8ae34 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -1,6 +1,6 @@
# Research and engineering roadmap
-## Current milestone: Snaky on finite boards
+## Current delivery: publish the reviewed research atlas
[PR #11](https://github.com/Maverick0351a/finite-congruence-checks/pull/11) and
[PR #12](https://github.com/Maverick0351a/finite-congruence-checks/pull/12) are merged.
@@ -13,10 +13,9 @@ and transported groupings, follow the applicable theorem, and distinguish a
failed grouping from a failed correspondence or an unsupported proof reference.
It reuses the existing generic theorem and retains the first example's evidence.
-The proof-reuse milestone was merged in PR #15. The user has now selected this
-mathematical order: first formalize the [saved five-object example](FIVE_OBJECT_MINIMUM.md),
-then investigate one exact Snaky certificate and its board assumptions, then
-consider a directed-graph example. The first task compares two exact families
+The proof-reuse milestone was merged in PR #15. The subsequent delivery track
+formalized the [saved five-object example](FIVE_OBJECT_MINIMUM.md), then one exact
+Snaky certificate and its board assumptions. The five-object task compares two exact families
with the same eight-element order but different minimum unary rule counts.
The five-object proof now supplies complete classifications, arbitrary-unary-map
lower bounds, exact theorem bindings, and a separate exhaustive Python audit.
@@ -33,15 +32,35 @@ different result. The [branch walkthrough](SNAKY_PLAY.md) shows one complete
independently replayed example, including each Maker move, chosen Breaker reply,
remaining budget and supporting certificate step. It distinguishes that chosen
eight-claim play from the theorem covering every legal reply within 21 claims.
-Complete hosted reproduction and publication review before closing this milestone.
-Then inspect one directed-graph example's exact source statement and
-assumptions before selecting its proof target.
+[PR #18](https://github.com/Maverick0351a/finite-congruence-checks/pull/18) merged as
+`0102845fc6a91c46e4b2def7455b6d418e671c01`. Its
+[main CI run](https://github.com/Maverick0351a/finite-congruence-checks/actions/runs/39385592591)
+completed all nine jobs successfully on 20 October 2026, including hosted Snaky
+reproduction. This source milestone is complete. Publishing the current website
+is a separate delivery: the [last recorded Space publication](HUGGING_FACE_DEMO.md#publish)
+predates Snaky.
+
+The current Atlas change synchronizes selection across the map, catalog, detail
+and export, exposes exact claim records, and adopts the yellow/black research
+presentation. Finish independent review, required CI and permitted browser
+acceptance before publishing the exact merged website bytes. Source/fixture
+checks do not establish rendered, responsive or assistive-technology behavior.
+
+## Mathematical research direction
+
+Sustain broad work across OpenAI Math, with deep investigations chosen from
+precise questions and current related research. Capture methods, counterexamples,
+failures and possible connections to useful technical capabilities. Foundational
+technology is the ambition; AI architectures are one possible outcome, and no
+single direction is predetermined. A directed-graph example remains a candidate,
+not a committed next theorem. Select its target only after inspecting the exact
+source statement, assumptions, prior art and a discriminating test.
Before any resumed model evaluation, resolve the dummy runner's
[isolation and usage gates](NATIVE_PREFLIGHT_STATUS.md). Report actual preflight
usage and a revised estimate before seeking approval for the original four
direct-answer sessions. The matched benchmark packets and four reserved task
-families remain frozen. Model benchmarks, handoffs, repeated trials, and training
+families remain frozen. Model benchmarks, model handoff experiments, repeated trials, and training
remain paused. The larger atlas and harder repair domain below are later work.
## The first release
diff --git a/scripts/check_atlas_contrast.cjs b/scripts/check_atlas_contrast.cjs
new file mode 100644
index 0000000..3fb40d4
--- /dev/null
+++ b/scripts/check_atlas_contrast.cjs
@@ -0,0 +1,341 @@
+/* Source-level color regression for the Atlas. Not a browser or a WCAG audit.
+ * Resolves the checked CSS subset (cascade, inheritance, vars, media, solid
+ * colors) against static HTML and generated operation/claim/SVG markup.
+ * Layout, native widgets, canvas, paint order and assistive technology remain
+ * separate browser checks. Unsupported checked color values/selectors fail.
+ */
+'use strict';
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+
+function parseHtml(html, parent = null) {
+ const document = parent || {tag: 'document', attrs: {}, children: [], parent: null, states: new Set()};
+ const stack = [document];
+ for (const token of html.matchAll(/|]*>|<\/?[\w-]+\b[^>]*>/g)) {
+ const text = token[0];
+ if (text.startsWith(']+)))?/g)) {
+ attrs[m[1]] = m[2] ?? m[3] ?? m[4] ?? '';
+ }
+ const node = {tag, attrs, parent: stack.at(-1), children: [], states: new Set()};
+ node.parent.children.push(node);
+ if (!text.endsWith('/>') && !['meta', 'link', 'img', 'br', 'hr', 'input'].includes(tag)) stack.push(node);
+ }
+ assert.equal(stack.length, 1, 'Balanced fixture document');
+ return document;
+}
+function descendants(node) { return node.children.flatMap(child => [child, ...descendants(child)]); }
+function parts(selector) {
+ return selector.trim().replace(/\s*>\s*/g, ' > ').split(/\s+/).filter(Boolean);
+}
+const checkedProperty = key => key.startsWith('--') ||
+ ['color', 'background', 'background-color', 'fill', 'stroke', 'border-color', 'outline-color'].includes(key);
+function checkedSelector(selector) {
+ // This existing separator is decorative generated content, not a fixture
+ // element. Exclude exactly this selector, not arbitrary pseudo-elements or
+ // sibling selectors that could otherwise conceal a checked color override.
+ if (selector.replace(/\s+/g, '') === '.metrics>div+div:before') return false;
+ const tokens = parts(selector);
+ const unsupported = () => new Error(`Unsupported checked color selector: ${selector}`);
+ if (!tokens.length) throw unsupported();
+ for (let i = 0; i < tokens.length; i++) {
+ if (tokens[i] === '>') {
+ if (!i || i === tokens.length - 1 || tokens[i - 1] === '>') throw unsupported();
+ continue;
+ }
+ if (tokens[i] === '*') continue;
+ let rest = tokens[i].replace(/^[\w-]+/, '');
+ // Validate the whole selector before matching any node: a class mismatch
+ // must not hide unsupported syntax later in the same compound selector.
+ while (rest) {
+ const m = /^(?:[.#][\w-]+|\[[\w-]+(?:=(?:"[\w-]+"|'[\w-]+'|[\w-]+))?\]|:nth-child\(\d+\)|:(?:root|first-child|hover|focus-visible|focus|disabled|target)(?![\w-]|\())/.exec(rest);
+ if (!m) throw unsupported();
+ rest = rest.slice(m[0].length);
+ }
+ }
+ return true;
+}
+function simple(node, selector) {
+ if (selector === '*') return true;
+ let rest = selector;
+ const tag = /^[\w-]+/.exec(rest);
+ if (tag) { if (tag[0] !== node.tag) return false; rest = rest.slice(tag[0].length); }
+ while (rest) {
+ let m;
+ if ((m = /^([.#])([\w-]+)/.exec(rest))) {
+ if (m[1] === '#' ? node.attrs.id !== m[2] : !(node.attrs.class || '').split(/\s+/).includes(m[2])) return false;
+ } else if ((m = /^\[([\w-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\]]+)))?\]/.exec(rest))) {
+ if (!(m[1] in node.attrs)) return false;
+ if (m[2] !== undefined || m[3] !== undefined || m[4] !== undefined) {
+ if (node.attrs[m[1]] !== (m[2] ?? m[3] ?? m[4])) return false;
+ }
+ } else if ((m = /^:([\w-]+)(?:\((\d+)\))?/.exec(rest))) {
+ if (m[1] === 'root') { if (node.tag !== 'html') return false; }
+ else if (m[1] === 'first-child' || m[1] === 'nth-child') {
+ if (node.parent?.children.indexOf(node) !== (m[1] === 'first-child' ? 0 : Number(m[2]) - 1)) return false;
+ } else if (!node.states.has(m[1])) return false;
+ } else throw new Error(`Unsupported checked selector: ${selector}`);
+ rest = rest.slice(m[0].length);
+ }
+ return true;
+}
+function matches(node, selector) {
+ const tokens = parts(selector);
+ function visit(current, i) {
+ if (!current || !simple(current, tokens[i])) return false;
+ if (i === 0) return true;
+ if (tokens[i - 1] === '>') return visit(current.parent, i - 2);
+ for (let p = current.parent; p; p = p.parent) if (visit(p, i - 1)) return true;
+ return false;
+ }
+ return visit(node, tokens.length - 1);
+}
+function specificity(selector) {
+ const attrs = selector.match(/\[[^\]]*\]/g) || [];
+ const plain = selector.replace(/\[[^\]]*\]/g, '').replace(/:[\w-]+(?:\([^)]*\))?/g, '');
+ return [(plain.match(/#[\w-]+/g) || []).length,
+ attrs.length + (plain.match(/\.[\w-]+/g) || []).length + (selector.match(/:[\w-]+/g) || []).length,
+ (plain.replace(/[.#][\w-]+/g, '').match(/\b[a-z][\w-]*/gi) || []).length];
+}
+function activeMedia(query, env) {
+ const tests = [...query.matchAll(/\(([\w-]+)\s*:\s*([\w-]+)\)/g)];
+ assert(tests.length, `Known media query: ${query}`);
+ return tests.every(([, key, value]) => {
+ if (key === 'max-width') return env.width <= Number(value.replace('px', ''));
+ if (key === 'prefers-color-scheme') return env.scheme === value;
+ if (key === 'forced-colors') return (env.forced ? 'active' : 'none') === value;
+ if (key === 'prefers-reduced-motion') return value === 'reduce';
+ throw new Error(`Unsupported media feature: ${key}`);
+ });
+}
+function parseCss(css, env) {
+ css = css.replace(/\/\*[\s\S]*?\*\//g, '');
+ const rules = [];
+ function block(start, end) {
+ let pos = start;
+ while (pos < end) {
+ const open = css.indexOf('{', pos);
+ if (open < 0 || open >= end) break;
+ const head = css.slice(pos, open).trim();
+ let close = open + 1, depth = 1;
+ while (close < end && depth) { if (css[close] === '{') depth++; if (css[close] === '}') depth--; close++; }
+ assert.equal(depth, 0, 'Balanced CSS blocks');
+ if (head.startsWith('@media')) {
+ if (activeMedia(head.slice(6), env)) block(open + 1, close - 1);
+ } else {
+ assert(!head.startsWith('@'), `Unsupported CSS at-rule: ${head}`);
+ const declarations = css.slice(open + 1, close - 1).split(';').map(part => {
+ const colon = part.indexOf(':');
+ return colon < 0 ? null : [part.slice(0, colon).trim(), part.slice(colon + 1).trim()];
+ }).filter(Boolean);
+ // Layout-only rules are outside the checked color subset. Validate
+ // color selectors up front, even when no fixture currently matches.
+ if (declarations.some(([key]) => checkedProperty(key))) {
+ for (const selector of head.split(',')) {
+ if (checkedSelector(selector)) rules.push({selector: selector.trim(), declarations, score: specificity(selector)});
+ }
+ }
+ }
+ pos = close;
+ }
+ }
+ block(0, css.length);
+ return rules;
+}
+function resolver(rules) {
+ const cache = new Map();
+ function style(node) {
+ if (cache.has(node)) return cache.get(node);
+ assert(!/(?:color|background|fill|stroke)\s*:/.test(node.attrs.style || ''), 'Inline component colors need explicit checker support');
+ const inherited = node.parent ? style(node.parent) : {};
+ const result = Object.fromEntries(Object.entries(inherited).filter(([key]) => key.startsWith('--') || ['color', 'fill', 'stroke'].includes(key)));
+ const winners = new Map();
+ rules.forEach((rule, order) => {
+ if (!matches(node, rule.selector)) return;
+ for (const [position, declaration] of rule.declarations.entries()) {
+ let [key, value] = declaration;
+ if (!checkedProperty(key)) continue;
+ if (key === 'background') key = 'background-color';
+ const important = /!important\s*$/.test(value) ? 1 : 0;
+ value = value.replace(/\s*!important\s*$/, '');
+ const score = [important, ...rule.score, order, position];
+ const old = winners.get(key);
+ if (!old || score.some((v, i) => v !== old.score[i] && score.slice(0, i).every((x, j) => x === old.score[j]) && v > old.score[i])) {
+ winners.set(key, {score, value});
+ }
+ }
+ });
+ for (const [key, item] of winners) result[key] = item.value;
+ cache.set(node, result);
+ return result;
+ }
+ function value(node, key) {
+ const s = style(node);
+ function resolve(v, depth = 0) {
+ assert(depth < 20, 'No variable cycle');
+ return v?.replace(/var\((--[\w-]+)\)/g, (_, name) => {
+ assert(s[name] !== undefined, `Defined CSS variable: ${name}`);
+ return resolve(s[name], depth + 1);
+ });
+ }
+ return resolve(s[key]);
+ }
+ function background(node) {
+ const color = value(node, 'background-color');
+ if (color && color !== 'transparent') return color;
+ assert(node.parent, 'Known opaque background');
+ return background(node.parent);
+ }
+ return {value, background};
+}
+function rgb(value) {
+ const named = {white: '#ffffff', black: '#000000'};
+ value = named[value] || value;
+ assert(/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i.test(value), `Supported opaque solid color: ${value}`);
+ if (value.length === 4) value = '#' + [...value.slice(1)].map(c => c + c).join('');
+ return value.slice(1).match(/../g).map(c => parseInt(c, 16) / 255);
+}
+function contrast(a, b) {
+ const luminance = value => rgb(value).map(c => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)
+ .reduce((sum, c, i) => sum + c * [0.2126, 0.7152, 0.0722][i], 0);
+ const x = luminance(a), y = luminance(b);
+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
+}
+function inspect(root, overrides = {}) {
+ const read = name => fs.readFileSync(path.join(root, name), 'utf8');
+ const html = read('space/atlas.html');
+ const styles = [...html.matchAll(/]*rel="stylesheet"[^>]*href="([^"]+)"/g)].map(m => m[1]);
+ assert.deepEqual(styles, ['atlas.css', 'atlas-research.css'], 'Check the actual stylesheet order');
+ const css = styles.map(name => overrides[name] ?? read(`space/${name}`)).join('\n');
+ const document = parseHtml(html), all = () => descendants(document);
+ const one = selector => { const found = all().filter(node => matches(node, selector)); assert(found.length, `Existing component: ${selector}`); return found[0]; };
+ const app = require(path.join(root, 'space/atlas.js'));
+ const data = JSON.parse(read('space/atlas-data.json'));
+ const registry = JSON.parse(read('space/atlas-claims.json'));
+ const entry = data.entries.find(item => item.operations.length && item.partitions.length > 1);
+ parseHtml(app.operationHtml(entry.operations[0], 0), one('#entry-operations'));
+ parseHtml(app.latticeSvg(entry, 0), one('#entry-diagram'));
+ parseHtml(app.claimsHtml(registry, entry), one('#entry-claims'));
+ // Control structure mirrors the dynamic button's documented class/ARIA path;
+ // selection/markup generation itself is covered by check_atlas_selection.cjs.
+ parseHtml('', one('#entry-list'));
+ const catalogButton = one('#entry-list button');
+ const textCases = [
+ ['skip link', '.skip'], ['catalog label', '.catalog label'], ['catalog count', '#entry-count'],
+ ['catalog select', '.catalog select'], ['entry title', '#entry-title'], ['status', '.status'],
+ ['pill', '.pill'], ['operation', '.operation'], ['operation label', '.operation>strong'],
+ ['operation mapping', '.mapping-row span'], ['operation arrow', '.mapping-row b'],
+ ['takeaway', '.takeaway p'], ['takeaway label', '.takeaway>span'], ['entry takeaway', '.entry-takeaway'],
+ ['preformatted data', '#entry-json'], ['reproduction commands', '#reproduce-commands'],
+ ['claim statement', '.claim-record p'], ['claim code', '.claim-record code'],
+ ['claim header', '.claim-gates th'], ['claim value', '.claim-gates td'], ['claim caption', '.claim-gates caption'],
+ ['primary button', '.primary'], ['secondary button', '.secondary'],
+ ];
+ const results = [], failures = [];
+ for (const env of [
+ {scheme: 'light', width: 1280, forced: false}, {scheme: 'dark', width: 1280, forced: false},
+ {scheme: 'light', width: 600, forced: false}, {scheme: 'dark', width: 600, forced: false},
+ ]) {
+ function check(name, fg, bg, minimum = 4.5) {
+ const ratio = contrast(fg, bg), item = {environment: `${env.scheme}/${env.width}`, name, foreground: fg, background: bg, ratio, minimum};
+ results.push(item); if (ratio < minimum) failures.push(item);
+ }
+ const get = () => resolver(parseCss(css, env));
+ let colors = get();
+ for (const [name, selector] of textCases) { const node = one(selector); check(name, colors.value(node, 'color'), colors.background(node)); }
+ for (const state of ['normal', 'hover', 'selected', 'selected-hover']) {
+ catalogButton.states = new Set(state.includes('hover') ? ['hover'] : []);
+ catalogButton.attrs['aria-pressed'] = state.includes('selected') ? 'true' : 'false';
+ colors = get();
+ for (const node of [catalogButton, ...catalogButton.children]) check(`catalog ${state} ${node.tag}`, colors.value(node, 'color'), colors.background(node));
+ }
+ catalogButton.states.clear(); catalogButton.attrs['aria-pressed'] = 'false';
+ for (const selector of ['.primary', '.secondary']) {
+ const node = one(selector); node.states.add('hover'); colors = get();
+ check(`${selector} hover`, colors.value(node, 'color'), colors.background(node)); node.states.clear();
+ }
+ for (const selector of ['.skip', '.primary', '.secondary', '.catalog select', '.lattice-scroll', 'summary']) {
+ const node = one(selector); node.states = new Set(['focus', 'focus-visible']); colors = get();
+ check(`${selector} keyboard focus text`, colors.value(node, 'color'), colors.background(node));
+ // The outline has a positive offset in the stylesheet; compare its color
+ // with the surrounding parent surface, not the button's interior fill.
+ check(`${selector} focus outline`, colors.value(node, 'outline-color'), colors.background(node.parent), 3);
+ node.states.clear();
+ }
+ colors = get();
+ for (const node of all().filter(item => matches(item, '.lattice-node'))) {
+ const rect = node.children.find(item => item.tag === 'rect'), fill = colors.value(rect, 'fill');
+ for (const label of node.children.filter(item => item.tag === 'text')) check(`SVG ${node.attrs.class} ${label.attrs.class || 'label'}`, colors.value(label, 'fill'), fill);
+ check('SVG node outline', colors.value(rect, 'stroke'), colors.background(one('.lattice-scroll')), 3);
+ }
+ check('SVG edge', colors.value(one('.lattice-edge'), 'stroke'), colors.background(one('.lattice-scroll')), 3);
+ }
+ // System colors cannot be reduced to fixed RGB without the user's palette.
+ // Require source-resolved symbolic pairs for the repaired and SVG paths.
+ const forced = resolver(parseCss(css, {scheme: 'dark', width: 600, forced: true}));
+ const systemColors = [];
+ for (const selector of ['.skip', '.operation', '#entry-json']) {
+ const node = one(selector);
+ const foreground = forced.value(node, 'color'), background = forced.background(node);
+ const passed = ['CanvasText', 'LinkText', 'ButtonText'].includes(foreground) && ['Canvas', 'ButtonFace'].includes(background);
+ const item = {environment: 'forced-colors', name: selector, foreground, background, passed};
+ systemColors.push(item); if (!passed) failures.push(item);
+ }
+ const edge = {environment: 'forced-colors', name: 'SVG edge', stroke: forced.value(one('.lattice-edge'), 'stroke')};
+ edge.passed = edge.stroke === 'CanvasText';
+ systemColors.push(edge); if (!edge.passed) failures.push(edge);
+ return {results, systemColors, failures, minText: Math.min(...results.filter(item => item.minimum === 4.5).map(item => item.ratio)),
+ minGraphic: Math.min(...results.filter(item => item.minimum === 3).map(item => item.ratio)),
+ limits: 'Source cascade/solid-color fixtures only; no browser rendering, native-widget, canvas, layout or assistive-technology acceptance.'};
+}
+function checkAtlasContrast(root) {
+ const result = inspect(root);
+ assert.deepEqual(result.failures, [], 'Component contrast regression');
+ const css = fs.readFileSync(path.join(root, 'space/atlas-research.css'), 'utf8');
+ const controls = [
+ ['skip link', '.skip{background:white;color:var(--accent)}'],
+ ['.skip keyboard focus text', '.skip:focus{background:white;color:var(--accent)}'],
+ ['operation', '.operation{background:#f0f4fc}'],
+ ['preformatted data', 'pre{background:#eaf0fa}'],
+ ['catalog hover button', '.entry-list button:hover{background:white}'],
+ ];
+ for (const [name, rule] of controls) {
+ const broken = inspect(root, {'atlas-research.css': css + '\n' + rule});
+ assert(broken.failures.some(item => item.name === name && item.ratio < 4.5), `Reject reintroduced ${name} failure`);
+ }
+ const svg = inspect(root, {'atlas-research.css': css + '\n.lattice-node rect{fill:white}'});
+ assert(svg.failures.some(item => item.name === 'SVG lattice-node label'), 'Reject pale SVG node fill');
+ assert(!svg.failures.some(item => item.name === 'SVG lattice-node selected label'), 'More-specific selected fill wins despite later generic rule');
+ const mobile = inspect(root, {'atlas-research.css': css + '\n@media(max-width:760px){.operation{background:white}}'});
+ assert(mobile.failures.some(item => item.name === 'operation' && item.environment === 'light/600'), 'Mobile-only color failure detected');
+ assert(!mobile.failures.some(item => item.name === 'operation' && item.environment === 'light/1280'), 'Inactive width query excluded');
+ const duplicate = inspect(root, {'atlas-research.css': css + '\n.operation{background:var(--surface-soft);background:white}'});
+ assert(duplicate.failures.some(item => item.name === 'operation'), 'Last same-priority declaration wins (CR-R1)');
+ for (const rule of [
+ '.operation{background:white;background:var(--surface-soft)}',
+ '.operation{background:var(--surface-soft)!important;background:white}',
+ ]) {
+ const valid = inspect(root, {'atlas-research.css': css + '\n' + rule});
+ assert.deepEqual(valid.failures, [], 'Later declaration and earlier !important controls preserve valid colors');
+ }
+ for (const selector of ['.operation:not(.disabled)', '.absent:not(.disabled)', '.operation:unsupported', '.operation+.operation']) {
+ assert.throws(() => inspect(root, {'atlas-research.css': css + `\n${selector}{background:white}`}),
+ /Unsupported checked color selector:/, `Unsupported color selector fails explicitly (CR-R2): ${selector}`);
+ }
+ console.log(`Atlas component color checks: ${result.results.length} pairings, eight color regressions, four unsupported-selector rejections and two cascade positives; text >= ${result.minText.toFixed(2)}:1; SVG/focus contrast >= ${result.minGraphic.toFixed(2)}:1. ${result.limits}`);
+ return result;
+}
+module.exports = {inspect, checkAtlasContrast, contrast};
+if (require.main === module) {
+ const root = path.resolve(process.argv[2] || path.join(__dirname, '..'));
+ const result = inspect(root, process.argv[3] ? {'atlas-research.css': fs.readFileSync(process.argv[3], 'utf8')} : {});
+ console.log(JSON.stringify(result, null, 2));
+ if (result.failures.length) process.exitCode = 1;
+}
diff --git a/scripts/check_atlas_selection.cjs b/scripts/check_atlas_selection.cjs
new file mode 100644
index 0000000..2a0cce3
--- /dev/null
+++ b/scripts/check_atlas_selection.cjs
@@ -0,0 +1,173 @@
+/* Deterministic event-wiring and data checks. This DOM fixture is NOT a browser. */
+'use strict';
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const vm = require('node:vm');
+const {checkAtlasContrast} = require('./check_atlas_contrast.cjs');
+const root = path.resolve(process.argv[2] || path.join(__dirname, '..'));
+const read = name => fs.readFileSync(path.join(root, name), 'utf8');
+const data = JSON.parse(read('space/atlas-data.json'));
+const registry = JSON.parse(read('space/atlas-claims.json'));
+const cytoscape = require(path.join(root, 'space/vendor/cytoscape-3.34.4.min.js'));
+const app = require(path.join(root, 'space/atlas.js'));
+const html = read('space/atlas.html');
+const charts = [];
+let checks = 0;
+function same(actual, expected, message) { checks++; assert.deepEqual(actual, expected, message); }
+function ok(value, message) { checks++; assert(value, message); }
+function fixture(search = '', renderer = 'cytoscape') {
+ const nodes = new Map(), downloads = [], clipboardCopies = [], blobs = new Map();
+ const document = { activeElement: null };
+ class Node {
+ constructor(tag = 'div', attrs = {}) {
+ this.tagName = tag; this.attrs = attrs; this.id = attrs.id; this.events = new Map(); this.children = [];
+ this.value = attrs.value || ''; this.dataset = {}; this.hidden = false; this.disabled = false;
+ for (const [key, value] of Object.entries(attrs)) if (key.startsWith('data-')) this.dataset[key.slice(5)] = value;
+ this.classList = { toggle() {} }; this.textContent = ''; this._html = '';
+ }
+ set innerHTML(value) {
+ this._html = value; this.children = [];
+ for (const match of value.matchAll(/<(button|option)\b([^>]*)>([\s\S]*?)<\/\1>/g)) {
+ const attrs = Object.fromEntries([...match[2].matchAll(/([\w-]+)="([^"]*)"/g)].map(m => [m[1], m[2]]));
+ const child = new Node(match[1], attrs); child.textContent = match[3]; this.children.push(child);
+ }
+ }
+ get innerHTML() { return this._html; }
+ addEventListener(type, callback) { this.events.set(type, [...(this.events.get(type) || []), callback]); }
+ dispatch(type) { for (const callback of this.events.get(type) || []) callback({ target: this }); }
+ click() { if (this.disabled) return; this.dispatch('click'); if (this.download) downloads.push({ name: this.download, text: blobs.get(this.href).parts.join('') }); }
+ setAttribute(key, value) { this.attrs[key] = value; }
+ getAttribute(key) { return this.attrs[key]; }
+ querySelectorAll(selector) { assert.equal(selector, 'button'); return this.children.filter(child => child.tagName === 'button'); }
+ closest(selector) { assert.equal(selector, '.entry-detail'); return document.detail; }
+ insertAdjacentHTML(position, value) { assert.equal(position, 'beforeend'); this.innerHTML = this.innerHTML + value; }
+ replaceChildren() { this.innerHTML = ''; }
+ focus() { document.activeElement = this; }
+ scrollIntoView() { this.scrolled = true; }
+ append() {}
+ remove() {}
+ }
+ for (const match of html.matchAll(/<([\w-]+)\b([^>]*\bid="([^"]+)"[^>]*)>/g)) nodes.set(match[3], new Node(match[1], {id:match[3]}));
+ for (const match of html.matchAll(/