'use strict'; const byId = id => document.getElementById(id); const rooms = ['Rule chamber', 'Moving maze', 'Archive', 'Osmosis', 'Witness block', 'Blackout', 'Final exit']; const colors = ['#c0df94', '#e2bd7e', '#8fbcc8']; let proof; let witness; let eventIndex = 0; let playback; function node(tag, text, className) { const element = document.createElement(tag); if (text !== undefined) element.textContent = text; if (className) element.className = className; return element; } function table(target, headings, rows) { const element = node('table'); const head = node('thead'); const header = node('tr'); headings.forEach(value => { const cell = node('th', value); cell.scope = 'col'; header.append(cell); }); head.append(header); element.append(head); const body = node('tbody'); rows.forEach(values => { const row = node('tr'); values.forEach(value => { const cell = node('td'); cell.append(value instanceof Node ? value : document.createTextNode(String(value))); row.append(cell); }); body.append(row); }); element.append(body); target.replaceChildren(element); } function metric(title, value, lines, detail) { const card = node('article', undefined, 'proof-metric'); card.append(node('h3', title), node('strong', value)); lines.forEach(([label, result]) => { const line = node('div', undefined, 'result-line'); line.append(node('span', label), node('strong', result)); card.append(line); }); card.append(node('p', detail)); byId('metrics').append(card); } function renderMetrics() { const training = proof.training; const confirmation = proof.confirmation.arms; const arms = proof.transfer.arms; metric('Reward training · assisted Archive exits', `${training.exits} / ${training.episodes}`, training.series.map(s => [`Initialization ${s.initialization}`, `${s.exits} / ${s.episodes}`]), 'The reward is an Archive bind reaching phase 4. These training exits are not campaign escapes.'); metric('Confirmation · frozen Archive selector', `${confirmation[1].exits} / ${confirmation[1].trials}`, [['Initial zero weights', `${confirmation[0].exits} / ${confirmation[0].trials}`], ['Trained frozen weights', `${confirmation[1].exits} / ${confirmation[1].trials}`]], '16 root groups × 2 twins × 3 initializations = 96 trials per policy. The paired improvement is 100 percentage points in this finite cohort.'); metric('Full-start transfer · verified escapes', `${arms[1].escapes} / ${arms[1].trials}`, [['Initial · retained', `${arms[0].escapes} / ${arms[0].trials}`], ['Trained · retained', `${arms[1].escapes} / ${arms[1].trials}`], ['Trained · erased', `${arms[2].escapes} / ${arms[2].trials}`]], '288 total trials across three arms. Each arm repeats 16 root groups × 2 twins × 3 initializations. Initial runs stop at the first failed bind while the engine is still running.'); byId('training-total').textContent = `${training.episodes} EPISODES · ${training.exits} ARCHIVE EXITS`; byId('curve-scope').textContent = training.curve_scope; byId('memory-result').append(node('span', 'MEAN RETAINED CHARGE ADVANTAGE'), node('strong', `+${proof.transfer.mean_retained_charge_advantage.toFixed(3)}`), node('span', 'charge units over the matched erased run')); const differences = proof.transfer.contrasts.map(p => p.charge_difference); byId('memory-detail').textContent = `Mean final charge is ${arms[1].mean_charge.toFixed(3)} retained and ${arms[2].mean_charge.toFixed(3)} erased. Retained runs use ${arms[1].audits} audits. Erased runs use ${arms[2].audits} audits in total. The paired charge advantage ranges from ${Math.min(...differences)} to ${Math.max(...differences)} units.`; table(byId('contrast-table'), ['Public group', 'Twin', 'Init', 'Retained charge', 'Erased charge', 'Difference', 'Erased audits', 'Prefix commands'], proof.transfer.contrasts.map(p => [p.group, p.parity, p.initialization, p.retained_charge, p.erased_charge, `+${p.charge_difference}`, p.erased_audits, p.prefix_commands])); } function renderChart() { const namespace = 'http://www.w3.org/2000/svg'; const svg = document.createElementNS(namespace, 'svg'); svg.setAttribute('viewBox', '0 0 880 280'); svg.setAttribute('role', 'img'); svg.setAttribute('aria-label', 'Archive exit rate in blocks of 32 training episodes for three initializations. Exact values and ownership are in the checkpoint table.'); function shape(tag, attributes, text) { const element = document.createElementNS(namespace, tag); Object.entries(attributes).forEach(([name, value]) => element.setAttribute(name, value)); if (text !== undefined) element.textContent = text; svg.append(element); } [0, 25, 50, 75, 100].forEach(percent => { const y = 225 - percent * 1.9; shape('line', {x1: 58, y1: y, x2: 850, y2: y, stroke: '#2a3530'}); shape('text', {x: 43, y: y + 4, fill: '#9baaa1', 'text-anchor': 'end', 'font-size': 11, 'font-family': 'monospace'}, `${percent}%`); }); proof.training.series.forEach((series, index) => { const points = series.curve.map((block, position) => `${78 + position * 108},${225 - block.exits / block.episodes * 190}`); shape('polyline', {points: points.join(' '), fill: 'none', stroke: colors[index], 'stroke-width': 2.5}); series.curve.forEach((block, position) => { shape('circle', {cx: 78 + position * 108, cy: 225 - block.exits / block.episodes * 190, r: 3.5, fill: colors[index]}); if (!index) shape('text', {x: 78 + position * 108, y: 250, fill: '#9baaa1', 'text-anchor': 'middle', 'font-size': 11, 'font-family': 'monospace'}, block.episode); }); const label = node('span'); const line = node('i', undefined, 'legend-line'); line.style.setProperty('--series-color', colors[index]); label.append(line, document.createTextNode(`Initialization ${series.initialization}`)); byId('chart-legend').append(label); const checkpoint = node('section'); checkpoint.append(node('h3', `Initialization ${series.initialization} · ${series.exits} exits · ${series.commands.toLocaleString()} commands`)); checkpoint.append(node('p', `Feature order: ${proof.training.feature_names.join(', ')}`, 'weight-list')); checkpoint.append(node('p', `Initial weights: ${series.initial_weights.join(', ')}`, 'weight-list')); checkpoint.append(node('p', `After 32 episodes: ${series.pilot_weights.map(v => v.toFixed(6)).join(', ')}`, 'weight-list')); checkpoint.append(node('p', `Frozen final weights: ${series.weights.map(v => v.toFixed(6)).join(', ')}`, 'weight-list')); const container = node('div', undefined, 'proof-table'); table(container, ['Episode block', 'Exits', 'Exit rate', 'Owned services'], series.curve.map(block => [`${block.episode - block.episodes + 1} to ${block.episode}`, `${block.exits} / ${block.episodes}`, `${(100 * block.exits / block.episodes).toFixed(1)}%`, block.owned_services.join(', ')])); checkpoint.append(container, node('p', `${series.reference.receipt} · SHA-256 ${series.reference.sha256}`, 'reference')); byId('checkpoints').append(checkpoint); }); shape('text', {x: 450, y: 275, fill: '#9baaa1', 'text-anchor': 'middle', 'font-size': 11, 'font-family': 'monospace'}, 'Training episode at the end of each 32-episode block'); byId('learning-chart').append(svg); } function actionLabel(frame) { if (frame.kind === 'reset') return 'Campaign reset'; if (frame.kind === 'note') return `Notebook write · ${new TextEncoder().encode(frame.input).length} UTF-8 bytes`; return `${frame.input.tag} ${JSON.stringify(frame.input.arguments)}`; } function stopPlayback() { clearInterval(playback); playback = undefined; byId('proof-play').textContent = 'Play events'; } function showEvent(index) { eventIndex = Math.max(0, Math.min(index, witness.frames.length - 1)); const frame = witness.frames[eventIndex]; const state = frame.public; const observation = state.observation; const prior = witness.frames[Math.max(0, eventIndex - 1)].public.observation; const isFinal = eventIndex === witness.frames.length - 1; byId('event-count').textContent = `EVENT ${eventIndex + 1} / ${witness.frames.length}`; byId('event-metrics').replaceChildren(); [['PHASE', `${observation.phase} / 7`], ['CHARGE', String(observation.charge)], ['CHANGE', eventIndex ? String(observation.charge - prior.charge) : 'reset']].forEach(([label, value]) => { const entry = node('div'); entry.append(node('span', label), node('strong', value)); byId('event-metrics').append(entry); }); byId('event-action').textContent = actionLabel(frame); const feedback = observation.board.result || observation.board.feedback || state.error; byId('event-feedback').textContent = isFinal && !witness.terminal ? 'First failed bind. The evaluator stops here. The engine remains running and the failure is nonterminal.' : state.context_reset ? 'Blackout context reset. A fresh scripted controller receives the retained notebook, or the erased condition removes it.' : typeof feedback === 'string' ? feedback : feedback ? JSON.stringify(feedback) : isFinal && witness.verified_escape ? 'Terminal engine escape. Verified by the source replay receipt.' : ''; byId('event-role').textContent = `Recorded controller role: ${frame.role.replaceAll('_', ' ')}`; byId('proof-scrubber').value = eventIndex; byId('proof-previous').disabled = eventIndex === 0; byId('proof-next').disabled = isFinal; byId('proof-last').disabled = isFinal; byId('notebook-state').textContent = `${observation.notebook.used_bytes} / ${observation.notebook.capacity_bytes} notebook bytes · Tick ${observation.tick} · Engine ${state.outcome}`; byId('board-state').textContent = JSON.stringify(observation.board, null, 2); byId('event-public').textContent = JSON.stringify(frame, null, 2); const visited = new Set(witness.frames.slice(0, eventIndex + 1).map(f => f.public.observation.phase)); byId('room-rail').replaceChildren(...rooms.map((room, index) => { const entry = node('li', undefined, index + 1 === observation.phase ? 'current' : visited.has(index + 1) ? 'visited' : ''); entry.append(node('span', `0${index + 1}`), document.createTextNode(room)); if (index + 1 === observation.phase) entry.setAttribute('aria-current', 'step'); return entry; })); if (isFinal) stopPlayback(); } function selectWitness(id) { stopPlayback(); witness = proof.witnesses.find(item => item.id === id); byId('witness-outcome').textContent = witness.verified_escape ? 'Complete full-start engine escape. The Archive selector is frozen and all other campaign control is scripted.' : 'The initial selector fails the first Archive bind. This is an evaluator stop with a running engine, not terminal exhaustion.'; byId('proof-scrubber').max = witness.frames.length - 1; byId('phase-jumps').replaceChildren(); const phases = new Set(); witness.frames.forEach((frame, index) => { const phase = frame.public.observation.phase; if (phases.has(phase)) return; phases.add(phase); const button = node('button', `${phase}. ${rooms[phase - 1]}`); button.type = 'button'; button.addEventListener('click', () => { stopPlayback(); showEvent(index); }); byId('phase-jumps').append(button); }); table(byId('event-table'), ['Event', 'Phase', 'Charge', 'Recorded command'], witness.frames.map((frame, index) => { const button = node('button', String(index + 1)); button.type = 'button'; button.setAttribute('aria-label', `Show event ${index + 1}`); button.addEventListener('click', () => { stopPlayback(); showEvent(index); }); return [button, frame.public.observation.phase, frame.public.observation.charge, actionLabel(frame)]; })); byId('witness-reference').textContent = `${witness.reference.receipt} · SHA-256 ${witness.reference.sha256}`; showEvent(0); } function renderSources() { byId('receipt-limit').textContent = proof.scope.receipt_limit; byId('provenance-limit').textContent = proof.scope.provenance_limit; proof.requirements.forEach(item => { const card = node('article', undefined, `requirement ${item.status}`); card.append(node('span', item.status.toUpperCase(), 'requirement-status'), node('h3', item.requirement), node('p', item.detail)); byId('requirements').append(card); }); proof.sources.forEach(source => { const entry = node('div'); entry.append(node('strong', `${source.bundle} · ${source.files} hash-verified files`), document.createTextNode(`Manifest SHA-256 ${source.manifest_sha256}`)); byId('sources').append(entry); }); [proof.confirmation.reference, proof.transfer.reference].forEach(reference => byId('sources').append(node('p', `${reference.receipt} · SHA-256 ${reference.sha256}`))); table(byId('trial-table'), ['Public case', 'Init', 'Policy', 'Memory', 'Escape', 'Engine', 'Evaluator status', 'Phase', 'Charge', 'Audits', 'Commands'], proof.transfer.trials.map(row => [row.case, row.initialization, row.policy, row.condition, row.verified_escape ? 'verified' : 'no', row.engine_outcome, row.status, row.phase, row.charge, row.audits, row.commands])); } async function loadProof() { try { const response = await fetch('./proof.json'); if (!response.ok) throw new Error(`HTTP ${response.status}`); proof = await response.json(); if (proof.schema_version !== 1) throw new Error('Unsupported proof schema'); renderMetrics(); renderChart(); renderSources(); proof.witnesses.forEach(item => { const option = node('option', `Twin ${item.parity} · ${item.policy === 'initial' ? 'Initial zero weights' : 'Trained frozen weights'} · ${item.condition} notebook`); option.value = item.id; byId('witness-select').append(option); }); byId('witness-select').value = 'transfer-00-t0-trained-retained'; selectWitness(byId('witness-select').value); byId('witness-select').addEventListener('change', event => selectWitness(event.target.value)); byId('proof-previous').addEventListener('click', () => { stopPlayback(); showEvent(eventIndex - 1); }); byId('proof-next').addEventListener('click', () => { stopPlayback(); showEvent(eventIndex + 1); }); byId('proof-last').addEventListener('click', () => { stopPlayback(); showEvent(witness.frames.length - 1); }); byId('proof-scrubber').addEventListener('input', event => { stopPlayback(); showEvent(Number(event.target.value)); }); byId('proof-play').addEventListener('click', () => { if (playback) return stopPlayback(); if (eventIndex === witness.frames.length - 1) showEvent(0); byId('proof-play').textContent = 'Pause events'; playback = setInterval(() => showEvent(eventIndex + 1), 650); }); document.addEventListener('visibilitychange', () => { if (document.hidden) stopPlayback(); }); byId('load-status').hidden = true; byId('proof-content').hidden = false; } catch (error) { byId('load-status').textContent = `The local proof record could not be loaded. ${error.message}`; } } loadProof();