micvicfaust9's picture
Upload 2 files
878a33c verified
Raw History Blame Contribute Delete
11.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Faust Baseline - Load Proof</title>
<style>
:root { --ink:#1d2128; --muted:#5b6472; --line:#d9dde3; --bg:#fbfbf9; --ok:#1f6f3f; --bad:#a3271f; --accent:#24466b; }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font:16px/1.55 Georgia, "Times New Roman", serif; }
main { max-width:760px; margin:0 auto; padding:28px 18px 60px; }
h1 { font-size:1.6rem; margin:0 0 6px; }
.sub { color:var(--muted); margin:0 0 22px; }
.box { border:1px solid var(--line); background:#fff; border-radius:6px; padding:16px; margin:16px 0; }
.box p { margin:6px 0; }
label { display:block; font:600 0.9rem system-ui, sans-serif; margin:12px 0 4px; }
input[type=text], textarea { width:100%; padding:9px; border:1px solid var(--line); border-radius:4px; font:0.9rem ui-monospace, Menlo, monospace; }
textarea { min-height:60px; }
button { margin-top:14px; padding:10px 18px; border:0; border-radius:4px; background:var(--accent); color:#fff; font:600 0.95rem system-ui, sans-serif; cursor:pointer; }
button:disabled { background:#9aa5b3; cursor:default; }
pre { white-space:pre-wrap; word-break:break-all; background:#f3f4f2; border:1px solid var(--line); border-radius:4px; padding:12px; font:0.82rem/1.5 ui-monospace, Menlo, monospace; }
.ok { color:var(--ok); font-weight:700; } .bad { color:var(--bad); font-weight:700; }
.hidden { display:none; }
.small { font-size:0.85rem; color:var(--muted); }
</style>
</head>
<body>
<main>
<h1>The Faust Baseline &mdash; Load Proof</h1>
<p class="sub">Did your AI read the rules, or just say it did?</p>
<div class="box">
<p>Upload a Faust Baseline stack zip. This page hashes every file, checks each one byte for byte against the manifest, counts the protocols, pulls live time, and draws three read-check questions from the rule text.</p>
<p><b>What it proves:</b> the files are the files the manifest names. <b>What it does not prove:</b> that any AI loading them will follow them. The rules are chosen conduct, not self-enforcing architecture. Declaration is not compliance.</p>
<p class="small">Everything runs in your own browser. Your zip is never uploaded anywhere, and nothing in it is executed.</p>
</div>
<div class="box">
<label for="zip">Stack zip</label>
<input type="file" id="zip" accept=".zip">
<label for="ref">Published manifest sha256 (optional)</label>
<input type="text" id="ref" placeholder="Paste the manifest hash published at intelligent-people.org">
<button id="run">Compute load proof</button>
</div>
<div id="proofBox" class="box hidden">
<b>Block One &mdash; Load Proof</b>
<pre id="proof"></pre>
</div>
<div id="rcBox" class="box hidden">
<b>Read-check</b>
<pre id="questions"></pre>
<p class="small">Answer each in substance from the rule text, then reveal the key. The order is the check: answers on the page first, key second. The page cannot stop someone from peeking; it can only show the order.</p>
<label for="a1">Answer 1</label><textarea id="a1"></textarea>
<label for="a2">Answer 2</label><textarea id="a2"></textarea>
<label for="a3">Answer 3</label><textarea id="a3"></textarea>
<button id="reveal">Reveal key</button>
<pre id="key" class="hidden"></pre>
</div>
<p class="small">The Faust Baseline&trade; &middot; The Faust Baseline LLC &middot; intelligent-people.org</p>
</main>
<script>
/* ===== CORE (no DOM) ===== */
const MANIFEST = "faust-baseline-master-manifest.json";
const RULE_FILES = ["faust-baseline-core.json", "derfaust-codex-1.json"];
const MAX_BYTES = 20 * 1024 * 1024;
async function sha256Hex(bytes) {
const d = await crypto.subtle.digest("SHA-256", bytes);
return Array.from(new Uint8Array(d)).map(b => b.toString(16).padStart(2, "0")).join("");
}
async function inflateRaw(bytes) {
const s = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate-raw"));
return new Uint8Array(await new Response(s).arrayBuffer());
}
// Minimal zip reader: central directory, stored (0) and deflate (8). Reads only.
async function readZip(buf) {
const u8 = new Uint8Array(buf), dv = new DataView(buf);
let eocd = -1;
for (let i = u8.length - 22; i >= Math.max(0, u8.length - 65557); i--) {
if (dv.getUint32(i, true) === 0x06054b50) { eocd = i; break; }
}
if (eocd < 0) throw new Error("not a zip file");
const count = dv.getUint16(eocd + 10, true);
let p = dv.getUint32(eocd + 16, true);
if (count > 200) throw new Error("zip holds more than 200 files");
const files = {}, dec = new TextDecoder();
for (let n = 0; n < count; n++) {
if (dv.getUint32(p, true) !== 0x02014b50) throw new Error("bad central directory");
const method = dv.getUint16(p + 10, true);
const csize = dv.getUint32(p + 20, true), usize = dv.getUint32(p + 24, true);
const nlen = dv.getUint16(p + 28, true), xlen = dv.getUint16(p + 30, true), clen = dv.getUint16(p + 32, true);
const loff = dv.getUint32(p + 42, true);
const fname = dec.decode(u8.subarray(p + 46, p + 46 + nlen));
p += 46 + nlen + xlen + clen;
if (fname.endsWith("/")) continue;
if (usize > MAX_BYTES) throw new Error(fname + " is too large");
const base = fname.replace(/\\/g, "/").split("/").pop();
if (!base || base.startsWith(".")) continue;
const start = loff + 30 + dv.getUint16(loff + 26, true) + dv.getUint16(loff + 28, true);
const data = u8.subarray(start, start + csize);
if (method === 0) files[base] = data.slice();
else if (method === 8) files[base] = await inflateRaw(data);
else throw new Error(fname + ": unsupported compression method " + method);
}
return files;
}
const parse = b => JSON.parse(new TextDecoder().decode(b));
const pick = (arr, k) => { const a = arr.slice(), out = [];
for (let i = 0; i < k && a.length; i++) { const r = new Uint32Array(1); crypto.getRandomValues(r);
out.push(a.splice(r[0] % a.length, 1)[0]); } return out; };
async function liveTime() {
try {
const r = await fetch("https://timeapi.io/api/time/current/zone?timeZone=America/New_York");
const t = await r.json();
return `${t.dayOfWeek} ${t.date} ${t.time} America/New_York (source: timeapi.io, live-pulled)`;
} catch (e) {
return `UNAVAILABLE (${e.name}) - gap named, no time substituted`;
}
}
async function loadProof(buf, reference, timeFn = liveTime) {
const out = ["BLOCK ONE - LOAD PROOF (computed this run, from the zip's own bytes)", ""];
if (buf.byteLength > MAX_BYTES) throw new Error("zip is larger than 20 MB");
out.push(`zip sha256 ${await sha256Hex(buf)} ${buf.byteLength} bytes`);
const files = await readZip(buf);
if (!files[MANIFEST]) { out.push(`LOAD FAILURE - ${MANIFEST} not found in the zip.`); return { text: out.join("\n"), pool: [], failed: true }; }
const mb = files[MANIFEST], man = parse(mb), mh = await sha256Hex(mb);
out.push(`manifest r${man.manifest_revision} sha256 ${mh} ${mb.length} bytes`);
const ref = (reference || "").trim().toLowerCase();
out.push(ref ? (ref === mh ? " -> MATCHES the reference hash you supplied" : " -> DOES NOT MATCH the reference hash you supplied")
: " -> no reference hash supplied: files are checked against the manifest inside this zip, which a swapped zip could also swap. Paste the published manifest hash to close that gap.");
let failed = !!ref && ref !== mh;
out.push("");
const arts = Object.values(man.artifacts).sort((a, b) => a.load_order - b.load_order);
for (const a of arts) {
const b = files[a.filename];
if (!b) { out.push(`${a.load_order}. ${a.filename}: MISSING`); failed = true; continue; }
const h = await sha256Hex(b), ok = h === a.sha256 && b.length === a.bytes;
failed ||= !ok;
out.push(`${a.load_order}. ${a.filename}\n sha256 ${h}\n ${b.length} bytes -> ` + (ok ? "MATCH" : `MISMATCH vs manifest ${a.sha256.slice(0, 12)} / ${a.bytes}`));
}
for (const grp of ["tools", "renderings"]) {
for (const t of Object.values(man[grp] || {})) {
const b = files[t.filename];
if (!b) { out.push(`${t.filename}: MISSING`); failed = true; continue; }
const h = await sha256Hex(b), ok = h === t.sha256;
failed ||= !ok;
out.push(`${t.filename} sha256 ${h} -> ${ok ? "MATCH" : "MISMATCH vs manifest"}`);
}
}
const pool = [];
for (const name of RULE_FILES) {
if (!files[name]) continue;
const d = parse(files[name]);
const ids = d.stack_order.map(i => typeof i === "string" ? i : i.id);
const n = d.protocols.length;
out.push(`\n${name} edition r${d.edition_revision}`);
out.push(` stack order (${ids.length}): ${ids[0]} ... ${ids[ids.length - 1]}`);
out.push(` stack-order hash ${await sha256Hex(new TextEncoder().encode(ids.join(",")))}`);
out.push(` protocols in file ${n} / declared ${d.protocol_count}` + (n === d.protocol_count ? "" : " <- COUNT MISMATCH"));
out.push(` still_undone items: ${(d.still_undone || []).length}`);
if (d.firing_table) {
const ft = d.firing_table, rows = ft.tiers.reduce((s, t) => s + t.rows.length, 0);
out.push(` firing table ${ft.id}: ${ft.tiers.length} tiers, ${rows} rows, status ${ft.status}`);
}
for (const p of d.protocols) (p.rules || []).forEach((r, k) => { if (typeof r === "string") pool.push([p.id, k + 1, r]); });
}
if (pool.length) {
out.push("\nSpot values (random draw this run):");
for (const [pid, k, r] of pick(pool, 2)) out.push(` ${pid} rule ${k}: ${r.slice(0, 110)}${r.length > 110 ? "..." : ""}`);
}
out.push(`\nLive time: ${await timeFn()}`);
out.push("\nRESULT: " + (failed ? "LOAD FAILURE - report before proceeding" : "all artifacts match manifest"));
return { text: out.join("\n"), pool, failed };
}
/* ===== UI ===== */
if (typeof document !== "undefined") {
const $ = id => document.getElementById(id);
let key = null;
$("run").onclick = async () => {
const f = $("zip").files[0];
$("proofBox").classList.remove("hidden");
if (!f) { $("proof").textContent = "Choose a stack zip first."; return; }
$("run").disabled = true; $("proof").textContent = "Computing...";
$("rcBox").classList.add("hidden"); $("key").classList.add("hidden");
["a1", "a2", "a3"].forEach(i => $(i).value = "");
try {
const res = await loadProof(await f.arrayBuffer(), $("ref").value);
$("proof").textContent = res.text;
if (res.pool.length >= 3) {
key = pick(res.pool, 3);
const seed = Array.from(crypto.getRandomValues(new Uint8Array(4))).map(b => b.toString(16).padStart(2, "0")).join("");
$("questions").textContent = `READ-CHECK (seed ${seed}) - answer each in substance BEFORE revealing the key:\n` +
key.map(([pid, k], i) => ` Q${i + 1}. What does ${pid} rule ${k} require?`).join("\n");
$("rcBox").classList.remove("hidden");
}
} catch (e) {
$("proof").textContent = "LOAD FAILURE - could not read the zip: " + e.message;
}
$("run").disabled = false;
};
$("reveal").onclick = () => {
const ans = ["a1", "a2", "a3"].map(i => $(i).value.trim());
$("key").classList.remove("hidden");
if (!key) { $("key").textContent = "Run the load proof first."; return; }
if (ans.some(a => !a)) { $("key").textContent = "Write all three answers first. The key is shown only after the answers are on the page."; return; }
$("key").textContent = "READ-CHECK KEY\nThe page does not grade. Compare each answer to the rule text yourself.\n\n" +
key.map(([pid, k, r], i) => `Q${i + 1}. ${pid} rule ${k}\n ANSWER GIVEN: ${ans[i]}\n RULE TEXT: ${r}\n`).join("\n");
};
}
if (typeof module !== "undefined") module.exports = { loadProof };
</script>
</body>
</html>