From 7942be25cc6dfa9b103670ff24d0b99485d2539a Mon Sep 17 00:00:00 2001
From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com>
Date: Sat, 3 Oct 2026 12:10:19 -0700
Subject: [PATCH 1/2] Make source references copyable and shareable with
explicit hash boundaries
---
docs/site/app.js | 6 +--
docs/site/brand.css | 2 +-
docs/site/cite.html | 8 +--
docs/site/cite.mjs | 4 +-
docs/site/conditionals.mjs | 2 +-
docs/site/dependencies.html | 10 ++--
docs/site/dependencies.mjs | 2 +-
docs/site/explore-models.mjs | 2 +-
docs/site/explore.html | 10 ++--
docs/site/explore.mjs | 4 +-
docs/site/formal.html | 6 +--
docs/site/index.html | 4 +-
docs/site/measure.html | 10 ++--
docs/site/measure.mjs | 2 +-
docs/site/museum.html | 6 +--
docs/site/museum.mjs | 6 +--
docs/site/reproduce.html | 4 +-
docs/site/research.html | 2 +-
docs/site/source-reference.mjs | 87 +++++++++++++++++++++++++++---
docs/site/workspace.html | 6 +--
tests/test_source_reference.mjs | 66 +++++++++++++++++++++++
tools/public_shop_browser_check.py | 54 +++++++++++++++++++
22 files changed, 247 insertions(+), 56 deletions(-)
diff --git a/docs/site/app.js b/docs/site/app.js
index 1ebd2e252..c2d6009b7 100644
--- a/docs/site/app.js
+++ b/docs/site/app.js
@@ -1,6 +1,6 @@
-import {verifiedJSON, verifiedBytes, validateStatus, validateCoefficient, safeSourceURL, hex40, hex64} from './core.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
-import {connectCatalogQuery} from './catalog-query.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
-import {prepareWorkspaceFragment} from './workspace-fragment.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import {verifiedJSON, verifiedBytes, validateStatus, validateCoefficient, safeSourceURL, hex40, hex64} from './core.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {connectCatalogQuery} from './catalog-query.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {prepareWorkspaceFragment} from './workspace-fragment.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
const finishFragment=prepareWorkspaceFragment();
const el=id=>document.getElementById(id);
const node=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
diff --git a/docs/site/brand.css b/docs/site/brand.css
index d754936dc..fd26e8dad 100644
--- a/docs/site/brand.css
+++ b/docs/site/brand.css
@@ -58,7 +58,7 @@ body > header {
color: var(--ul-text); font-weight: 750; letter-spacing: .13em;
position: relative; padding-left: 57px; min-height: 44px; line-height: 1.65;
}
-.brand::before { content: ""; position: absolute; left: 0; top: 1px; width: 42px; height: 42px; background: url("brand/mark.svg?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37") center/contain no-repeat; }
+.brand::before { content: ""; position: absolute; left: 0; top: 1px; width: 42px; height: 42px; background: url("brand/mark.svg?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a") center/contain no-repeat; }
.brand span { color: var(--ul-muted); font-size: 10px; letter-spacing: .18em; }
nav { gap: 12px 24px; flex-wrap: wrap; }
nav a { color: var(--ul-text); min-height: 36px; display: inline-flex; align-items: center; font-size: 13px; }
diff --git a/docs/site/cite.html b/docs/site/cite.html
index f167b6cf2..3505b5da9 100644
--- a/docs/site/cite.html
+++ b/docs/site/cite.html
@@ -4,8 +4,8 @@
Cite · Universal Law
-
-
+
+
Skip to content
Reproduce Cite
@@ -14,8 +14,8 @@
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 .
-LOCAL REFERENCE BUILDER
Make an exact source link. This tool formats the identity you enter. It does not contact GitHub, check that the commit exists, retrieve a file, assign authorship, or evaluate its correctness. Everything stays in your browser.
-Enter the source identity, then build a reference.
Open this exact source on GitHub
+LOCAL REFERENCE BUILDER
Make an exact source link. This tool formats the identity you enter. It does not contact GitHub, check that the commit exists, retrieve a file, assign authorship, or evaluate its correctness. Only syntax is checked. Built references can be shared in the page address; include public source metadata only. Nothing is submitted to a verification service.
+Enter the source identity, then build a reference.
Open this exact source on GitHub
Inspect structured source identity (JSON) This source identity is not a complete bibliographic citation. Add the source’s actual authors, title and publication details, and cite relied-upon reviews separately. JSON records verification: not_performed; an entered hash is not a byte check.
Build a source link without JavaScript Open the file on GitHub, press y to switch to its commit permalink, then copy the URL. Include the source’s authorship and review scope in your reference.
diff --git a/docs/site/cite.mjs b/docs/site/cite.mjs
index e39a1959e..cc45a94ef 100644
--- a/docs/site/cite.mjs
+++ b/docs/site/cite.mjs
@@ -1,4 +1,4 @@
-import {wireReferenceForm} from './source-reference.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import {wireReferenceForm} from './source-reference.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
const byId = id => document.getElementById(id);
-wireReferenceForm({form:byId('reference-form'), repository:byId('reference-repository'), commit:byId('reference-commit'), path:byId('reference-path'), output:byId('reference-output'), link:byId('reference-link'), status:byId('reference-status')});
+wireReferenceForm({form:byId('reference-form'), repository:byId('reference-repository'), commit:byId('reference-commit'), path:byId('reference-path'), sha256:byId('reference-sha256'), output:byId('reference-output'), json:byId('reference-json'), link:byId('reference-link'), status:byId('reference-status'), actions:byId('reference-actions'), copyText:byId('reference-copy'), copyJSON:byId('reference-copy-json'), share:byId('reference-share'), clipboard:globalThis.navigator?.clipboard, location:globalThis.location, history:globalThis.history, events:globalThis.window});
byId('reference-builder').hidden = false;
diff --git a/docs/site/conditionals.mjs b/docs/site/conditionals.mjs
index 9a6cec008..94596c991 100644
--- a/docs/site/conditionals.mjs
+++ b/docs/site/conditionals.mjs
@@ -93,7 +93,7 @@ export function renderProjection(document,host,data,source){
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?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37');
+const services=()=>import('./museum.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a');
// 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.
diff --git a/docs/site/dependencies.html b/docs/site/dependencies.html
index 331120c27..2b70ac7b2 100644
--- a/docs/site/dependencies.html
+++ b/docs/site/dependencies.html
@@ -7,11 +7,11 @@
Claim dependency viewer · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/dependencies.mjs b/docs/site/dependencies.mjs
index 21491de33..92d75fc31 100644
--- a/docs/site/dependencies.mjs
+++ b/docs/site/dependencies.mjs
@@ -10,7 +10,7 @@ import {
normalizeSelection,
parsePinnedGraph,
unresolvedTargets,
-} from './dependency-model.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+} from './dependency-model.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
const byId = id => document.getElementById(id);
diff --git a/docs/site/explore-models.mjs b/docs/site/explore-models.mjs
index 6d6f1e22e..0f22daca5 100644
--- a/docs/site/explore-models.mjs
+++ b/docs/site/explore-models.mjs
@@ -1,6 +1,6 @@
// NON-CERTIFYING educational arithmetic. These functions illustrate source
// definitions; they do not simulate a field or estimate a theorem's constants.
-import { annulusModel, p15Model, remoteModel } from './geometry.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import { annulusModel, p15Model, remoteModel } from './geometry.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
function finite(value, name) {
if (!Number.isFinite(value)) throw new RangeError(`${name} must be finite`);
diff --git a/docs/site/explore.html b/docs/site/explore.html
index bf4ed62a0..b181c329c 100644
--- a/docs/site/explore.html
+++ b/docs/site/explore.html
@@ -7,11 +7,11 @@
Explore the mathematics · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/explore.mjs b/docs/site/explore.mjs
index 434a8cf8d..069e35e06 100644
--- a/docs/site/explore.mjs
+++ b/docs/site/explore.mjs
@@ -1,5 +1,5 @@
-import { coneModel, pinModel, paletteModel } from './explore-models.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
-import { readExploreState, exploreStateURL } from './explore-state.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import { coneModel, pinModel, paletteModel } from './explore-models.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import { readExploreState, exploreStateURL } from './explore-state.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
const ns = 'http://www.w3.org/2000/svg';
const byId = id => document.getElementById(id);
diff --git a/docs/site/formal.html b/docs/site/formal.html
index 3d1c5e4a2..3c3f6097d 100644
--- a/docs/site/formal.html
+++ b/docs/site/formal.html
@@ -4,9 +4,9 @@
Formal verification · Universal Law
-
-
-
+
+
+
diff --git a/docs/site/index.html b/docs/site/index.html
index f1c259c9a..f6e9ddfd5 100644
--- a/docs/site/index.html
+++ b/docs/site/index.html
@@ -4,8 +4,8 @@
Universal Law · The shape of randomness
-
-
+
+
Skip to content
diff --git a/docs/site/measure.html b/docs/site/measure.html
index 2ae7230b7..bae81c321 100644
--- a/docs/site/measure.html
+++ b/docs/site/measure.html
@@ -7,11 +7,11 @@
From counts to density · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/measure.mjs b/docs/site/measure.mjs
index 16879964b..518b1ed6c 100644
--- a/docs/site/measure.mjs
+++ b/docs/site/measure.mjs
@@ -1,4 +1,4 @@
-import { measurementModel, parseMeasurementInputs } from './measurement-model.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import { measurementModel, parseMeasurementInputs } from './measurement-model.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
const byId = id => document.getElementById(id);
const fields = Object.fromEntries(['count', 'realizations', 'lower', 'upper'].map(name => [name, byId(`measure-${name}`)]));
diff --git a/docs/site/museum.html b/docs/site/museum.html
index 13a7990c5..b301282b9 100644
--- a/docs/site/museum.html
+++ b/docs/site/museum.html
@@ -4,11 +4,11 @@
Source records & exhibits · Universal Law
-
+
-
-
+
+
diff --git a/docs/site/museum.mjs b/docs/site/museum.mjs
index 45ff93101..21e87aba8 100644
--- a/docs/site/museum.mjs
+++ b/docs/site/museum.mjs
@@ -1,5 +1,5 @@
-import {renderSourceQuote} from './source-quote.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
-import {verifiedBytes, hex40, hex64} from './core.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37';
+import {renderSourceQuote} from './source-quote.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {verifiedBytes, hex40, hex64} from './core.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
export const DISCLAIMER='This canvas explains the pinned source. It is not a proof and does not change status.';
const REVIEWED_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'];
@@ -247,7 +247,7 @@ function prepareClaimFragment(document,window,currentHash) {
return true;
};
}
-export async function startMuseum({document=globalThis.document,window=globalThis.window,fetcher=globalThis.fetch,search=globalThis.location?.search||'',geometryLoader=()=>import('./geometry.mjs?site-release=afac1358a71a41317dc244b90babf1c60be46544a66c800c47b1111e4f3dce37'),currentHash=()=>globalThis.location?.hash||''}={}){
+export async function startMuseum({document=globalThis.document,window=globalThis.window,fetcher=globalThis.fetch,search=globalThis.location?.search||'',geometryLoader=()=>import('./geometry.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a'),currentHash=()=>globalThis.location?.hash||''}={}){
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];}));
const finishFragment=prepareClaimFragment(document,window,currentHash);
diff --git a/docs/site/reproduce.html b/docs/site/reproduce.html
index 56ee21656..46db32463 100644
--- a/docs/site/reproduce.html
+++ b/docs/site/reproduce.html
@@ -4,9 +4,9 @@
Reproduce · Universal Law
-
+
-
+
Skip to content
Reproduce Cite
diff --git a/docs/site/research.html b/docs/site/research.html
index b1b7452ff..b100e7032 100644
--- a/docs/site/research.html
+++ b/docs/site/research.html
@@ -4,7 +4,7 @@
Research · Universal Law
-
+
Skip to content
Reproduce Cite
diff --git a/docs/site/source-reference.mjs b/docs/site/source-reference.mjs
index 966bb1605..b1b9d4ad9 100644
--- a/docs/site/source-reference.mjs
+++ b/docs/site/source-reference.mjs
@@ -1,6 +1,6 @@
/** Build syntax-checked source references locally. No source existence or review claim. */
const REPOSITORIES = new Set(['main', 'Math-', 'query-', 'Universal-Law-Workspace']);
-export function buildReference(repository, commit, path = '') {
+export function buildReference(repository, commit, path = '', sha256 = '') {
if (!REPOSITORIES.has(repository)) throw new Error('Choose a listed research repository.');
if (typeof commit !== 'string' || !/^[a-f0-9]{40}$/i.test(commit)) throw new Error('Enter the full 40-character Git commit, not a branch or short SHA.');
if (typeof path !== 'string' || path.length > 500 || /[%\\\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/u.test(path) ||
@@ -8,24 +8,95 @@ export function buildReference(repository, commit, path = '') {
throw new Error('Use a relative file path with ordinary / separators; no dot segments, encoded characters or control characters.');
}
const sha = commit.toLowerCase();
+ if (typeof sha256 !== 'string' || (sha256 && !/^[a-f0-9]{64}$/i.test(sha256))) throw new Error('Use a complete 64-character SHA-256, or leave it empty.');
+ if (sha256 && !path) throw new Error('A supplied file SHA-256 needs a file path.');
let encoded;
try { encoded = path.split('/').map(encodeURIComponent).join('/'); }
catch { throw new Error('The path must contain valid Unicode characters.'); }
const project = `d6g8k5htny-coder/${repository}`;
const url = `https://github.com/${project}/${path ? 'blob' : 'tree'}/${sha}${path ? '/' + encoded : ''}`;
- return {url, text: `${project}${path ? ' — ' + path : ''}. Git commit ${sha}. ${url}`};
+ const digest = sha256.toLowerCase();
+ const data = {schema: 'universal-law/source-reference/v1', repository: project, commit: sha, path: path || null, sha256: digest || null, url, verification: 'not_performed'};
+ return {url, text: `${project}${path ? ' — ' + path : ''}. Git commit ${sha}.${digest ? ' Supplied SHA-256 (not checked): ' + digest + '.' : ''} ${url}`, json: JSON.stringify(data, null, 2)};
}
-export function wireReferenceForm({form, repository, commit, path, output, link, status}) {
- const clear = () => { output.textContent = ''; link.hidden = true; link.removeAttribute('href'); status.textContent = 'Enter the source identity, then build a reference.'; };
+const STATE_KEYS = ['repo', 'commit', 'path', 'sha256'];
+export function readReferenceState(search) {
+ const params = new URLSearchParams(search);
+ if (!STATE_KEYS.some(key => params.has(key))) return null;
+ for (const key of STATE_KEYS) if (params.getAll(key).length > 1) throw new Error('The shared link has duplicate source fields. Enter the identity again.');
+ const state = {repository: params.get('repo'), commit: params.get('commit'), path: params.get('path') || '', sha256: params.get('sha256') || ''};
+ buildReference(state.repository, state.commit, state.path, state.sha256);
+ return {...state, commit: state.commit.toLowerCase(), sha256: state.sha256.toLowerCase()};
+}
+export function referenceStateURL(href, state) {
+ buildReference(state.repository, state.commit, state.path, state.sha256);
+ const url = new URL(href);
+ for (const key of STATE_KEYS) url.searchParams.delete(key);
+ url.searchParams.set('repo', state.repository);
+ url.searchParams.set('commit', state.commit.toLowerCase());
+ if (state.path) url.searchParams.set('path', state.path);
+ if (state.sha256) url.searchParams.set('sha256', state.sha256.toLowerCase());
+ return url.href;
+}
+export function wireReferenceForm({form, repository, commit, path, sha256, output, json, link, status, actions, copyText, copyJSON, share, clipboard, location, history, events}) {
+ let current = null, revision = 0;
+ const copyButtons = [copyText, copyJSON].filter(Boolean);
+ const canCopy = typeof clipboard?.writeText === 'function';
+ const setCopy = enabled => copyButtons.forEach(button => { button.disabled = !enabled; });
+ const clear = () => {
+ revision++; current = null;
+ output.textContent = ''; if (json) json.textContent = '';
+ link.hidden = true; link.removeAttribute('href');
+ if (actions) actions.hidden = true;
+ if (share) { share.hidden = true; share.removeAttribute('href'); }
+ setCopy(false);
+ status.textContent = 'Enter the source identity, then build a reference. Edits must be built before copying or sharing; the page address may still describe the previous reference.';
+ };
+ const values = () => ({repository: repository.value, commit: commit.value, path: path.value, sha256: sha256?.value || ''});
+ const render = state => {
+ current = buildReference(state.repository, state.commit, state.path, state.sha256);
+ output.textContent = current.text; if (json) json.textContent = current.json;
+ link.href = current.url; link.textContent = 'Open this exact source on GitHub ↗'; link.hidden = false;
+ if (actions) actions.hidden = false;
+ if (share && location) { share.href = referenceStateURL(location.href, state); share.hidden = false; }
+ setCopy(canCopy);
+ status.textContent = 'Reference built locally. Source existence, supplied hash, authorship and review status are not checked.' + (canCopy ? '' : ' Select the text or JSON and copy it manually.');
+ };
form.addEventListener('input', clear);
form.addEventListener('change', clear);
form.addEventListener('submit', event => {
event.preventDefault(); clear();
try {
- const reference = buildReference(repository.value, commit.value, path.value);
- output.textContent = reference.text;
- link.href = reference.url; link.textContent = 'Open this exact source on GitHub ↗'; link.hidden = false;
- status.textContent = 'Reference built locally. Source existence, authorship and review status are not checked.';
+ render(values());
+ if (share && history && share.href !== location.href) {
+ try { history.pushState(null, '', share.href); }
+ catch { status.textContent += ' The page address could not be updated; use the share link below.'; }
+ }
} catch (error) { status.textContent = error.message; }
});
+ for (const [button, key] of [[copyText, 'text'], [copyJSON, 'json']]) button?.addEventListener('click', async () => {
+ if (!current || !canCopy || button.disabled) return;
+ const started = revision, text = current[key];
+ setCopy(false); status.textContent = 'Copying source reference…';
+ try {
+ await clipboard.writeText(text);
+ if (started === revision) status.textContent = `Copied ${key === 'json' ? 'JSON' : 'source reference'}. The source and supplied hash are not verified.`;
+ } catch {
+ if (started === revision) status.textContent = 'Clipboard unavailable. Select the text or JSON and copy it manually. The source is not verified.';
+ } finally { if (started === revision) setCopy(canCopy); }
+ });
+ const restore = () => {
+ clear(); repository.value = 'main'; commit.value = ''; path.value = ''; if (sha256) sha256.value = '';
+ try {
+ const state = readReferenceState(location.search);
+ if (!state) return;
+ repository.value = state.repository; commit.value = state.commit; path.value = state.path; if (sha256) sha256.value = state.sha256;
+ render(state);
+ } catch (error) { status.textContent = `Shared reference unavailable: ${error.message}`; }
+ };
+ events?.addEventListener('popstate', restore);
+ events?.addEventListener('hashchange', () => {
+ if (current && share) share.href = referenceStateURL(location.href, values());
+ });
+ if (location && STATE_KEYS.some(key => new URLSearchParams(location.search).has(key))) restore();
}
diff --git a/docs/site/workspace.html b/docs/site/workspace.html
index 2e70044a1..5af7a5621 100644
--- a/docs/site/workspace.html
+++ b/docs/site/workspace.html
@@ -4,9 +4,9 @@
Research workspace · Universal Law
-
-
-
+
+
+
diff --git a/tests/test_source_reference.mjs b/tests/test_source_reference.mjs
index 0613dcb91..44aee6787 100644
--- a/tests/test_source_reference.mjs
+++ b/tests/test_source_reference.mjs
@@ -65,3 +65,69 @@ test('reproduction controls have static fallback and an explicit live announceme
assert.match(html,/id="copy-commands-status"[^>]*role="status"/);
assert.match(html,/script-src 'self'/);assert.match(html,/src="reproduce-copy.mjs/);
});
+
+const refs = await import('../docs/site/source-reference.mjs');
+const digest = 'AB'.repeat(32);
+test('optional file digest is preserved as supplied metadata with explicit unverified JSON',()=>{
+ const ref=buildReference('Math-',sha,'proofs/α #1.md',digest);
+ assert.match(ref.text,new RegExp(digest.toLowerCase()));
+ const record=JSON.parse(ref.json);
+ assert.equal(record.repository,'d6g8k5htny-coder/Math-');
+ assert.equal(record.commit,sha);assert.equal(record.path,'proofs/α #1.md');
+ assert.equal(record.sha256,digest.toLowerCase());assert.equal(record.verification,'not_performed');
+ assert.equal(record.url,ref.url);assert.equal(record.authors,undefined);
+ assert.equal(JSON.parse(buildReference('main',sha).json).sha256,null);
+});
+test('rejects misleading or malformed digest identities',()=>{
+ for(const value of [digest+'0',' main ', '0'.repeat(63), 'g'.repeat(64),digest+'\n',42]) {
+ assert.throws(()=>buildReference('main',sha,'README.md',value));
+ }
+ assert.throws(()=>buildReference('main',sha,'',digest),/file path/i);
+});
+test('reference links roundtrip exact unicode identity and preserve unrelated URL fields',()=>{
+ assert.equal(typeof refs.referenceStateURL,'function');
+ assert.equal(typeof refs.readReferenceState,'function');
+ const state={repository:'Math-',commit:sha,path:'proofs/α #1.md',sha256:digest};
+ const url=new URL(refs.referenceStateURL('https://example.test/cite.html?lang=en#reference-builder',state));
+ assert.equal(url.searchParams.get('lang'),'en');assert.equal(url.hash,'#reference-builder');
+ assert.deepEqual(refs.readReferenceState(url.search),{...state,sha256:digest.toLowerCase()});
+ assert.equal(refs.readReferenceState('?lang=en'),null);
+});
+test('malformed shared references are refused without partial source identity',()=>{
+ assert.equal(typeof refs.readReferenceState,'function');
+ for(const query of [`?repo=main&commit=${sha}&commit=${sha}`,`?repo=main&commit=main`,`?commit=${sha}`,`?repo=evil&commit=${sha}`,`?repo=main&commit=${sha}&path=%252e%252e/x`,`?repo=main&commit=${sha}&sha256=${digest}`]) {
+ assert.throws(()=>refs.readReferenceState(query),query);
+ }
+});
+function referenceControls(clipboard) {
+ const node=(value='')=>({value,textContent:'',hidden:true,disabled:true,listeners:{},addEventListener(k,v){this.listeners[k]=v;},removeAttribute(k){delete this[k];}});
+ const c={form:node(),repository:node('main'),commit:node(sha),path:node('README.md'),sha256:node(digest),output:node(),json:node(),link:node(),status:node(),actions:node(),copyText:node(),copyJSON:node(),share:node(),clipboard,
+ location:{href:'https://example.test/cite.html#reference-builder',search:''},history:{pushState(_a,_b,url){c.location.href=url;c.location.search=new URL(url).search;}},events:node()};
+ c.submit=()=>c.form.listeners.submit({preventDefault(){}});return c;
+}
+test('reference workflow copies selected representations and invalidates stale outputs',async()=>{
+ let copied;const c=referenceControls({async writeText(text){copied=text;}});
+ wireReferenceForm(c);c.submit();assert.equal(c.actions.hidden,false);
+ await c.copyText.listeners.click();assert.equal(copied,c.output.textContent);
+ await c.copyJSON.listeners.click();assert.equal(copied,c.json.textContent);
+ assert.match(c.status.textContent,/not verified/i);assert.equal(c.share.hidden,false);
+ c.path.value='other.md';c.form.listeners.input();assert.equal(c.actions.hidden,true);
+ assert.equal(c.copyJSON.disabled,true);assert.equal(c.json.textContent,'');assert.equal(c.share.href,undefined);
+});
+test('shared reference restoration and Back reject invalid state without publishing old output',()=>{
+ const c=referenceControls();c.location.search=`?repo=Math-&commit=${sha}&path=PROOF.md`;
+ c.location.href='https://example.test/cite.html'+c.location.search;
+ wireReferenceForm(c);assert.equal(c.repository.value,'Math-');assert.equal(c.path.value,'PROOF.md');
+ assert.equal(c.copyText.disabled,true);assert.match(c.status.textContent,/manually/i);
+ c.location.search='?repo=main&commit=main';c.events.listeners.popstate();
+ assert.equal(c.output.textContent,'');assert.equal(c.actions.hidden,true);assert.match(c.status.textContent,/40/);
+ c.location.search='';c.events.listeners.popstate();assert.equal(c.commit.value,'');
+});
+test('clipboard rejection and delayed completion do not claim a stale copy succeeded',async()=>{
+ const c=referenceControls({async writeText(){throw Error('denied');}});
+ wireReferenceForm(c);c.submit();await c.copyText.listeners.click();assert.match(c.status.textContent,/manually/i);assert.doesNotMatch(c.status.textContent,/Copied/);
+ let finish;const d=referenceControls({writeText(){return new Promise(resolve=>{finish=resolve;});}});
+ wireReferenceForm(d);d.submit();const pending=d.copyJSON.listeners.click();
+ d.path.value='new.md';d.form.listeners.input();finish();await pending;
+ assert.equal(d.actions.hidden,true);assert.equal(d.copyJSON.disabled,true);assert.doesNotMatch(d.status.textContent,/Copied/);
+});
diff --git a/tools/public_shop_browser_check.py b/tools/public_shop_browser_check.py
index 783f7e3f0..fb8dbfedb 100644
--- a/tools/public_shop_browser_check.py
+++ b/tools/public_shop_browser_check.py
@@ -281,6 +281,60 @@ def check_source_card_flow(page, origin, expect, result, output):
expect(page.locator("#curvature-kind")).to_contain_text("flat")
page.locator("#explore-state-link").scroll_into_view_if_needed()
result["steps"].append("Explore URLs restore all controls and derived explanations; keyboard edits, reset, reload, Back/Forward, malformed fields and JavaScript-off fallback checked")
+ if entry == "cite":
+ commit="a414e77d6278a5d9ce6aa6e2bdca6146b048f27a"
+ digest=sha256((ROOT/"CITATION.cff").read_bytes()).hexdigest()
+ page.locator("#reference-commit").fill(commit)
+ page.locator("#reference-path").fill("CITATION.cff")
+ page.locator("#reference-sha256").fill(digest)
+ page.get_by_role("button",name="Build reference",exact=True).click()
+ expect(page.locator("#reference-link")).to_have_attribute("href",f"https://github.com/d6g8k5htny-coder/main/blob/{commit}/CITATION.cff")
+ page.context.grant_permissions(["clipboard-read","clipboard-write"],origin=origin.rstrip("/"))
+ copy=page.get_by_role("button",name="Copy source reference",exact=True)
+ copy.focus();page.keyboard.press("Enter")
+ expect(page.locator("#reference-status")).to_contain_text("Copied source reference")
+ require(page.evaluate("navigator.clipboard.readText()") == page.locator("#reference-output").text_content(),"Source clipboard differs from visible reference")
+ page.get_by_role("button",name="Copy JSON",exact=True).click()
+ expect(page.locator("#reference-status")).to_contain_text("Copied JSON")
+ record=json.loads(page.evaluate("navigator.clipboard.readText()"))
+ require(record["commit"]==commit and record["sha256"]==digest and record["verification"]=="not_performed","JSON reference lost source or verification boundary")
+ shared=page.locator("#reference-share").get_attribute("href")
+ page.locator("#reference-path").fill("README.md")
+ expect(page.locator("#reference-actions")).to_be_hidden()
+ expect(page.locator("#reference-output")).to_be_empty()
+ page.locator("#reference-sha256").fill("")
+ page.get_by_role("button",name="Build reference",exact=True).click()
+ page.go_back();expect(page.locator("#reference-path")).to_have_value("CITATION.cff")
+ expect(page.locator("#reference-sha256")).to_have_value(digest)
+ page.go_forward();expect(page.locator("#reference-path")).to_have_value("README.md")
+ expect(page.locator("#reference-sha256")).to_have_value("")
+ page.goto(shared);expect(page.locator("#reference-path")).to_have_value("CITATION.cff")
+ expect(page.locator("#reference-output")).to_contain_text(digest)
+ page.goto(origin+"cite.html?repo=main&commit=main#reference-builder")
+ expect(page.locator("#reference-status")).to_contain_text("Shared reference unavailable")
+ expect(page.locator("#reference-output")).to_be_empty()
+ expect(page.locator("#reference-actions")).to_be_hidden()
+ page.add_init_script("const mode=sessionStorage.getItem('reference-clipboard-test');if(mode)Object.defineProperty(navigator,'clipboard',{configurable:true,value:mode==='deny'?{writeText:async()=>{throw new Error('denied')}}:undefined})")
+ page.evaluate("sessionStorage.setItem('reference-clipboard-test','deny')")
+ page.goto(shared);copy.click()
+ expect(page.locator("#reference-status")).to_contain_text("copy it manually")
+ expect(copy).to_be_enabled()
+ page.evaluate("sessionStorage.setItem('reference-clipboard-test','unsupported')")
+ page.reload();expect(copy).to_be_disabled()
+ expect(page.locator("#reference-output")).to_contain_text(digest)
+ page.evaluate("sessionStorage.removeItem('reference-clipboard-test')")
+ page.reload();expect(copy).to_be_enabled()
+ page.get_by_text("Inspect structured source identity (JSON)",exact=True).click()
+ expect(page.locator("#reference-json")).to_be_visible()
+ page.locator("#reference-actions").scroll_into_view_if_needed()
+ static=page.context.browser.new_context(java_script_enabled=False)
+ try:
+ fallback=static.new_page();fallback.goto(shared)
+ expect(fallback.locator("#reference-builder")).to_be_hidden()
+ expect(fallback.get_by_role("heading",name="Build a source link without JavaScript")).to_be_visible()
+ finally:
+ static.close()
+ result["steps"].append("Cite keyboard copies exact text/JSON with supplied digest; edit invalidation, share/reload, Back/Forward, invalid links, clipboard refusal and JavaScript-off fallback checked")
if entry == "reproduce":
commands=page.locator("#reproduction-commands").inner_text()
page.context.grant_permissions(["clipboard-read","clipboard-write"],origin=origin.rstrip("/"))
From 35e2b4bc6b70acf540ad4fbcb998460003e388b2 Mon Sep 17 00:00:00 2001
From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com>
Date: Sat, 3 Oct 2026 12:13:10 -0700
Subject: [PATCH 2/2] Serialize citation clipboard writes and refuse malformed
shared paths
---
docs/site/app.js | 6 +++---
docs/site/brand.css | 2 +-
docs/site/cite.html | 4 ++--
docs/site/cite.mjs | 2 +-
docs/site/conditionals.mjs | 2 +-
docs/site/dependencies.html | 10 +++++-----
docs/site/dependencies.mjs | 2 +-
docs/site/explore-models.mjs | 2 +-
docs/site/explore.html | 10 +++++-----
docs/site/explore.mjs | 4 ++--
docs/site/formal.html | 6 +++---
docs/site/index.html | 4 ++--
docs/site/measure.html | 10 +++++-----
docs/site/measure.mjs | 2 +-
docs/site/museum.html | 6 +++---
docs/site/museum.mjs | 6 +++---
docs/site/reproduce.html | 4 ++--
docs/site/research.html | 2 +-
docs/site/source-reference.mjs | 17 ++++++++++++-----
docs/site/workspace.html | 6 +++---
tests/test_source_reference.mjs | 18 ++++++++++++++++++
tools/public_shop_browser_check.py | 15 ++++++++++++++-
22 files changed, 89 insertions(+), 51 deletions(-)
diff --git a/docs/site/app.js b/docs/site/app.js
index c2d6009b7..bb03d74a0 100644
--- a/docs/site/app.js
+++ b/docs/site/app.js
@@ -1,6 +1,6 @@
-import {verifiedJSON, verifiedBytes, validateStatus, validateCoefficient, safeSourceURL, hex40, hex64} from './core.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
-import {connectCatalogQuery} from './catalog-query.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
-import {prepareWorkspaceFragment} from './workspace-fragment.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {verifiedJSON, verifiedBytes, validateStatus, validateCoefficient, safeSourceURL, hex40, hex64} from './core.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
+import {connectCatalogQuery} from './catalog-query.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
+import {prepareWorkspaceFragment} from './workspace-fragment.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
const finishFragment=prepareWorkspaceFragment();
const el=id=>document.getElementById(id);
const node=(tag,text,cls)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;if(cls)n.className=cls;return n;};
diff --git a/docs/site/brand.css b/docs/site/brand.css
index fd26e8dad..cf73f4505 100644
--- a/docs/site/brand.css
+++ b/docs/site/brand.css
@@ -58,7 +58,7 @@ body > header {
color: var(--ul-text); font-weight: 750; letter-spacing: .13em;
position: relative; padding-left: 57px; min-height: 44px; line-height: 1.65;
}
-.brand::before { content: ""; position: absolute; left: 0; top: 1px; width: 42px; height: 42px; background: url("brand/mark.svg?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a") center/contain no-repeat; }
+.brand::before { content: ""; position: absolute; left: 0; top: 1px; width: 42px; height: 42px; background: url("brand/mark.svg?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404") center/contain no-repeat; }
.brand span { color: var(--ul-muted); font-size: 10px; letter-spacing: .18em; }
nav { gap: 12px 24px; flex-wrap: wrap; }
nav a { color: var(--ul-text); min-height: 36px; display: inline-flex; align-items: center; font-size: 13px; }
diff --git a/docs/site/cite.html b/docs/site/cite.html
index 3505b5da9..9c2786dba 100644
--- a/docs/site/cite.html
+++ b/docs/site/cite.html
@@ -4,8 +4,8 @@
Cite · Universal Law
-
-
+
+
Skip to content
Reproduce Cite
diff --git a/docs/site/cite.mjs b/docs/site/cite.mjs
index cc45a94ef..df27f1b38 100644
--- a/docs/site/cite.mjs
+++ b/docs/site/cite.mjs
@@ -1,4 +1,4 @@
-import {wireReferenceForm} from './source-reference.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {wireReferenceForm} from './source-reference.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
const byId = id => document.getElementById(id);
wireReferenceForm({form:byId('reference-form'), repository:byId('reference-repository'), commit:byId('reference-commit'), path:byId('reference-path'), sha256:byId('reference-sha256'), output:byId('reference-output'), json:byId('reference-json'), link:byId('reference-link'), status:byId('reference-status'), actions:byId('reference-actions'), copyText:byId('reference-copy'), copyJSON:byId('reference-copy-json'), share:byId('reference-share'), clipboard:globalThis.navigator?.clipboard, location:globalThis.location, history:globalThis.history, events:globalThis.window});
byId('reference-builder').hidden = false;
diff --git a/docs/site/conditionals.mjs b/docs/site/conditionals.mjs
index 94596c991..4390da8ed 100644
--- a/docs/site/conditionals.mjs
+++ b/docs/site/conditionals.mjs
@@ -93,7 +93,7 @@ export function renderProjection(document,host,data,source){
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?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a');
+const services=()=>import('./museum.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404');
// 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.
diff --git a/docs/site/dependencies.html b/docs/site/dependencies.html
index 2b70ac7b2..7ff3645ee 100644
--- a/docs/site/dependencies.html
+++ b/docs/site/dependencies.html
@@ -7,11 +7,11 @@
Claim dependency viewer · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/dependencies.mjs b/docs/site/dependencies.mjs
index 92d75fc31..2c21ece81 100644
--- a/docs/site/dependencies.mjs
+++ b/docs/site/dependencies.mjs
@@ -10,7 +10,7 @@ import {
normalizeSelection,
parsePinnedGraph,
unresolvedTargets,
-} from './dependency-model.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+} from './dependency-model.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
const byId = id => document.getElementById(id);
diff --git a/docs/site/explore-models.mjs b/docs/site/explore-models.mjs
index 0f22daca5..ae44e4878 100644
--- a/docs/site/explore-models.mjs
+++ b/docs/site/explore-models.mjs
@@ -1,6 +1,6 @@
// NON-CERTIFYING educational arithmetic. These functions illustrate source
// definitions; they do not simulate a field or estimate a theorem's constants.
-import { annulusModel, p15Model, remoteModel } from './geometry.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import { annulusModel, p15Model, remoteModel } from './geometry.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
function finite(value, name) {
if (!Number.isFinite(value)) throw new RangeError(`${name} must be finite`);
diff --git a/docs/site/explore.html b/docs/site/explore.html
index b181c329c..3518a58a5 100644
--- a/docs/site/explore.html
+++ b/docs/site/explore.html
@@ -7,11 +7,11 @@
Explore the mathematics · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/explore.mjs b/docs/site/explore.mjs
index 069e35e06..9cb6efbd5 100644
--- a/docs/site/explore.mjs
+++ b/docs/site/explore.mjs
@@ -1,5 +1,5 @@
-import { coneModel, pinModel, paletteModel } from './explore-models.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
-import { readExploreState, exploreStateURL } from './explore-state.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import { coneModel, pinModel, paletteModel } from './explore-models.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
+import { readExploreState, exploreStateURL } from './explore-state.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
const ns = 'http://www.w3.org/2000/svg';
const byId = id => document.getElementById(id);
diff --git a/docs/site/formal.html b/docs/site/formal.html
index 3c3f6097d..a946d8b74 100644
--- a/docs/site/formal.html
+++ b/docs/site/formal.html
@@ -4,9 +4,9 @@
Formal verification · Universal Law
-
-
-
+
+
+
diff --git a/docs/site/index.html b/docs/site/index.html
index f6e9ddfd5..9126745f8 100644
--- a/docs/site/index.html
+++ b/docs/site/index.html
@@ -4,8 +4,8 @@
Universal Law · The shape of randomness
-
-
+
+
Skip to content
diff --git a/docs/site/measure.html b/docs/site/measure.html
index bae81c321..4e4c6166a 100644
--- a/docs/site/measure.html
+++ b/docs/site/measure.html
@@ -7,11 +7,11 @@
From counts to density · Universal Law
-
-
-
-
-
+
+
+
+
+
Skip to content
diff --git a/docs/site/measure.mjs b/docs/site/measure.mjs
index 518b1ed6c..24d8dd951 100644
--- a/docs/site/measure.mjs
+++ b/docs/site/measure.mjs
@@ -1,4 +1,4 @@
-import { measurementModel, parseMeasurementInputs } from './measurement-model.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import { measurementModel, parseMeasurementInputs } from './measurement-model.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
const byId = id => document.getElementById(id);
const fields = Object.fromEntries(['count', 'realizations', 'lower', 'upper'].map(name => [name, byId(`measure-${name}`)]));
diff --git a/docs/site/museum.html b/docs/site/museum.html
index b301282b9..193ad795a 100644
--- a/docs/site/museum.html
+++ b/docs/site/museum.html
@@ -4,11 +4,11 @@
Source records & exhibits · Universal Law
-
+
-
-
+
+
diff --git a/docs/site/museum.mjs b/docs/site/museum.mjs
index 21e87aba8..e77c7af6c 100644
--- a/docs/site/museum.mjs
+++ b/docs/site/museum.mjs
@@ -1,5 +1,5 @@
-import {renderSourceQuote} from './source-quote.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
-import {verifiedBytes, hex40, hex64} from './core.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a';
+import {renderSourceQuote} from './source-quote.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
+import {verifiedBytes, hex40, hex64} from './core.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404';
export const DISCLAIMER='This canvas explains the pinned source. It is not a proof and does not change status.';
const REVIEWED_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'];
@@ -247,7 +247,7 @@ function prepareClaimFragment(document,window,currentHash) {
return true;
};
}
-export async function startMuseum({document=globalThis.document,window=globalThis.window,fetcher=globalThis.fetch,search=globalThis.location?.search||'',geometryLoader=()=>import('./geometry.mjs?site-release=800883be52a6541f3722bc1d034dabeed1ca56fc758d08535c0714aad2d0c44a'),currentHash=()=>globalThis.location?.hash||''}={}){
+export async function startMuseum({document=globalThis.document,window=globalThis.window,fetcher=globalThis.fetch,search=globalThis.location?.search||'',geometryLoader=()=>import('./geometry.mjs?site-release=59ae2f18050fb2edc3d40738450b9137e3570730af2ff09026589b086d78c404'),currentHash=()=>globalThis.location?.hash||''}={}){
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];}));
const finishFragment=prepareClaimFragment(document,window,currentHash);
diff --git a/docs/site/reproduce.html b/docs/site/reproduce.html
index 46db32463..1b85dd222 100644
--- a/docs/site/reproduce.html
+++ b/docs/site/reproduce.html
@@ -4,9 +4,9 @@
Reproduce · Universal Law
-
+
-
+
Skip to content
Reproduce Cite
diff --git a/docs/site/research.html b/docs/site/research.html
index b100e7032..29044cebf 100644
--- a/docs/site/research.html
+++ b/docs/site/research.html
@@ -4,7 +4,7 @@
Research · Universal Law
-
+
Skip to content
Reproduce Cite
diff --git a/docs/site/source-reference.mjs b/docs/site/source-reference.mjs
index b1b9d4ad9..f280f8248 100644
--- a/docs/site/source-reference.mjs
+++ b/docs/site/source-reference.mjs
@@ -23,6 +23,9 @@ const STATE_KEYS = ['repo', 'commit', 'path', 'sha256'];
export function readReferenceState(search) {
const params = new URLSearchParams(search);
if (!STATE_KEYS.some(key => params.has(key))) return null;
+ // URLSearchParams replaces invalid UTF-8. Exact source paths must not be repaired silently.
+ try { decodeURIComponent(search); }
+ catch { throw new Error('The shared link has malformed URL encoding. Enter the source identity again.'); }
for (const key of STATE_KEYS) if (params.getAll(key).length > 1) throw new Error('The shared link has duplicate source fields. Enter the identity again.');
const state = {repository: params.get('repo'), commit: params.get('commit'), path: params.get('path') || '', sha256: params.get('sha256') || ''};
buildReference(state.repository, state.commit, state.path, state.sha256);
@@ -39,7 +42,7 @@ export function referenceStateURL(href, state) {
return url.href;
}
export function wireReferenceForm({form, repository, commit, path, sha256, output, json, link, status, actions, copyText, copyJSON, share, clipboard, location, history, events}) {
- let current = null, revision = 0;
+ let current = null, revision = 0, copying = false;
const copyButtons = [copyText, copyJSON].filter(Boolean);
const canCopy = typeof clipboard?.writeText === 'function';
const setCopy = enabled => copyButtons.forEach(button => { button.disabled = !enabled; });
@@ -59,8 +62,9 @@ export function wireReferenceForm({form, repository, commit, path, sha256, outpu
link.href = current.url; link.textContent = 'Open this exact source on GitHub ↗'; link.hidden = false;
if (actions) actions.hidden = false;
if (share && location) { share.href = referenceStateURL(location.href, state); share.hidden = false; }
- setCopy(canCopy);
+ setCopy(canCopy && !copying);
status.textContent = 'Reference built locally. Source existence, supplied hash, authorship and review status are not checked.' + (canCopy ? '' : ' Select the text or JSON and copy it manually.');
+ if (copying) status.textContent += ' A previous copy is still finishing; copying is temporarily disabled.';
};
form.addEventListener('input', clear);
form.addEventListener('change', clear);
@@ -75,15 +79,18 @@ export function wireReferenceForm({form, repository, commit, path, sha256, outpu
} catch (error) { status.textContent = error.message; }
});
for (const [button, key] of [[copyText, 'text'], [copyJSON, 'json']]) button?.addEventListener('click', async () => {
- if (!current || !canCopy || button.disabled) return;
+ if (!current || !canCopy || copying || button.disabled) return;
const started = revision, text = current[key];
- setCopy(false); status.textContent = 'Copying source reference…';
+ copying = true; setCopy(false); status.textContent = 'Copying source reference…';
try {
await clipboard.writeText(text);
if (started === revision) status.textContent = `Copied ${key === 'json' ? 'JSON' : 'source reference'}. The source and supplied hash are not verified.`;
} catch {
if (started === revision) status.textContent = 'Clipboard unavailable. Select the text or JSON and copy it manually. The source is not verified.';
- } finally { if (started === revision) setCopy(canCopy); }
+ } finally {
+ copying = false; setCopy(Boolean(current) && canCopy);
+ if (started !== revision && current) status.textContent = 'Previous copy finished. Copy the current reference when ready. The source and supplied hash are not verified.';
+ }
});
const restore = () => {
clear(); repository.value = 'main'; commit.value = ''; path.value = ''; if (sha256) sha256.value = '';
diff --git a/docs/site/workspace.html b/docs/site/workspace.html
index 5af7a5621..c80b1f968 100644
--- a/docs/site/workspace.html
+++ b/docs/site/workspace.html
@@ -4,9 +4,9 @@
Research workspace · Universal Law
-
-
-
+
+
+
diff --git a/tests/test_source_reference.mjs b/tests/test_source_reference.mjs
index 44aee6787..1a763a186 100644
--- a/tests/test_source_reference.mjs
+++ b/tests/test_source_reference.mjs
@@ -131,3 +131,21 @@ test('clipboard rejection and delayed completion do not claim a stale copy succe
d.path.value='new.md';d.form.listeners.input();finish();await pending;
assert.equal(d.actions.hidden,true);assert.equal(d.copyJSON.disabled,true);assert.doesNotMatch(d.status.textContent,/Copied/);
});
+
+test('rejects malformed percent and UTF-8 links rather than substituting source path bytes',()=>{
+ for(const path of ['%FF','%C0%AF','%ED%A0%80','bad%','bad%2','%GG']) {
+ assert.throws(()=>refs.readReferenceState(`?repo=main&commit=${sha}&path=${path}`),path);
+ }
+});
+test('a pending clipboard operation prevents a newer reference from overtaking it',async()=>{
+ const writes=[];let resolveA;
+ const c=referenceControls({writeText(text){writes.push(text);return writes.length===1?new Promise(r=>{resolveA=r;}):Promise.resolve();}});
+ wireReferenceForm(c);c.submit();const a=c.copyText.listeners.click();
+ c.path.value='B.md';c.form.listeners.input();c.submit();
+ assert.equal(c.copyJSON.disabled,true);
+ await c.copyJSON.listeners.click();assert.equal(writes.length,1);
+ resolveA();await a;assert.equal(c.copyJSON.disabled,false);
+ assert.doesNotMatch(c.status.textContent,/Copied JSON/);
+ await c.copyJSON.listeners.click();assert.equal(writes.length,2);
+ assert.equal(JSON.parse(writes[1]).path,'B.md');assert.match(c.status.textContent,/Copied JSON/);
+});
diff --git a/tools/public_shop_browser_check.py b/tools/public_shop_browser_check.py
index fb8dbfedb..9cdfa3606 100644
--- a/tools/public_shop_browser_check.py
+++ b/tools/public_shop_browser_check.py
@@ -314,7 +314,20 @@ def check_source_card_flow(page, origin, expect, result, output):
expect(page.locator("#reference-status")).to_contain_text("Shared reference unavailable")
expect(page.locator("#reference-output")).to_be_empty()
expect(page.locator("#reference-actions")).to_be_hidden()
- page.add_init_script("const mode=sessionStorage.getItem('reference-clipboard-test');if(mode)Object.defineProperty(navigator,'clipboard',{configurable:true,value:mode==='deny'?{writeText:async()=>{throw new Error('denied')}}:undefined})")
+ page.goto(origin+f"cite.html?repo=main&commit={commit}&path=%FF#reference-builder")
+ expect(page.locator("#reference-status")).to_contain_text("malformed URL encoding")
+ expect(page.locator("#reference-output")).to_be_empty()
+ page.add_init_script("const mode=sessionStorage.getItem('reference-clipboard-test');if(mode)Object.defineProperty(navigator,'clipboard',{configurable:true,value:mode==='deny'?{writeText:async()=>{throw new Error('denied')}}:mode==='defer'?{writeText:text=>new Promise(resolve=>{window.referencePending={text,resolve}})}:undefined})")
+ page.evaluate("sessionStorage.setItem('reference-clipboard-test','defer')")
+ page.goto(shared);copy.click()
+ expect(copy).to_be_disabled()
+ page.locator("#reference-path").fill("README.md")
+ page.locator("#reference-sha256").fill("")
+ page.get_by_role("button",name="Build reference",exact=True).click()
+ expect(page.get_by_role("button",name="Copy JSON",exact=True)).to_be_disabled()
+ page.evaluate("window.referencePending.resolve()")
+ expect(copy).to_be_enabled()
+ expect(page.locator("#reference-status")).to_contain_text("Previous copy finished")
page.evaluate("sessionStorage.setItem('reference-clipboard-test','deny')")
page.goto(shared);copy.click()
expect(page.locator("#reference-status")).to_contain_text("copy it manually")