GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / pipelinenews / tools/intelligence/cartridges/atlas-live-handoff/assets

Atlas Pointer Deep Link and 2 more files (part 1)

A JavaScript module in the assets folder of PipelineNews that works with solar and uses data from the GridAtlas repository.

540 lines of JavaScript from pipelinenews, in 3 files. Topic: Maps, GIS and field navigation. Section 713 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. Atlas Pointer Deep Link transform · pipelinenews / tools/intelligence/cartridges/atlas-live-handoff/assets/{GEN}-atlas-pointer-deep-link.mjs lines 1–252
  2. Proof ingest · pipelinenews / tools/intelligence/cartridges/atlas-live-handoff/proof.mjs lines 1–160
  3. Atlas Pointer Deep Link transform · pipelinenews / tools/intelligence/cartridges/map-corpus-contract/assets/{GEN}-atlas-pointer-deep-link.mjs lines 1–128

Atlas Pointer Deep Link

A JavaScript module in the assets folder of PipelineNews that works with solar and uses data from the GridAtlas repository.

transformpipelinenews / tools/intelligence/cartridges/atlas-live-handoff/assets/{GEN}-atlas-pointer-deep-link.mjs · lines 1–252 of 252 · Not reached from any entry point (candidate for review) · pattern finiteInRange (shared by 4 files)

What it does
It calculates solar. Defines invariant, finiteInRange, buildAtlasV9DeepLink, selfTest, add.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'handoff'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: solar, 132kV.
Inputs & outputs
In: JSON file live-set.json. Voltage levels named: 132kV.
What it achieves
It builds atlas v9 deep link (`buildAtlasV9DeepLink`) and is built from the invariant step (`invariant`) and the finite in range helper (`finiteInRange`). PipelineNews -> GridAtlas deep-link cartridge. Its code works with 132 kV.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/intelligence/cartridges/atlas-live-handoff/assets · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL)
Used by
none found
Produces
ATLAS_DEEP_LINK_CONTRACT, buildAtlasV9DeepLink, selfTest
Defines here
invariant, finiteInRange, buildAtlasV9DeepLink, selfTest, add
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/atlas-live-handoff/assets/{GEN}-atlas-pointer-deep-link.mjs:1-252 · blob 817da36cf83b46966696a5a9ab2a21f804231212 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: duplicate_candidate
/**
 * PipelineNews -> GridAtlas deep-link cartridge.
 *
 * Generation {GEN}. Successor to 202608291447-atlas-pointer-deep-link.mjs.
 * DRAFT - deployment: not-authorised. Review before promoting.
 *
 * ---------------------------------------------------------------------------
 * WHAT CHANGED AND WHY
 * ---------------------------------------------------------------------------
 * The predecessor emitted   /gridatlas/<release_id>/?repd_ref=<n>
 * which fails twice:
 *
 *   FAULT 1 - wrong path. The release is served at
 *             /gridatlas/atlas/releases/<release_id>/ and GridAtlas'
 *             atlas/current.json declares the stable route as /gridatlas/atlas/.
 *             The "atlas/" segment was missing, so every link 404s.
 *
 *             Note the predecessor's own invariant ASSERTED the broken shape:
 *               receiverUrl.pathname === `/gridatlas/${release_id}/`
 *             so correcting base_url alone would have thrown. Both had to move
 *             together, which is why this is a new cartridge and not an edit.
 *
 *   FAULT 2 - stripped payload. The link carried the reference alone, so the
 *             atlas had to resolve it by booting a 35.7 MB query engine before
 *             it could move the map. The known-good legacy link carries
 *             repd_ref + project + technology + capacity_mw + latitude +
 *             longitude + zoom and flies straight there, resolving nothing.
 *
 *             Every one of those fields is ALREADY in the compact project index
 *             (fields: repd_ref, gg_project_id, name, technology, status,
 *             capacity_mw, county, region, operator, repd_record_updated,
 *             geometry_status, latitude, longitude) and is ALREADY passed to
 *             this function by app.mjs. The predecessor simply ignored them.
 *             No data change, no schema change, no GridAtlas change.
 *
 * The eligibility gate already requires geometry_status === "valid", which is
 * exactly the guarantee that latitude and longitude are present. The contract
 * that makes the full payload safe was there all along.
 *
 * ---------------------------------------------------------------------------
 * THE DECISION, CLOSED 2026-09-05
 * ---------------------------------------------------------------------------
 * This file used to offer two receivers and default to the wrong one:
 * ACTIVE_TARGET was "legacy", the V8 overlay that the engine now publishes as
 * retired. The route is deliberately not spelled out anywhere in this file any
 * more -- Ventusltd/testcode's link-target driver counts every mention of it,
 * and a comment is as good a place as a constant for a dead route to survive.
 *
 * It still serves, so nothing ever 404'd and no link checker went red.
 * It carries zero engine cartridges and no current.json -- measured 2026-09-05,
 * 0 against the canonical shell's 20 and 3 -- so an arrival there can never
 * compute a nearest substation, a corridor estimate or a rating envelope.
 * Driven live on REPD 8162 the retired receiver exposes no __GRIDATLAS_*
 * globals at all and never names the project; the canonical one loads 14 engine
 * modules and answers BRAINTREE at 9.44 km, 400/132 kV.
 *
 * The composed releases were correct only because release_builder.py rewrites
 * this line when --atlas-target ported is passed. A source part whose default
 * is a dead receiver is a defect waiting for the first build that forgets the
 * flag, so the branch is gone rather than the default changed. The engine now
 * publishes the answer as data in ventus-grid-engine/deeplink/receivers.json,
 * and an ACTIVE_TARGET this file does not know still fails the invariant below
 * rather than resolving to anything.
 */

const ATLAS_TARGETS = Object.freeze({
  ported: Object.freeze({
    id: "ported",
    schema: "pipelinenews.gridatlas-live-pointer-receipt.v4",
    classification: "VERIFIED_PROMOTION_ELIGIBLE_GRIDATLAS_V9",
    generation: "202608300453",
    release_id: "202608300453-atlas-v9",
    // The STABLE route. GridAtlas atlas/current.json -> "live_route".
    // Using the stable route rather than the pinned release means a GridAtlas
    // release promotion does not silently break every PipelineNews link.
    base_url: "https://ventusltd.github.io/gridatlas/atlas/",
    pinned_release_url:
      "https://ventusltd.github.io/gridatlas/atlas/releases/202608300453-atlas-v9/",
    hostname: "ventusltd.github.io",
    pathname: "/gridatlas/atlas/",
    state_url: "https://ventusltd.github.io/gridatlas/state/live-set.json",
    source_commit: "4f3e8fc5c7ea28edf83dbac9b231024723bcf231",
  }),
});

/** One receiver, because the other one carries no engine. An unknown value
 *  here fails the invariant below rather than selecting anything. */
const ACTIVE_TARGET = "ported";

const RECEIVER = ATLAS_TARGETS[ACTIVE_TARGET];

function invariant(condition, message) {
  if (!condition) throw new Error(`Atlas receiver contract: ${message}`);
}

invariant(Boolean(RECEIVER), `ACTIVE_TARGET "${ACTIVE_TARGET}" is not a known receiver`);

const receiverUrl = new URL(RECEIVER.base_url);
invariant(receiverUrl.protocol === "https:", "receiver is not HTTPS");
invariant(receiverUrl.hostname === RECEIVER.hostname, "receiver hostname changed");
// Validate against the receiver's OWN declared pathname. The predecessor
// hardcoded a template here, which is what pinned the broken shape in place.
invariant(receiverUrl.pathname === RECEIVER.pathname, "receiver route mismatch");
invariant(receiverUrl.pathname.endsWith("/"), "receiver route must end in a slash");

/** Emitted in this order, matching the known-good legacy link exactly. */
const QUERY_PARAMETER_ORDER = Object.freeze([
  "repd_ref", "project", "technology", "capacity_mw", "latitude", "longitude", "zoom",
]);

const DEFAULT_ZOOM = 12;

export const ATLAS_DEEP_LINK_CONTRACT = Object.freeze({
  schema: "pipelinenews.atlas-current-deep-link-cartridge.v2",
  generation: "{GEN}",
  supersedes: "pipelinenews.atlas-current-deep-link-cartridge.v1",
  supersede_reason:
    "v1 emitted a 404 path and carried repd_ref alone, forcing a 35.7 MB engine boot to resolve it",
  deployment: "not-authorised",
  active_target: ACTIVE_TARGET,
  receiver: RECEIVER,
  available_targets: Object.freeze(Object.keys(ATLAS_TARGETS)),
  eligibility: Object.freeze({
    field: "geometry_status",
    equals: "valid",
    ineligible_result: "",
    presentation: "NO MAP",
  }),
  identity_anchor: "repd_ref",
  query_parameter_order: QUERY_PARAMETER_ORDER,
  inbound_match_semantics: "EXACT_PROJECT_REPD_REF",
  context_parameters_are_advisory: true,
  lifecycle:
    "timestamped PipelineNews release; receiver authenticated at build and public readback",
});

/** Finite, in-range coordinate. Anything else means we do not emit one. */
function finiteInRange(value, limit) {
  // Number(null) and Number("") are both 0, which is finite and in range. Without
  // this guard a project with a missing longitude is emitted at longitude 0 - the
  // Greenwich meridian - instead of having its coordinates dropped. Caught by
  // selfTest case "drops both coordinates when only one is present".
  if (value === null || value === undefined || value === "") return null;
  const n = Number(value);
  return Number.isFinite(n) && Math.abs(n) <= limit ? n : null;
}

/**
 * Build the atlas deep link for a project.
 *
 * Identity (repd_ref) is REQUIRED and remains the only field the receiver
 * matches on - EXACT_PROJECT_REPD_REF is unchanged. Everything else is
 * advisory context that lets the map position itself without a lookup, and any
 * field that is missing or malformed is simply omitted rather than guessed.
 *
 * @param {object} project compact project index row
 * @returns {string} absolute URL, or "" when the project has no valid geometry
 */
export function buildAtlasV9DeepLink(project) {
  if (project?.[ATLAS_DEEP_LINK_CONTRACT.eligibility.field]
      !== ATLAS_DEEP_LINK_CONTRACT.eligibility.equals) return "";

  const repdRef = String(project?.repd_ref ?? "").trim();
  if (!/^\d+$/u.test(repdRef)) return "";

  const url = new URL(RECEIVER.base_url);
  url.searchParams.set("repd_ref", repdRef);

  const name = String(project?.name ?? "").trim();
  if (name) url.searchParams.set("project", name);

  const technology = String(project?.technology ?? "").trim();
  if (technology) url.searchParams.set("technology", technology);

  const capacity = Number(project?.capacity_mw);
  if (Number.isFinite(capacity) && capacity > 0) {
    url.searchParams.set("capacity_mw", String(capacity));
  }

  // Emitted as a pair or not at all. Half a coordinate is worse than none.
  const latitude = finiteInRange(project?.latitude, 90);
  const longitude = finiteInRange(project?.longitude, 180);
  if (latitude !== null && longitude !== null) {
    url.searchParams.set("latitude", String(latitude));
    url.searchParams.set("longitude", String(longitude));
    url.searchParams.set("zoom", String(DEFAULT_ZOOM));
  }

  return url.href;
}

/**
 * Self-test. Pure, no IO, no network. Callable from a build step or a verifier.
 * Returns {ok, checks:[{name, ok, detail}]}.
 */
export function selfTest() {
  const checks = [];
  const add = (name, ok, detail) => checks.push({ name, ok: Boolean(ok), detail: detail ?? null });

  const cleveHill = {
    repd_ref: "6502", name: "Cleve Hill Solar Project", technology: "solar",
    capacity_mw: 373, latitude: 51.338767, longitude: 0.913885,
    geometry_status: "valid",
  };
  const href = buildAtlasV9DeepLink(cleveHill);
  const u = href ? new URL(href) : null;

  add("emits a link for a valid-geometry project", Boolean(href), href);
  add("path ends in a slash and is the declared route",
      u && u.pathname === RECEIVER.pathname, u && u.pathname);
  add("carries repd_ref", u && u.searchParams.get("repd_ref") === "6502");
  add("carries project name", u && u.searchParams.get("project") === "Cleve Hill Solar Project");
  add("carries technology", u && u.searchParams.get("technology") === "solar");
  add("carries capacity_mw", u && u.searchParams.get("capacity_mw") === "373");
  add("carries latitude", u && u.searchParams.get("latitude") === "51.338767");
  add("carries longitude", u && u.searchParams.get("longitude") === "0.913885");
  add("carries zoom", u && u.searchParams.get("zoom") === String(DEFAULT_ZOOM));

  // The regression that started this: a ref-only link is no longer produced
  // for a project that has coordinates.
  add("does NOT emit a ref-only link when coordinates exist",
      u && [...u.searchParams.keys()].length > 1,
      u && [...u.searchParams.keys()].join(","));

  // Eligibility gate still closes.
  add("no link when geometry is not valid",
      buildAtlasV9DeepLink({ ...cleveHill, geometry_status: "missing" }) === "");
  add("no link when repd_ref is not numeric",
      buildAtlasV9DeepLink({ ...cleveHill, repd_ref: "B0850" }) === "");

  // Partial coordinates must be dropped as a pair, not emitted half.
  const half = new URL(buildAtlasV9DeepLink({ ...cleveHill, longitude: null }));
  add("drops both coordinates when only one is present",
      !half.searchParams.has("latitude") && !half.searchParams.has("longitude"),
      half.search);
  add("still carries identity when coordinates are dropped",
      half.searchParams.get("repd_ref") === "6502");

  // Out-of-range coordinates are treated as absent, not clamped.
  const bad = new URL(buildAtlasV9DeepLink({ ...cleveHill, latitude: 999 }));
  add("rejects out-of-range latitude rather than clamping it",
      !bad.searchParams.has("latitude"));

  // Golden ref from the predecessor contract must still resolve.
  const golden = buildAtlasV9DeepLink({
    repd_ref: "13599", name: "Golden", technology: "solar",
    capacity_mw: 1, latitude: 52, longitude: -1, geometry_status: "valid",
  });
  add("golden repd_ref 13599 still emits", golden.includes("repd_ref=13599"));

  return { ok: checks.every((c) => c.ok), target: ACTIVE_TARGET, checks };
}

Proof

A JavaScript module in the atlas live handoff folder of PipelineNews that reads the Renewable Energy Planning Database (REPD) register from the GridAtlas repository.

ingestpipelinenews / tools/intelligence/cartridges/atlas-live-handoff/proof.mjs · lines 1–160 of 160 · Not reached from any entry point (candidate for review) · pattern decode (shared by 19 files)

What it does
It loads the REPD register. Defines check, text, json, decode. Uses libraries node:fs/promises, node:fs, node:path, node:url. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'handoff'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: the REPD register.
Inputs & outputs
In: data source: gridatlas data; JSON file release-manifest.json; JSON file 202608291447-registry.json; JSON file 202608270055-8ab1807551bc-v8-fast-projects.json; command-line arguments.
Downstream impact
Used directly by 1 file: Shift (pipelinenews).
What it achieves
It is built from the check step (`check`), the text step (`text`) and the JSON step (`json`). Independent proof for the Pipeline News -> composed GridAtlas handoff. Its code works with 840 MW.
Why it matters
Run by Shift.
Application
pipelinenews · tools/intelligence/cartridges/atlas-live-handoff · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL), node:fs/promises, node:fs, node:path, node:url
Used by
run by Shift (script call)
Produces
check, text, json, decode
Defines here
check, text, json, decode
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/atlas-live-handoff/proof.mjs:1-160 · blob d4e29a41e9150920bad93e06951af13dda78a74a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
/**
 * Independent proof for the Pipeline News -> composed GridAtlas handoff.
 *
 * This reads the release that will be handed to a browser, imports its actual
 * deep-link module, and generates a URL for every row in the frozen compact
 * project index. It does not ask app.mjs whether its own links are correct.
 */
import { readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';

const here = dirname(fileURLToPath(import.meta.url));
const repo = resolve(here, '../../../..');
const releaseId = process.argv[2] || '202608312018-pipelinenews';
const release = join(repo, 'releases', releaseId);
const generation = releaseId.slice(0, 12);

let passed = 0;
const failures = [];
function check(name, condition, detail = '') {
  if (condition) {
    passed += 1;
    console.log(`PASS  ${name}`);
  } else {
    failures.push(`${name}${detail ? `: ${detail}` : ''}`);
    console.error(`FAIL  ${name}${detail ? `: ${detail}` : ''}`);
  }
}

const text = async (relative) => readFile(join(release, relative), 'utf8');
const json = async (relative) => JSON.parse(await text(relative));

const app = await text('assets/202608291447-app.mjs');
const index = await text('index.html');
const manifest = await json('release-manifest.json');
const registry = await json('data/202608291447-registry.json');
const projects = await json('data/202608270055-8ab1807551bc-v8-fast-projects.json');
/* The deep-link module is resolved from what the runtime ACTUALLY imports,
   not from the release's own generation.
   ------------------------------------------------------------------------
   It used to be `${generation}-atlas-pointer-deep-link.mjs`, which is only
   the right name for a release built by the cartridge that introduced that
   asset. Every other release carries its parent's copy, so this proof could
   not run on them at all - it threw ERR_MODULE_NOT_FOUND, which is a gate
   that cannot check rather than a gate that fails. 202609012324, the first
   release cut by the night shift, is where that surfaced.

   Reading the specifier out of app.mjs is also a stronger check: it proves
   the module the runtime really loads, rather than a file that merely
   happens to be named after the release. */
const imported = app.match(
  /^import \{ buildAtlasV9DeepLink \} from "\.\/(\d{12}-atlas-pointer-deep-link\.mjs)";/m);
check('the runtime imports exactly one deep-link receiver, by name',
  !!imported && (app.match(/-atlas-pointer-deep-link\.mjs"/g) || []).length === 1,
  imported ? imported[1] : 'no import found in assets/202608291447-app.mjs');
if (!imported) {
  console.error('\nFAIL: cannot resolve the deep-link module the runtime imports.');
  process.exit(1);
}
const modulePath = join(release, 'assets', imported[1]);
const deepLink = await import(pathToFileURL(modulePath).href);

check('release manifest records the ported target', manifest.atlas_target === 'ported');
check('the imported receiver module is present in this release\'s own assets',
  existsSync(modulePath), imported[1]);
check('the receiver is the ported one, not a legacy-target module',
  (await readFile(modulePath, 'utf8')).includes('ventusltd.github.io/gridatlas/atlas/'));
check('runtime no longer imports the legacy-target module',
  !app.includes('./202608311343-atlas-pointer-deep-link.mjs'));
check('both site-navigation links use the stable GridAtlas route',
  (index.match(/https:\/\/ventusltd\.github\.io\/gridatlas\/atlas\//g) || []).length === 2);
/* Was: assert the navigation does not contain one named legacy href. Naming a
   dead route in a proof keeps a copy of it alive -- Ventusltd/testcode's
   link-target driver counts every mention, and cannot tell an assertion of
   absence from a link. This asks the positive question instead, against the
   receiver module's own base_url: every Atlas href in the navigation is the
   receiver this release actually ships. It is stronger, because it fails for
   ANY other receiver rather than for one remembered string, and it needs no
   network. */
const atlasHrefs = [...index.matchAll(/https:\/\/[^"'\s>]*?(?:atlas|repd_grid)[^"'\s>]*/gi)].map((m) => m[0]);
check('every Atlas href in the navigation is this release\'s own receiver',
  atlasHrefs.length > 0 && atlasHrefs.every((href) => href.startsWith(deepLink.ATLAS_DEEP_LINK_CONTRACT.receiver.base_url)),
  atlasHrefs.join(' | '));

const entry = registry.supplemental_assets?.atlas_live_handoff;
check('registry carries the handoff receipt', Boolean(entry));
check('registry and executable agree on target',
  entry?.active_target === 'ported' && deepLink.ATLAS_DEEP_LINK_CONTRACT.active_target === 'ported');
check('receiver is the stable composed route',
  deepLink.ATLAS_DEEP_LINK_CONTRACT.receiver.base_url
    === 'https://ventusltd.github.io/gridatlas/atlas/');

const self = deepLink.selfTest();
check('module self-test passes', self.ok,
  self.checks.filter((item) => !item.ok).map((item) => item.name).join(', '));
check('module self-test ran against ported target', self.target === 'ported');

function decode(row) {
  return Object.fromEntries(projects.fields.map((field, index) => {
    const encoded = row[index];
    const dictionary = projects.dictionaries[field];
    return [field, dictionary ? (dictionary[encoded] ?? '') : encoded];
  }));
}

let valid = 0;
let invalid = 0;
let wrongHost = 0;
let wrongPath = 0;
let missingIdentity = 0;
let missingContext = 0;
let unnamed = 0;
let botley = null;
for (const row of projects.rows) {
  const project = decode(row);
  const href = deepLink.buildAtlasV9DeepLink(project);
  if (project.geometry_status !== 'valid') {
    invalid += 1;
    if (href) failures.push(`invalid geometry emitted a URL for REPD ${project.repd_ref}`);
    continue;
  }
  valid += 1;
  const url = new URL(href);
  if (url.hostname !== 'ventusltd.github.io') wrongHost += 1;
  if (url.pathname !== '/gridatlas/atlas/') wrongPath += 1;
  if (url.searchParams.get('repd_ref') !== String(project.repd_ref)) missingIdentity += 1;
  for (const key of ['technology', 'capacity_mw', 'latitude', 'longitude', 'zoom']) {
    if (!url.searchParams.has(key)) missingContext += 1;
  }
  if (project.name) {
    if (url.searchParams.get('project') !== project.name) missingContext += 1;
  } else {
    unnamed += 1;
    if (url.searchParams.has('project')) failures.push(`blank source name was guessed for REPD ${project.repd_ref}`);
  }
  if (String(project.repd_ref) === '12588') botley = { project, url };
}

check('all valid-geometry projects emit a link', valid === 7652, `found ${valid}`);
check('all non-valid geometry rows fail closed', invalid === 28, `found ${invalid}`);
check('every emitted URL uses the Ventus host', wrongHost === 0, `${wrongHost} wrong`);
check('every emitted URL uses the stable composed path', wrongPath === 0, `${wrongPath} wrong`);
check('every emitted URL retains exact REPD identity', missingIdentity === 0,
  `${missingIdentity} missing`);
check('every emitted URL carries layout/deep-link context', missingContext === 0,
  `${missingContext} missing fields`);
check('two blank official project names remain blank rather than guessed', unnamed === 2,
  `found ${unnamed}`);
check('Botley West retains the 840 MW register value',
  botley?.url.searchParams.get('capacity_mw') === '840');
check('Botley West is handed to the composed Atlas',
  botley?.url.href.startsWith('https://ventusltd.github.io/gridatlas/atlas/?repd_ref=12588'));

console.log(`\n${passed}/${passed + failures.length} checks passed`);
if (failures.length) {
  console.error('\nFAILURES');
  failures.forEach((failure) => console.error(`  ${failure}`));
  process.exit(1);
}

Atlas Pointer Deep Link

A JavaScript module in the assets folder of PipelineNews that works with the Renewable Energy Planning Database (REPD) register and uses data from the GridAtlas repository.

Set aside from the main view: 98% of its lines are the same as pipelinenews_intelligence/202609040144/assets/202609040044-atlas-pointer-deep-link.mjs (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Atlas Pointer Deep Link; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.981 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 pipelinenews_intelligence/202609040144/assets/202609040044-atlas-pointer-deep-link.mjs:1-128 d379c9ce4e097d3a460b2414714e37f6ed18884b
  • sha256 c45974e90ba93fc3bd2a3a8e881ffd2ff9abffcca3d69acaa4fb74823a0b477d
  • target sha256 7ab16bbc704324d177210dd45acd54a684018980df766bdebdd7689a0f7571ae
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

transformpipelinenews / tools/intelligence/cartridges/map-corpus-contract/assets/{GEN}-atlas-pointer-deep-link.mjs · lines 1–128 of 128 · Not reached from any entry point (candidate for review) · pattern projectFields (shared by 3 files)

What it does
It calculates the REPD register. Defines numberInRange, projectFields, buildAtlasV9DeepLink, selfTest, check.
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
Coordinate systems named: WGS84 / EPSG:4326.
Downstream impact
Used directly by 1 file: Wider Fleet (pipelinenews).
What it achieves
It builds atlas v9 deep link (`buildAtlasV9DeepLink`) and is built from the number in range helper (`numberInRange`) and the project fields helper (`projectFields`). One fail-closed Pipeline News -> GridAtlas transport contract.
Why it matters
Imported by Wider Fleet.
Application
pipelinenews · tools/intelligence/cartridges/map-corpus-contract/assets · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL)
Used by
imported by Wider Fleet (import)
Produces
CANONICAL_PROJECT_TECHNOLOGIES, ATLAS_DEEP_LINK_CONTRACT, buildAtlasV9DeepLink, selfTest
Defines here
numberInRange, projectFields, buildAtlasV9DeepLink, selfTest, check
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/map-corpus-contract/assets/{GEN}-atlas-pointer-deep-link.mjs:1-128 · blob 5c938b74b800242bad337af154478b61f0921eea · 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
/**
 * One fail-closed Pipeline News -> GridAtlas transport contract.
 *
 * Every clickable MAP action carries an exact REPD identity, one canonical
 * GridAtlas technology token, and a complete WGS84 coordinate pair.  Display
 * context remains advisory at the receiver; dropping identity is never a
 * fallback for a receiver defect.
 */

const RECEIVER = Object.freeze({
  base_url: "https://ventusltd.github.io/gridatlas/atlas/",
  hostname: "ventusltd.github.io",
  pathname: "/gridatlas/atlas/",
});

export const CANONICAL_PROJECT_TECHNOLOGIES = Object.freeze([
  "act", "bess", "biomass", "caes", "flywheel", "geothermal",
  "hydro", "hydrogen", "other", "solar", "solar_roof", "tidal",
  "wind_offshore", "wind_onshore",
]);

const TECHNOLOGIES = new Set(CANONICAL_PROJECT_TECHNOLOGIES);
const QUERY_PARAMETER_ORDER = Object.freeze([
  "repd_ref", "project", "technology", "capacity_mw",
  "latitude", "longitude", "zoom",
]);
const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/u;
const DEFAULT_ZOOM = 12;

export const ATLAS_DEEP_LINK_CONTRACT = Object.freeze({
  schema: "pipelinenews.atlas-map-corpus-contract.v1",
  generation: "{GEN}",
  active_target: "ported",
  receiver: RECEIVER,
  identity_anchor: "repd_ref",
  query_parameter_order: QUERY_PARAMETER_ORDER,
  canonical_project_technologies: CANONICAL_PROJECT_TECHNOLOGIES,
  context_parameters_are_advisory: true,
  clickable_requires: Object.freeze([
    "canonical repd_ref", "canonical technology", "finite latitude",
    "finite longitude", "non-negative capacity_mw",
  ]),
  receiver_candidate: Object.freeze({
    commit: "b73247803377233069acfeff415ecad4e8391cb2",
    module: "atlas/codex/20260904-finding-loop-30x/finding-loop.mjs",
    module_sha256: "fdaf16829275c904ef190ba96925415151c9ac6f409eac39d81440dbdd0c3d20",
    module_bytes: 60148,
    contract: "PROJECT_TECHNOLOGIES + parseProjectDeepLink",
  }),
});

function numberInRange(value, minimum, maximum) {
  if (value === null || value === undefined || value === "") return null;
  const number = Number(value);
  return Number.isFinite(number) && number >= minimum && number <= maximum
    ? number : null;
}

function projectFields(project) {
  const coordinates = Array.isArray(project?.ll) ? project.ll : null;
  return {
    repdRef: String(project?.repd_ref ?? project?.ref ?? "").trim(),
    // REPD 13263 contains an embedded line break in its official display
    // name. Whitespace canonicalisation preserves the words without putting a
    // control character into a query string or discarding the exact identity.
    name: String(project?.name ?? project?.n ?? "").replace(/\s+/gu, " ").trim(),
    technology: String(project?.technology ?? project?.t ?? "").trim(),
    capacity: numberInRange(project?.capacity_mw ?? project?.c, 0, Number.MAX_VALUE),
    latitude: numberInRange(project?.latitude ?? coordinates?.[1], -90, 90),
    longitude: numberInRange(project?.longitude ?? coordinates?.[0], -180, 180),
    geometryStatus: project?.geometry_status,
  };
}

/** Return a canonical absolute URL, or an empty string for a non-clickable row. */
export function buildAtlasV9DeepLink(project) {
  const fields = projectFields(project);
  if (fields.geometryStatus !== undefined && fields.geometryStatus !== "valid") return "";
  if (!/^[1-9]\d*$/u.test(fields.repdRef)) return "";
  if (!TECHNOLOGIES.has(fields.technology)) return "";
  if (CONTROL_CHARACTER.test(fields.name)) return "";
  if (fields.capacity === null || fields.latitude === null || fields.longitude === null) return "";

  const url = new URL(RECEIVER.base_url);
  url.searchParams.set("repd_ref", fields.repdRef);
  // An official blank stays blank. The parameter is still present, and no
  // replacement name is invented merely to make a URL look complete.
  url.searchParams.set("project", fields.name);
  url.searchParams.set("technology", fields.technology);
  url.searchParams.set("capacity_mw", String(fields.capacity));
  url.searchParams.set("latitude", String(fields.latitude));
  url.searchParams.set("longitude", String(fields.longitude));
  url.searchParams.set("zoom", String(DEFAULT_ZOOM));
  return url.href;
}

export function selfTest() {
  const checks = [];
  const check = (name, ok) => checks.push({ name, ok: Boolean(ok) });
  const fixture = {
    repd_ref: "155", name: "Markinch Biomass CHP Plant", technology: "biomass",
    capacity_mw: 65, latitude: 56.20118, longitude: -3.162255,
    geometry_status: "valid",
  };
  const href = buildAtlasV9DeepLink(fixture);
  const url = new URL(href);
  check("valid row emits", Boolean(href));
  check("stable receiver", url.hostname === RECEIVER.hostname && url.pathname === RECEIVER.pathname);
  check("exact ordered parameters",
    [...url.searchParams.keys()].join(",") === QUERY_PARAMETER_ORDER.join(","));
  check("identity retained", url.searchParams.get("repd_ref") === "155");
  check("canonical technology retained", url.searchParams.get("technology") === "biomass");
  check("coordinates retained",
    url.searchParams.get("latitude") === "56.20118"
      && url.searchParams.get("longitude") === "-3.162255");
  check("zero capacity remains explicit",
    new URL(buildAtlasV9DeepLink({ ...fixture, capacity_mw: 0 }))
      .searchParams.get("capacity_mw") === "0");
  check("missing identity is not worked around",
    buildAtlasV9DeepLink({ ...fixture, repd_ref: "" }) === "");
  check("unknown technology fails closed",
    buildAtlasV9DeepLink({ ...fixture, technology: "Biomass (dedicated)" }) === "");
  check("half coordinate fails closed",
    buildAtlasV9DeepLink({ ...fixture, longitude: null }) === "");
  check("invalid geometry fails closed",
    buildAtlasV9DeepLink({ ...fixture, geometry_status: "missing" }) === "");
  return Object.freeze({ ok: checks.every(({ ok }) => ok), checks: Object.freeze(checks) });
}