GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Websites and apps / ventus-grid-engine / genome

Place Global Search Arrival Identity Excerpt and 5 more files

A JavaScript file in the receiver folder of Ventus Grid Engine that works with supplied arrival fields and still owned, covering the Renewable Energy Planning Database (REPD) register and postcodes.

617 lines of JavaScript and HTML from ventus-grid-engine, in 6 files. Topic: Websites and apps. Section 2021 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. Ventus Grid Engine — Genome Page render · ventus-grid-engine / genome/index.html lines 360–412
  2. App Technology Vocabulary Excerpt transform · ventus-grid-engine / sources/deeplink-extracts/emitter/app-technology-vocabulary.excerpt.mjs lines 1–61
  3. Wider Fleet Deep Link Excerpt render · ventus-grid-engine / sources/deeplink-extracts/emitter/wider-fleet-deep-link.excerpt.mjs lines 1–95
  4. Index Composer render · ventus-grid-engine / sources/deeplink-extracts/receiver/index-composer.html lines 1–119
  5. Place Global Search Arrival Identity Excerpt interaction · ventus-grid-engine / sources/deeplink-extracts/receiver/place-global-search-arrival-identity.excerpt.js lines 1–207
  6. Corridor Estimate render · ventus-grid-engine / sources/v9-extracts/corridor-estimate.mjs lines 1–82

Ventus Grid Engine — Genome Page

A web page that draws maths provenance, engine graph, battery storage (BESS) and solar, using haversine and SHA-256. Published at https://ventusltd.github.io/ventus-grid-engine/genome/.

renderventus-grid-engine / genome/index.html · lines 360–412 of 412 (continued from section 2020) · Entry point · pattern loadLive (shared by 2 files)

What it does
It draws maths provenance, engine graph, battery storage (BESS) and solar. Defines 20 functions or classes, including rebuildSelect, actionable, openUrl, handleTap, neighbours. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain terms in the code: battery storage (BESS), solar.
Inputs & outputs
In: JSON file engine-graph.json; form fields (user input). Out: web page; SVG drawing.
Downstream impact
It is itself an entry point, published at https://ventusltd.github.io/ventus-grid-engine/genome/.
What it achieves
It rebuilds select (`rebuildSelect`), opens URL (`openUrl`) and sets hint (`setHint`). Defines `rebuildSelect`, `actionable`, `openUrl` and 17 more. Its code works with 211.2 MW and 52.8 MW. It reads `./engine-graph.json`. It responds to change and click events.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
ventus-grid-engine · genome · page
Uses
Geo Core (estate URL), Geo Area (estate URL), Geo Shapes (estate URL), Geo GeoJSON (estate URL), V9 Geodesy (estate URL), V9 Nearest Search (estate URL), Contract (estate URL), Network Topology (estate URL), and 23 more
Used by
none found
Produces
rebuildSelect, actionable, openUrl, handleTap, neighbours, evidenceHTML, cardInner, goLabel, setHint, setCrumbs, draw, drawColumn
Defines here
buildFixedLegend, loadEmbedded, loadLive
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 genome/index.html:360-412 · blob fdad5aa9c37e96d039740f426d54667ae03f79d8 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: production_core
  };
  el.onpointercancel = () => { down = false; dragging = false; el.classList.remove("dragging"); };
}

function buildFixedLegend(){
  fixedLegend.innerHTML = "";
  Object.keys(REL).sort().forEach(t => {
    const s = document.createElement("span");
    s.innerHTML = `<i style="border-color:${ECSS[t]}"></i>${REL[t]} (${(GRAPH.edge_kind_counts && GRAPH.edge_kind_counts[t]) || 0})`;
    fixedLegend.appendChild(s);
  });
  Object.keys(BADGE).forEach(t => {
    const s = document.createElement("span");
    s.innerHTML = `<i style="border-top-color:var(--line);color:var(--muted)">[${BADGE[t]}]</i>${t}`;
    fixedLegend.appendChild(s);
  });
}

// ---------------------------------------------------------------------------
// Load: try a live fetch of ./engine-graph.json first (works over http(s), a
// dev server, or GitHub Pages); fall back to the graph embedded in this page
// (works from a bare file:// path, where fetch of a sibling file is blocked
// by the browser). Either source is read into the exact same GRAPH shape.
async function loadEmbedded(){
  const text = document.getElementById("graph-data").textContent;
  return JSON.parse(text);
}
async function loadLive(){
  const r = await fetch("./engine-graph.json", { cache: "no-cache" });
  if (!r.ok) throw new Error("engine-graph.json " + r.status);
  return r.json();
}
(async () => {
  let src = "snapshot";
  try {
    const live = await loadLive();
    if (live && Array.isArray(live.nodes) && live.nodes.length) { GRAPH = live; src = "live"; }
    else throw new Error("empty");
  } catch (e) {
    GRAPH = await loadEmbedded();
  }
  current = Number.isInteger(GRAPH.focus_default) ? GRAPH.focus_default : 0;
  const tag = document.getElementById("srcTag");
  tag.textContent = src; tag.classList.toggle("live", src === "live");
  buildFixedLegend();
  rebuildSelect();
  draw();
})();

})();
  </script>
</body>
</html>

App Technology Vocabulary Excerpt

A JavaScript module in the emitter folder of Ventus Grid Engine that works with solar, battery storage (BESS) and wind.

transformventus-grid-engine / sources/deeplink-extracts/emitter/app-technology-vocabulary.excerpt.mjs · lines 1–61 of 61 · Not reached from any entry point (candidate for review) · pattern dictionary (shared by 10 files)

What it does
It calculates solar, battery storage (BESS) and wind. Defines dictionary, project, atlasUrl.
Why it exists in the grid workflow
Domain terms in the code: solar, battery storage (BESS), wind.
What it achieves
It is built from the dictionary step (`dictionary`), the project step (`project`) and the atlas URL helper (`atlasUrl`). PROVENANCE (excerpt, not the whole file) `head_sha` (PipelineNews): .
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/deeplink-extracts/emitter · JavaScript module
Uses
./202608312037-atlas-pointer-deep-link.mjs
Used by
none found
Produces
dictionary, project, atlasUrl
Defines here
dictionary, project, atlasUrl
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/emitter/app-technology-vocabulary.excerpt.mjs:1-61 · blob fc37084cdb19412a768e5c529a7af5a7d441e1ee · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: unknown · users: none · canonical: unreached_review
/*
 * PROVENANCE (excerpt, not the whole file)
 * source_repo: pipelinenews
 * source_path: releases/202609032329-pipelinenews/assets/202608291447-app.mjs
 * head_sha (pipelinenews): ade103ae2a2eec4f334e159b479f20b857d63515
 * This file has been unchanged (same filename, same content) since generation
 * 202608291447 and is still the app.mjs shipped in the latest release folder
 * (202609032329-pipelinenews) as of HEAD.
 *
 * Excerpt A: line 1 -- the import of the emitter (buildAtlasV9DeepLink) from
 *   ./202608312037-atlas-pointer-deep-link.mjs, i.e. the "ported" ACTIVE_TARGET
 *   version, not the 202608311343 sibling.
 */
import { buildAtlasV9DeepLink } from "./202608312037-atlas-pointer-deep-link.mjs";

/* Excerpt B: lines 105-118 -- the complete technology bucket vocabulary this
 * emitter can hold (LABELS/COLOURS/UNITS/TECHNOLOGIES). Four spine buckets:
 * solar, bess, wind_onshore, wind_offshore. (The wider-fleet cartridge, a
 * separate emitter, adds nine more buckets plus "other" -- see
 * wider-fleet-deep-link.mjs in this same directory.) */
const LABELS = Object.freeze({
  solar: "Solar",
  bess: "Battery Storage",
  wind_onshore: "Onshore Wind",
  wind_offshore: "Offshore Wind",
});
const COLOURS = Object.freeze({
  solar: "#ffff00",
  bess: "#ffae00",
  wind_onshore: "#00ffff",
  wind_offshore: "#0066ff",
});
const UNITS = Object.freeze({ solar: "MWp", bess: "MW", wind_onshore: "MW", wind_offshore: "MW" });
const TECHNOLOGIES = new Set(["all", "solar", "bess", "wind_onshore", "wind_offshore"]);

/* Excerpt C: lines 405-419 -- how project.technology is produced: a dictionary
 * lookup (dictionary("technology", row[FIELD.technology])), so the value
 * handed to buildAtlasV9DeepLink is always exactly one of the TECHNOLOGIES
 * bucket strings above, never a raw REPD technology-type string. */
function dictionary(name, index) {
  return dictionaries[name][index] ?? "";
}

function project(index) {
  const row = rows[index];
  return {
    index,
    row,
    repd_ref: row[FIELD.repdRef],
    gg_project_id: row[FIELD.projectId],
    name: row[FIELD.name],
    technology: dictionary("technology", row[FIELD.technology]),
    status: dictionary("status", row[FIELD.status]),
    capacity_mw: Number(row[FIELD.capacity]),

/* Excerpt D: lines 488-491 -- the MAP button's href is exactly this emitter's
 * output; nothing else in app.mjs builds the URL. */

function atlasUrl(item) {
  return buildAtlasV9DeepLink(item);
}

Wider Fleet Deep Link Excerpt

A JavaScript module in the emitter folder of Ventus Grid Engine covering the Renewable Energy Planning Database (REPD) register, solar and wind, and uses data from the GridAtlas repository.

renderventus-grid-engine / sources/deeplink-extracts/emitter/wider-fleet-deep-link.excerpt.mjs · lines 1–95 of 95 · Not reached from any entry point (candidate for review) · pattern atlasLink (shared by 4 files)

What it does
Defines esc, atlasLink, num, mountWiderFleet. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain terms in the code: the REPD register, solar, wind, battery storage (BESS).
What it achieves
It is built from the esc step (`esc`), the atlas link helper (`atlasLink`) and the num step (`num`). `head_sha` (PipelineNews): lines: 1-80 of the file (`atlasLink` and its immediate context); full file is ~300 lines of DOM mounting code not part of the deep-link contract.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/deeplink-extracts/emitter · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL)
Used by
none found
Produces
WIDER_FLEET_CONTRACT, mountWiderFleet
Defines here
esc, atlasLink, num, mountWiderFleet
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/emitter/wider-fleet-deep-link.excerpt.mjs:1-95 · blob 4b47eb00e1b0c853db678cfb14bd542b110dbcd0 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/*
 * PROVENANCE
 * source_repo: pipelinenews
 * source_path: tools/intelligence/cartridges/wider-fleet/assets/{GEN}-wider-fleet.mjs
 * head_sha (pipelinenews): bab117e4bff007939a9230079788b8643c650a4e
 * lines: 1-80 of the file (atlasLink() and its immediate context); full file is ~300 lines
 * of DOM mounting code not part of the deep-link contract.
 *
 * This is a SECOND, separate emitter from atlas-pointer-deep-link.mjs. It builds
 * MAP links for the ~20 REPD technology types the main product spine (solar/bess/
 * wind_onshore/wind_offshore) does not carry, appended as extra tabs in the same
 * technology row. It emits technology=row.t where row.t comes from
 * build_payload.py: props.get("tech") or "other" -- i.e. it can emit "other",
 * confirmed live.
 */
/**
 * WIDER FLEET — the REPD technology types the spine does not carry, as tabs
 * in the product's own technology row.
 *
 * The DESNZ Renewable Energy Planning Database carries 24 technology types.
 * The spine admits four — Solar Photovoltaics, Battery, Wind Onshore, Wind
 * Offshore — and those four are its four tabs. This adds the other twenty to
 * the SAME row, as more tabs, under the REPD's own names. Vikram, on the
 * first attempt, which hid them behind a button in a panel of their own:
 * "I dont see the options for other tech they are not on the UI like solar,
 * BEss onshroe and offshore wind". They are on the UI now.
 *
 * HOW THIS STAYS ADDITIVE
 * -----------------------
 * The spine binds its technology handler once, at boot:
 *
 *     document.querySelectorAll("#tech .btn").forEach(...)
 *
 * to the buttons present at that moment. Tabs appended afterwards therefore
 * carry NO spine listener, and the spine's `technology` variable is never set
 * to a value its TECHNOLOGIES whitelist would reject. The four original tabs
 * keep their own handler, their own payload and their own render path,
 * untouched and unwrapped.
 *
 * When a wider tab is chosen this renders its own rows into the product's
 * table. When a spine tab is chosen the spine's own apply() runs and repaints
 * from its own data, so going back is the spine restoring itself rather than
 * this cartridge putting anything back.
 *
 * It reads no spine payload, binds no project and emits no news signal.
 */

export const WIDER_FLEET_CONTRACT = Object.freeze({
  schema: "pipelinenews.wider-fleet-cartridge.v2",
  generation: "{GEN}",
  additive_only: true,
  tabs_in_product_technology_row: true,
  reads_spine_payload: false,
  project_bindings: 0,
  eligible_for_news_signal: false,
});

/* Engine layer colours, so a technology reads the same here as on the Atlas.
   Keyed by the family the REPD updater already assigns — no second table. */
const FAMILY_COLOUR = Object.freeze({
  biomass: "#39ff14", hydro: "#00aaff", hydrogen: "#ffffff", tidal: "#00bfff",
  act: "#ff6600", caes: "#88aaff", geothermal: "#ff3300", flywheel: "#ff69b4",
  other: "#888888",
});

const ATLAS = "https://ventusltd.github.io/gridatlas/atlas/";
const PAGE = 50;

const esc = (value) => String(value == null ? "" : value)
  .replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
/* The Atlas resolves an arrival by REPD ref and nothing else
   (identity_rule: EXACT_REPD_REF_ONLY). Without one it reports status ABSENT
   and its place-search cartridge returns before its own flyTo, so the card
   opens and the measurement runs while the camera stays on the default UK
   view -- which reads as "the map cannot find it". Watched live for Rainham
   Phase II on 2026-09-02. A row that genuinely has no resolved ref still
   links without one: the card and the measurement work, only the camera
   does not move, and that is better than sending a guessed identity. */
function atlasLink(row) {
  const query = new URLSearchParams();
  if (row.ref) query.set("repd_ref", row.ref);
  query.set("project", row.n);
  query.set("technology", row.t);
  query.set("capacity_mw", String(row.c));
  query.set("latitude", String(row.ll[1]));
  query.set("longitude", String(row.ll[0]));
  query.set("zoom", "12");
  return `${ATLAS}?${query.toString()}`;
}

const num = (value) => value.toLocaleString("en-GB", { maximumFractionDigits: 2 });

export async function mountWiderFleet({ host, payloadAsset }) {
  const techRow = document.getElementById("tech");
  const tableBody = document.querySelector(".tablewrap tbody");

Index Composer

A web page in the receiver folder of Ventus Grid Engine that uses SHA-256 using data from the GridAtlas repository. Published at https://ventusltd.github.io/ventus-grid-engine/sources/deeplink-extracts/receiver/index-composer.html.

renderventus-grid-engine / sources/deeplink-extracts/receiver/index-composer.html · lines 1–119 of 119 · Entry point · pattern escapeAttribute (shared by 6 files)

What it does
It draws its content. Defines invariant, escapeAttribute, sha256Hex, fail. Uses libraries ${escapeAttribute(blobUrl)}. Side effects: changes the web page (DOM); makes network requests.
Inputs & outputs
In: data source: gridatlas data; JSON file current.json. Out: web page.
Downstream impact
It is itself an entry point, published at https://ventusltd.github.io/ventus-grid-engine/sources/deeplink-extracts/receiver/index-composer.html.
What it achieves
It is built from the invariant step (`invariant`), the escape attribute helper (`escapeAttribute`) and the sha256 hex helper (`sha256Hex`). `head_sha` (GridAtlas): lines: 1-104 (whole file). It reads `./current.json`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
ventus-grid-engine · sources/deeplink-extracts/receiver · page
Uses
${escapeAttribute(blobUrl)}
Used by
none found
Produces
invariant, escapeAttribute, sha256Hex, fail
Defines here
invariant, escapeAttribute, sha256Hex, fail
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/receiver/index-composer.html:1-119 · blob d9b59725ee91ba4f0f9aa57a5566ccf20f037c42 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: unknown · users: none · canonical: production_core
<!--
PROVENANCE
source_repo: gridatlas
source_path: atlas/index.html
head_sha (gridatlas): 64268fd06a0da54ddffbcdaaaee382e314e829f7
lines: 1-104 (whole file)

This is the actual entry point for https://ventusltd.github.io/gridatlas/atlas/
(the ACTIVE_TARGET the live PipelineNews emitter points to). It fetches
current.json, fetches the immutable shell HTML (a pinned atlas-v9 release),
verifies and splices in the four cartridge scripts named in current.json by
SHA-256, and document.writes the composed page. The query string (repd_ref,
technology, latitude, longitude, zoom, project, capacity_mw) is untouched by
this step -- it rides along on window.location and is read independently by
each cartridge after this composition finishes.
-->
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Grid Atlas</title>
  <style>
    html,body{height:100%;margin:0;background:#000;color:#00ffff;font:13px monospace}
    #gridatlas-loader{display:grid;place-items:center;height:100%;padding:24px;text-align:center}
    #gridatlas-loader strong{color:#ffae00}
  </style>
</head>
<body data-gridatlas-router="loading">
  <main id="gridatlas-loader"><div><strong>GRIDATLAS</strong><br>verifying immutable shell and cartridges…</div></main>
  <script type="module">
    const SCRIPT_CLOSE = '</scr' + 'ipt>';
    const loader = document.getElementById('gridatlas-loader');

    function invariant(condition, message) {
      if (!condition) throw new Error(message);
    }

    function escapeAttribute(value) {
      return String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
    }

    async function sha256Hex(bytes) {
      const digest = await crypto.subtle.digest('SHA-256', bytes);
      return [...new Uint8Array(digest)].map(value => value.toString(16).padStart(2, '0')).join('');
    }

    function fail(error) {
      console.error('[GRIDATLAS COMPOSER]', error);
      document.body.dataset.gridatlasRouter = 'failed';
      loader.innerHTML = `<div><strong>GRIDATLAS COMPOSITION FAILED</strong><br>${String(error?.message || error).replace(/[<>&]/g, '')}<br><small>The immutable shell was not changed.</small></div>`;
    }

    try {
      const currentResponse = await fetch('./current.json', { cache: 'no-store' });
      invariant(currentResponse.ok, `current.json HTTP ${currentResponse.status}`);
      const current = await currentResponse.json();
      invariant(current?.schema === 'gridatlas.current.v2', 'unsupported current.json schema');
      invariant(current?.architecture === 'IMMUTABLE_SHELL_PLUS_HASHED_CARTRIDGES', 'architecture contract mismatch');
      invariant(Array.isArray(current.cartridge_order) && Array.isArray(current.cartridges), 'cartridge registry malformed');

      const shellUrl = new URL(current.shell.index, window.location.href);
      const shellBase = new URL(current.shell.base, window.location.href).href;
      const shellResponse = await fetch(shellUrl, { cache: 'no-store' });
      invariant(shellResponse.ok, `immutable shell HTTP ${shellResponse.status}`);
      let html = await shellResponse.text();
      invariant(/<head\b/i.test(html) && /<body\b/i.test(html), 'immutable shell is not HTML');
      html = html.replace(/<head([^>]*)>/i, match => `${match}\n<base href="${escapeAttribute(shellBase)}">`);

      const byId = new Map(current.cartridges.map(item => [item.id, item]));
      const loaded = [];
      const scriptTagPattern = new RegExp('<script\\b[^>]*\\bsrc=(["\\\'])([^"\\\']+)\\1[^>]*>\\s*<\\/script>', 'gi');

      for (const id of current.cartridge_order) {
        const cartridge = byId.get(id);
        invariant(cartridge, `missing cartridge ${id}`);
        invariant(cartridge.type === 'script', `${id}: unsupported cartridge type`);
        invariant(cartridge.slot === 'replace-script', `${id}: unsupported cartridge slot`);
        invariant(typeof cartridge.replace_script === 'string' && cartridge.replace_script, `${id}: replace_script missing`);
        invariant(/^[a-f0-9]{64}$/.test(cartridge.sha256 || ''), `${id}: invalid SHA-256`);

        const cartridgeUrl = new URL(cartridge.path, window.location.href);
        const response = await fetch(cartridgeUrl, { cache: 'no-store' });
        invariant(response.ok, `${id}: HTTP ${response.status}`);
        const bytes = await response.arrayBuffer();
        invariant(await sha256Hex(bytes) === cartridge.sha256, `${id}: SHA-256 mismatch`);
        const blobUrl = URL.createObjectURL(new Blob([bytes], { type: 'text/javascript' }));

        let replaced = false;
        html = html.replace(scriptTagPattern, (full, quote, src) => {
          if (replaced || String(src).split('/').pop() !== cartridge.replace_script) return full;
          replaced = true;
          return `<script data-gridatlas-cartridge="${escapeAttribute(id)}" src="${escapeAttribute(blobUrl)}">${SCRIPT_CLOSE}`;
        });
        invariant(replaced, `${id}: shell slot ${cartridge.replace_script} not found`);
        loaded.push({ id, sha256: cartridge.sha256, blob_url: blobUrl });
      }

      const publicState = JSON.stringify({
        schema: current.schema,
        generation: current.generation,
        release_id: current.release_id,
        architecture: current.architecture,
        shell: current.shell,
        cartridge_order: current.cartridge_order,
        loaded_cartridges: loaded.map(item => ({ id: item.id, sha256: item.sha256 }))
      }).replace(/</g, '\\u003c');
      const stateScript = `<script>window.__GRIDATLAS_ATLAS__=${publicState};document.documentElement.dataset.gridatlasGeneration=${JSON.stringify(current.generation)};${SCRIPT_CLOSE}`;
      html = html.replace(/<body([^>]*)>/i, match => `${match}\n${stateScript}`);

      document.open();
      document.write(html);
      document.close();
    } catch (error) {
      fail(error);
    }
  </script>
</body>
</html>

Place Global Search Arrival Identity Excerpt

A JavaScript file in the receiver folder of Ventus Grid Engine that works with supplied arrival fields and still owned, covering the Renewable Energy Planning Database (REPD) register and postcodes.

interactionventus-grid-engine / sources/deeplink-extracts/receiver/place-global-search-arrival-identity.excerpt.js · lines 1–207 of 207 · Not reached from any entry point (candidate for review) · pattern retryExactRepdDeepLink (shared by 8 files)

What it does
Defines 7 functions or classes, including suppliedArrivalFields, numberOrNull, textOrNull, receiveExactRepdDeepLink, stillOwned. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain terms in the code: the REPD register, postcodes.
What it achieves
It binds search (`bindSearch`) and is built from the supplied arrival fields helper (`suppliedArrivalFields`) and the number or null helper (`numberOrNull`). `head_sha` (GridAtlas): (this file's last commit; repo HEAD is, file unchanged since). It responds to input, keydown and click events.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/deeplink-extracts/receiver · script
Uses
none found
Used by
none found
Produces
suppliedArrivalFields, numberOrNull, textOrNull, receiveExactRepdDeepLink, stillOwned, retryExactRepdDeepLink, bindSearch
Defines here
suppliedArrivalFields, numberOrNull, textOrNull, receiveExactRepdDeepLink, stillOwned, retryExactRepdDeepLink, bindSearch
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/deeplink-extracts/receiver/place-global-search-arrival-identity.excerpt.js:1-207 · blob a94cf7588f981054d3fde6be946d1935f457e65b · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/*
 * PROVENANCE (excerpt)
 * source_repo: gridatlas
 * source_path: atlas/parts/202609040229-place-global-search-arrival-identity.js
 * head_sha (gridatlas): 2d8cc7bacf80a3f20ecfb96ea24548fcea43a19d (this file's last commit;
 *   repo HEAD is 64268fd06a0da54ddffbcdaaaee382e314e829f7, file unchanged since)
 * lines: 566-747
 *
 * Assembled into the LIVE cartridge "uk-gazetteer-flyto" (current.json generation
 * 202609040337, capability "exact-repd-first") via
 * atlas/manifests/202609040337-place-global-search-v9-5-parts.json, which lists
 * this file as its only 'part'. Loaded as the SECOND script in the shell (replaces
 * 202608291818-place-postcode-search.js), fires on DOMContentLoaded -- i.e. this
 * is the FIRST code to read the deep link's repd_ref.
 *
 * This is the identity/parse path: reads repd_ref (identity anchor,
 * EXACT_REPD_REF_ONLY), plus project/technology/capacity_mw/latitude/longitude/
 * status as advisory fields (suppliedArrivalFields), then queries the pinned
 * active-register product for the exact repd_ref and publishes
 * state.deep_link.status = ABSENT | RECEIVING | NOT_IN_ACTIVE_REGISTER | RESOLVED |
 * FAILED. The sld-sandbox cartridge (arrival-run excerpt, this same directory)
 * consumes this published state rather than re-parsing the URL for identity.
 * NOTE: identity regex here is /^[A-Za-z0-9-]{1,40}$/ -- broader than the
 * emitter's own /^\d+$/ numeric-only check.
 */
  function suppliedArrivalFields(params, repdRef) {
    const numberOrNull = (name) => {
      const raw = params.get(name);
      if (raw === null || String(raw).trim() === '') return null;
      const value = Number(raw);
      return Number.isFinite(value) ? value : null;
    };
    const textOrNull = (name) => {
      const value = String(params.get(name) || '').trim();
      return value || null;
    };
    return Object.freeze({
      repd_ref: repdRef,
      name: textOrNull('project'),
      technology: textOrNull('technology'),
      capacity_mw: numberOrNull('capacity_mw'),
      longitude: numberOrNull('longitude'),
      latitude: numberOrNull('latitude'),
      // Pipeline News 0144 does not send status. Retain it only when another
      // authorised producer explicitly supplies it; never present it as an
      // official active-register value.
      supplied_status: textOrNull('status')
    });
  }

  async function receiveExactRepdDeepLink(input, resultsEl,
    expectedOwnerEpoch = null) {
    const params = new URLSearchParams(window.location.search);
    const repdRef = String(params.get('repd_ref') || '').trim();
    if (!repdRef) {
      state.deep_link = { status: 'ABSENT', repd_ref: null, resolved: false, mapped: false };
      return;
    }

    const arrival = suppliedArrivalFields(params, repdRef);
    let coordinator = null;
    let ownerEpoch = null;
    try {
      invariant(/^[A-Za-z0-9-]{1,40}$/.test(repdRef), 'invalid exact REPD deep-link identity');
      coordinator = arrivalCoordinator();
      invariant(coordinator, 'shared arrival coordinator unavailable');
      if (Number.isInteger(expectedOwnerEpoch)) {
        if (!coordinator.arrivalGate.isCurrent(expectedOwnerEpoch)) return;
        ownerEpoch = expectedOwnerEpoch;
      } else {
        ownerEpoch = coordinator.claimPendingArrival(window.location.search);
      }
      state.deep_link = {
        ...arrival, owner_epoch: ownerEpoch, status: 'RECEIVING',
        resolved: false, mapped: false,
        identity_source: 'ACTIVE_REGISTER_PENDING'
      };
      const stillOwned = () => coordinator.arrivalGate.isCurrent(ownerEpoch);
      const querySerial = ++activeQuerySerial;
      input.value = repdRef;
      const results = await queryOfficialRepd(repdRef, querySerial, stillOwned);
      if (!stillOwned() || querySerial !== activeQuerySerial) return;
      const exact = results.find(result => String(result.repd_ref) === repdRef);
      if (!exact) {
        // A successful query with no exact row is evidence about this active
        // snapshot, not a network failure and not evidence that the supplied
        // project never existed. Keep the link's point and identity separate.
        renderResults(results, resultsEl);
        document.body.dataset.gridatlasRepdRef = repdRef;
        document.body.dataset.gridatlasRepdDeepLink = 'not-in-active-register';
        state.deep_link = {
          ...arrival,
          owner_epoch: ownerEpoch,
          status: 'NOT_IN_ACTIVE_REGISTER',
          resolved: false,
          mapped: false,
          supplied_point_usable: hasSafeMapPoint(arrival),
          identity_source: 'ARRIVAL_LINK',
          official_active_register_match: false,
          statement: 'No exact identity in the active-register snapshot; supplied arrival fields retained.'
        };
        return;
      }
      renderResults(results, resultsEl);
      await waitForCapturedMap();
      if (!stillOwned()) return;
      if (!selectResult(exact, { deepLinkEpoch: ownerEpoch })) return;
      if (!stillOwned()) return;
      invariant(state.last_selection?.repd_ref === repdRef, 'exact REPD selection was not retained');
      invariant(state.last_selection?.mapped === true, 'exact REPD identity did not fly to a safe map point');
      document.body.dataset.gridatlasRepdRef = repdRef;
      document.body.dataset.gridatlasRepdDeepLink = 'resolved';
      state.deep_link = {
        status: 'RESOLVED',
        owner_epoch: ownerEpoch,
        repd_ref: repdRef,
        resolved: true,
        mapped: true,
        name: exact.name,
        postcode: exact.postcode,
        longitude: exact.longitude,
        latitude: exact.latitude,
        technology: exact.technology,
        capacity_mw: exact.capacity_mw,
        status_value: exact.status,
        identity_source: 'OFFICIAL_ACTIVE_REGISTER',
        official_active_register_match: true
      };
    } catch (error) {
      if (coordinator && Number.isInteger(ownerEpoch)
          && !coordinator.arrivalGate.isCurrent(ownerEpoch)) return;
      const message = String(error?.message || error);
      state.failures.push({ phase: 'exact_repd_deep_link', repd_ref: repdRef, message });
      state.deep_link = {
        ...arrival, owner_epoch: ownerEpoch, status: 'FAILED',
        resolved: false, mapped: false, message,
        identity_source: 'ACTIVE_REGISTER_CHECK_FAILED'
      };
      document.body.dataset.gridatlasRepdDeepLink = 'failed';
      console.error('[V9 EXACT REPD DEEP LINK]', error);
    }
  }

  async function retryExactRepdDeepLink(input, resultsEl, ownerEpoch) {
    const coordinator = arrivalCoordinator();
    invariant(coordinator, 'shared arrival coordinator unavailable for retry');
    invariant(Number.isInteger(ownerEpoch), 'identity retry requires one shared owner epoch');
    if (!coordinator.arrivalGate.isCurrent(ownerEpoch)) return state.deep_link;
    state.identity_retry_count += 1;
    await resetOfficialRuntime();
    if (!coordinator.arrivalGate.isCurrent(ownerEpoch)) return state.deep_link;
    return receiveExactRepdDeepLink(input, resultsEl, ownerEpoch);
  }

  function bindSearch() {
    const input = document.getElementById('search-input');
    const button = document.getElementById('search-btn');
    const resultsEl = document.getElementById('search-results');
    invariant(input && button && resultsEl, 'V8 search controls missing');
    input.setAttribute('placeholder', 'Search project, address, postcode or place...');
    input.setAttribute('aria-label', 'Search project, address, postcode or place');

    input.addEventListener('input', event => {
      event.stopImmediatePropagation();
      invalidatePendingDeepLink('user-search-input');
      clearTimeout(debounceTimer);
      debounceTimer = setTimeout(() => executeSearch(input, resultsEl, false), 180);
    }, true);

    input.addEventListener('keydown', event => {
      if (event.key === 'Enter') {
        event.preventDefault();
        event.stopImmediatePropagation();
        invalidatePendingDeepLink('user-search-submit');
        clearTimeout(debounceTimer);
        executeSearch(input, resultsEl, true);
      } else if (event.key === 'Escape') {
        event.stopImmediatePropagation();
        invalidatePendingDeepLink('user-search-dismiss');
        resultsEl.style.display = 'none';
      }
    }, true);

    button.addEventListener('click', event => {
      event.preventDefault();
      event.stopImmediatePropagation();
      invalidatePendingDeepLink('user-search-submit');
      clearTimeout(debounceTimer);
      executeSearch(input, resultsEl, true);
    }, true);

    state.retry_exact_deep_link = (ownerEpoch) =>
      retryExactRepdDeepLink(input, resultsEl, ownerEpoch);
    state.ready = true;
  }

  window.addEventListener('DOMContentLoaded', () => {
    try {
      bindSearch();
      const input = document.getElementById('search-input');
      const resultsEl = document.getElementById('search-results');
      void receiveExactRepdDeepLink(input, resultsEl);
    } catch (error) {
      state.failures.push({ phase: 'bind', message: String(error?.message || error) });
      console.error('[V9 PLACE SEARCH INIT]', error);
    }
  }, { once: true });

Corridor Estimate

A JavaScript module in the sources folder of Ventus Grid Engine covering cables and overhead lines (OHL). It is built from the for cable helper (`forCable`).

renderventus-grid-engine / sources/v9-extracts/corridor-estimate.mjs · lines 1–82 of 82 · Not reached from any entry point (candidate for review) · pattern forCable (shared by 10 files)

What it does
Defines forCable. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage hv_procurement (path word 'estimate'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, overhead lines (OHL).
What it achieves
Extracted verbatim from `gridatlas/atlas/modules/202609030205-corridor-estimate.js`.
Why it matters
No other file in the estate was found to import it.
Application
ventus-grid-engine · sources/v9-extracts · JavaScript module
Uses
none found
Used by
none found
Produces
CABLE_FACTOR, OHL_FACTOR, MINIMUM_KM, BASIS, CAVEAT, NOT_FOR_OVERHEAD, forCable, not_an_assessment, schema
Defines here
forCable
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 sources/v9-extracts/corridor-estimate.mjs:1-82 · blob bbd494cdf3004a34067027f8442e875a4f2ae089 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
/**
 * Module: corridor-estimate
 *
 * Extracted verbatim from
 * gridatlas/atlas/modules/202609030205-corridor-estimate.js.
 *
 * A straight line is not a route: an empirically calibrated multiplier
 * (CABLE_FACTOR = 1.245) turning a great-circle distance into an
 * indicative highway-corridor screening estimate for CABLE circuits only,
 * calibrated against 95 published GB transmission cable circuits spanning
 * 59 distinct site pairs (median absolute error 8.45%, 73% within 15%).
 * Refuses to estimate below 1 km (MINIMUM_KM), where centroid resolution
 * dominates the geometry. Deliberately has no forOverhead(): OHL_FACTOR
 * (1.13) is published only so a reader can see why the cable factor is
 * the wrong model for an overhead-line question.
 *
 * Depends on: nothing. Pure scalar arithmetic on a caller-supplied
 * straight-line km (the caller is expected to have produced that km via
 * geodesy.mjs distanceKm).
 *
 * CHANGED: source is an IIFE registering itself on
 * `window.__GRIDATLAS_MODULES__.corridorEstimate`. That wiring is
 * removed; `forCable()` is otherwise unchanged.
 */

export const CABLE_FACTOR = 1.245;
export const OHL_FACTOR = 1.13;
export const MINIMUM_KM = 1;

export const BASIS = Object.freeze({
  factor: CABLE_FACTOR,
  median_absolute_error_pct: 8.45,
  within_15_pct: 73,
  circuits: 95,
  distinct_site_pairs: 59,
  source: 'published built lengths of GB transmission cable circuits',
  sample_note: 'parallel circuits between the same two sites duplicate the '
    + 'geometry, so the sample is 59 distinct site pairs and not 95 circuits',
  minimum_separation_km: MINIMUM_KM,
  below_minimum: 'under about a kilometre the site-centroid resolution '
    + 'dominates: median published length 0.59 km against a median error of '
    + '52.5%, so a straight line between centroids is not measuring route '
    + 'factor and no estimate is offered'
});

export const CAVEAT = 'Indicative highway-corridor screening only. Not a connection '
  + 'offer, not a constructability assessment and not a consenting design.';

export const NOT_FOR_OVERHEAD = 'Calibrated on cable circuits, which follow the '
  + 'highway network. Overhead line crosses open country and measures 1.13; '
  + 'this factor is not applied to an overhead-line question.';

/**
 * The corridor estimate for a CABLE route of `km` straight-line distance.
 * @returns null when there is nothing honest to say - no distance, or a
 *   separation short enough that the straight line is not measuring
 *   route factor. Null is the answer, not zero.
 */
export function forCable(km) {
  const straight = Number(km);
  if (!Number.isFinite(straight) || straight <= 0) return null;
  if (straight < MINIMUM_KM) {
    return { km: null, factor: CABLE_FACTOR, straight_km: straight,
      withheld: BASIS.below_minimum };
  }
  return {
    km: straight * CABLE_FACTOR,
    factor: CABLE_FACTOR,
    straight_km: straight,
    withheld: null
  };
}

/* Deliberately no forOverhead(). A module that offered one would be used,
   and OHL_FACTOR above is published here so a reader can see WHY the
   cable factor is not the answer to that question - not so that this
   module can start answering it. */

export const not_an_assessment = 'An estimated corridor length says nothing about '
  + 'whether a connection is available, consentable or affordable.';

export const schema = 'gridatlas.module.corridor-estimate.v1';