diff --git a/.github/workflows/public-shop.yml b/.github/workflows/public-shop.yml index da33c895c..17852207b 100644 --- a/.github/workflows/public-shop.yml +++ b/.github/workflows/public-shop.yml @@ -29,3 +29,33 @@ jobs: node --test tests/test_museum_geometry.mjs - name: Pinned public source readback and interaction harness run: python3 -B tools/public_shop_check.py + browser-smoke: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - name: Record setup identity + run: | + mkdir -p browser-evidence + git rev-parse HEAD > browser-evidence/commit.txt + echo 'Setup record only; report.json establishes whether a browser ran.' > browser-evidence/setup.txt + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 + with: + python-version: '3.12' + - name: Install pinned optional browser tooling + run: | + python -m pip install -r tests/browser-requirements.txt + - name: Check Library in headless Chromium + env: + BROWSER_PR_HEAD: ${{ github.event.pull_request.head.sha }} + run: python -B tools/public_shop_browser_check.py --output browser-evidence + - name: Preserve browser results including failures + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a + with: + name: public-shop-browser-${{ github.run_id }} + path: browser-evidence + if-no-files-found: error + retention-days: 30 diff --git a/docs/site/README.md b/docs/site/README.md index 7618c5da0..46a4ff4c4 100644 --- a/docs/site/README.md +++ b/docs/site/README.md @@ -23,6 +23,45 @@ python3 -B -S -m unittest discover -s tests -p test_reader_links.py -v Check real desktop/mobile layouts, keyboard operation, light/dark appearance and source-unavailable behavior separately. The pure-model tests are not browser or scientific verification. +## Keep or share a Library search + +The Library's search, repository and path filters are saved in the current URL +without adding a browser-history entry for every keystroke. Refreshing or +returning with Back/Forward restores the filters. **Link to this search** gives a +bookmarkable link directly to the catalog; **Clear filters** restores its initial +50-row view. Filtering never changes source identities or recorded review scope. + +Search links use `q`, `repository` (`main` or `Math-`) and `path`. Empty values are +omitted; the first repeated value is used, and an unknown repository is treated +as all repositories. Unrelated parameters and section bookmarks are preserved in +the current address but omitted from the explicit search link. Filters are visible +in URLs and browser history. Links use the catalog’s pinned source records, not a +live proof index; the search URL does not freeze future catalog updates. If history updates are unavailable, filtering and the explicit +link still work; if source verification fails, controls stay unavailable. + +## Browser evidence in CI + +The existing `public-shop` workflow also runs a separate read-only `browser-smoke` +job. Its optional [pinned Playwright dependencies](../../tests/browser-requirements.txt) +use the [official Python package](https://pypi.org/project/playwright/1.62.0/) +with the Ubuntu 24.04 runner’s packaged stable Chrome and its enabled sandbox. +The browser version/executable hash and runner-image identity are recorded; the +browser is runner-bound rather than a fixed Playwright download. The runner serves +only `docs` on an ephemeral +loopback port. It does not publish a preview or use account credentials. + +The `public-shop-browser-` artifact contains a JSON report and screenshots +for 1200×900 and 390×844 in light and dark mode, plus an explicitly refused +inventory request. It tests URL round-trips, actual Back/Forward navigation, +keyboard reset/focus and document overflow against the real app and pinned public +sources. The report binds the actual tested checkout separately from the PR head. +A setup artifact without a successful report is not a completed browser run. + +Inspect the screenshots before accepting visual quality. This is headless Chromium +with mobile-sized viewports, not physical touch-device, all-browser, full +accessibility or deployed-Pages certification. The original source validation and +required hosted checks remain separate and unchanged. + ## Run locally From the repository root: diff --git a/docs/site/app.js b/docs/site/app.js index 55872500d..82fbc1a68 100644 --- a/docs/site/app.js +++ b/docs/site/app.js @@ -1,4 +1,5 @@ import {verifiedJSON, verifiedBytes, validateStatus, validateCoefficient, safeSourceURL, hex40, hex64} from './core.mjs'; +import {connectCatalogQuery} from './catalog-query.mjs'; import {prepareWorkspaceFragment} from './workspace-fragment.mjs'; const finishFragment=prepareWorkspaceFragment(); const el=id=>document.getElementById(id); @@ -85,9 +86,12 @@ async function inventory(config) { const render=()=>{const query=el('search').value.trim().toLowerCase(),repository=el('repository-filter').value,path=el('path-filter').value.trim().toLowerCase(); const matches=rows.filter(row=>(!repository||row.repository===repository)&&row.path.toLowerCase().includes(path)&&[row.repository,row.path,row.commit,row.sha256].some(s=>s.toLowerCase().includes(query)));el('catalog').replaceChildren(); matches.slice(0,limit).forEach(row=>{const tr=node('tr'),name=node('td'),commit=node('td'),hash=node('td');name.append(node('small',row.repository),link(row.path,safeSourceURL(row)));commit.append(node('code',row.commit));hash.append(node('code',row.sha256));tr.append(name,commit,hash);el('catalog').append(tr);}); - el('inventory-state').textContent=`${matches.length.toLocaleString()} matches · ${Math.min(limit,matches.length)} shown · all 2,138 source records loaded from the original hash-verified shards.`;el('more').hidden=matches.length<=limit;}; + el('inventory-state').textContent=`${matches.length.toLocaleString()} matches · ${Math.min(limit,matches.length)} shown · all 2,138 source records loaded from the original hash-verified shards.`;if(!matches.length)el('inventory-state').append(' Try a broader search or clear filters.');el('more').hidden=matches.length<=limit;}; + const syncQuery=connectCatalogQuery(typeof window==='undefined'?null:window,{search:el('search'),repository:el('repository-filter'),path:el('path-filter'),link:el('catalog-link'),note:el('catalog-query-note')},()=>{limit=50;render();}); + el('catalog-clear').disabled=false; + el('catalog-clear').addEventListener('click',()=>{for(const id of ['search','repository-filter','path-filter'])el(id).value='';limit=50;render();syncQuery();el('search').focus();}); for(const [id,event] of [['search','input'],['repository-filter','change'],['path-filter','input']]) { - el(id).disabled=false;el(id).addEventListener(event,()=>{limit=50;render();}); + el(id).disabled=false;el(id).addEventListener(event,()=>{limit=50;render();syncQuery();}); } el('more').addEventListener('click',()=>{limit+=50;render();});render(); } diff --git a/docs/site/catalog-query.mjs b/docs/site/catalog-query.mjs new file mode 100644 index 000000000..5f26b3950 --- /dev/null +++ b/docs/site/catalog-query.mjs @@ -0,0 +1,41 @@ +// URL state is a reader convenience, never a source or scientific-status input. +// URLSearchParams.get deliberately uses the first occurrence of each filter. +export function readCatalogQuery(search) { + const params=new URLSearchParams(search); + const repository=params.get('repository'); + return {query:(params.get('q')||'').trim(),repository:['main','Math-'].includes(repository)?repository:'',path:(params.get('path')||'').trim()}; +} +export function catalogQueryURL(href,filters,share=false) { + const url=new URL(href); + if(share){url.search='';url.hash='inventory';} + for(const [key,value] of [['q',filters.query],['repository',filters.repository],['path',filters.path]]) { + if(value.trim())url.searchParams.set(key,value.trim());else url.searchParams.delete(key); + } + return url; +} +export function connectCatalogQuery(win,controls,onRestore) { + const current=()=>{try{return new URL(win.location.href);}catch{return null;}}; + const values=()=>({query:controls.search.value,repository:controls.repository.value,path:controls.path.value}); + const note='Filters appear in the address, shared links, and browser history. Search links use the catalog’s pinned source records, not a live research index.'; + const link=()=>{ + const url=current();if(!url)return; + controls.link.href=catalogQueryURL(url,values(),true).href; + controls.link.setAttribute('aria-disabled','false'); + controls.note.textContent=note; + }; + const restore=()=>{ + const url=current();if(!url)return; + const filters=readCatalogQuery(url.search); + controls.search.value=filters.query;controls.repository.value=filters.repository;controls.path.value=filters.path; + link(); + }; + // Read at verified-catalog readiness so newer navigation wins over startup. + restore(); + if(current())win.addEventListener('popstate',()=>{restore();onRestore();}); + return ()=>{ + link();const url=current();if(!url)return; + const next=catalogQueryURL(url,values());if(next.href===url.href)return; + try {win.history.replaceState(win.history.state,'',next.href);} + catch {controls.note.textContent='The address could not be updated. Use Link to this search to preserve these filters. Shared links include the filters and use the catalog’s pinned source records.';} + }; +} diff --git a/docs/site/style.css b/docs/site/style.css index 519e64045..4bc115007 100644 --- a/docs/site/style.css +++ b/docs/site/style.css @@ -14,3 +14,6 @@ nav,.actions{flex-wrap:wrap} .cards article.amend{border-top:3px dashed #b48235} .status-object[data-class="AMEND/open"]{border-left:3px dashed #b48235;padding-left:18px} .status-object[data-class="AMEND/open"]>.source-header{border-style:dashed} + +/* The author button display must not override the catalog visibility state. */ +#more[hidden]{display:none} diff --git a/docs/site/workspace.html b/docs/site/workspace.html index f5a3b3eae..b0c17c68e 100644 --- a/docs/site/workspace.html +++ b/docs/site/workspace.html @@ -26,7 +26,7 @@

03 / THE EXISTING CATALOG

Find the full argument.

Reading guide ↗

The existing 2,138-file inventory includes proofs, partial arguments, reviews, and historical reading copies. It counts files, not accepted theorems. New imports and proposals have separate public links.

-

Verifying the original inventory and its shards…

Repository / full textCommitSHA-256
+
Link to this search

Search links become available after catalog verification.

Verifying the original inventory and its shards…

Repository / full textCommitSHA-256

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 ↗
diff --git a/tests/browser-requirements.txt b/tests/browser-requirements.txt new file mode 100644 index 000000000..0e41e4513 --- /dev/null +++ b/tests/browser-requirements.txt @@ -0,0 +1,6 @@ +# Optional CI browser tests only; no runtime dependency for the static site. +# The runner’s packaged stable Chrome retains its existing supported sandbox. +playwright==1.62.0 +pyee==13.0.1 +greenlet==3.5.5 +typing_extensions==4.16.0 diff --git a/tests/test_catalog_query.mjs b/tests/test_catalog_query.mjs new file mode 100644 index 000000000..728510e6c --- /dev/null +++ b/tests/test_catalog_query.mjs @@ -0,0 +1,119 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; + +// Run the actual app against original hash-verified catalog bytes. These browser +// and fetch boundary doubles do not attest to layout or full accessibility. +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))); +let run=0; +class Element extends EventTarget { + constructor(tag,attributes){super();this.tag=tag;this.children=[];this.value='';this._text='';this.disabled=attributes.includes(' disabled');this.hidden=attributes.includes(' hidden');} + set textContent(value){this._text=String(value);this.children=[];} + get textContent(){return this._text+this.children.map(child=>typeof child==='string'?child:child.textContent).join('');} + append(...children){this.children.push(...children);} + replaceChildren(...children){this._text='';this.children=children;} + setAttribute(name,value){this[name]=String(value);} + removeAttribute(name){delete this[name];} +} +async function page(t,{query='',hash='#inventory',historyFailure=false,inventoryFailure=false,delay=false}={}){ + const nodes=new Map(); + for(const match of html.matchAll(/<([a-z][a-z0-9-]*)\b([^>]*\bid="([^"]+)"[^>]*)>/gi))nodes.set(match[3],new Element(match[1],match[2])); + const window=new EventTarget(),writes=[],focus=[]; + window.location=new URL('https://example.test/site/workspace.html'+query+hash); + window.history={state:{reader:'keep'},replaceState(state,title,url){if(historyFailure)throw new Error('History refused');writes.push({state,url});window.location=new URL(url,window.location);}}; + window.requestAnimationFrame=fn=>{fn();return 1;}; + const document={getElementById:id=>nodes.get(id)||null,createElement:tag=>new Element(tag,''),createElementNS:(_,tag)=>new Element(tag,''),createTextNode:text=>({textContent:text})}; + for(const [id,node] of nodes){node.scrollIntoView=()=>{};node.focus=()=>focus.push(id);} + nodes.get('dimension').value='2'; + const mapping=new Map([ + ['status.json','docs/site/status.json'],[config.status.url,'tests/fixtures/status_f2e432e.md'], + [config.inventory.url,'docs/public-math/sources.json'],...config.inventory.pages.map(pin=>[pin.url,pin.path]) + ]); + let release;const pending=new Promise(r=>release=r); + const saved=new Map(['window','document','fetch'].map(name=>[name,Object.getOwnPropertyDescriptor(globalThis,name)])); + t.after(()=>{for(const [name,value] of saved)if(value)Object.defineProperty(globalThis,name,value);else delete globalThis[name];}); + globalThis.window=window;globalThis.document=document; + globalThis.fetch=async url=>{ + if(url==='config.json')return new Response(JSON.stringify(config)); + if(url===config.coefficient.url||url===config.imports.url)return new Response('',{status:503}); + if(url===config.inventory.url){if(delay)await pending;if(inventoryFailure)return new Response('',{status:503});} + assert.ok(mapping.has(url),`Unexpected fetch ${url}`);return new Response(fs.readFileSync(new URL(mapping.get(url),root))); + }; + const loading=import(`../docs/site/app.js?catalog-query-test=${++run}`); + if(!delay)await loading; + const change=(id,value,event='input')=>{nodes.get(id).value=value;nodes.get(id).dispatchEvent(new Event(event));}; + return {window,writes,focus,nodes,loading,release,change}; +} +const text=(p,id)=>p.nodes.get(id).textContent; +const count=p=>p.nodes.get('catalog').children.length; + +test('a bookmarked combined search restores the one exact proof and source link',async t=>{ + const p=await page(t,{query:'?q=PROOF.md&repository=Math-&path=coefficients%2Fside24_v1%2F'}); + assert.equal(p.nodes.get('search').value,'PROOF.md');assert.equal(count(p),1); + assert.match(p.nodes.get('catalog').children[0].textContent,/coefficients\/side24_v1\/PROOF.md/); + assert.match(p.nodes.get('catalog').children[0].children[0].children[1].href,/\/blob\/[0-9a-f]{40}\//); + assert.equal(p.writes.length,0); +}); +test('typing preserves unrelated parameters, fragment and history state; share link only includes filters',async t=>{ + const p=await page(t,{query:'?from=research',hash:'#coefficient'}); + p.change('search','SIDE24');assert.match(text(p,'inventory-state'),/^96 matches/); + assert.equal(p.window.location.search,'?from=research&q=SIDE24');assert.equal(p.window.location.hash,'#coefficient'); + assert.deepEqual(p.writes[0].state,{reader:'keep'}); + const link=new URL(p.nodes.get('catalog-link').href); + assert.equal(link.search,'?q=SIDE24');assert.equal(link.hash,'#inventory'); +}); +test('popstate restores filters and pagination without rewriting history or stealing focus',async t=>{ + const p=await page(t);p.nodes.get('more').dispatchEvent(new Event('click'));assert.equal(count(p),100); + const focusBefore=p.focus.length; + p.window.location=new URL('https://example.test/site/workspace.html?q=SIDE24&repository=Math-#board'); + p.window.dispatchEvent(new Event('popstate')); + assert.equal(p.nodes.get('search').value,'SIDE24');assert.equal(p.nodes.get('repository-filter').value,'Math-');assert.equal(count(p),1); + assert.equal(p.writes.length,0);assert.equal(p.focus.length,focusBefore);assert.equal(p.window.location.hash,'#board'); +}); +test('clear filters recovers from no matches and resets pagination with search focus',async t=>{ + const p=await page(t,{query:'?q=NO-MATCH&repository=main&path=missing&keep=1'}); + assert.equal(count(p),0);assert.match(text(p,'inventory-state'),/clear filters/i); + p.nodes.get('catalog-clear').dispatchEvent(new Event('click')); + assert.equal(count(p),50);assert.equal(p.nodes.get('search').value,'');assert.equal(p.nodes.get('repository-filter').value,'');assert.equal(p.nodes.get('path-filter').value,''); + assert.equal(p.window.location.search,'?keep=1');assert.equal(p.focus.at(-1),'search'); + p.nodes.get('more').dispatchEvent(new Event('click'));assert.equal(count(p),100); + p.nodes.get('catalog-clear').dispatchEvent(new Event('click'));assert.equal(count(p),50); +}); +test('unknown repository and duplicate parameters use documented first-value rules',async t=>{ + const p=await page(t,{query:'?q=SIDE24&q=absent&repository=unknown&repository=Math-&path='}); + assert.equal(p.nodes.get('search').value,'SIDE24');assert.equal(p.nodes.get('repository-filter').value,'');assert.equal(count(p),50); + assert.match(text(p,'inventory-state'),/^96 matches/);assert.equal(p.writes.length,0); +}); +test('encoded punctuation stays inert search text',async t=>{ + const p=await page(t,{query:'?q=%3Cscript%3E%26%23%2B%25E0%25A4%25A&path=a%2Fb'}); + assert.equal(p.nodes.get('search').value,'