diff --git a/.github/workflows/museum-conditionals.yml b/.github/workflows/museum-conditionals.yml new file mode 100644 index 000000000..2b56d7ebe --- /dev/null +++ b/.github/workflows/museum-conditionals.yml @@ -0,0 +1,29 @@ +name: Museum conditional source route +on: + pull_request: + paths: + - 'docs/site/**' + - 'tools/museum_conditionals.mjs' + - 'tests/test_museum*.mjs' + - 'tests/fixtures/cumulative_transfer_source.txt' + - '.github/workflows/museum-conditionals.yml' + workflow_dispatch: +permissions: + contents: read +jobs: + conditional-projection: + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - name: Record runner Node version + run: node --version + - name: Museum frontend and conditional-route controls + run: node --test tests/test_museum*.mjs tests/test_public_shop_frontend.mjs + - name: Replay the actual committed museum source selection + run: | + node tools/museum_conditionals.mjs --source tests/fixtures/cumulative_transfer_source.txt > /tmp/conditional-route.json + node tools/museum_conditionals.mjs --source tests/fixtures/cumulative_transfer_source.txt --check /tmp/conditional-route.json > /tmp/conditional-route-replay.json + cmp /tmp/conditional-route.json /tmp/conditional-route-replay.json diff --git a/docs/site/CONDITIONAL_ROUTES.md b/docs/site/CONDITIONAL_ROUTES.md new file mode 100644 index 000000000..66ce5dd9a --- /dev/null +++ b/docs/site/CONDITIONAL_ROUTES.md @@ -0,0 +1,126 @@ +# Conditional proof routes — cumulative-transfer pilot + +Engineering projection only. Scientific effect: NONE. +This page describes one added view, not a new claim database, theorem verdict, +or general-purpose theorem prover. The original museum cards, source inventory, +STATUS snapshot, config and manifest retain their existing identities and meaning. + +## The first route + +`conditionals.mjs` reads the already-indexed cumulative-transfer correction from +`museum.json`. Its exact source is +`reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md` in Math-, +Git blob `044ac5fdaf403a38e33983e31f0ad69f8e76d6d5`, 3272 bytes, +SHA256 `83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6`. +The audited commit is `d6628da09384728992dcbe6e921cc28ba85aebb0`. +Both interfaces require that exact commit and matching immutable URLs. +A different 40-character string is not evidence that these bytes belong to it. +The exported projection retains the complete source descriptor as well as its digest. +The checked source fixture under `tests/fixtures/` is an exact reading copy of +those public bytes, not a new proof body or an authoritative source. + +The view retains six inputs: the setup/quantifiers, four numbered hypotheses, +and the definition of N. One ALL edge joins those inputs to the conditional +limit. The positive-coefficient and zero-coefficient conclusions remain separate. +The warning that a cumulative asymptotic does not imply a density asymptotic +is retained. The ratio h/(kappa*r^m) -> 1 and one fixed lower comparison constant +are not replaced by pointwise comparisons or a fitted exponent. + +Application evaluation is always NOT_EVALUATED in this pilot. Hypotheses are +not declared satisfied merely because their implication has a reviewed source. +The existing source/review card remains the source of quoted review information. +No independence credit, lemma closure or promotion is computed here. + +## One projection, two interfaces + +The browser reuses the museum module's single verified startup +(`verifiedMuseum`): config-to-manifest digest, central source projection and the +per-page byte cache are fetched and verified once per page fetch and shared by +`museum.mjs` and `conditionals.mjs`, so the route repeats no central request and +reads the cumulative proof bytes from the same cache the claim card verified. +It then checks the audited proof descriptor and its complete byte and Git-blob +identities before parsing any hypotheses. A rejected startup is not retained; a +later caller re-verifies instead of inheriting a stale refusal. A failed load +clears the conditional view and reports unavailable. Source text is rendered +with textContent, not HTML. +The new HTML section is an accessible text dependency view, not a new 3D exhibit. + +The read-only CLI uses the same projection function. It checks the existing +config-to-manifest digest, selects the one source descriptor, and verifies a +local source file against it. The CLI makes no network request, does not execute +the source, and does not replay the central index or review semantics. The +browser retains those extra existing checks. A projection supplied via --check +must equal the complete regenerated statement: missing premises, ALL-to-ANY +changes, extra nodes, cycles or status fields are refused rather than adopted. + +Run from the main repository root: + +```sh +node --test tests/test_museum_conditionals.mjs tests/test_museum_conditionals_startup.mjs tests/test_museum_conditionals_cli.mjs tests/test_museum_identity.mjs +node tools/museum_conditionals.mjs --source tests/fixtures/cumulative_transfer_source.txt > /tmp/conditional-route.json +node tools/museum_conditionals.mjs --source tests/fixtures/cumulative_transfer_source.txt --check /tmp/conditional-route.json +``` + +`--root CHECKOUT` selects a different local checkout for config/manifest reads. +The emitted JSON is a disposable projection, not a committed second inventory. +The source must remain byte-identical to the named proof. A new mathematical +statement requires an explicitly reviewed update to this bounded projection. +The CLI tests use temporary metadata fixtures around the real proof bytes; +the hosted workflow also exercises the actual committed config and manifest. + +## Scope and deployment + +This adds a pilot to museum.html, not an exhaustive graph of P0.1, D1, D5, +SARD-G or all research obligations. No OR route is invented. Future alternative +proof routes need their own exact statements and source-bound interfaces; +induction must state its base case and a well-founded decreasing parameter. +A larger graph cannot turn circular support into proof. + +The separate Math- scalar and one-endpoint Hessian certificates in PR89 are +author derivations awaiting review. They are deliberately not added to the +museum's accepted result cards. Neither supplies the additional-witness +covariance or determinant-weighted Palm estimate. query- remains a read-only +identity lookup. + +Local verification covers the new module, CLI, source integrity, HTML wiring, +a lightweight DOM refusal harness, and a mocked successful browser startup +(`tests/test_museum_conditionals_startup.mjs`): shared config/manifest reuse +with `startMuseum`, claim selection, proof loading, host replacement, and the +fail-closed paths for altered proof bytes, a non-audited descriptor and a stale +manifest. It is not a real-browser, layout, GPU or live +network test, nor a replay of every unrelated repository test. The hosted workflow +records its own results. A draft PR is not a deployed change to the public site. + +## Reconnaissance and next mathematical interface + +Lean blueprints are an inspected precedent for making dependencies visible: +https://github.com/PatrickMassot/leanblueprint. This implementation installs no +Lean toolchain and creates no kernel-checked proof. The analogy concerns +presentation and source navigation only, not formalization or acceptance. +The full local source/proof identities and limits are the controlling context +for this pilot; literature analogies do not discharge its hypotheses. + +For a future D5 multiscale proof, a useful conditional interface is explicit: +if a complete weighted counting partition yields E[N]=sum_j J_j(r)/Z_r, +Z_r>=c_Z*r^2, and J_j(r)<=A*r^5*2^(-gamma*j) uniformly with gamma>0, +then E[N]<=A*r^3/[c_Z*(1-2^(-gamma))]. This is geometric-series arithmetic, +not evidence that these bounds or the partition hold for D5. Every collar, +axis, remainder and law-identification interface must be supplied. A first +moment does not by itself establish the separate elder-event inclusion. +No cumulant hierarchy or new PDE/gravitational interpretation is installed. + +## Identity follow-through + +The initial offline implementation checked commit syntax, digest and URL +consistency, but could accept correct bytes attributed to a different, +syntactically valid commit if the fixture manifest and URLs were changed +coherently. Three test-first controls exposed that gap (24 old tests passed, +3 new tests failed). The source selector now requires the audited commit; the +exported route also carries the complete repository/path/commit/blob/bytes/hash +and URL descriptor. Changing source revision requires a reviewed projection +update, not relabeling a local proof. This is an author correction, not a +nonauthor review or a change to mathematical status. + +A Chromium smoke-test attempt in this continuation was blocked at localhost +navigation with ERR_BLOCKED_BY_ADMINISTRATOR, before any module assertion. +No browser protection was changed; this is a recorded verification gap, not a pass. diff --git a/docs/site/conditionals.mjs b/docs/site/conditionals.mjs new file mode 100644 index 000000000..0c52dcbdc --- /dev/null +++ b/docs/site/conditionals.mjs @@ -0,0 +1,114 @@ +// One dependency transcription of an already-indexed proof. No status engine. +const CLAIM_ID='cumulative-transfer-correction'; +const SOURCE_COMMIT='d6628da09384728992dcbe6e921cc28ba85aebb0'; +const SOURCE_PATH='reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md'; +const SOURCE_SHA256='83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6'; +const SOURCE_BLOB='044ac5fdaf403a38e33983e31f0ad69f8e76d6d5'; +const encoder=new TextEncoder(),decoder=new TextDecoder('utf-8',{fatal:true}); +const hex40=v=>typeof v==='string'&&/^[0-9a-f]{40}$/.test(v); + +function validateSource(source){ + if(!source||source.repository!=='d6g8k5htny-coder/Math-'||!hex40(source.commit)||source.commit!==SOURCE_COMMIT + ||source.path!==SOURCE_PATH||source.sha256!==SOURCE_SHA256||source.blob!==SOURCE_BLOB + ||source.bytes!==3272)throw Error('Conditional source identity mismatch'); + const suffix=`${source.repository}/${source.commit}/${SOURCE_PATH}`; + if(source.url!==`https://raw.githubusercontent.com/${suffix}` + ||source.html_url!==`https://github.com/${source.repository}/blob/${source.commit}/${SOURCE_PATH}`) + throw Error('Conditional source URL identity mismatch'); + return source; +} +async function digest(algorithm,raw,crypto){ + if(!crypto?.subtle)throw Error('Source identity hashing unavailable'); + return [...new Uint8Array(await crypto.subtle.digest(algorithm,raw))].map(v=>v.toString(16).padStart(2,'0')).join(''); +} +function between(text,start,end){ + if(text.split(start).length!==2)throw Error('Conditional source boundary changed'); + const tail=text.split(start)[1]; + if(tail.split(end).length!==2)throw Error('Conditional source boundary changed'); + return tail.split(end)[0]; +} +function projectText(text){ + const theorem=between(text,'## Corrected cumulative theorem\n\n','\n## Proof\n').trim(); + const nodes=[{id:'setup',role:'hypothesis',quote:theorem.split('\n1. ')[0].trim()}]; + for(let i=1;i<=4;i++){ + const start=`${i}. `,end=i<4?`\n${i+1}. `:'\n\nNeither a derivative'; + nodes.push({id:`H${i}`,role:'hypothesis',quote:(start+between(theorem,start,end)).trim()}); + } + nodes.push({id:'definition',role:'definition',quote:(' N(ell)='+between(theorem,' N(ell)=','\n\nThen')).trim()}); + nodes.push({id:'conclusion',role:'conditional-conclusion',quote:(' lim_(ell->0)'+between(theorem,' lim_(ell->0)','\n\nIf the displayed')).trim()}); + return { + schema_version:1,projection_kind:'conditional-proof-route',claim_id:CLAIM_ID, + scientific_status_authority:false,scientific_effect:'NONE',application_evaluation:'NOT_EVALUATED', + source_sha256:SOURCE_SHA256,nodes, + routes:[{id:'cumulative-limit',logic:'ALL',requires:['setup','H1','H2','H3','H4','definition'],concludes:'conclusion'}], + case_split:'If the displayed'+theorem.split('If the displayed')[1], + boundary:text.slice(text.lastIndexOf('This corrects an underspecified theorem statement;')).trim(), + }; +} +export async function projectVerified(raw,source,crypto=globalThis.crypto){ + validateSource(source); + if(!(raw instanceof Uint8Array)||raw.byteLength!==source.bytes + ||await digest('SHA-256',raw,crypto)!==source.sha256)throw Error('Conditional source byte identity mismatch'); + const header=encoder.encode(`blob ${raw.byteLength}\0`),blob=new Uint8Array(header.length+raw.length); + blob.set(header);blob.set(raw,header.length); + if(await digest('SHA-1',blob,crypto)!==source.blob)throw Error('Conditional Git blob identity mismatch'); + const identity=Object.fromEntries(['repository','path','commit','blob','bytes','sha256','url','html_url'].map(key=>[key,source[key]])); + return {...projectText(decoder.decode(raw)),source:identity}; +} +function stable(value){ + if(value===null||typeof value==='string'||typeof value==='boolean')return JSON.stringify(value); + if(typeof value==='number'&&Number.isSafeInteger(value))return String(value); + if(Array.isArray(value))return '['+value.map(stable).join(',')+']'; + if(value&&Object.getPrototypeOf(value)===Object.prototype) + return '{'+Object.keys(value).sort().map(k=>JSON.stringify(k)+':'+stable(value[k])).join(',')+'}'; + throw Error('Unsupported projection value'); +} +export async function verifyProjection(data,raw,source,crypto=globalThis.crypto){ + const expected=await projectVerified(raw,source,crypto); + if(stable(data)!==stable(expected))throw Error('Conditional projection differs from the complete pinned statement'); + return expected; +} +function el(document,tag,text){const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n;} +export function renderProjection(document,host,data,source){ + const article=el(document,'article');article.className='museum-card engineering-only'; + article.setAttribute('data-object-class','engineering-only'); + article.append(el(document,'h3','Conditional route: cumulative transfer'), + el(document,'p','ALL six inputs are required. These are hypotheses and definitions, not newly discharged obligations.'), + el(document,'p','Application evaluation: NOT_EVALUATED. A proved implication is not proof that its hypotheses hold for a particular field.')); + const identity=el(document,'dl');identity.className='source-identity'; + for(const key of ['repository','path','commit','sha256'])identity.append(el(document,'dt',key),el(document,'dd',source[key])); + article.append(identity); + const list=el(document,'ol'); + for(const node of data.nodes.filter(n=>n.id!=='conclusion')){ + const item=el(document,'li'),details=el(document,'details'); + details.append(el(document,'summary',`${node.id} — ${node.role}`),el(document,'blockquote',node.quote)); + item.append(details);list.append(item); + } + article.append(list,el(document,'p','setup + H1 + H2 + H3 + H4 + definition → conclusion (ALL)'), + el(document,'pre',data.nodes.find(n=>n.id==='conclusion').quote), + el(document,'p',data.case_split),el(document,'p',data.boundary)); + const sourceLink=el(document,'a','Open the exact source');sourceLink.href=source.html_url; + const reviewLink=el(document,'a','Read the existing source/review card');reviewLink.href='#'+CLAIM_ID; + article.append(sourceLink,el(document,'p'),reviewLink, + el(document,'p','Generated from verified source bytes. This graph is not formal verification, a proof review, or a scientific-status register.')); + host.replaceChildren(article); +} +const services=()=>import('./museum.mjs'); +// The museum module already verifies config → manifest → index/status once per +// page fetch and caches every pinned byte request. This route consumes that same +// verified startup, so it adds only the audited-descriptor check and projection. +export async function startConditionals({document=globalThis.document,fetcher=globalThis.fetch,loadServices=services}={}){ + const host=document?.getElementById('conditional-route');if(!host)return false; + host.replaceChildren(el(document,'p','Verifying the conditional route source…')); + try{ + const s=await loadServices(); + const {manifest,cachedFetch}=await s.verifiedMuseum({fetcher}); + const selected=manifest.claims.filter(c=>c.id===CLAIM_ID); + if(selected.length!==1)throw Error('Conditional source claim is missing or duplicated'); + const claim=selected[0];validateSource(claim.proof); + const {proofText}=await s.verifyClaim(claim,cachedFetch); + const data=await projectVerified(encoder.encode(proofText),claim.proof); + renderProjection(document,host,data,claim.proof);return true; + }catch(error){host.replaceChildren(el(document,'p',`Unavailable: ${error.message}. No conditional result inferred.`));return false;} +} +if(typeof document!=='undefined')void startConditionals(); diff --git a/docs/site/museum.html b/docs/site/museum.html index 9398563ab..59385f821 100644 --- a/docs/site/museum.html +++ b/docs/site/museum.html @@ -4,12 +4,12 @@ Verification museum · Universal Law - + -
UNIVERSAL LAW VERIFICATION MUSEUM
+
UNIVERSAL LAW VERIFICATION MUSEUM

OPEN THE SOURCE · READ THE SCOPE · REPLAY THE EVIDENCE

Verification museum

This site is for verifying Universal Law mathematics. Pictures explain pinned sources. Submissions come back as packets. Scientific status follows the pinned source and its recorded review scope. Publication does not change it.

A scoped result and an open parent can coexist. A hash verifies bytes. It does not verify a theorem.

Verifying the pinned source index and status snapshot…

01 / PICTURES WITH SOURCES

Inspect one object.

SIDE24 exact endpoints ↗
@@ -22,6 +22,10 @@
Solid · ACCEPT-scopedDashed · AMEND/openDouble · engineering-onlyDotted · illustration
+

CONDITIONAL PROOF ROUTE / FIRST PILOT

Hypotheses, implication, application.

Scope and replay instructions ↗
+

The cumulative-transfer pilot shows the complete assumptions of one already-indexed proof. An ALL connection requires every listed input. This is a source transcription, not a new status register or an evaluation of its application to a random field.

+

Verifying the conditional route source…

+

03 / REPLAY BOUNDARY

D2 lifetime fixture

Verifying the pinned D2 source contract…

04 / PACKETS RETURN TO REVIEW

Packet — not STATUS

These are pinned landed submissions. A packet's presence, output or passing check does not promote a claim. Review remains a separate process.

Prepare a source-bound incoming packet ↗

diff --git a/docs/site/museum.mjs b/docs/site/museum.mjs index 7a380f5cf..b2d404d73 100644 --- a/docs/site/museum.mjs +++ b/docs/site/museum.mjs @@ -179,22 +179,36 @@ async function renderPacket(document,packet,fetcher){ body.append(element(document,'p','packet — not STATUS'),element(document,'p',`Packet ID: ${packet.id}`),packet.issue===null?element(document,'p','Task issue: not stated in the packet'):anchor(document,`Task issue: #${packet.issue}`,`https://github.com/d6g8k5htny-coder/main/issues/${packet.issue}`),element(document,'p','scientific_effect: NONE · review_status: REVIEW_REQUIRED'),anchor(document,'Open pinned RESULT.md ↗',packet.result.html_url)); article.append(body,strip(document,'Landed packet bytes are visible for review. The result is not an accepted claim and is not inserted into STATUS.'));return article; } +async function verifyStartup(fetcher){ + const freshLocal=(url,options)=>fetcher(url,{...options,cache:'no-store'}); + const configResponse=await boundedFetch('config.json',freshLocal,32*1024);if(!configResponse.ok)throw Error(`Museum config unavailable (${configResponse.status})`); + const config=JSON.parse(decoder.decode(configResponse.bytes)); + const pin=config.museum_json; + if(pin?.url!=='museum.json'||!hex64.test(pin.sha256)||!Number.isSafeInteger(pin.bytes)||pin.bytes<1||pin.bytes>256*1024)throw Error('Invalid museum manifest descriptor'); + const localFetch=async url=>{const response=await boundedFetch(url,freshLocal,pin.bytes);return {ok:response.ok,status:response.status,arrayBuffer:async()=>response.bytes.buffer};}; + const raw=await verifiedBytes(pin,localFetch); + const manifest=JSON.parse(decoder.decode(raw));validateDescriptor(manifest.index_source);validateDescriptor(manifest.status_source); + const cache=new Map(); + const cachedFetch=url=>{const key=String(url);if(!cache.has(key))cache.set(key,boundedFetch(url,fetcher));return cache.get(key).then(result=>({ok:result.ok,status:result.status,arrayBuffer:async()=>result.bytes.buffer}));}; + const [index,status]=await Promise.all([verifiedBytes(manifest.index_source,cachedFetch),verifiedBytes(manifest.status_source,cachedFetch)]); + validateBoundManifest(manifest,decoder.decode(index),decoder.decode(status)); + return {manifest,cachedFetch}; +} +// One verified config→manifest→index/status startup per fetcher. Every page module +// that shares the browser fetch reuses the same verified manifest and byte cache +// instead of repeating the central fetches. Failures are not retained, so a later +// caller re-verifies rather than inheriting a stale refusal. +const startups=new WeakMap(); +export function verifiedMuseum({fetcher=globalThis.fetch}={}){ + if(typeof fetcher!=='function')throw Error('Museum fetch is unavailable'); + if(!startups.has(fetcher))startups.set(fetcher,verifyStartup(fetcher).catch(error=>{startups.delete(fetcher);throw error;})); + return startups.get(fetcher); +} export async function startMuseum({document=globalThis.document,fetcher=globalThis.fetch,search=globalThis.location?.search||'',geometryLoader=()=>import('./geometry.mjs')}={}){ const ids=['museum-state','claim-cards','lifetime-fixture','packet-cards','active-exhibit']; const containers=Object.fromEntries(ids.map(id=>{const node=document.getElementById(id);if(!node)throw Error(`Missing museum container: ${id}`);return [id,node];})); try{ - const freshLocal=(url,options)=>fetcher(url,{...options,cache:'no-store'}); - const configResponse=await boundedFetch('config.json',freshLocal,32*1024);if(!configResponse.ok)throw Error(`Museum config unavailable (${configResponse.status})`); - const config=JSON.parse(decoder.decode(configResponse.bytes)); - const pin=config.museum_json; - if(pin?.url!=='museum.json'||!hex64.test(pin.sha256)||!Number.isSafeInteger(pin.bytes)||pin.bytes<1||pin.bytes>256*1024)throw Error('Invalid museum manifest descriptor'); - const localFetch=async url=>{const response=await boundedFetch(url,freshLocal,pin.bytes);return {ok:response.ok,status:response.status,arrayBuffer:async()=>response.bytes.buffer};}; - const raw=await verifiedBytes(pin,localFetch); - const manifest=JSON.parse(decoder.decode(raw));validateDescriptor(manifest.index_source);validateDescriptor(manifest.status_source); - const cache=new Map(); - const cachedFetch=url=>{const key=String(url);if(!cache.has(key))cache.set(key,boundedFetch(url,fetcher));return cache.get(key).then(result=>({ok:result.ok,status:result.status,arrayBuffer:async()=>result.bytes.buffer}));}; - const [index,status]=await Promise.all([verifiedBytes(manifest.index_source,cachedFetch),verifiedBytes(manifest.status_source,cachedFetch)]); - validateBoundManifest(manifest,decoder.decode(index),decoder.decode(status)); + const {manifest,cachedFetch}=await verifiedMuseum({fetcher}); containers['museum-state'].textContent='Pinned source projections verified: 11 reviewed index entries and 3 separate AMEND rows. Verifying each linked source before display…'; const placeholders=manifest.claims.map(claim=>{const host=element(document,'div');host.append(element(document,'p',`Verifying ${claim.title}…`));containers['claim-cards'].append(host);return host;}); const jobs=manifest.claims.map(async(claim,i)=>{try{await verifyClaim(claim,cachedFetch);placeholders[i].replaceChildren(renderClaim(document,claim));}catch(error){placeholders[i].replaceChildren(refusal(document,claim.title,error));return false;}return true;}); diff --git a/tests/__pycache__/test_museum_data.cpython-312.pyc b/tests/__pycache__/test_museum_data.cpython-312.pyc new file mode 100644 index 000000000..d217a5c9b Binary files /dev/null and b/tests/__pycache__/test_museum_data.cpython-312.pyc differ diff --git a/tests/__pycache__/test_navigation.cpython-312.pyc b/tests/__pycache__/test_navigation.cpython-312.pyc new file mode 100644 index 000000000..edb1a6e87 Binary files /dev/null and b/tests/__pycache__/test_navigation.cpython-312.pyc differ diff --git a/tests/__pycache__/test_public_intake.cpython-312.pyc b/tests/__pycache__/test_public_intake.cpython-312.pyc new file mode 100644 index 000000000..8d8633493 Binary files /dev/null and b/tests/__pycache__/test_public_intake.cpython-312.pyc differ diff --git a/tests/__pycache__/test_public_shop_data.cpython-312.pyc b/tests/__pycache__/test_public_shop_data.cpython-312.pyc new file mode 100644 index 000000000..ccc13329d Binary files /dev/null and b/tests/__pycache__/test_public_shop_data.cpython-312.pyc differ diff --git a/tests/__pycache__/test_workspace_landing.cpython-312.pyc b/tests/__pycache__/test_workspace_landing.cpython-312.pyc new file mode 100644 index 000000000..3dd361a47 Binary files /dev/null and b/tests/__pycache__/test_workspace_landing.cpython-312.pyc differ diff --git a/tests/fixtures/cumulative_transfer_source.txt b/tests/fixtures/cumulative_transfer_source.txt new file mode 100644 index 000000000..044ac5fda --- /dev/null +++ b/tests/fixtures/cumulative_transfer_source.txt @@ -0,0 +1,56 @@ +# Correction to the cumulative transfer statement (D2) + +**Author:** OpenAI / ChatGPT. **Scientific effect:** NONE. Separate reviewer confirmation requested. + +This additive correction replaces only the cumulative paragraph and its proof in Section D of NOTE.md at source ad35e46d15c2815c36746442808a1626a9724e8a (SHA256530dd3efaa965c850ea9e6575f42d3952c3efe6a89b2b5355b6afb4285c9d37e). The original source stays unchanged for provenance. Sections B/C and the density theorem D1 are not changed. + +Nonauthor review PR32, commit189628119f65d845e270759e1b2b1e84ddb4cfe3, correctly found that saying only 'monotonicity and the same comparison/envelope assumptions' could drop the necessary normalization h/(kappa*r^m)->1. Two-sided comparisons do not determine the sharp constant. The correction explicitly retains that ratio hypothesis while dropping only derivative assumptions. + +## Corrected cumulative theorem + +Let (Z,lambda) be sigma-finite, alpha>-1, m>0, beta=(alpha+1)/m, and r0>0. Let all integrands be jointly measurable. Assume, for lambda-almost every z: + +1. kappa(z)>0; 0<=B(r,z)<=G(z); B(r,z)->B0(z) as r->0. +2. The weighted negative moment integral G(z)*kappa(z)^(-beta) dlambda is finite. +3. h(r,z) is continuous and strictly increasing for 0 1. + +4. Uniformly in r,z, h(r,z)>=c0*kappa(z)*r^m for a fixed c0>0. + +Neither a derivative limit nor a lower derivative bound is required for this cumulative theorem. Define + + N(ell)=integral_Z integral_0^r0 r^alpha B(r,z) 1{h(r,z)<=ell} dr dlambda. + +Then + + lim_(ell->0) N(ell)/ell^beta + = 1/(alpha+1) * integral_Z B0(z)*kappa(z)^(-beta) dlambda. + +If the displayed coefficient is positive, this limit is a positive asymptotic equivalence. If it is zero, only the corresponding o(ell^beta) conclusion is asserted. + +## Proof + +At each fixed z and sufficiently small ell, let R=R(ell,z) be the inverse of h. The explicitly retained ratio hypothesis gives + + R^(alpha+1) / (ell/kappa(z))^beta -> 1. + +Also, + + R^(-alpha-1) integral_0^R r^alpha B(r,z) dr + -> B0(z)/(alpha+1), + +by convergence of B at zero and alpha>-1. Therefore the normalized inner integral converges to B0(z)*kappa(z)^(-beta)/(alpha+1). + +For domination, the lower comparison implies h(r,z)<=ell only if r<=(ell/(c0*kappa(z)))^(1/m). Thus, also when the inverse would exceed r0, + + ell^(-beta) integral_0^r0 r^alpha B(r,z)1{h<=ell}dr + <= c0^(-beta) G(z)*kappa(z)^(-beta)/(alpha+1). + +This is integrable by assumption2. Dominated convergence proves the result. + +## Why the added precision matters + +For h(r)=2*kappa*r^m with constant amplitude1, the actual coefficient is multiplied by2^(-beta). This example satisfies suitable fixed two-sided comparison bounds but violates h/(kappa*r^m)->1. For alpha=1,m=3,kappa=1 and R=1/2, ell=1/4 and N=1/8: the actual cube is1/512, whereas the uncorrected candidate constant (ell^(2/3)/2)^3 is1/128. The ratio hypothesis excludes precisely this mismatch. + +This corrects an underspecified theorem statement; it is not an excuse to infer a density asymptotic from a cumulative asymptotic. D1 still requires its separate derivative controls. The Gaussian contact, thin-belt, whole-annulus, and global persistence statuses are untouched. diff --git a/tests/fixtures/museum_fixture.mjs b/tests/fixtures/museum_fixture.mjs new file mode 100644 index 000000000..02dda3776 --- /dev/null +++ b/tests/fixtures/museum_fixture.mjs @@ -0,0 +1,32 @@ +// Shared synthetic museum projection for Node tests. Not a source of record. +import fs from 'node:fs'; +import {createHash} from 'node:crypto'; + +export const digest = value => createHash('sha256').update(value).digest('hex'); +export const pin = (path, value, commit='a'.repeat(40)) => ({repository:'d6g8k5htny-coder/Math-', path, commit, blob:'b'.repeat(40), bytes:Buffer.byteLength(value), sha256:digest(value), url:`https://raw.githubusercontent.com/d6g8k5htny-coder/Math-/${commit}/${path}`, html_url:`https://github.com/d6g8k5htny-coder/Math-/blob/${commit}/${path}`}); +export const ids = ['d2-lifetime-remainder','d3-side24-coefficient','d4-fixed-remote-rn','d5-all-height-annulus','d5-height-window-annulus','d5-two-scale','d5-inner-belt-density','d5-fixed-transverse','cumulative-transfer-correction','p15-demand-one-counterexample','d6-p15-full-price']; +// `proofs` substitutes a real pinned descriptor for a reviewed claim; `commit` must then +// equal that descriptor's commit because claims bind to the index commit. +export function fixture({commit='a'.repeat(40),proofs={}}={}) { + const proof = pin('proof.md','Pinned proof.',commit); + const claims = ids.map((id,i) => {const p=proofs[id]??proof;return {id,title:`Object ${i}`,scope_quote:`- Object ${i}: [proof](${p.path}). Scope ${i}.`,source_label:i===9?'EXACT_COUNTEREXAMPLE':'ACCEPT',class:i===9?'engineering-only':'ACCEPT-scoped',proof:p,review:null,replay:{command:null,url:null,notice:'No executable replay fixture is supplied.'},status_quote:null};}); + for(const i of [0,1,2,10])claims[i].status_quote=`Accepted scope ${i}.`; + const open = ['d1-parent-selection-open','d5-pin-neighborhoods-open','sard-g-a1-a6-open'].map((id,i)=>({id,title:`Open ${i}`,scope_quote:`| **Open ${i}** | Still open ${i}. | [Proof](proof.md) |`,source_label:'AMEND / open',class:'AMEND/open',proof,review:null,replay:{command:null,url:null,notice:'No executable replay fixture is supplied.'},status_quote:`Still open ${i}.`})); + const index = `# Index\n\n## Reviewed scoped results\n\n${claims.map(c=>c.scope_quote).join('\n')}\n\n## Open or conditional results with complete proof text in GitHub\n- D1 parent lifetime theorem: full proof [proof](proof.md).\n`; + const acceptedRows=[[0,'D2'],[1,'D3'],[2,'D4'],[10,'D6']].map(([i,id])=>`| **${id} — scope** | Accepted scope ${i}. | Review | Limits |`).join('\n'); + const status = `# Status\n\n## ACCEPT — scoped\n\n| Object | Accepted scope | Source and review | Explicit limits |\n|---|---|---|---|\n${acceptedRows}\n\n## AMEND / open\n\n| Object | Current reason | Source |\n|---|---|---|\n${open.map(c=>c.scope_quote).join('\n')}\n\n## Engineering only\n`; + const indexSource=pin('PROOF_INDEX.md',index,commit),statusSource=pin('STATUS.md',status,commit);open[1].proof=indexSource;open[2].proof=statusSource; + return {index,status,manifest:{schema_version:1,scientific_status_authority:false,index_source:indexSource,status_source:statusSource,claims:[...claims,...open],exhibits:{ec014:proof,remote:proof,annulus:proof,p15:proof,lifetime:proof},packets:[]}}; +} + +export class Element { + constructor(tag){this.tagName=tag.toUpperCase();this.children=[];this.attributes={};this.listeners={};this.hidden=false;this._text='';} + set textContent(value){this._text=String(value);this.children=[];} get textContent(){return this._text+this.children.map(c=>c.textContent??String(c)).join('');} + append(...children){this.children.push(...children);} replaceChildren(...children){this._text='';this.children=children;} + setAttribute(k,v){this.attributes[k]=String(v);} addEventListener(k,f){this.listeners[k]=f;} +} +export function documentFromHTML(){ + const html=fs.readFileSync(new URL('../../docs/site/museum.html',import.meta.url),'utf8'); + const nodes=new Map([...html.matchAll(/<([a-z][a-z0-9]*)\b[^>]*\bid="([^"]+)"/gi)].map(m=>[m[2],new Element(m[1])])); + return {nodes,createElement:tag=>new Element(tag),createTextNode:value=>({textContent:value}),getElementById:id=>nodes.get(id)??null}; +} diff --git a/tests/test_museum_conditionals.mjs b/tests/test_museum_conditionals.mjs new file mode 100644 index 000000000..282b569f7 --- /dev/null +++ b/tests/test_museum_conditionals.mjs @@ -0,0 +1,92 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import {webcrypto} from 'node:crypto'; + +const moduleURL=new URL('../docs/site/conditionals.mjs',import.meta.url); +const raw=new Uint8Array(fs.readFileSync(new URL('./fixtures/cumulative_transfer_source.txt',import.meta.url))); +const path='reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md'; +const repo='d6g8k5htny-coder/Math-'; +const commit='d6628da09384728992dcbe6e921cc28ba85aebb0'; +const pin={repository:repo,commit,path,blob:'044ac5fdaf403a38e33983e31f0ad69f8e76d6d5',bytes:3272, + sha256:'83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6', + url:`https://raw.githubusercontent.com/${repo}/${commit}/${path}`, + html_url:`https://github.com/${repo}/blob/${commit}/${path}`}; +async function load(){assert.ok(fs.existsSync(moduleURL),'conditional projection implementation is absent');return import(moduleURL);} +async function project(){const m=await load();return m.projectVerified(raw,pin,webcrypto);} + +class Node { + constructor(tag){this.tagName=tag;this.children=[];this.text='';this.attributes={};} + set textContent(v){this.text=String(v);this.children=[];} + get textContent(){return this.text+this.children.map(x=>x.textContent).join(' ');} + set innerHTML(v){throw Error('innerHTML must not be used');} + append(...v){this.children.push(...v);} + replaceChildren(...v){this.text='';this.children=[...v];} + setAttribute(k,v){this.attributes[k]=v;} +} +const documentFor=host=>({createElement:tag=>new Node(tag),getElementById:id=>id==='conditional-route'?host:null}); + +test('six complete inputs feed exactly one conditional conclusion',async()=>{ + const p=await project();assert.equal(p.nodes.length,7); + assert.deepEqual(p.routes,[{id:'cumulative-limit',logic:'ALL',requires:['setup','H1','H2','H3','H4','definition'],concludes:'conclusion'}]); + assert.equal(p.scientific_status_authority,false);assert.equal(p.application_evaluation,'NOT_EVALUATED'); +}); +test('the normalization and fixed lower comparison are retained',async()=>{ + const p=await project();assert.match(p.nodes.find(n=>n.id==='H3').quote,/h\(r,z\)\/\(kappa\(z\)\*r\^m\) -> 1/); + assert.match(p.nodes.find(n=>n.id==='H4').quote,/Uniformly in r,z/);assert.match(p.nodes.find(n=>n.id==='H4').quote,/fixed c0>0/); +}); +test('measurability and almost-everywhere quantifiers are retained',async()=>{ + const q=(await project()).nodes[0].quote; + for(const word of ['sigma-finite','alpha>-1','m>0','jointly measurable','lambda-almost every'])assert.ok(q.includes(word)); +}); +test('positive and zero cases and the density non-implication remain explicit',async()=>{ + const p=await project();assert.match(p.case_split,/If it is zero/);assert.match(p.case_split,/o\(ell\^beta\)/); + assert.match(p.boundary,/not an excuse to infer a density asymptotic/); +}); +test('changed source bytes are refused before projection',async()=>{ + const m=await load(),bad=raw.slice();bad[30]^=1;await assert.rejects(m.projectVerified(bad,pin,webcrypto),/identity/); +}); +test('integer and mutable commit identities are refused',async()=>{ + const m=await load();for(const commit of [1111111111111111111111111111111111111111n,'main',true]) + await assert.rejects(m.projectVerified(raw,{...pin,commit},webcrypto),/identity/); +}); +test('a numeric hash cannot be coerced into a string',async()=>{ + const m=await load();await assert.rejects(m.projectVerified(raw,{...pin,sha256:3333},webcrypto),/identity/); +}); +test('private repository and changed proof paths are refused',async()=>{ + const m=await load();for(const changes of [{repository:'d6g8k5htny-coder/sandbox'},{path:'../proof.txt'},{path:'another/PROOF.md'}]) + await assert.rejects(m.projectVerified(raw,{...pin,...changes},webcrypto),/identity/); +}); +test('redirected URL and changed blob or size are refused',async()=>{ + const m=await load();for(const changes of [{url:'https://example.com/proof'},{blob:'a'.repeat(40)},{bytes:'3272'}]) + await assert.rejects(m.projectVerified(raw,{...pin,...changes},webcrypto),/identity/); +}); +test('deleting H3 cannot silently weaken the route',async()=>{ + const m=await load(),p=await project();p.nodes=p.nodes.filter(n=>n.id!=='H3'); + await assert.rejects(m.verifyProjection(p,raw,pin,webcrypto),/projection/); +}); +test('ALL cannot become ANY',async()=>{ + const m=await load(),p=await project();p.routes[0].logic='ANY'; + await assert.rejects(m.verifyProjection(p,raw,pin,webcrypto),/projection/); +}); +test('self dependency or unknown nodes are refused',async()=>{ + const m=await load();for(const node of ['conclusion','imaginary']){const p=await project();p.routes[0].requires.push(node); + await assert.rejects(m.verifyProjection(p,raw,pin,webcrypto),/projection/);} +}); +test('invented acceptance and independence fields are refused',async()=>{ + const m=await load();for(const changes of [{scientific_status_authority:true},{status:'ACCEPT'},{independence_credit:1}]) + await assert.rejects(m.verifyProjection({...await project(),...changes},raw,pin,webcrypto),/projection/); +}); +test('rendering exposes hypotheses, exact identity, and application boundary',async()=>{ + const m=await load(),host=new Node('div');m.renderProjection(documentFor(host),host,await project(),pin); + for(const text of ['H1','H2','H3','H4','ALL','NOT_EVALUATED',pin.commit,pin.sha256])assert.ok(host.textContent.includes(text),text); + assert.ok(!host.textContent.includes('all hypotheses discharged')); +}); +test('a failed load clears any earlier ready view',async()=>{ + const m=await load(),host=new Node('div');host.textContent='old ready result'; + const ok=await m.startConditionals({document:documentFor(host),loadServices:async()=>{throw Error('source unavailable');}}); + assert.equal(ok,false);assert.match(host.textContent,/Unavailable/);assert.ok(!host.textContent.includes('old ready')); +}); +test('the source fixture is complete and immutable',async()=>{ + await project();assert.equal(raw.length,3272);assert.match(new TextDecoder().decode(raw),/## Proof/); +}); diff --git a/tests/test_museum_conditionals_cli.mjs b/tests/test_museum_conditionals_cli.mjs new file mode 100644 index 000000000..85eff3948 --- /dev/null +++ b/tests/test_museum_conditionals_cli.mjs @@ -0,0 +1,89 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import {createHash} from 'node:crypto'; +import {spawnSync} from 'node:child_process'; +import {fileURLToPath} from 'node:url'; + +const script=fileURLToPath(new URL('../tools/museum_conditionals.mjs',import.meta.url)); +const fixture=fileURLToPath(new URL('./fixtures/cumulative_transfer_source.txt',import.meta.url)); +const sourcePath='reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md'; +const repository='d6g8k5htny-coder/Math-',commit='d6628da09384728992dcbe6e921cc28ba85aebb0'; +const proof={repository,commit,path:sourcePath,bytes:3272,blob:'044ac5fdaf403a38e33983e31f0ad69f8e76d6d5', + sha256:'83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6', + url:`https://raw.githubusercontent.com/${repository}/${commit}/${sourcePath}`, + html_url:`https://github.com/${repository}/blob/${commit}/${sourcePath}`}; +function workspace(){ + const root=fs.mkdtempSync(path.join(os.tmpdir(),'conditional-cli-')); + const site=path.join(root,'docs/site');fs.mkdirSync(site,{recursive:true}); + return {root,site,cleanup:()=>fs.rmSync(root,{recursive:true,force:true})}; +} +function putManifest(site,claims=[{id:'cumulative-transfer-correction',proof}]){ + const raw=Buffer.from(JSON.stringify({schema_version:1,scientific_status_authority:false,claims})); + fs.writeFileSync(path.join(site,'museum.json'),raw); + fs.writeFileSync(path.join(site,'config.json'),JSON.stringify({museum_json:{url:'museum.json',bytes:raw.length,sha256:createHash('sha256').update(raw).digest('hex')}})); +} +function run(root,...extra){ + assert.ok(fs.existsSync(script),'conditional CLI is absent'); + return spawnSync(process.execPath,[script,'--root',root,'--source',fixture,...extra],{encoding:'utf8',timeout:10000}); +} +test('museum HTML has the route host, navigation and module without replacing existing cards',()=>{ + const htmlURL=new URL('../docs/site/museum.html',import.meta.url); + assert.ok(fs.existsSync(htmlURL),'updated museum HTML is absent'); + const html=fs.readFileSync(htmlURL,'utf8'); + for(const text of ['id="conditional-route"','href="#conditionals"','src="conditionals.mjs"','src="museum.mjs"','id="claim-cards"','id="packet-cards"'])assert.ok(html.includes(text),text); + assert.equal((html.match(/id="conditional-route"/g)||[]).length,1); +}); +test('CLI projects the exact source and produces deterministic JSON',()=>{ + const w=workspace();try{ + putManifest(w.site);const p=run(w.root),again=run(w.root); + assert.equal(p.status,0,p.stderr);assert.equal(again.stdout,p.stdout); + const data=JSON.parse(p.stdout);assert.equal(data.nodes.length,7); + assert.equal(data.routes[0].logic,'ALL');assert.equal(data.application_evaluation,'NOT_EVALUATED'); + }finally{w.cleanup();} +}); +test('CLI rejects altered manifest bytes',()=>{ + const w=workspace();try{ + putManifest(w.site);fs.appendFileSync(path.join(w.site,'museum.json'),' '); + const p=run(w.root);assert.notEqual(p.status,0);assert.match(p.stderr,/REFUSED.*manifest/i); + }finally{w.cleanup();} +}); +test('CLI refuses missing or repeated conditional claim',()=>{ + const w=workspace();try{ + for(const claims of [[],[{id:'cumulative-transfer-correction',proof},{id:'cumulative-transfer-correction',proof}]]){ + putManifest(w.site,claims);const p=run(w.root);assert.notEqual(p.status,0);assert.match(p.stderr,/REFUSED/); + } + }finally{w.cleanup();} +}); +test('CLI rejects weakened projection in check mode',()=>{ + const w=workspace();try{ + putManifest(w.site);const p=run(w.root);assert.equal(p.status,0,p.stderr); + const output=path.join(w.root,'projection.json');fs.writeFileSync(output,p.stdout); + assert.equal(run(w.root,'--check',output).status,0); + const data=JSON.parse(p.stdout);data.routes[0].logic='ANY';fs.writeFileSync(output,JSON.stringify(data)); + const bad=run(w.root,'--check',output);assert.notEqual(bad.status,0);assert.match(bad.stderr,/projection/); + }finally{w.cleanup();} +}); +test('CLI rejects nonlocal manifest and malformed hash types',()=>{ + const w=workspace();try{ + for(const change of [{url:'../other.json'},{sha256:123},{bytes:'3272'}]){ + putManifest(w.site);const f=path.join(w.site,'config.json'),c=JSON.parse(fs.readFileSync(f)); + Object.assign(c.museum_json,change);fs.writeFileSync(f,JSON.stringify(c)); + const p=run(w.root);assert.notEqual(p.status,0);assert.match(p.stderr,/REFUSED/); + } + }finally{w.cleanup();} +}); +test('CLI refuses missing input and unknown options',()=>{ + const w=workspace();try{ + const p=run(w.root);assert.notEqual(p.status,0);assert.match(p.stderr,/REFUSED/); + putManifest(w.site);assert.notEqual(run(w.root,'--accept','true').status,0); + }finally{w.cleanup();} +}); +test('CLI rejects source substitution',()=>{ + const w=workspace();try{ + putManifest(w.site,[{id:'cumulative-transfer-correction',proof:{...proof,commit:'main'}}]); + const p=run(w.root);assert.notEqual(p.status,0);assert.match(p.stderr,/identity/); + }finally{w.cleanup();} +}); diff --git a/tests/test_museum_conditionals_startup.mjs b/tests/test_museum_conditionals_startup.mjs new file mode 100644 index 000000000..efdb6e374 --- /dev/null +++ b/tests/test_museum_conditionals_startup.mjs @@ -0,0 +1,85 @@ +// Browser startup path of the conditional route: verified config/manifest reuse, +// claim selection, proof loading and host replacement. Engineering test only. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import {digest,pin,fixture,documentFromHTML} from './fixtures/museum_fixture.mjs'; + +const museum=await import(new URL('../docs/site/museum.mjs',import.meta.url)); +const conditionals=await import(new URL('../docs/site/conditionals.mjs',import.meta.url)); +const raw=new Uint8Array(fs.readFileSync(new URL('./fixtures/cumulative_transfer_source.txt',import.meta.url))); +const repo='d6g8k5htny-coder/Math-',commit='d6628da09384728992dcbe6e921cc28ba85aebb0'; +const path='reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md'; +const audited={repository:repo,commit,path,blob:'044ac5fdaf403a38e33983e31f0ad69f8e76d6d5',bytes:3272, + sha256:'83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6', + url:`https://raw.githubusercontent.com/${repo}/${commit}/${path}`, + html_url:`https://github.com/${repo}/blob/${commit}/${path}`}; +const CLAIM='cumulative-transfer-correction'; + +function scene(proof=audited){ + const f=fixture({commit,proofs:{[CLAIM]:proof}}); + const manifestRaw=JSON.stringify(f.manifest); + const config=JSON.stringify({museum_json:{url:'museum.json',bytes:Buffer.byteLength(manifestRaw),sha256:digest(manifestRaw)}}); + const bodies=new Map([['config.json',config],['museum.json',manifestRaw],[f.manifest.index_source.url,f.index],[f.manifest.status_source.url,f.status],[f.manifest.claims[0].proof.url,'Pinned proof.'],[audited.url,raw]]); + const requests=[]; + const fetcher=async url=>{const key=String(url);requests.push(key);assert.ok(bodies.has(key),`Unexpected URL ${key}`);return new Response(bodies.get(key));}; + return {f,bodies,requests,fetcher,document:documentFromHTML()}; +} +const count=(requests,url)=>requests.filter(r=>r===url).length; + +test('a verified startup renders the route from the selected claim proof bytes',async()=>{ + const {requests,fetcher,document}=scene(); + const ok=await conditionals.startConditionals({document,fetcher}); + assert.equal(ok,true); + const text=document.getElementById('conditional-route').textContent; + for(const expected of ['Conditional route: cumulative transfer','H1','H2','H3','H4','ALL','NOT_EVALUATED',commit,audited.sha256,'lim_(ell->0)'])assert.ok(text.includes(expected),expected); + assert.ok(!text.includes('Verifying the conditional route source')); + assert.deepEqual(requests.slice(0,2),['config.json','museum.json']); + for(const url of ['config.json','museum.json',audited.url])assert.equal(count(requests,url),1,url); +}); +test('the museum page and the conditional route share one verified startup and byte cache',async()=>{ + const {requests,fetcher,document}=scene(); + const [,ok]=await Promise.all([museum.startMuseum({document,fetcher,search:''}),conditionals.startConditionals({document,fetcher})]); + assert.equal(ok,true); + assert.equal(new Set(requests).size,requests.length,`repeated request: ${requests.join(', ')}`); + assert.equal(count(requests,'config.json'),1);assert.equal(count(requests,'museum.json'),1);assert.equal(count(requests,audited.url),1); + assert.match(document.getElementById('museum-state').textContent,/verified/i); + assert.match(document.getElementById('claim-cards').textContent,/Object 8/); + assert.match(document.getElementById('conditional-route').textContent,/NOT_EVALUATED/); +}); +test('a rejected startup is not retained for a later caller',async()=>{ + const {bodies,requests,fetcher,document}=scene(); + const good=bodies.get('museum.json');bodies.set('museum.json',good+' '); + assert.equal(await conditionals.startConditionals({document,fetcher}),false); + assert.match(document.getElementById('conditional-route').textContent,/Unavailable/); + bodies.set('museum.json',good); + assert.equal(await conditionals.startConditionals({document,fetcher}),true); + assert.equal(count(requests,'config.json'),2); +}); +test('changed proof bytes clear an earlier view and infer nothing',async()=>{ + const {bodies,fetcher,document}=scene(); + const altered=raw.slice();altered[30]^=1;bodies.set(audited.url,altered); + const host=document.getElementById('conditional-route');host.textContent='old ready result'; + assert.equal(await conditionals.startConditionals({document,fetcher}),false); + assert.match(host.textContent,/Unavailable: Source SHA-256 mismatch/); + assert.ok(!host.textContent.includes('old ready'));assert.ok(!host.textContent.includes('H1')); +}); +test('a manifest proof that is not the audited descriptor is refused before its bytes are fetched',async()=>{ + const other=pin(path,'A different text at the same path.',commit); + const {requests,fetcher,document}=scene(other); + assert.equal(await conditionals.startConditionals({document,fetcher}),false); + assert.match(document.getElementById('conditional-route').textContent,/Conditional source identity mismatch/); + assert.equal(count(requests,other.url),0); +}); +test('a stale manifest stops before any pinned remote request',async()=>{ + const {bodies,requests,fetcher,document}=scene(); + bodies.set('museum.json',bodies.get('museum.json').replace('"schema_version":1','"schema_version":2')); + assert.equal(await conditionals.startConditionals({document,fetcher}),false); + assert.deepEqual(requests,['config.json','museum.json']); + assert.match(document.getElementById('conditional-route').textContent,/Unavailable/); +}); +test('a page without the route container is left untouched',async()=>{ + const {requests,fetcher,document}=scene();document.nodes.delete('conditional-route'); + assert.equal(await conditionals.startConditionals({document,fetcher}),false); + assert.deepEqual(requests,[]); +}); diff --git a/tests/test_museum_frontend.mjs b/tests/test_museum_frontend.mjs index 44839f24b..a19ba29ca 100644 --- a/tests/test_museum_frontend.mjs +++ b/tests/test_museum_frontend.mjs @@ -1,8 +1,8 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; -import {createHash} from 'node:crypto'; import {execFileSync} from 'node:child_process'; +import {digest,pin,fixture,documentFromHTML} from './fixtures/museum_fixture.mjs'; const moduleURL = new URL('../docs/site/museum.mjs', import.meta.url); test('museum exposes source-bound rendering rather than silently omitting the page', () => { @@ -10,21 +10,6 @@ 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}; -const digest = value => createHash('sha256').update(value).digest('hex'); -const pin = (path, value) => ({repository:'d6g8k5htny-coder/Math-', path, commit:'a'.repeat(40), blob:'b'.repeat(40), bytes:Buffer.byteLength(value), sha256:digest(value), url:`https://raw.githubusercontent.com/d6g8k5htny-coder/Math-/${'a'.repeat(40)}/${path}`, html_url:`https://github.com/d6g8k5htny-coder/Math-/blob/${'a'.repeat(40)}/${path}`}); -const ids = ['d2-lifetime-remainder','d3-side24-coefficient','d4-fixed-remote-rn','d5-all-height-annulus','d5-height-window-annulus','d5-two-scale','d5-inner-belt-density','d5-fixed-transverse','cumulative-transfer-correction','p15-demand-one-counterexample','d6-p15-full-price']; -function fixture() { - const proof = pin('proof.md','Pinned proof.'); - const claims = ids.map((id,i) => ({id,title:`Object ${i}`,scope_quote:`- Object ${i}: [proof](proof.md). Scope ${i}.`,source_label:i===9?'EXACT_COUNTEREXAMPLE':'ACCEPT',class:i===9?'engineering-only':'ACCEPT-scoped',proof,review:null,replay:{command:null,url:null,notice:'No executable replay fixture is supplied.'},status_quote:null})); - for(const i of [0,1,2,10])claims[i].status_quote=`Accepted scope ${i}.`; - const open = ['d1-parent-selection-open','d5-pin-neighborhoods-open','sard-g-a1-a6-open'].map((id,i)=>({id,title:`Open ${i}`,scope_quote:`| **Open ${i}** | Still open ${i}. | [Proof](proof.md) |`,source_label:'AMEND / open',class:'AMEND/open',proof,review:null,replay:{command:null,url:null,notice:'No executable replay fixture is supplied.'},status_quote:`Still open ${i}.`})); - const index = `# Index\n\n## Reviewed scoped results\n\n${claims.map(c=>c.scope_quote).join('\n')}\n\n## Open or conditional results with complete proof text in GitHub\n- D1 parent lifetime theorem: full proof [proof](proof.md).\n`; - const acceptedRows=[[0,'D2'],[1,'D3'],[2,'D4'],[10,'D6']].map(([i,id])=>`| **${id} — scope** | Accepted scope ${i}. | Review | Limits |`).join('\n'); - const status = `# Status\n\n## ACCEPT — scoped\n\n| Object | Accepted scope | Source and review | Explicit limits |\n|---|---|---|---|\n${acceptedRows}\n\n## AMEND / open\n\n| Object | Current reason | Source |\n|---|---|---|\n${open.map(c=>c.scope_quote).join('\n')}\n\n## Engineering only\n`; - const indexSource=pin('PROOF_INDEX.md',index),statusSource=pin('STATUS.md',status);open[1].proof=indexSource;open[2].proof=statusSource; - return {index,status,manifest:{schema_version:1,scientific_status_authority:false,index_source:indexSource,status_source:statusSource,claims:[...claims,...open],exhibits:{ec014:proof,remote:proof,annulus:proof,p15:proof,lifetime:proof},packets:[]}}; -} - test('full reviewed bullets and all three AMEND rows retain their classes and source wording',available,()=>{ const {manifest,index,status}=fixture(); assert.equal(museum.validateBoundManifest(manifest,index,status).claims.length,14); @@ -121,17 +106,6 @@ test('new landed chart packet requires its exact separate main commit and remain assert.throws(()=>museum.validateBoundManifest(promoted,f.index,f.status),/scientific effect/i); }); -class Element { - constructor(tag){this.tagName=tag.toUpperCase();this.children=[];this.attributes={};this.listeners={};this.hidden=false;this._text='';} - set textContent(value){this._text=String(value);this.children=[];} get textContent(){return this._text+this.children.map(c=>c.textContent??String(c)).join('');} - append(...children){this.children.push(...children);} replaceChildren(...children){this._text='';this.children=children;} - setAttribute(k,v){this.attributes[k]=String(v);} addEventListener(k,f){this.listeners[k]=f;} -} -function documentFromHTML(){ - const html=fs.readFileSync(new URL('../docs/site/museum.html',import.meta.url),'utf8'); - const nodes=new Map([...html.matchAll(/<([a-z][a-z0-9]*)\b[^>]*\bid="([^"]+)"/gi)].map(m=>[m[2],new Element(m[1])])); - return {nodes,createElement:tag=>new Element(tag),createTextNode:value=>({textContent:value}),getElementById:id=>nodes.get(id)??null}; -} test('rendered claims use declared HTML containers, complete identities and literal disclaimer',available,async()=>{ const f=fixture(),document=documentFromHTML(); const raw=JSON.stringify(f.manifest),config=JSON.stringify({museum_json:{url:'museum.json',bytes:Buffer.byteLength(raw),sha256:digest(raw)}}); diff --git a/tests/test_museum_identity.mjs b/tests/test_museum_identity.mjs new file mode 100644 index 000000000..ff911c95f --- /dev/null +++ b/tests/test_museum_identity.mjs @@ -0,0 +1,38 @@ +// Regression for hash-correct bytes relabeled with an unaudited commit. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import {createHash,webcrypto} from 'node:crypto'; +import {spawnSync} from 'node:child_process'; +import {fileURLToPath} from 'node:url'; +import {projectVerified} from '../docs/site/conditionals.mjs'; +const repository='d6g8k5htny-coder/Math-',commit='d6628da09384728992dcbe6e921cc28ba85aebb0'; +const sourcePath='reviews/collision_mechanism_20260925/CUMULATIVE_TRANSFER_CORRECTION.md'; +const fixture=fileURLToPath(new URL('./fixtures/cumulative_transfer_source.txt',import.meta.url)); +const raw=new Uint8Array(fs.readFileSync(fixture)); +function pin(revision=commit){return {repository,commit:revision,path:sourcePath,bytes:3272, + blob:'044ac5fdaf403a38e33983e31f0ad69f8e76d6d5', + sha256:'83f653393dc6245980f6848e2bfc65ac9ad4c7d8304b028b88764356fd3825b6', + url:`https://raw.githubusercontent.com/${repository}/${revision}/${sourcePath}`, + html_url:`https://github.com/${repository}/blob/${revision}/${sourcePath}`};} +test('correct source bytes cannot acquire a different valid-looking commit',async()=>{ + await assert.rejects(projectVerified(raw,pin('1'.repeat(40)),webcrypto),/identity/); +}); +test('exported projection preserves the complete audited source descriptor',async()=>{ + assert.deepEqual((await projectVerified(raw,pin(),webcrypto)).source,pin()); +}); +test('offline CLI refuses coherent hash-correct source relabeling',()=>{ + const root=fs.mkdtempSync(path.join(os.tmpdir(),'conditional-identity-')); + try{ + const site=path.join(root,'docs/site');fs.mkdirSync(site,{recursive:true}); + const manifest=Buffer.from(JSON.stringify({schema_version:1,scientific_status_authority:false, + claims:[{id:'cumulative-transfer-correction',proof:pin('1'.repeat(40))}]})); + fs.writeFileSync(path.join(site,'museum.json'),manifest); + fs.writeFileSync(path.join(site,'config.json'),JSON.stringify({museum_json:{url:'museum.json',bytes:manifest.length,sha256:createHash('sha256').update(manifest).digest('hex')}})); + const script=fileURLToPath(new URL('../tools/museum_conditionals.mjs',import.meta.url)); + const result=spawnSync(process.execPath,[script,'--root',root,'--source',fixture],{encoding:'utf8',timeout:10000}); + assert.notEqual(result.status,0);assert.match(result.stderr,/REFUSED:.*identity/); + }finally{fs.rmSync(root,{recursive:true,force:true});} +}); diff --git a/tools/__pycache__/museum_data.cpython-312.pyc b/tools/__pycache__/museum_data.cpython-312.pyc new file mode 100644 index 000000000..fda7c76b1 Binary files /dev/null and b/tools/__pycache__/museum_data.cpython-312.pyc differ diff --git a/tools/__pycache__/navigation_check.cpython-312.pyc b/tools/__pycache__/navigation_check.cpython-312.pyc new file mode 100644 index 000000000..c7221cbce Binary files /dev/null and b/tools/__pycache__/navigation_check.cpython-312.pyc differ diff --git a/tools/__pycache__/public_intake_check.cpython-312.pyc b/tools/__pycache__/public_intake_check.cpython-312.pyc new file mode 100644 index 000000000..970b36436 Binary files /dev/null and b/tools/__pycache__/public_intake_check.cpython-312.pyc differ diff --git a/tools/__pycache__/public_shop_data.cpython-312.pyc b/tools/__pycache__/public_shop_data.cpython-312.pyc new file mode 100644 index 000000000..06571d51d Binary files /dev/null and b/tools/__pycache__/public_shop_data.cpython-312.pyc differ diff --git a/tools/__pycache__/workspace_landing_check.cpython-312.pyc b/tools/__pycache__/workspace_landing_check.cpython-312.pyc new file mode 100644 index 000000000..e3b33f970 Binary files /dev/null and b/tools/__pycache__/workspace_landing_check.cpython-312.pyc differ diff --git a/tools/museum_conditionals.mjs b/tools/museum_conditionals.mjs new file mode 100644 index 000000000..6513bf1f8 --- /dev/null +++ b/tools/museum_conditionals.mjs @@ -0,0 +1,51 @@ +// Read-only export of one conditional route; never executes a source or fetches the network. +import fs from 'node:fs'; +import path from 'node:path'; +import {fileURLToPath} from 'node:url'; +import {createHash,webcrypto} from 'node:crypto'; +import {projectVerified,verifyProjection} from '../docs/site/conditionals.mjs'; + +function readBounded(filename,limit){ + const fd=fs.openSync(filename,'r'); + try{ + const stat=fs.fstatSync(fd); + if(!stat.isFile()||stat.size>limit)throw Error('Input is not a bounded regular file'); + const raw=Buffer.alloc(limit+1);let total=0; + while(totallimit)throw Error('Input exceeds byte limit'); + return raw.subarray(0,total); + }finally{fs.closeSync(fd);} +} +function argumentsFor(argv){ + const options={root:path.resolve(fileURLToPath(new URL('..',import.meta.url)))}; + const seen=new Set(); + for(let i=0;i256*1024)throw Error('Invalid museum manifest identity'); + let raw; + try{raw=readBounded(path.join(site,'museum.json'),pin.bytes);} + catch(error){throw Error('Museum manifest unreadable: '+error.message);} + if(raw.length!==pin.bytes||createHash('sha256').update(raw).digest('hex')!==pin.sha256) + throw Error('Museum manifest byte identity mismatch'); + const manifest=JSON.parse(raw); + if(manifest.schema_version!==1||manifest.scientific_status_authority!==false||!Array.isArray(manifest.claims)) + throw Error('Invalid museum manifest declarations'); + const claims=manifest.claims.filter(c=>c?.id==='cumulative-transfer-correction'); + if(claims.length!==1)throw Error('Conditional claim is missing or repeated'); + const source=new Uint8Array(readBounded(options.source,3272)); + const projected=await projectVerified(source,claims[0].proof,webcrypto); + if(options.check)await verifyProjection(JSON.parse(readBounded(options.check,64*1024)),source,claims[0].proof,webcrypto); + process.stdout.write(JSON.stringify(projected,null,2)+'\n'); +} +try{await main();}catch(error){process.stderr.write('REFUSED: '+error.message+'\n');process.exitCode=1;}