In this section
- Release Builder automation · testcode / backups/202611140229-pipelinenews-before-repd-2026q3/files/tools/intelligence/release_builder.py lines 701–919
- Renewable Energy Planning Database (REPD) Rows energy-data · testcode / drivers/repd-rows.mjs lines 1–250
- Sandbox — Pipeline Page render · testcode / sandbox/202609052028/pipeline/index.html lines 1–150
- Teleprinter Bootstrap render · testcode / sandbox/202609052028/pipeline/teleprinter-bootstrap.js lines 1–11
- Registry transform · testcode / sandbox/capsules/tool-layers/registry.mjs lines 1–42
Release Builder
A Python command-line tool in the intelligence folder of Testcode that reads cartridge and the Renewable Energy Planning Database (REPD) register, using SHA-256.
automationtestcode / backups/202611140229-pipelinenews-before-repd-2026q3/files/tools/intelligence/release_builder.py · lines 701–919 of 919 · version 2026-11-14 02:29 (continued from section 1068) · Entry point · pattern refresh_sha256_sidecars (shared by 2 files)
- What it does
- It loads cartridge and the REPD register. Defines 22 functions or classes, including utc_stamp, sha256_file, sha256_published, published_bytes, published_size. Uses libraries argparse, atexit, contextlib, datetime, hashlib. Side effects: reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register.
- Inputs & outputs
- In: JSON file 202608291447-registry.json; JSON file build-manifest.json; JSON file cartridge.json; JSON file release-manifest.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 normalises lf (`normalise_to_lf`), refreshes sha256 sidecars (`refresh_sha256_sidecars`) and refreshes build manifest (`refresh_build_manifest`). PipelineNews release builder — one timestamp, one discovery cartridge. It accepts `--list`, `--from` and `--cartridge`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- testcode · backups/202611140229-pipelinenews-before-repd-2026q3/files/tools/intelligence · Python CLI
- Uses
- argparse, atexit, contextlib, datetime, hashlib, io, json, os
- Used by
- none found
- Produces
- utc_stamp, sha256_file, sha256_published, published_bytes, published_size, read, write, walk, normalise_to_lf, refresh_sha256_sidecars, refresh_build_manifest, apply_once
- Defines here
- cmd_check, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 backups/202611140229-pipelinenews-before-repd-2026q3/files/tools/intelligence/release_builder.py:701-919 · blob 2743fa486e4f3223fa203e713f42143bcc33618b · 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: unknown
if forbidden:
raise SystemExit("registry repair fields forbidden for %s: %s"
% (other_key, forbidden))
for field, value in updates.items():
other[field] = value
print(" %s UI state -> %s" % (other_key, other.get("ui_state", "unchanged")))
# Every INHERITED cartridge entry still carries the parent's digest, and
# the parent's digest was taken from a Windows working copy holding CRLF.
# normalise_to_lf has since rewritten those files to the LF bytes that
# actually ship, so the inherited digests now describe bytes no one will
# ever receive. Measured on 202608311610: the registry claims
# grid-proximity.mjs is 34,239 bytes (3265e118...), the file on the server
# is 33,541 (8703fce7...). The build manifest is already re-derived after
# normalisation for exactly this reason; the registry never was.
print(" re-deriving inherited digests after LF normalisation")
for other_key, other in sorted((reg.get("supplemental_assets") or {}).items()):
for kind in ("cartridge", "payload"):
node = other.get(kind)
if not isinstance(node, dict) or "path" not in node:
continue
abs_path = os.path.join(target, node["path"])
if not os.path.exists(abs_path):
continue
digest, size = sha256_published(abs_path), published_size(abs_path)
if node.get("sha256") != digest or node.get("bytes") != size:
print(" %s.%s %s -> %s" % (other_key, kind,
str(node.get("sha256"))[:12], digest[:12]))
node["sha256"], node["bytes"] = digest, size
# record_count is the same kind of claim as sha256 and bytes: a statement
# about the file at `path`. It was not re-derived, so a cartridge that ships
# a longer payload under an inherited filename left the registry announcing
# the old count for the new file - the registry describing a file no one will
# ever receive, which is the exact defect the block above exists to fix.
# Derived, never repaired: `record_count` is deliberately absent from
# allowed_registry_repairs, because a count a cartridge can assert is a count
# that can disagree with the payload.
if kind == "payload" and "record_count" in node:
# An unparseable payload is a worse problem than a stale count, and
# swallowing it would leave the registry asserting the inherited number
# over a file nobody can read - neither a failure nor a correction.
try:
doc = json.loads(read(abs_path))
except ValueError as exc:
raise SystemExit("payload will not parse, so its record_count cannot "
"be derived: %s (%s)" % (node["path"], exc))
counted = None
if isinstance(doc, dict):
# Exactly one list-of-records, named or not. Taking the FIRST such
# list in dict order would count whichever key the JSON happens to
# put first, so a payload carrying both `rows` and `sources` would
# produce a confidently wrong number rather than no number. Ambiguity
# must fail loudly, not resolve itself by insertion order.
candidates = [k for k, v in doc.items()
if isinstance(v, list) and v and isinstance(v[0], dict)]
if len(candidates) > 1:
raise SystemExit(
"cannot derive record_count for %s: %d candidate row lists "
"(%s). Name the field rather than trusting key order."
% (node["path"], len(candidates), ", ".join(sorted(candidates))))
counted = (len(doc[candidates[0]]) if candidates
else doc.get("record_count"))
elif isinstance(doc, list):
counted = len(doc)
if isinstance(counted, int) and node.get("record_count") != counted:
print(" %s.%s record_count %s -> %s"
% (other_key, kind, node.get("record_count"), counted))
node["record_count"] = counted
write(reg_path, json.dumps(reg, indent=2, ensure_ascii=False) + "\n")
print(" supplemental_assets.%s" % key)
# ---- 5. manifests ----------------------------------------------------
print("\n manifests")
rel = json.loads(read(os.path.join(target, "release-manifest.json")))
rel.update({
"schema": "pipelinenews.additive-cartridge-release.v1",
"generation": gen,
"release_id": release_id,
"parent_release_id": parent_id,
"classification": ("DASHBOARD_MODIFYING_CARTRIDGE"
if man.get("modifies_existing_dashboard")
else "ADDITIVE_DISCOVERY_CARTRIDGE"),
"cartridge_added": key,
"cartridges_present": sorted(reg["supplemental_assets"].keys()),
# Hard-coding False was true while every cartridge was a self-contained
# panel. A cartridge that patches the table renderer is not additive,
# and a manifest that says it is would be the one place a reader goes
# to find out. The cartridge declares it; the manifest records it.
"existing_dashboard_modified": bool(man.get("modifies_existing_dashboard")),
"existing_dashboard_modification": man.get("modification_note") or None,
"generation_source": "read from UTC clock at build time, never chosen",
"rollback": "build again with --from an earlier release; nothing is edited in place",
"immutable_after_publication": True,
"deployment": "not-authorised",
"runtime_verified": False,
})
if atlas_target:
rel["atlas_target"] = atlas_target
write(os.path.join(target, "release-manifest.json"),
json.dumps(rel, indent=2, sort_keys=True, ensure_ascii=False) + "\n")
print(" release-manifest.json")
refresh_sha256_sidecars(target)
refresh_build_manifest(target, release_id)
files = [f for f in walk(target) if f != "sha256sums.txt"]
write(os.path.join(target, "sha256sums.txt"),
"".join("%s %s\n" % (sha256_published(os.path.join(target, f)), f) for f in files))
print(" sha256sums.txt (%d files)" % len(files))
# ---- 6. the parent must be untouched ---------------------------------
after = {p: sha256_file(os.path.join(parent, p)) for p in walk(parent)}
if after != before:
raise SystemExit("FAIL: the parent release changed. That must never happen.")
print("\n %s unchanged (%d files, byte-for-byte)" % (parent_id, len(after)))
# ---- 7. the release must pass its own check ---------------------------
# `--check` existed from the beginning and nothing ran it. Six releases
# shipped with a digest that does not describe their own bytes, and each of
# them would have been caught here, at the one moment when the answer is
# still "build it again" rather than "it is immutable now".
#
# A failure leaves build_ok False, so the atexit handler above discards the
# partial release. That is deliberate: a release that cannot verify itself
# must not exist, because --list will offer it as a parent and every later
# build will inherit whatever was wrong with it.
print("\n ---- proving the release against itself ----\n")
if cmd_check(release_id) != 0:
raise SystemExit("FAIL: %s does not pass its own --check. Nothing shipped."
% release_id)
build_ok["done"] = True
print("\nBuilt %s" % release_id)
print(" unhappy with it? python release_builder.py --from %s --cartridge <other>"
% parent_id)
return 0
# --------------------------------------------------------------------- check
def cmd_check(release_id):
target = os.path.join(RELEASES, release_id)
if not os.path.isdir(target):
raise SystemExit("no such release: %s" % target)
print("Checking %s\n" % release_id)
ok = True
listed = {}
for line in io.open(os.path.join(target, "sha256sums.txt"), encoding="utf-8"):
digest, name = line.rstrip("\n").split(" ", 1)
listed[name] = digest
actual = {f for f in walk(target) if f != "sha256sums.txt"}
bad = [n for n, d in listed.items()
if n in actual and sha256_published(os.path.join(target, n)) != d]
for label, items in (("unlisted files", sorted(actual - set(listed))),
("listed but absent", sorted(set(listed) - actual)),
("digest mismatch", bad)):
print(" [%s] %-20s %s" % ("PASS" if not items else "FAIL", label,
"none" if not items else items[:4]))
ok &= not items
reg = json.loads(read(os.path.join(target, REGISTRY)))
idx = read(os.path.join(target, "index.html"))
app = read(os.path.join(target, APP))
for key, entry in sorted((reg.get("supplemental_assets") or {}).items()):
for kind in ("cartridge", "payload"):
node = entry.get(kind)
if not node or "path" not in node:
continue
p = os.path.join(target, node["path"])
good = os.path.exists(p) and sha256_published(p) == node.get("sha256")
print(" [%s] %s.%s digest" % ("PASS" if good else "FAIL", key, kind))
ok &= good
withdrawn = entry.get("ui_state") == "WITHDRAWN"
host = entry.get("host_id")
if host:
present = ('id="%s"' % host) in idx
good = (not present) if withdrawn else present
expectation = "absent after withdrawal" if withdrawn else "present in UI"
print(" [%s] %s host %s" % ("PASS" if good else "FAIL", key, expectation))
ok &= good
bind = entry.get("bind_call")
if bind:
wired = bind in app
good = (not wired) if withdrawn else wired
expectation = "absent after withdrawal" if withdrawn else "wired in boot()"
print(" [%s] %s loader %s" % ("PASS" if good else "FAIL", key, expectation))
ok &= good
print()
return 0 if ok else 1
def main():
ap = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--list", action="store_true", help="show rollback points and cartridges")
ap.add_argument("--from", dest="parent", help="parent release id to build from")
ap.add_argument("--cartridge", help="cartridge package name under cartridges/")
ap.add_argument("--gen", help="12-digit generation (default: current UTC minute)")
ap.add_argument("--atlas-target", choices=["legacy", "ported"],
help="record which atlas this release points at")
ap.add_argument("--check", help="verify an existing release")
ap.add_argument("--applicable", metavar="PARENT",
help="report which cartridges can actually be built onto PARENT")
a = ap.parse_args()
if a.list:
return cmd_list()
if a.check:
return cmd_check(a.check)
if a.applicable:
return cmd_applicable(a.applicable)
if a.parent and a.cartridge:
return cmd_build(a.parent, a.cartridge, a.gen or utc_stamp(), a.atlas_target)
ap.print_help()
return 1
if __name__ == "__main__":
sys.exit(main())Renewable Energy Planning Database (REPD) Rows
A JavaScript module in the drivers folder of Testcode that reads REPD rows and the REPD register.
energy-datatestcode / drivers/repd-rows.mjs · lines 1–250 of 250 · Not reached from any entry point (candidate for review)
- What it does
- It loads REPD rows and the REPD register. Defines check, note, rank, partsDirOf, declaredCounts. 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 (path word 'repd'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register. README: "Every run saves all six immutable checkout SHAs in `estate-inputs.json` alongside `testcode-run.json`, `link-targets.json` and `repd-rows.json`."
- Inputs & outputs
- In: command-line arguments. Out: JSON file repd-rows.json.
- What it achieves
- It is built from the check step (`check`), the note step (`note`) and the rank step (`rank`). Every REPD row on every surface the estate publishes, and the link it should have.
- Why it matters
- No other file in the estate was found to import it.
- Application
- testcode · drivers · JavaScript module
- Uses
- Published Surfaces (import), node:fs, node:path, node:url
- Used by
- none found
- Produces
- check, note, rank, partsDirOf, declaredCounts
- Defines here
- check, note, rank, partsDirOf, declaredCounts
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 drivers/repd-rows.mjs:1-250 · blob 3878ba88f5282c6c0018e5cfba2412a2ab8c7dcc · 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: unreached_review
/* repd-rows.mjs — every REPD row on every surface the estate publishes, and
* the link it should have.
*
* "once test code tells you all 7000 + REPD rows pass" — the architect,
* 2026-09-05.
*
* This is that gate. It runs the engine's own auditProjectRows over the WHOLE
* published corpus of EVERY published surface — sixteen parts each, read from
* the local clone — and checks each result against what that surface's own
* release contract says it should be. Offline; no socket is opened.
*
* The query is not reimplemented here. It is imported from
* ventus-grid-engine/deeplink/contract.js, the same function the receiver audit
* and the workflow use, because an audit whose logic differs from the fix it
* authorises is not a gate.
*
* WHAT IT USED TO AUDIT, AND WHY THAT WAS NOT AN ANSWER
* ---------------------------------------------------------------------------
* Until 2026-09-05 it chose ONE corpus with
*
* readdirSync(pipelineDir).filter((n) => /^v9(\.\d+)*$/.test(n)).sort(rank).slice(-1)
*
* and printed `version v9.7`. The build cut that morning lives in
* uk_renewables_pipeline/202609051156/ — it is the first pipeline link on the
* homepage — and a timestamped directory matches no version pattern, so it was
* invisible to this gate. So were v9, v9.4, v9.5, v9.5.1, v9.6, v9.6.1 and
* v9.6.2, all of which the homepage publishes. The 10/10 was a true statement
* about the control and said nothing whatever about any candidate, which is
* the most expensive kind of green there is.
*
* So the surfaces come from lib/published-surfaces.mjs: what the homepage
* actually links, rather than what a directory name looks like. A surface the
* homepage publishes is audited. A surface that carries no corpus is named and
* counted, never quietly skipped.
*
* What it is really checking is the thing that hid for weeks: a row can have an
* identity, a coordinate and a MAP button, and still produce a link that lands
* on a page carrying no engine. Counting rows is not enough — every link has to
* be built against the canonical receiver, and the count of rows that cannot be
* linked has to match what the corpus itself declares, so a silent loss shows
* up as a number rather than as nothing.
*
* Run: node drivers/repd-rows.mjs
* node drivers/repd-rows.mjs --estate DIR read a different estate root,
* so this gate can be shown going red on a controlled corpus.
*/
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
import path from 'node:path';
import { pathToFileURL, fileURLToPath } from 'node:url';
import { homepageSurfaces } from '../lib/published-surfaces.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const estateFlag = process.argv.indexOf('--estate');
const PARENT = estateFlag >= 0 && process.argv[estateFlag + 1]
? path.resolve(process.cwd(), process.argv[estateFlag + 1])
: path.resolve(ROOT, '..');
const contractModule = path.join(PARENT, 'ventus-grid-engine', 'deeplink', 'contract.js');
if (!existsSync(contractModule)) {
console.error(`ventus-grid-engine/deeplink/contract.js is not present under ${PARENT}.`);
console.error('This driver audits with the engine\'s own query rather than a copy of it,');
console.error('so without the engine it has checked nothing. That is a failure, not a pass.');
process.exit(1);
}
const { auditProjectRows, CANONICAL_RECEIVER, isRetiredReceiver } =
await import(pathToFileURL(contractModule).href);
const checks = [];
const check = (name, ok, detail = '') => checks.push({ name, ok: Boolean(ok), detail });
/* A line that is always true is a measurement, not a check. Counted separately
so "N/N checks passed" only ever counts lines that could have gone red. */
const notes = [];
const note = (name, detail) => notes.push({ name, detail });
/* ---- Which surfaces to audit, read from the page that publishes them ----- */
const pipelineDir = path.join(PARENT, 'globalgrid2050', 'uk_renewables_pipeline');
if (!existsSync(pipelineDir)) {
console.error('No local globalgrid2050 clone: nothing to audit.');
console.error('That is a failure, not a pass — a check that finds nothing to');
console.error('check has not checked anything.');
process.exit(1);
}
const published = homepageSurfaces(PARENT);
check('the surfaces to audit were read from the homepage the estate serves, not from a directory-name pattern',
published.ok && published.pipelineDirs.length > 0,
`${published.source}: ${published.pipelineDirs.join(', ') || 'no pipeline surfaces linked'}`);
const rank = (n) => n.replace(/^v/, '').split('.').map(Number)
.reduce((a, p, i) => a + (p || 0) * [1e6, 1e3, 1][i], 0);
function partsDirOf(dir) {
const data = path.join(dir, 'data');
if (!existsSync(data)) return null;
for (const gen of readdirSync(data).sort().reverse()) {
const candidate = path.join(data, gen, 'projects');
if (existsSync(candidate) && readdirSync(candidate).some((n) => /^part-\d+\.json$/.test(n))) {
return candidate;
}
}
return null;
}
const surfaces = published.pipelineDirs.map((name) => {
const dir = path.join(pipelineDir, name);
const partsDir = existsSync(dir) ? partsDirOf(dir) : null;
return {
name,
dir,
present: existsSync(dir),
partsDir,
parts: partsDir ? readdirSync(partsDir).filter((n) => /^part-\d+\.json$/.test(n)).sort() : []
};
});
const missing = surfaces.filter((s) => !s.present);
check('every surface the homepage publishes is present in the local clone',
missing.length === 0,
missing.length ? `absent: ${missing.map((s) => s.name).join(', ')}` : `${surfaces.length} surface(s) present`);
const withCorpus = surfaces.filter((s) => s.present && s.parts.length > 0);
const withoutCorpus = surfaces.filter((s) => s.present && s.parts.length === 0);
check('at least one published surface carries a corpus, so this driver is auditing something',
withCorpus.length > 0,
`${withCorpus.length} of ${surfaces.length} published surface(s) carry a parts corpus`);
note('a published surface that carries no corpus is named rather than silently skipped',
withoutCorpus.length ? `no corpus: ${withoutCorpus.map((s) => s.name).join(', ')}` : 'every published surface carries a corpus');
/* ---- What a surface itself says its corpus contains ----------------------
A release contract does not always restate the corpus counts: v9.7 declares
`data_parent: { release: 9.1, data_changed: false }` and inherits them. So
walk the release contracts newest-first and take the first that actually
DECLARES a geometry count, then say which one it was. Taking the
alphabetically last file gave `undefined` and two failures that looked like
a data fault and were a lookup fault — the difference matters, because one
of those would have sent someone hunting through 7,680 rows. */
function declaredCounts(surfaceDir) {
const contractsDir = path.join(surfaceDir, 'contracts');
if (!existsSync(contractsDir)) return { declared: {}, declaredBy: null };
const releaseFiles = readdirSync(contractsDir)
.filter((n) => /^release\.v[\d.]+\.json$/.test(n))
.sort((a, b) => rank(a.replace(/^release\.|\.json$/g, '')) - rank(b.replace(/^release\.|\.json$/g, '')))
.reverse();
let declared = {};
let declaredBy = null;
for (const name of releaseFiles) {
const expected = (JSON.parse(readFileSync(path.join(contractsDir, name), 'utf8')).expected) || {};
if (expected.valid_geometry_count !== undefined) return { declared: expected, declaredBy: name };
if (!declaredBy && expected.project_count !== undefined) { declared = expected; declaredBy = name; }
}
return { declared, declaredBy };
}
/* ---- The audit, once per published surface -------------------------------- */
const audits = [];
for (const surface of withCorpus) {
const rows = [];
for (const name of surface.parts) {
const parsed = JSON.parse(readFileSync(path.join(surface.partsDir, name), 'utf8'));
const part = Array.isArray(parsed) ? parsed : (parsed.projects || parsed.rows || []);
rows.push(...part);
}
const { declared, declaredBy } = declaredCounts(surface.dir);
const audit = auditProjectRows(rows);
const built = audit.entries.filter((e) => e.expected_href);
const noGeometry = audit.entries.filter((e) => e.has_identity && !e.has_geometry);
const at = surface.name;
check(`${at}: the corpus was found and read from its parts`,
rows.length > 0, `${surface.parts.length} parts, ${rows.length} rows`);
check(`${at}: a release contract declaring the corpus counts was found`,
Boolean(declaredBy) && declared.valid_geometry_count !== undefined,
declaredBy || 'no release contract declares a geometry count');
check(`${at}: the corpus is the size its own release contract declares`,
rows.length === declared.project_count,
`read ${rows.length}, declared ${declared.project_count}`);
check(`${at}: every row carries an REPD identity`,
audit.with_identity === rows.length, `${audit.with_identity} of ${rows.length}`);
check(`${at}: the rows that cannot be linked are exactly the ones the contract declares`,
audit.no_geometry === declared.missing_geometry_count,
`no geometry ${audit.no_geometry}, declared missing ${declared.missing_geometry_count}`);
check(`${at}: every linkable row matches the declared valid-geometry count`,
audit.linkable === declared.valid_geometry_count,
`linkable ${audit.linkable}, declared ${declared.valid_geometry_count}`);
/* The point of the whole exercise: not that a link exists, but that it
lands somewhere that can compute. */
check(`${at}: every link is built against the canonical receiver`,
built.length > 0 && built.every((e) => e.expected_href.startsWith(CANONICAL_RECEIVER)),
`${built.length} links, all on ${CANONICAL_RECEIVER}`);
check(`${at}: no link is built against a retired receiver`,
built.length > 0 && built.every((e) => !isRetiredReceiver(e.expected_href)),
'zero links to a page that carries no engine');
check(`${at}: every link carries the REPD identity the arrival resolves on`,
built.length > 0 && built.every((e) => /[?&]repd_ref=/.test(e.expected_href)),
'repd_ref present on every link');
/* A row with an identity but no geometry must be REPORTED, never given a
link that silently goes to the map's default view — that is a MAP button
that looks alive and answers a question about the wrong place. */
check(`${at}: a row without geometry is given no link at all, rather than a wrong one`,
noGeometry.every((e) => e.expected_href === null),
`${noGeometry.length} rows correctly left without a link`);
audits.push({
surface: surface.name,
parts_dir: path.relative(PARENT, surface.partsDir).replace(/\\/g, '/'),
parts: surface.parts.length,
rows: rows.length,
declared_by: declaredBy,
declared,
with_identity: audit.with_identity,
linkable: audit.linkable,
no_geometry: audit.no_geometry,
links_built: built.length,
unlinkable_repd_refs: noGeometry.map((e) => e.repd_ref).slice(0, 40)
});
}
const report = {
schema: 'globalgrid2050.testcode.repd-rows.v2',
generated_utc: new Date().toISOString(),
estate_root: PARENT.replace(/\\/g, '/'),
surfaces_source: published.source,
published_surfaces: published.pipelineDirs,
surfaces_without_a_corpus: withoutCorpus.map((s) => s.name),
canonical_receiver: CANONICAL_RECEIVER,
total_rows_audited: audits.reduce((a, s) => a + s.rows, 0),
total_links_built: audits.reduce((a, s) => a + s.links_built, 0),
audits
};
writeFileSync(path.join(process.cwd(), 'repd-rows.json'), JSON.stringify(report, null, 2) + '\n');
console.log(`surfaces published ${published.pipelineDirs.join(', ') || 'none'} (from ${published.source})`);
console.log(`surfaces audited ${withCorpus.map((s) => s.name).join(', ') || 'none'}`);
console.log(`surfaces with no corpus ${withoutCorpus.map((s) => s.name).join(', ') || 'none'}`);
console.log(`canonical receiver ${CANONICAL_RECEIVER}\n`);
console.log('surface parts rows identity linkable no-geom links');
for (const a of audits) {
console.log(`${a.surface.padEnd(16)}${String(a.parts).padStart(5)}${String(a.rows).padStart(7)}${String(a.with_identity).padStart(10)}${String(a.linkable).padStart(10)}${String(a.no_geometry).padStart(9)}${String(a.links_built).padStart(7)}`);
}
console.log(`\n${report.total_rows_audited} rows audited across ${audits.length} published surface(s)\n`);
let failed = 0;
for (const c of checks) {
if (!c.ok) failed += 1;
console.log(`${c.ok ? 'ok ' : 'FAIL'} ${c.name}${c.detail ? ' -- ' + c.detail : ''}`);
}
console.log('');
for (const n of notes) console.log(`note ${n.name} -- ${n.detail}`);
console.log(`(a note is a measurement with no pass or fail, and is not counted below.)`);
console.log(`\n${checks.length - failed}/${checks.length} checks passed`);
if (failed) { console.error(`${failed} FAILED`); process.exit(1); }Sandbox — Pipeline Page
A web page in Testcode that reads inputs for news, county and sort projects (units: MW), covering the Renewable Energy Planning Database (REPD) register, solar and battery storage (BESS).
rendertestcode / sandbox/202609052028/pipeline/index.html · lines 1–150 of 150 · version 2026-09-05 20:28 · Entry point
- What it does
- It draws the REPD register, solar and battery storage (BESS). Uses libraries styles/v7.css?v=9.7. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: the REPD register, solar, battery storage (BESS). README: "The publication checkout is sparse: `index.html` and the complete `uk_renewables_pipeline/` tree."
- Inputs & outputs
- In: form fields (user input). Out: web page.
- Downstream impact
- It is itself an entry point (page); no other file was found loading it.
- What it achieves
- The deep-link contract this page verifies its MAP receiver against lives on a second origin. Its code works with 1 MW.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- testcode · sandbox/202609052028/pipeline · page
- Uses
- Mobile (stylesheet), V9 3 (stylesheet), V9 4 (stylesheet), V9 5 1 (stylesheet), V9 6 1 (stylesheet), Testcode (stylesheet), App V9 7 (script src), Capacity Presentation V9 3 (script src), and 1 more, styles/v7.css?v=9.7, https://cdn.jsdelivr.net/npm/chart.js
- 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
- testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/202609052028/pipeline/index.html:1-150 · blob 756f1f71fb35c5d2d519d5f4cc8ad221abd54835 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: unknown
<!DOCTYPE html>
<html lang="en">
<head><link rel="icon" href="data:,">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Test Code 202609052028 · GlobalGrid2050 | UK Renewables Pipeline V9.7</title>
<!-- The deep-link contract this page verifies its MAP receiver against lives
on a second origin. Nothing waits on that request any more, but it still
costs DNS + TCP + TLS on a cold mobile radio the first time it is made;
starting the handshake here overlaps it with the project payload instead
of paying for it in series. -->
<link rel="preconnect" href="https://ventusltd.github.io" crossorigin>
<link rel="stylesheet" href="styles/v7.css?v=9.7">
<link rel="stylesheet" href="styles/mobile.css?v=9.7">
<link rel="stylesheet" href="styles/v9-3.css?v=9.7">
<link rel="stylesheet" href="styles/v9-4.css?v=9.7">
<link rel="stylesheet" href="styles/v9-5-1.css?v=9.7">
<link rel="stylesheet" href="styles/v9-6-1.css?v=9.7">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="styles/testcode.css">
</head>
<body>
<aside class="sidebar">
<div class="brand">
<b>GLOBALGRID2050</b>
<small>UK RENEWABLES PIPELINE · V9.7</small>
</div>
<nav aria-label="Version comparison" class="testcode-nav"><a href="../">Test Code 202609052028</a><a href="/uk_renewables_pipeline/v9.7/">Claude current Pipeline</a><a href="../atlas/" id="mapAtlasNav">Test Code Atlas</a><button type="button" id="export">Export CSV</button></nav>
</aside>
<main class="main">
<div class="header">
<h1>UK RENEWABLES PIPELINE V9.7</h1>
<div class="status">● 133 HEADLINES · 45 UK · 19 INTERNATIONAL · FULL ≥1 MW</div>
</div>
<div class="meta">
<strong>V9.7 · AUDITABLE REGIONAL NEWS · CANDIDATE · 24 August 2026</strong>
<span>Canonical DESNZ REPD Q2 2026: 7,680 solar, BESS and wind records at ≥1 MW.</span>
<span id="releaseMeta" class="release-meta">Loading canonical release contract…</span>
<a href="https://www.gov.uk/government/publications/renewable-energy-planning-database-quarterly-extract" target="_blank" rel="noopener">Official REPD source</a>
</div>
<section class="newspaper">
<div class="masthead">
<h2>GLOBALGRID2050 <span>ENERGY DAILY</span></h2>
<div class="strap">
<span>UK requires canonical REPD binding · INTERNATIONAL is read from a committed build-time decision ledger · regional items never drive REPD project signals</span>
<span id="newsMeta">loading daily edition…</span>
</div>
</div>
<div class="news-tools" id="newsTools">
<button class="active" data-news="ALL">ALL</button>
<button data-news="UK">UK</button>
<button data-news="INTERNATIONAL">INTERNATIONAL</button>
<button data-news="US">US</button>
<button data-news="EUROPE">EUROPE</button>
<button data-news="SOLAR">SOLAR</button>
<button data-news="BESS">BESS</button>
<button data-news="CONSENT">CONSENT</button>
<button data-news="CONSTRUCTION">CONSTRUCTION</button>
<button data-news="OPERATIONAL">OPERATIONAL</button>
<button data-news="FINANCE">FINANCE / M&A</button>
<input id="newsSearch" placeholder="SEARCH HEADLINES / PROJECT / OPERATOR">
</div>
<div class="paper">
<div class="stories" id="stories">
<div class="news-empty">Loading today’s major-project newspaper…</div>
</div>
</div>
</section>
<h2 class="section-title">REPD PIPELINE ANALYTICS</h2>
<div class="gauges">
<div class="card">
<h3>FILTERED CAPACITY (MW)</h3>
<div class="chart"><canvas id="g1"></canvas><div class="value" id="v1">0</div></div>
</div>
<div class="card">
<h3>FILTERED PROJECTS (≥1MW)</h3>
<div class="chart"><canvas id="g2"></canvas><div class="value" id="v2">0</div></div>
</div>
<div class="card">
<h3>LARGEST SINGLE SITE (MW)</h3>
<div class="chart"><canvas id="g3"></canvas><div class="value" id="v3">0</div></div>
</div>
</div>
<div class="filters" id="tech">
<button class="btn active" data-technology="all" aria-pressed="true">ALL TECH</button>
<button class="btn" data-technology="solar" aria-pressed="false">SOLAR</button>
<button class="btn" data-technology="bess" aria-pressed="false">BATTERY</button>
<button class="btn" data-technology="wind_onshore" aria-pressed="false">ONSHORE</button>
<button class="btn" data-technology="wind_offshore" aria-pressed="false">OFFSHORE</button>
</div>
<div class="filters" id="status">
<button class="btn active" data-official-status="All" aria-pressed="true">ALL STATUS</button>
<button class="btn" data-official-status="Operational" aria-pressed="false">OPERATIONAL</button>
<button class="btn" data-official-status="Under Construction" aria-pressed="false">CONSTRUCTING</button>
<button class="btn" data-official-status="Awaiting Construction" aria-pressed="false">AWAITING</button>
<button class="btn" data-official-status="Application Submitted" aria-pressed="false">SUBMITTED</button>
</div>
<div class="filters">
<select id="county"><option value="All">🌍 ALL COUNTIES</option></select>
<select id="sortProjects" aria-label="Sort projects">
<option value="capacity_desc">SORT: CAPACITY (DEFAULT)</option>
<option value="updated_desc">SORT: REPD UPDATED — NEWEST</option>
<option value="updated_asc">SORT: REPD UPDATED — OLDEST</option>
</select>
<input id="search" class="asset-search" placeholder="🔍 SEARCH PROJECT / REPD / GLOBALGRID / PLANNING..." autocomplete="off">
<button class="btn clear-filters" id="clearFilters">CLEAR FILTERS</button>
<button class="btn export-inline" id="exportInline">EXPORT FILTERED CSV</button>
<span id="resultsMeta" class="results-meta">Loading all qualifying records…</span>
<span id="exportMeta" class="export-meta">CSV contains the current filtered rows only</span>
</div>
<div class="meta">
<strong>STATUS DISCIPLINE</strong>
<span><b>DEFAULT:</b> every qualifying ≥1 MW record is loaded. Filters are user controls; they never redefine or truncate the pipeline.</span>
<span><b>NEWS:</b> relevance scores are algorithmic screening only and never change an official REPD fact.</span>
<span><b>ATLAS:</b> valid geometry resolves the exact REPD Ref. Records without REPD geometry remain in search and CSV. Morgan MAP uses an attributed approximate Crown Estate lease-area centre; other unresolved locations open DETAILS.</span>
</div>
<nav id="projectPagination" aria-label="Project pages"></nav>
<div class="tablewrap">
<table>
<thead>
<tr>
<th>SITE NAME</th>
<th class="hide-mobile">COUNTY</th>
<th class="hide-mobile">OPERATOR</th>
<th>TECHNOLOGY</th>
<th>OFFICIAL REPD STATUS</th>
<th>OFFICIAL CAPACITY</th>
<th class="hide-mobile">REPD REF</th>
<th class="hide-mobile">GLOBALGRID REF</th>
<th class="hide-mobile repd-updated-heading" id="repdUpdatedHeader" aria-sort="none">
<button id="sortUpdated" type="button" aria-label="Sort by REPD updated date, newest first">
REPD UPDATED <span id="updatedSortIndicator" aria-hidden="true">↕</span>
</button>
</th>
<th>NEWS SIGNAL</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody id="tbody"><tr><td colspan="11" role="status">Loading project records…</td></tr></tbody>
</table>
</div>
</main>
<script type="module" src="scripts/app-v9-7.js?v=9.7"></script>
<script type="module" src="scripts/plugins/capacity-presentation-v9-3.js?v=9.7"></script>
<script type="module" src="./teleprinter-bootstrap.js"></script>
</body>
</html>Teleprinter Bootstrap
A JavaScript module in the pipeline folder of Testcode that draws pipeline pin and pipeline code.
rendertestcode / sandbox/202609052028/pipeline/teleprinter-bootstrap.js · lines 1–11 of 11 · version 2026-09-05 20:28 · Entry point
- What it does
- It draws pipeline pin and pipeline code. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Inputs & outputs
- In: JSON file pipeline-source-pin.json; JSON file pipeline-source-code.manifest.json.
- Downstream impact
- Used directly by 1 file: Sandbox — Pipeline Page (testcode).
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Loaded by the Pipeline page.
- Application
- testcode · sandbox/202609052028/pipeline · JavaScript module
- Uses
- Controls (import)
- Used by
- loaded by Sandbox — Pipeline Page (script src)
- 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
- testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/202609052028/pipeline/teleprinter-bootstrap.js:1-11 · blob 9b3c9058cf964f86ae551c336de8abb1f992c630 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unknown
import { mountTeleprinter } from '../teleprinter/controls.js';
const base = new URL('../teleprinter/', import.meta.url);
try {
const response = await fetch(new URL('pipeline-source-pin.json', base), { cache: 'no-store', credentials: 'same-origin', redirect: 'error' });
if (!response.ok) throw new Error('Source code is still being prepared.');
const pin = await response.json();
if (pin.generation !== '202609052028' || pin.app !== 'pipeline' || !/^[a-f0-9]{40}$/.test(pin.commit) || pin.repository !== 'https://github.com/Ventusltd/testcode') throw new Error('The source code version could not be checked.');
mountTeleprinter({ printButtons: undefined, appName: "Pipeline News", manifestUrl: new URL('pipeline-source-code.manifest.json', base), textUrl: new URL('pipeline-source-code.txt', base), expectedCommit: pin.commit, expectedRepository: pin.repository });
} catch (error) {
const note = document.createElement('p'); note.setAttribute('role', 'status'); note.textContent = 'Print options: ' + error.message; document.body.append(note);
}Registry
A JavaScript module in the tool layers folder of Testcode that resolves actual composed destinations; historical navigation declarations remain separate.
transformtestcode / sandbox/capsules/tool-layers/registry.mjs · lines 1–42 of 42 · pattern entryFor (shared by 4 files)
- What it does
- It calculates its inputs. Defines buildNavigationRegistry, pin, identity, entryFor.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. README: "`registry.mjs` resolves explicit current tool pins before retained historical bundles and also identifies unlaunched DC/AC review."
- Downstream impact
- Used directly by 2 files: Registry Test (testcode); Build (testcode). Reached from 3 other entry points, including Codex Cartridges Workflow (testcode); Controls Layout Workflow (testcode); Offshore Route Workflow (testcode).
- What it achieves
- It builds navigation registry (`buildNavigationRegistry`) and is built from the pin step (`pin`) and the identity step (`identity`). The README says: `registry.mjs` resolves explicit current tool pins before retained historical bundles and also identifies unlaunched DC/AC review.
- Why it matters
- Run by Build. Checked by Registry Test.
- Application
- testcode · sandbox/capsules/tool-layers · JavaScript module
- Uses
- none found
- Used by
- imported by Registry Test (import), run by Build (script call)
- Produces
- buildNavigationRegistry
- Defines here
- buildNavigationRegistry, pin, identity, entryFor
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/capsules/tool-layers/registry.mjs:1-42 · blob 081b9a0f7e61bfc55322d79e80486d0bd2978db8 · GitHub at these lines
- State
- achieves: readme · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unknown
/** Resolve actual composed destinations; historical navigation declarations remain separate. */
export function buildNavigationRegistry(config) {
if(!Array.isArray(config?.owners) || !Array.isArray(config?.tools))throw Error('Navigation owners and tools are required');
const pin=owner=>{
if(!owner || typeof owner.repository!=='string' || !owner.repository.trim() || !/^[a-f0-9]{40}$/.test(owner.commit||'') || !/^\d{12}$/.test(owner.release||'') || !/^[a-f0-9]{64}$/.test(owner.manifestSha256||''))throw Error('Complete navigation owner pin required');
return {repository:owner.repository,commit:owner.commit,release:owner.release,manifestSha256:owner.manifestSha256};
};
const identity=owner=>JSON.stringify(pin(owner));
const entryFor=app=>{
if(typeof app?.id!=='string' || !app.id || typeof app.entry!=='string' || /[\\:%?#]/.test(app.entry) || app.entry.split('/').some(p=>!p || p==='.' || p==='..'))throw Error('Unsafe navigation application path');
return '../layer-apps/'+app.entry;
};
const candidates=new Map();
for(const owner of config.owners) {
const bound=pin(owner);
if(!Array.isArray(owner.applications))throw Error('Owner applications required');
for(const app of owner.applications) {
const entry=entryFor(app), key=identity(bound)+'\n'+entry;
if(!candidates.has(app.id))candidates.set(app.id,new Map());
candidates.get(app.id).set(key,{id:app.id,entry,owner:bound});
}
}
const explicit=new Map();
for(const tool of config.tools) {
if(explicit.has(tool.id))throw Error('Duplicate explicit navigation tool: '+tool.id);
const options=[...(candidates.get(tool.id)?.values()||[])];
const matches=options.filter(item=>identity(item.owner)===identity(tool.owner) && item.entry===tool.entry);
if(matches.length!==1)throw Error('Explicit tool does not match a composed owner/application: '+tool.id);
explicit.set(tool.id,{...matches[0],title:tool.title || tool.id,owner:pin(tool.owner)});
}
const entries=[],paths=new Set();
for(const [id,options] of candidates) {
let resolved=explicit.get(id);
if(!resolved) {
if(options.size!==1)throw Error('Ambiguous unlaunched navigation owner: '+id);
resolved={...options.values().next().value,title:id==='dc-ac-lv-topology-review'?'DC/AC LV Topology Review':id};
}
if(paths.has(resolved.entry))throw Error('Multiple applications share a navigation destination: '+resolved.entry);
paths.add(resolved.entry);entries.push({...resolved,owner:pin(resolved.owner)});
}
return entries;
}