In this section
- JavaScript V8 Live News Runtime energy-data · pipelinenews / ui/javascript/202608270844-v8-live-news-runtime.js lines 511–900
JavaScript V8 Live News Runtime
A JavaScript file in PipelineNews covering the Renewable Energy Planning Database (REPD) register, battery storage (BESS), solar and wind, using EPSG:27700 and SHA-256, and uses data from the GridAtlas repository.
Set aside from the main view: 93% of its lines are the same as releases/javascript/202609010719-v8-fast-runtime.js (pipelinenews), which stays. (near-copy-of, proposed by families.py). 92% of lines shared with JavaScript V8 Fast Runtime; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.927 to pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 releases/javascript/202609010719-v8-fast-runtime.js:1-942 8c5440bde1530575ada1a7f17cbfacd84f7903f4
- sha256 6c39694b32fe7b1364ef655bc3865833d74a063e9c5ce625e11d8d06ce2b0383
- target sha256 483ffd99803fbf1d8e0e5befc8de860d8530b63727532b748baa9d0cf1f0dcd6
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
energy-datapipelinenews / ui/javascript/202608270844-v8-live-news-runtime.js · lines 511–900 of 900 · version 2026-08-27 08:44 (continued from section 1061) · Not reached from any entry point (candidate for review) · pattern ensureSearchSupplement (shared by 6 files)
- What it does
- It draws the REPD register, battery storage (BESS), solar and wind. Defines 48 functions or classes, including FetchQueue, escapeHtml, normalise, invariant, arraysEqual. 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. Domain terms in the code: the REPD register, battery storage (BESS), solar, wind.
- Inputs & outputs
- In: data source: gridatlas data. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
- What it achieves
- It fetches queue (`FetchQueue`), hashes JSON (`hashJson`) and fetches immutable (`fetchImmutable`). Its `downloadCsv` function gives CSV download or refusal from active table owner, filtered register rows and official detail partitions (VEDIC: export filtered projects). It responds to click, change and input events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · ui/javascript · script
- VEDIC
- EXPORT FILTERED PROJECTS (GG2050-VEDIC-000060): Pipeline News · Renewable project register. active_table_owner, filtered_register_rows, official_detail_partitions → csv_download_or_refusal
- Uses
- none found
- Used by
- none found
- Produces
- FetchQueue, escapeHtml, normalise, invariant, arraysEqual, hashJson, fetchImmutable, promise, dictionary, project, compactSearchText, formatNumber
- Defines here
- loadDetailPartition, detailFor, hydrateDetail, copyProjectId, csvCell, downloadCsv, clearFilters, bindProjectControls, newsTechnology, newsMatches, newsHtml, drawNews, bindNewsControls, loadNews, createGauge, loadCharts, scheduleOptionalLoads, boot
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 ui/javascript/202608270844-v8-live-news-runtime.js:511-900 · blob 8887e581d1c2e0b6d9a78b3119c2f50ff560dc62 · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
invariant(payload.generation === registry.assets.search.generation, "search generation mismatch");
invariant(payload.cache_identity === registry.assets.search.cache_identity, "search cache identity mismatch");
invariant(payload.row_alignment === registry.cache_contract.search_index.row_alignment, "search row alignment mismatch");
invariant(Array.isArray(payload.rows) && payload.rows.length === rows.length, "search row count mismatch");
searchSupplement = payload.rows;
runtimeEvidence.searchReady = true;
return searchSupplement;
}
async function loadDetailPartition(partitionIndex) {
if (detailPromises.has(partitionIndex)) return detailPromises.get(partitionIndex);
const entry = registry.detail_partitions[partitionIndex];
invariant(entry, `detail partition ${partitionIndex} missing`);
const promise = detailQueue.add(async () => {
runtimeEvidence.detailRequests += 1;
const payload = await fetchImmutable(entry.path);
invariant(payload.schema === registry.detail_schema, `${entry.path} detail schema mismatch`);
invariant(payload.record_count === entry.record_count && payload.projects.length === entry.record_count, `${entry.path} detail count mismatch`);
for (const item of payload.projects) detailByRef.set(String(item.repd_ref), item);
runtimeEvidence.maximumDetailConcurrency = detailQueue.maximumActive;
return payload.projects;
});
detailPromises.set(partitionIndex, promise);
promise.catch(() => detailPromises.delete(partitionIndex));
return promise;
}
async function detailFor(index) {
const ref = String(rows[index][FIELD.repdRef]);
if (detailByRef.has(ref)) return detailByRef.get(ref);
const partition = Math.floor(index / registry.detail_partition_size);
await loadDetailPartition(partition);
const item = detailByRef.get(ref);
invariant(item, `REPD ${ref} missing from declared detail partition`);
return item;
}
async function hydrateDetail(details) {
if (details.dataset.loaded === "true" || details.dataset.loading === "true") return;
details.dataset.loading = "true";
const container = details.querySelector(".record-grid");
try {
const item = await detailFor(Number(details.dataset.detailIndex));
container.innerHTML = `<div><b>PLANNING AUTHORITY</b><span>${escapeHtml(item.planning_authority || "not supplied by REPD")}</span></div><div><b>PLANNING REF</b><span>${escapeHtml(item.planning_application_reference || "not supplied by REPD")}</span></div><div><b>DEVELOPMENT ID</b><span>${escapeHtml(item.gg_development_id || "not assigned")}</span></div><div><b>LIFECYCLE</b><span>${escapeHtml(i … [line shortened here: 682 characters; full line on GitHub]
details.dataset.loaded = "true";
} catch (error) {
console.error(error);
container.innerHTML = '<div class="detail-error">Official project details unavailable; the canonical row remains live.</div>';
} finally {
delete details.dataset.loading;
}
}
async function copyProjectId(button) {
const value = button.dataset.copyId;
try {
await navigator.clipboard.writeText(value);
} catch {
const field = document.createElement("textarea");
field.value = value;
field.style.position = "fixed";
field.style.opacity = "0";
document.body.appendChild(field);
field.select();
document.execCommand("copy");
field.remove();
}
const original = button.textContent;
button.textContent = "COPIED";
setTimeout(() => { button.textContent = original; }, 1200);
}
function csvCell(value) {
let text = value === null || value === undefined ? "" : String(value);
if (/^(?:[=+\-@]|\s+[=+\-@]|\t|\r|\n)/u.test(text)) text = `'${text}`;
return `"${text.replaceAll('"', '""')}"`;
}
async function downloadCsv(event) {
event.preventDefault();
const meta = document.getElementById("exportMeta");
meta.textContent = "Loading full official fields for filtered export…";
try {
await Promise.all(registry.detail_partitions.map((_, index) => loadDetailPartition(index)));
const headers = ["Site Name", "REPD Ref", "GlobalGrid Project ID", "GlobalGrid Development ID", "Identity Status", "Identity Confidence", "Technology", "Official REPD Technology", "Official REPD Capacity", "Capacity Unit", "Official REPD Status", "Derived Lifecycle", "Operator or Applicant", "County", "Region", "Country", "Planning Authority", "Planning Application Reference", "REPD Record Upd … [line shortened here: 1,132 characters; full line on GitHub]
const outputRows = filtered.map((index) => {
const compact = project(index);
const item = detailByRef.get(String(compact.repd_ref));
invariant(item, `REPD ${compact.repd_ref} unavailable for export`);
const signal = signalFor(compact);
return [item.name, item.repd_ref, item.gg_project_id, item.gg_development_id, item.identity_status, item.identity_confidence, LABELS[item.technology], item.repd_technology, item.capacity_mw, UNITS[item.technology], item.status, item.lifecycle, item.operator, item.county, item.region, item.country, item.planning_authority, item.planning_application_reference, item.repd_record_updated, item.pl … [line shortened here: 1,281 characters; full line on GitHub]
});
const content = `\ufeff${[headers, ...outputRows].map((row) => row.map(csvCell).join(",")).join("\r\n")}`;
const url = URL.createObjectURL(new Blob([content], { type: "text/csv;charset=utf-8" }));
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = `globalgrid2050_uk_renewables_pipeline_v8_fast_${new Date().toISOString().slice(0, 10)}.csv`;
anchor.click();
URL.revokeObjectURL(url);
meta.textContent = `${filtered.length.toLocaleString("en-GB")} filtered records exported`;
} catch (error) {
console.error(error);
meta.textContent = "export unavailable; no partial CSV was produced";
}
}
function clearFilters(event) {
event.preventDefault();
technology = "all";
status = "All";
county = "All";
query = "";
sortMode = "capacity_desc";
setButtonState("#tech", "technology", technology);
setButtonState("#status", "officialStatus", status);
document.getElementById("county").value = county;
document.getElementById("search").value = "";
document.getElementById("sortProjects").value = sortMode;
apply();
}
function bindProjectControls() {
if (controlsBound) return;
controlsBound = true;
document.querySelectorAll("#tech .btn").forEach((button) => {
button.addEventListener("click", () => {
technology = button.dataset.technology;
setButtonState("#tech", "technology", technology);
apply();
});
});
document.querySelectorAll("#status .btn").forEach((button) => {
button.addEventListener("click", () => {
status = button.dataset.officialStatus;
setButtonState("#status", "officialStatus", status);
apply();
});
});
document.getElementById("county").addEventListener("change", (event) => { county = event.target.value; apply(); });
document.getElementById("sortProjects").addEventListener("change", (event) => { sortMode = event.target.value; apply(); });
document.getElementById("sortUpdated").addEventListener("click", () => {
sortMode = sortMode === "updated_desc" ? "updated_asc" : "updated_desc";
document.getElementById("sortProjects").value = sortMode;
apply();
});
document.getElementById("search").addEventListener("input", (event) => {
query = event.target.value.trim();
clearTimeout(searchTimer);
if (!query) {
apply();
return;
}
document.getElementById("resultsMeta").textContent = "loading complete planning/reference search index…";
searchTimer = setTimeout(async () => {
try {
await ensureSearchSupplement();
apply();
} catch (error) {
console.error(error);
apply();
}
}, 120);
});
document.getElementById("export").addEventListener("click", downloadCsv);
document.getElementById("exportInline").addEventListener("click", downloadCsv);
document.getElementById("clearFilters").addEventListener("click", clearFilters);
document.getElementById("tbody").addEventListener("click", (event) => {
const copy = event.target.closest(".copy-id");
if (copy) copyProjectId(copy);
const summary = event.target.closest("summary");
const details = summary?.closest("details[data-detail-index]");
if (details) hydrateDetail(details);
});
}
function newsTechnology(row) {
return String(row[NEWS_FIELD.technology] || row[NEWS_FIELD.regionalTechnology] || "").toUpperCase();
}
function newsMatches(row) {
const event = String(row[NEWS_FIELD.event] || "").toUpperCase();
const newsTechnologyValue = newsTechnology(row);
const regional = row[NEWS_FIELD.region];
if (newsMode === "UK" && row[NEWS_FIELD.canonical] !== true) return false;
if (newsMode === "INTERNATIONAL" && !regional) return false;
if (newsMode === "US" && regional !== "US") return false;
if (newsMode === "EUROPE" && regional !== "EUROPE") return false;
if (newsMode === "SOLAR" && !newsTechnologyValue.includes("SOLAR")) return false;
if (newsMode === "BESS" && !newsTechnologyValue.includes("BESS")) return false;
if (newsMode === "CONSENT" && event !== "CONSENT") return false;
if (newsMode === "CONSTRUCTION" && event !== "CONSTRUCTION") return false;
if (newsMode === "OPERATIONAL" && event !== "OPERATIONAL") return false;
if (newsMode === "FINANCE" && !FINANCE_EVENTS.has(event)) return false;
if (newsQuery) {
const haystack = normalise([
row[NEWS_FIELD.headline],
row[NEWS_FIELD.project],
row[NEWS_FIELD.operator],
row[NEWS_FIELD.county],
row[NEWS_FIELD.source],
row[NEWS_FIELD.event],
row[NEWS_FIELD.eventDetail],
row[NEWS_FIELD.repdRef],
row[NEWS_FIELD.projectId],
row[NEWS_FIELD.relatedContextRepdRef],
row[NEWS_FIELD.relatedContextProject],
row[NEWS_FIELD.bindingLabel],
JSON.stringify(row[NEWS_FIELD.relatedComponents] || []),
].join(" "));
const tokens = normalise(newsQuery).split(" ").filter(Boolean);
if (!tokens.every((token) => haystack.includes(token))) return false;
}
return true;
}
function newsHtml(row) {
const regional = row[NEWS_FIELD.region];
const technologyValue = newsTechnology(row);
const articleClass = technologyValue.includes("BESS") ? "bess" : "solar";
const projectName = row[NEWS_FIELD.project] || "";
const capacity = Number(row[NEWS_FIELD.capacity] || 0);
const role = String(row[NEWS_FIELD.role] || "");
const relatedContextProject = String(row[NEWS_FIELD.relatedContextProject] || "");
const relatedContextRef = String(row[NEWS_FIELD.relatedContextRepdRef] || "");
const relatedComponents = Array.isArray(row[NEWS_FIELD.relatedComponents]) ? row[NEWS_FIELD.relatedComponents] : [];
const eventDetail = String(row[NEWS_FIELD.eventDetail] || "").replaceAll("_", " ");
const quality = role === "RELATED_MENTION"
? `<span class="news-quality unverified">${escapeHtml(row[NEWS_FIELD.bindingLabel] || "RELATED CONTEXT ONLY — NOT A PROJECT BINDING")}</span>${relatedContextProject ? ` · context: ${escapeHtml(relatedContextProject)}` : ""}${relatedContextRef ? ` · related REPD ${escapeHtml(relatedContextRef)}` : ""} · no project signal`
: row[NEWS_FIELD.canonical] === true
? `<span class="news-quality relevant">RELEVANT ${Number(row[NEWS_FIELD.confidence] || 0)}%</span> · PRIMARY_MATCH · REPD ${escapeHtml(row[NEWS_FIELD.repdRef])}`
: regional
? `<span class="news-quality relevant">${escapeHtml(regional === "INTERNATIONAL_OTHER" ? "INTERNATIONAL" : regional)}</span> · ${escapeHtml(row[NEWS_FIELD.regionalEvidence])} · regional discovery only · no REPD project signal`
: '<span class="news-quality unverified">DISCOVERY ONLY</span> · no project signal';
const componentNote = relatedComponents.length
? `<p>${relatedComponents.map((component) => `RELATED DEVELOPMENT · REPD ${escapeHtml(component.repd_ref || "unknown")} · ${escapeHtml(String(component.technology || "").toUpperCase())}${Number.isFinite(component.official_capacity_mw) ? ` · ${Number(component.official_capacity_mw).toLocaleString("en-GB")} MW` : " · official capacity unknown"} · no project signal`).join(" · ")}</p>`
: "";
return `<a class="story ${articleClass}" data-article-id="${escapeHtml(row[NEWS_FIELD.articleId])}" href="${escapeHtml(row[NEWS_FIELD.url])}" target="_blank" rel="noopener"><div class="kicker">${escapeHtml(technologyValue || "ENERGY")} · ${escapeHtml(row[NEWS_FIELD.event] || "PROJECT UPDATE")}${eventDetail ? ` · ${escapeHtml(eventDetail)}` : ""} · ${escapeHtml(row[NEWS_FIELD.published] || "")}</ … [line shortened here: 900 characters; full line on GitHub]
}
function drawNews() {
const matches = newsRows.filter(newsMatches);
const stories = document.getElementById("stories");
if (newsStart >= matches.length) newsStart = 0;
if (!matches.length) {
stories.innerHTML = '<div class="news-empty">No headlines match this newspaper filter.</div>';
} else {
stories.innerHTML = matches.slice(newsStart, newsStart + NEWS_WINDOW_SIZE).map(newsHtml).join("");
}
let pager = document.getElementById("newsPager");
if (!pager) {
pager = document.createElement("div");
pager.id = "newsPager";
pager.className = "news-pager";
pager.innerHTML = '<button id="newsPrevious" type="button">PREVIOUS 30</button><span id="newsWindowRange"></span><button id="newsMore" type="button">NEXT 30</button>';
document.querySelector(".paper").after(pager);
pager.querySelector("#newsPrevious").addEventListener("click", () => {
newsStart = Math.max(0, newsStart - NEWS_WINDOW_SIZE);
drawNews();
});
pager.querySelector("#newsMore").addEventListener("click", () => {
newsStart += NEWS_WINDOW_SIZE;
drawNews();
});
}
const end = Math.min(matches.length, newsStart + NEWS_WINDOW_SIZE);
const previous = pager.querySelector("#newsPrevious");
const more = pager.querySelector("#newsMore");
previous.disabled = newsStart === 0;
more.disabled = end >= matches.length;
pager.querySelector("#newsWindowRange").textContent = matches.length
? `${newsStart + 1}–${end} of ${matches.length.toLocaleString("en-GB")}`
: "0 headlines";
more.textContent = `NEXT ${Math.min(NEWS_WINDOW_SIZE, Math.max(0, matches.length - end))} · ${matches.length.toLocaleString("en-GB")} MATCHES`;
}
function bindNewsControls() {
document.querySelectorAll("#newsTools button").forEach((button) => {
button.addEventListener("click", () => {
document.querySelectorAll("#newsTools button").forEach((candidate) => candidate.classList.remove("active"));
button.classList.add("active");
newsMode = button.dataset.news;
newsStart = 0;
drawNews();
});
});
document.getElementById("newsSearch").addEventListener("input", (event) => {
newsQuery = event.target.value.trim();
newsStart = 0;
drawNews();
});
}
async function loadNews() {
if (runtimeEvidence.newsReady) return;
runtimeEvidence.newsRequests += 1;
try {
const payload = await fetchImmutable(registry.assets.news.path);
invariant(payload.schema === registry.assets.news.schema, "news schema mismatch");
invariant(payload.generation === registry.assets.news.generation, "news generation mismatch");
invariant(payload.cache_identity === registry.assets.news.cache_identity, "news cache identity mismatch");
invariant(arraysEqual(payload.fields, NEWS_FIELDS), "news field contract mismatch");
invariant(payload.rows.length === registry.news_counts.all, "news count mismatch");
newsRows = payload.rows;
runtimeEvidence.newsReady = true;
document.getElementById("newsMeta").textContent = `${registry.news_counts.uk} UK · ${registry.news_counts.international} international (${registry.news_counts.us} US · ${registry.news_counts.europe} Europe · ${registry.news_counts.other} other) · ${registry.news_counts.all} headlines · immutable compact edition`;
drawNews();
} catch (error) {
console.error(error);
document.getElementById("stories").innerHTML = '<div class="news-empty">Newspaper unavailable. REPD analytics remain live.</div>';
document.getElementById("newsMeta").textContent = "newspaper unavailable";
}
}
function createGauge(canvasId, colour) {
const options = { responsive: true, maintainAspectRatio: false, circumference: 180, rotation: 270, cutout: "80%", plugins: { tooltip: { enabled: false }, legend: { display: false } } };
return new globalThis.Chart(document.getElementById(canvasId), { type: "doughnut", data: { datasets: [{ data: [0, 1], backgroundColor: [colour, "#222"], borderWidth: 0 }] }, options });
}
async function loadCharts() {
if (runtimeEvidence.chartsReady) return;
await new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = registry.assets.chart.path;
script.async = true;
script.onload = resolve;
script.onerror = () => reject(new Error("pinned Chart.js failed to load"));
document.head.appendChild(script);
});
invariant(typeof globalThis.Chart === "function", "pinned Chart.js API unavailable");
charts.capacity = createGauge("g1", "#ff00ff");
charts.projects = createGauge("g2", "#00ffff");
charts.largest = createGauge("g3", "#00ff88");
runtimeEvidence.chartsReady = true;
updateGauges({ count: filtered.length, capacity: filtered.reduce((sum, index) => sum + Number(rows[index][FIELD.capacity]), 0), largest: filtered.reduce((maximum, index) => Math.max(maximum, Number(rows[index][FIELD.capacity])), 0) });
}
function scheduleOptionalLoads() {
setTimeout(() => {
const schedule = globalThis.requestIdleCallback || ((callback) => setTimeout(callback, 0));
schedule(() => loadNews(), { timeout: 1500 });
schedule(() => loadCharts().catch((error) => console.error(error)), { timeout: 2000 });
}, 1000);
}
async function boot() {
registry = await fetchImmutable(REGISTRY_URL);
invariant(registry.schema === "pipelinenews.v8.live-news-registry.v1", "registry schema mismatch");
invariant(registry.generation === GENERATION, "registry generation mismatch");
invariant(registry.compiler_method === EXPECTED_COMPILER_METHOD, "registry compiler method mismatch");
invariant(registry.cache_identity === EXPECTED_CACHE_IDENTITY, "registry cache identity mismatch");
invariant(await hashJson(registry.cache_contract) === EXPECTED_CACHE_IDENTITY, "registry cache contract digest mismatch");
invariant(registry.cache_contract.compiler_method === EXPECTED_COMPILER_METHOD, "cache compiler method mismatch");
invariant(arraysEqual(registry.cache_contract.project_index.fields, PROJECT_FIELDS), "registry project field contract mismatch");
invariant(arraysEqual(registry.cache_contract.news_index.fields, NEWS_FIELDS), "registry news field contract mismatch");
invariant(registry.cache_contract.news_index.stable_key === "gg_article_id", "registry news key contract mismatch");
invariant(registry.cache_contract.runtime.physical_project_rows === WINDOW_SIZE, "project window contract mismatch");
invariant(registry.cache_contract.runtime.physical_news_rows === NEWS_WINDOW_SIZE, "news window contract mismatch");
invariant(registry.cache_contract.runtime.detail_fetch_concurrency === DETAIL_CONCURRENCY, "detail concurrency contract mismatch");
projectPayload = await fetchImmutable(registry.assets.projects.path);
invariant(projectPayload.schema === registry.assets.projects.schema, "project index schema mismatch");
invariant(projectPayload.generation === registry.assets.projects.generation, "project generation mismatch");
invariant(projectPayload.cache_identity === registry.assets.projects.cache_identity, "project cache identity mismatch");
invariant(arraysEqual(projectPayload.fields, PROJECT_FIELDS), "project field contract mismatch");
invariant(projectPayload.rows.length === registry.totals.project_count, "project index count mismatch");
rows = projectPayload.rows;
dictionaries = projectPayload.dictionaries;
updatedTimes = rows.map((row) => {
const value = row[FIELD.updated];
const timestamp = value ? Date.parse(`${value}T00:00:00Z`) : NaN;
return Number.isFinite(timestamp) ? timestamp : null;
});
bindProjectControls();
bindNewsControls();
populateCounties();
hydrateFiltersFromUrl();
if (query) await ensureSearchSupplement();
apply({ syncUrl: false });
document.getElementById("releaseMeta").textContent = `Live News Discovery candidate · ${rows.length.toLocaleString("en-GB")} canonical projects · ${registry.performance.maximum_physical_project_rows} physical rows · full details loaded only on demand · NOT DEPLOYED`;
document.body.dataset.fastReady = "true";
document.body.dataset.fastGeneration = GENERATION;
globalThis.dispatchEvent(new CustomEvent("pipelinenews-fast-ready", { detail: { generation: GENERATION } }));
scheduleOptionalLoads();
}
boot().catch((error) => {
console.error(error);
document.getElementById("tbody").innerHTML = '<tr><td colspan="11" class="fast-fail">Canonical Q2 REPD data unavailable. The fast candidate has failed closed.</td></tr>';
document.getElementById("resultsMeta").textContent = "canonical data unavailable";
document.body.dataset.fastFailed = "true";
});