In this section
- Compare Atlas V8 Deep Links ingest · pipelinenews / atman/202608271329-compare-atlas-v8-deep-links.mjs lines 1–169
- Resolve GridAtlas Pointer storage · pipelinenews / atman/202608291504-resolve-gridatlas-pointer.mjs lines 1–184
- Verify Current Atlas V9 Deep Link electrical · pipelinenews / atman/202608300309-verify-current-atlas-v9-deep-link.mjs lines 1–328
Compare Atlas V8 Deep Links
A JavaScript module in the atman folder of PipelineNews that reads the Renewable Energy Planning Database (REPD) register, using SHA-256.
ingestpipelinenews / atman/202608271329-compare-atlas-v8-deep-links.mjs · lines 1–169 of 169 · version 2026-08-27 13:29 · Not reached from any entry point (candidate for review)
- What it does
- It loads the REPD register. Defines 6 functions or classes, including sha256, projectDecoder, parseAdapterArgument, parameterOrder, atlasParameters. Uses libraries node:assert/strict, node:crypto, node:fs/promises, node:path, node:url. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): 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.
- Inputs & outputs
- In: JSON file 202608270055-8ab1807551bc-v8-fast-projects.json; command-line arguments.
- What it achieves
- It parses adapter argument (`parseAdapterArgument`) and is built from the project decoder helper (`projectDecoder`) and the parameter order helper (`parameterOrder`). Defines `sha256`, `projectDecoder`, `parseAdapterArgument` and 2 more.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · atman · JavaScript module
- Uses
- Projects V9 5 1 (import), Atlas V8 Deep Link (import), node:assert/strict, node:crypto, node:fs/promises, node:path, node:url
- Used by
- none found
- Produces
- sha256, projectDecoder, parseAdapterArgument, parameterOrder, atlasParameters, main
- Defines here
- sha256, projectDecoder, parseAdapterArgument, parameterOrder, atlasParameters, 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 atman/202608271329-compare-atlas-v8-deep-links.mjs:1-169 · blob 7cd32a01c4bd43f68a864543da21d8e38fdb7a13 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { atlasUrlV9_5_1 as trustedAtlasUrl } from "../archive/202608261547-pipelinenews/202608260159-pipelinenews/scripts/plugins/projects-v9-5-1.js";
import {
ATLAS_V8_DEEP_LINK_CONTRACT,
buildAtlasV8DeepLink,
} from "../ui/cartridges/202608271329-atlas-v8-deep-link.mjs";
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const TRUSTED_SOURCE = "archive/202608261547-pipelinenews/202608260159-pipelinenews/scripts/plugins/projects-v9-5-1.js";
const TRUSTED_SHA256 = "f0c63602d85a5726aa38106157e8d3d6924d0ab1a684194ffe2de93df1c6d823";
const PARENT_RUNTIME = "releases/javascript/202608270844-v8-fast-runtime.js";
const PROJECTS = "releases/data/202608270055-8ab1807551bc-v8-fast-projects.json";
const PROJECTS_SHA256 = "c06aedef176d2d38fd135806306a8ef81b4af9994c7be31e8bd760304149f862";
const EXPECTED_PARAMETERS = [
"repd_ref",
"project",
"technology",
"capacity_mw",
"latitude",
"longitude",
"zoom",
];
function sha256(bytes) {
return createHash("sha256").update(bytes).digest("hex");
}
function projectDecoder(payload) {
const field = Object.fromEntries(payload.fields.map((name, index) => [name, index]));
return (row) => ({
repd_ref: row[field.repd_ref],
gg_project_id: row[field.gg_project_id],
name: row[field.name],
technology: payload.dictionaries.technology[row[field.technology]],
status: payload.dictionaries.status[row[field.status]],
capacity_mw: row[field.capacity_mw],
county: payload.dictionaries.county[row[field.county]],
region: payload.dictionaries.region[row[field.region]],
operator: payload.dictionaries.operator[row[field.operator]],
repd_record_updated: row[field.repd_record_updated],
geometry_status: payload.dictionaries.geometry_status[row[field.geometry_status]],
latitude: row[field.latitude],
longitude: row[field.longitude],
});
}
function parseAdapterArgument(argv) {
if (argv.length === 0) return null;
assert.equal(argv.length, 2, "usage: --adapter <compiled-cartridge-path>");
assert.equal(argv[0], "--adapter", "usage: --adapter <compiled-cartridge-path>");
const relative = path.posix.normalize(argv[1]);
assert.ok(relative.startsWith("releases/javascript/202608271329-"), "adapter must be the timestamped release cartridge");
const absolute = path.resolve(ROOT, relative);
assert.ok(absolute.startsWith(`${ROOT}${path.sep}`), "adapter escapes repository");
return { relative, absolute };
}
function parameterOrder(url) {
return [...new URL(url).searchParams.keys()];
}
function atlasParameters(source, functionName) {
const start = source.indexOf(`function ${functionName}`);
assert.ok(start >= 0, `missing ${functionName}`);
const tail = source.slice(start, start + 1_500);
return [...tail.matchAll(/searchParams\.set\("([^"]+)"/gu)].map((match) => match[1]);
}
async function main() {
const adapterArgument = parseAdapterArgument(process.argv.slice(2));
const trustedBytes = await readFile(path.join(ROOT, TRUSTED_SOURCE));
assert.equal(sha256(trustedBytes), TRUSTED_SHA256, "trusted V9.6.2 builder changed");
assert.deepEqual(
atlasParameters(trustedBytes.toString("utf8"), "atlasUrlV9_5_1"),
EXPECTED_PARAMETERS,
"trusted V9.6.2 query contract changed",
);
const parentRuntimeBytes = await readFile(path.join(ROOT, PARENT_RUNTIME));
assert.deepEqual(
atlasParameters(parentRuntimeBytes.toString("utf8"), "atlasUrl"),
["repd_ref", "technology", "longitude", "latitude"],
"08:44 regression evidence changed",
);
let adapterBuild = buildAtlasV8DeepLink;
let adapterContract = ATLAS_V8_DEEP_LINK_CONTRACT;
let adapterSha256 = null;
if (adapterArgument) {
const adapterBytes = await readFile(adapterArgument.absolute);
adapterSha256 = sha256(adapterBytes);
const adapter = await import(`${pathToFileURL(adapterArgument.absolute).href}?${adapterSha256}`);
adapterBuild = adapter.buildAtlasV8DeepLink;
adapterContract = adapter.ATLAS_V8_DEEP_LINK_CONTRACT;
}
assert.deepEqual(adapterContract, ATLAS_V8_DEEP_LINK_CONTRACT, "compiled cartridge contract changed");
const projectBytes = await readFile(path.join(ROOT, PROJECTS));
assert.equal(sha256(projectBytes), PROJECTS_SHA256, "compact project cartridge changed");
const payload = JSON.parse(projectBytes);
assert.equal(payload.rows.length, 7_680);
const decode = projectDecoder(payload);
let mapLinks = 0;
let noMap = 0;
let blankProjectParameters = 0;
for (const row of payload.rows) {
const project = decode(row);
const trusted = trustedAtlasUrl(project);
const source = buildAtlasV8DeepLink(project);
const compiled = adapterBuild(project);
assert.equal(source, trusted, `source cartridge differs from V9.6.2 for REPD ${project.repd_ref}`);
assert.equal(compiled, trusted, `compiled cartridge differs from V9.6.2 for REPD ${project.repd_ref}`);
if (!trusted) {
noMap += 1;
assert.notEqual(project.geometry_status, "valid");
continue;
}
mapLinks += 1;
assert.equal(project.geometry_status, "valid");
assert.deepEqual(parameterOrder(trusted), EXPECTED_PARAMETERS, `parameter order changed for REPD ${project.repd_ref}`);
const url = new URL(trusted);
assert.equal(url.protocol, "https:");
assert.equal(url.hostname, "globalgrid2050.com");
assert.equal(url.pathname, "/repd_grid_atlasv8/");
assert.equal(url.searchParams.get("repd_ref"), String(project.repd_ref));
assert.equal(url.searchParams.get("technology"), String(project.technology));
assert.equal(url.searchParams.get("zoom"), "12");
if (url.searchParams.get("project") === "") blankProjectParameters += 1;
}
assert.equal(mapLinks, 7_652);
assert.equal(noMap, 28);
assert.equal(blankProjectParameters, 2, "blank V9.6.2 project parameters must remain representable");
const byRef = new Map(payload.rows.map((row) => [String(row[0]), decode(row)]));
for (const sentinel of Object.values(ATLAS_V8_DEEP_LINK_CONTRACT.sentinels)) {
const project = byRef.get(sentinel.repd_ref);
assert.ok(project, `missing sentinel REPD ${sentinel.repd_ref}`);
assert.equal(adapterBuild(project), sentinel.expected_url, `sentinel changed: REPD ${sentinel.repd_ref}`);
}
process.stdout.write(`${JSON.stringify({
schema: "pipelinenews.atman.atlas-v8-deep-link-parity.v1",
generation: ATLAS_V8_DEEP_LINK_CONTRACT.generation,
parent_generation: ATLAS_V8_DEEP_LINK_CONTRACT.parent_generation,
trusted_source: TRUSTED_SOURCE,
trusted_source_sha256: TRUSTED_SHA256,
parent_regression_parameters: ["repd_ref", "technology", "longitude", "latitude"],
restored_parameters: EXPECTED_PARAMETERS,
project_count: payload.rows.length,
map_links: mapLinks,
no_map: noMap,
blank_project_parameters: blankProjectParameters,
adapter: adapterArgument?.relative || "source-cartridge",
adapter_sha256: adapterSha256,
status: "PASS",
}, null, 2)}\n`);
}
main().catch((error) => {
process.stderr.write(`${error.stack || error.message}\n`);
process.exitCode = 1;
});Resolve GridAtlas Pointer
A JavaScript module in the atman folder of PipelineNews that fetches fast site, using SHA-256 from GitHub API. It parses args (`parseArgs`), reads bundle (`readBundle`) and validates pointer bundle (`validatePointerBundle`).
storagepipelinenews / atman/202608291504-resolve-gridatlas-pointer.mjs · lines 1–184 of 184 · version 2026-08-29 15:04 · Entry point · pattern parseArgs (shared by 14 files)
- What it does
- It fetches fast site. Defines 8 functions or classes, including parseArgs, sha256, record, githubJson, githubFile. Uses libraries node:assert/strict, node:crypto, node:child_process, node:fs/promises, node:path. Side effects: reads or writes files; makes network requests; starts processes.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'gridatlas'): 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: data source: GitHub API; JSON file current-v3.json; JSON file live-set.json; JSON file 202608271524-v8-fast-site-manifest.json; JSON file release-manifest.json; command-line arguments.
- Downstream impact
- Used directly by 1 file: Atlas Pointer Deep Link Successor (pipelinenews).
- What it achieves
- Defines `parseArgs`, `sha256`, `record` and 4 more.
- Why it matters
- Run by Atlas Pointer Deep Link Successor.
- Application
- pipelinenews · atman · JavaScript module
- Uses
- V8 Fast Candidate (estate URL), node:assert/strict, node:crypto, node:child_process, node:fs/promises, node:path, node:util, node:url
- Used by
- run by Atlas Pointer Deep Link Successor (workflow run)
- Produces
- validatePointerBundle, main
- Defines here
- parseArgs, sha256, record, githubJson, githubFile, readBundle, validatePointerBundle, 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 atman/202608291504-resolve-gridatlas-pointer.mjs:1-184 · blob bc76e3b1d65fd4043fcbc99181d46a421735ff38 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem, network, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env node
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { execFile } from "node:child_process";
import { mkdir, readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import { promisify } from "node:util";
import { pathToFileURL } from "node:url";
const execFileAsync = promisify(execFile);
const DEFAULT_REPOSITORY = "Ventusltd/gridatlas";
const POINTER_PATH = "releases/current-v3.json";
const MIRROR_PATH = "state/live-set.json";
const FALLBACK = Object.freeze({
classification: "LAST_KNOWN_GREEN_V8_PUBLIC_CANDIDATE",
generation: "202608271524",
route: "/pipelinenews/releases/202608271524-v8-fast-candidate.html",
public_url: "https://ventusltd.github.io/pipelinenews/releases/202608271524-v8-fast-candidate.html",
pages_run_id: 33085685060,
manifest_path: "build/202608271524-v8-fast-site-manifest.json",
manifest_sha256: "fef485accb1509297dbc64c5e30806c60d977bedb06591e8b324e7bbab06e818",
retention_rule: "PRESERVE_ON_ANY_GRIDATLAS_POINTER_OR_RECEIVER_FAILURE",
});
function parseArgs(argv) {
const args = {};
for (let index = 0; index < argv.length; index += 2) {
assert.match(argv[index] || "", /^--[a-z0-9-]+$/u);
assert.ok(argv[index + 1], `missing value for ${argv[index]}`);
args[argv[index].slice(2)] = argv[index + 1];
}
assert.ok(args.output, "missing --output");
assert.ok(Boolean(args["gridatlas-root"]) !== Boolean(args.repository), "provide exactly one of --gridatlas-root or --repository");
if (args.repository) assert.match(args.repository, /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u);
if (args["expected-pointer-sha256"]) assert.match(args["expected-pointer-sha256"], /^[0-9a-f]{64}$/u);
if (args["expected-commit"]) assert.match(args["expected-commit"], /^[0-9a-f]{40}$/u);
return args;
}
const sha256 = (raw) => createHash("sha256").update(raw).digest("hex");
const record = (relative, raw) => Object.freeze({ path: relative, bytes: raw.length, sha256: sha256(raw) });
async function githubJson(url, token) {
const response = await fetch(url, {
headers: {
Accept: "application/vnd.github+json",
...(token ? { Authorization: `Bearer ${token}` } : {}),
"User-Agent": "PipelineNews-GridAtlas-Pointer-Resolver/1",
"X-GitHub-Api-Version": "2022-11-28",
},
});
assert.equal(response.ok, true, `GitHub ${response.status}: ${url}`);
return response.json();
}
async function githubFile(repository, commit, relative, token) {
const value = await githubJson(`https://api.github.com/repos/${repository}/contents/${relative}?ref=${commit}`, token);
assert.equal(value.type, "file", `not a GitHub file: ${relative}`);
assert.equal(value.encoding, "base64", `unexpected GitHub encoding: ${relative}`);
return Buffer.from(String(value.content || "").replace(/\s/gu, ""), "base64");
}
async function readBundle(args) {
if (args["gridatlas-root"]) {
const root = path.resolve(args["gridatlas-root"]);
const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], { cwd: root, encoding: "utf8" });
const commit = stdout.trim();
assert.match(commit, /^[0-9a-f]{40}$/u);
const pointerRaw = await readFile(path.join(root, POINTER_PATH));
const pointer = JSON.parse(pointerRaw);
const releaseId = pointer?.current?.release_id;
assert.match(String(releaseId || ""), /^\d{12}-atlas-v9$/u);
return {
repository: DEFAULT_REPOSITORY,
commit,
pointerRaw,
mirrorRaw: await readFile(path.join(root, MIRROR_PATH)),
manifestPath: `${releaseId}/release-manifest.json`,
manifestRaw: await readFile(path.join(root, releaseId, "release-manifest.json")),
};
}
const repository = args.repository;
const token = process.env.GH_TOKEN || "";
const branch = await githubJson(`https://api.github.com/repos/${repository}/branches/main`, token);
const commit = branch?.commit?.sha;
assert.match(String(commit || ""), /^[0-9a-f]{40}$/u, "GridAtlas main commit unavailable");
const pointerRaw = await githubFile(repository, commit, POINTER_PATH, token);
const pointer = JSON.parse(pointerRaw);
const releaseId = pointer?.current?.release_id;
assert.match(String(releaseId || ""), /^\d{12}-atlas-v9$/u);
const manifestPath = `${releaseId}/release-manifest.json`;
const [mirrorRaw, manifestRaw] = await Promise.all([
githubFile(repository, commit, MIRROR_PATH, token),
githubFile(repository, commit, manifestPath, token),
]);
return { repository, commit, pointerRaw, mirrorRaw, manifestPath, manifestRaw };
}
export function validatePointerBundle(bundle, expectations = {}) {
assert.equal(bundle.pointerRaw.equals(bundle.mirrorRaw), true, "GridAtlas current-v3/live-set bytes differ");
const pointerRecord = record(POINTER_PATH, bundle.pointerRaw);
if (expectations.pointerSha256) assert.equal(pointerRecord.sha256, expectations.pointerSha256, "GridAtlas pointer digest changed");
if (expectations.commit) assert.equal(bundle.commit, expectations.commit, "GridAtlas pointer commit changed");
const pointer = JSON.parse(bundle.pointerRaw);
assert.equal(pointer.schema, "gridatlas.live-set.v3");
assert.equal(pointer.classification, "VERIFIED_LIVE_ATLAS_V9");
assert.match(String(pointer.generation || ""), /^\d{12}$/u);
const current = pointer.current || {};
assert.match(String(current.release_id || ""), /^\d{12}-atlas-v9$/u);
assert.equal(current.query_contract?.parameter, "repd_ref");
assert.match(String(current.query_contract?.golden_value || ""), /^\d+$/u);
assert.match(String(current.source_commit || ""), /^[0-9a-f]{40}$/u);
assert.match(String(current.publication_commit || ""), /^[0-9a-f]{40}$/u);
assert.match(String(current.release_manifest_sha256 || ""), /^[0-9a-f]{64}$/u);
const live = new URL(current.live_url);
assert.equal(live.protocol, "https:");
assert.equal(live.hostname, "ventusltd.github.io");
assert.equal(live.pathname, `/gridatlas/${current.release_id}/`);
assert.equal(live.search, "");
assert.equal(live.hash, "");
assert.equal(current.route, live.pathname);
const manifestRecord = record(bundle.manifestPath, bundle.manifestRaw);
assert.equal(manifestRecord.sha256, current.release_manifest_sha256, "GridAtlas release manifest digest changed");
const manifest = JSON.parse(bundle.manifestRaw);
assert.equal(manifest.schema, "gridatlas.timestamped-live-release.v1");
assert.equal(manifest.classification, "LIVE_RELEASE");
assert.equal(manifest.release_id, current.release_id);
assert.equal(manifest.generation, pointer.generation);
assert.equal(manifest.live_url, current.live_url);
assert.equal(manifest.source_commit, current.source_commit);
assert.equal(manifest.route_contract?.query_parameter, "repd_ref");
assert.equal(manifest.route_contract?.route, current.route);
const golden = new URL(manifest.route_contract?.golden_deep_link);
assert.equal(golden.origin, live.origin);
assert.equal(golden.pathname, live.pathname);
assert.deepEqual([...golden.searchParams.keys()], ["repd_ref"]);
assert.equal(golden.searchParams.get("repd_ref"), String(current.query_contract.golden_value));
return Object.freeze({
schema: "pipelinenews.gridatlas-pointer-receipt.v1",
classification: "VERIFIED_GRIDATLAS_LIVE_POINTER",
repository: bundle.repository,
resolved_ref: "refs/heads/main",
resolved_commit: bundle.commit,
pointer: pointerRecord,
mirror: record(MIRROR_PATH, bundle.mirrorRaw),
release_manifest: manifestRecord,
receiver: Object.freeze({
generation: pointer.generation,
release_id: current.release_id,
base_url: current.live_url,
route: current.route,
query_parameter: "repd_ref",
golden_repd_ref: String(current.query_contract.golden_value),
source_commit: current.source_commit,
publication_commit: current.publication_commit,
}),
fallback: FALLBACK,
});
}
export async function main(argv = process.argv.slice(2)) {
const args = parseArgs(argv);
const bundle = await readBundle(args);
const receipt = validatePointerBundle(bundle, {
pointerSha256: args["expected-pointer-sha256"],
commit: args["expected-commit"],
});
const output = path.resolve(args.output);
await mkdir(path.dirname(output), { recursive: true });
await writeFile(output, `${JSON.stringify(receipt, null, 2)}\n`);
process.stdout.write(`${JSON.stringify({ classification: receipt.classification, commit: receipt.resolved_commit, receiver: receipt.receiver.base_url, golden_repd_ref: receipt.receiver.golden_repd_ref })}\n`);
}
if (process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url) {
main().catch((error) => {
process.stderr.write(`${error.stack || error.message}\n`);
process.exitCode = 1;
});
}Verify Current Atlas V9 Deep Link
A JavaScript module in the atman folder of PipelineNews that fetches diagnostic and the Renewable Energy Planning Database (REPD) register.
electricalpipelinenews / atman/202608300309-verify-current-atlas-v9-deep-link.mjs · lines 1–328 of 328 · version 2026-08-30 03:09 · Entry point · pattern isKnownLegacyDuplicateEngineError (shared by 2 files)
- What it does
- It fetches diagnostic and the REPD register. Defines writeJson, pageDiagnostics, dictionary, isKnownLegacyDuplicateEngineError. Uses libraries node:fs/promises, playwright. Side effects: changes the web page (DOM); reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): 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.
- Inputs & outputs
- In: JSON file -diagnostic.json; JSON file 202608291447-registry.json.
- Downstream impact
- Used directly by 2 files: PipelineNews Current GridAtlas V9 Deep Link Successor Workflow (pipelinenews); PipelineNews Resume Exact Atlas Pages Promotion Workflow (pipelinenews).
- What it achieves
- It writes JSON (`writeJson`) and is built from the page diagnostics helper (`pageDiagnostics`) and the dictionary step (`dictionary`). Activated for verified GridAtlas.
- Why it matters
- Run by PipelineNews Current GridAtlas V9 Deep Link Successor Workflow and PipelineNews Resume Exact Atlas Pages Promotion Workflow.
- Application
- pipelinenews · atman · JavaScript module
- Uses
- node:fs/promises, playwright
- Used by
- run by PipelineNews Current GridAtlas V9 Deep Link Successor Workflow (workflow run), run by PipelineNews Resume Exact Atlas Pages Promotion Workflow (workflow run)
- Produces
- writeJson, pageDiagnostics, dictionary, isKnownLegacyDuplicateEngineError
- Defines here
- writeJson, pageDiagnostics, dictionary, isKnownLegacyDuplicateEngineError
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 atman/202608300309-verify-current-atlas-v9-deep-link.mjs:1-328 · blob d3e0c6ec66f817d34967d045271689971ee0f2c8 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
// Activated for verified GridAtlas generation 202608300453.
import fs from 'node:fs/promises';
import { chromium } from 'playwright';
const pipelineUrl = process.env.PIPELINE_URL;
const atlasUrl = process.env.ATLAS_URL;
const goldenRepdRef = process.env.GOLDEN_REPD_REF || '9873';
const mode = process.env.MODE || 'local';
const output = process.env.OUTPUT || `work/202608300309-${mode}-atlas-deep-link-proof.json`;
const diagnosticOutput = output.replace(/\.json$/u, '-diagnostic.json');
const failureScreenshot = output.replace(/\.json$/u, '-failure.png');
if (!pipelineUrl || !atlasUrl) throw new Error('PIPELINE_URL and ATLAS_URL are required');
if (!/^\d+$/u.test(goldenRepdRef)) throw new Error('GOLDEN_REPD_REF is invalid');
const expected = `${atlasUrl}?repd_ref=${goldenRepdRef}`;
const pipelineProbe = new URL(pipelineUrl);
pipelineProbe.searchParams.set('repd_ref', goldenRepdRef);
const goldenRowId = `repd-${goldenRepdRef}`;
const pipelineOrigin = pipelineProbe.origin;
const atlasOrigin = new URL(atlasUrl).origin;
const viewport = mode === 'public' ? { width: 390, height: 844 } : { width: 1440, height: 900 };
async function writeJson(path, value) {
await fs.mkdir(path.split('/').slice(0, -1).join('/') || '.', { recursive: true });
await fs.writeFile(path, JSON.stringify(value, null, 2) + '\n');
}
async function pageDiagnostics(page) {
try {
return await page.evaluate(() => ({
url: location.href,
body_dataset: { ...document.body?.dataset },
release_meta: document.querySelector('#releaseMeta')?.textContent?.trim() || null,
results_meta: document.querySelector('#resultsMeta')?.textContent?.trim() || null,
filtered_count: document.querySelector('#resultsMeta')?.dataset?.filteredCount || null,
total_count: document.querySelector('#resultsMeta')?.dataset?.totalCount || null,
search_value: document.querySelector('#search')?.value || null,
tbody_rows: document.querySelectorAll('#tbody tr').length,
row_ids: [...document.querySelectorAll('#tbody tr[id]')].slice(0, 12).map(row => row.id),
tbody_text: document.querySelector('#tbody')?.textContent?.replace(/\s+/gu, ' ').trim().slice(0, 1200) || null,
runtime: globalThis.__PIPELINENEWS_FAST__
? JSON.parse(JSON.stringify(globalThis.__PIPELINENEWS_FAST__))
: null,
}));
} catch (error) {
return { diagnostic_error: String(error?.message || error) };
}
}
const browser = await chromium.launch();
const page = await browser.newPage({ viewport, serviceWorkers: 'block' });
const consoleErrors = [];
const requestFailures = [];
const httpErrors = [];
let dataBoundary = null;
let moduleBoundary = null;
page.on('pageerror', error => consoleErrors.push(`pageerror:${String(error?.message || error)}`));
page.on('console', message => {
if (message.type() === 'error') consoleErrors.push(`console:${message.text()}`);
});
page.on('requestfailed', request => {
const url = new URL(request.url());
if (url.origin !== pipelineOrigin) return;
requestFailures.push({
url: request.url(),
method: request.method(),
failure: request.failure()?.errorText || 'unknown',
});
});
page.on('response', response => {
const url = new URL(response.url());
if (url.origin === pipelineOrigin && response.status() >= 400 && !url.pathname.endsWith('/favicon.ico')) {
httpErrors.push({ url: response.url(), status: response.status() });
}
});
try {
await page.goto(pipelineProbe.href, { waitUntil: 'domcontentloaded', timeout: 90000 });
await page.waitForSelector('#search', { timeout: 90000 });
dataBoundary = await page.evaluate(async (repdRef) => {
const registryUrl = new URL('data/202608291447-registry.json', document.baseURI);
const registryResponse = await fetch(registryUrl, { cache: 'no-store' });
if (!registryResponse.ok) throw new Error(`registry HTTP ${registryResponse.status}`);
const registry = await registryResponse.json();
const projectsUrl = new URL(registry.assets.projects.path, document.baseURI);
const projectsResponse = await fetch(projectsUrl, { cache: 'no-store' });
if (!projectsResponse.ok) throw new Error(`projects HTTP ${projectsResponse.status}`);
const projects = await projectsResponse.json();
const rowIndex = projects.rows.findIndex(row => String(row[0]) === repdRef);
const row = rowIndex >= 0 ? projects.rows[rowIndex] : null;
const dictionary = (name, index) => projects.dictionaries?.[name]?.[index] ?? '';
const record = row ? {
repd_ref: row[0],
gg_project_id: row[1],
name: row[2],
technology: dictionary('technology', row[3]),
status: dictionary('status', row[4]),
capacity_mw: Number(row[5]),
county: dictionary('county', row[6]),
region: dictionary('region', row[7]),
operator: dictionary('operator', row[8]),
repd_record_updated: row[9],
geometry_status: dictionary('geometry_status', row[10]),
latitude: row[11],
longitude: row[12],
} : null;
return {
registry_url: registryUrl.href,
projects_url: projectsUrl.href,
registry_schema: registry.schema,
projects_schema: projects.schema,
project_count: projects.rows.length,
row_index: rowIndex,
record,
};
}, goldenRepdRef);
if (dataBoundary.row_index < 0 || !dataBoundary.record) {
throw new Error(`REPD ${goldenRepdRef} is absent from the compact project index`);
}
if (dataBoundary.record.geometry_status !== 'valid') {
throw new Error(`REPD ${goldenRepdRef} geometry is not eligible: ${dataBoundary.record.geometry_status}`);
}
moduleBoundary = await page.evaluate(async ({ repdRef, expectedUrl, record }) => {
const moduleUrl = new URL('assets/202608291447-atlas-pointer-deep-link.mjs', document.baseURI);
const cartridge = await import(`${moduleUrl.href}?proof=${Date.now()}`);
const actual = cartridge.buildAtlasV9DeepLink(record);
return {
module_url: moduleUrl.href,
repd_ref: repdRef,
expected_url: expectedUrl,
actual_url: actual,
contract_schema: cartridge.ATLAS_V9_DEEP_LINK_CONTRACT?.schema || null,
identity_anchor: cartridge.ATLAS_V9_DEEP_LINK_CONTRACT?.identity_anchor || null,
receiver_release_id: cartridge.ATLAS_V9_DEEP_LINK_CONTRACT?.receiver?.release_id || null,
};
}, { repdRef: goldenRepdRef, expectedUrl: expected, record: dataBoundary.record });
if (moduleBoundary.actual_url !== expected) {
throw new Error(`deep-link cartridge mismatch: ${moduleBoundary.actual_url}`);
}
if (moduleBoundary.identity_anchor !== 'repd_ref') {
throw new Error(`deep-link identity anchor changed: ${moduleBoundary.identity_anchor}`);
}
await page.waitForFunction(
() => document.body?.dataset?.fastReady === 'true' || document.body?.dataset?.fastFailed === 'true',
null,
{ timeout: 90000 }
);
const readiness = await pageDiagnostics(page);
if (readiness.body_dataset?.fastFailed === 'true') {
throw new Error(`PipelineNews failed closed: ${JSON.stringify(readiness)}`);
}
if (readiness.body_dataset?.fastReady !== 'true') {
throw new Error(`PipelineNews did not reach fast-ready: ${JSON.stringify(readiness)}`);
}
await page.waitForSelector(`#${goldenRowId}`, { state: 'attached', timeout: 30000 });
await page.waitForFunction(
({ expectedUrl, rowId }) => {
const row = document.getElementById(rowId);
const anchor = row?.querySelector('a.atlaslink[href]');
return anchor?.href === expectedUrl;
},
{ expectedUrl: expected, rowId: goldenRowId },
{ timeout: 30000 }
);
const evidence = await page.evaluate(({ expectedUrl, rowId }) => {
const anchors = [...document.querySelectorAll('a[href*="repd_ref="]')];
const row = document.getElementById(rowId);
const golden = row?.querySelector('a.atlaslink[href]') || null;
return {
probe_url: location.href,
generated_links: anchors.map(anchor => anchor.href),
golden_href: golden?.href || null,
golden_text: golden?.textContent?.trim() || null,
row_text: row?.textContent?.replace(/\s+/gu, ' ').trim() || null,
release_id: document.body?.dataset?.releaseId || null,
generation: document.body?.dataset?.fastGeneration || null,
search_value: document.querySelector('#search')?.value || null,
filtered_count: document.querySelector('#resultsMeta')?.dataset?.filteredCount || null,
expected_url: expectedUrl,
runtime: globalThis.__PIPELINENEWS_FAST__
? JSON.parse(JSON.stringify(globalThis.__PIPELINENEWS_FAST__))
: null,
};
}, { expectedUrl: expected, rowId: goldenRowId });
if (evidence.golden_href !== expected) throw new Error(`golden link mismatch: ${evidence.golden_href}`);
if (evidence.generated_links.length !== 1) {
throw new Error(`exact REPD route rendered ${evidence.generated_links.length} Atlas links`);
}
if (evidence.generated_links.some(link => !link.startsWith(atlasUrl))) {
throw new Error('a rendered project link points to a stale Atlas receiver');
}
if (!evidence.row_text?.includes(goldenRepdRef)) {
throw new Error('golden project row does not preserve its REPD identity');
}
if (evidence.search_value !== goldenRepdRef || evidence.filtered_count !== '1') {
throw new Error(`exact REPD filter did not resolve one row: ${JSON.stringify(evidence)}`);
}
if (evidence.runtime?.searchRequests !== 0 || evidence.runtime?.searchReady !== false) {
throw new Error(`exact REPD route touched the broad search supplement: ${JSON.stringify(evidence.runtime)}`);
}
if (consoleErrors.length || requestFailures.length || httpErrors.length) {
throw new Error(`PipelineNews browser errors: ${JSON.stringify({ consoleErrors, requestFailures, httpErrors })}`);
}
const receiver = await browser.newPage({ viewport, serviceWorkers: 'block' });
const receiverErrors = [];
const receiverFailures = [];
receiver.on('pageerror', error => receiverErrors.push(`pageerror:${String(error?.message || error)}`));
receiver.on('console', message => {
if (message.type() === 'error') receiverErrors.push(`console:${message.text()}`);
});
receiver.on('requestfailed', request => {
const url = new URL(request.url());
if (url.origin !== atlasOrigin) return;
receiverFailures.push({
url: request.url(),
failure: request.failure()?.errorText || 'unknown',
});
});
await receiver.goto(expected, { waitUntil: 'domcontentloaded', timeout: 90000 });
await receiver.waitForSelector('.dashboard', { timeout: 90000 });
await receiver.waitForSelector('#map canvas', { timeout: 90000 });
await receiver.waitForFunction(
repdRef => document.body?.innerText?.includes(repdRef),
goldenRepdRef,
{ timeout: 90000 }
);
const receiverEvidence = await receiver.evaluate(repdRef => ({
url: location.href,
dashboard: !!document.querySelector('.dashboard'),
map_canvas: !!document.querySelector('#map canvas'),
repd_identity_visible: document.body?.innerText?.includes(repdRef) || false,
matching_text: [...document.querySelectorAll('body *')]
.filter(element => element.children.length === 0 && element.textContent?.includes(repdRef))
.slice(0, 8)
.map(element => element.textContent.trim()),
fatal_banner_visible: (() => {
const element = document.querySelector('#fatal-banner');
return !!element && getComputedStyle(element).display !== 'none';
})(),
}), goldenRepdRef);
const isKnownLegacyDuplicateEngineError = message =>
message.includes('console:[V9 DEEP LINK FAILED] Error: canonical project technology is invalid')
&& message.includes('ventus-corev8engine.js');
const knownReceiverErrors = receiverErrors.filter(isKnownLegacyDuplicateEngineError);
const unexpectedReceiverErrors = receiverErrors.filter(message => !isKnownLegacyDuplicateEngineError(message));
if (receiverEvidence.url !== expected) throw new Error(`receiver URL changed: ${receiverEvidence.url}`);
if (!receiverEvidence.dashboard || !receiverEvidence.map_canvas) throw new Error('Atlas receiver surface is absent');
if (!receiverEvidence.repd_identity_visible) throw new Error('Atlas receiver did not expose the requested REPD identity');
if (receiverEvidence.fatal_banner_visible) throw new Error('Atlas receiver fatal banner is visible');
if (knownReceiverErrors.length > 1 || unexpectedReceiverErrors.length || receiverFailures.length) {
throw new Error(`Atlas receiver errors: ${JSON.stringify({ knownReceiverErrors, unexpectedReceiverErrors, receiverFailures })}`);
}
const proof = {
schema: 'pipelinenews.current-atlas-v9-browser-proof.v3',
classification: mode === 'public'
? 'VERIFIED_PUBLIC_PIPELINENEWS_ATLAS_V9_DEEP_LINK'
: 'VERIFIED_LOCAL_PIPELINENEWS_ATLAS_V9_DEEP_LINK',
mode,
pipeline_url: pipelineUrl,
pipeline_probe_url: pipelineProbe.href,
atlas_base_url: atlasUrl,
golden_repd_ref: goldenRepdRef,
expected_url: expected,
data_boundary: dataBoundary,
module_boundary: moduleBoundary,
pipeline: evidence,
receiver: receiverEvidence,
known_receiver_errors: knownReceiverErrors,
unexpected_receiver_errors: unexpectedReceiverErrors,
errors: [],
route_interceptions: 0,
synthetic_receiver: false,
broad_search_supplement_requests: 0,
};
await writeJson(output, proof);
console.log(JSON.stringify({
classification: proof.classification,
expected,
project_row_index: dataBoundary.row_index,
generated_links: evidence.generated_links.length,
known_receiver_errors: knownReceiverErrors.length,
broad_search_supplement_requests: 0,
}));
} catch (error) {
const diagnostic = {
schema: 'pipelinenews.current-atlas-v9-browser-diagnostic.v1',
classification: 'PIPELINENEWS_ATLAS_V9_DEEP_LINK_FAILURE',
mode,
error: String(error?.stack || error?.message || error),
pipeline_url: pipelineUrl,
pipeline_probe_url: pipelineProbe.href,
expected_url: expected,
data_boundary: dataBoundary,
module_boundary: moduleBoundary,
ui: await pageDiagnostics(page),
console_errors: consoleErrors,
request_failures: requestFailures,
http_errors: httpErrors,
};
await writeJson(diagnosticOutput, diagnostic);
try {
await page.screenshot({ path: failureScreenshot, fullPage: true });
} catch {}
console.error(JSON.stringify(diagnostic));
throw error;
} finally {
await browser.close();
}