GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / pipelinenews / tools/overnight/steps

Build 30x Ledger and 9 more files

A Python command-line tool in the publication folder of PipelineNews that builds the machine-readable receipt ledger for the audited candidate stream.

642 lines of JavaScript and Python from pipelinenews, in 10 files. Topic: Electricity markets and data pipelines. Section 1054 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. Transmission Is Answerable other · pipelinenews / tools/overnight/steps/202609012335-transmission-is-answerable.mjs lines 1–51
  2. Mapped Is Not Nearest other · pipelinenews / tools/overnight/steps/202609012340-mapped-is-not-nearest.mjs lines 1–49
  3. Season Is Named other · pipelinenews / tools/overnight/steps/202609012345-season-is-named.mjs lines 1–48
  4. Hops Are Not Kilometres other · pipelinenews / tools/overnight/steps/202609012350-hops-are-not-kilometres.mjs lines 1–47
  5. Homepage Reachability ingest · pipelinenews / tools/publication/202609020042-homepage-reachability.mjs lines 1–96
  6. Build Coverage Candidate render · pipelinenews / tools/publication/build-coverage-candidate.mjs lines 1–56
  7. Build Reported Project Candidate render · pipelinenews / tools/publication/build-reported-project-candidate.mjs lines 1–20
  8. Build RSS Candidate storage · pipelinenews / tools/publication/build-rss-candidate.mjs lines 1–35
  9. Build 30x Ledger storage · pipelinenews / tools/publication/build_30x_ledger.py lines 1–125
  10. Build Pages Promotion Pointer storage · pipelinenews / tools/publication/build_pages_promotion_pointer.py lines 1–115

Transmission Is Answerable

A JavaScript module in the steps folder of PipelineNews covering cartridge.

otherpipelinenews / tools/overnight/steps/202609012335-transmission-is-answerable.mjs · lines 1–51 of 51 · version 2026-09-01 23:35 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'transmission'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file cartridge.json.
What it achieves
The GRID strip stops ending on what cannot be answered.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
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/overnight/steps/202609012335-transmission-is-answerable.mjs:1-51 · blob 093156b28f3e35a800531656bf6ae13d39629d61 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the GRID strip stops ending on what cannot be answered.
 *
 * The strip has ended, correctly, on a refusal - "not a cable route, and
 * not headroom - fault level and thermal headroom need DNO network data
 * such as source impedance and a connection study". Every word of that is
 * still true and none of it is removed.
 *
 * But it was the LAST thing the reader was told, and on 1 September 2026 it
 * stopped being the whole story. The Atlas now reads NESO's published
 * transmission network and answers, for the site a project declares: the
 * circuits and transformers that land there per voltage; their ratings in
 * every season the operator publishes, never summed; how many published
 * circuits away a neighbour is; and where the project's own output would
 * flow on a declared DC model. So the strip gains one clause naming what
 * MAP now opens, and keeps every caveat it had.
 *
 * This is the first Pipeline News release of the night shift, and the
 * first to be cut by a runner rather than by hand.
 */

const CARTRIDGE = 'transmission-is-answerable';

export default {
  id: 'transmission-is-answerable',
  cartridge: CARTRIDGE,
  atlasTarget: 'ported',

  scope: 'the GRID + SUB strip names what the published transmission network can now answer',

  note: 'Every refusal is kept verbatim - distance is not a route, a rating is not headroom, and the DC model is not a loading because what is already flowing is published nowhere. What is added is only what is answerable from a published source: NESO ETYS 2025 Appendix B, via Ventusltd/data-grid-gb.',

  brings: [
    `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
    `tools/intelligence/cartridges/${CARTRIDGE}/cartridge.json`,
  ],

  /* The cartridge is regenerated against the ACTUAL parent this run picked,
     not the one it was written against. If the anchor has moved because a
     release landed in between, make_cartridge.py fails here with the
     anchor's name attached - before the builder is asked to apply it. */
  async prepare({ parent, run, python }) {
    const r = run(python, [
      `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
      '--parent', parent,
    ], { allowFail: true });
    if (r.status !== 0) {
      throw new Error(`the cartridge could not be generated against ${parent}: ${r.out.slice(-600)}`);
    }
  },
};

Mapped Is Not Nearest

A JavaScript module in the steps folder of PipelineNews covering cartridge and substations.

otherpipelinenews / tools/overnight/steps/202609012340-mapped-is-not-nearest.mjs · lines 1–49 of 49 · version 2026-09-01 23:40 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: substations, 132kV.
Inputs & outputs
In: JSON file cartridge.json. Voltage levels named: 132kV.
What it achieves
The GRID + SUB strip states the limit of the word "nearest". Its code works with 132 kV.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
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/overnight/steps/202609012340-mapped-is-not-nearest.mjs:1-49 · blob a1b2797f625e7b19a2669c3f2fa1e41988526eea · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the GRID + SUB strip states the limit of the word "nearest".
 *
 * The strip has always said "nearest mapped", which was careful, and it
 * never said how much of the network is unmapped. 384 of 886 published
 * connection points carry no coordinates at all - not because they do not
 * exist but because nobody has mapped them, and the owner product publishes
 * them anyway rather than dropping them, which is the honest choice and the
 * reason the gap is knowable.
 *
 * A distance to the nearest mapped substation is therefore a distance to
 * the nearest substation SOMEONE HAS MAPPED. For most projects those are
 * the same thing. For some they are not, and nothing on the page told the
 * reader which case they were looking at.
 *
 * One string in one file. No payload, no render-time network call, and
 * every existing caveat kept verbatim - this only adds.
 */

const CARTRIDGE = 'mapped-is-not-nearest';

export default {
  id: 'mapped-is-not-nearest',
  cartridge: CARTRIDGE,
  atlasTarget: 'ported',

  scope: "the GRID + SUB strip states the limit of the word \"nearest\"",

  note: "NESO names 886 transmission substations at 132 kV and above; the Atlas locates 502 of them and the owner product publishes the other 384 without coordinates rather than dropping them, saying so in its own join block. So the nearest MAPPED substation may not be the nearest substation, and a reader comparing two projects on that number is comparing coverage as much as geography. Counts read  … [line shortened here: 442 characters; full line on GitHub]

  brings: [
    `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
    `tools/intelligence/cartridges/${CARTRIDGE}/cartridge.json`,
  ],

  /* Regenerated against the parent this run actually picked. If a release
     landed in between and moved the anchor, make_cartridge.py fails here
     with the anchor's own name attached, before the builder is asked to
     apply something that no longer matches. */
  async prepare({ parent, run, python }) {
    const r = run(python, [
      `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
      '--parent', parent,
    ], { allowFail: true });
    if (r.status !== 0) {
      throw new Error(`the cartridge could not be generated against ${parent}: ${r.out.slice(-600)}`);
    }
  },
};

Season Is Named

A JavaScript module in the steps folder of PipelineNews covering cartridge.

otherpipelinenews / tools/overnight/steps/202609012345-season-is-named.mjs · lines 1–48 of 48 · version 2026-09-01 23:45 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file cartridge.json.
What it achieves
The strip says a rating without its season is ambiguous, and that the Atlas never sums them.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
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/overnight/steps/202609012345-season-is-named.mjs:1-48 · blob 618aa1558286aedcb01279bf9caddd573134b66f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the strip says a rating without its season is ambiguous, and that the Atlas never sums them.
 *
 * A rating quoted without its season is ambiguous, and the ambiguity is
 * not symmetric: winter is the more generous number on 1,273 of the 1,276
 * circuits that publish both. A reader who sees one figure and assumes it
 * holds all year is assuming the most favourable case.
 *
 * Pipeline News quotes no MVA rating itself - that was checked before this
 * was written, across every html, mjs and css file in the parent release -
 * so there is nothing here to correct. What there is, is a reader who
 * clicks through to ratings that ARE quoted, and who should arrive knowing
 * that each one names its season and that they are never added together.
 *
 * One string in one file. No payload, no render-time network call, and
 * every existing caveat kept verbatim - this only adds.
 */

const CARTRIDGE = 'season-is-named';

export default {
  id: 'season-is-named',
  cartridge: CARTRIDGE,
  atlasTarget: 'ported',

  scope: "the strip says a rating without its season is ambiguous, and that the Atlas never sums them",

  note: "Pipeline News quotes no MVA rating at all - verified by searching every html, mjs and css in the parent release. What it can do is tell the reader what the ratings in the Atlas mean: NESO publishes a winter rating for all 1,392 circuits and a summer rating for 1,276, and summer differs from winter on 1,081 of those. Winter is the more generous figure on 1,273 of them, which is why a ratin  … [line shortened here: 451 characters; full line on GitHub]

  brings: [
    `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
    `tools/intelligence/cartridges/${CARTRIDGE}/cartridge.json`,
  ],

  /* Regenerated against the parent this run actually picked. If a release
     landed in between and moved the anchor, make_cartridge.py fails here
     with the anchor's own name attached, before the builder is asked to
     apply something that no longer matches. */
  async prepare({ parent, run, python }) {
    const r = run(python, [
      `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
      '--parent', parent,
    ], { allowFail: true });
    if (r.status !== 0) {
      throw new Error(`the cartridge could not be generated against ${parent}: ${r.out.slice(-600)}`);
    }
  },
};

Hops Are Not Kilometres

A JavaScript module in the steps folder of PipelineNews covering cartridge.

otherpipelinenews / tools/overnight/steps/202609012350-hops-are-not-kilometres.mjs · lines 1–47 of 47 · version 2026-09-01 23:50 · Not reached from any entry point (candidate for review)

Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file cartridge.json.
What it achieves
The connections panel says a kilometre is not a connection, and points at the measurement that is.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/overnight/steps · JavaScript module
Uses
none found
Used by
none found
Produces
none declared
Defines here
none
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/overnight/steps/202609012350-hops-are-not-kilometres.mjs:1-47 · blob e33d37d5485fe2a02fde8e0534caf880ded2689d · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Step: the connections panel says a kilometre is not a connection, and points at the measurement that is.
 *
 * The panel measures straight-line kilometres and says so. What it could
 * not say, until 1 September 2026, was that there is another measurement -
 * because there was not one. The Atlas now traverses the published
 * node/branch model and counts circuits, and the two answers are different
 * questions rather than better and worse versions of one.
 *
 * The figures in the note are read from the product, not chosen for effect:
 * the longest published circuit runs 223.195 km of route between its two
 * ends, so "far apart" and "not connected" are plainly independent.
 *
 * One string in one file. No payload, no render-time network call, and
 * every existing caveat kept verbatim - this only adds.
 */

const CARTRIDGE = 'hops-are-not-kilometres';

export default {
  id: 'hops-are-not-kilometres',
  cartridge: CARTRIDGE,
  atlasTarget: 'ported',

  scope: "the connections panel says a kilometre is not a connection, and points at the measurement that is",

  note: "Two sites a few kilometres apart can share no published circuit, and the two ends of ONE published circuit can be over 200 km of route apart - the longest, PEMB41-WALH41, is 223.195 km, and 17 of 1,392 circuits exceed 100 km. Lengths read from circuits[].ohl_km + cable_km. The panel still reports straight-line kilometres, which is what it measures; MAP now reports the count of published c  … [line shortened here: 472 characters; full line on GitHub]

  brings: [
    `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
    `tools/intelligence/cartridges/${CARTRIDGE}/cartridge.json`,
  ],

  /* Regenerated against the parent this run actually picked. If a release
     landed in between and moved the anchor, make_cartridge.py fails here
     with the anchor's own name attached, before the builder is asked to
     apply something that no longer matches. */
  async prepare({ parent, run, python }) {
    const r = run(python, [
      `tools/intelligence/cartridges/${CARTRIDGE}/make_cartridge.py`,
      '--parent', parent,
    ], { allowFail: true });
    if (r.status !== 0) {
      throw new Error(`the cartridge could not be generated against ${parent}: ${r.out.slice(-600)}`);
    }
  },
};

Homepage Reachability

A JavaScript module in the publication folder of PipelineNews. It is built from the homepage reachability helper (`homepageReachability`) and the is reachable helper (`isReachable`).

ingestpipelinenews / tools/publication/202609020042-homepage-reachability.mjs · lines 1–96 of 96 · version 2026-09-02 00:42 · Not reached from any entry point (candidate for review)

What it does
It loads data. Defines homepageReachability, isReachable. Uses libraries node:fs, node:path, node:url. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: command-line arguments.
Downstream impact
Used directly by 1 file: Shift (pipelinenews).
What it achieves
Is the published snapshot reachable from the homepage that serves it?
Why it matters
Run by Shift.
Application
pipelinenews · tools/publication · JavaScript module
Uses
node:fs, node:path, node:url
Used by
run by Shift (script call)
Produces
homepageReachability, isReachable
Defines here
homepageReachability, isReachable
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/publication/202609020042-homepage-reachability.mjs:1-96 · blob 69d426bec63319b1fd564b2082ba88ad76fe422a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Is the published snapshot reachable from the homepage that serves it?
 *
 * The overnight runner publishes `releases/<generation>-pipelinenews/` into
 * `../globalgrid2050/pipelinenews_intelligence/<generation>/`, verifies it byte
 * for byte, pushes it, and waits for the public host to serve it. All of that
 * held for 202609012326 and 202609020025 and both were still, in the only sense
 * a reader cares about, unpublished: `index.html` is the only route to those
 * directories and it named neither, so the newest reachable version was
 * 202608312339, three behind the head of the lineage.
 *
 * The runner does not edit that homepage - naming a release there is a
 * deliberate act governed by a numbered-snapshot ritual - so this module does
 * not either. It reports. A cut that is served but reachable from nothing is
 * recorded as exactly that, instead of being recorded as finished.
 *
 *   node tools/publication/202609020042-homepage-reachability.mjs
 *   node tools/publication/202609020042-homepage-reachability.mjs --generation 202609020025
 */
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const HERE = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(HERE, '..', '..');
const GG = path.resolve(ROOT, '..', 'globalgrid2050');

const SNAPSHOT_URL = /url:"\.\/pipelinenews_intelligence\/([0-9]{12})\/"/g;

/**
 * @param {{ globalgrid?: string }} options
 * @returns {{ available: boolean, reason?: string, published: string[], named: string[],
 *             presentedFirst: string|null, unreachable: string[], dangling: string[] }}
 */
export function homepageReachability({ globalgrid = GG } = {}) {
  const index = path.join(globalgrid, 'index.html');
  const snapshots = path.join(globalgrid, 'pipelinenews_intelligence');
  if (!fs.existsSync(index) || !fs.existsSync(snapshots)) {
    return {
      available: false,
      reason: `no globalgrid2050 checkout beside this repository at ${globalgrid}`,
      published: [], named: [], presentedFirst: null, unreachable: [], dangling: [],
    };
  }

  const published = fs.readdirSync(snapshots, { withFileTypes: true })
    .filter(entry => entry.isDirectory() && /^[0-9]{12}$/.test(entry.name))
    .map(entry => entry.name)
    .sort();

  const html = fs.readFileSync(index, 'utf8');
  const named = [...html.matchAll(SNAPSHOT_URL)].map(match => match[1]);
  const namedSet = new Set(named);

  return {
    available: true,
    published,
    named,
    presentedFirst: named[0] ?? null,
    unreachable: published.filter(generation => !namedSet.has(generation)),
    dangling: named.filter(generation => !published.includes(generation)),
  };
}

/**
 * The one question the runner asks: is this generation both served and named?
 */
export function isReachable(generation, options) {
  const state = homepageReachability(options);
  if (!state.available) return { ...state, generation, served: false, named: false };
  return {
    ...state,
    generation,
    served: state.published.includes(generation),
    named: state.named.includes(generation),
    is_newest_named: state.presentedFirst === generation,
  };
}

if (import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith('202609020042-homepage-reachability.mjs')) {
  const index = process.argv.indexOf('--generation');
  const state = homepageReachability();
  if (!state.available) {
    console.log(`skipped: ${state.reason}`);
    process.exit(0);
  }
  if (index > 0) {
    const report = isReachable(process.argv[index + 1]);
    console.log(JSON.stringify(report, null, 2));
    process.exit(report.served && report.named ? 0 : 1);
  }
  console.log(`published: ${state.published.length}   named: ${new Set(state.named).size}   newest named first: ${state.presentedFirst}`);
  if (state.unreachable.length) console.log(`served but reachable from nothing: ${state.unreachable.join(', ')}`);
  if (state.dangling.length) console.log(`named but not published: ${state.dangling.join(', ')}`);
  process.exit(state.unreachable.length || state.dangling.length ? 1 : 0);
}

Build Coverage Candidate

A JavaScript module in the publication folder of PipelineNews that draws grid proximity, grid distance, substation 33kV and substations, using SHA-256.

renderpipelinenews / tools/publication/build-coverage-candidate.mjs · lines 1–56 of 56 · Entry point · pattern committed (shared by 3 files)

What it does
It draws grid proximity, grid distance, substation 33kV and substations. Defines hash, committed, el, update. Uses libraries node:fs, node:crypto, node:child_process, node:path. Side effects: changes the web page (DOM); reads or writes files; makes network requests; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: substations, 33kV.
Inputs & outputs
In: JSON file 202608311610-grid-proximity.json; JSON file 202608311800-grid-distance.json; JSON file 202608311858-substation-33kv.json; JSON file coverage.json; form fields (user input); command-line arguments. Out: JSON file coverage.json. Voltage levels named: 33kV.
Downstream impact
Used directly by 1 file: PipelineNews Coverage Contract Workflow (pipelinenews).
What it achieves
Its name says it builds coverage candidate. Defines `hash`, `committed` and `update`. It reads `./coverage.json` and writes `/coverage.json`. It responds to change and input events.
Why it matters
Run by PipelineNews Coverage Contract Workflow.
Application
pipelinenews · tools/publication · JavaScript module
Uses
Coverage Join Audit (script call), node:fs, node:crypto, node:child_process, node:path
Used by
run by PipelineNews Coverage Contract Workflow (workflow run)
Produces
hash, committed, el, update
Defines here
hash, committed, el, update
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/publication/build-coverage-candidate.mjs:1-56 · blob 74585e6e7b9eb2079000db222dd7093dab973f7e · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, network, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
import { resolve } from 'node:path';
import { auditCoverage } from '../../cartridges/coverage-join-audit.mjs';

const generation = process.argv[2];
if (!/^\d{12}$/.test(generation ?? '')) throw Error('Supply a unique UTC YYYYMMDDHHMM generation');
const output = resolve('testcode', generation);
if (existsSync(output)) throw Error('Candidate already exists; immutable output will not be overwritten');
const root = 'releases/202609050309-pipelinenews/data/';
const names = ['202608311610-grid-proximity.json','202608311800-grid-distance.json','202608311858-substation-33kv.json'];
const hash = body => createHash('sha256').update(body).digest('hex');
const sourceCommit = execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8'}).trim();
const committed = path => execFileSync('git',['show',sourceCommit+':'+path],{maxBuffer:20*1024*1024});
const bytes = names.map(name => committed(root + name));
const sources = names.map((name,i) => ({path:root + name, sha256:hash(bytes[i]), bytes:bytes[i].length}));
const result = auditCoverage(...bytes.map(b => JSON.parse(b)));
result.sourceCommit = sourceCommit;
result.sources = sources;
mkdirSync(output, {recursive:true});
const report = JSON.stringify(result,null,2)+'\n';
writeFileSync(output+'/coverage.json',report);
writeFileSync(output+'/index.html',`<!doctype html>
<html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Pipeline News · Coverage audit ${generation}</title>
<style>body{font:17px/1.55 system-ui;margin:auto;padding:24px;max-width:900px;color:#e6edf3;background:#101923}a{color:#82cfff}h1{line-height:1.2}section{border:1px solid #435361;padding:18px;margin:20px 0;border-radius:8px}input,select,button{font:inherit;padding:9px;max-width:100%;box-sizing:border-box}table{width:100%;border-collapse:collapse}td,th{text-align:left;border-bottom:1px solid #43536  … [line shortened here: 612 characters; full line on GitHub]
<a href="https://globalgrid2050.com/#test-code">Test Code</a>
<h1>Pipeline News coverage audit</h1><p>Version ${generation} · PIPELINE-01 · Test candidate</p>
<p>This checks which project identities appear in the three pinned datasets. It does not change the live application.</p>
<p id="status" role="status">Loading verified coverage report…</p>
<section><h2>Dataset coverage</h2><div id="counts"></div><div id="technologies"></div></section>
<section><h2>Missing project identities</h2><label for="source">Missing from </label><select id="source"><option value="missingGrid">GRID</option><option value="missingSubstation">SUB</option></select>
<p><label for="search">Find REPD identity </label><input id="search" type="search" inputmode="numeric"></p><p id="match-count" aria-live="polite"></p><div id="identities"></div></section>
<section><h2>Records that cannot be joined</h2><div id="invalid"></div></section>
<p id="caveat"></p><p><a href="coverage.json" download>Download complete coverage report</a> · <a href="manifest.json">Source and version record</a></p>
<script type="module">
const el=id=>document.getElementById(id);
try {
 const response=await fetch('./coverage.json'); if(!response.ok)throw Error('Report unavailable');
 const bytes=await response.arrayBuffer(); const actual=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',bytes)),b=>b.toString(16).padStart(2,'0')).join('');
 if(actual!=='${hash(report)}')throw Error('Report identity mismatch');
 const data=JSON.parse(new TextDecoder().decode(bytes));
 el('status').textContent='Verified source report loaded. Coverage differs between datasets.';
 el('counts').textContent=data.counts.proximity+' proximity records; '+data.counts.validProximityIdentities+' valid identities; '+data.counts.grid+' GRID entries; '+data.counts.substation+' SUB entries.';
 const table=document.createElement('table');const header=table.createTHead().insertRow();for(const label of ['Technology','Proximity','GRID','SUB']){const th=document.createElement('th');th.textContent=label;header.append(th);}
 for(const [tech,counts]of Object.entries(data.byTechnology)){const row=table.insertRow();for(const value of [tech,counts.proximity,counts.grid,counts.substation])row.insertCell().textContent=value;}el('technologies').append(table);
 const update=()=>{const matches=data[el('source').value].filter(id=>id.includes(el('search').value.trim()));el('match-count').textContent=matches.length+' matching identities';el('identities').textContent=matches.join(', ')||'No matches';};
 el('source').addEventListener('change',update);el('search').addEventListener('input',update);update();
 for(const item of data.invalidProximity){const p=document.createElement('p');p.textContent=item.name+' — '+item.reason;el('invalid').append(p);}
 el('caveat').textContent=data.caveat;
}catch(error){el('status').textContent='Coverage unavailable: '+error.message;}
</script></html>`);
const files=['index.html','coverage.json'].map(path=>{const b=readFileSync(output+'/'+path);return {path,bytes:b.length,sha256:hash(b)};});
writeFileSync(output+'/manifest.json',JSON.stringify({schema:'ventus.testcode-candidate.v1',generation,planId:'PIPELINE-01',status:'candidate',change:'Report exact coverage differences and unjoinable source rows',owner:'Ventusltd/pipelinenews',sourceCommit:result.sourceCommit,module:{path:'cartridges/coverage-join-audit.mjs',sha256:hash(committed('cartridges/coverage-join-audit.mjs'))},sources,fil  … [line shortened here: 494 characters; full line on GitHub]
console.log(output);

Build Reported Project Candidate

A JavaScript module in the publication folder of PipelineNews that fetches cearn project evidence, using SHA-256.

renderpipelinenews / tools/publication/build-reported-project-candidate.mjs · lines 1–20 of 20 · Not reached from any entry point (candidate for review) · pattern digest (shared by 56 files)

What it does
It fetches cearn project evidence. Defines blob, digest. Uses libraries node:fs, node:child_process, node:crypto. Side effects: changes the web page (DOM); reads or writes files; makes network requests; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file 202609060208-cearn-project-evidence.json; JSON file project-evidence.json; JSON file snapshot.json; command-line arguments.
What it achieves
Its name says it builds reported project candidate. Defines `blob` and `digest`. It reads `./project-evidence.json`.
Why it matters
No other file in the estate was found to import it.
Application
pipelinenews · tools/publication · JavaScript module
Uses
Build RSS Candidate (script call), Reported Project (import), node:fs, node:child_process, node:crypto
Used by
none found
Produces
blob, digest
Defines here
blob, digest
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/publication/build-reported-project-candidate.mjs:1-20 · blob db041824c56af4b58121f679eb423839c2872f93 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, network, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
import {readFileSync,writeFileSync} from 'node:fs';
import {execFileSync} from 'node:child_process';
import {createHash} from 'node:crypto';
import {validateReportedProject} from '../../cartridges/reported-project.mjs';
const gen=process.argv[2];
execFileSync(process.execPath,['tools/publication/build-rss-candidate.mjs',gen],{stdio:'inherit'});
const out=`testcode/${gen}`,manifest=JSON.parse(readFileSync(`${out}/manifest.json`));
const blob=path=>execFileSync('git',['show',`${manifest.sourceCommit}:${path}`],{maxBuffer:2*1024*1024});
const digest=b=>createHash('sha256').update(b).digest('hex');
const evidence='discovery/inbox/202609060208-cearn-project-evidence.json';
validateReportedProject(JSON.parse(blob(evidence)));
const extra={'project-evidence.json':evidence,'reported-project.mjs':'cartridges/reported-project.mjs','reported-project-panel.mjs':'cartridges/reported-project-panel.mjs'};
for(const [name,path]of Object.entries(extra)){const b=blob(path);writeFileSync(`${out}/${name}`,b);manifest.sources.push({path,sha256:digest(b)});}
let html=readFileSync(`${out}/index.html`,'utf8');
html=html.replace('<section><h2>Energy and infrastructure news</h2>', '<section id="reported-project"><p>Loading attributed project evidence...</p></section><section><h2>Energy and infrastructure news</h2>');
html=html.replace('</html>',`<script type="module">import {showReportedProject} from './reported-project-panel.mjs';const host=document.getElementById('reported-project');try{const r=await fetch('./project-evidence.json');if(!r.ok)throw Error('Source unavailable');showReportedProject(host,await r.json());}catch(e){host.textContent='Project evidence unavailable: '+e.message;}</script></html>`);
writeFileSync(`${out}/index.html`,html);
manifest.planId='BBC-RSS-02';manifest.relatedPlan='PIPELINE-01';manifest.change='Keep Cearn news-only and separate its claims from related Botley West facts';
manifest.files=['index.html','snapshot.json',...Object.keys(extra)].map(path=>{const b=readFileSync(`${out}/${path}`);return{path,bytes:b.length,sha256:digest(b)};});
writeFileSync(`${out}/manifest.json`,JSON.stringify(manifest,null,2)+'\n');

Build RSS Candidate

A JavaScript module in the publication folder of PipelineNews covering bbc rss, using SHA-256.

storagepipelinenews / tools/publication/build-rss-candidate.mjs · lines 1–35 of 35 · Entry point · pattern digest (shared by 56 files)

What it does
Defines blob, digest. Uses libraries node:fs, node:child_process, node:crypto. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file bbc-rss.json; JSON file snapshot.json; command-line arguments.
Downstream impact
Used directly by 2 files: Build Reported Project Candidate (pipelinenews); PipelineNews Coverage Contract Workflow (pipelinenews).
What it achieves
Its name says it builds RSS candidate. Defines `blob` and `digest`.
Why it matters
Run by Build Reported Project Candidate and PipelineNews Coverage Contract Workflow.
Application
pipelinenews · tools/publication · JavaScript module
Uses
BBC RSS (script call), PipelineNews — News (script call), News — BBC (script call), Sources (script call), Articles (script call), Collector (script call), node:fs, node:child_process, node:crypto
Used by
run by Build Reported Project Candidate (script call), run by PipelineNews Coverage Contract Workflow (workflow run)
Produces
blob, digest
Defines here
blob, digest
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/publication/build-rss-candidate.mjs:1-35 · blob 5d2487298f0a508a08c114e416ee3193b7aa22f7 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import { mkdirSync, existsSync, writeFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { createHash } from 'node:crypto';
const generation = process.argv[2];
if (!/^\d{12}$/.test(generation ?? '')) throw Error('Supply unique UTC YYYYMMDDHHMM');
const out = `testcode/${generation}`;
if (existsSync(out)) throw Error('Immutable candidate already exists');
const sha = execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8'}).trim();
const blob = path => execFileSync('git',['show',`${sha}:${path}`],{maxBuffer:2*1024*1024});
const digest = bytes => createHash('sha256').update(bytes).digest('hex');
const sources = [
  'ui/templates/bbc-rss-intelligence.html',
  'discovery/bbc_rss.py',
  'news/__init__.py',
  'news/bbc/__init__.py',
  'news/bbc/sources.py',
  'news/bbc/articles.py',
  'news/bbc/collector.py',
  'discovery/products/bbc-rss.json',
].map(path => ({ path, sha256: digest(blob(path)) }));
const template = blob('ui/templates/bbc-rss-intelligence.html');
const snapshot = blob('discovery/products/bbc-rss.json');
const html = template.toString('utf8').replaceAll('{{GENERATION}}', generation);
const files = {'index.html':Buffer.from(html), 'snapshot.json':snapshot};
mkdirSync(out,{recursive:true});
for (const [name,bytes] of Object.entries(files)) writeFileSync(`${out}/${name}`,bytes);
writeFileSync(`${out}/manifest.json`,JSON.stringify({schema:'ventus.testcode-candidate.v1',generation,
  planId:'BBC-RSS-01',relatedPlan:'PIPELINE-35',scopeExtension:'User requested automated BBC RSS discovery, independent of energy-feed rollup prerequisites',
  owner:'Ventusltd/pipelinenews',sourceCommit:sha,status:'candidate',
  change:'Automatically discover BBC energy headlines with unmatched identity and explicit feed health',
  paper:'https://globalgrid2050.com/papers/202609060203-electrification/',
  schedule:'17 */2 * * *',
  sources,
  files:Object.entries(files).map(([path,b])=>({path,bytes:b.length,sha256:digest(b)}))},null,2)+'\n');
console.log(out);

Build 30x Ledger

A Python command-line tool in the publication folder of PipelineNews that builds the machine-readable receipt ledger for the audited candidate stream.

storagepipelinenews / tools/publication/build_30x_ledger.py · lines 1–125 of 125 · Entry point

What it does
Defines git, main. Uses libraries __future__, argparse, json, subprocess, pathlib. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: command-line arguments.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
Its name says it builds 30x ledger. Defines `git`. It accepts `--base`, `--head` and `--output`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
pipelinenews · tools/publication · Python CLI
Uses
Test Pages Release Classifier (script call), Pages Release Classifier (script call), Release Builder (script call), Test Verify Pages Workflow (script call), Run Pages Candidate Gate (script call), __future__, argparse, json, subprocess, pathlib
Used by
none found
Produces
git, main
Defines here
git, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/publication/build_30x_ledger.py:1-125 · blob d7fd0da4e55c9fcde062c5574457470e5c059c84 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Build the machine-readable receipt ledger for the audited candidate stream."""

from __future__ import annotations

import argparse
import json
import subprocess
from pathlib import Path


TESTS: dict[int, list[dict[str, object]]] = {
    1: [{"command": "python -m unittest tools/publication/test_pages_release_classifier.py", "result": "fail", "detail": "Windows import path was not initialized; iteration 02 repaired the harness."}],
    21: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}, {"command": "python tools/publication/pages_release_classifier.py --repo . --release 202609032251-pipelinenews", "result": "pass"}],
    22: [{"command": "python tools/intelligence/release_builder.py --check 202609032251-pipelinenews", "result": "pass"}],
    23: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}],
    24: [{"command": "git diff --check", "result": "pass"}],
    25: [{"command": "git diff --check", "result": "pass"}],
    26: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}, {"command": "python tools/publication/test_verify_pages_workflow.py", "result": "pass"}],
    27: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}],
    28: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}],
    29: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}, {"command": "python tools/publication/test_verify_pages_workflow.py", "result": "pass"}],
    30: [{"command": "python tools/publication/run_pages_candidate_gate.py --receipt <temp>", "result": "pass"}],
    31: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}, {"command": "python tools/publication/test_verify_pages_workflow.py", "result": "pass"}],
    32: [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}, {"command": "python tools/publication/test_verify_pages_workflow.py", "result": "pass"}],
    33: [{"command": "python tools/publication/run_pages_candidate_gate.py --receipt <temp>", "result": "pass"}],
}


def git(repo: Path, *args: str) -> str:
    return subprocess.check_output(["git", *args], cwd=repo, text=True).strip()


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--base", required=True)
    parser.add_argument("--head", required=True)
    parser.add_argument("--output", type=Path, required=True)
    args = parser.parse_args()
    repo = Path(__file__).resolve().parents[2]
    commits = git(repo, "rev-list", "--reverse", f"{args.base}..{args.head}").splitlines()
    if len(commits) != 33:
        raise SystemExit(f"expected 33 attempts, found {len(commits)}")
    entries = []
    expected_parent = args.base
    default_test = [{"command": "python tools/publication/test_pages_release_classifier.py", "result": "pass"}]
    for number, commit in enumerate(commits, 1):
        parent = git(repo, "show", "-s", "--format=%P", commit)
        subject = git(repo, "show", "-s", "--format=%s", commit)
        expected_prefix = f"iteration {number:02d}: "
        if parent != expected_parent or not subject.startswith(expected_prefix):
            raise SystemExit(f"broken sequence at iteration {number}: {commit}")
        paths_text = git(repo, "diff-tree", "--no-commit-id", "--name-only", "-r", commit)
        tests = TESTS.get(number, default_test)
        entries.append(
            {
                "iteration": number,
                "commit": commit,
                "parent": parent,
                "improvement": subject.removeprefix(expected_prefix),
                "changed_paths": paths_text.splitlines(),
                "tests": tests,
                "result": "superseded" if number == 1 else "pass",
                "qualifies": number != 1,
            }
        )
        expected_parent = commit
    payload = {
        "schema": "pipelinenews.30x-candidate-ledger.v2",
        "base_commit": args.base,
        "branch": "codex/202609040002-pages-classifier",
        "iteration_head": args.head,
        "attempt_count": 33,
        "iteration_count": 32,
        "iteration_count_semantics": "passing material improvements; the failed seed is recorded but not counted",
        "minimum_required_iterations": 30,
        "qualifying_iterations": list(range(2, 34)),
        "entries": entries,
        "evidence_corpus": [
            "claude/CLAUDE.md",
            "claude/sessions/202609032300-four-lanes-one-night/00-NOTE.md",
            "claude/sessions/202609032304-codex-cto-control/00-NOTE.md",
            "claude/sessions/202609032304-codex-cto-control/01-CLAUDE-REPLY.md",
            "claude/sessions/202609032304-codex-cto-control/02-CODEX-REPLY.md",
            "claude/sessions/202609032304-codex-cto-control/03-MILESTONE-PIPELINE-30-GRID-10.md",
            "pipelinenews/docs/coordination/BOARD.md",
            "codex-chatgpt/codex/2026-09-03-claude-24h-audit/EXECUTIVE_TIMELINE.md",
            "codex-chatgpt/codex/2026-09-03-claude-24h-audit/QA_REPORT.md",
            "codex-chatgpt/codex/2026-09-03-phase0/CLAUDE_10X_GRID_FINDING_BRIEF.md",
            "codex-chatgpt/codex/2026-09-03-gridatlas-v10-proposal/PRODUCT_AND_ARCHITECTURE.md",
            "codex-chatgpt/codex/2026-09-03-gridatlas-v10-proposal/RED_TEAM_FINDINGS.md",
            "git range b1e09fb9f2afaeeb989fa8f5e96528f8d68c1aaf..937b8c019074e40bebbc7edf5d8ef8d1751e034e",
            "branch codex/202609012206-pipelinenews-10x10 at 3724c9d and 721c4ae",
            "branch codex/202609020100-pipeline-pages-fix (documentation only; not counted)",
        ],
        "finding_drivers": {
            "pages_red_on_expected_additive_release": [1, 7, 21, 22, 23, 24, 25, 26],
            "identity_and_provenance_failure_classes": list(range(3, 21)),
            "pointer_and_blank_manual_dispatch_compatibility_review": [27, 28, 29],
            "independent_pass_count_and_toctou_review": [31, 32],
            "branch_only_compute_without_deploy_authority": [33],
        },
        "cumulative_validation": {
            "head": args.head,
            "result": "pass",
            "commands": [
                "python tools/publication/run_pages_candidate_gate.py --receipt <temp>",
                "python tools/publication/pages_release_classifier.py --repo . --base b1e09fb9f2afaeeb989fa8f5e96528f8d68c1aaf --head 9ffb4f3df8a1a7e62b7bec7942ec25d1ff09ccb9",
                "git diff --check origin/main...HEAD",
                "git rev-list --count origin/main..HEAD",
            ],
            "classifier_tests": 26,
            "workflow_checks": 15,
            "candidate_workflow_checks": 1,
            "release_builder_check": "pass",
            "historical_additive_push_route": "source-only",
        },
    }
    args.output.parent.mkdir(parents=True, exist_ok=True)
    args.output.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Build Pages Promotion Pointer

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

storagepipelinenews / tools/publication/build_pages_promotion_pointer.py · lines 1–115 of 115 · Entry point · pattern record (shared by 46 files)

What it does
It loads atlas link. Defines require, git, record, main. Uses libraries __future__, argparse, datetime, hashlib, json. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight.
Inputs & outputs
In: JSON file release-manifest.json; JSON file build-manifest.json; JSON file atlas-link-manifest.json; JSON file current-v3.json; JSON file current-v4.json; JSON file live-set.json; command-line arguments.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
It is built from the require step (`require`), the git step (`git`) and the record step (`record`). Write the two byte-identical v4 pointers for one committed promotion wrapper. It accepts `--repo`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
pipelinenews · tools/publication · Python CLI
Uses
__future__, argparse, datetime, hashlib, json, pathlib, re, subprocess
Used by
none found
Produces
require, git, record, main
Defines here
require, git, record, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 tools/publication/build_pages_promotion_pointer.py:1-115 · blob c19ae8ea61f019e6eb71dcb43c16fc6d535b3541 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Write the two byte-identical v4 pointers for one committed promotion wrapper."""

from __future__ import annotations

import argparse
from datetime import datetime, timezone
import hashlib
import json
from pathlib import Path
import re
import subprocess


RELEASE_RE = re.compile(r"^(\d{12})-pipelinenews$")


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


def git(repo: Path, *args: str) -> str:
    return subprocess.check_output(["git", *args], cwd=repo, text=True).strip()


def record(path: Path, local: str) -> dict[str, object]:
    payload = path.read_bytes()
    return {
        "path": local,
        "bytes": len(payload),
        "sha256": hashlib.sha256(payload).hexdigest(),
    }


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("release_id")
    parser.add_argument("--repo", type=Path, default=Path(__file__).resolve().parents[2])
    args = parser.parse_args()
    repo = args.repo.resolve()
    match = RELEASE_RE.fullmatch(args.release_id)
    require(match is not None, "release id must be timestamped")
    require(not git(repo, "status", "--porcelain"), "pointer must be cut from a clean wrapper commit")
    wrapper_commit = git(repo, "rev-parse", "HEAD")
    release = repo / "releases" / args.release_id
    release_manifest = json.loads((release / "release-manifest.json").read_text(encoding="utf-8"))
    build_manifest = json.loads((release / "build-manifest.json").read_text(encoding="utf-8"))
    atlas = json.loads((release / "atlas-link-manifest.json").read_text(encoding="utf-8"))
    promotion = release_manifest.get("promotion_wrapper") or {}
    require(promotion.get("schema") == "pipelinenews.pages-promotion-wrapper.v1",
            "release is not a promotion wrapper")
    owner = git(repo, "log", "--diff-filter=A", "-1", "--format=%H", "--",
                f"releases/{args.release_id}/release-manifest.json")
    require(owner == wrapper_commit, "HEAD does not own the immutable wrapper")
    require(build_manifest.get("promotion_wrapper") == promotion,
            "wrapper promotion bindings differ")
    require(atlas.get("receiver") == build_manifest.get("receiver"),
            "wrapper receiver bindings differ")
    pointer = {
        "schema": "pipelinenews.live-pointer.v4",
        "generation": match.group(1),
        "release_id": args.release_id,
        "classification": "VERIFIED_LIVE_TIMESTAMPED_RELEASE",
        "route": f"/pipelinenews/releases/{args.release_id}/",
        "entrypoint": f"releases/{args.release_id}/index.html",
        "release_manifest": record(
            release / "release-manifest.json",
            f"releases/{args.release_id}/release-manifest.json",
        ),
        "build_manifest": record(
            release / "build-manifest.json",
            f"releases/{args.release_id}/build-manifest.json",
        ),
        "atlas_link_manifest": record(
            release / "atlas-link-manifest.json",
            f"releases/{args.release_id}/atlas-link-manifest.json",
        ),
        "release_source_commit": promotion["source_commit"],
        "deployed_commit": wrapper_commit,
        "prepared_at_utc": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
        "promotion_source": {
            "release_id": promotion["source_release_id"],
            "commit": promotion["source_commit"],
            "manifest": promotion["source_release_manifest"],
        },
        "atlas_v9_receiver": atlas["receiver"],
        "verification": {
            "mode": "EXACT_HEAD_PREVIEW_DEPLOY_PUBLIC_READBACK",
            "source_rows": 8756,
            "clickable_rows": 8743,
            "synthetic_receiver": False,
            "route_interceptions": 0,
        },
        "rollback": {
            "pointer": "releases/current-v3.json",
            "rule": "older immutable pointer remains present and is never overwritten",
        },
    }
    payload = json.dumps(pointer, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
    current = repo / "releases" / "current-v4.json"
    state = repo / "state" / "live-set.json"
    current.write_text(payload, encoding="utf-8", newline="\n")
    state.write_text(payload, encoding="utf-8", newline="\n")
    print(json.dumps({
        "release_id": args.release_id,
        "deployed_commit": wrapper_commit,
        "bytes": len(payload.encode("utf-8")),
        "sha256": hashlib.sha256(payload.encode("utf-8")).hexdigest(),
    }, sort_keys=True))
    return 0


if __name__ == "__main__":
    raise SystemExit(main())