GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / pipelinenews / orchestration

PipelineNews Atlas Pointer Deep Link and 3 more files

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

656 lines of JavaScript and Python from pipelinenews, in 4 files. Topic: Maps, GIS and field navigation. Section 711 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. Repair Exact Renewable Energy Planning Database (REPD) Route energy-data · pipelinenews / orchestration/202608300358-repair-exact-repd-route.py lines 1–188
  2. PipelineNews Atlas Pointer Deep Link transform · pipelinenews / releases/202608312018-pipelinenews/assets/202608312018-atlas-pointer-deep-link.mjs lines 1–249
  3. PipelineNews Codex Atlas Lab Proof ingest · pipelinenews / releases/202609020010-pipelinenews/202609020010-codex-atlas-lab.proof.mjs lines 1–123
  4. PipelineNews Codex Atlas Lab Deep Link transform · pipelinenews / releases/202609020010-pipelinenews/assets/202609020010-codex-atlas-lab-deep-link.mjs lines 1–96

Repair Exact Renewable Energy Planning Database (REPD) Route

A Python command-line tool in the orchestration folder of PipelineNews that reads atlas link and the REPD register, using SHA-256.

energy-datapipelinenews / orchestration/202608300358-repair-exact-repd-route.py · lines 1–188 of 188 · version 2026-08-30 03:58 · Entry point · pattern replace_exactly_once (shared by 2 files)

What it does
It loads atlas link and the REPD register. Defines 8 functions or classes, including require, load_json, sha256, write_json, replace_exactly_once. Uses libraries __future__, argparse, hashlib, json, re. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage field_execution (path word 'route'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work. Domain terms in the code: the REPD register.
Inputs & outputs
In: JSON file build-manifest.json; JSON file release-manifest.json; JSON file atlas-link-manifest.json; command-line arguments.
Downstream impact
Used directly by 1 file: PipelineNews Current GridAtlas V9 Deep Link Successor Workflow (pipelinenews).
What it achieves
It loads JSON (`load_json`), writes JSON (`write_json`) and replaces exactly once (`replace_exactly_once`). Repair PipelineNews exact-REPD routing without changing data, news, or project bytes. It accepts `--release-dir` and `--golden-repd-ref`.
Why it matters
Run by PipelineNews Current GridAtlas V9 Deep Link Successor Workflow.
Application
pipelinenews · orchestration · Python CLI
Uses
__future__, argparse, hashlib, json, re, pathlib, typing
Used by
run by PipelineNews Current GridAtlas V9 Deep Link Successor Workflow (workflow run)
Produces
require, load_json, sha256, write_json, replace_exactly_once, refresh_file_inventory, write_sha256sums, main
Defines here
require, load_json, sha256, write_json, replace_exactly_once, refresh_file_inventory, write_sha256sums, 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 orchestration/202608300358-repair-exact-repd-route.py:1-188 · blob 5267cca9a4b9c2ad66782ff3df2e3640ecc8a85f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: field_execution · users: IPP_developer, EPC_contractor, landowner_planner · canonical: production_core
#!/usr/bin/env python3
"""Repair PipelineNews exact-REPD routing without changing data, news, or project bytes."""

from __future__ import annotations

import argparse
import hashlib
import json
import re
from pathlib import Path
from typing import Any

APP_RELATIVE = Path("assets/202608291447-app.mjs")
APP_REPAIRS = (
    (
        "    if (tokens.length) {\n",
        "    if (!requestedRepdRef && tokens.length) {\n",
        "exact REPD identity bypasses broad-search row text",
    ),
    (
        "  if (query) await ensureSearchSupplement();\n",
        "  if (query && !requestedRepdRef) await ensureSearchSupplement();\n",
        "exact REPD identity does not fetch broad-search supplement",
    ),
)


def require(condition: bool, message: str) -> None:
    if not condition:
        raise RuntimeError(message)


def load_json(path: Path) -> dict[str, Any]:
    value = json.loads(path.read_text(encoding="utf-8"))
    require(isinstance(value, dict), f"JSON root is not an object: {path}")
    return value


def sha256(path: Path) -> str:
    digest = hashlib.sha256()
    with path.open("rb") as handle:
        for chunk in iter(lambda: handle.read(1024 * 1024), b""):
            digest.update(chunk)
    return digest.hexdigest()


def write_json(path: Path, value: dict[str, Any]) -> None:
    path.write_text(
        json.dumps(value, indent=2, sort_keys=True) + "\n",
        encoding="utf-8",
        newline="\n",
    )


def replace_exactly_once(source: str, before: str, after: str, label: str) -> str:
    count = source.count(before)
    require(count == 1, f"repair anchor mismatch for {label}: {count}")
    require(after not in source, f"repair already applied for {label}")
    return source.replace(before, after)


def refresh_file_inventory(root: Path, build: dict[str, Any]) -> None:
    files: list[dict[str, Any]] = []
    excluded = {"sha256sums.txt", "build-manifest.json", "release-manifest.json"}
    for path in sorted(item for item in root.rglob("*") if item.is_file() and item.name not in excluded):
        files.append(
            {
                "path": path.relative_to(root).as_posix(),
                "bytes": path.stat().st_size,
                "sha256": sha256(path),
            }
        )
    build["files"] = files


def write_sha256sums(root: Path) -> None:
    rows: list[str] = []
    for path in sorted(item for item in root.rglob("*") if item.is_file() and item.name != "sha256sums.txt"):
        rows.append(f"{sha256(path)}  {path.relative_to(root).as_posix()}\n")
    (root / "sha256sums.txt").write_text("".join(rows), encoding="utf-8", newline="\n")


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--release-dir", required=True)
    parser.add_argument("--golden-repd-ref", required=True)
    args = parser.parse_args()

    root = Path(args.release_dir)
    require(root.is_dir(), f"release directory missing: {root}")
    require(re.fullmatch(r"\d+", args.golden_repd_ref) is not None, "golden REPD Ref invalid")

    app_path = root / APP_RELATIVE
    atlas_manifest_path = root / "atlas-link-manifest.json"
    build_manifest_path = root / "build-manifest.json"
    release_manifest_path = root / "release-manifest.json"
    for path in (app_path, atlas_manifest_path, build_manifest_path, release_manifest_path):
        require(path.is_file(), f"required candidate file missing: {path}")

    app = app_path.read_text(encoding="utf-8")
    repairs: list[dict[str, str]] = []
    for before, after, label in APP_REPAIRS:
        app = replace_exactly_once(app, before, after, label)
        repairs.append({"id": label, "before": before.strip(), "after": after.strip()})
    app_path.write_text(app, encoding="utf-8", newline="\n")

    atlas_manifest = load_json(atlas_manifest_path)
    require(atlas_manifest.get("data_changes") == 0, "builder data-change boundary moved")
    require(atlas_manifest.get("news_changes") == 0, "builder news-change boundary moved")
    require(atlas_manifest.get("project_changes") == 0, "builder project-change boundary moved")
    require(
        str(atlas_manifest.get("identity", {}).get("golden_repd_ref")) == args.golden_repd_ref,
        "golden REPD identity differs from receiver contract",
    )
    atlas_manifest.update(
        {
            "application_changes": 1,
            "deep_link_logic_changes": len(APP_REPAIRS),
            "exact_identity_route": {
                "parameter": "repd_ref",
                "stable_key_source": "compact project index field zero",
                "broad_search_supplement_required": False,
                "broad_search_supplement_requests_expected": 0,
                "golden_repd_ref": args.golden_repd_ref,
            },
        }
    )
    write_json(atlas_manifest_path, atlas_manifest)

    build = load_json(build_manifest_path)
    require(build.get("classification") == "DETERMINISTIC_RECEIVER_ONLY_BUILD", "builder classification moved")
    build.update(
        {
            "schema": "pipelinenews.current-atlas-link-build-manifest.v2",
            "application_changes": 1,
            "data_changes": 0,
            "news_changes": 0,
            "project_changes": 0,
            "deep_link_logic_changes": len(APP_REPAIRS),
            "deep_link_repairs": repairs,
            "golden_repd_ref": args.golden_repd_ref,
        }
    )
    allowed = set(build.get("allowed_changed_paths") or [])
    allowed.add(APP_RELATIVE.as_posix())
    build["allowed_changed_paths"] = sorted(allowed)
    refresh_file_inventory(root, build)
    write_json(build_manifest_path, build)

    release = load_json(release_manifest_path)
    release.update(
        {
            "schema": "pipelinenews.current-atlas-link-release.v2",
            "product_surface": "SOURCE_RELEASE_PLUS_VERIFIED_ATLAS_RECEIVER_AND_EXACT_REPD_ROUTE",
            "application_changes": 1,
            "data_changes": 0,
            "news_changes": 0,
            "project_changes": 0,
            "exact_identity_route": {
                "parameter": "repd_ref",
                "golden_repd_ref": args.golden_repd_ref,
                "broad_search_supplement_requests_expected": 0,
            },
        }
    )
    write_json(release_manifest_path, release)

    write_sha256sums(root)
    print(
        json.dumps(
            {
                "classification": "DETERMINISTIC_EXACT_REPD_ROUTE_REPAIRED",
                "release_id": root.name,
                "golden_repd_ref": args.golden_repd_ref,
                "application_changes": 1,
                "data_changes": 0,
                "news_changes": 0,
                "project_changes": 0,
                "deep_link_logic_changes": len(APP_REPAIRS),
                "app_sha256": sha256(app_path),
            },
            sort_keys=True,
        )
    )


if __name__ == "__main__":
    main()

PipelineNews Atlas Pointer Deep Link

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

transformpipelinenews / releases/202608312018-pipelinenews/assets/202608312018-atlas-pointer-deep-link.mjs · lines 1–249 of 249 · version 2026-08-31 20:18 · 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 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: solar.
Inputs & outputs
In: JSON file live-set.json.
Downstream impact
Used directly by 3 files: Releases — PipelineNews (pipelinenews); Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Ventus Grid Engine — Genome Page (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/). Reached from 2 other entry points, including Releases — PipelineNews Page (pipelinenews, https://ventusltd.github.io/pipelinenews/releases/202611132345-pipelinenews/); Genome Workflow (ventus-grid-engine).
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.
Why it matters
Loaded by the Genome page in Ventus Grid Engine at https://ventusltd.github.io/ventus-grid-engine/genome/. Also imported by Releases — PipelineNews and Build Graph, from Ventus Grid Engine.
Application
pipelinenews · releases/202608312018-pipelinenews/assets · JavaScript module
Uses
GridAtlas — Atlas Page (estate URL), GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL)
Used by
imported by Releases — PipelineNews (import), named by URL in Build Graph (estate URL), named by URL in Ventus Grid Engine — Genome Page (estate URL)
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 releases/202608312018-pipelinenews/assets/202608312018-atlas-pointer-deep-link.mjs:1-249 · blob cb85109f99373755ba2a868bff9b65ea78265f2d · 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: production_core
/**
 * PipelineNews -> GridAtlas deep-link cartridge.
 *
 * Generation 202608312018. 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 OPEN DECISION (priority item L-04)
 * ---------------------------------------------------------------------------
 * Two receivers accept the same parameters:
 *   "legacy" - globalgrid2050.com/repd_grid_atlasv8/  - proven, in use today
 *   "ported" - ventusltd.github.io/gridatlas/atlas/   - the migration target
 *
 * Change ACTIVE_TARGET below. That is the entire switch. Both are validated by
 * the same invariants, so neither can be selected in a broken state.
 */

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",
  }),
  legacy: Object.freeze({
    id: "legacy",
    schema: "pipelinenews.gridatlas-live-pointer-receipt.v4",
    classification: "VERIFIED_LEGACY_ATLAS_V8_IN_SERVICE",
    generation: "legacy",
    release_id: "repd_grid_atlasv8",
    base_url: "https://globalgrid2050.com/repd_grid_atlasv8/",
    pinned_release_url: "https://globalgrid2050.com/repd_grid_atlasv8/",
    hostname: "globalgrid2050.com",
    pathname: "/repd_grid_atlasv8/",
    state_url: null,
    source_commit: null,
  }),
});

/** L-04. One line. Both branches are invariant-checked below. */
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: "202608312018",
  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 };
}

PipelineNews Codex Atlas Lab Proof

A JavaScript module that reads the Renewable Energy Planning Database (REPD) register from the GridAtlas repository.

ingestpipelinenews / releases/202609020010-pipelinenews/202609020010-codex-atlas-lab.proof.mjs · lines 1–123 of 123 · version 2026-09-02 00:10 · 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:path, node:url. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'codex'): 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; JSON file current.json.
What it achieves
It is built from the check step (`check`), the text step (`text`) and the JSON step (`json`). Executable acceptance proof for the isolated Codex MAP journey.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · releases/202609020010-pipelinenews · JavaScript module
Uses
node:fs/promises, node:path, node:url
Used by
none found
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 releases/202609020010-pipelinenews/202609020010-codex-atlas-lab.proof.mjs:1-123 · blob 3ee6765377470794a072df8374021e87f6c574f0 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: duplicate_candidate
/** Executable acceptance proof for the isolated Codex MAP journey. */
import { readFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';

const ROOT = dirname(fileURLToPath(import.meta.url));
const GENERATION = '202609020010';
const ROUTE = `https://ventusltd.github.io/gridatlas/atlas/codex/${GENERATION}/`;
const ASSET = `assets/${GENERATION}-codex-atlas-lab-deep-link.mjs`;

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

const text = async (relative) => readFile(join(ROOT, relative), 'utf8');
const json = async (relative) => JSON.parse(await text(relative));
const app = await text('assets/202608291447-app.mjs');
const source = await text(ASSET);
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');
const module = await import(`${pathToFileURL(join(ROOT, ASSET)).href}?proof=${GENERATION}`);

check('release generation is the paired Codex timestamp',
  manifest.generation === GENERATION && manifest.release_id === `${GENERATION}-pipelinenews`);
check('release is explicitly a non-deployed Codex candidate',
  manifest.atlas_target === 'codex' && manifest.deployment === 'not-authorised');
check('release metadata has no stale shared/Claude receiver',
  manifest.atlas_live_url === ROUTE
  && manifest.atlas_release_id === `codex/${GENERATION}`
  && manifest.shared_atlas_pointer_consumed === false
  && manifest.shared_atlas_route_consumed === false);
check('app imports only the timestamped Codex handoff',
  app.startsWith(`import { buildAtlasV9DeepLink } from "./${GENERATION}-codex-atlas-lab-deep-link.mjs";`));
check('app does not import either inherited Atlas handoff',
  !/^import .*20260831(?:1343|2037)-atlas-pointer-deep-link/mu.test(app));

const entry = registry.supplemental_assets?.codex_atlas_lab_handoff;
check('registry pins the isolated receiver',
  entry?.receiver_route === ROUTE && entry?.active_target === 'codex');
check('registry refuses both shared receiver mechanisms',
  entry?.shared_pointer_consumed === false && entry?.shared_atlas_route_consumed === false);
check('executable contract pins the same immutable receiver',
  module.ATLAS_DEEP_LINK_CONTRACT.receiver.base_url === ROUTE);
check('handoff source contains no parent-relative reference', !source.includes('../'));
check('handoff source cannot assign the shared current pointer as its receiver',
  !/BASE_URL\s*=.*current\.json/u.test(source));

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

let eligible = 0;
let emitted = 0;
let wrongRoute = 0;
let sharedRoute = 0;
let sharedPointer = 0;
let wrongIdentity = 0;
let missingContext = 0;
let halfCoordinate = 0;
let nonFinite = 0;
let overBudget = 0;
let maxBytes = 0;
for (const row of projects.rows) {
  const project = decode(row);
  const href = module.buildAtlasV9DeepLink(project);
  const shouldEmit = project.geometry_status === 'valid'
    && /^\d+$/u.test(String(project.repd_ref));
  if (!shouldEmit) {
    if (href) failures.push(`ineligible REPD ${project.repd_ref} emitted a MAP URL`);
    continue;
  }
  eligible += 1;
  if (!href) continue;
  emitted += 1;
  const url = new URL(href);
  const bytes = Buffer.byteLength(href, 'utf8');
  maxBytes = Math.max(maxBytes, bytes);
  if (bytes > 2048) overBudget += 1;
  if (url.href.startsWith(ROUTE) === false) wrongRoute += 1;
  if (url.pathname === '/gridatlas/atlas/') sharedRoute += 1;
  if (url.href.includes('current.json')) sharedPointer += 1;
  if (url.searchParams.get('repd_ref') !== String(project.repd_ref)) wrongIdentity += 1;
  for (const key of ['technology', 'capacity_mw', 'latitude', 'longitude', 'zoom']) {
    if (!url.searchParams.has(key)) missingContext += 1;
  }
  if (project.name
      ? url.searchParams.get('project') !== project.name
      : url.searchParams.has('project')) missingContext += 1;
  const lat = url.searchParams.get('latitude');
  const lon = url.searchParams.get('longitude');
  if ((lat === null) !== (lon === null)) halfCoordinate += 1;
  if (![lat, lon, url.searchParams.get('capacity_mw'), url.searchParams.get('zoom')]
    .every((value) => value !== null && Number.isFinite(Number(value)))) nonFinite += 1;
}

check('every eligible project emits one lab MAP URL', emitted === eligible,
  `${emitted}/${eligible}`);
check('every MAP URL uses only the paired Codex generation', wrongRoute === 0);
check('no Codex lab MAP URL targets Claude/shared /atlas/', sharedRoute === 0);
check('no Codex lab MAP URL targets atlas/current.json', sharedPointer === 0);
check('every MAP URL preserves exact REPD identity', wrongIdentity === 0);
check('every MAP URL carries immediate mobile/grid context', missingContext === 0);
check('coordinates remain a finite inseparable pair', halfCoordinate === 0 && nonFinite === 0);
check('every URL is under the 2 KiB mobile/proxy budget', overBudget === 0,
  `maximum ${maxBytes} bytes`);
check('module self-test passes', module.selfTest().ok);

console.log(`\n${passed}/${passed + failures.length} checks passed`);
console.log(`${emitted} Codex-lab MAP journeys; maximum URL ${maxBytes} bytes`);
if (failures.length) {
  console.error('\nFAILURES');
  failures.forEach((failure) => console.error(`  ${failure}`));
  process.exit(1);
}

PipelineNews Codex Atlas Lab Deep Link

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

transformpipelinenews / releases/202609020010-pipelinenews/assets/202609020010-codex-atlas-lab-deep-link.mjs · lines 1–96 of 96 · version 2026-09-02 00:10 · 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.
Why it exists in the grid workflow
Domain stage agent_infra (path word 'codex'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: solar.
Inputs & outputs
In: JSON file current.json.
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`). Pipeline News -> immutable Codex GridAtlas laboratory generation.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · releases/202609020010-pipelinenews/assets · JavaScript module
Uses
none found
Used by
none found
Produces
ATLAS_DEEP_LINK_CONTRACT, buildAtlasV9DeepLink, selfTest
Defines here
invariant, finiteInRange, buildAtlasV9DeepLink, selfTest
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 releases/202609020010-pipelinenews/assets/202609020010-codex-atlas-lab-deep-link.mjs:1-96 · blob e0cdc5d22e64f50aec22db662995a5657117c662 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
/**
 * Pipeline News -> immutable Codex GridAtlas laboratory generation.
 *
 * This is deliberately not the shared /gridatlas/atlas/ route. A Codex lab
 * release and Claude's active composition must be comparable without either
 * agent silently moving the other's receiver.
 */
const GENERATION = "202609020010";
const BASE_URL = `https://ventusltd.github.io/gridatlas/atlas/codex/${GENERATION}/`;
const DEFAULT_ZOOM = 12;

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

const receiver = new URL(BASE_URL);
invariant(receiver.protocol === "https:", "receiver must use HTTPS");
invariant(receiver.hostname === "ventusltd.github.io", "receiver host changed");
invariant(receiver.pathname === `/gridatlas/atlas/codex/${GENERATION}/`,
  "receiver is not the immutable Codex laboratory route");
invariant(!receiver.pathname.endsWith("/atlas/"), "shared Atlas route is forbidden");
invariant(!BASE_URL.includes("current.json"), "shared Atlas pointer is forbidden");

export const ATLAS_DEEP_LINK_CONTRACT = Object.freeze({
  schema: "pipelinenews.codex-atlas-lab-deep-link.v1",
  generation: GENERATION,
  deployment: "not-authorised",
  active_target: "codex",
  receiver: Object.freeze({
    base_url: BASE_URL,
    pathname: receiver.pathname,
    immutable_generation: GENERATION,
  }),
  identity_anchor: "repd_ref",
  inbound_match_semantics: "EXACT_PROJECT_REPD_REF",
  context_parameters_are_advisory: true,
  shared_pointer_consumed: false,
});

function finiteInRange(value, limit) {
  if (value === null || value === undefined || value === "") return null;
  const number = Number(value);
  return Number.isFinite(number) && Math.abs(number) <= limit ? number : null;
}

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

  const url = new URL(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));
  }

  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;
}

export function selfTest() {
  const project = {
    repd_ref: "10916",
    name: "West Burton Solar Project",
    technology: "solar",
    capacity_mw: 480,
    latitude: 53.2926216,
    longitude: -0.6774547,
    geometry_status: "valid",
  };
  const url = new URL(buildAtlasV9DeepLink(project));
  const checks = [
    ["immutable Codex path", url.pathname === `/gridatlas/atlas/codex/${GENERATION}/`],
    ["exact REPD identity", url.searchParams.get("repd_ref") === "10916"],
    ["project context", url.searchParams.get("project") === project.name],
    ["technology context", url.searchParams.get("technology") === "solar"],
    ["capacity context", url.searchParams.get("capacity_mw") === "480"],
    ["coordinate pair", url.searchParams.has("latitude") && url.searchParams.has("longitude")],
    ["mobile zoom", url.searchParams.get("zoom") === "12"],
    ["not shared Atlas", url.pathname !== "/gridatlas/atlas/"],
    ["no shared pointer", !url.href.includes("current.json")],
  ].map(([name, ok]) => ({ name, ok }));
  return { ok: checks.every((item) => item.ok), checks, url: url.href };
}