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 -![Finite Congruence Checks — project identity banner: small algebras, explicit witnesses and reproducible evidence](charts/project-banner.svg) - [![Reproduce and verify](https://github.com/Maverick0351a/finite-congruence-checks/actions/workflows/verify.yml/badge.svg)](https://github.com/Maverick0351a/finite-congruence-checks/actions/workflows/verify.yml) [![Recorded Lean 4.34.1 checks passed: concrete N5/B3 and targeted upstream modules](charts/lean-checks-badge.svg)](docs/LEAN_VERIFICATION.md) [![Release v0.1.0](charts/release-badge.svg)](https://github.com/Maverick0351a/finite-congruence-checks/releases/tag/v0.1.0) [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-315B78)](LICENSE) [![Python: 3.10+](https://img.shields.io/badge/python-3.10%2B-315B78)](#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(/]*id="([^"]+)"[^>]*>([\s\S]*?)<\/select>/g)) { + const node = nodes.get(match[1]); node.innerHTML = match[2]; + node.value = /value="([^"]+)" selected/.exec(match[2])?.[1] || node.children[0]?.value || ''; + } + document.detail = new Node('article'); document.body = new Node('body'); + document.getElementById = id => { assert(nodes.has(id), `Missing DOM fixture id ${id}`); return nodes.get(id); }; + document.querySelectorAll = selector => { assert.equal(selector, '[data-lesson]'); return []; }; + document.createElement = tag => new Node(tag); document.documentElement = new Node('html'); + let chart; + const window = { + ATLAS_DATA: data, ATLAS_CLAIMS: registry, location: {search}, addEventListener() {}, + matchMedia: () => ({matches:true, addEventListener() {}}), + }; + // Transfer plain graph options out of the VM realm; no browser layout is simulated. + if (renderer === 'cytoscape') window.cytoscape = options => { chart = cytoscape({...JSON.parse(JSON.stringify({...options,container:undefined})), headless:true, styleEnabled:false}); charts.push(chart); return chart; }; + if (renderer === 'throws') window.cytoscape = () => { throw new Error('Injected renderer failure'); }; + const navigator = {clipboard: {writeText(text) {clipboardCopies.push(text); return Promise.resolve();}}}; + const context = vm.createContext({window, document, navigator, URLSearchParams, Blob:class {constructor(parts) {this.parts=parts;}}, URL:{createObjectURL(blob) { const id=`blob:fixture-${blobs.size}`; blobs.set(id,blob); return id; },revokeObjectURL() {}}, getComputedStyle:() => ({getPropertyValue:()=>'#111111'})}); + for (const name of ['atlas-map.js','atlas.js']) vm.runInContext(read(`space/${name}`), context, {filename:name}); + const get = id => nodes.get(id); + const change = (id, value) => { get(id).value = value; get(id).dispatch('change'); }; + function expectEntry(id) { + same(get('map-entry').value, id, 'Map selector matches detail selection'); + ok(get('entry-kicker').textContent.includes(id), 'Detail matches selection'); + const record = JSON.parse(get('entry-json').textContent); + same(record.entry.id, id, 'Certificate preview matches selection'); + ok(get('entry-claims').innerHTML.includes(`construction:${id}`), 'Inspector contains exact construction claim'); + ok(get('entry-claims').innerHTML.includes(`minimum:${id}`), 'Inspector contains separate minimum claim'); + same(get('map-carrier').value, get('carrier-filter').value, 'Carrier filters mirror'); + same(get('map-shape').value, get('shape-filter').value, 'Shape filters mirror'); + const pressed = get('entry-list').children.filter(button=>button.getAttribute('aria-pressed')==='true'); + same(pressed.map(button=>button.dataset.entry), [id], 'One catalog entry is pressed'); + if (chart) same(chart.nodes('.inspected').map(node=>node.id()), [id], 'Real headless Cytoscape marks the same node'); + } + return {get, change, expectEntry, downloads, clipboardCopies, document, chart:()=>chart}; +} +try { + const f = fixture(); + const selectionCommand = 'node scripts/check_atlas_selection.cjs'; + const displayedCommands = f.get('reproduce-commands').textContent; + same(displayedCommands.split('\n').filter(line=>line.trim()===selectionCommand).length,1,'Runtime reproduction list includes the selection checker exactly once'); + const staticCommands = /
([\s\S]*?)<\/pre>/.exec(html)?.[1] || '';
+  same(staticCommands.split('\n').filter(line=>line.trim()===selectionCommand).length,1,'Static reproduction list includes the selection checker exactly once');
+  f.get('copy-commands').click();
+  same(f.clipboardCopies,[displayedCommands],'Copy commands passes the complete displayed runtime list to the clipboard API');
+  const editedCommands = `${displayedCommands}\n# local annotation`;
+  f.get('reproduce-commands').textContent = editedCommands;
+  f.get('copy-commands').click();
+  same(f.clipboardCopies[1],editedCommands,'Copy commands reads current displayed text rather than a cached list');
+  f.get('reproduce-commands').textContent = displayedCommands;
+  // This assertion fails on the exact unmodified base: map defaults to C4, detail to B2.
+  f.expectEntry('n4-E16403');
+  f.get('map-entry').focus();
+  f.change('map-entry','n4-E16457'); f.expectEntry('n4-E16457');
+  same(f.document.activeElement, f.get('map-entry'), 'Passive selection does not steal focus');
+  f.get('map-open-entry').click(); same(f.document.activeElement,f.get('entry-title'),'Explicit jump focuses detail heading');
+  f.get('comparison-cards').children.find(button=>button.dataset.compare==='n4-E16403').click(); f.expectEntry('n4-E16403');
+  f.chart().getElementById('n4-E16457').emit('tap'); f.expectEntry('n4-E16457');
+  const catalogButton = f.get('entry-list').children.find(button=>button.dataset.entry==='n4-E16403');
+  catalogButton.focus(); catalogButton.click(); f.expectEntry('n4-E16403');
+  same(f.document.activeElement,catalogButton,'Catalog selection preserves the focused button');
+  f.get('download-entry').click();
+  same(f.downloads[0].name,'atlas-n4-E16403.json','Download name follows shared selection');
+  const exported = JSON.parse(f.downloads[0].text);
+  same(exported.entry.id,'n4-E16403','Downloaded exact entry');
+  same(exported.claims.records.filter(record=>record.entry_id==='n4-E16403').map(record=>record.id),['construction:n4-E16403','minimum:n4-E16403'],'Export contains full exact claim records');
+  same(exported.claims.registry_git_revision,null,'No invented registry Git revision');
+  f.change('map-carrier','1');
+  ok(f.document.detail.hidden,'No-match filter hides stale detail');
+  ok(f.get('download-entry').disabled && f.get('map-entry').disabled && f.get('map-open-entry').disabled,'No-match controls disabled');
+  same(f.get('entry-json').textContent,'','No stale certificate remains');
+  same(f.get('entry-claims').innerHTML,'','No stale claims remain');
+  f.change('shape-filter','all');
+  const zero = data.entries.find(entry=>entry.carrier_size===1);
+  f.expectEntry(zero.id); ok(f.get('entry-claims').innerHTML.includes('Minimum unary operations
0
'),'Zero is not missing'); + f.change('carrier-filter','all'); + const shapeNode = f.chart().nodes('[kind="shape"]').find(node=>node.data('abstract_type')==='T06'); + shapeNode.emit('tap'); f.expectEntry('n4-E16403'); + f.get('map-reset').click(); f.expectEntry('n4-E16403'); + fixture('?entry=n4-E16457').expectEntry('n4-E16457'); + fixture('?entry=not-an-entry').expectEntry('n4-E16403'); + for (const renderer of ['absent','throws']) { + const fallback = fixture('',renderer); fallback.change('map-entry','n4-E16457'); fallback.expectEntry('n4-E16457'); + ok(!fallback.get('map-fallback').hidden,'Native fallback remains available'); + ok(fallback.get('construction-map').hidden,'Unavailable canvas hidden'); + } + for (const entry of data.entries) { + const selected = app.createSelection(data,entry.id); same(selected.snapshot().entry.id,entry.id,'Every entry can be addressed exactly'); + const exact = app.claimsForEntry(registry,entry).filter(claim=>claim.entry_id===entry.id); + for (const claim of exact) { + const gates=app.evidenceGates(claim); same(gates.filter(([gate,status])=>['Lean compilation','Kernel replay','Allowed-axiom audit','Formal theorem/data binding','Model performance'].includes(gate)).every(([,status])=>status==='Not supplied for this claim'),true,'Absent formal gates stay unknown'); + } + } + const model=app.createSelection(data); + const before=model.snapshot(); + for (const action of [()=>model.select('bad'),()=>model.setFilters('5','all'),()=>model.setFilters('all','N5-proof')]) assert.throws(action); + same(model.snapshot(),before,'Invalid identifiers cannot mutate selection'); + const escapedRegistry={...registry,claims:registry.claims.map(claim=>claim.id==='construction:n4-E16403'?{...claim,statement:'',assumptions:['']}:claim)}; + const escaped=app.claimsHtml(escapedRegistry,data.entries.find(entry=>entry.id==='n4-E16403')); + ok(!escaped.includes(' @@ -17,33 +18,21 @@ - -
Finite Congruence Checks
+ +
Finite Congruence Checks
-

A field guide to small mathematical worlds

A few objects.
A rule.
A whole new way to see.

Which objects can we group together and still apply the rules consistently? Follow one tiny example, then explore the patterns our tool checks.

Start with three objects

No abstract algebra background needed.

- -
- -
-

01 / Learn by trying

Meet A, B, and C.

A complete, three-object example
-
-
1

Give them a rule

A stays A. B stays B. C becomes B.

AAstays
BBstays
CBchanges

Each letter is one object. An arrow means “apply the rule once.”

-
2

Try a grouping

Objects in the same group must have outputs in the same group.

Choose a grouping to see what happens.

A bar separates groups. “BC” means B and C are together.

-
3

See the whole pattern

Exactly four of the five possible groupings work. Together, they form this square.

New kind of diagram: each node is a whole grouping. Moving upward merges groups. Lines connect neighboring allowed groupings.

-
-
THE IDEA

Our tool runs this story in reverse: choose a mathematical shape, then find objects and rules whose complete set of valid groupings makes that shape.

-
Now give those ideas their mathematical names
Carrier
The objects the rules act on. Here, A, B, and C.
Unary operation
A rule taking one object as input and returning one object.
Partition
A division of all the objects into separate, nonempty groups.
Congruence
A partition that respects every rule: inputs together stay together after each rule.
Congruence lattice
The complete pattern of valid groupings, ordered from finer to coarser.
B2
The name of the four-node square above. Its two middle groupings are incomparable.

Any two nodes of a lattice have a greatest common refinement (their meet) and a least common coarsening (their join). Here, the two middle nodes meet at the bottom and join at the top.

This example relabels the saved B2 construction: A = 2, B = 0, C = 1. The saved operation is (0, 0, 2); the friendly-label operation is (A, B, B).

- +

FINITE CONGRUENCE CHECKS

Inspect exact claims
and their evidence.

Compare finite constructions and inspect the assumptions, sources and recorded checks behind each selected claim.

Compare constructions

Research goal: discover new technical capabilities through mathematical work. Novelty and performance remain goals.

+
-

02 / The collection

Explore a small system.

One to four objects
-

Choose an entry, follow its rules, then inspect every grouping that works. Each entry represents systems that differ only by renaming their objects.

+

Atlas / recorded finite constructions

Inspect a construction.

One to four objects
+

Choose an exact entry to synchronize the map, catalog, detail and JSON export. Filters apply to both views. Each entry represents a complete relation family up to simultaneous carrier relabeling.

Loading the atlas…

Each rectangle is a whole mathematical system; each diamond is an abstract shape. Lines mean “has this shape.” Node positions and distances carry no mathematical meaning. Rule minima apply to each exact grouping family and object count.

-

Computationally checked

1 Start with the objects

2 Apply the rules

Each arrow gives the output for one input. Each rule acts on all the objects.

3 Inspect the valid groupings

Select a grouping below. Its matching node lights up in the shape.

Why does a different grouping fail?

4 Read the mathematical shape

Each node is a whole grouping. Moving upward merges groups. Lines connect allowed groupings with no allowed grouping between them. These lines describe order; they are different from rule arrows. Scroll sideways to see wide diagrams. Focus the diagram and use the left and right arrow keys when using a keyboard.

Open this entry’s technical details and certificate

The minimum below fixes this carrier, these exact relations, and unary operations. It does not optimize over larger carriers or operations with several inputs.

View the exact mathematical data
+

Saved finite evidence

1 Start with the objects

2 Apply the rules

Each arrow gives the output for one input. Each rule acts on all the objects.

3 Inspect the valid groupings

Select a grouping below. Its matching node lights up in the shape.

Why does a different grouping fail?

4 Read the mathematical shape

Each node is a whole grouping. Moving upward merges groups. Lines connect allowed groupings with no allowed grouping between them. These lines describe order; they are different from rule arrows. Scroll sideways to see wide diagrams. Focus the diagram and use the left and right arrow keys when using a keyboard.

Open this entry’s technical details and certificate

The minimum below fixes this carrier, these exact relations, and unary operations. It does not optimize over larger carriers or operations with several inputs.

View the exact mathematical data
-

03 / A useful surprise

Same shape. Different work.

Both systems below use four objects and make a four-level chain, called C4. Their groupings differ. One family needs one rule; the other needs two.

WHY IT MATTERS

Choosing the representation changes the cost. Finding a shape is one task. Finding a simpler way to build that shape is another question our tool can investigate.

“Needs” here means the fewest unary operations for that particular grouping family on that particular carrier. Four objects are necessary for a four-level chain: each strict step must merge at least two groups.

+

Comparison / fixed-carrier operation cost

Same shape. Different minima.

Both systems below use four objects and make a four-level chain, called C4. Their groupings differ. One family needs one rule; the other needs two.

WHY IT MATTERS

Choosing the representation changes the cost. Finding a shape is one task. Finding a simpler way to build that shape is another question our tool can investigate.

“Needs” here means the fewest unary operations for that particular grouping family on that particular carrier. Four objects are necessary for a four-level chain: each strict step must merge at least two groups.

+ +
+

Worked example / inspect a local witness

A three-object witness.

A complete, three-object example
+
+
1

Give them a rule

A stays A. B stays B. C becomes B.

AAstays
BBstays
CBchanges

Each letter is one object. An arrow means “apply the rule once.”

+
2

Try a grouping

Objects in the same group must have outputs in the same group.

Choose a grouping to see what happens.

A bar separates groups. “BC” means B and C are together.

+
3

See the whole pattern

Exactly four of the five possible groupings work. Together, they form this square.

New kind of diagram: each node is a whole grouping. Moving upward merges groups. Lines connect neighboring allowed groupings.

+
+
THE IDEA

Our tool runs this story in reverse: choose a mathematical shape, then find objects and rules whose complete set of valid groupings makes that shape.

+
Now give those ideas their mathematical names
Carrier
The objects the rules act on. Here, A, B, and C.
Unary operation
A rule taking one object as input and returning one object.
Partition
A division of all the objects into separate, nonempty groups.
Congruence
A partition that respects every rule: inputs together stay together after each rule.
Congruence lattice
The complete pattern of valid groupings, ordered from finer to coarser.
B2
The name of the four-node square above. Its two middle groupings are incomparable.

Any two nodes of a lattice have a greatest common refinement (their meet) and a least common coarsening (their join). Here, the two middle nodes meet at the bottom and join at the top.

This example relabels the saved B2 construction: A = 2, B = 0, C = 1. The saved operation is (0, 0, 2); the friendly-label operation is (A, B, B).

+ +

04 / A second kind of small system

Same stopping time.
Same result?

Four exact machine pairs
@@ -92,8 +93,9 @@ 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

Source and generator hashes
Download the complete browser data ↓ +node scripts/check_atlas_map.cjs +node scripts/check_atlas_selection.cjs

Source and generator hashes
Download the complete browser data ↓ - + diff --git a/space/atlas.js b/space/atlas.js index ba6d64c..c7424a4 100644 --- a/space/atlas.js +++ b/space/atlas.js @@ -101,23 +101,70 @@ if (!registry || registry.schema_version !== 1 || !Array.isArray(registry.claims)) return []; return registry.claims.filter(claim => claim.entry_id === entry.id || (Array.isArray(claim.entry_ids) && claim.entry_ids.includes(entry.id))); } + // Build provenance is separate from the registry, which supplies no Git revision. + const BUILD_INPUT = Object.freeze({ repository: GITHUB, base_revision: '5a5167574cf63ba4e807893a3fb2f71277b14611' }); + function createSelection(data, requestedId) { + if (data.schema_version !== 1 || new Set(data.entries.map(entry => entry.id)).size !== data.entries.length) throw new Error('Unique schema-1 entry IDs are required.'); + const initial = data.entries.find(entry => entry.id === requestedId) || data.entries.find(entry => entry.name === 'C4' && entry.carrier_size === 4 && entry.minimum_unary_operations === 1) || data.entries[0]; + let state = Object.freeze({ carrier: String(initial.carrier_size), shape: initial.abstract_type, entry: initial }); + const listeners = new Set(); + function publish(carrier, shape, entry) { + if (state.carrier === carrier && state.shape === shape && state.entry === entry) return; + state = Object.freeze({ carrier, shape, entry }); + listeners.forEach(listener => listener(state)); + } + return Object.freeze({ + snapshot: () => state, + subscribe(listener) { listeners.add(listener); listener(state); return () => listeners.delete(listener); }, + select(id) { + const entry = data.entries.find(item => item.id === id); + if (!entry) throw new Error('Unknown entry ID.'); + const visible = filterEntries(data.entries, state.carrier, state.shape).includes(entry); + publish(visible ? state.carrier : String(entry.carrier_size), visible ? state.shape : entry.abstract_type, entry); + }, + setFilters(carrier, shape) { + carrier = String(carrier); + if (!['all', '1', '2', '3', '4'].includes(carrier) || (shape !== 'all' && !data.abstract_types.some(item => item.id === shape))) throw new Error('Unknown atlas filter.'); + const visible = filterEntries(data.entries, carrier, shape); + publish(carrier, shape, visible.includes(state.entry) ? state.entry : visible[0] || null); + }, + }); + } + function evidenceGates(claim) { + const absent = 'Not supplied for this claim'; + return [ + ['Formal source / theorem type', absent], + ['Lean compilation', absent], + ['Kernel replay', absent], + ['Allowed-axiom audit', absent], + ['Finite computation', claim.evidence_status === 'exhaustive_computation_independently_checked' ? 'Saved exhaustive computation and independent check; not rerun by this inspector' : `Recorded status: ${claim.evidence_status || 'not supplied'}`], + ['Negative controls', 'No per-claim receipt supplied; atlas-wide controls are recorded separately'], + ['Citation integrity', Array.isArray(claim.citations) && claim.citations.length ? 'Source locators and normalized SHA-256 hashes supplied; not rehashed by the browser' : absent], + ['Formal theorem/data binding', absent], + ['Model performance', absent], + ]; + } function claimsHtml(registry, entry) { const claims = claimsForEntry(registry, entry); if (!claims.length) return '

The offline claim registry is unavailable for this entry. The mathematical data remains available below.

'; - const unique = field => [...new Set(claims.flatMap(claim => claim[field] || []))]; const list = items => ``; - const records = claims.map(claim => `
${escapeHtml(claim.id)}

${escapeHtml(claim.statement)}

`).join(''); - const scopes = [...new Set(claims.map(claim => claim.scope))]; - const evidence = [...new Set(claims.map(claim => claim.evidence_status.replace(/_/g, ' ')))]; - return `

Claims attached to this entry

These stable IDs connect the displayed result to source locations and file hashes in the downloadable registry.

${records}
Read the assumptions, limits, and evidence status

Evidence: ${escapeHtml(evidence.join('; '))}.

Scope: ${scopes.map(escapeHtml).join(' ')}

Assumptions

${list(unique('assumptions'))}

Limits

${list(unique('limits'))}

Download all claim records and source citations ↓ · Query guide ↗

`; + const pinned = path => `${GITHUB}/blob/${BUILD_INPUT.base_revision}/${path.split('/').map(encodeURIComponent).join('/')}`; + const records = claims.map(claim => { + const direct = claim.entry_id === entry.id; + const citations = (claim.citations || []).map(citation => `
  • ${escapeHtml(citation.path)}
    JSON pointer ${escapeHtml(citation.json_pointer)}
    SHA-256 ${escapeHtml(citation.sha256)}
  • `).join(''); + const gates = evidenceGates(claim).map(([gate, status]) => `${escapeHtml(gate)}${escapeHtml(status)}`).join(''); + return `
    ${direct ? (claim.kind === 'fixed_family_minimum' ? 'Fixed-family minimum' : 'Exact construction') : 'Related comparison'}
    ${escapeHtml(claim.id)}

    ${escapeHtml(claim.statement)}

    Scope: ${escapeHtml(claim.scope)}

    Inspect ${escapeHtml(claim.id)}: hypotheses, citations and evidence gates
    Kind
    ${escapeHtml(claim.kind)}
    Exact entry IDs
    ${escapeHtml(direct ? claim.entry_id : claim.entry_ids.join(', '))}
    Carrier size
    ${escapeHtml(claim.carrier_size)}
    Shape key (classification only)
    ${escapeHtml(claim.shape_key)}
    ${claim.minimum_unary_operations !== undefined ? `
    Minimum unary operations
    ${escapeHtml(claim.minimum_unary_operations)}
    ` : ''}
    Recorded status
    ${escapeHtml(claim.evidence_status)}
    Recorded hypotheses
    ${list(claim.assumptions || [])}
    Limits
    ${list(claim.limits || [])}
    Separate evidence gates
    ${gates}
    Evidence supplied for ${escapeHtml(claim.id)}
    GateRecord status
    Source citations

    ${escapeHtml(registry.hash_encoding)}

      ${citations}
    `; + }).join(''); + return `

    Exact claim record

    Selected mathematical object: schema 1 / ${escapeHtml(entry.id)}. Carrier: {${Array.from({ length: entry.carrier_size }, (_, i) => i).join(', ')}}. Construction and minimum are distinct claims.

    Inspect the selected operations and complete relation family
    ${escapeHtml(JSON.stringify({ operations: entry.operations, partitions: entry.partitions, order: entry.order, covers: entry.covers }, null, 2))}
    Registry
    ${escapeHtml(registry.namespace)} · schema ${escapeHtml(registry.schema_version)}
    UI/build input revision
    ${BUILD_INPUT.base_revision}
    Registry Git revision
    Not supplied by this registry; the revision above identifies the copied build inputs.
    Formal theorem type
    Not supplied for this claim

    Shape labels classify records; they do not transfer N5 or B3 proofs to this entry. Citation hashes are record-integrity metadata, not formal theorem/data binding.

    ${records}

    Download all claim records and source citations ↓ · Pinned query contract ↗

    `; } function certificate(data, entry, registry = null) { const record = { schema_version: data.schema_version, scope: data.scope, evidence_status: data.evidence_status, minimum_scope: data.minimum_scope, source_sha256: data.source_sha256, generator_sha256: data.generator_sha256, hash_encoding: data.hash_encoding, entry }; const claims = claimsForEntry(registry, entry); - if (claims.length) record.claims = { registry: 'atlas-claims.json', namespace: registry.namespace, ids: claims.map(claim => claim.id), sources: registry.sources }; + record.ui_build_input = BUILD_INPUT; + if (claims.length) record.claims = { registry: 'atlas-claims.json', schema_version: registry.schema_version, namespace: registry.namespace, registry_git_revision: null, hash_encoding: registry.hash_encoding, ids: claims.map(claim => claim.id), sources: registry.sources, records: claims, evidence_gates: claims.map(claim => ({ claim_id: claim.id, gates: evidenceGates(claim) })) }; return record; } - const api = { LESSON, escapeHtml, blocks, partitionLabel, partitions, checkGrouping, operationHtml, groupingHtml, latticeSvg, filterEntries, claimsForEntry, claimsHtml, certificate }; + const api = { LESSON, escapeHtml, blocks, partitionLabel, partitions, checkGrouping, operationHtml, groupingHtml, latticeSvg, filterEntries, claimsForEntry, claimsHtml, certificate, createSelection, evidenceGates, BUILD_INPUT }; if (typeof module !== 'undefined' && module.exports) module.exports = api; if (typeof document === 'undefined') return; @@ -139,23 +186,22 @@ byId('comparison').hidden = true; return; } - let selectedEntry = data.entries.find(entry => entry.name === 'B2' && entry.carrier_size === 3) || data.entries[0]; - let selectedGrouping = 0; + const selection = createSelection(data, new URLSearchParams(window.location.search).get('entry')); let lastDownloadUrl = null; function renderGrouping(index) { - selectedGrouping = index; + const selectedEntry = selection.snapshot().entry; + if (!selectedEntry) return; const partition = selectedEntry.partitions[index]; byId('entry-grouping').innerHTML = groupingHtml(partition, selectedEntry.operations); byId('entry-diagram').innerHTML = latticeSvg(selectedEntry, index); byId('grouping-list').querySelectorAll('button').forEach(button => button.setAttribute('aria-pressed', String(Number(button.dataset.grouping) === index))); } function renderEntry(entry) { - selectedEntry = entry; const n = entry.carrier_size, minimum = entry.minimum_unary_operations; const shape = entry.name.startsWith('Shape ') ? `${entry.name} · ${entry.partitions.length} grouping${entry.partitions.length === 1 ? '' : 's'}` : `${entry.name} · ${n} object${n === 1 ? '' : 's'}`; byId('entry-kicker').textContent = `ENTRY ${entry.id} / SHAPE ${entry.abstract_type}`; byId('entry-title').textContent = shape; - byId('entry-intro').textContent = `${n} object${n === 1 ? '' : 's'} and ${minimum} rule${minimum === 1 ? '' : 's'} give exactly ${entry.partitions.length} valid grouping${entry.partitions.length === 1 ? '' : 's'}. Each entry has its own rules and object labels; check the arrows again.`; + byId('entry-intro').textContent = `${n} object${n === 1 ? '' : 's'} and ${minimum} rule${minimum === 1 ? '' : 's'} give exactly ${entry.partitions.length} valid grouping${entry.partitions.length === 1 ? '' : 's'}. The operation tables and complete relation family identify this exact construction.`; byId('entry-facts').innerHTML = `
    ${n}object${n === 1 ? '' : 's'}
    ${minimum}minimum unary rule${minimum === 1 ? '' : 's'}
    ${entry.partitions.length}valid grouping${entry.partitions.length === 1 ? '' : 's'}
    `; byId('entry-objects').innerHTML = Array.from({ length: n }, (_, i) => `${LETTERS[i]}`).join(''); byId('entry-operations').innerHTML = entry.operations.length ? entry.operations.map(operationHtml).join('') : '

    This system has no rules. Every partition of its objects is therefore a valid grouping. Allowing zero operations is part of this atlas’s stated convention.

    '; @@ -165,7 +211,7 @@ byId('entry-failure').innerHTML = rejected ? `
    ${groupingHtml(rejected, entry.operations)}
    ` : '

    Every possible grouping works for this entry. There is no failing grouping to display.

    '; byId('failure-details').open = false; byId('entry-takeaway').textContent = minimum === 0 ? `Takeaway: the objects alone already give this shape. Adding a rule is unnecessary for this grouping family.` : `Takeaway: ${minimum === 1 ? 'this one rule allows' : `these ${minimum} rules allow`} every displayed grouping and ${minimum === 1 ? 'excludes' : 'exclude'} every other partition. Exhaustive checking shows that fewer unary rules cannot produce this exact family on these ${n} objects.`; - byId('entry-provenance').innerHTML = `
    Entry
    ${escapeHtml(entry.id)}
    Abstract shape
    ${escapeHtml(entry.abstract_type)}
    Labeled families represented
    ${entry.orbit_size} under object renaming
    Stored object indices
    ${Array.from({ length: n }, (_, i) => `${LETTERS[i]} = ${i}`).join(', ')}
    Evidence type
    Exhaustive finite computation and independent verification

    Inspect the independent verification record ↗

    `; + byId('entry-provenance').innerHTML = `
    Entry
    ${escapeHtml(entry.id)}
    Abstract shape
    ${escapeHtml(entry.abstract_type)}
    Labeled families represented
    ${entry.orbit_size} under object renaming
    Stored object indices
    ${Array.from({ length: n }, (_, i) => `${LETTERS[i]} = ${i}`).join(', ')}
    Evidence type
    Saved exhaustive finite computation and independent verification; not rerun here

    Inspect the independent verification record ↗

    `; byId('entry-claims').innerHTML = claimsHtml(registry, entry); byId('entry-context').hidden = entry.id !== 'n4-E16709'; byId('entry-json').textContent = JSON.stringify(certificate(data, entry, registry), null, 2); @@ -174,15 +220,17 @@ renderGrouping(firstNontrivial >= 0 ? firstNontrivial : 0); } function renderCatalog() { - const visible = filterEntries(data.entries, byId('carrier-filter').value, byId('shape-filter').value); + const { carrier, shape, entry: selectedEntry } = selection.snapshot(); + byId('carrier-filter').value = carrier; + byId('shape-filter').value = shape; + const visible = filterEntries(data.entries, carrier, shape); byId('entry-count').textContent = `${visible.length} ${visible.length === 1 ? 'entry' : 'entries'} shown`; - byId('entry-list').innerHTML = visible.length ? visible.map(entry => ``).join('') : '

    No entries match both filters. Try a different object count or shape.

    '; - byId('entry-list').querySelectorAll('button').forEach(button => button.addEventListener('click', () => renderEntry(data.entries.find(entry => entry.id === button.dataset.entry)))); - if (visible.length && !visible.some(entry => entry.id === selectedEntry.id)) renderEntry(visible[0]); - byId('entry-title').closest('.entry-detail').hidden = !visible.length; + byId('entry-list').innerHTML = visible.length ? visible.map(entry => ``).join('') : '

    No entries match both filters. Try a different object count or shape.

    '; + byId('entry-list').querySelectorAll('button').forEach(button => button.addEventListener('click', () => selection.select(button.dataset.entry))); } - byId('carrier-filter').addEventListener('change', renderCatalog); - byId('shape-filter').addEventListener('change', renderCatalog); + const changeFilters = () => selection.setFilters(byId('carrier-filter').value, byId('shape-filter').value); + byId('carrier-filter').addEventListener('change', changeFilters); + byId('shape-filter').addEventListener('change', changeFilters); byId('shape-filter').insertAdjacentHTML('beforeend', data.abstract_types.map(shape => ``).join('')); const totalFamilies = data.carrier_summary.reduce((sum, row) => sum + row.labeled_relation_families, 0); byId('atlas-totals').innerHTML = `
    ${totalFamilies}labeled grouping families
    ${data.entries.length}entries after renaming
    ${data.abstract_types.length}distinct abstract shapes
    `; @@ -190,15 +238,14 @@ const comparisons = [1, 2].map(minimum => data.entries.find(entry => entry.name === 'C4' && entry.carrier_size === 4 && entry.minimum_unary_operations === minimum)).filter(Boolean); byId('comparison-cards').innerHTML = comparisons.map(entry => `

    FOUR OBJECTS / FOUR GROUPINGS

    ${entry.minimum_unary_operations === 1 ? 'One rule is enough.' : 'Two rules are necessary.'}

    Read the groups inside each node: they distinguish this construction.

    ${latticeSvg(entry, -1, true)}
    ${entry.operations.map(operationHtml).join('')}
    `).join(''); byId('comparison-cards').querySelectorAll('button').forEach(button => button.addEventListener('click', () => { - byId('carrier-filter').value = '4'; - byId('shape-filter').value = comparisons[0].abstract_type; - renderCatalog(); - renderEntry(data.entries.find(entry => entry.id === button.dataset.compare)); + selection.select(button.dataset.compare); byId('entry-title').scrollIntoView({ behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'instant' : 'smooth', block: 'start' }); byId('entry-title').setAttribute('tabindex', '-1'); byId('entry-title').focus({ preventScroll: true }); })); byId('download-entry').addEventListener('click', () => { + const selectedEntry = selection.snapshot().entry; + if (!selectedEntry) return; if (lastDownloadUrl) URL.revokeObjectURL(lastDownloadUrl); lastDownloadUrl = URL.createObjectURL(new Blob([JSON.stringify(certificate(data, selectedEntry, registry), null, 2) + '\n'], { type: 'application/json' })); const link = document.createElement('a'); @@ -206,7 +253,7 @@ link.download = `atlas-${selectedEntry.id}.json`; document.body.append(link); link.click(); link.remove(); }); - byId('reproduce-commands').textContent = 'python scripts/build_atlas_data.py --check\npython scripts/check_atlas.py --check-receipt evidence/atlas-review.json\npython scripts/check_atlas.py --out runs/atlas-review.json\npython scripts/query_atlas.py build-claims --check\npython -m unittest discover -s scripts -p "test_atlas*.py" -v\nnode scripts/check_atlas_ui.cjs\nnode scripts/check_atlas_map.cjs'; + byId('reproduce-commands').textContent = 'python scripts/build_atlas_data.py --check\npython scripts/check_atlas.py --check-receipt evidence/atlas-review.json\npython scripts/check_atlas.py --out runs/atlas-review.json\npython scripts/query_atlas.py build-claims --check\npython -m unittest discover -s scripts -p "test_atlas*.py" -v\nnode scripts/check_atlas_ui.cjs\nnode scripts/check_atlas_map.cjs\nnode scripts/check_atlas_selection.cjs'; byId('copy-commands').addEventListener('click', async () => { try { await navigator.clipboard.writeText(byId('reproduce-commands').textContent); @@ -218,18 +265,21 @@ byId('source-record').textContent = JSON.stringify({ scope: data.scope, evidence_status: data.evidence_status, minimum_scope: data.minimum_scope, hash_encoding: data.hash_encoding, generator_sha256: data.generator_sha256, source_sha256: data.source_sha256 }, null, 2); byId('atlas-loading').hidden = true; byId('atlas-app').hidden = false; - renderCatalog(); - const requestedEntry = data.entries.find(entry => entry.id === new URLSearchParams(window.location.search).get('entry')); - if (requestedEntry) selectedEntry = requestedEntry; - renderEntry(selectedEntry); - if (window.AtlasMap) window.AtlasMap.mount(data, registry, entry => { - byId('carrier-filter').value = String(entry.carrier_size); - byId('shape-filter').value = entry.abstract_type; - renderCatalog(); - renderEntry(entry); + let renderedFilters = '', renderedEntry = null; + selection.subscribe(state => { + const filters = `${state.carrier}/${state.shape}`; + if (filters !== renderedFilters) { renderCatalog(); renderedFilters = filters; } + byId('entry-title').closest('.entry-detail').hidden = !state.entry; + byId('download-entry').disabled = !state.entry; + if (state.entry && state.entry !== renderedEntry) renderEntry(state.entry); + if (!state.entry) { byId('entry-json').textContent = ''; byId('entry-claims').innerHTML = ''; } + renderedEntry = state.entry; + byId('entry-list').querySelectorAll('button').forEach(button => button.setAttribute('aria-pressed', String(button.dataset.entry === state.entry?.id))); + }); + if (window.AtlasMap) window.AtlasMap.mount(data, registry, () => { const title = byId('entry-title'); title.setAttribute('tabindex', '-1'); title.scrollIntoView({ block: 'start', behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'instant' : 'smooth' }); title.focus({ preventScroll: true }); - }); + }, selection); }());