GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / globalgrid2050 / solar-design-studio/202609271853-site-world/world

Hud UI and 3 more files

A JavaScript module in the world folder of GlobalGrid2050 that places box (`placeBox`) and loads rules (`loadRulesText`) (units: kVA), covering solar and cables.

467 lines of JavaScript from globalgrid2050, in 4 files. Topic: Solar and storage design. Section 184 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. Hud Checks ingest · globalgrid2050 / solar-design-studio/202609271853-site-world/world/hud-checks.mjs lines 1–154
  2. Hud UI render · globalgrid2050 / solar-design-studio/202609271853-site-world/world/hud-ui.mjs lines 1–159
  3. Jump transform · globalgrid2050 / solar-design-studio/202609271853-site-world/world/jump.mjs lines 1–132
  4. Keyset transform · globalgrid2050 / solar-design-studio/202609271853-site-world/world/keyset.mjs lines 1–22

Hud Checks

A JavaScript module in the world folder of GlobalGrid2050 that parses private rules (`parsePrivateRules`) (units: mm²), covering cables and solar, using BS 7671 and IEC 62548-1.

ingestglobalgrid2050 / solar-design-studio/202609271853-site-world/world/hud-checks.mjs · lines 1–154 of 154 · version 2026-09-27 18:53 · Not reached from any entry point (candidate for review) · pattern pctOf (shared by 4 files)

What it does
It lists and searches cables and solar. Defines 11 functions or classes, including pctOf, publicChecks, voc, plantStringFacts, hi.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, solar.
Downstream impact
Used directly by 1 file: Hud UI (globalgrid2050).
What it achieves
It parses private rules (`parsePrivateRules`) and is built from the pct of helper (`pctOf`) and the public checks helper (`publicChecks`). The design checks the check HUD shows (`hud-ui.mjs`), one line per FAILED check.
Why it matters
Imported by Hud UI.
Application
globalgrid2050 · solar-design-studio/202609271853-site-world/world · JavaScript module
Uses
String Design (import), Structures (import), Measure Format (import), LV DC Sizing (import), Single-Line Diagram (SLD) Rules (import)
Used by
imported by Hud UI (import)
Produces
HUD_NOTE, HUD_TITLE, QUALIFIED, LV_DROP_LIMIT_PCT, DC_DROP_LIMIT_PCT, AC_OPTIONS, TRENCH_OPTIONS, publicChecks, plantStringFacts, plantFacts, parsePrivateRules, evaluatePrivate
Defines here
pctOf, publicChecks, voc, plantStringFacts, hi, plantFacts, parsePrivateRules, compare, dotted, evaluatePrivate, hudLines
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/hud-checks.mjs:1-154 · blob fc68561addf36d3e83d2dccdaba9c20a14afa0d0 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// hud-checks.mjs: the design checks the check HUD shows (hud-ui.mjs), one line per FAILED check. Owner's instruction
// (27 Sept): a failed check is shown, in small red HUD text; this replaces the earlier "no red verdict" rule for the HUD
// only. Every figure is illustrative and every assumption editable; nothing here is a design for any site.
//
// Public checks: generic physics and published standards, worked out from the placed solar block and its staged cable
// schedule. Private checks: an owner's rules file (schema spec-rules.v1, checks[]) loaded LOCALLY by the viewer; never
// fetched from the server, never staged, never shipped (tools/prepush.mjs refuses *.rules.json). Pure: no DOM, no fetch.

import { stringDesign, stringLine, typedClass, STRING_ADVICE, ILLUSTRATIVE } from './string-design.mjs';
import { structureChecks } from './structures.mjs';
import { fmtQ, fmtPct, fmtVolt } from './measure-format.mjs';
import { inverterCircuit, AC_DEFAULTS } from './lv-dc-sizing.mjs';
import { isolationChecks } from './sld-rules.mjs';

export const HUD_NOTE = `Illustrative, assumptions editable. ${ILLUSTRATIVE}`;
export const HUD_TITLE = 'Illustrative checks at the assumptions shown, not a design assessment';
export const QUALIFIED = 'Check with a qualified engineer.';
export const LV_DROP_LIMIT_PCT = 3; // a common design limit for LV cables (BS 7671 Appendix 12 gives 3 % / 5 % from the origin)
export const DC_DROP_LIMIT_PCT = 3; // an assumed design limit for a DC string circuit (IEC 62548-1 leaves it to the designer)
// Single changes that bring a continuously loaded cable back under its rating, each on its own (said behind [i]; the
// trench designer rates each one: type it, then trench design).
export const AC_OPTIONS = ['load solar-day: the daily cycle of a solar day instead of full current all day', 'a larger conductor (500 mm² Al)',
  'copper instead of aluminium', 'wider spacing between circuits, or more trenches side by side (trench split collector N)'];
export const TRENCH_OPTIONS = ['trenches side by side (trench split collector N): narrower trenches, a wider corridor', 'two layers in one trench',
  'a duct bank (ducts in cement-bound sand)', 'type trench design to compare the arrangements the rating allows'];
const pctOf = u => Math.round(u * 100);

// facts: { mps, tempMinC, spareStrings, strings, connectedStrings, cls, cat, plan: { summary, env } (the built trench plan),
//   drops: { dc, ac } (hud-drops.mjs), plant: plantFacts(result), plantString: { cls, cat, mps, tempMinC } }. Missing inputs skip.
export function publicChecks(f = {}) {
  const out = [], add = (id, failed, line, inputs, standard, extra = {}) => out.push({ id, failed: !!failed, line,
    working: { inputs, standard, note: `${QUALIFIED} ${HUD_NOTE}` }, ...extra });
  // The string voltage is always shown (owner, 27 Sept: show the truth): red when over the system voltage, neutral with the
  // headroom when under; the advisory goes under it either way. Modules in series and the coldest cell are editable. The
  // plant's line is worked out the same way from the plant's own module (one class, one rule).
  const voc = (id, pre, S) => {
    const sd = S?.cls && S.mps ? stringDesign({ cls: S.cls, cat: S.cat || {}, mps: S.mps, tempMinC: S.tempMinC }) : null;
    if (!sd) return;
    add(id, !sd.ok, pre + stringLine(sd),
      [['Modules in series', S.mps], ['Module Voc, highest bin', `${sd.worst.voc} V (${sd.worst.pmax} W)`], ['β Voc', `${S.cls.temp_coeff.voc} %/K`],
        ['Coldest cell', `${sd.tempMinC} °C (editable: temp min)`], ['Rule', `the stricter of the coldest cell and Voc × 1.15: ${sd.rule} governs`],
        ...sd.bins.map(b => [`Cold Voc, ${b.pmax} W bin`, `${fmtQ(b.vocCold, 'V')} (cell ${fmtQ(b.byTemp, 'V')}, × 1.15 ${fmtQ(b.byFactor, 'V')})`]),
        ['String Voc', fmtVolt(sd.stringV)], ['System voltage', `${sd.systemV} V`], ['Headroom', fmtQ(sd.headroomV, 'V')], ['Most in series here', sd.most]],
      'IEC 62548-1 (array maximum voltage at the lowest expected cell temperature); IEC 61730-1 (module maximum system voltage)',
      { always: true, advice: STRING_ADVICE, headroomV: sd.headroomV, stringV: sd.stringV });
  };
  voc('string-voc', '', f.cls && f.cat && f.mps ? f : null);
  voc('plant-string-voc', 'PLANT ', f.plantString);
  // Voltage drops of the placed block with the typed series length (hud-drops.mjs, the way Follow works them): always shown.
  const D = f.drops || {};
  if (D.dc) add('dc-drop', D.dc.pct > DC_DROP_LIMIT_PCT, `DC DROP ${D.dc.pct.toFixed(2)} % WORST STRING · ${D.dc.mps} IN SERIES`,
    [['Worst string', `${D.dc.string + 1}: ${fmtQ(D.dc.lengthM, 'm')} of series loop and home cables`], ['Limit', `${DC_DROP_LIMIT_PCT} % (assumed)`]],
    'IEC 62548-1 (DC voltage drop left to the designer); cable resistance by IEC 60228 method', { always: true });
  if (D.ac) add('ac-drop', D.ac.pct > LV_DROP_LIMIT_PCT, `AC DROP ${D.ac.pct.toFixed(2)} % WORST INVERTER CABLE`,
    [['Worst AC cable', `${D.ac.id}, ${fmtQ(D.ac.lengthM, 'm')}`], ['Limit', `${LV_DROP_LIMIT_PCT} % (assumed)`]],
    'BS 7671:2018+A2 Appendix 12 (voltage drop)', { always: true });
  // The AC cables and the collector trench as BUILT: the rated trench plan (trench-plan.mjs) at its stated soil and load.
  const P = f.plan, A = P?.summary?.ac, env = P?.env;
  if (A && env) {
    const pct = pctOf(A.worst), tight = A.worst >= (env.tight ?? 0.95), soil = `SOIL ${env.soilKmW} K·m/W`;
    add('ac-load', A.worst > 1 + 1e-9 || A.notOk > 0, `AC CABLE LOAD ${pct}% OF RATING · ${String(env.load).toUpperCase()} LOAD · ${soil}`,
      [['Worst AC cable, as built', `${pct} % of its rating`], ['Load', env.load === 'continuous' ? 'continuous: full current all day (conservative)' : env.load],
        ['Soil thermal resistivity', `${env.soilKmW} K·m/W (moist ground, assumed; a soil thermal survey sets it)`],
        ...AC_OPTIONS.map((o, i) => [`Option ${i + 1}`, o])], 'IEC 60287-1-1 and IEC 60287-2-1 (current rating; grouping)',
      { always: tight, advice: tight ? `Runs at ${pct} % at ${env.soilKmW} K·m/W: no margin if the ground dries out.` : undefined });
    add('collector-trench', A.notOk > 0, `COLLECTOR TRENCH ${A.corridor.toFixed(1)} M · ${A.split} SIDE BY SIDE · RATED AT ${soil}`,
      [['Corridor as built', `${A.corridor} m (${A.split} trench${A.split > 1 ? 'es' : ''}, widest ${A.widest} m)`], ['Runs not rated', A.notOk],
        ...TRENCH_OPTIONS.map((o, i) => [`Option ${i + 1}`, o])], 'IEC 60287-2-1 (spacing between circuits in the thermal model)', { always: true });
  }
  // The default inverter trench against the wiring rules (bs7671-checks.mjs): overload of a buried cable with the soil 25 %
  // drier than stated, and armour or duct for LV cable in the ground. Red while it fails; the working says what is assumed.
  if (env) {
    const ic = inverterCircuit({ soilKmW: env.soilKmW }), [ov, pr] = ic.buried;
    add('lv-buried-overload', !ov.ok, `LV OVERLOAD, BURIED: IN ${Math.round(ov.value)} A ${ov.ok ? '<=' : '>'} IZ ${Math.round(ov.limit)} A AT SOIL ${ov.soilKmW.toFixed(2)} K·m/W`,
      [['Circuits', `default inverter trench: ${AC_DEFAULTS.circuits} × ${AC_DEFAULTS.area} mm² Al trefoils, ${AC_DEFAULTS.spacingM} m apart (assumed)`],
        ['Breaker setting In', `${ic.In} A`], ['Iz at the stated soil', `${Math.round(ic.Iz)} A at ${env.soilKmW} K·m/W`],
        ['Iz with the soil 25 % drier', `${Math.round(ov.limit)} A at ${ov.soilKmW.toFixed(2)} K·m/W (our margin)`],
        ['Remedies', 'wider spacing, fewer circuits a trench, a larger conductor']], 'BS 7671 433.1.203 (buried cables); IEC 60287 method (BS 7671 523.3)');
    add('lv-buried-protection', !pr.ok, 'LV CABLE LAID DIRECT UNARMOURED · ARMOUR OR DUCT NEEDED',
      [['Cable', `${AC_DEFAULTS.area} mm² Al single-core, no armour (assumed default)`], ['Laid', pr.value],
        ['Remedies', 'armoured cable with the armour earthed, or ducts; marker tape or cover over LV and DC trenches']], 'BS 7671 522.8.10');
  }
  // Isolation at the inverter from every source (sld-rules.mjs): red while a source has none there.
  if (env) {
    const iso = isolationChecks(), miss = iso.filter(c => !c.ok);
    add('inverter-isolation', miss.length > 0, `INVERTER ISOLATION: ${miss.length ? 'NONE AT THE INVERTER FOR ' + miss.map(c => c.source.toUpperCase()).join(', ') : 'EVERY SOURCE'}`,
      iso.map(c => [c.source, c.device]), 'BS 7671 537 and 712.537 (isolation of every source)');
  }
  // The block's trenches rated by trench-plan.mjs: every design fault it names is a red line, the full words in the working.
  (f.trenchFaults || []).forEach((t, i) => add(`trench-fault-${i + 1}`, true, `TRENCH: ${t.split(/[.:]/)[0].toUpperCase().slice(0, 56)}`,
    [['Fault', t], ['Basis', 'trench plan sized by rating, own code (indicative)']], 'IEC 60287-1-1 and IEC 60287-2-1 method (current rating of the grouped circuits)'));
  if (Number.isFinite(f.spareStrings)) {
    add('unconnected', f.spareStrings > 0, `${f.spareStrings} STRINGS UNCONNECTED`, [['Strings built', f.strings], ['Connected', f.connectedStrings],
      ['Unconnected', f.spareStrings]], 'IEC 62446-1 (every string tested and connected at commissioning)');
  }
  // Structure checks of the laid-out plant (structures.mjs): posts over the height limit, tracker cross slope, the MPPT cap.
  for (const c of f.plant ? structureChecks(f.plant) : []) add(c.id, c.failed, c.line, c.inputs, c.standard);
  return out;
}
/** The plant's string facts from its template (plant-template.mjs): its module as a one-bin class, its string length and
 * coldest cell, for the same string check the block uses; null without a plant. */
export function plantStringFacts(r, cat = null) {
  const p = r?.template?.params, mps = r?.template?.counts?.modulesPerString;
  if (!p || !(mps > 0)) return null;
  // The catalogue class the template's module came from (same highest-bin Voc and β), else a one-bin class of the typed values.
  const hi = c => Math.max(...c.electrical.bins.map(b => b.voc));
  const cls = (cat?.classes || []).find(c => hi(c) === p.moduleVoc && Math.abs(c.temp_coeff.voc - p.vocCoeffPerK * 100) < 1e-9)
    || typedClass({ wp: p.moduleWp, voc: p.moduleVoc, coeffPctPerK: p.vocCoeffPerK * 100 });
  return { cls, cat: { ...(cat || {}), system_voltage_V: p.systemV },
    mps, tempMinC: p.minCellC };
}
/** The structure facts of a plant layout result (plant-layout.mjs), or null. */
export function plantFacts(r) {
  if (!r) return null;
  return { piles: r.piles?.summary || null, rules: r.piles?.rules || null, tracker: !!r.table?.tracker, skipped: r.skipped, crossReview: r.crossReview || 0,
    crossReviewPct: r.params?.trackerCrossReviewPct, crossMaxPct: r.params?.trackerCrossMaxPct, counts: r.template?.counts, params: r.template?.params,
    tiltDeg: r.table?.south ? r.params?.tiltSouthDeg : null };
}

// ---- private rules (spec-rules.v1) ----
const FAIL_STATUS = /^(X|DOES NOT COMPLY)$/i;
export function parsePrivateRules(doc) {
  if (!doc || doc.schema !== 'spec-rules.v1' || !Array.isArray(doc.checks)) throw Error('not a private rules file (spec-rules.v1 with checks[])');
  return { label: String(doc.label || 'private rules'), checks: doc.checks.filter(c => c && typeof c.id === 'string') };
}
const compare = (v, op, lim) => {
  if (op === 'between' && Array.isArray(lim)) return v >= lim[0] && v <= lim[1];
  if (op === 'in' && Array.isArray(lim)) return lim.includes(v);
  if (typeof v === 'number' && typeof lim === 'number') return { '<=': v <= lim, '>=': v >= lim, '<': v < lim, '>': v > lim, '==': Math.abs(v - lim) < 1e-9 }[op];
  if (op === '==') return String(v) === String(lim);
  return undefined;
};
const dotted = (o, k) => (o && /^[\w.]+$/.test(k) ? k.split('.').reduce((a, p) => (a == null ? undefined : a[p]), o) : undefined) ?? undefined;
/** Each private check: worked out from the facts where it names one, else from its design value, else as the file states. */
export function evaluatePrivate(rules, facts = {}) {
  return rules.checks.map(c => {
    // A live fact wins (by name, or a dotted path into facts.$design); a null/absent value is "unknown", never a pass or a fail.
    const key = c.value || c.subject || c.metric, live = key == null ? undefined : facts[key] ?? dotted(facts.$design, key);
    const v = live ?? c.design_value ?? c.desk_value ?? undefined;
    const worked = v != null && c.limit != null ? compare(v, c.op, c.limit) : undefined;
    const failed = worked === undefined ? FAIL_STATUS.test(String(c.status ?? c.status_at_defaults ?? '')) : !worked;
    const what = String(c.topic || c.requirement || c.id).toUpperCase().slice(0, 48);
    const lim = Array.isArray(c.limit) ? c.limit.join('–') : c.limit;
    const line = `${c.id} ${what}${worked !== undefined ? ` · ${v} ${c.op} ${lim}${c.units || c.unit ? ' ' + (c.units || c.unit) : ''}` : ''}`;
    return { id: c.id, private: true, failed, live: live != null && worked !== undefined, line, working: { inputs: [['Requirement', c.requirement], ['Value', v ?? 'as stated in the file'],
      ['Test', c.op ? `${c.op} ${lim ?? ''}` : 'as stated'], ['Note', c.note || '']], standard: c.source || 'private rules', note: HUD_NOTE } };
  });
}

/** The HUD's lines: the failed checks, public first, private after (only when a local rules file is loaded), and the lines
 * always shown (the string voltage, neutral while it passes). A fixed check clears. */
export function hudLines(publicList, privateList = []) {
  return [...publicList, ...privateList].filter(c => c.failed || c.always);
}

Hud UI

A JavaScript module in the world folder of GlobalGrid2050 that places box (`placeBox`) and loads rules (`loadRulesText`) (units: kVA), covering solar and cables.

renderglobalgrid2050 / solar-design-studio/202609271853-site-world/world/hud-ui.mjs · lines 1–159 of 159 · version 2026-09-27 18:53 · Not reached from any entry point (candidate for review) · pattern inputs (shared by 2 files)

What it does
It draws solar and cables. Defines 10 functions or classes, including mountHud, inputs, dropsFor, facts, render. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: solar, cables.
Inputs & outputs
In: JSON file modules.json.
What it achieves
It places box (`placeBox`) and loads rules text (`loadRulesText`). Small monospace red text over the view, top-left under the plan, a thin red rule, low opacity: one line per failed design check (`hud-checks.mjs`), each with a tiny "i" that opens its working (inputs, the standard cited by number. It responds to change and click events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · solar-design-studio/202609271853-site-world/world · JavaScript module
Uses
Hud Checks (import), Hud Drops (dynamic import)
Used by
none found
Produces
mountHud
Defines here
mountHud, inputs, dropsFor, facts, render, placeBox, replace, refresh, loadRulesText, rulesFromQuery
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/hud-ui.mjs:1-159 · blob 6721741a7bf748ab30d81d9fec3285bf7fe44917 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// hud-ui.mjs: the check HUD. Small monospace red text over the view, top-left under the plan, a thin red rule, low
// opacity: one line per failed design check (hud-checks.mjs), each with a tiny "i" that opens its working (inputs, the
// standard cited by number, "illustrative, assumptions editable"). Owner's instruction, 27 Sept; no copied graphics.
// Public checks come from the placed solar block. Typed-limit checks (the project spec) appear ONLY after a rules file is loaded
// locally: the file picker ("hud rules"), or ?rules= naming a file on this machine's own local server (loopback only).
// Nothing private is ever fetched from the public server. Off in print. "hud on|off" in the command line.
// Loaded just after the first frame; it reads the design only when it changes (no frames of its own: 0 fps when still).

import { publicChecks, parsePrivateRules, evaluatePrivate, hudLines, plantFacts, plantStringFacts, HUD_TITLE, QUALIFIED } from './hud-checks.mjs';

const CSS = `#check-hud { position: fixed; left: 10px; top: 246px; max-width: min(520px, calc(100vw - 20px)); z-index: 4; pointer-events: none;
  font: 10px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.04em; color: #ff3b30; opacity: 0.78;
  border-top: 1px solid rgba(255, 59, 48, 0.7); padding-top: 3px; text-shadow: 0 0 2px rgba(0, 0, 0, 0.9); }
#check-hud[hidden] { display: none; }
#check-hud { overflow-y: auto; } #check-hud .t, #check-hud .q { color: #d0d4d8; opacity: 0.85; margin-bottom: 2px; }
#check-hud.compact .l, #check-hud.compact .a, #check-hud.compact .w, #check-hud.compact .q { display: none; }
#check-hud .more { pointer-events: auto; font: inherit; color: #d0d4d8; background: none; border: 1px solid rgba(208, 212, 216, 0.5); border-radius: 3px; padding: 0 4px; cursor: pointer; }
#check-hud .l { display: flex; gap: 6px; align-items: baseline; }
#check-hud button { pointer-events: auto; font: inherit; color: inherit; background: none; border: 1px solid rgba(255, 59, 48, 0.6);
  border-radius: 50%; width: 13px; height: 13px; line-height: 10px; padding: 0; cursor: pointer; font-size: 8px; font-style: italic; }
#check-hud .ok { color: #d0d4d8; }
#check-hud .ok button { border-color: rgba(208, 212, 216, 0.6); }
#check-hud .a { margin: 0 0 2px 10px; max-width: 480px; }
#check-hud .w { pointer-events: auto; margin: 2px 0 4px 10px; color: #ff8a80; white-space: pre-wrap; max-height: 40vh; overflow: auto; }
@media print { #check-hud { display: none !important; } }`;

const LOOPBACK = /^(localhost|127\.0\.0\.1|\[::1\])$/;

// deps: { api (substrate), world (window.world), doc, fetchImpl }
export function mountHud({ api, world, doc = document, fetchImpl = (u, o) => fetch(u, o) }) {
  const S = { on: true, key: '', pub: [], priv: null, rules: null, open: new Set(), cat: null, loading: null, note: '', drops: null, dropsKey: null,
    cramped: false, compact: false };
  if (!doc.getElementById('check-hud-style')) { const s = doc.createElement('style'); s.id = 'check-hud-style'; s.textContent = CSS; doc.head.append(s); }
  const box = doc.createElement('section'); box.id = 'check-hud'; box.hidden = true; box.setAttribute('aria-label', 'Design checks');
  doc.body.append(box);
  const pick = Object.assign(doc.createElement('input'), { type: 'file', accept: '.json,application/json', hidden: true, id: 'check-hud-rules' });
  doc.body.append(pick);
  pick.addEventListener('change', async () => { const f = pick.files?.[0]; pick.value = ''; if (f) await loadRulesText(await f.text(), f.name); });

  // The inputs the public checks read, fetched once (the module catalogue and the staged cable schedule).
  // The module catalogue, fetched once; the block's drops (hud-drops.mjs, the Follow method) worked out once per block version.
  const inputs = () => (S.loading ||= fetchImpl('./world/data/modules.json', { cache: 'no-cache' }).then(r => (r.ok ? r.json() : null)).catch(() => null)
    .then(cat => { S.cat = cat; }));
  async function dropsFor(B) {
    if (!B) return null;
    if (S.dropsKey !== B.version) { S.dropsKey = B.version; S.drops = null; try { S.drops = (await import('./hud-drops.mjs')).blockDrops(B.built, B.anchor); } catch { S.drops = null; } }
    return S.drops;
  }

  function facts() {
    const r = world.plant?.result?.(), b = world.block?.built?.()?.built, inv = b?.summary?.inventory, plant = plantFacts(r);
    const plantString = plantStringFacts(r, S.cat);   // the plant's own string line: shown with or without a block
    if (!b) return plant ? { plant, plantString } : null;
    const cls = S.cat?.classes?.find(c => c.id === (world.module?.debug?.()?.class || 'A')) || S.cat?.classes?.[0];
    const p = world.block?.built?.()?.params || {}, tp = b.trenchPlan, acPct = tp?.summary?.ac ? tp.summary.ac.worst * 100 : undefined;
    return { plant, plantString, mps: inv?.modulesPerString, tempMinC: p.tempMinC, strings: inv?.totalStrings, connectedStrings: inv?.connectedStrings,
      spareStrings: inv?.spareStrings, cls, cat: S.cat, drops: S.drops,
      // The AC cables and the collector trench as BUILT: the rated trench plan (trench-plan.mjs), its own soil and load.
      plan: tp ? { summary: tp.summary, env: tp.env } : null, trenchFaults: tp?.faults || [],
      // named facts a private rules file may test (spec-rules.v1 value / subject / metric keys)
      named: { modules_per_string: inv?.modulesPerString, inverterKVA: inv?.inverterKVA, strings_unconnected: inv?.spareStrings,
        ac_loading_pct: acPct, lv_drop_pct: S.drops?.ac?.pct, acGroupedLoadingPct: acPct, lvDropPctWorst: S.drops?.ac?.pct,
        dc_drop_pct: S.drops?.dc?.pct, $design: { summary: b.summary } } };
  }
  function render() {
    const lines = S.on ? hudLines(S.pub, S.priv || []) : [];
    box.hidden = !lines.length && !S.note;
    const red = lines.filter(c => c.failed).length, top = doc.createElement('div'), more = doc.createElement('button');
    top.className = 't'; top.textContent = `${HUD_TITLE} · ${red} red, ${lines.length - red} shown `;
    more.type = 'button'; more.className = 'more';
    more.addEventListener('click', () => { S.compact = !S.compact; placeBox(); });
    top.append(more);
    const kids = [top, ...lines.map(c => {
      const row = doc.createElement('div'), txt = doc.createElement('span'), i = doc.createElement('button');
      row.className = c.failed ? 'l' : 'l ok'; txt.textContent = c.line; i.type = 'button'; i.textContent = 'i';
      i.setAttribute('aria-label', `Working for ${c.id}`); i.setAttribute('aria-expanded', String(S.open.has(c.id)));
      i.addEventListener('click', () => { S.open.has(c.id) ? S.open.delete(c.id) : S.open.add(c.id); render(); });
      row.append(txt, i);
      const head = [row];
      if (c.advice) { const a = doc.createElement('div'); a.className = c.failed ? 'a' : 'a ok'; a.textContent = c.advice; head.push(a); }
      if (!S.open.has(c.id)) return head;
      const w = doc.createElement('div'); w.className = 'w';
      w.textContent = [...c.working.inputs.map(([k, v]) => `${k}: ${v ?? '–'}`), `Standard: ${c.working.standard}`, c.working.note].join('\n');
      return [...head, w];
    }).flat()];
    const q = doc.createElement('div'); q.className = 'q'; q.textContent = QUALIFIED; kids.push(q);
    if (S.note) { const n = doc.createElement('div'); n.textContent = S.note; kids.push(n); }
    box.replaceChildren(...kids);
    placeBox();
  }
  // The HUD never sits under an open panel (the command line, Design, Follow, earthing, module detail): it narrows to the
  // room left of a panel, stops above one below it, and where too little room is left it folds to its title line (show
  // opens it). Worked out when the HUD or a panel changes, never per frame.
  const PANELS = '#cmd, #design, #layers, #sld-follow, #sld-panel, #earth-panel, #module-panel';
  function placeBox() {
    const W = globalThis.innerWidth || 1024, H = globalThis.innerHeight || 768, left = 10, top = Math.min(246, Math.max(60, H * 0.3));
    let maxW = Math.min(520, W - 20), maxH = H - top - 8;
    for (const el of doc.querySelectorAll(PANELS)) {
      if (el.hidden || !el.getClientRects?.().length) continue;
      const r = el.getBoundingClientRect();
      if (r.width < 1 || r.bottom <= top || r.top >= top + maxH) continue;
      if (r.left >= left + 170) maxW = Math.min(maxW, r.left - left - 8);      // a panel to the right: stop short of it
      else if (r.top > top) maxH = Math.min(maxH, r.top - top - 8);            // a panel below across the left: stop above it
      else maxH = 0;                                                            // a panel over the HUD's corner
    }
    const cramped = maxW < 170 || maxH < 60;
    if (cramped !== S.cramped) { S.cramped = cramped; S.compact = cramped; }
    box.classList.toggle('compact', !!S.compact);
    box.style.top = `${Math.round(top)}px`;
    box.style.maxWidth = `${Math.max(160, Math.round(maxW))}px`;
    box.style.maxHeight = S.compact ? '' : `${Math.max(60, Math.round(maxH))}px`;
    const b = box.querySelector('.more'); if (b) { b.hidden = !S.cramped; b.textContent = S.compact ? 'show' : 'hide'; }
  }
  let placing = 0;
  const replace = () => { if (!placing && !box.hidden) placing = requestAnimationFrame(() => { placing = 0; placeBox(); }); };
  globalThis.addEventListener?.('resize', replace);
  for (const ev of ['click', 'keyup', 'transitionend']) doc.addEventListener?.(ev, replace, true);
  async function refresh(force = false) {
    // Extra check providers (api.hooks.checks: () => { key, list }), e.g. build mode's checks on what was built (build-ui.mjs).
    const extra = [...(api.hooks.checks || [])].map(fn => { try { return fn(); } catch { return null; } }).filter(Boolean);
    const B = world.block?.built?.(), bv = `${B?.version ?? -1}:${B?.params?.tempMinC ?? ''}:${world.plant?.version?.() ?? 0}`;
    const key = `${bv}|${S.rules ? S.rules.label : ''}|${S.on}|${globalThis.worldEarth?.version?.() ?? ''}|${extra.map(x => x.key)}`;
    if (!force && key === S.key) return;
    S.key = key;
    await inputs();                                           // the module catalogue (the block's and the plant's string lines)
    await dropsFor(world.block?.built?.());
    const f = facts();
    S.pub = f ? [...publicChecks(f), ...(globalThis.worldEarth?.checks?.() || [])] : []; // earthing: earth-mount.mjs, once typed
    S.pub.push(...extra.flatMap(x => x.list || [])); // build mode's checks, with or without a plant
    const sv = S.pub.find(c => c.id === 'string-voc');   // the live cold string Voc, so a private string-voltage test follows "string N"
    S.priv = S.rules && f ? evaluatePrivate(S.rules, { ...(f.named || {}), string_voc_cold_v: sv?.stringV }) : null;
    render();
  }
  async function loadRulesText(text, name = 'rules') {
    try { S.rules = parsePrivateRules(JSON.parse(text)); S.note = ''; } catch (e) { S.rules = null; S.note = `RULES REFUSED: ${e.message}`; }
    await refresh(true);
    return S.rules ? S.rules.checks.length : 0;
  }
  // ?rules=<url>: only on this machine (the page and the file both on a loopback host), never from the public server.
  async function rulesFromQuery(loc = location) {
    const q = new URLSearchParams(loc.search).get('rules');
    if (!q) return 0;
    let u;
    try { u = new URL(q, loc.href); } catch { u = null; }
    if (!u || !LOOPBACK.test(loc.hostname) || !LOOPBACK.test(u.hostname)) { S.note = 'RULES NOT LOADED: ?rules= works only for a file on this machine'; render(); return 0; }
    try { return await loadRulesText(await (await fetchImpl(u.href, { cache: 'no-store' })).text(), u.pathname); } catch { S.note = 'RULES NOT LOADED'; render(); return 0; }
  }
  api.hooks.after.add(() => { refresh(); });
  api.hooks.design?.add(() => { refresh(); });
  rulesFromQuery();
  return {
    set(on) { S.on = !!on; refresh(true); return S.on; },
    pickRules() { pick.click(); },
    loadRulesText, rulesFromQuery, refresh: () => refresh(true),
    lines: () => (S.on ? hudLines(S.pub, S.priv || []).map(c => ({ id: c.id, line: c.line, private: !!c.private, failed: !!c.failed,
      ...(c.advice ? { advice: c.advice } : {}) })) : []),
    state: () => ({ on: S.on, shown: !box.hidden, rules: S.rules ? S.rules.checks.length : 0, note: S.note, compact: !!S.compact, title: HUD_TITLE })
  };
}

Jump

A JavaScript module in the world folder of GlobalGrid2050 that works with take off (`takeOff`) and calculates planar distances.

transformglobalgrid2050 / solar-design-studio/202609271853-site-world/world/jump.mjs · lines 1–132 of 132 · version 2026-09-27 18:53 · Not reached from any entry point (candidate for review) · pattern airTimeOf (shared by 2 files)

What it does
It calculates its inputs. Defines 11 functions or classes, including apexOf, airTimeOf, dipAt, supportAt, createJump.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Downstream impact
Used directly by 1 file: Senses Mount (globalgrid2050).
What it achieves
It is built from the apex of helper (`apexOf`), the air time of helper (`airTimeOf`) and the dip at helper (`dipAt`). Jump in Walk (Space): real gravity, a short hold for a little more height, landing on measured ground and on solids.
Why it matters
Imported by Senses Mount.
Application
globalgrid2050 · solar-design-studio/202609271853-site-world/world · JavaScript module
Uses
Views (import)
Used by
imported by Senses Mount (import)
Produces
G, COYOTE_S, OMEGA, STEP_UP_M, TOP_GAP_M, apexOf, airTimeOf, dipAt, supportAt, createJump
Defines here
apexOf, airTimeOf, dipAt, supportAt, createJump, reset, dipNow, carried, takeOff, fly, under
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/jump.mjs:1-132 · blob 5a79b6b536f5bafc2bf65de40440140362e59986 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// Jump in Walk (Space): real gravity, a short hold for a little more height, landing on measured ground and on solids.
// Pure and deterministic: time is the sum of the frame steps it is given, never a wall clock, so tests replay exactly.
// Local east (x), north (y), up (z) metres, like views.mjs; a walker's eye is VIEWS.standing.eye above its feet.
//
// Numbers (SI):
//   G 9.81 m/s² (standard gravity). V0 3.0 m/s take-off: apex V0²/2G = 0.459 m, air time 2·V0/G = 0.612 s (a tap).
//   Held past GRACE_S (0.1 s), the legs keep pushing at PUSH m/s² until the predicted apex reaches MAX_APEX_M (0.60 m):
//   a full hold of about 0.22 s. COYOTE_S 0.1 s: a jump still starts just after walking off an edge. BUFFER_S 0.1 s:
//   a press just before landing jumps again on touchdown. Landing dips the eye by about 1.2 cm per m/s of impact
//   (cap 6 cm) and brings it back critically damped (OMEGA 45 rad/s: deepest at 22 ms, within 7 % by 120 ms).
// Solids are the substrate's boxes [{ min, max }]; standing on one means the feet on its top (table tops, compounds).

import { VIEWS, step as walkStep, blocked, speedOf } from './views.mjs';

export const G = 9.81, V0 = 3.0, GRACE_S = 0.1, PUSH = 6.0, MAX_HOLD_S = 0.35, MAX_APEX_M = 0.6;
export const COYOTE_S = 0.1, BUFFER_S = 0.1;
export const OMEGA = 45, DIP_PER_MS = 1.43, DIP_MAX_M = 0.06, SETTLE_S = 0.15;
export const STEP_UP_M = 0.05;   // a top this far above the feet still counts as underfoot (no stepping up onto a table)
export const TOP_GAP_M = 1e-4;   // stand this far above a solid's top, so the body never counts as inside it
const TELEPORT_M = 5;            // a pose moved further than this between frames (Find, a tour) starts on the ground

// Apex height and air time (back to the take-off level) of a jump at take-off speed v under gravity g, no push.
export const apexOf = (v = V0, g = G) => (v * v) / (2 * g);
export const airTimeOf = (v = V0, g = G) => (2 * v) / g;
// The eye's landing dip d(t) (m, negative = down) at t s after touchdown with impact speed vi (m/s).
export function dipAt(t, vi) {
  if (!(t >= 0)) return 0;
  const v0 = Math.min(DIP_PER_MS * Math.abs(vi), DIP_MAX_M * OMEGA * Math.E);
  return -v0 * t * Math.exp(-OMEGA * t);
}

// The height the feet rest on at (x, y): the ground, or the highest solid top under the body's footprint that is not
// above the feet by more than STEP_UP_M. feetZ: where the feet are now (Infinity: any top counts).
export function supportAt(x, y, feetZ, heightAt, solids = [], radius = VIEWS.standing.body.radius) {
  let s = heightAt(x, y), onSolid = false;
  for (const b of solids) {
    if (x <= b.min[0] - radius || x >= b.max[0] + radius || y <= b.min[1] - radius || y >= b.max[1] + radius) continue;
    const top = b.max[2] + TOP_GAP_M;
    if (top > s && top <= feetZ + STEP_UP_M) { s = top; onSolid = true; }
  }
  return { z: s, onSolid };
}

export function createJump() {
  const W = VIEWS.standing, eye = W.eye;
  let t = 0;                 // simulation time, s: the sum of the frame steps (frozen while nothing moves)
  let air = null;            // { vx, vy, vz, t0, feet0, coyote } while off the ground
  let pressT = -Infinity, holding = false, dip = null, last = null, jumps = 0;
  const landings = [];

  const reset = () => { air = null; dip = null; pressT = -Infinity; };
  const dipNow = () => (dip ? dipAt(t - dip.t0, dip.vi) : 0);
  const carried = (yaw, i) => { const sp = speedOf(W, i.slow), f = Math.max(-1, Math.min(1, i.forward || 0)); return [Math.sin(yaw) * f * sp, Math.cos(yaw) * f * sp]; };
  // Leaves the ground at the start of this frame (time t), with the walking speed and heading of the moment.
  const takeOff = (state, i) => {
    const feet = state.pos[2] - eye - (air ? 0 : dipNow()), [vx, vy] = air ? [air.vx, air.vy] : carried(state.yaw, i); // off an edge: keep going
    air = { vx, vy, vz: V0, t0: t, feet0: feet, coyote: false, top: 0 };
    pressT = -Infinity; dip = null; jumps++;
  };
  // One frame in the air, from t to t + dt: gravity (and the push while held), carried momentum, solids, touchdown.
  function fly(state, dt, heightAt, solids) {
    const a = air, since = t - a.t0, feet = state.pos[2] - eye;
    let acc = -G;
    if (holding && !a.coyote && a.vz > 0 && since >= GRACE_S && since < MAX_HOLD_S && feet - a.feet0 + a.vz * a.vz / (2 * G) < MAX_APEX_M) acc += PUSH;
    let vz = a.vz + acc * dt, z = state.pos[2] + a.vz * dt + 0.5 * acc * dt * dt;
    if (acc > -G && vz > 0) {                                                 // pushing: never past MAX_APEX_M
      const over = z - eye - a.feet0 + vz * vz / (2 * G) - MAX_APEX_M;
      if (over > 0) vz = Math.sqrt(Math.max(0, vz * vz - 2 * G * over));
    }
    let [x, y] = state.pos;
    const nx = x + a.vx * dt, ny = y + a.vy * dt;
    if (!blocked([nx, ny, z], W.body, solids)) { x = nx; y = ny; }
    else if (!blocked([nx, y, z], W.body, solids)) { x = nx; a.vy = 0; }
    else if (!blocked([x, ny, z], W.body, solids)) { y = ny; a.vx = 0; }
    else { a.vx = 0; a.vy = 0; }
    if (vz > 0 && blocked([x, y, z], W.body, solids)) { z = state.pos[2]; vz = 0; } // head against something above
    a.top = Math.max(a.top, z - eye - a.feet0);
    const s = supportAt(x, y, Math.max(feet, z - eye), heightAt, solids);
    if (vz <= 0 && z - eye <= s.z) {                                         // touchdown on the ground or a solid top
      air = null; z = s.z + eye; dip = { t0: t + dt, vi: -vz };
      landings.push({ t: t + dt, airTime: t + dt - a.t0, apex: a.top, vi: -vz, onSolid: s.onSolid, feet: s.z });
      if (landings.length > 8) landings.shift();
    } else a.vz = vz;
    return { ...state, pos: [x, y, z] };
  }

  return {
    // Space went down: a jump at the next frame if on the ground (or just off an edge), else remembered for BUFFER_S.
    press() { holding = true; pressT = t; },
    release() { holding = false; },
    // One frame: in Walk the jump owns the height; in Drone it hands over to views.step untouched.
    step(state, input, dt, heightAt, solids = []) {
      if (state.view !== 'standing') { reset(); return walkStep(state, input, dt, heightAt, solids); }
      if (last && Math.hypot(state.pos[0] - last[0], state.pos[1] - last[1]) > TELEPORT_M) reset();
      const i = input || {}, t1 = t + dt;
      if (t1 - pressT <= BUFFER_S && (!air || (air.coyote && pressT - air.t0 <= COYOTE_S))) takeOff(state, i);
      if (air) {
        state = fly(state, dt, heightAt, solids); t = t1;
        if (!air && t - pressT <= BUFFER_S) takeOff(state, i);                // pressed just before touchdown
        last = state.pos; return state;
      }
      t = t1;
      // On the ground: the usual walk, standing on whatever is underfoot.
      const feet = state.pos[2] - eye - dipNow();
      const under = (x, y) => supportAt(x, y, feet, heightAt, solids).z;
      const next = walkStep({ ...state, pos: [state.pos[0], state.pos[1], feet + eye] }, i, dt, under, solids);
      const s = supportAt(next.pos[0], next.pos[1], feet, heightAt, solids);
      const moved = Math.hypot(next.pos[0] - state.pos[0], next.pos[1] - state.pos[1]);
      if (feet - s.z > 0.3 + moved) {                                        // walked off an edge: fall, with coyote time
        const [vx, vy] = carried(state.yaw, i);
        air = { vx, vy, vz: 0, t0: t, feet0: feet, coyote: true, top: 0 };
        state = { ...next, pos: [next.pos[0], next.pos[1], feet + eye] };
      } else state = { ...next, pos: [next.pos[0], next.pos[1], s.z + eye + dipNow()] };
      last = state.pos;
      return state;
    },
    // Every frame, moving or not: the walker's eye on what is underfoot (ground can stream in late), plus the dip.
    hold(state, heightAt, solids = []) {
      if (state.view !== 'standing') { reset(); return state; }
      if (air) return state;
      if (dip && t - dip.t0 > SETTLE_S) dip = null;
      const feet = state.pos[2] - eye - dipNow(), s = supportAt(state.pos[0], state.pos[1], feet, heightAt, solids);
      const z = s.z + eye + dipNow();
      return Math.abs(z - state.pos[2]) > 1e-6 ? { ...state, pos: [state.pos[0], state.pos[1], z] } : state;
    },
    // Frames are needed in the air, while a press waits to be used, and while the eye settles after a landing.
    busy: () => !!air || t - pressT <= BUFFER_S || (!!dip && t - dip.t0 <= SETTLE_S),
    airborne: () => !!air,
    reset,
    debug: () => ({ t, airborne: !!air, vz: air ? air.vz : 0, holding, jumps, dip: dipNow(), landings: landings.slice() })
  };
}

Keyset

A JavaScript module in the world folder of GlobalGrid2050. It is built from the address step (`address`), the anchor step (`anchor`) and the records step (`records`).

transformglobalgrid2050 / solar-design-studio/202609271853-site-world/world/keyset.mjs · lines 1–22 of 22 · version 2026-09-27 18:53 · Not reached from any entry point (candidate for review) · pattern records (shared by 2 files)

What it does
It calculates its inputs. Defines address, anchor, records.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
What it achieves
The pair's key set: synthetic plants (anonymous test land, no site) whose table addresses and anchors are fixed integer functions of an ordinal.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · solar-design-studio/202609271853-site-world/world · JavaScript module
Uses
Procedural Detail (import)
Used by
none found
Produces
PLANTS, address, anchor, records
Defines here
address, anchor, records
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/world/keyset.mjs:1-22 · blob c9f1aa7c0bf875ff73178f4c1c35ec5717b76df6 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// The pair's key set: synthetic plants (anonymous test land, no site) whose table addresses and anchors
// are fixed integer functions of an ordinal. Used by the tests and by export-electron.mjs; the CuPy
// positron reads the addresses and anchors from the electron file, it does not share this code.

import { plantRecord } from './procedural-detail.mjs';

export const PLANTS = Object.freeze([
  { name: 'p30', seed: 20260927, headingDeg: 23.5, table: {} },
  // modules in series changed (28 a string, 88 columns: a short last string) to prove the typed change
  { name: 'p28', seed: 7, headingDeg: -61, table: { modulesPerString: 28, columns: 88, tilt: 25, pileLines: 17 } }
]);

// ordinal n -> address: k bits 0-1, s bit 2, j bits 3-6, r bits 7-9, i the rest (a bijection).
export function address(n) { return { k: n & 3, s: (n >> 2) & 1, j: (n >> 3) & 15, r: (n >> 7) & 7, i: n >> 10 }; }

// Anchor in integer mm: a spread over +-3 km including negatives (exercises floor division), z 0..4.999 m.
export function anchor(n) {
  const a = address(n);
  return [(a.k * 2 + a.s) * 31_417 + a.j * 263_000 - 2_900_000 + a.i * 7, a.r * 129_050 + a.i * 1_032_400 - 3_000_000, (n * 37) % 5000];
}

export const records = () => PLANTS.map(p => ({ name: p.name, rec: plantRecord(p) }));