GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / pipelinenews / tools/intelligence/cartridges/project-intelligence/assets

Project Intelligence and 3 more files

A JavaScript module in the assets folder of PipelineNews that works with tab overview (`tabOverview`) and tab lead time (`tabLeadTime`) (units: MW).

645 lines of JavaScript and Python from pipelinenews, in 4 files. Topic: Electricity markets and data pipelines. Section 1044 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. Project Intelligence render · pipelinenews / tools/intelligence/cartridges/project-intelligence/assets/{GEN}-project-intelligence.mjs lines 1–323
  2. Provisional Identity transform · pipelinenews / tools/intelligence/cartridges/provisional-projects/assets/{GEN}-provisional-identity.mjs lines 1–52
  3. Make Cartridge ingest · pipelinenews / tools/intelligence/cartridges/season-is-named/make_cartridge.py lines 1–159
  4. Make Cartridge ingest · pipelinenews / tools/intelligence/cartridges/sector-open-neutral-sort/make_cartridge.py lines 1–111

Project Intelligence

A JavaScript module in the assets folder of PipelineNews that works with tab overview (`tabOverview`) and tab lead time (`tabLeadTime`) (units: MW).

Set aside from the main view: 98% of its lines are the same as pipelinenews_intelligence/202608311343/assets/202608311343-project-intelligence.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Project Intelligence; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9841 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 pipelinenews_intelligence/202608311343/assets/202608311343-project-intelligence.mjs:1-323 3f2c37a896a6f14858f19ba15e74877a53eaa827
  • sha256 be08a22f7c0d0ea561fd297630f65e1cd65791cb3bf0c537649ca3fddc1bff12
  • target sha256 e9f075cd623bab37ebafe52923d32d1062d80d7bf33622e3c26adc49bb018f00
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

renderpipelinenews / tools/intelligence/cartridges/project-intelligence/assets/{GEN}-project-intelligence.mjs · lines 1–323 of 323 · Not reached from any entry point (candidate for review) · pattern mountProjectIntelligence (shared by 2 files)

What it does
It draws its content. Defines 12 functions or classes, including invariant, el, fmt, esc, barList. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
What it achieves
It is built from the invariant step (`invariant`), the fmt step (`fmt`) and the esc step (`esc`). Deployment: not-authorised. It responds to click events.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/intelligence/cartridges/project-intelligence/assets · JavaScript module
Uses
none found
Used by
none found
Produces
PROJECT_INTELLIGENCE_CARTRIDGE_CONTRACT, mountProjectIntelligence
Defines here
invariant, el, fmt, esc, barList, tabOverview, tabLeadTime, tabGrid, tabDataCentres, tabMethod, mountProjectIntelligence, select
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/project-intelligence/assets/{GEN}-project-intelligence.mjs:1-323 · blob 5ca4b13a0dbf5aec50e333f8cea1412d5851d489 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
/**
 * PipelineNews project-intelligence cartridge.
 * Generation {GEN}. DRAFT - deployment: not-authorised.
 *
 * ADDITIVE ONLY. This cartridge adds a tabbed panel inside its own host div.
 * It does not modify, re-render, restyle or re-order any existing part of the
 * application. If it fails to load, the core product is unchanged - the same
 * boundary the sector-intelligence and federated-relationship cartridges hold.
 *
 * It follows the established supplemental-asset contract exactly:
 *   - export <NAME>_CARTRIDGE_CONTRACT with a .generation the loader asserts
 *   - export mount<Name>({ host, payloadAsset }) returning { payloadRequests }
 *   - request NO payload at mount; fetch only on first tab selection
 *   - assert zero project bindings and no news-signal eligibility
 *
 * It uses only classes already present in the frozen stylesheet (.card, .btn,
 * .filters, .gauges, .meta, .section-title) so it inherits the design freeze
 * rather than introducing a second visual language.
 *
 * PUBLIC WORDING: every band name, caveat and note is read from the payload's
 * `labels` block. Nothing is hardcoded here. To change wording, edit LABELS in
 * build_intelligence_cartridge.py and regenerate the payload.
 */

export const PROJECT_INTELLIGENCE_CARTRIDGE_CONTRACT = Object.freeze({
  schema: "pipelinenews.project-intelligence-cartridge.v1",
  generation: "{GEN}",
  deployment: "not-authorised",
  activation: "dynamic-import-on-user-open; payload-fetch-on-first-tab-selection",
  additive_only: true,
  mutates_existing_dom: false,
  project_bindings: 0,
  eligible_for_news_signal: false,
  asserts_no_personal_data: true,
  derived_values_are_inferred: true,
  corroboration_adapters_built: false,
  one_signal_policy: "WITHHOLD",
  tabs: Object.freeze(["OVERVIEW", "LEAD TIME", "GRID", "DATA CENTRES", "METHOD"]),
});

function invariant(condition, message) {
  if (!condition) throw new Error(`Project intelligence cartridge: ${message}`);
}

const el = (tag, cls, html) => {
  const n = document.createElement(tag);
  if (cls) n.className = cls;
  if (html !== undefined) n.innerHTML = html;
  return n;
};
const fmt = (n) => (n === null || n === undefined || Number.isNaN(Number(n)))
  ? "—" : Number(n).toLocaleString("en-GB");
const esc = (s) => String(s ?? "").replace(/[&<>"]/g,
  (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));

/** Horizontal bar list, built from the frozen stylesheet's own idiom. */
function barList(rows, colour) {
  const max = Math.max(...rows.map((r) => r.n), 1);
  return rows.map((r) => `
    <div style="display:grid;grid-template-columns:minmax(120px,1fr) 2fr minmax(90px,auto);
                gap:10px;align-items:center;padding:5px 0;font-size:11px">
      <span style="color:#a6adbb">${esc(r.label)}</span>
      <span style="height:9px;background:rgba(255,255,255,.07);border-radius:999px;overflow:hidden">
        <span style="display:block;height:100%;width:${(r.n / max) * 100}%;
                     background:${r.c || colour || "#00ffff"};border-radius:999px"></span>
      </span>
      <span style="text-align:right;color:#fff">${fmt(r.n)}${
        r.mw !== undefined ? ` <span style="color:#555">/ ${fmt(Math.round(r.mw))} MW</span>` : ""}</span>
    </div>`).join("");
}

const BAND_COLOUR = {
  EARLY: "#00ff88", LATE: "#ffbe45", BEYOND: "#bdb2ff",
  AWAITING: "#8888ff", BUILDING: "#9aa3af", NOT_CURRENT: "#8b929b",
  NO_DATE: "#4a525c", UNCLASSIFIED: "#3b444f",
};

/* ------------------------------------------------------------------ tabs */

function tabOverview(data, ix) {
  const bands = {};
  for (const r of data.rows) {
    const b = r[ix.band];
    bands[b] = bands[b] || { n: 0 };
    bands[b].n += 1;
  }
  const rows = Object.keys(BAND_COLOUR)
    .filter((b) => bands[b])
    .map((b) => ({ label: data.labels.band[b], n: bands[b].n, c: BAND_COLOUR[b] }));

  const corroborated = data.rows.filter((r) => r[ix.corroborating_signal] !== "none").length;

  return `
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:0 0 10px">
      WHERE TO LOOK FIRST · ${fmt(data.record_count)} LIVE SOLAR AND BATTERY PROJECTS</h3>
    ${barList(rows)}
    <p style="font-size:10px;color:#555;line-height:1.7;margin-top:14px">
      ${esc(data.scope)}. ${esc(data.labels.caveat.lead)}</p>
    <div style="margin-top:14px;padding:10px 12px;border:1px solid rgba(0,255,255,.3);
                background:rgba(0,20,20,.5);font-size:10px;color:#a6adbb;line-height:1.7">
      <b style="color:#00ffff">The early window is where specification is still open.</b>
      Studies, cable and LV design are decided before a project freezes its design; this shows which
      consented projects are still inside that window, and how far through it they are.</div>`;
}

function tabLeadTime(data, ix) {
  const c = data.calibration;
  const withPct = data.rows.filter((r) => r[ix.pct_of_lead] !== null);
  const buckets = [
    { label: "0–25% of lead", lo: 0, hi: 25, c: "#00ff88" },
    { label: "25–50%", lo: 25, hi: 50, c: "#7dff9f" },
    { label: "50–75%", lo: 50, hi: 75, c: "#ffbe45" },
    { label: "75–100%", lo: 75, hi: 100, c: "#ff9f45" },
    { label: "over 100%", lo: 100, hi: Infinity, c: "#bdb2ff" },
  ].map((b) => ({
    label: b.label, c: b.c,
    n: withPct.filter((r) => r[ix.pct_of_lead] >= b.lo && r[ix.pct_of_lead] < b.hi).length,
  }));

  return `
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:0 0 10px">
      POSITION IN THE MEASURED LEAD</h3>
    ${barList(buckets)}
    <div class="gauges" style="margin-top:16px">
      <div class="card"><h3>SOLAR MEDIAN</h3>
        <div style="font-size:26px;font-weight:bold;color:#ffff00">${c.solar_median_days} d</div>
        <div style="font-size:10px;color:#a6adbb;margin-top:4px">n = ${fmt(c.solar_n)}</div></div>
      <div class="card"><h3>BATTERY MEDIAN</h3>
        <div style="font-size:26px;font-weight:bold;color:#ffae00">${c.bess_median_days} d</div>
        <div style="font-size:10px;color:#a6adbb;margin-top:4px">n = ${fmt(c.bess_n)}</div></div>
      <div class="card"><h3>SAMPLE</h3>
        <div style="font-size:26px;font-weight:bold;color:#00ffff">${fmt(c.sample)}</div>
        <div style="font-size:10px;color:#a6adbb;margin-top:4px">projects with both dates</div></div>
    </div>
    <p style="font-size:10px;color:#555;line-height:1.7;margin-top:14px">
      <b style="color:#888">Method.</b> ${esc(c.method)}. Bands with n &lt; ${c.min_band_sample}
      ${esc(c.fallback)}. A project inside the first ${c.early_threshold_pct}% of the measured median
      is banded early.<br><br>
      <b style="color:#888">Why it matters.</b> Battery takes roughly 2.5× as long as solar from
      consent to construction, so the two cannot share a timeline. A battery consented this month is
      still early in its window long after a solar project consented the same week has closed.</p>`;
}

function tabGrid(data, ix) {
  const d = data.rows.map((r) => r[ix.circuit_km]).filter((v) => v !== null);
  const buckets = [
    { label: "within 2 km", f: (v) => v <= 2, c: "#00ff88" },
    { label: "2 – 5 km", f: (v) => v > 2 && v <= 5, c: "#00ffff" },
    { label: "5 – 10 km", f: (v) => v > 5 && v <= 10, c: "#66ccff" },
    { label: "10 – 20 km", f: (v) => v > 10 && v <= 20, c: "#8888ff" },
    { label: "over 20 km", f: (v) => v > 20, c: "#bdb2ff" },
  ].map((b) => ({ label: b.label, c: b.c, n: d.filter(b.f).length }));
  const near = d.filter((v) => v <= 2).length;

  return `
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:0 0 10px">
      STRAIGHT-LINE DISTANCE TO THE NEAREST MAPPED TRANSMISSION CIRCUIT</h3>
    ${barList(buckets)}
    <p style="font-size:10px;color:#555;line-height:1.7;margin-top:14px">
      <b style="color:#888">${fmt(near)} of ${fmt(d.length)}
      (${Math.round((near / d.length) * 100)}%) sit within 2 km of a mapped circuit.</b>
      Most of this population is close to the network, so distance is most useful for spotting the
      minority that are not.<br><br>
      <b style="color:#888">Note.</b> ${esc(data.labels.caveat.distance)}
      ${esc(data.labels.provenance.network)}
      ${fmt(data.dictionaries.substation_name.length)} distinct substations matched.</p>`;
}

function tabDataCentres(data, ix) {
  const withDc = data.rows.filter((r) => r[ix.datacentre_km] !== null);
  const buckets = [
    { label: "within 5 km", f: (v) => v <= 5, c: "#00ff88" },
    { label: "5 – 10 km", f: (v) => v > 5 && v <= 10, c: "#00ffff" },
    { label: "10 – 25 km", f: (v) => v > 10 && v <= 25, c: "#66ccff" },
    { label: "over 25 km", f: (v) => v > 25, c: "#8888ff" },
  ].map((b) => ({ label: b.label, c: b.c, n: withDc.filter((r) => b.f(r[ix.datacentre_km])).length }));

  const close = withDc
    .filter((r) => r[ix.datacentre_km] <= 5 && r[ix.band] === "EARLY")
    .sort((a, b) => a[ix.datacentre_km] - b[ix.datacentre_km])
    .slice(0, 12);

  const rows = close.map((r) => `
    <tr><td style="padding:6px 8px;border-bottom:1px solid #16191f;color:#66ccff">${esc(r[ix.repd_ref])}</td>
        <td style="padding:6px 8px;border-bottom:1px solid #16191f;color:#a6adbb">${
          esc(data.dictionaries.datacentre_name[r[ix.datacentre_name]] ?? "—")}</td>
        <td style="padding:6px 8px;border-bottom:1px solid #16191f;text-align:right;color:#fff">${
          r[ix.datacentre_km]} km</td></tr>`).join("");

  return `
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:0 0 10px">
      DISTANCE TO THE NEAREST MAPPED DATA CENTRE</h3>
    ${barList(buckets)}
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:18px 0 8px">
      CLOSEST PAIRINGS WHERE THE PROJECT IS EARLY IN LEAD TIME</h3>
    <div style="overflow-x:auto"><table style="width:100%;border-collapse:collapse;font-size:11px">
      <thead><tr>
        <th style="text-align:left;padding:6px 8px;color:#00ffff;font-size:9px;letter-spacing:.6px">REPD</th>
        <th style="text-align:left;padding:6px 8px;color:#00ffff;font-size:9px;letter-spacing:.6px">MAPPED DATA CENTRE</th>
        <th style="text-align:right;padding:6px 8px;color:#00ffff;font-size:9px;letter-spacing:.6px">DISTANCE</th>
      </tr></thead><tbody>${rows || '<tr><td colspan="3" style="padding:10px;color:#555">none</td></tr>'}</tbody>
    </table></div>
    <p style="font-size:10px;color:#555;line-height:1.7;margin-top:14px">
      ${esc(data.labels.provenance.datacentres)} This is the mapped built estate, so coverage varies.
      Useful for spotting where generation and demand are landing in the same place.
      ${esc(data.labels.caveat.distance)}</p>`;
}

function tabMethod(data, ix) {
  const bind = { HIGH: 0, LOW: 0, NONE: 0 };
  for (const r of data.rows) bind[r[ix.binding]] = (bind[r[ix.binding]] || 0) + 1;
  const rows = ["HIGH", "LOW", "NONE"].map((k) => ({
    label: data.labels.binding[k], n: bind[k] || 0,
    c: { HIGH: "#00ff88", LOW: "#ffbe45", NONE: "#ff4444" }[k],
  }));

  return `
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:0 0 10px">
      NAME-MATCH REACHABILITY</h3>
    ${barList(rows)}
    <p style="font-size:10px;color:#555;line-height:1.7;margin-top:12px">
      ${esc(data.labels.caveat.binding)} ${fmt(bind.NONE)} projects have names too generic to match
      on, and need a planning reference or operator name instead.</p>
    <h3 style="font-size:11px;letter-spacing:1px;color:#66ccff;margin:18px 0 8px">PROVENANCE</h3>
    <p style="font-size:10px;color:#555;line-height:1.9">
      <b style="color:#888">Spine.</b> ${esc(data.labels.provenance.spine)}
      ${fmt(data.spine.project_count)} records, ${fmt(data.spine.capacity_mw)} MW,
      <code>projects_sha256 ${esc(data.spine.projects_sha256.slice(0, 16))}…</code><br>
      <b style="color:#888">Network.</b> ${esc(data.labels.provenance.network)}<br>
      <b style="color:#888">Data centres.</b> ${esc(data.labels.provenance.datacentres)}<br>
      <b style="color:#888">Derived.</b> ${esc(data.labels.provenance.derived)}<br>
      <b style="color:#888">Privacy.</b> Organisation-level records only. No personal data is read,
      stored or displayed.</p>
    <div style="margin-top:14px;padding:10px 12px;border:1px solid #2f343d;background:#07090c;
                font-size:10px;color:#a6adbb;line-height:1.8">
      <b style="color:#00ffff">Wording on this panel is set in one place</b> — the
      <code>labels</code> block of the data file. Change it there and every tab follows.</div>`;
}

const TABS = [
  { id: "OVERVIEW", render: tabOverview },
  { id: "LEAD TIME", render: tabLeadTime },
  { id: "GRID", render: tabGrid },
  { id: "DATA CENTRES", render: tabDataCentres },
  { id: "METHOD", render: tabMethod },
];

/* ----------------------------------------------------------------- mount */

/**
 * Mount the tabbed panel into `host`.
 *
 * Requests NO payload at mount - the loader asserts payloadRequests === 0,
 * matching the existing supplemental cartridges. The payload is fetched once,
 * on the first tab the user selects, and reused for every tab after that.
 *
 * @returns {{payloadRequests:number, projectBindings:number}}
 */
export function mountProjectIntelligence({ host, payloadAsset }) {
  invariant(host instanceof HTMLElement, "host element is missing");
  invariant(payloadAsset && typeof payloadAsset.url === "string", "payload asset is missing");

  let payloadRequests = 0;
  let data = null;
  let ixCache = null;
  let active = null;

  host.textContent = "";

  const tools = el("div", "news-tools");
  const panel = el("div");
  panel.style.cssText = "padding:12px 0;min-height:80px";
  const note = el("div", null,
    "WAIT · no payload requested · choose a tab to load the compact derived index");
  note.style.cssText = "font-size:10px;color:#555;letter-spacing:.5px;padding:4px 0";

  const buttons = TABS.map((t) => {
    const b = el("button", null, t.id);
    b.type = "button";
    b.setAttribute("role", "tab");
    b.setAttribute("aria-selected", "false");
    b.addEventListener("click", () => select(t).catch((error) => {
      console.error("project intelligence", error);
      panel.innerHTML = '<div style="font-size:11px;color:#ff4444;padding:10px 0">'
        + "FAIL · derived index unavailable; the core product is unchanged</div>";
    }));
    tools.appendChild(b);
    return { tab: t, node: b };
  });

  async function select(tab) {
    if (active === tab.id) return;
    active = tab.id;
    for (const b of buttons) {
      const on = b.tab.id === tab.id;
      b.node.classList.toggle("active", on);
      b.node.setAttribute("aria-selected", String(on));
    }
    if (!data) {
      note.textContent = "LOAD · requesting the compact derived index once";
      payloadRequests += 1;
      invariant(payloadRequests === 1, "derived index requested more than once");
      const response = await fetch(payloadAsset.url, { cache: "force-cache" });
      invariant(response.ok, `derived index HTTP ${response.status}`);
      data = await response.json();
      invariant(data.schema === "pipelinenews.v9.project-intelligence.v1",
        "derived index schema changed");
      invariant(data.law?.no_personal_data === true, "privacy boundary changed");
      invariant(data.law?.corroboration_adapters_built === false,
        "corroboration claim changed; review before display");
      ixCache = Object.fromEntries(data.fields.map((f, i) => [f, i]));
      note.textContent = `READY · ${fmt(data.record_count)} projects · generation ${data.generation}`
        + " · derived values are inferred, not published facts";
    }
    panel.innerHTML = tab.render(data, ixCache);
  }

  host.appendChild(tools);
  host.appendChild(note);
  host.appendChild(panel);

  return { payloadRequests, projectBindings: 0 };
}

Provisional Identity

A JavaScript module in the assets folder of PipelineNews that works with the Renewable Energy Planning Database (REPD) register, using SHA-256.

transformpipelinenews / tools/intelligence/cartridges/provisional-projects/assets/{GEN}-provisional-identity.mjs · lines 1–52 of 52 · Not reached from any entry point (candidate for review) · pattern reconcileProvisional (shared by 3 files)

What it does
It calculates the REPD register. Defines globalGridReference, normalise, allocateProvisional, reconcileProvisional, resolveProject.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register.
Downstream impact
Used directly by 1 file: Reconcile Provisional (testcode).
What it achieves
It resolves project (`resolveProject`) and is built from the global grid reference helper (`globalGridReference`) and the normalise step (`normalise`). Uses the existing Pipeline Global Grid reference convention.
Why it matters
Imported by Reconcile Provisional, from Testcode.
Application
pipelinenews · tools/intelligence/cartridges/provisional-projects/assets · JavaScript module
Uses
none found
Used by
imported by Reconcile Provisional (import), mentioned in Standalone (comment link)
Produces
globalGridReference, allocateProvisional, reconcileProvisional, resolveProject
Defines here
globalGridReference, normalise, allocateProvisional, reconcileProvisional, resolveProject
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/provisional-projects/assets/{GEN}-provisional-identity.mjs:1-52 · blob ea3eaa9b800cc3ab3a4b88bb2f5473eaed1085f6 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
// Uses the existing Pipeline Global Grid reference convention.
export const globalGridReference = ref => `GG2050-REPD-${ref}`;
const normalise = value => String(value ?? '').normalize('NFKC').toLowerCase().replace(/[^a-z0-9]+/g,' ').trim();

export function allocateProvisional(records, project) {
  const existing = records.find(row => row.source_key === project.source_key
    || (normalise(row.name)===normalise(project.name)
      && normalise(row.operator)===normalise(project.operator)
      && normalise(row.county)===normalise(project.county)
      && Number(row.capacity_mw)===Number(project.capacity_mw)));
  if (existing) return structuredClone(existing);
  let number=9999;
  const used=new Set(records.flatMap(row=>[row.repd_ref,...(row.aliases ?? [])]));
  while(used.has(`${number}-REPD-TBC`)) number++;
  const repd_ref=`${number}-REPD-TBC`;
  return {...structuredClone(project),repd_ref,official_repd_ref:null,
    gg_project_id:globalGridReference(repd_ref),identity_status:'REPD_PENDING',
    aliases:[],identity_history:[]};
}

export function reconcileProvisional(records, official, source) {
  if (!source?.path || !/^[a-f0-9]{64}$/.test(source.sha256 ?? '')) throw Error('Quarterly source identity required');
  const numeric=official.filter(row=>/^\d+$/.test(String(row.repd_ref)));
  const occupied=new Set(records.filter(row=>row.official_repd_ref).map(row=>row.official_repd_ref));
  return records.map(input=>{
    const row=structuredClone(input);
    if(row.official_repd_ref) return row;
    // A common name or a nearby site is insufficient: require the declared
    // name/alias, developer, county and reported capacity to agree uniquely.
    const names=[row.name,...(row.name_aliases ?? [])].map(normalise);
    const matches=numeric.filter(candidate=>names.includes(normalise(candidate.name))
      && normalise(candidate.operator)===normalise(row.operator)
      && normalise(candidate.county)===normalise(row.county)
      && Number(candidate.capacity_mw)===Number(row.capacity_mw));
    if(matches.length!==1 || occupied.has(String(matches[0].repd_ref))) {
      row.reconciliation={status:matches.length?'AMBIGUOUS_REQUIRES_REVIEW':'NO_VERIFIED_MATCH',source,candidate_count:matches.length};
      return row;
    }
    const previous=row.repd_ref, next=String(matches[0].repd_ref);
    occupied.add(next);
    row.aliases=[...new Set([...row.aliases,previous,row.gg_project_id])];
    row.repd_ref=next;row.official_repd_ref=next;row.gg_project_id=globalGridReference(next);
    row.identity_status='REPD_BOUND';
    row.identity_history.push({from:previous,to:next,source,reason:'unique name/developer/county/capacity match'});
    row.reconciliation={status:'REPLACED_TEMPORARY_ID',source,candidate_count:1};
    return row;
  });
}

export function resolveProject(records, identity) {
  return records.find(row=>[row.repd_ref,row.gg_project_id,...row.aliases].includes(identity)) ?? null;
}

Make Cartridge

A Python command-line tool in the season is named folder of PipelineNews that generates `cartridge.json`: a rating is per season, and the season is named.

ingestpipelinenews / tools/intelligence/cartridges/season-is-named/make_cartridge.py · lines 1–159 of 159 · Entry point · pattern anchor (shared by 16 files)

What it does
Defines read, anchor, main. Uses libraries argparse, io, json, os.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file cartridge.json; command-line arguments.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
Its name says it makes cartridge. Defines `read` and `anchor`. It accepts `--parent`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
pipelinenews · tools/intelligence/cartridges/season-is-named · Python CLI
Uses
argparse, io, json, os
Used by
none found
Produces
read, anchor, main
Defines here
read, anchor, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/season-is-named/make_cartridge.py:1-159 · blob a94cfeb2ac3b51c8d6eec3e20de5e6d29ca2ddbf · GitHub at these lines
State
achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
"""Generate cartridge.json: a rating is per season, and the season is named.

WHAT WAS CHECKED FIRST
----------------------
Whether Pipeline News quotes any MVA rating at all. It does not. A
case-insensitive search of every .html, .mjs and .css file in the parent
release 202608312339-pipelinenews for MVA, rating, season, winter and summer
finds one hit, and it is the word "corroborating" in
assets/202608311343-project-intelligence.mjs. The GRID and SUB chips quote
kilometres and kilovolts; the grid proximity panel quotes kilometres,
kilovolts and MW of the project itself. No surface quotes a circuit rating,
so there is no unseasoned rating to season. The second branch of the task
applies: the strip states that the ratings shown in the Atlas are per season
and never summed.

WHY THE SEASON MATTERS
----------------------
Read on 2 September 2026 from Ventusltd/data-grid-gb
derived/gb-transmission-network.v1.json, whose 1,392 circuits each carry
winter_mva, spring_mva, summer_mva and autumn_mva:

    circuits publishing winter_mva     1,392 of 1,392
    circuits publishing spring_mva     1,391
    circuits publishing summer_mva     1,276
    circuits publishing autumn_mva     1,276
    summer differs from winter         1,081 of the 1,276 that publish both
    winter >= summer                   1,273 of those 1,276

A rating quoted without its season is therefore ambiguous on most of the
network, and winter is the generous one. The Atlas shows every season the
operator publishes and names it; it does not add a site's circuit ratings
together, because that sum is not a quantity that exists in the network.

The strip already refuses headroom - "not a cable route, and not headroom"
- and that refusal is kept verbatim. This clause says something narrower:
what a rating IS when the reader sees one in the Atlas, so that no reader
carries a winter figure into a summer question, or a total into anything.

This cartridge changes one string in one file. It adds no payload, makes no
network call at render time, and touches no other surface.

    python tools/intelligence/cartridges/season-is-named/make_cartridge.py \
        --parent 202608312339-pipelinenews
"""

import argparse
import io
import json
import os

HERE = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(HERE))))
RELEASES = os.path.join(REPO, "releases")
APP = "assets/202608291447-app.mjs"


def read(path):
    return io.open(path, encoding="utf-8", newline="").read()


def anchor(text, needle, label):
    """A repair is an exact substitution, so the anchor must be unique.

    Asserting the count here rather than at build time means a parent whose
    text has moved fails while the cartridge is being written, with a name
    attached, instead of failing inside the builder with a diff.
    """
    n = text.count(needle)
    if n != 1:
        raise SystemExit("anchor %r occurs %d times, expected 1" % (label, n))
    return needle


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--parent", default="202608312339-pipelinenews")
    args = ap.parse_args()

    parent = os.path.join(RELEASES, args.parent)
    if not os.path.isdir(parent):
        raise SystemExit("no such release: %s" % parent)
    app = read(os.path.join(parent, APP))

    # The literal source bytes, including the · escape as it is written
    # in the file rather than the middle dot it denotes. This is the end of
    # the strip's count clause, immediately before the refusal; the cartridge
    # that extends the refusal anchors on the refusal itself, so the two are
    # independent and can be applied in either order.
    count_clause = "within 2 km of a circuit \\u00b7 "
    anchor(app, count_clause, "the GRID + SUB strip's count clause")

    added = ("no MVA rating is quoted here; the ratings the Atlas shows are "
             "per season, named, and never summed \\u2014 NESO publishes a "
             "winter rating for all 1,392 circuits and a summer rating for "
             "1,276, and summer differs from winter on 1,081 of those "
             "\\u00b7 ")

    cartridge = {
        "key": "season_is_named",
        "summary": (
            "Pipeline News quotes no MVA rating. The GRID + SUB strip now "
            "says so, and says that the ratings the Atlas shows are per "
            "season, named, and never summed, with NESO's own counts of "
            "which circuits publish which season."
        ),
        "modifies_existing_dashboard": True,
        "modification_note": "Extends one strip caption. No payload, no render-time network call.",
        "repairs": {
            "app": [
                {
                    "label": "the strip names the season a rating belongs to, without dropping a caveat",
                    "from": count_clause,
                    "to": count_clause + added,
                }
            ]
        },
        "registry_entry": {
            "schema": "pipelinenews.season-is-named.v1",
            "generation": "{GEN}",
            "usage_context": "NON_COMMERCIAL_OPEN_SOURCE",
            "usage_context_establishes_upstream_rights": False,
            "activation": "render-time; no payload",
            "additive_only": False,
            "mutates_existing_dashboard": "extends the GRID + SUB strip caption",
            "network_at_runtime": False,
            "rule": (
                "A rating without its season is ambiguous: NESO publishes a "
                "summer rating on 1,276 of 1,392 circuits and it differs "
                "from winter on 1,081 of them. Every rating the Atlas shows "
                "names its season and none is summed across circuits. A "
                "rating is still not headroom, and the strip's refusal on "
                "that point is kept verbatim. Pipeline News itself quotes "
                "no MVA figure and now says so."
            ),
            "found_by": (
                "Searching every .html, .mjs and .css file in the parent "
                "release for MVA, rating, season, winter and summer: one "
                "hit, the word 'corroborating'. Then reading the four "
                "seasonal fields on every circuit in Ventusltd/data-grid-gb "
                "derived/gb-transmission-network.v1.json on 2 September "
                "2026 and counting which are published and where they "
                "differ."
            ),
            "upstream": (
                "NESO Electricity Ten Year Statement 2025, Appendix B, via "
                "Ventusltd/data-grid-gb derived/gb-transmission-network.v1.json "
                "(circuits[].winter_mva, spring_mva, summer_mva, autumn_mva)"
            ),
        },
    }

    out = os.path.join(HERE, "cartridge.json")
    io.open(out, "w", encoding="utf-8", newline="\n").write(
        json.dumps(cartridge, indent=2, ensure_ascii=False) + "\n")
    print("wrote %s (parent %s)" % (out, args.parent))


if __name__ == "__main__":
    main()

Make Cartridge

A Python command-line tool in the sector open neutral sort folder of PipelineNews that repairs Sector Intelligence identity and the remaining distance verdict.

ingestpipelinenews / tools/intelligence/cartridges/sector-open-neutral-sort/make_cartridge.py · lines 1–111 of 111 · Entry point

What it does
Defines read, one, main. Uses libraries argparse, io, json, os, sys. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file cartridge.json; command-line arguments.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
Its name says it makes cartridge. Defines `read` and `one`. It accepts `--parent`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
pipelinenews · tools/intelligence/cartridges/sector-open-neutral-sort · Python CLI
Uses
argparse, io, json, os, sys
Used by
none found
Produces
read, one, main
Defines here
read, one, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/intelligence/cartridges/sector-open-neutral-sort/make_cartridge.py:1-111 · blob 43443115db45d09ea985a31b2e5c6f00318f2568 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: unknown · effects: process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
"""Repair Sector Intelligence identity and the remaining distance verdict.

The clean sector module is new code over the immutable 202608272130 payload.
Its one GENERATION constant was used for both identities, so the registry's
202608312109 module contract could not match the 202608272130 payload at the
same time. The browser rejects it before mount.

This repair separates module and payload generations. It also removes the last
connection-quality claim from the distance sorter: "best-connected" becomes a
literal description of the ordering.
"""

import argparse
import io
import json
import os
import sys

HERE = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(HERE))))
RELEASES = os.path.join(REPO, "releases")
SECTOR = "assets/202608312109-sector-intelligence.mjs"
PROXIMITY = "assets/202608311610-grid-proximity.mjs"


def read(path):
    return io.open(path, encoding="utf-8", newline="").read()


def one(text, needle, label):
    count = text.count(needle)
    if count != 1:
        raise SystemExit("anchor %r occurs %d times, expected 1" % (label, count))
    return needle


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--parent", default="202608312202-pipelinenews")
    args = parser.parse_args()
    parent = os.path.join(RELEASES, args.parent)
    sector = read(os.path.join(parent, SECTOR))
    proximity = read(os.path.join(parent, PROXIMITY))

    module_identity = (
        '// This module is a new cartridge over the immutable 202608272130 payload.\n'
        '// The two identities must not be collapsed into one constant.\n'
        'const GENERATION = "202608312109";\n'
        'const PAYLOAD_GENERATION = "202608272130";')

    manifest = {
        "key": "sector_open_neutral_sort",
        "summary": (
            "Sector Intelligence opens with separate module/payload identity; "
            "grid distance sorting makes no connection-quality claim."),
        "modifies_existing_dashboard": True,
        "modification_note": (
            "Separates the 202608312109 clean module contract from its immutable "
            "202608272130 payload identity and replaces best-connected with a "
            "literal shortest-distance ordering description."),
        "repairs": {
            "assets": [
                {
                    "path": SECTOR,
                    "edits": [
                        {
                            "label": "separate module identity from payload identity",
                            "from": one(
                                sector,
                                'const GENERATION = "202608272130";',
                                "collapsed sector identity"),
                            "to": module_identity,
                        },
                        {
                            "label": "validate the immutable payload against its own generation",
                            "from": one(
                                sector,
                                "payload.generation !== GENERATION",
                                "payload generation check"),
                            "to": "payload.generation !== PAYLOAD_GENERATION",
                        },
                    ],
                },
                {
                    "path": PROXIMITY,
                    "edits": [
                        {
                            "label": "describe the distance ordering without judging connection quality",
                            "from": one(
                                proximity,
                                "sorting by circuit distance puts the best-connected first.",
                                "best-connected claim"),
                            "to": "sorting by mapped circuit distance orders the measurements shortest first.",
                        }
                    ],
                },
            ]
        },
    }

    output = os.path.join(HERE, "cartridge.json")
    io.open(output, "w", encoding="utf-8", newline="").write(
        json.dumps(manifest, ensure_ascii=False, indent=2) + "\n")
    print("wrote cartridge.json")
    print("  sector identity repairs  2")
    print("  proximity copy repairs   1")
    return 0


if __name__ == "__main__":
    sys.exit(main())