GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / galaxies-wafers / iterations/37-hidden-wires

Wires and 3 more files

A JavaScript module in the iterations folder of Galaxies Wafers that parses message (`parseMessage`) and counts failures (`countFailures`). Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.

468 lines of JavaScript and HTML and CSS from galaxies-wafers, in 4 files. Topic: Kuiper, cosmos and drawing engines. Section 1217 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Iterations — 37 Hidden Wires render · galaxies-wafers / iterations/37-hidden-wires/app.mjs lines 467–638
  2. Hw render · galaxies-wafers / iterations/37-hidden-wires/hw.css lines 1–45
  3. Iterations — 37 Hidden Wires Page render · galaxies-wafers / iterations/37-hidden-wires/index.html lines 1–69
  4. Wires ingest · galaxies-wafers / iterations/37-hidden-wires/wires.mjs lines 1–182

Iterations — 37 Hidden Wires

A JavaScript module in Galaxies Wafers that draws blocks and compounds, and uses data from GitHub API and the star-maker and stars repositories. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.

rendergalaxies-wafers / iterations/37-hidden-wires/app.mjs · lines 467–638 of 638 (continued from section 1216) · Entry point · pattern endPointer (shared by 2 files)

What it does
It draws blocks and compounds. Defines 39 functions or classes, including $, el, fmt, short, FetchQueue. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
README: "The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/202609151339."
Inputs & outputs
In: data source: star-maker data; data source: stars data; data source: GitHub API; JSON file blocks.json; JSON file compounds.json; JSON file graph.json. Out: canvas drawing.
Downstream impact
Used directly by 1 file: Iterations — 37 Hidden Wires Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/). Reached from 1 other entry point, including Iterations — 46 Chemistry Ledger Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/46-chemistry-ledger/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.
What it achieves
It fetches queue (`FetchQueue`), fetches once (`fetchOnce`) and updates ui state (`updateUIState`). Loading in Grid Atlas grammar, drawing on one canvas, one card re-filled. It responds to change, click and pointerdown events.
Why it matters
Loaded by the page of the same name at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.
Application
galaxies-wafers · iterations/37-hidden-wires · JavaScript module
Uses
Wires (import)
Used by
loaded by Iterations — 37 Hidden Wires Page (script src)
Produces
$, el, fmt, short, FetchQueue, fetchOnce, updateUIState, hydrate, buildNodes, endpointOf, buildWires, wireShown
Defines here
dl, vaccineText, declaredText, fillCard, buildRows, refreshVaccineCells, paintWorkCount, focusWire, paintSummary, paintQuestions
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/37-hidden-wires/app.mjs:467-638 · blob e41fd88b386a826ae6ce127b1f79159fb304fdb4 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: unknown
    const box = document.querySelector('input[data-layer="vaccines"]');
    box.checked = true; RT.vaccines.visible = true; hydrate('vaccines');
  }
  fillCard();
  schedule();
}

/* ── the card: one element, re-filled ───────────────────────────────────── */
function dl(pairs) {
  const d = el('dl');
  for (const [k, v] of pairs) { d.append(el('dt', null, k)); const dd = el('dd'); if (v instanceof Node) dd.append(v); else dd.textContent = v; d.append(dd); }
  return d;
}
function vaccineText(w) {
  if (D.vaccines) {
    const hits = W.vaccineMentions(D.vaccines, w);
    return hits.length ? `yes — ${hits.join(', ')}` : `no — none of ${D.vaccines.length} vaccine file names mentions "${w.failing}" or "${w.needed}"`;
  }
  if (D.vaccineError) return `not known — the cvaa listing did not load: ${D.vaccineError}`;
  return RT.vaccines.loading ? 'LOAD — reading the cvaa vaccine names' : 'WAIT — tick Vaccine names';
}
function declaredText(w) {
  const d = w.decl;
  if (d.declared === null) return `not known — ${d.reason}`;
  if (d.declared) return `yes — block ${d.host} ${d.by}`;
  return `no — block ${d.host} lists ${d.depends} depends_on and ${d.needs} needs; none is ${[...new Set([w.needed, W.camel(w.needed)])].map(x => `"${x}"`).join(' or ')}`;
}

function fillCard() {
  const card = $('card');
  card.textContent = '';
  const sel = S.sel;
  if (!sel) { card.append(el('p', 'dim', 'Tap a dashed wire to read its failure. Tap a dot to read its block.')); return; }
  if (sel.type === 'wire') {
    const w = D.wires.find(x => x.id === sel.id);
    card.append(el('h3', null, `${w.failing} → ${w.needed}`));
    card.append(el('p', 'dim small', w.failing === w.reporter ? `hidden wire from ${w.reporter} to the module it needed` : `hidden wire from ${w.failing}, a module inside ${w.reporter}, to the module it needed`));
    const msg = el('code', 'msg', w.text); card.append(msg);
    const count = el('span', 'big', `${fmt(w.compositions)} compositions`);
    const kinds = Object.entries(w.kinds).map(([k, v]) => `${k} ${fmt(v)}`).join(' · ');
    const stamps = Object.entries(w.stamps).map(([s, r]) => `${s} ${r.min}–${r.max} (${r.set.size} generations)`).join(' · ') || 'no stamped elements';
    const u = w.unplug;
    const unplug = !u.hits ? `not exposed by unplugging: none of the ${u.withHost} unplug compositions containing ${w.hostSymbol || w.reporter} failed with this message`
      : u.suppliers.length ? `${u.hits} of ${u.withHost} unplug compositions containing ${w.hostSymbol} failed with it; each lacks ${u.suppliers.map(s => `${s.symbol} (${D.legend[s.symbol]})`).join(', ')}, and none containing it failed`
      : `${u.hits} of ${u.withHost} unplug compositions containing ${w.hostSymbol} failed with it; no single unplugged element explains all of them`;
    const cand = w.decl.candidates && w.decl.candidates.length && !w.decl.target ? `blocks whose title contains "${w.needed}" (name-match inference): ${w.decl.candidates.map(s => `${s} ${D.idx.bySymbol.get(s).title}`).join('; ')}; ${w.decl.host || 'the host'} depends on ${w.decl.candidateDeps.length ? w.decl.candidateDeps.join(', ') : 'none of them'}` : w.decl.target ? `block ${w.decl.target}` : `  … [line shortened here: 441 characters; full line on GitHub]
    const decay = w.decay ? (w.decay.node ? `${w.decay.elements} elements carry a DECAYS_TO edge to it` : 'graph.json has no decay node with this text') : 'graph.json not read';
    card.append(dl([
      ['failed on it', count],
      ['by kind', kinds],
      ['stars', fmt(w.stars)],
      ['generations', stamps],
      ['register declares it now', declaredText(w)],
      ['needed part in register', cand],
      ['cvaa vaccine name', vaccineText(w)],
      ['unplug evidence', unplug],
      ['graph.json', decay]
    ]));
    return;
  }
  if (sel.type === 'node') {
    const n = NODE_BY_ID.get(sel.id);
    const touching = D.wires.filter(w => w.fromId === n.id || w.toId === n.id || w.hostId === n.id);
    if (n.block) {
      const b = n.block;
      card.append(el('h3', null, `${b.symbol} · ${b.title}`));
      card.append(el('p', 'dim small', b.description || ''));
      const f = (b.files || [])[0];
      card.append(dl([
        ['category / kind', `${b.category} / ${b.kind}`],
        ['functions', `${fmt(b.functions)} (${fmt(b.named_functions)} named)`],
        ['declared depends_on', (b.depends_on || []).length ? b.depends_on.map(d => `${d.symbol} via ${(d.via || []).join(', ')}`).join('; ') : 'none'],
        ['used_by (register)', `${(b.used_by || []).length} blocks`],
        ['hidden wires touching', RT.hidden.loaded ? (touching.length ? touching.map(w => `${w.failing} → ${w.needed} (${fmt(w.compositions)})`).join('; ') : 'none recorded') : 'WAIT — tick Hidden wires'],
        ['first file', f ? `${f.repo} ${f.path} @ ${short(f.commit)}` : 'the register lists no file']
      ]));
    } else {
      card.append(el('h3', null, n.title));
      card.append(el('p', 'dim small', n.kind === 'sat' ? `A module inside ${NODE_BY_ID.get(n.host).title}, named only by its failure message. It has no register block of its own.` : 'Named in a failure message; no register block carries this exact title, so it sits on the outer ring.'));
      card.append(dl([['hidden wires touching', touching.map(w => `${w.failing} → ${w.needed} (${fmt(w.compositions)})`).join('; ') || 'none']]));
    }
    return;
  }
  if (sel.type === 'edge') {
    const e = D.idx.edges[sel.i];
    const a = D.idx.bySymbol.get(e.from), b = D.idx.bySymbol.get(e.to);
    card.append(el('h3', null, `${a.symbol} → ${b.symbol}`));
    card.append(dl([['declared need', `${a.title} depends on ${b.title}`], ['via (register)', e.via.join(', ') || 'not stated'], ['kind', 'declared in blocks.json depends_on; solid line']]));
  }
}

/* ── lists: built once, rows updated in place ───────────────────────────── */
const rowById = new Map();
function buildRows() {
  const ul = $('worklist');
  ul.textContent = '';
  rowById.clear();
  if (!D.wires.length) ul.append(el('li', 'plain', 'EMPTY — no failure message in compounds.json names a needed module.'));
  for (const w of D.wires.slice(0, ROW_CAP)) {
    const li = el('li'), btn = el('button');
    btn.type = 'button';
    const decl = el('span', null, declaredText(w)), vac = el('span', null, vaccineText(w));
    btn.append(el('span', 't', `${w.failing} → ${w.needed}`), el('br'), el('span', 'dim', `${fmt(w.compositions)} compositions · declared: `), decl, el('br'), el('span', 'dim', 'vaccine: '), vac);
    btn.addEventListener('click', () => { if (!RT.hidden.visible) { const box = document.querySelector('input[data-layer="hidden"]'); box.checked = true; RT.hidden.visible = true; } select({ type: 'wire', id: w.id }); focusWire(w); });
    li.append(btn); ul.append(li);
    li.hidden = !wireShown(w);
    rowById.set(w.id, { li, btn, decl, vac });
  }
  if (D.wires.length > ROW_CAP) ul.append(el('li', 'plain dim', `${fmt(D.wires.length - ROW_CAP)} more wires are drawn but not listed (row cap ${ROW_CAP}).`));
  const un = $('unnamed');
  un.textContent = '';
  if (!D.chem.unnamed.length) un.append(el('li', 'plain dim', 'EMPTY — every failure message names a needed module.'));
  for (const m of D.chem.unnamed.slice(0, ROW_CAP)) {
    const li = el('li', 'plain');
    li.append(el('code', null, m.text), el('br'), el('span', 'dim', `${fmt(m.compositions)} compositions · ${Object.entries(m.kinds).map(([k, v]) => `${k} ${fmt(v)}`).join(' · ')} · no "requires the … module" wording, so no far end`));
    un.append(li);
  }
  paintWorkCount();
}
function refreshVaccineCells() { for (const w of D.wires) { const r = rowById.get(w.id); if (r) r.vac.textContent = vaccineText(w); } }
function paintWorkCount() {
  if (!RT.hidden.loaded) return;
  const n = D.wires.filter(wireShown).length;
  $('worktitle').textContent = (S.filter === 'all' ? 'hidden wires' : 'hidden, not yet declared') + ` · ${n}`;
}
function focusWire(w) {
  const [a0, b0, a1, b1] = w.bbox;
  S.view.x = (a0 + a1) / 2; S.view.y = (b0 + b1) / 2;
  S.view.k = clampK(Math.min(W_CSS / ((a1 - a0) * 1.6 + 1), H_CSS / ((b1 - b0) * 1.6 + 1)));
  canvas.scrollIntoView({ block: 'nearest' });
  schedule();
}

/* ── computed prose ─────────────────────────────────────────────────────── */
function paintSummary() {
  const c = D.chem;
  const s = $('summary');
  s.textContent = '';
  const top = c.wires.map(w => `"${w.failing} requires ${w.needed}" on ${fmt(w.compositions)}`).join(', then ');
  s.append(el('b', null, `${fmt(c.failed)} of ${fmt(c.total)} compositions failed`),
    ` (star-maker chemistry, generated ${c.generated_utc}). ${c.messages.length} distinct failure messages; ${c.wires.length} name the module the failing part needed and are drawn as wires, carried by ${fmt(c.withWire)} of the failed compositions (one composition can carry several messages). By compositions: ${top || 'none'}.`);
  $('prov').textContent = `Sources: star-maker chemistry/compounds.json, chemistry/graph.json and CHEMISTRY.md at commit ${STAR_MAKER_COMMIT} (raw.githubusercontent.com); block register ${URL_REGISTER} as served now (generated ${D.idx.generated_utc}); cvaa vaccine names from the GitHub contents API as served now.`;
}

function paintQuestions() {
  if (!D.idx) return;
  const host = D.wires[0] ? D.idx.byTitle.get(D.wires[0].reporter) : null;
  $('q-host').textContent = host ? `${host.symbol}, number ${host.number}` : 'not found by exact title';
  $('q-used').textContent = host ? String((host.used_by || []).length) : 'not known';
  const sup = D.wires.flatMap(w => w.unplug.suppliers.map(s => `unplugging ${s.symbol} (${D.legend[s.symbol]}) exposed "${w.failing} requires ${w.needed}" in every one of ${s.lacking} unplug compositions that kept ${w.hostSymbol} and lacked it`));
  $('q-supplier').textContent = sup.length ? sup.join('; ') : 'no unplug composition singles out a supplier';
  const undeclared = D.wires.filter(w => w.decl.declared === false).length;
  const vacc = D.vaccines ? D.wires.filter(w => !W.vaccineMentions(D.vaccines, w).length).length : null;
  $('q-work').textContent = `${undeclared} of ${D.wires.length} hidden wires are not declared in the register; ${vacc == null ? 'vaccine names not yet read (tick Vaccine names)' : `${vacc} of ${D.wires.length} are named by no cvaa vaccine file`}`;
  $('machine').textContent = `Machine detail · inputs: compounds[].formula (element symbols with generation stamps), compounds[].kind (live, unplug, version, constellation), compounds[].red and amber (star counts), compounds[].decays[].text and .n (failure message, star count) from compounds.json; the Symbols line of CHEMISTRY.md; DECAYS_TO edges of graph.json; blocks[].title, depends_on[].symbol,  … [line shortened here: 1,168 characters; full line on GitHub]
}

try { if (window.matchMedia('(min-width: 900px)').matches) $('questions').open = true; } catch (_) { /* stays collapsed */ }

/* for tests: where things are on screen, and what was drawn */
window.__hw = {
  RT, drawn, fetchLog, queue, get sel() { return S.sel; }, get view() { return { ...S.view }; },
  wires: () => D.wires.map(w => ({ id: w.id, failing: w.failing, needed: w.needed, compositions: w.compositions, declared: w.decl.declared, shown: wireShown(w) })),
  wireScreen(id) {
    const w = D.wires.find(x => x.id === id); if (!w) return null;
    const i = Math.floor(w.pts.length / 4) * 2, r = canvas.getBoundingClientRect();
    return { x: r.left + sx(w.pts[i]), y: r.top + sy(w.pts[i + 1]) };
  },
  panBy(dx, dy) { S.view.x += dx / S.view.k; S.view.y += dy / S.view.k; schedule(); },
  zoomTo(f) { S.view.k = clampK(S.fitK * f); schedule(); }
};
resize();

Hw

A style sheet in the iterations folder of Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.

rendergalaxies-wafers / iterations/37-hidden-wires/hw.css · lines 1–45 of 45 · Entry point

What it does
Side effects: changes the web page (DOM).
Downstream impact
Used directly by 1 file: Iterations — 37 Hidden Wires Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/). Reached from 1 other entry point, including Iterations — 46 Chemistry Ledger Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/46-chemistry-ledger/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
Loaded by the 37 Hidden Wires page at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.
Application
galaxies-wafers · iterations/37-hidden-wires · style sheet
Uses
none found
Used by
loaded by Iterations — 37 Hidden Wires Page (stylesheet)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/37-hidden-wires/hw.css:1-45 · blob fbfa7331e9c77e2e5454aeacbb287c355b35ee21 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
:root{--ink:#d8dee9;--dim:#8b93a7;--ground:#0b0d12;--edge:#1b2030;--lit:#ffd54a;--beam:#5ec8f2;--wire:#efe9dc}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  padding:calc(env(safe-area-inset-top,0px) + .8rem) 1rem calc(env(safe-area-inset-bottom,0px) + 2rem)}
main{max-width:60rem;margin:0 auto}
h1{font-size:14px;letter-spacing:.18em;font-weight:600;margin:0 0 .35rem;color:#fff}
h2{font-size:11px;letter-spacing:.14em;font-weight:400;color:var(--dim);margin:1.2rem 0 .4rem}
p{margin:.35rem 0}
.dim{color:var(--dim)} .small{font-size:11.5px}
a{color:var(--beam)}
code{color:var(--beam);overflow-wrap:anywhere}
q{quotes:"\201C" "\201D"}
.summary{border-left:3px solid var(--wire);padding:.35rem .6rem;background:#10131b;margin:.6rem 0}
.summary b{color:#fff}
.layers{display:grid;gap:.2rem;margin:.6rem 0}
.layer{display:flex;align-items:center;gap:.55rem;min-height:40px;padding:0 .2rem;border-bottom:1px solid var(--edge);cursor:pointer}
.layer input{width:20px;height:20px;accent-color:#d8dee9;flex:none}
.layer span{overflow-wrap:anywhere}
.seg{display:flex;flex-wrap:wrap;gap:.35rem;margin:.5rem 0}
.seg button{font:inherit;color:var(--ink);background:#07080c;border:1px solid var(--edge);border-radius:.35rem;padding:.45rem .6rem;min-height:40px}
.seg button[aria-pressed=true]{border-color:#fff;box-shadow:inset 0 0 0 1px #fff}
.plane{position:relative;margin:.4rem -1rem 0;height:62vh;min-height:320px;max-height:760px;background:#05060a;border-top:1px solid var(--edge);border-bottom:1px solid var(--edge)}
#plane{display:block;width:100%;height:100%;touch-action:none;cursor:crosshair}
.fit{position:absolute;right:.6rem;top:.6rem;font:inherit;color:var(--ink);background:#0b0d12e6;border:1px solid var(--edge);border-radius:.35rem;min-width:44px;min-height:40px}
.drawn{position:absolute;left:.6rem;bottom:.35rem;font-size:10.5px;pointer-events:none}
.card{border:1px solid var(--edge);border-radius:.45rem;background:#10131b;padding:.55rem .7rem;margin:.7rem 0;overflow-wrap:anywhere}
.card h3{margin:0 0 .35rem;font-size:14px;color:#fff;font-weight:600}
.card .msg{display:block;background:#05060a;border:1px solid var(--edge);border-left:3px dashed var(--wire);padding:.4rem .5rem;margin:.35rem 0;color:#fff;font-size:12.5px}
.card dl{display:grid;grid-template-columns:minmax(6.5rem,auto) 1fr;gap:.25rem .7rem;margin:.4rem 0}
.card dt{color:var(--dim)} .card dd{margin:0}
.card .big{font-size:15px;color:#fff;font-weight:600}
.rows{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}
.rows button{all:unset;display:block;box-sizing:border-box;width:100%;cursor:pointer;border:1px solid var(--edge);border-radius:.4rem;background:#07080c;padding:.45rem .55rem;min-height:44px;overflow-wrap:anywhere}
.rows button:focus-visible{outline:1px solid #fff}
.rows button.on{border-color:#fff}
.rows .t{color:#fff}
.rows li.plain{border:1px solid var(--edge);border-radius:.4rem;padding:.45rem .55rem;overflow-wrap:anywhere}
.questions{border:1px solid var(--edge);border-radius:.45rem;background:#10131b;padding:0 .65rem;margin:1.2rem 0 .5rem}
.questions summary{font-size:11px;letter-spacing:.14em;text-transform:uppercase;cursor:pointer;color:var(--beam);min-height:40px;display:flex;align-items:center}
.questions dt{color:#fff;margin-top:.5rem;font-size:12px}
.questions dd{margin:.2rem 0 .6rem;font-size:11.5px;overflow-wrap:anywhere}
.machine{border-left:3px solid var(--beam);padding:.35rem .6rem;background:#07080c;overflow-wrap:anywhere}
footer{margin-top:1.2rem;overflow-wrap:anywhere}
@media (min-width:900px){.plane{margin:.4rem 0 0;border:1px solid var(--edge);border-radius:.45rem}}

Iterations — 37 Hidden Wires Page

A web page in Galaxies Wafers covering substations and cables. Published at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.

rendergalaxies-wafers / iterations/37-hidden-wires/index.html · lines 1–69 of 69 · Entry point

What it does
It draws substations and cables. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain terms in the code: substations, cables. README: "The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/202609151339."
Inputs & outputs
In: form fields (user input). Out: web page.
Downstream impact
Used directly by 1 file: Iterations — 46 Chemistry Ledger Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/46-chemistry-ledger/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.
What it achieves
The README says: The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/.
Why it matters
Loaded by the 46 Chemistry Ledger page at https://ventusltd.github.io/galaxies-wafers/iterations/46-chemistry-ledger/.
Application
galaxies-wafers · iterations/37-hidden-wires · page
Uses
Hw (stylesheet), Galaxies Wafers — Iterations Page (link), Iterations — 37 Hidden Wires (script src)
Used by
linked from Iterations — 46 Chemistry Ledger Page (link)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/37-hidden-wires/index.html:1-69 · blob 71f0391bf4a49ddd688081d015e4cad05ca16480 · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="color-scheme" content="dark">
<title>Hidden Wires</title>
<link rel="icon" href="data:,">
<link rel="stylesheet" href="hw.css">
</head>
<body>
<main>
  <header>
    <h1>HIDDEN WIRES</h1>
    <p class="dim">A hidden wire is a need a part never declared, found by unplugging or swapping parts and watching what breaks. Each dot is a block in the public block register. Each dashed wire is a recorded failure that names the module the failing part needed, drawn from that part to the module, as thick as the number of compositions that failed on it. Solid cased lines are the needs the regi  … [line shortened here: 418 characters; full line on GitHub]
    <p id="summary" class="summary">WAIT — nothing is fetched until you tick a layer. Tick <b>Hidden wires</b> to begin.</p>
  </header>

  <section class="layers" aria-label="Layers">
    <label class="layer"><input type="checkbox" data-layer="hidden"><span id="lbl-hidden" data-base-label="Hidden wires · star-maker failures">Hidden wires · star-maker failures [WAIT]</span></label>
    <label class="layer"><input type="checkbox" data-layer="declared"><span id="lbl-declared" data-base-label="Declared needs · register depends_on">Declared needs · register depends_on [WAIT]</span></label>
    <label class="layer"><input type="checkbox" data-layer="parts"><span id="lbl-parts" data-base-label="Parts · block register">Parts · block register [WAIT]</span></label>
    <label class="layer"><input type="checkbox" data-layer="vaccines"><span id="lbl-vaccines" data-base-label="Vaccine names · cvaa">Vaccine names · cvaa [WAIT]</span></label>
  </section>

  <div class="seg" id="filter" role="group" aria-label="Which wires">
    <button type="button" data-f="all" aria-pressed="true">all hidden wires</button>
    <button type="button" data-f="undeclared" aria-pressed="false">hidden, not yet declared</button>
  </div>

  <div class="plane">
    <canvas id="plane" aria-label="Parts and wires. Drag to pan, pinch or wheel to zoom, tap a wire or a dot to read it."></canvas>
    <button type="button" id="fit" class="fit">fit</button>
    <div id="drawn" class="drawn dim"></div>
  </div>

  <section id="card" class="card" aria-live="polite">
    <p class="dim">Tap a dashed wire to read its failure. Tap a dot to read its block.</p>
  </section>

  <h2>WORK LIST · <span id="worktitle">hidden wires</span></h2>
  <ul id="worklist" class="rows"><li class="dim">WAIT — tick Hidden wires.</li></ul>

  <h2>FAILURES THAT NAME NO NEEDED PART</h2>
  <p class="dim small">Not drawn: the message does not say which module was missing, so no wire can be drawn without inventing its far end.</p>
  <ul id="unnamed" class="rows"><li class="dim">WAIT — tick Hidden wires.</li></ul>

  <details id="questions" class="questions">
    <summary>Questions</summary>
    <dl>
      <dt>1. How does this help draw a system or a single-line diagram?</dt>
      <dd>It draws no busbar, feeder, transformer, cable route, protection or earthing itself. It shows why the part that draws the single-line panel stops before drawing anything. In gridatlas commit <code>ece848117a6d</code>, <code>atlas/cartridges/202609080850-sld-sandbox-v9-8.js</code> throws <q>sld-sandbox requires the sld-styles module</q> at line 1581 when <code>window.__GRIDATLAS_MODULES__  … [line shortened here: 1,030 characters; full line on GitHub]
      <dt>2. What is this code used for?</dt>
      <dd>This page: <code>wires.mjs</code> <code>parseMessage</code>, <code>countFailures</code>, <code>unplugSuppliers</code>, <code>decayEdges</code>, <code>registerIndex</code>, <code>declaredNow</code>, <code>vaccineMentions</code>, <code>layout</code>; drawn by <code>app.mjs</code> on one canvas. It reads star-maker <code>chemistry/compounds.json</code>, <code>chemistry/graph.json</code> and  … [line shortened here: 1,132 characters; full line on GitHub]
      <dt>3. Where does it lead next?</dt>
      <dd>To the substation-intelligence cartridge, which carries both needed modules (header above) and which the unplug compositions single out: <span id="q-supplier">not yet known</span>. star-maker's README says each hidden wire <q>becomes a declared NEEDS in the next composition manifest and a cvaa vaccine</q>. Measured now: <span id="q-work">not yet known</span>.</dd>
    </dl>
  </details>
  <p id="machine" class="machine small">Machine detail · not yet known: tick Hidden wires.</p>

  <footer class="dim small">
    <p id="loadingrule">Loading, as Grid Atlas does it: every layer starts hidden and unfetched; ticking it fetches its files through one queue of at most 3 requests, each with a 15 s timeout; a file shared by two layers is fetched once; a failed fetch can be retried by ticking again; unticking hides and keeps the data. Each source is one whole file, so there are no tiles: at most 5 files are ever  … [line shortened here: 641 characters; full line on GitHub]
    <p id="prov"></p>
    <p>Wire colour is one neutral tone for every wire: a failure is not a verdict. <a href="../">every version</a></p>
  </footer>
</main>
<script type="module" src="app.mjs"></script>
</body>
</html>

Wires

A JavaScript module in the iterations folder of Galaxies Wafers that parses message (`parseMessage`) and counts failures (`countFailures`). Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/.

ingestgalaxies-wafers / iterations/37-hidden-wires/wires.mjs · lines 1–182 of 182 · pattern curve (shared by 3 files)

What it does
It lists and searches its content. Defines 13 functions or classes, including parseMessage, tokens, legend, countFailures, unplugSuppliers.
Downstream impact
Used directly by 1 file: Iterations — 37 Hidden Wires (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/). Reached from 2 other entry points, including Iterations — 37 Hidden Wires Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/37-hidden-wires/); Iterations — 46 Chemistry Ledger Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/46-chemistry-ledger/).
What it achieves
It parses message (`parseMessage`), counts failures (`countFailures`) and registers index (`registerIndex`). The arithmetic of Hidden Wires, with no DOM and no fetch.
Why it matters
Imported by Iterations — 37 Hidden Wires.
Application
galaxies-wafers · iterations/37-hidden-wires · JavaScript module
Uses
none found
Used by
imported by Iterations — 37 Hidden Wires (import)
Produces
parseMessage, tokens, legend, countFailures, unplugSuppliers, decayEdges, registerIndex, camel, declaredNow, vaccineMentions, GOLDEN, layout
Defines here
parseMessage, tokens, legend, countFailures, unplugSuppliers, decayEdges, registerIndex, camel, declaredNow, vaccineMentions, layout, curve, distToSegment
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/37-hidden-wires/wires.mjs:1-182 · blob 9302bbbc9d492176f0df3d5002a3cd9af291035e · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: unknown
/* wires.mjs — the arithmetic of Hidden Wires, with no DOM and no fetch.
   Every number the page prints about a failure is computed here from the
   files as served; nothing is typed. The tests import this same file. */

/* A failure message in compounds.json reads "<reporting part>: <text>".
   It names a hidden wire only when the text says "<X> requires the <Y> module"
   (the wording of the throw sites in the cartridges). Any other message names
   no needed part, so no wire is drawn for it. */
const NEED = /^(?:[A-Za-z]*Error: )?([a-z0-9][a-z0-9-]*) requires the ([a-z0-9][a-z0-9-]*) module$/;

export function parseMessage(text) {
  const s = String(text);
  const i = s.indexOf(': ');
  if (i < 0) return { text: s, reporter: null, body: s, failing: null, needed: null };
  const reporter = s.slice(0, i), body = s.slice(i + 2);
  const m = body.match(NEED);
  return { text: s, reporter, body, failing: m ? m[1] : null, needed: m ? m[2] : null };
}

/* Formula "Si(202609030137)·Sp·Ss(202609072337)·Ug" -> {Si:'202609030137', Sp:'', ...}.
   An element with no stamp is the generation the composition was cut from. */
export function tokens(formula) {
  const out = {};
  for (const t of String(formula).split('·')) {
    const m = t.match(/^([A-Za-z]+)(?:\((\d+)\))?$/);
    if (m) out[m[1]] = m[2] || '';
  }
  return out;
}

/* The symbol legend in CHEMISTRY.md: "Symbols: **Sp** streaming-parquet-bridge · **Ug** ..." */
export function legend(markdown) {
  const line = String(markdown).split('\n').find(l => /^Symbols:/.test(l));
  const map = {};
  if (!line) return map;
  for (const m of line.matchAll(/\*\*([A-Za-z]+)\*\*\s+([a-z0-9-]+)/g)) map[m[1]] = m[2];
  return map;
}

/* All the counting, one pass over the compounds. */
export function countFailures(doc) {
  const compounds = Array.isArray(doc && doc.compounds) ? doc.compounds : [];
  const byText = new Map();
  let failed = 0, clean = 0, withWire = 0;
  for (const c of compounds) {
    if ((c.red || 0) + (c.amber || 0) > 0) failed++; else clean++;
    if ((c.decays || []).some(d => parseMessage(d.text).needed)) withWire++;
    for (const d of c.decays || []) {
      let w = byText.get(d.text);
      if (!w) { w = { ...parseMessage(d.text), compositions: 0, stars: 0, kinds: {}, stamps: {} }; byText.set(d.text, w); }
      w.compositions++;
      w.stars += d.n || 0;
      w.kinds[c.kind] = (w.kinds[c.kind] || 0) + 1;
      for (const [s, stamp] of Object.entries(tokens(c.formula))) {
        if (!stamp) continue;
        const r = (w.stamps[s] ||= { min: stamp, max: stamp, set: new Set() });
        if (stamp < r.min) r.min = stamp;
        if (stamp > r.max) r.max = stamp;
        r.set.add(stamp);
      }
    }
  }
  const messages = [...byText.values()].sort((a, b) => b.compositions - a.compositions || (a.text < b.text ? -1 : 1));
  messages.forEach((m, i) => { m.id = 'w' + i; });
  return {
    total: compounds.length, failed, clean, withWire, generated_utc: doc && doc.generated_utc, stars: doc && doc.stars,
    messages,
    wires: messages.filter(m => m.needed),
    unnamed: messages.filter(m => !m.needed)
  };
}

/* Unplug evidence. Among compositions of kind "unplug" that contain the host
   element (the element whose legend name is the reporting part), an element E
   is a supplier by unplug when every such composition lacking E failed with
   the message and none containing E did. */
export function unplugSuppliers(doc, text, hostSymbol, symbols) {
  const un = ((doc && doc.compounds) || []).filter(c => c.kind === 'unplug')
    .map(c => ({ tk: tokens(c.formula), hit: (c.decays || []).some(d => d.text === text) }));
  const withHost = hostSymbol ? un.filter(u => hostSymbol in u.tk) : [];
  const hits = withHost.filter(u => u.hit).length;
  const suppliers = [];
  if (hits) {
    for (const e of symbols) {
      if (e === hostSymbol) continue;
      const lacking = withHost.filter(u => !(e in u.tk)), having = withHost.filter(u => e in u.tk);
      if (lacking.length && lacking.every(u => u.hit) && having.every(u => !u.hit)) suppliers.push({ symbol: e, lacking: lacking.length, having: having.length });
    }
  }
  return { suppliers, unplugs: un.length, withHost: withHost.length, hits };
}

/* graph.json: is there a decay node for this message, and how many elements
   carry a DECAYS_TO edge into it. */
export function decayEdges(graph, text) {
  if (!graph || !Array.isArray(graph.edges)) return null;
  const node = (graph.nodes || []).some(n => n.type === 'decay' && n.label === text);
  const from = new Set();
  for (const e of graph.edges) if (e.kind === 'DECAYS_TO' && e.to === text) from.add(e.from);
  return { node, elements: from.size };
}

/* The register, read as it is now. */
export function registerIndex(reg) {
  const blocks = Array.isArray(reg && reg.blocks) ? reg.blocks : [];
  const bySymbol = new Map(), byTitle = new Map();
  for (const b of blocks) { bySymbol.set(b.symbol, b); if (!byTitle.has(b.title)) byTitle.set(b.title, b); }
  const edges = [];
  for (const b of blocks) for (const d of b.depends_on || []) if (bySymbol.has(d.symbol)) edges.push({ from: b.symbol, to: d.symbol, via: d.via || [] });
  return { blocks, bySymbol, byTitle, edges, generated_utc: reg && reg.generated_utc };
}

export const camel = s => String(s).replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());

/* Does the register now declare that <host> needs <needed>?
   yes when the host block's depends_on names a block titled exactly the needed
   part, or the host block's needs lists the needed part by name (as written,
   or in the camelCase the cartridges use for module keys). */
export function declaredNow(idx, hostTitle, needed) {
  const host = idx.byTitle.get(hostTitle) || null;
  const candidates = idx.blocks.filter(b => String(b.title).toLowerCase().includes(needed.toLowerCase())).map(b => b.symbol);
  if (!host) return { host: null, declared: null, reason: `no register block is titled "${hostTitle}"`, candidates, candidateDeps: [] };
  const target = idx.byTitle.get(needed) || null;
  const dep = (host.depends_on || []).find(d => (target && d.symbol === target.symbol) || d.title === needed);
  const need = (host.needs || []).find(n => n.name === needed || n.name === camel(needed));
  const candidateDeps = (host.depends_on || []).filter(d => candidates.includes(d.symbol)).map(d => d.symbol);
  return {
    host: host.symbol, declared: Boolean(dep || need),
    by: dep ? `depends_on ${dep.symbol}` : need ? `needs "${need.name}"` : null,
    target: target ? target.symbol : null, candidates, candidateDeps,
    depends: (host.depends_on || []).length, needs: (host.needs || []).length
  };
}

/* cvaa vaccine file names that mention either end of a wire. */
export function vaccineMentions(names, wire) {
  const terms = [wire.needed, wire.failing, wire.needed && camel(wire.needed), wire.failing && camel(wire.failing)]
    .filter(Boolean).map(s => s.toLowerCase());
  return names.filter(n => terms.some(t => n.toLowerCase().includes(t)));
}

/* Layout, a pure function of the register order: blocks on a golden-angle
   disc by their position in the register; parts named in failure messages
   that have no register block sit on an outer ring, in name order. */
export const GOLDEN = Math.PI * (3 - Math.sqrt(5));
export function layout(blocks, extraNames, R = 100) {
  const pos = new Map();
  const n = blocks.length;
  blocks.forEach((b, i) => {
    const r = R * Math.sqrt((i + 0.5) / Math.max(1, n)), t = i * GOLDEN;
    pos.set(b.symbol, [r * Math.cos(t), r * Math.sin(t)]);
  });
  const names = [...new Set(extraNames)].sort();
  names.forEach((name, i) => {
    const t = -Math.PI / 2 + (i + 0.5) * (2 * Math.PI / Math.max(1, names.length));
    pos.set('part:' + name, [1.25 * R * Math.cos(t), 1.25 * R * Math.sin(t)]);
  });
  return pos;
}

/* Quadratic curve samples for a wire, bowed to one side so a hidden wire never
   hides under a straight declared line between the same two points. */
export function curve(a, b, bow = 0.22, steps = 24) {
  const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;
  const dx = b[0] - a[0], dy = b[1] - a[1];
  const cx = mx - dy * bow, cy = my + dx * bow;
  const pts = new Float64Array((steps + 1) * 2);
  for (let i = 0; i <= steps; i++) {
    const t = i / steps, u = 1 - t;
    pts[i * 2] = u * u * a[0] + 2 * u * t * cx + t * t * b[0];
    pts[i * 2 + 1] = u * u * a[1] + 2 * u * t * cy + t * t * b[1];
  }
  return pts;
}

export function distToSegment(px, py, ax, ay, bx, by) {
  const dx = bx - ax, dy = by - ay, L = dx * dx + dy * dy;
  let t = L ? ((px - ax) * dx + (py - ay) * dy) / L : 0;
  t = t < 0 ? 0 : t > 1 ? 1 : t;
  const x = ax + t * dx - px, y = ay + t * dy - py;
  return Math.sqrt(x * x + y * y);
}