GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Kuiper, cosmos and drawing engines / globalgrid2050 / kuiper-grid/i0089/cartridges

Kuiper Chrome and 1 more file

A JavaScript file in the cartridges folder of GlobalGrid2050 that opens sheet (`openSheet`), shows systems (`showSystems`) and groups boxes (`groupBoxes`) (units: mm²), covering cables and substations.

687 lines of JavaScript and HTML from globalgrid2050, in 2 files. Topic: Kuiper, cosmos and drawing engines. Section 1406 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. Kuiper Chrome interaction · globalgrid2050 / kuiper-grid/i0089/cartridges/009200000000-kuiper-chrome.js lines 1–579
  2. Kuiper Grid — I0089 Page render · globalgrid2050 / kuiper-grid/i0089/index.html lines 1–108

Kuiper Chrome

A JavaScript file in the cartridges folder of GlobalGrid2050 that opens sheet (`openSheet`), shows systems (`showSystems`) and groups boxes (`groupBoxes`) (units: mm²), covering cables and substations.

interactionglobalgrid2050 / kuiper-grid/i0089/cartridges/009200000000-kuiper-chrome.js · lines 1–579 of 579 · Not reached from any entry point (candidate for review) · pattern showSystems (shared by 3 files)

What it does
It draws cables and substations. Defines 27 functions or classes, including PHONE, $, el, kick, relayout. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: cables, substations.
What it achieves
It opens sheet (`openSheet`), shows systems (`showSystems`) and marks state (`markState`). A cartridge of the Kuiper shell: HOW THE PAGE IS DRESSED. It responds to click, focus and keydown events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · kuiper-grid/i0089/cartridges · script
Uses
none found
Used by
none found
Produces
PHONE, $, el, kick, relayout, gatherMs, judge, boot, isOpen, shut, loosen, openSheet
Defines here
PHONE, $, el, kick, relayout, gatherMs, judge, boot, isOpen, shut, loosen, openSheet, refire, camera, typed, showSystems, markState, fixChips, devWatch, groupBoxes, keyOfRow, readKey, applyKey, keepMark, filterDrawing, applyMarks, hideWordy
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0089/cartridges/009200000000-kuiper-chrome.js:1-579 · blob 7a23e79af4fdaafae93bc13e54db923d21d68ea5 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
'use strict';
// kuiper-chrome.js - a cartridge of the Kuiper shell: HOW THE PAGE IS DRESSED. What sits over the disc,
// and how much of it. The shell is never edited, so the dressing lives here, where it can be changed.
//
// THE DRAWING FIRST. Vikram, 20 September, looking at his phone: "Can't even see the drawing!", then
// "The drawing should show first. All else should be in the pop up command selector and layout changes
// commands. Keep the view minimalist like the Kuiper, Wafer and Gridatlas", and "Module measurements in
// boxes in tools, not in the drawing". One question decides every line below: ON A 390 PIXEL PHONE, DOES
// THE PICTURE OF BOXES JOINED BY CABLES GET MORE OF THE SCREEN.
//
// WHAT IS ON THE FACE, and nothing else:
//   1. the drawing, edge to edge;
//   2. ONE scrollable row of short chips in the top left - never three rows of wrapped chips;
//   3. one thin RED line across the very top for a solar answer (the whole wording is in the pop-up);
//   4. ONE key line above the bar, with "more", instead of six pinned lines under the drawing;
//   5. one grey foot line, and one bar holding a plain name.
// Everything else - the examples picker, the presets, the declared inputs as number boxes, the answer
// and its figures, the applications, and the LAYOUT CHANGE COMMANDS - is in THE WAFER'S OWN WINDOW,
// which is the pop-up: a bottom sheet on a phone, the draggable window on a desk, CLOSED BY DEFAULT.
//
// NOTHING HERE IS A RIVAL COMPONENT. "You've killed the preset wafer lifted popup bar" was said once and
// is not going to be said again: #pilot, #pin, #eg, #egs, #presets and #say are the wafer's own parts,
// built by the programs cartridge, and this file only MOVES them, DRESSES them and HOOKS them. The
// examples picker is not rebuilt, it is carried into the sheet. The window is not replaced, it is
// restyled. The number boxes are not rebuilt, they are moved into groups, so every listener that was on
// them is still on them. Not one of the wafer's ids, classes or handlers is taken away.
//
// HOW IT HOOKS WITHOUT TOUCHING ANOTHER CARTRIDGE. Classic scripts share one global scope, so the parts
// the programs cartridge declares at the top level - sayOpen, sldShapes, fireLive, reFire, shapeBand,
// stringDrawing, stringNearView, stringWholeView - are reachable from here by name. Three are wrapped:
//   sayOpen       so a fired answer NEVER opens itself over the drawing; the answer chip pulses once.
//   shapeBand     so the band the drawing is laid into stops at the top of the sheet, not under it.
//   stringDrawing so the measurements come off the picture and live in the boxes and the answer.
// Each wrapper calls the original first and changes nothing it computes.
(function () {
  const PHONE = () => innerWidth <= 700;
  const $ = id => document.getElementById(id);
  const el = (tag, cls, t) => { const e = document.createElement(tag); if (cls) e.className = cls; if (t !== undefined) e.textContent = t; return e; };
  const kick = () => { try { if (typeof dirty !== 'undefined') dirty = true; } catch (_) {} };
  const relayout = () => { try { if (typeof layout === 'function') layout(); } catch (_) {} kick(); };

  // ---- THE SEQUENCE: CINEMATIC ON ARRIVAL, NEAR-INSTANT AFTER IT ---------------------------------
  // THE DELAY IS DESIGNED, NOT SLOWNESS. Nothing blocks the thread while it runs; TWO NUMBERS hold the
  // clock, and until now both were fixed for every command of a visit:
  //   the ring sweep   isoAnim.ms, set in isolate() from the fired program's own pulse.seconds
  //                    (FIRE_PROGRAM in kuiper-programs.js: seconds 1.0 -> 1000 ms; a pressed program 1.5 -> 1500 ms)
  //   the gathering    ASM.MOVE_MS, 2000 ms, declared in assemble.mjs beside the shell
  // 1000 + 2000 = 3.0 s before a fired drawing can be read, every single time.
  // ARRIVAL IS WORTH THREE SECONDS; THE SECOND COMMAND IS NOT. The first pulse of a visit keeps the
  // cinematic exactly as it was. Every command after it uses the short pair below. Both numbers are
  // here, named, in one object, so the distinction is a number to change and not a rewrite.
  const SEQUENCE = {
    arrival: { sweepMs: null, gatherMs: null },   // null: whatever the program and the module already say
    after:   { sweepMs: 140,  gatherMs: 220 }     // near-instant: still a move, not a jump cut
  };
  window.KUIPER_SEQUENCE = SEQUENCE;              // one place to tune it, from the console or from a test
  let arrived = false;                            // set by the first pulse of the visit, never reset

  // THE GATHERING. A module's namespace cannot be written to, so ASM is swapped for a copy of itself
  // whose MOVE_MS is asked for every frame. Everything else on it is the module's own function.
  let ASM_MOVE_MS = 2000;
  const gatherMs = () => (arrived && SEQUENCE.after.gatherMs != null) ? SEQUENCE.after.gatherMs : ASM_MOVE_MS;
  try {
    asmReady.then(() => {
      if (typeof ASM === 'undefined' || !ASM || ASM.__kuiperClock) return;
      ASM_MOVE_MS = ASM.MOVE_MS;
      const shim = Object.assign({}, ASM);
      Object.defineProperty(shim, 'MOVE_MS', { get: gatherMs, enumerable: true });
      shim.__kuiperClock = true;
      ASM = shim;
    });
  } catch (_) {}

  // THE RING SWEEP. isolate() sets the length of the sweep from the program it is about to run; this
  // shortens it AFTER the sweep has been set up, so the program's own declared seconds are untouched
  // and the arrival - the first one - runs at its full length.
  try {
    if (typeof isolate === 'function') {
      const origIsolate = isolate;
      isolate = function (name) {
        const out = origIsolate.apply(this, arguments);
        if (!arrived) arrived = true;
        else if (typeof isoAnim !== 'undefined' && isoAnim && SEQUENCE.after.sweepMs != null) isoAnim.ms = SEQUENCE.after.sweepMs;
        return out;
      };
    }
  } catch (_) {}

  // ---- the look ---------------------------------------------------------------------------------
  const css = document.createElement('style');
  css.textContent = `
  /* what 0044 took off the face, still off it */
  #top{display:none !important}
  #foot .long{display:none !important}
  #keys{display:none !important}
  #foot .short{display:block;margin-top:6px;font-size:10px;letter-spacing:.02em;line-height:1.4;color:var(--dim)}
  html,body{overflow-x:hidden}

  /* THE CHIPS ARE ONE BUTTON. A scrolling row of eight was still a row: it held the top of the screen
     and the band the drawing is laid into started under it. There is ONE small button now, "layouts",
     and the presets themselves are in the pop-up it opens - the same pop-up, no new widget. */
  #presets{top:20px !important;left:10px !important;flex-wrap:nowrap !important;overflow-x:auto;overflow-y:hidden;
    max-width:calc(100% - 20px) !important;padding-bottom:2px;scrollbar-width:none;-ms-overflow-style:none;
    -webkit-overflow-scrolling:touch;z-index:19}
  #presets::-webkit-scrollbar{display:none}
  #presets button{flex:0 0 auto;white-space:nowrap}
  #presets button.konly{border-color:#3b4760;color:#cfe3f2}
  #chipapps{display:none}
  #chipanswer{display:none !important}
  #presets button{min-height:26px;padding:2px 9px;font-size:11px}
  #chipmore.pulse{animation:kpulse 1s ease-out 1}
  @keyframes kpulse{0%{box-shadow:0 0 0 0 #5ec8f2aa}70%{box-shadow:0 0 0 9px #5ec8f200}100%{box-shadow:0 0 0 0 #5ec8f200}}

  /* THE RED LINE IS ONE THIN LINE ACROSS THE TOP, not a paragraph pinned under the picture. It carries
     the short wording; the whole sentence is the first thing inside the pop-up. It is never hidden, at
     any zoom and under any window, because it is the only thing on this page that must always be read. */
  #sldnames span.danger{position:fixed;left:0 !important;right:0 !important;top:0 !important;
    width:auto !important;max-width:none !important;transform:none !important;visibility:visible !important;
    text-align:center;padding:2px 8px;font-size:9.5px !important;line-height:1.5;letter-spacing:.04em;
    background:#160b0a;border-bottom:1px solid #4a2019;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

  /* THE SAME RED LINE BEFORE ANYTHING IS DRAWN. The engine writes its warning beside a study, so the
     first screen - the disc, nothing fired - carried no warning at all. This line is the chrome's own,
     it is there from the first paint, and it steps aside the moment the engine's own line appears. */
  #kdev{position:fixed;left:0;right:0;top:0;z-index:9;text-align:center;padding:2px 8px;
    font:9.5px/1.5 ui-monospace,Menlo,Consolas,monospace;font-weight:600;letter-spacing:.04em;color:#ff5a4f;
    background:#160b0a;border-bottom:1px solid #4a2019;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

  /* THE KEY, COLLAPSED, ON EVERY SIZE. The pinned lines under the drawing become one line above the
     bar with "more". On a desk they used to stay pinned, and the band the drawing is laid into was
     shortened by whatever they took - eighty pixels of key under a picture that had asked for the
     screen. One line above the bar says the same thing and costs fifteen. */
  html.kquiet #sldnames span.pinned:not(.danger){display:none !important}
  html.knokey #sldnames span.pinned:not(.danger){display:none !important}
  #keyline{display:none;align-items:baseline;gap:8px;font:10px/1.35 ui-monospace,Menlo,Consolas,monospace;
    color:#8b93a7;padding:0 0 3px;border-bottom:1px solid #141a26;margin-bottom:3px}
  #keyline.on{display:flex}
  #keyline span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  #keyline button{flex:none;background:none;border:0;color:#5ec8f2;font:inherit;text-decoration:underline;cursor:pointer;padding:2px 0}

  /* THE BAR, AND THE FOOT THAT HOLDS IT. Everything below the drawing - the key line, the line that
     says what this is not, and the bar - is a hundred pixels, not two hundred. The drawing gets the
     rest, on a telephone and on a desk. */
  #pilot{margin-top:4px;padding-top:4px}
  #foot{padding:5px 12px !important}
  #foot .short{margin-top:3px;font-size:9px;line-height:1.3}

  /* THE POP-UP. On a phone it is a bottom sheet: it covers at most the lower 60 per cent, it sits ABOVE
     the bar so the bar can still be typed in, the drawing stays whole above it, and a tap outside shuts
     it. Collapsed it is the title bar alone, at the bottom, where it cannot cover the chips. */
  #kt{padding:.5rem .7rem;border-bottom:1px solid #1b2030;background:#0c1017;max-height:46vh;overflow:auto}
  #say.min #kt{display:none}
  #say #saybody{min-height:110px}
  #kt #eg{margin:0 0 6px;border:0;background:none;padding:0}
  #kt #eg select{align-self:stretch;width:auto;max-width:none;min-height:34px}
  #kt details{border-top:1px solid #141a26;padding:4px 0 2px}
  #kt summary{font:11px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;
    color:#8b93a7;cursor:pointer;padding:3px 0;list-style:none}
  #kt summary::-webkit-details-marker{display:none}
  #kt summary::before{content:'+ ';color:#5ec8f2}
  #kt details[open] summary::before{content:'− ';color:#5ec8f2}
  #kt .krow{display:flex;flex-wrap:wrap;gap:5px;margin:3px 0 5px}
  #kt .klab{font:10px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.06em;text-transform:uppercase;
    color:#5b6377;width:100%;margin:2px 0 0}
  #kt button{font:11px/1.6 ui-monospace,Menlo,Consolas,monospace;color:#8b93a7;background:#0b0e14;
    border:1px solid #232a3a;border-radius:4px;padding:3px 9px;cursor:pointer}
  #kt button:hover,#kt button:focus-visible{color:#e6e9f0;border-color:#4a5573;outline:none}
  #kt button.on{color:#eaf6ff;border-color:#5ec8f2}
  #kt p.kdim{margin:.2rem 0;font-size:11px;color:#5b6377;line-height:1.45}
  #kt .kkey p{margin:.25rem 0;font-size:11px;color:#8b93a7;line-height:1.45}

  /* the declared inputs, grouped, so twenty-eight boxes are not one wall */
  #saybody details.kbox{border-top:1px solid #141a26;padding:2px 0}
  #saybody details.kbox summary{font:11px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.08em;
    text-transform:uppercase;color:#8b93a7;cursor:pointer;padding:4px 0;list-style:none}
  #saybody details.kbox summary::-webkit-details-marker{display:none}
  #saybody details.kbox summary::before{content:'+ ';color:#5ec8f2}
  #saybody details.kbox[open] summary::before{content:'− ';color:#5ec8f2}

  @media (max-width:700px){
    #foot{padding:4px 10px !important}
    #foot .short{margin-top:3px;font-size:8.5px;line-height:1.25}
    #presets{top:20px !important;gap:5px}
    #presets button{min-height:26px;padding:2px 9px;font-size:11px}
    #pilot input{min-height:36px !important;padding:.35rem .8rem}
    #say.open:not(.max){left:0 !important;right:0 !important;top:auto !important;
      bottom:var(--footh) !important;width:100% !important;min-width:0;
      max-height:60vh !important;height:auto !important;transform:none !important;
      border-radius:10px 10px 0 0;border-left:0;border-right:0;resize:none}
    #say.open:not(.max) #kt{max-height:none}
  }`;
  document.head.appendChild(css);

  // THE WORDS GO, NOT ONLY THEIR PIXELS. A sentence set to display:none is still read back by anything
  // that asks the page what it says, so the two lines nobody asked for are taken out of the page.
  for (const sel of ['#use', '#foot .long']) { const e = document.querySelector(sel); if (e && e.remove) e.remove(); }
  { const keys = $('keys'); if (keys) keys.setAttribute('aria-hidden', 'true'); }
  // THE CORNER IS SILENT UNTIL IT HAS SOMETHING TO REFUSE.
  { const hudEl = $('hud');
    if (hudEl) {
      const REFUSAL = /REFUSED|CONTEXT LOST|not available|did not load|will not invent|Nothing on screen/i;
      const judge = () => { const said = hudEl.textContent || '';
        hudEl.style.visibility = REFUSAL.test(said) ? 'visible' : 'hidden'; };
      judge();
      try { new MutationObserver(judge).observe(hudEl, { childList: true, characterData: true, subtree: true }); } catch (_) {}
    } }

  // ===============================================================================================
  // Everything below needs the wafer's own parts, which the programs cartridge builds on
  // DOMContentLoaded; its listener was registered first, so it has run by the time this one does.
  // ===============================================================================================
  function boot() {
    const sayEl = $('say'), body2 = $('saybody'), foot = $('foot'), pin = $('pin'), eg = $('eg'), chips = $('presets');
    if (!sayEl || !body2 || !pin) return;                        // nothing to dress: leave the page alone

    // NUMBERS ARE OFF THE PICTURE. "Module measurements in boxes in tools, not in the drawing." Every
    // figure is in the number boxes and in the answer; the picture carries what a wiring drawing is.
    let numbersOn = false, keyOn = true, haveAnswer = false;

    // ---- the pop-up is the wafer's window, and it is CLOSED unless somebody asked for it ---------
    const isOpen = () => sayEl.classList.contains('open');
    const shut = () => { sayEl.classList.remove('open', 'max', 'min'); relayout(); };
    const loosen = () => { sayEl.style.left = ''; sayEl.style.top = ''; sayEl.style.width = '';
      sayEl.style.maxHeight = ''; sayEl.style.transform = ''; };
    // THE CARD OPENS AS ITS TITLE BAR. A card that opens full is the drawing gone, and that is what a
    // reader saw the moment they touched the bar to type. FOLDED it is one line - the wafer's own title
    // bar, which already expands on a tap and is still draggable - so the picture stays whole and the
    // card is one tap away, never two. A reader who ASKS for the commands still gets them in full; the
    // page never opens itself full over the drawing.
    const openSheet = (title, folded) => {
      if (title) { const t = $('saytitle'); if (t) t.textContent = title; }
      sayEl.classList.toggle('min', !!folded);
      if (PHONE()) loosen();                                    // the sheet's place is in the stylesheet
      sayEl.classList.add('open');
      relayout();
      try { if (window.__placeSay && !PHONE() && !folded) window.__placeSay(); } catch (_) {}
    };

    // ---- THE TOOLS: the picker, the layout change commands, the key, the applications ------------
    // They live BETWEEN the title bar and the body, because the body is written again on every answer
    // and a tool that an answer wipes is not a tool.
    const kt = el('div'); kt.id = 'kt';
    sayEl.insertBefore(kt, body2);
    if (eg) kt.append(eg);                                      // the wafer's own examples picker, carried, not rebuilt
    kt.append(el('p', 'kdim', 'Pick a preset below, or type a few plain words in the bar and press Enter.'));

    // THE PRESETS LIVE HERE NOW. They are the page's own chips, CARRIED, not rebuilt: every listener the
    // programs cartridge put on them is still on them. The face keeps one button that opens this.
    const presetRow = el('div', 'krow'); presetRow.append(el('p', 'klab', 'the presets')); kt.append(presetRow);

    // WHAT A LAYOUT COMMAND IS: a change to the drawing that happens AT ONCE, in place, with the camera
    // where the reader left it - no flying home and gathering again for a different routing. Every one
    // is a first-class entry: a plain name, a button here, and it can be typed in the bar.
    const refire = (extra) => {
      try {
        if (typeof fireLive === 'undefined' || !fireLive || !fireLive.boxes) {
          const first = chips && chips.querySelector('button');   // nothing fired yet: fire the first preset
          if (!first) return false;
          first.click();
          setTimeout(() => { try { reFire(extra); } catch (_) {} }, 500);
          return true;
        }
        reFire(extra);
        return true;
      } catch (_) { return false; }
    };
    const camera = (fn) => { try { fn(); } catch (_) {} kick(); return true; };
    // TYPE IT AND FIRE IT, exactly as a reader would. The word goes into the bar and the bar's own
    // Enter carries it, so a menu entry and a typed line take ONE path into the engine, never two.
    const typed = (text) => { if (!pin) return false; pin.value = text;
      pin.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })); openSheet(null, true); return true; };

    const COMMANDS = [
      ['wiring sequential', 'the wiring', 'sequential', () => refire({ routing: 'one-after-another' })],
      ['wiring u', 'the wiring', 'U', () => refire({ routing: 'serpentine', turn_alternate_rows: 1 })],
      ['wiring leapfrog', 'the wiring', 'leapfrog', () => refire({ routing: 'leapfrog', turn_every_second: 0 })],
      ['wiring turned', 'the wiring', 'turned', () => refire({ routing: 'leapfrog', turn_every_second: 1 })],
      ['table one high', 'the table', '1 high', () => refire({ modules_high: 1 })],
      ['table two high', 'the table', '2 high', () => refire({ modules_high: 2 })],
      ['table three high', 'the table', '3 high', () => refire({ modules_high: 3 })],
      ['table four high', 'the table', '4 high', () => refire({ modules_high: 4 })],
      ['portrait', 'the table', 'portrait', () => refire({ orientation: 'portrait' })],
      ['landscape', 'the table', 'landscape', () => refire({ orientation: 'landscape' })],
      ['back of modules', 'the view', 'back of modules', () => refire({ view: 'wiring' })],
      ['to scale', 'the view', 'to scale', () => refire({ view: 'scale' })],
      ['near end', 'the view', 'near end', () => camera(() => stringNearView())],
      ['whole string', 'the view', 'whole string', () => camera(() => stringWholeView())],
      ['numbers on', 'on the picture', 'numbers on', () => { numbersOn = true; applyMarks(); return true; }],
      ['numbers off', 'on the picture', 'numbers off', () => { numbersOn = false; applyMarks(); return true; }],
      ['key on', 'on the picture', 'key on', () => { keyOn = true; applyKey(); return true; }],
      ['key off', 'on the picture', 'key off', () => { keyOn = false; applyKey(); return true; }],
      // ONE MORE COMMAND, NO NEW WIDGET: the systems of the estate, listed in this same window. Tapping
      // one fires its pulse through the engine and shuts the sheet, so the disc is what is seen.
      ['systems', 'the estate', 'systems', () => { showSystems(); return true; }],
      ['substation', 'the estate', 'substation', () => typed('fire substation')],
      ['neighbours', 'the estate', 'neighbours', () => typed('fire neighbours')],
      ['pulse', 'the estate', 'pulse', () => typed('fire pulse')]
    ];

    // THE LIST OF SYSTEMS, built into this window's own tools the first time it is asked for.
    let sysBox = null;
    function showSystems() {
      const S = window.KUIPER_SYSTEMS; if (!S) return false;
      if (!sysBox) {
        sysBox = el('details'); sysBox.append(el('summary', null, 'the systems of the estate'));
        const b = el('div', 'kkey'); sysBox.append(b);
        for (const s of S.all) {
          const line = el('button', null, s.id + '  ' + s.system + '  · ' + s.files_total + ' files');
          line.type = 'button'; line.dataset.sys = s.id;
          line.style.display = 'block'; line.style.textAlign = 'left'; line.style.width = '100%';
          line.addEventListener('click', e => { e.stopPropagation(); S.fire(s.id); shut(); });
          b.append(line);
        }
        kt.append(sysBox);
      }
      sysBox.open = true; openSheet();
      try { sysBox.scrollIntoView({ block: 'nearest' }); } catch (_) {}
      return true;
    }

    const layoutBox = el('details'); layoutBox.open = true;
    layoutBox.append(el('summary', null, 'layout change commands'));
    let group = null;
    for (const [name, family, words, run] of COMMANDS) {
      if (!group || group.dataset.family !== family) {
        group = el('div', 'krow'); group.dataset.family = family;
        group.append(el('p', 'klab', family)); layoutBox.append(group);
      }
      const b = el('button', null, words); b.type = 'button'; b.title = name; b.dataset.cmd = name;
      b.addEventListener('click', e => { e.stopPropagation(); run(); markState(); });
      group.append(b);
    }
    kt.append(layoutBox);

    // THE KEY IN FULL, where there is room to read it. One line of it stays on the face.
    const keyBox = el('details'); keyBox.append(el('summary', null, 'the key'));
    const keyBody = el('div', 'kkey'); keyBox.append(keyBody); kt.append(keyBox);

    // THE APPLICATIONS, through the page's own chip, so there is one path to them and not two.
    { const row = el('div', 'krow');
      const b = el('button', null, 'the applications'); b.type = 'button';
      b.addEventListener('click', e => { e.stopPropagation(); const c = $('chipapps'); if (c) c.click(); openSheet(); });
      const h = el('button', null, 'help'); h.type = 'button';
      h.addEventListener('click', e => { e.stopPropagation(); pin.value = 'help';
        pin.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })); pin.value = ''; openSheet(); });
      row.append(b, h); kt.append(row); }

    function markState() {
      for (const b of kt.querySelectorAll('button[data-cmd]')) {
        const n = b.dataset.cmd;
        const on = (n === 'numbers on' && numbersOn) || (n === 'numbers off' && !numbersOn)
                || (n === 'key on' && keyOn) || (n === 'key off' && !keyOn);
        b.classList.toggle('on', !!on);
      }
    }

    // ---- THE CHIPS: one row, a few short names, and the answer ----------------------------------
    // The programs cartridge draws these, and draws them again when the published list lands, so they
    // are put back after each of its redraws. Nothing of its own is removed: the applications chip is
    // only taken off the face, and it is still the thing that opens the applications.
    let mine = null, answerChip = null;
    function fixChips() {
      if (!chips) return;
      if (!mine) { mine = el('button', 'konly', 'layouts'); mine.type = 'button'; mine.id = 'chipmore';
        mine.title = 'every preset, every layout change and every input';
        mine.addEventListener('click', e => { e.stopPropagation(); openSheet(haveAnswer ? null : 'commands'); }); }
      if (!answerChip) { answerChip = el('button', 'konly', 'answer'); answerChip.type = 'button'; answerChip.id = 'chipanswer';
        answerChip.style.display = 'none';
        answerChip.addEventListener('click', e => { e.stopPropagation(); openSheet(); }); }
      // every preset chip the page draws is MOVED into the pop-up, where the one button opens it
      const own = Array.from(chips.children).filter(b => b.id !== 'chipapps' && b !== mine && b !== answerChip);
      for (const b of own) { b.style.display = ''; presetRow.append(b); }
      // the button is the FIRST thing in the row, and it is the only one on the face
      if (chips.firstElementChild !== mine) chips.prepend(mine);
      if (answerChip.parentNode !== chips) chips.append(answerChip);
    }
    fixChips();

    // THE WARNING IS ON THE FIRST SCREEN. It is put up once, and hidden only while the engine's own
    // red line is on the page, so a reader never sees the sentence twice and never sees it not at all.
    const dev = el('div', null, 'Not real cable or array sizing - consult a design engineer. DEVELOPMENT ENVIRONMENT: estimates from a model, nothing measured.');
    dev.id = 'kdev';
    try { document.body.appendChild(dev); } catch (_) {}
    const devWatch = () => { try { const own = document.querySelector('#sldnames span.danger');
      dev.style.display = (own && own.getClientRects().length) ? 'none' : 'block'; } catch (_) {} };
    devWatch();
    try { setInterval(devWatch, 1000); } catch (_) {}
    try { new MutationObserver(fixChips).observe(chips, { childList: true }); } catch (_) {}

    // ---- THE BAR: a plain name, and the way into the pop-up --------------------------------------
    pin.placeholder = 'tap here for the commands';                // no JSON, no pre-typed sentence
    pin.addEventListener('focus', () => openSheet(haveAnswer ? null : 'commands', true));
    // A LAYOUT COMMAND CAN BE TYPED. The bar's own Enter searches the published list, so this listener
    // is on the foot, in the capture phase, where it runs first and can keep the press for itself.
    if (foot) foot.addEventListener('keydown', e => {
      if (e.key !== 'Enter' || e.target !== pin) return;
      const q = String(pin.value || '').trim().toLowerCase();
      if (!q) return;
      // "system <id or name>" fires that one system's pulse at once. "systems" alone opens the list,
      // through the ordinary command below, so there is one way in and not two.
      if (/^system\s+\S/.test(q) && window.KUIPER_SYSTEMS) {
        e.stopPropagation(); e.preventDefault();
        window.KUIPER_SYSTEMS.fire(q.replace(/^system\s+/, '')); shut(); pin.value = '';
        return;
      }
      const hit = COMMANDS.find(c => c[0] === q) || (q.length >= 4 ? COMMANDS.find(c => c[0].startsWith(q)) : null);
      if (!hit) return;
      e.stopPropagation(); e.preventDefault();
      pin.value = hit[0];
      hit[3](); markState();
    }, true);

    // A TAP OUTSIDE SHUTS THE SHEET. Inside it, on the chips and on the bar, nothing is shut.
    addEventListener('pointerdown', e => {
      if (!isOpen()) return;
      const t = e.target;
      if (sayEl.contains(t) || (chips && chips.contains(t)) || (foot && foot.contains(t))) return;
      shut();
    }, true);

    // ---- A FIRED ANSWER DOES NOT OPEN ITSELF OVER THE DRAWING -------------------------------------
    // The wafer's window is still the window and the answer is still written into it; what changes is
    // WHEN it is seen. On a phone an answer that opens itself is the drawing gone. The answer chip
    // pulses once instead, and one tap opens it. A reader who already has the pop-up open keeps it.
    try {
      if (typeof sayOpen === 'function') {
        const orig = sayOpen;
        sayOpen = function (title, nodes, beside) {
          const wasOpen = isOpen();
          orig(title, nodes, false);
          haveAnswer = true;
          groupBoxes();
          readKey();
          if (mine) { mine.classList.remove('pulse'); void mine.offsetWidth; mine.classList.add('pulse'); }
        // THE ANSWER ARRIVES AS A TITLE BAR. It used to be taken off the screen altogether, which kept
        // the drawing whole and put the answer two taps away behind the layouts button. Folded, it is
        // on the page, it says what it is, and ONE tap on it opens it in full.
        if (!wasOpen) { sayEl.classList.remove('max'); sayEl.classList.add('open', 'min'); relayout(); }
          else if (PHONE()) loosen();
          markState();
        };
      }
    } catch (_) {}

    // THE DECLARED INPUTS IN COLLAPSIBLE GROUPS. The window builds a labelled box for every input the
    // command declares, which for a string is twenty-eight: one wall of boxes on a phone. The boxes are
    // not rebuilt - they are MOVED, so every listener the programs cartridge put on them is still on
    // them - into four groups, of which one is open.
    const GROUPS = [
      ['the table', ['mounting', 'orientation', 'modules_high', 'modules', 'routing', 'turn_alternate_rows', 'turn_every_second', 'jumpers', 'view']],
      ['the module, in metres', ['width_m', 'module_height_m', 'gap_m', 'gap_up_m', 'ridge_gap_m', 'tube_gap_m', 'box_spacing_m', 'cell_cols', 'cell_rows']],
      ['the cables', ['lead_plus_m', 'lead_minus_m', 'lead_mm2', 'cable_mm2', 'near_end_m', 'slack_m', 'home_separation_m']],
      ['the electrical figures', ['amps', 't_lead_c', 't_site_c', 'rating_c', 'module_vmp', 'module_voc']]
    ];
    function groupBoxes() {
      const wrap = body2.querySelector('.boxes');
      if (!wrap || wrap.dataset.kgrouped) return;
      const rows = Array.from(wrap.querySelectorAll('.boxrow'));
      if (!rows.length) return;
      const keyOfRow = r => { const f = r.querySelector('input,select'); const id = f ? (f.id || '') : '';
        const at = id.indexOf('-', 4); return at > 0 ? id.slice(at + 1) : ''; };
      const left = new Set(rows), made = [];
      for (const [name, keys] of GROUPS) {
        const want = rows.filter(r => keys.includes(keyOfRow(r)));
        if (!want.length) continue;
        const d = el('details', 'kbox'); d.append(el('summary', null, name));
        for (const r of want) { d.append(r); left.delete(r); }
        made.push(d);
      }
      if (left.size) { const d = el('details', 'kbox'); d.append(el('summary', null, 'the rest'));
        for (const r of left) d.append(r); made.push(d); }
      if (made.length) { made[0].open = true; wrap.prepend(...made); }
      wrap.dataset.kgrouped = '1';
    }

    // ---- THE KEY: one line on the face, all of it in the pop-up ----------------------------------
    // The programs cartridge pins the key under the drawing, which is right on a desk and is half a
    // phone screen on a phone. The lines are READ from its own layer - never rewritten here - the one
    // that carries the arithmetic stays on the face, and the rest are behind "more".
    const keyRow = el('div'); keyRow.id = 'keyline';
    const keyText = el('span'), keyMore = el('button', null, 'more'); keyMore.type = 'button';
    keyMore.addEventListener('click', e => { e.stopPropagation(); keyBox.open = true; openSheet('the key'); });
    keyRow.append(keyText, keyMore);
    if (foot) foot.prepend(keyRow);

    function readKey() {
      const layer = $('sldnames');
      const lines = layer ? Array.from(layer.querySelectorAll('span.pinned'))
        .filter(s => !s.classList.contains('danger'))
        .map(s => (s.textContent || '').trim()).filter(Boolean) : [];
      keyBody.replaceChildren(...(lines.length ? lines.map(t => el('p', null, t))
        : [el('p', null, 'The key appears with the drawing.')]));
      keyText.textContent = lines.find(t => /ohm/.test(t)) || lines[0] || '';
      applyKey();
    }
    function applyKey() {
      const has = keyText.textContent !== '';
      const root = document.documentElement;
      root.classList.toggle('knokey', !keyOn);
      root.classList.toggle('kquiet', keyOn && PHONE());
      keyRow.classList.toggle('on', has && keyOn);
      relayout();
    }

    // ---- THE MEASUREMENTS COME OFF THE PICTURE ----------------------------------------------------
    // Every figure the drawing used to carry along its cables is in the number boxes and in the answer.
    // What stays on the picture is what a wiring drawing IS: the boxes, the cables, which is + and
    // which is -, and which module is which. "numbers on" puts them back for anybody who wants them.
    const keepMark = m => { const t = String((m && m.text) || '');
      return !/\d/.test(t) || /^M\d+$/.test(t) || /^INV/.test(t); };
    function filterDrawing(d) {
      if (!d || !d.marks) return d;
      if (!d.__marksAll) d.__marksAll = d.marks;
      d.marks = numbersOn ? d.__marksAll : d.__marksAll.filter(keepMark);
      return d;
    }
    function applyMarks() {
      try { if (typeof sldShapes !== 'undefined' && sldShapes) filterDrawing(sldShapes); } catch (_) {}
      hideWordy(); kick();
    }
    // the few loose words that carry a length go with the numbers; they are all in the answer
    function hideWordy() {
      const layer = $('sldnames'); if (!layer) return;
      for (const s of layer.querySelectorAll('span:not(.pinned)')) {
        const hide = !numbersOn && /\d/.test(s.textContent || '') && /\bm\b|\bV\b/.test(s.textContent || '');
        s.style.display = hide ? 'none' : '';
      }
    }
    try {
      if (typeof stringDrawing === 'function') {
        const origDraw = stringDrawing;
        window.stringDrawing = function (g) { return filterDrawing(origDraw(g)); };
      }
    } catch (_) {}

    // ---- THE BAND STOPS AT THE TOP OF THE SHEET ---------------------------------------------------
    // The programs cartridge measures the free part of the screen and lays the row into it. Its rule
    // for a window across the width is "go under it", which is right for a window at the top and would
    // put the whole drawing behind a sheet at the bottom. One line is added: a sheet takes the bottom.
    try {
      if (typeof shapeBand === 'function') {
        const origBand = shapeBand;
        window.shapeBand = function (reserve) {
          const b = origBand(reserve);
          // FULL SCREEN. Not eighty-five per cent of it: the whole viewport. The canvas is already fixed
          // to all four edges, and the band the drawing is laid into is now that same rectangle, corner
          // to corner. The red line, the one button, the key line and the bar keep their own backgrounds
          // and sit OVER the picture; nothing is given a strip of its own any more.
          b.left = 0; b.right = innerWidth; b.top = 0; b.bottom = innerHeight;
          // A CARD OPENED IN FULL ON A PHONE STILL TAKES THE BOTTOM, because the reader asked for it.
          // Folded to its title bar it takes nothing.
          if (isOpen() && !sayEl.classList.contains('min') && PHONE()) { const r = sayEl.getBoundingClientRect();
            if (r.height > 8 && r.top > 80) b.bottom = Math.min(b.bottom, r.top - 8); }
          if (b.bottom - b.top < 120) b.top = Math.max(14, b.bottom - 120);
          return b;
        };
      }
    } catch (_) {}

    // THE KEY AND THE LOOSE WORDS ARE READ AFTER THE PAGE HAS DRAWN, which is when that layer exists.
    try { if (window.__wafer && window.__wafer.onDraw) window.__wafer.onDraw.add(function () {
      try { const layer = $('sldnames');
        if (layer && layer.childElementCount !== (layer.dataset.kseen | 0)) {
          layer.dataset.kseen = layer.childElementCount; readKey(); hideWordy(); }
      } catch (_) {}
    }); } catch (_) {}
    addEventListener('resize', () => { applyKey(); fixChips(); });
    addEventListener('orientationchange', () => { applyKey(); fixChips(); });

    markState(); applyKey(); relayout();
    // the foot is a different height now, so the disc is fitted into what is left, not left as it was
    try { if (typeof atHome !== 'undefined' && atHome && typeof homeCamera === 'function' && typeof SPACE !== 'undefined' && SPACE) {
      const h = homeCamera(); cx = h.x; cy = h.y; zoom = h.z; tween = null; } } catch (_) {}
    kick();
  }

  if (document.readyState === 'loading') addEventListener('DOMContentLoaded', () => { try { boot(); } catch (e) { console.error('the dressing did not go on: ' + (e && e.stack ? e.stack : e)); } });
  else { try { boot(); } catch (e) { console.error('the dressing did not go on: ' + (e && e.stack ? e.stack : e)); } }
})();

Kuiper Grid — I0089 Page

A web page in GlobalGrid2050 that uses SHA-256. Published at https://globalgrid2050.com/kuiper-grid/i0089/. It is built from the must step (`must`), the attr step (`attr`) and the sha256 step (`sha256`).

Set aside from the main view: 98% of its lines are the same as kuiper-grid/i0073/index.html (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Kuiper Grid — I0097 Page; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9802 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0073/index.html:1-108 073cc692d3750aac95d1654f9a0b315d2b568d11
  • sha256 a79817347e00003acfc42b49cd992e3c58a62fdfc0ab356657a487c2f9d36f1a
  • target sha256 fb96bcf6b8a812967bfc0fc386a3d015e90f507f76ce774101a57ea29aba253a
  • group of 16 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines
  • re-pointed by apply.py version rule from file 3650 to file 3695; similarity was measured to file 3650

renderglobalgrid2050 / kuiper-grid/i0089/index.html · lines 1–108 of 108 · Entry point

What it does
It draws its content. Defines must, attr, sha256. Uses libraries …/NAME, ' + attr(url.href) + '. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
Inputs & outputs
In: JSON file current.json. Out: web page.
Downstream impact
Used directly by 6 files: GlobalGrid2050 — Kuiper Grid Page (globalgrid2050, https://globalgrid2050.com/kuiper-grid/); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html); Homepage Versions — Before Refresh Page (globalgrid2050, https://globalgrid2050.com/homepage_versions/20260922-before-refresh/); Homepage V123 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v123.html); and 2 more. Reached from 103 other entry points, including GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 — Compute Page (globalgrid2050, https://globalgrid2050.com/compute/); GlobalGrid2050 — Kuiper Page (globalgrid2050, https://globalgrid2050.com/kuiper/). It is itself an entry point, published at https://globalgrid2050.com/kuiper-grid/i0089/.
What it achieves
THE WAY OUT. This page is a composer: with script off, or with a refused record, it renders nothing a reader can click. It reads `./current.json`.
Why it matters
Loaded by the Kuiper Grid page at https://globalgrid2050.com/kuiper-grid/ and 5 other pages.
Application
globalgrid2050 · kuiper-grid/i0089 · page
Uses
Manual (link), GlobalGrid2050 — Plant Page (link), GlobalGrid2050 — Kuiper Grid Page (link), GlobalGrid2050 — Compute Page (link), …/NAME, ' + attr(url.href) + '
Used by
linked from GlobalGrid2050 — Kuiper Grid Page (link), linked from GlobalGrid2050 Homepage Before Four Nests (link), linked from Homepage Versions — Before Refresh Page (link), linked from Homepage V123 (link), linked from Homepage V124 (link), linked from Homepage V125 (link)
Produces
must, attr, sha256
Defines here
must, attr, sha256
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0089/index.html:1-108 · blob 16aa227b744ddc5dc99eb767a75e802b4571559b · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: agent_infra · users: ai_agent · canonical: production_core
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>globalgrid2050</title>
  <style>
    html,body{margin:0;background:#0b0d12;color:#d8dee9;font:13px/1.5 ui-monospace,Menlo,Consolas,monospace}
    #composer{display:grid;place-items:center;min-height:50vh;padding:24px;text-align:center}
    #composer strong{color:#5ec8f2;letter-spacing:.1em}
    #composer small{color:#8b93a7}
    #waysout{max-width:44rem;margin:0 auto;padding:0 20px 40px;border-top:1px solid #1b2030}
    #waysout h2{font-size:14px;color:#5ec8f2;letter-spacing:.06em;text-transform:uppercase;margin:24px 0 8px}
    #waysout p{color:#8b93a7;margin:8px 0}
    #waysout ul{margin:10px 0;padding-left:1.1rem}
    #waysout li{margin:7px 0;color:#8b93a7}
    #waysout a{color:#5ec8f2;font-weight:600}
    #waysout .small{font-size:12px;color:#6f7789}
  </style>
</head>
<body data-composer="loading">
  <main id="composer"><div><strong>GLOBALGRID2050</strong><br>checking this page against its record…<br><small>provided as is, without warranty of any kind; a chart, not a design</small></div></main>
  <!-- THE WAY OUT. This page is a composer: with script off, or with a refused
       record, it renders nothing a reader can click. Plain anchors, in the
       served bytes, so this build is never a dead end. -->
  <nav id="waysout">
    <h2>Build i0089 &mdash; part of the Kuiper</h2>
    <p>This address loads one development build. If it has not loaded, or you have script switched off, start from the plain pages:</p>
    <ul>
      <li><a href="/kuiper-grid/manual.html">The manual</a> &mdash; what this is, what to type, what the answer means, and what it refuses</li>
      <li><a href="/plant/">Will this string go over 1500&nbsp;V on the coldest morning?</a> &mdash; three commands ready to copy</li>
      <li><a href="/kuiper-grid/">All development builds</a></li>
      <li><a href="/compute/">Independent compute</a> &nbsp;&middot;&nbsp; <a href="/">Everything else published here</a></li>
    </ul>
    <p class="small">A development build. Two of the four limits this engine measures a design against have no source in any document, and a verdict that turns on one of them is provisional. <a href="/kuiper-grid/manual.html#unsourced">The manual says which.</a></p>
    <p class="small">A chart, not a design. Not a connection offer, not a constructability assessment, not a consenting design. No output of it is engineering.</p>
  </nav>
  <script type="module">
    // THE COMPOSER. GridAtlas's pattern as it stands (gridatlas/atlas/index.html): one frozen shell, features as hashed
    // cartridges, and current.json, the pointer, saying which. This page is the ONE ADDRESS that never changes. It reads
    // the pointer, fetches the shell, fetches every cartridge the pointer names, and lets a cartridge in ONLY if its
    // bytes hash to what the pointer says. A release is a change to the pointer; a rollback is the pointer put back;
    // the shell is never edited. If anything does not match, nothing runs and the page says so in plain words.
    //
    // Two slots:  replace-script  the shell's <script src="…/NAME"> is pointed at the cartridge instead
    //             import-map      an import of NAME anywhere in the shell resolves to the cartridge instead
    // A cartridge is ONE file with no imports of its own neighbours: one file, one job.
    const CLOSE = '</scr' + 'ipt>';
    const box = document.getElementById('composer');
    const must = (ok, why) => { if (!ok) throw new Error(why); };
    const attr = v => String(v).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
    const sha256 = async bytes => [...new Uint8Array(await crypto.subtle.digest('SHA-256', bytes))].map(b => b.toString(16).padStart(2, '0')).join('');

    try {
      const r = await fetch('./current.json', { cache: 'no-store' });
      must(r.ok, 'the record of this page could not be read (' + r.status + ')');
      const cur = await r.json();
      must(cur && cur.schema === 'globalgrid.current.v1', 'the record of this page is in a form this page does not know');
      must(cur.architecture === 'IMMUTABLE_SHELL_PLUS_HASHED_CARTRIDGES', 'the record of this page names another architecture');
      must(Array.isArray(cur.cartridge_order) && Array.isArray(cur.cartridges) && cur.shell, 'the record of this page is incomplete');

      const shellUrl = new URL(cur.shell.index, location.href), shellBase = new URL(cur.shell.base, location.href).href;
      const sr = await fetch(shellUrl, { cache: 'no-store' });
      must(sr.ok, 'the page itself could not be fetched (' + sr.status + ')');
      const shellBytes = await sr.arrayBuffer();
      must(await sha256(shellBytes) === cur.shell.sha256, 'the page itself is not the one that was released');
      let html = new TextDecoder('utf-8').decode(shellBytes);
      must(/<head\b/i.test(html) && /<body\b/i.test(html), 'the page itself is not a page');

      const byId = new Map(cur.cartridges.map(c => [c.id, c])), loaded = [], imports = {};
      const tags = new RegExp('<script\\b([^>]*)\\bsrc=(["\'])([^"\']+)\\2([^>]*)>\\s*<\\/script>', 'gi');
      for (const id of cur.cartridge_order) {
        const c = byId.get(id);
        must(c, 'a part named in the record is missing from it: ' + id);
        must(/^[a-f0-9]{64}$/.test(c.sha256 || ''), id + ': the record holds no fingerprint for it');
        must(c.slot === 'replace-script' || c.slot === 'import-map', id + ': a slot this page does not have');
        must(typeof c.replaces === 'string' && c.replaces, id + ': the record does not say what it replaces');
        const url = new URL(c.path, location.href);
        const cr = await fetch(url, { cache: 'no-store' });
        must(cr.ok, id + ' could not be fetched (' + cr.status + ')');
        must(await sha256(await cr.arrayBuffer()) === c.sha256, id + ' is not the file that was released');
        if (c.slot === 'import-map') imports[new URL(c.replaces, shellBase).href] = url.href;
        else {
          let done = false;
          html = html.replace(tags, (full, a, q, src, b) => {
            if (done || String(src).split(/[?#]/)[0].split('/').pop() !== c.replaces) return full;   // matched by file name
            done = true;
            return '<script' + a + 'data-cartridge="' + attr(id) + '" src="' + attr(url.href) + '"' + b + '>' + CLOSE;
          });
          must(done, id + ': the page has no place for it (' + c.replaces + ')');
        }
        loaded.push({ id, generation: c.generation, sha256: c.sha256 });
      }
      const state = JSON.stringify({ schema: cur.schema, generation: cur.generation, shell: cur.shell, cartridges: loaded }).replace(/</g, '\\u003c');
      const head = '\n<base href="' + attr(shellBase) + '">'
        + (Object.keys(imports).length ? '\n<script type="importmap">' + JSON.stringify({ imports }).replace(/</g, '\\u003c') + CLOSE : '')
        + '\n<script>window.__COMPOSED__=' + state + ';document.documentElement.dataset.generation=' + JSON.stringify(cur.generation) + ';' + CLOSE;
      html = html.replace(/<head([^>]*)>/i, m => m + head);
      document.open(); document.write(html); document.close();
    } catch (e) {
      console.error('[composer]', e);
      document.body.dataset.composer = 'refused';
      box.innerHTML = '<div><strong>THIS PAGE DID NOT OPEN</strong><br>' + String(e && e.message || e).replace(/[<>&]/g, '')
        + '<br><small>Nothing was run. The released page has not been changed. The plain pages below still work.<br>provided as is, without warranty of any kind; a chart, not a design</small></div>';
    }
  </script>
</body>
</html>