diff --git a/.github/workflows/public-shop.yml b/.github/workflows/public-shop.yml index d00ea6008..6f390a481 100644 --- a/.github/workflows/public-shop.yml +++ b/.github/workflows/public-shop.yml @@ -19,7 +19,7 @@ jobs: - name: Status-export negative controls run: python3 -B -m unittest discover -s tests -p test_public_shop_data.py - name: Browser data-validation controls - run: node --test tests/test_public_shop_frontend.mjs tests/test_explore_models.mjs tests/test_reader_navigation.mjs tests/test_source_reference.mjs tests/test_measurement_model.mjs tests/test_dependency_viewer.mjs + run: node --test tests/test_public_shop_frontend.mjs tests/test_explore_models.mjs tests/test_reader_navigation.mjs tests/test_source_reference.mjs tests/test_measurement_model.mjs tests/test_dependency_viewer.mjs tests/test_museum_frontend.mjs tests/test_workspace_navigation.mjs - name: Reader navigation and local asset routes run: python3 -B -S -m unittest discover -s tests -p test_reader_links.py -v - name: Museum source projection and refusal controls diff --git a/docs/site/app.js b/docs/site/app.js index 82fbc1a68..b264b1be2 100644 --- a/docs/site/app.js +++ b/docs/site/app.js @@ -101,6 +101,8 @@ async function custody(config) { const observed=config.observations; el('custody-note').textContent=`${config.imports.count} byte-copy imports landed at Math ${config.imports.commit}; source labels were not adopted. ${observed.open_math_prs} Math PRs were open when observed ${observed.observed_at}. An open PR is not landed math.`; el('custody-note').append(' ',link('Import identities ↗',config.imports.manifest_url)); +} +async function queryIdentity(config) { const q=config.query;const bundle=await verifiedJSON(q);if(bundle.math_tip!==q.math_pin||bundle.scientific_status_authority!==false)throw new Error('Query source mismatch'); if(!hex40.test(q.math_pin)||!hex40.test(q.commit))throw new Error('Query pin unavailable'); identity(el('query-identity'),q);el('query-identity').append(node('p','Recorded Math commit: '+q.math_pin)); @@ -109,7 +111,7 @@ async function custody(config) { } try { const response=await fetch('config.json',{credentials:'omit'});if(!response.ok)throw new Error('Shop config unavailable');const config=await response.json(); - const jobs=[['status-note',()=>board(config)],['coefficient-state',()=>coefficients(config)],['inventory-state',()=>inventory(config)],['custody-note',()=>custody(config)]]; + const jobs=[['status-note',()=>board(config)],['coefficient-state',()=>coefficients(config)],['inventory-state',()=>inventory(config)],['custody-note',()=>custody(config)],['query-note',()=>queryIdentity(config)]]; await Promise.allSettled(jobs.map(async([id,job])=>{try{await job();}catch(e){error(id,e);}})); -} catch(e) {['status-note','coefficient-state','inventory-state','custody-note'].forEach(id=>error(id,e));} +} catch(e) {['status-note','coefficient-state','inventory-state','custody-note','query-note'].forEach(id=>error(id,e));} finally {finishFragment();} diff --git a/docs/site/cite.html b/docs/site/cite.html index 571403d83..66b80cfa0 100644 --- a/docs/site/cite.html +++ b/docs/site/cite.html @@ -11,7 +11,7 @@

A REFERENCE SOMEONE ELSE CAN FOLLOW

Cite the work
you actually used.

A research program, a proof, and a calculation are different sources. Point readers to the exact object and version that support your work.

-

Choose the right object.

The research website

Use main’s citation metadata for this public guide and reproduction surface. GitHub’s “Cite this repository” menu supplies APA and BibTeX formats.

A mathematical result

Link the exact proof in Math-, its full commit and the review you used. Preserve the authorship and hypotheses stated by that object; a repository maintainer is not automatically every proof’s author.

A tool or data artifact

Name the package or artifact, its version or commit, and its own citation guidance. query- identifies source bytes; it does not certify the mathematical claim they contain.

+

Choose the right object.

The research website

Use main’s citation metadata for this public guide and reproduction surface. GitHub’s “Cite this repository” menu supplies APA and BibTeX formats.

A mathematical result

Find the result in Math-’s current proof index, then cite its exact proof, full commit and the review you used. Preserve the authorship and hypotheses stated by that object; a repository maintainer is not automatically every proof’s author.

A tool or data artifact

Name the package or artifact, its version or commit, and its own citation guidance. query- identifies source bytes; it does not certify the mathematical claim they contain.

EXACT SOURCES

Give a future reader a fixed point.

Use a commit permalink for the content you read. Branch links such as main can change. Record the repository, complete Git commit and file path; include a SHA-256 or artifact identifier when the source provides one.

A source reference locates bytes. Add the source’s own authors, title and publication details when preparing a bibliography. A review should be cited separately when your argument relies on that review’s scope.

No DOI or tagged-release version is declared in main’s current citation metadata. Use a commit reference now. A future archive deposit must supply its actual identifier before a DOI is advertised. Citation and archival identifiers do not establish scientific acceptance.

A complete example

SIDE24 coefficient proof, Math- commit f430fdecbb1d8802d8af40419b701f12af87c039, coefficients/side24_v1/PROOF.md. Pair this source with its recorded review and scope when discussing acceptance. Replay its calculation.

-

04 / JOIN THE WORK

Bring a result. Keep its evidence.

1. Claim a bounded task

Replay a pinned calculation, chart public data, document an import, or leave a source-bound review comment. Comment /claim; wait for assignment and keep one active claim.

Browse public tasks ↗

2. Submit a result PR

Fork main. Add an incoming/<id>/ package with your result, outputs, and source/file identities. Do not edit scientific status rows.

Contribution instructions ↗

3. Review before integration

A designated reviewer checks the sources, scope, and limitations. Intake checks validate packaging; accepted intake is not an accepted theorem.

Public review queue ↗
+

04 / JOIN THE WORK

Bring a result. Keep its evidence.

1. Claim a bounded task

Replay a pinned calculation, chart public data, document an import, or leave a source-bound review comment. Check current ownership, comment /claim with your scope before beginning, and keep one active claim.

Browse public tasks ↗

2. Submit a result PR

Fork main. Add an incoming/<id>/ package with your result, outputs, and source/file identities. Do not edit scientific status rows.

Contribution instructions ↗

3. Review before integration

A designated reviewer checks the sources, scope, and limitations. Intake checks validate packaging; accepted intake is not an accepted theorem.

Public review queue ↗
diff --git a/tests/test_dependency_viewer.mjs b/tests/test_dependency_viewer.mjs index 2dcb42bd9..de27d8723 100644 --- a/tests/test_dependency_viewer.mjs +++ b/tests/test_dependency_viewer.mjs @@ -1,6 +1,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; +import { webcrypto } from 'node:crypto'; import { buildGraphIndex, @@ -21,6 +22,45 @@ const pageURL = new URL('docs/site/dependencies.html', root); const appURL = new URL('docs/site/dependencies.mjs', root); const styleURL = new URL('docs/site/dependencies.css', root); +for (const digestDelay of [0, 150]) test(`broad dependency searches expose every matching node after ${digestDelay} ms digest delay`, async () => { + class Element extends EventTarget { + constructor(){super();this.children=[];this.value='';this._text='';} + set textContent(value){this._text=String(value);this.children=[];} + get textContent(){return this._text+this.children.map(child=>child.textContent||'').join('');} + append(...children){this.children.push(...children);} + replaceChildren(...children){this.children=children;this._text='';} + } + const html=await readFile(pageURL,'utf8'); + const nodes=new Map([...html.matchAll(/\bid="([^"]+)"/g)].map(match=>[match[1],new Element()])); + const saved=new Map(['window','document','fetch','crypto'].map(name=>[name,Object.getOwnPropertyDescriptor(globalThis,name)])); + if (digestDelay) Object.defineProperty(globalThis,'crypto',{configurable:true,value:{subtle:{async digest(...args){ + await new Promise(resolve=>setTimeout(resolve,digestDelay)); + return webcrypto.subtle.digest(...args); + }}}}); + const window=new EventTarget();window.location={hash:'',search:'',href:'https://example.test/dependencies.html'}; + globalThis.window=window; + globalThis.document={getElementById:id=>nodes.get(id),createElement:()=>new Element(),createTextNode:text=>({textContent:text})}; + globalThis.fetch=async url=>{ + assert.ok(['./dependency-source/GRAPH.json','./dependency-source/PROVENANCE.json'].includes(url)); + return new Response(await readFile(new URL('docs/site/'+url,root))); + }; + let initialization; + try { + ({initialization}=await import(`../docs/site/dependencies.mjs?visitor-search-${digestDelay}`)); + // Await the actual startup lifecycle, including byte validation and rendering. + await initialization; + assert.match(nodes.get('load-status').textContent,/^Pinned Math/); + const search=nodes.get('dependency-search');search.value='math';search.dispatchEvent(new Event('input')); + assert.equal(nodes.get('search-results').children.length,39); + assert.match(nodes.get('search-results').textContent,/math.side24-coefficient/); + assert.match(nodes.get('search-results').textContent,/math.uniform-matrix-cap-lifetime/); + } finally { + // Keep the DOM/network globals alive until all startup work has settled. + await initialization; + for(const [name,descriptor] of saved)if(descriptor)Object.defineProperty(globalThis,name,descriptor);else delete globalThis[name]; + } +}); + async function fixture() { return JSON.parse(await readFile(graphURL, 'utf8')); } diff --git a/tests/test_museum_frontend.mjs b/tests/test_museum_frontend.mjs index fed278c4e..44225b17b 100644 --- a/tests/test_museum_frontend.mjs +++ b/tests/test_museum_frontend.mjs @@ -10,6 +10,42 @@ test('museum exposes source-bound rendering rather than silently omitting the pa }); const museum = fs.existsSync(moduleURL) ? await import(moduleURL) : null; const available = {skip: !museum}; + +async function delayedClaimPage(interaction) { + const f=fixture(),document=documentFromHTML(),window=new EventTarget(),events=[]; + window.location={hash:'#d3-side24-coefficient'}; + const frames=[];window.requestAnimationFrame=callback=>frames.push(callback); + const create=document.createElement; + document.createElement=tag=>{ + const node=create(tag); + node.focus=()=>{document.activeElement=node;events.push('focus:'+node.id);}; + node.scrollIntoView=()=>events.push('scroll:'+node.id); + return node; + }; + const find=(node,id)=>node.id===id?node:node.children?.map(child=>find(child,id)).find(Boolean); + document.getElementById=id=>document.nodes.get(id)||[...document.nodes.values()].map(node=>find(node,id)).find(Boolean); + const raw=JSON.stringify(f.manifest),config=JSON.stringify({museum_json:{url:'museum.json',bytes:Buffer.byteLength(raw),sha256:digest(raw)}}); + const mapping=new Map([['config.json',config],['museum.json',raw],[f.manifest.index_source.url,f.index],[f.manifest.status_source.url,f.status],[f.manifest.claims[0].proof.url,'Pinned proof.'],[f.manifest.claims[11].review.url,'Pinned reconciliation.']]); + let release,started;const gate=new Promise(resolve=>release=resolve),requested=new Promise(resolve=>started=resolve); + const loading=museum.startMuseum({document,window,search:'',currentHash:()=>window.location.hash,fetcher:async url=>{ + if(url===f.manifest.claims[0].proof.url){started();await gate;} + assert.ok(mapping.has(url),'Unexpected museum source '+url);return new Response(mapping.get(url)); + }}); + await requested; + if(interaction)window.dispatchEvent(new Event(interaction)); + release();await loading; + for(const frame of frames)frame(); + return {events,document}; +} +test('a delayed initial museum bookmark still reaches its verified claim when untouched',async()=>{ + const page=await delayedClaimPage(); + assert.deepEqual(page.events,['scroll:d3-side24-coefficient','focus:d3-side24-coefficient']); +}); +for(const interaction of ['wheel','keydown','pointerdown','focusin','hashchange','popstate','pagehide']) { + test(`museum ${interaction} while verifying sources cancels delayed focus and scroll`,async()=>{ + const page=await delayedClaimPage(interaction);assert.deepEqual(page.events,[]); + }); +} test('full reviewed bullets, the reconciled D1 row and both AMEND rows retain their classes and source wording',available,()=>{ const {manifest,index,status}=fixture(); assert.equal(museum.validateBoundManifest(manifest,index,status).claims.length,14); diff --git a/tests/test_public_shop_browser_contract.py b/tests/test_public_shop_browser_contract.py index 1a2b3266e..f42a181e1 100644 --- a/tests/test_public_shop_browser_contract.py +++ b/tests/test_public_shop_browser_contract.py @@ -51,7 +51,7 @@ def test_browser_dependencies_are_separate_and_version_pinned(self): class ReaderSourceBrowserContract(unittest.TestCase): def test_existing_runner_covers_source_quote_and_keyboard_disclosure(self): source=(ROOT/'tools/public_shop_browser_check.py').read_text() - for token in ['check_source_card_flow','source-quote-readable','source-quote-original','Exact source quote','issuecomment-5841270276','len(report["cases"])==13']: + for token in ['check_source_card_flow','source-quote-readable','source-quote-original','Exact source quote','issuecomment-5841270276','len(report["cases"])==15']: self.assertIn(token,source) def test_reader_tools_have_desktop_and_mobile_browser_evidence(self): @@ -69,7 +69,7 @@ def test_reader_tools_have_desktop_and_mobile_browser_evidence(self): 'dated claim-dependency snapshot', 'page.keyboard.press("Tab")', 'page.keyboard.press("Enter")', 'documentElement.scrollWidth', - 'len(report["cases"])==13', + 'len(report["cases"])==15', ]: self.assertIn(token,source) diff --git a/tests/test_workspace_navigation.mjs b/tests/test_workspace_navigation.mjs index a62f82fee..99c26b11a 100644 --- a/tests/test_workspace_navigation.mjs +++ b/tests/test_workspace_navigation.mjs @@ -1,12 +1,13 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; +import {createHash} from 'node:crypto'; // Exercise actual app startup and source validation. Only the browser and // network boundaries are replaced; this is not a browser layout test. const root=new URL('../',import.meta.url); const html=fs.readFileSync(new URL('docs/site/workspace.html',root),'utf8'); -const config=JSON.parse(fs.readFileSync(new URL('docs/site/config.json',root))); +const originalConfig=JSON.parse(fs.readFileSync(new URL('docs/site/config.json',root))); const deferred=()=>{let resolve;const promise=new Promise(r=>{resolve=r;});return {promise,resolve};}; let run=0; @@ -19,7 +20,13 @@ class Element extends EventTarget { setAttribute(name,value){this.attributes[name]=String(value);} } -function page(hash='#inventory',{configFailure=false}={}) { +function page(hash='#inventory',{configFailure=false,importSuccess=false,querySuccess=false}={}) { + const config=structuredClone(originalConfig); + const importBytes=JSON.stringify({scientific_effect:'NONE',byte_copies:Array.from({length:config.imports.count},()=>({kind:'BYTE_COPY',source_label_adopted:false}))}); + const queryBytes=JSON.stringify({math_tip:config.query.math_pin,scientific_status_authority:false}); + for(const [key,bytes] of [['imports',importBytes],['query',queryBytes]]){ + config[key].bytes=Buffer.byteLength(bytes);config[key].sha256=createHash('sha256').update(bytes).digest('hex'); + } const events=[],nodes=new Map(),window=new EventTarget(),listeners=new Set(),frames=[]; window.location={hash}; window.requestAnimationFrame=callback=>{frames.push(callback);return frames.length;}; @@ -49,8 +56,9 @@ function page(hash='#inventory',{configFailure=false}={}) { globalThis.fetch=async url=>{ if(url==='config.json'){requested.resolve();await configuration.promise;return configFailure?new Response('',{status:503}):new Response(JSON.stringify(config));} if(url===config.status.url){statusRequested.resolve();await status.promise;} - if(url===config.imports.url){custodyRequested.resolve();await custody.promise;return new Response('',{status:503});} + if(url===config.imports.url){custodyRequested.resolve();await custody.promise;return importSuccess?new Response(importBytes):new Response('',{status:503});} if(url===config.coefficient.url)return new Response('',{status:503}); + if(url===config.query.url)return querySuccess?new Response(queryBytes):new Response('',{status:503}); assert.ok(mapping.has(url),`Unexpected fetch ${url}`); return new Response(fs.readFileSync(new URL(mapping.get(url),root))); }; @@ -155,3 +163,28 @@ test('reader movement between source settlement and final rendering prevents cor p.window.dispatchEvent(new Event('wheel'));p.flushFrames(); assert.deepEqual(p.events,[]);assert.equal(p.listeners.size,0); }); + +test('an import refusal does not leave the separate query source loading forever',async()=>{ + const p=page();await complete(p); + assert.match(p.nodes.get('query-note').textContent,/Unavailable:.*503.*No result inferred/); + assert.doesNotMatch(p.nodes.get('query-note').textContent,/Loading/); + assert.equal(p.nodes.get('query-identity').children.length,0); +}); + +test('a config refusal settles every pending source note',async()=>{ + const p=page('',{configFailure:true});await complete(p); + assert.match(p.nodes.get('query-note').textContent,/Unavailable: Shop config unavailable/); +}); + +test('a query refusal preserves verified import custody information',async()=>{ + const p=page('',{importSuccess:true});await complete(p); + assert.match(p.nodes.get('custody-note').textContent,/9 byte-copy imports landed/); + assert.match(p.nodes.get('query-note').textContent,/Unavailable:.*503/); +}); + +test('a successful query remains usable when the unrelated import source fails',async()=>{ + const p=page('',{querySuccess:true});await complete(p); + assert.match(p.nodes.get('custody-note').textContent,/Unavailable:.*503/); + assert.match(p.nodes.get('query-note').textContent,/performs no live tip check/); + assert.match(p.nodes.get('query-identity').textContent,/c88768bb11efd1f7d6bda188f13064bedec54a06/); +}); diff --git a/tools/public_shop_browser_check.py b/tools/public_shop_browser_check.py index 821573ddb..1b069b4bf 100644 --- a/tools/public_shop_browser_check.py +++ b/tools/public_shop_browser_check.py @@ -14,6 +14,7 @@ from pathlib import Path import subprocess import threading +import time import traceback from urllib.parse import parse_qs, urlsplit @@ -253,6 +254,11 @@ def check_reader_tools_flow(page, origin, expect, result, output): expect(page.locator("#unresolved-count")).to_have_text("15") expect(page.locator(".boundary")).to_contain_text("Dated read-only snapshot") expect(page.get_by_role("link",name="Provenance record",exact=True)).to_have_attribute("href","dependency-source/PROVENANCE.json") + page.locator("#dependency-search").fill("math") + expect(page.locator("#search-results > li")).to_have_count(39) + expect(page.locator("#search-results")).to_contain_text("math.side24-coefficient") + expect(page.locator("#search-results")).to_contain_text("math.uniform-matrix-cap-lifetime") + result["steps"].append("broad dependency search exposes all 39 matching nodes") page.locator("#dependency-search").fill("reviews/pr22_fixed_annulus_nonauthor_20260925/REVIEW.md") expect(page.locator("#search-results > li")).to_have_count(1) result_button=page.locator("#search-results button") @@ -292,6 +298,42 @@ def check_reader_tools_flow(page, origin, expect, result, output): result["steps"].append("Pinned 49/55/15 graph, review-source search, post-layout saved-link focus, invalid-ID refusal and narrow overflow checked") +def check_visitor_recovery(page, origin, expect, result): + if result["case"] == "query-refusal": + config=json.loads((ROOT/"docs/site/config.json").read_text()) + hits=[] + def refuse_query(route): + hits.append(route.request.url) + route.fulfill(status=503,headers={"Access-Control-Allow-Origin":"*"},body="") + page.route(config["query"]["url"],refuse_query) + page.goto(origin+"workspace.html#board") + expect(page.locator("#query-note")).to_contain_text("Source unavailable (503). No result inferred.",timeout=45000) + expect(page.locator("#custody-note")).to_contain_text("9 byte-copy imports landed",timeout=45000) + expect(page.locator("#query-identity")).to_be_empty() + require(len(hits)==1,"Expected exactly one refused query request") + result["steps"].append("query 503 ends loading without erasing verified import information") + else: + manifest=json.loads((ROOT/"docs/site/museum.json").read_text()) + held=[] + page.route(manifest["claims"][0]["proof"]["url"],lambda route:held.append(route)) + page.goto(origin+"museum.html#d3-side24-coefficient",wait_until="domcontentloaded") + expect(page.locator("#claim-cards")).to_contain_text("Verifying",timeout=45000) + deadline=time.monotonic()+45 + while not held and time.monotonic() new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))") + expect(focused).to_be_focused() + require(page.evaluate("Math.abs(document.querySelector('#d3-side24-coefficient').getBoundingClientRect().top)>100"),"Delayed claim completion pulled the reader back") + result["steps"].append("keyboard navigation during museum verification keeps focus and reading position") + + def main(): parser=argparse.ArgumentParser(description=__doc__) parser.add_argument("--output",type=Path,required=True) @@ -381,6 +423,25 @@ def main(): finally: result["page_errors"]=errors context.close() + for label in ["query-refusal","museum-reader-intent"]: + result={"case":label,"steps":[],"passed":False};report["cases"].append(result) + context=browser.new_context(viewport={"width":390,"height":844},color_scheme="light",reduced_motion="reduce") + page=context.new_page();page.set_default_timeout(15000);errors=[] + page.on("pageerror",lambda error:errors.append(str(error))) + try: + check_visitor_recovery(page,origin,expect,result) + require(not errors,f"Visitor recovery page errors: {errors}") + result["passed"]=True + except Exception: + result["error"]=traceback.format_exc() + finally: + result["page_errors"]=errors;shot=output/f"{label}.png" + try: + page.screenshot(path=str(shot)) + result["screenshot"]={"path":shot.name,"sha256":sha256(shot.read_bytes()).hexdigest()} + except Exception: + result["screenshot_error"]=traceback.format_exc();result["passed"]=False + context.close() result={"case":"inventory-refusal","steps":[],"passed":False};report["cases"].append(result) context=browser.new_context(viewport={"width":390,"height":844},color_scheme="dark") page=context.new_page();refusal_errors=[];route_hits=[] @@ -415,7 +476,7 @@ def refuse_inventory(route): context.close() finally: browser.close() - report["passed"]=len(report["cases"])==13 and all(case["passed"] for case in report["cases"]) + report["passed"]=len(report["cases"])==15 and all(case["passed"] for case in report["cases"]) except Exception: report["passed"]=False;report["error"]=traceback.format_exc() finally: