In this section
- GlobalGrid2050 Build News Feed 2026q3 storage · globalgrid2050 / scripts/build_news_feed_2026q3.py lines 1–285
- GlobalGrid2050 Build News Feed V9 5 1 storage · globalgrid2050 / scripts/build_news_feed_v9_5_1.py lines 1–221
- GlobalGrid2050 Build Ons MWh Energy Use Placeholder energy-data · globalgrid2050 / scripts/build_ons_mwh_energy_use_placeholder.py lines 1–36
- GlobalGrid2050 Build Renewables V6 Dashboard ingest · globalgrid2050 / scripts/build_renewables_v6_dashboard.py lines 1–79
GlobalGrid2050 Build News Feed 2026q3
A Python command-line tool in the scripts folder that reads diff, project news links and the Renewable Energy Planning Database (REPD) register, using SHA-256.
storageglobalgrid2050 / scripts/build_news_feed_2026q3.py · lines 1–285 of 285 · Entry point · pattern discovery_item (shared by 2 files)
- What it does
- It loads diff, project news links and the REPD register. Defines 11 functions or classes, including sha256_file, read_json, parse_instant, story_key, as_story. Uses libraries __future__, argparse, copy, hashlib, json. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (topic 'markets-data'): 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 major_projects_2026q3.json; JSON file diff.json; JSON file major_project_news_v4.json; JSON file major_project_news_v5.json; JSON file major_project_news_v6.json; JSON file major_project_news_v9_5_1.json; JSON file major_projects_v6.json; JSON file project_news_links_v6.json.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Test News Binder Refaware (globalgrid2050). Reached from 1 other entry point, including GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
- What it achieves
- It reads JSON (`read_json`) and parses instant (`parse_instant`). Build an October 2026 (Q3) REPD-bound Pipeline News feed from cached articles. It accepts `--binder`, `--universe` and `--diff`.
- Why it matters
- Checked by GlobalGrid2050 Test News Binder Refaware.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- GlobalGrid2050 Major Project News V6 (import), GlobalGrid2050 News Binder Refaware (import), __future__, argparse, copy, hashlib, json, sys, collections, datetime
- Used by
- imported by GlobalGrid2050 Test News Binder Refaware (import)
- Produces
- sha256_file, read_json, parse_instant, story_key, as_story, freshness, strip_unverified_label, discovery_item, merge, build, main
- Defines here
- sha256_file, read_json, parse_instant, story_key, as_story, freshness, strip_unverified_label, discovery_item, merge, build, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/build_news_feed_2026q3.py:1-285 · blob e831d3994113767fa5c3d705fb392401652274e7 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Build an October 2026 (Q3) REPD-bound Pipeline News feed from cached articles.
Offline. Reads only committed files; writes only the --out file (a NEW name).
It never touches dist/major_project_news_v9_5_1.json or any Q2 V4/V5/V6 file.
Two binders:
--binder legacy the existing V9.5.1 algorithm (build_news_feed_v9_5_1.py):
V5 headlines re-resolved by major_project_news_v6._resolve_story,
V6 PRIMARY_MATCH items kept if their ref is in the universe,
against the October universe. Default out:
dist/major_project_news_2026q3.json
--binder refaware scripts/news_binder_refaware.py over V4+V5+V6 headlines, plus
REPD status-change candidates from automation/repd/diff.py
output. Default out: dist/major_project_news_2026q3_refaware.json
No article is fetched: the inputs are the August 2026 crawls committed in
dist/major_project_news_v4/v5/v6.json. A live crawl needs news.google.com
(major_project_news_v6.fetch_rss); see REPORT.md. Counts are derived from the
universe file, never pinned. Binding is scored at the crawl instant (the newest
input `updated`), so a rebuild is byte-identical; freshness against the edition
instant (the universe's validated_at) is reported per item, not used to score.
"""
from __future__ import annotations
import argparse
import copy
import hashlib
import json
import sys
from collections import Counter
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
import major_project_news_v6 as matcher # noqa: E402
import news_binder_refaware as refaware # noqa: E402
NEWS_HORIZON_DAYS = matcher.LOOKBACK_DAYS
DEFAULT_UNIVERSE = "dist/major_projects_2026q3.json"
DEFAULT_DIFF = "docs/repd/2026q3/changes-jul-to-oct/diff.json"
PROTECTED = (
"dist/major_project_news_v4.json", "dist/major_project_news_v5.json", "dist/major_project_news_v6.json",
"dist/major_project_news_v9_5_1.json", "dist/major_projects_v6.json", "dist/project_news_links_v6.json",
)
def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def read_json(path: Path) -> dict:
return json.loads(path.read_text(encoding="utf-8"))
def parse_instant(value: object) -> datetime:
parsed = datetime.fromisoformat(str(value).strip().replace("Z", "+00:00"))
return (parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc)).astimezone(timezone.utc)
def story_key(item: dict) -> tuple[str, str, str]:
return (matcher.norm(item.get("headline")), matcher.norm(item.get("source_url") or item.get("source")),
str(item.get("published") or "")[:10])
def as_story(item: dict) -> dict:
return {"title": str(item.get("headline") or ""), "description": "", "source": str(item.get("source") or ""),
"source_url": str(item.get("source_url") or ""), "link": str(item.get("url") or ""),
"published": parse_instant(str(item.get("published"))[:10])}
def freshness(item: dict, edition: datetime) -> dict:
age = (edition.date() - parse_instant(str(item["published"])[:10]).date()).days
return {"age_days_at_edition": age, "within_news_horizon_at_edition": 0 <= age <= NEWS_HORIZON_DAYS}
LEGACY_PROJECT_FIELDS = ("project", "project_id", "technology", "capacity_mw", "operator", "county", "status")
def strip_unverified_label(item: dict) -> None:
"""V4/V5 headlines carry the project their name-token scorer picked (wrong for 70 of
114 labelled V5 items). The V9.5.1 page prints that label beside DISCOVERY_ONLY
stories; keep it only as legacy_* fields and derive technology from the text."""
item["legacy_unverified_label"] = {field: item.pop(field) for field in LEGACY_PROJECT_FIELDS if field in item}
context = refaware.story_context(as_story(item))
item["technology"] = "solar" if context["solar_context"] else "bess" if context["bess_context"] else ""
def discovery_item(source: dict, origin: str, canonical_by_key: dict, strip_labels: bool = False) -> dict:
item = copy.deepcopy(source)
if strip_labels and origin in {"V4_BASELINE", "V5_BASELINE"}:
strip_unverified_label(item)
canonical = canonical_by_key.get(story_key(source))
item["discovery_origin"] = origin
item["canonical_relevant"] = canonical is not None
if canonical:
for field in ("gg_article_id", "repd_ref", "primary_repd_ref", "gg_project_id", "gg_development_id", "role",
"eligible_for_news_signal", "confidence", "match_evidence", "event"):
item[field] = copy.deepcopy(canonical.get(field))
item["canonical_project"] = canonical.get("project")
item["canonical_technology"] = canonical.get("technology")
item["canonical_capacity_mw"] = canonical.get("capacity_mw")
else:
item["role"] = "DISCOVERY_ONLY"
item["eligible_for_news_signal"] = False
for field in ("repd_ref", "primary_repd_ref", "gg_project_id", "gg_development_id", "match_evidence"):
item.pop(field, None)
return item
def merge(items: list[dict]) -> list[dict]:
merged: dict = {}
for item in items:
key = story_key(item)
if key not in merged or float(item.get("confidence") or 0) > float(merged[key].get("confidence") or 0):
merged[key] = item
return sorted(merged.values(), key=lambda i: (str(i.get("published")), int(i.get("confidence") or 0),
i.get("headline") or ""), reverse=True)
def build(args: argparse.Namespace) -> dict:
root = Path(args.root)
before = {p: sha256_file(root / p) for p in PROTECTED if (root / p).exists()}
v4, v5, v6 = (read_json(root / f"dist/major_project_news_{v}.json") for v in ("v4", "v5", "v6"))
universe_path = root / args.universe
scoring_instant = max(str(v5["updated"]), str(v6["updated"]), str(v4["updated"]) if args.binder == "refaware" else "")
matcher.pin_scoring_reference(scoring_instant)
snapshot, projects = refaware.load_universe(universe_path)
by_ref = {p["repd_ref"]: p for p in projects}
edition = parse_instant(snapshot.get("validated_at"))
origins = [("V5_BASELINE", v5["items"]), ("V6_CANONICAL", v6.get("items") or [])]
if args.binder == "refaware":
origins.insert(0, ("V4_BASELINE", v4["items"]))
rejections: Counter = Counter()
canonical: list[dict] = []
v6_kept = v6_demoted = 0
for origin, items in origins:
for source in items:
story = as_story(source)
if args.binder == "legacy":
if origin == "V6_CANONICAL":
ref = str(source.get("repd_ref") or "")
if source.get("role") != "PRIMARY_MATCH" or ref not in by_ref \
or source.get("gg_project_id") != f"GG2050-REPD-{ref}":
rejections["v6_ref_not_in_universe"] += 1
continue
item = copy.deepcopy(source)
v6_kept += 1
else:
item, reason, _ = matcher._resolve_story(story, projects)
if item is None:
rejections[reason] += 1
continue
else:
item, reason, _ = refaware.resolve_story(story, projects, by_ref)
if item is None and origin == "V6_CANONICAL":
# V6 bound with an RSS description that is not cached; keep the
# original ref unless the refaware rules reject that project.
ref = str(source.get("repd_ref") or "")
project = by_ref.get(ref)
context = refaware.story_context(story)
if project is None:
reason = "v6_ref_not_in_universe"
elif refaware._stale(project, story["published"].date(), context):
reason = "v6_stale_record_demoted"
else:
item = copy.deepcopy(source)
item["match_evidence"] = dict(item.get("match_evidence") or {},
binder="v6-description-bound (not reproducible headline-only)")
reason = "v6_retained"
if item is None:
v6_demoted += 1
else:
v6_kept += 1
if item is None:
rejections[reason] += 1
continue
item["discovery_origin"] = origin
item["legacy_project_label"] = source.get("project")
canonical.append(item)
canonical = merge(canonical)
matcher._build_links(canonical, projects)
for item in canonical:
item.update(freshness(item, edition))
canonical_by_key = {story_key(i): i for i in canonical}
all_by_key: dict = {}
for origin, items in origins:
for source in items:
all_by_key[story_key(source)] = discovery_item(source, origin, canonical_by_key,
strip_labels=args.binder == "refaware")
all_items = sorted(all_by_key.values(), key=lambda i: (str(i.get("published")), i.get("headline") or ""),
reverse=True)
for item in all_items:
item.update(freshness(item, edition))
# Invariants (structural, no pinned counts)
for item in canonical:
assert item["role"] == "PRIMARY_MATCH" and item["eligible_for_news_signal"] is True
assert item["repd_ref"] in by_ref and item["gg_project_id"] == f"GG2050-REPD-{item['repd_ref']}"
keys = {story_key(i) for i in all_items}
assert {story_key(i) for i in v5["items"]} <= keys, "V5 discovery truncated"
assert sum(i["canonical_relevant"] for i in all_items) == len(canonical)
payload = {
"schema": "globalgrid2050.major-project-news.2026q3",
"binder": "major_project_news_v6 (V9.5.1 algorithm)" if args.binder == "legacy" else refaware.BINDER_VERSION,
"repd_edition": snapshot.get("source_dataset_title"),
"edition_instant": snapshot.get("validated_at"),
"scoring_reference": scoring_instant,
"news_horizon_days": NEWS_HORIZON_DAYS,
"all_headline_count": len(all_items),
"relevant_headline_count": len(canonical),
"relevant_within_horizon_count": sum(i["within_news_horizon_at_edition"] for i in canonical),
"rules": {
"relevant_requires_canonical_primary_match": True,
"project_signal_requires_exact_repd_ref": True,
"discovery_only_drives_project_signal": False,
"official_repd_facts_overwritten": False,
"repd_status_change_drives_news_signal": False,
},
"project_snapshot": {
"path": args.universe, "sha256": sha256_file(universe_path), "schema": snapshot.get("schema"),
"project_count": len(projects), "solar_count": sum(p["technology"] == "solar" for p in projects),
"bess_count": sum(p["technology"] == "bess" for p in projects),
"projects_sha256": snapshot.get("projects_sha256"),
},
"inputs": {p: before[p] for p in PROTECTED if p.startswith("dist/major_project_news_v") and p in before
and p != "dist/major_project_news_v9_5_1.json"},
"network": {"articles_fetched": 0, "note": "cached August 2026 crawls only; live crawl needs news.google.com"},
"telemetry": {
"headlines_considered": sum(len(items) for _o, items in origins),
"rejection_reasons": dict(sorted(rejections.items())),
"v6_items_retained": v6_kept, "v6_items_demoted": v6_demoted,
"by_origin": dict(sorted(Counter(i["discovery_origin"] for i in canonical).items())),
},
"canonical_items": canonical,
"all_items": all_items,
}
if args.binder == "refaware" and args.diff:
diff_path = root / args.diff
diff = read_json(diff_path)
changes = refaware.repd_status_change_candidates(diff, projects)
linked = refaware.corroborate(changes, canonical)
payload["repd_status_changes"] = {
"source": {"path": args.diff, "sha256": sha256_file(diff_path), "schema": diff.get("schema"),
"from": (diff.get("previous") or {}).get("label"), "to": (diff.get("new") or {}).get("label")},
"rule": "official REPD status transitions for universe projects; never a NEWS SIGNAL; never alters status",
"count": len(changes),
"by_event": dict(sorted(Counter(c["event"] for c in changes).items())),
"corroborated_by_article_links": linked,
"items": changes,
}
after = {p: sha256_file(root / p) for p in before}
if after != before:
raise RuntimeError("a protected Q2 news/project file changed during the build")
return payload
def main(argv: list[str] | None = None) -> dict:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--binder", choices=("legacy", "refaware"), default="legacy")
parser.add_argument("--universe", default=DEFAULT_UNIVERSE)
parser.add_argument("--diff", default=DEFAULT_DIFF)
parser.add_argument("--root", default=str(ROOT))
parser.add_argument("--out", default=None)
args = parser.parse_args(argv)
out = Path(args.out or (Path(args.root) / ("dist/major_project_news_2026q3.json" if args.binder == "legacy"
else "dist/major_project_news_2026q3_refaware.json")))
resolved = out.resolve()
if any(resolved == (Path(args.root) / p).resolve() for p in PROTECTED):
raise SystemExit("refusing to overwrite a protected Q2 feed")
payload = build(args)
out.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8", newline="\n")
print(f"{out.name}: {payload['all_headline_count']} ALL, {payload['relevant_headline_count']} RELEVANT "
f"({payload['relevant_within_horizon_count']} within {NEWS_HORIZON_DAYS} d of {payload['edition_instant']})"
+ (f", {payload['repd_status_changes']['count']} REPD status changes" if "repd_status_changes" in payload else ""))
return payload
if __name__ == "__main__":
main()GlobalGrid2050 Build News Feed V9 5 1
A Python command-line tool in the scripts folder that reads major project news and the Renewable Energy Planning Database (REPD) register.
storageglobalgrid2050 / scripts/build_news_feed_v9_5_1.py · lines 1–221 of 221 · Entry point · pattern discovery_item (shared by 2 files)
- What it does
- It loads major project news and the REPD register. Defines 10 functions or classes, including read_json, published_datetime, story_key, as_story, canonical_v5_items. Uses libraries __future__, copy, json, sys, collections. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (topic 'markets-data'): 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 major_project_news_v5.json; JSON file major_project_news_v6.json; JSON file major_project_news_v9_5_1.json.
- Downstream impact
- Used directly by 2 files: Review2 Check (globalgrid2050); Review2b Check (globalgrid2050).
- What it achieves
- It reads JSON (`read_json`), validates v6 (`validate_v6_items`) and merges canonical (`merge_canonical`). Build the V9.5.1 dual-layer newspaper without mutating source feeds. Its code works with 400 MW.
- Why it matters
- Run by Review2 Check and Review2b Check.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- GlobalGrid2050 Major Project News V6 (import), __future__, copy, json, sys, collections, datetime, pathlib
- Used by
- run by Review2 Check (script call), run by Review2b Check (script call)
- Produces
- read_json, published_datetime, story_key, as_story, canonical_v5_items, validate_v6_items, merge_canonical, Number, discovery_item, main
- Defines here
- read_json, published_datetime, story_key, as_story, canonical_v5_items, validate_v6_items, merge_canonical, Number, discovery_item, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/build_news_feed_v9_5_1.py:1-221 · blob 185f555157effc326ad3057542df564caf40d9fa · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Build the V9.5.1 dual-layer newspaper without mutating source feeds.
ALL preserves every V9.4/V5 discovery headline and adds current V6 discoveries.
RELEVANT and project NEWS SIGNAL use only one canonical PRIMARY_MATCH per article.
"""
from __future__ import annotations
import copy
import json
import sys
from collections import Counter
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
import major_project_news_v6 as matcher # noqa: E402
V5_PATH = ROOT / "dist" / "major_project_news_v5.json"
V6_PATH = ROOT / "dist" / "major_project_news_v6.json"
OUT_PATH = ROOT / "dist" / "major_project_news_v9_5_1.json"
def read_json(path: Path) -> dict:
return json.loads(path.read_text(encoding="utf-8"))
def published_datetime(value: object) -> datetime:
parsed = datetime.fromisoformat(str(value).strip().replace("Z", "+00:00"))
return (parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc)).astimezone(timezone.utc)
def story_key(item: dict) -> tuple[str, str, str]:
return (
matcher.norm(item.get("headline")),
matcher.norm(item.get("source_url") or item.get("source")),
str(item.get("published") or "")[:10],
)
def as_story(item: dict) -> dict:
return {
"title": str(item.get("headline") or ""),
"description": "",
"source": str(item.get("source") or ""),
"source_url": str(item.get("source_url") or ""),
"link": str(item.get("url") or ""),
"published": published_datetime(item.get("published")),
}
def canonical_v5_items(items: list[dict], projects: list[dict]) -> tuple[list[dict], Counter]:
accepted: list[dict] = []
rejected: Counter = Counter()
for legacy in items:
resolved, reason, _detail = matcher._resolve_story(as_story(legacy), projects)
if resolved is None:
rejected[reason] += 1
continue
resolved["discovery_origin"] = "V5_REVALIDATED"
resolved["legacy_project_label"] = legacy.get("project")
resolved["legacy_technology_label"] = legacy.get("technology")
accepted.append(resolved)
return accepted, rejected
def validate_v6_items(items: list[dict], known_refs: set[str]) -> list[dict]:
accepted: list[dict] = []
for index, source in enumerate(items):
item = copy.deepcopy(source)
if item.get("role") != "PRIMARY_MATCH" or item.get("eligible_for_news_signal") is not True:
raise RuntimeError(f"V6 item {index} is not a signal-eligible PRIMARY_MATCH")
repd_ref = str(item.get("repd_ref") or "")
if repd_ref not in known_refs or item.get("gg_project_id") != f"GG2050-REPD-{repd_ref}":
raise RuntimeError(f"V6 item {index} has invalid canonical identity")
item["discovery_origin"] = "V6_CANONICAL"
accepted.append(item)
return accepted
def merge_canonical(v5_items: list[dict], v6_items: list[dict]) -> list[dict]:
merged: dict[tuple[str, str, str], dict] = {}
for item in (*v5_items, *v6_items):
key = story_key(item)
previous = merged.get(key)
if previous is None or Number(item.get("confidence", 0)) > Number(previous.get("confidence", 0)):
merged[key] = item
return sorted(
merged.values(),
key=lambda item: (str(item.get("published") or ""), int(item.get("confidence") or 0), item.get("headline") or ""),
reverse=True,
)
def Number(value: object) -> float:
try:
return float(value)
except (TypeError, ValueError):
return 0.0
def discovery_item(source: dict, origin: str, canonical_by_key: dict[tuple[str, str, str], dict]) -> dict:
item = copy.deepcopy(source)
canonical = canonical_by_key.get(story_key(source))
item["discovery_origin"] = origin
item["canonical_relevant"] = canonical is not None
if canonical:
for field in (
"gg_article_id", "repd_ref", "primary_repd_ref", "gg_project_id", "gg_development_id",
"role", "eligible_for_news_signal", "confidence", "match_evidence",
):
item[field] = copy.deepcopy(canonical.get(field))
item["canonical_project"] = canonical.get("project")
item["canonical_technology"] = canonical.get("technology")
item["canonical_capacity_mw"] = canonical.get("capacity_mw")
else:
item["role"] = "DISCOVERY_ONLY"
item["eligible_for_news_signal"] = False
return item
def main() -> dict:
v5, v6 = read_json(V5_PATH), read_json(V6_PATH)
if v5.get("schema") != "globalgrid2050.major-project-news.v5" or len(v5.get("items") or []) != 125:
raise RuntimeError("V9.4/V5 125-headline baseline is unavailable")
if v6.get("schema") != "globalgrid2050.major-project-news.v6":
raise RuntimeError("Canonical V6 feed is unavailable")
# Score against the instant this edition was originally scored at, not the
# instant of the rebuild. Without this the recency component decays with the
# calendar and a rebuild disagrees with the recorded bytes on nobody's
# change. See major_project_news_v6.scoring_reference for the full account.
matcher.pin_scoring_reference(v6["updated"])
snapshot, projects = matcher.load_project_snapshot()
known_refs = {project["repd_ref"] for project in projects}
revalidated_v5, rejections = canonical_v5_items(v5["items"], projects)
canonical_v6 = validate_v6_items(v6.get("items") or [], known_refs)
canonical = merge_canonical(revalidated_v5, canonical_v6)
matcher._build_links(canonical, projects)
canonical_by_key = {story_key(item): item for item in canonical}
all_by_key: dict[tuple[str, str, str], dict] = {}
for item in v5["items"]:
all_by_key[story_key(item)] = discovery_item(item, "V5_BASELINE", canonical_by_key)
for item in v6.get("items") or []:
all_by_key[story_key(item)] = discovery_item(item, "V6_CANONICAL", canonical_by_key)
all_items = sorted(
all_by_key.values(),
key=lambda item: (str(item.get("published") or ""), item.get("headline") or ""),
reverse=True,
)
beacon = [item for item in canonical if item.get("repd_ref") == "13599" and "Beacon Fen" in item.get("headline", "")]
if len(beacon) != 1 or beacon[0].get("capacity_mw") != 400.0 or beacon[0].get("operator") != "Low Carbon Limited":
raise RuntimeError("Beacon Fen must resolve once to Low Carbon REPD 13599 at 400 MW")
if len(revalidated_v5) != 37 or len(canonical_v6) != 8 or len(canonical) != 45 or len(all_items) != 133:
raise RuntimeError("V9.5.1 newspaper cardinality regression")
updated = max(str(v5.get("updated") or ""), str(v6.get("updated") or ""))
payload = {
"schema": "globalgrid2050.major-project-news.v9.5.1",
"release": "9.5.1",
"updated": updated,
"all_headline_count": len(all_items),
"relevant_headline_count": len(canonical),
"v9_4_baseline_headline_count": len(v5["items"]),
"v6_canonical_headline_count": len(canonical_v6),
"v5_revalidated_primary_count": len(revalidated_v5),
"rules": {
"all_preserves_complete_v9_4_newspaper": True,
"relevant_requires_canonical_primary_match": True,
"project_signal_requires_exact_repd_ref": True,
"discovery_only_drives_project_signal": False,
"official_repd_facts_overwritten": False,
},
"project_snapshot": {
"schema": snapshot.get("schema"),
"project_count": len(projects),
"projects_sha256": snapshot.get("projects_sha256"),
},
"beacon_fen_contract": {
"headline": beacon[0]["headline"],
"repd_ref": "13599",
"gg_project_id": "GG2050-REPD-13599",
"operator": "Low Carbon Limited",
"official_capacity_mw": 400.0,
"related_bess_repd_ref": "13600",
"related_bess_drives_signal": False,
},
"telemetry": {
"v5_items_considered": len(v5["items"]),
"v5_items_revalidated": len(revalidated_v5),
"v5_rejection_reasons": dict(sorted(rejections.items())),
"v6_items_preserved": len(canonical_v6),
"canonical_union_items": len(canonical),
"discovery_union_items": len(all_items),
},
"canonical_items": canonical,
"all_items": all_items,
}
# newline="\n" is not cosmetic. Path.write_text opens in TEXT mode, so "\n"
# becomes os.linesep: CRLF on Windows, LF on Linux. That is the same build
# producing different bytes per platform, and every digest and byte-identity
# gate downstream then disagrees with itself depending on whose machine ran.
OUT_PATH.write_text(
json.dumps(payload, indent=2, ensure_ascii=False) + "\n",
encoding="utf-8",
newline="\n",
)
print(
f"V9.5.1 feed built: {len(all_items)} ALL, {len(canonical)} RELEVANT, "
"Beacon Fen -> REPD 13599 (400 MW)"
)
return payload
if __name__ == "__main__":
main()GlobalGrid2050 Build Ons MWh Energy Use Placeholder
A Python command-line tool in the scripts folder.
energy-dataglobalgrid2050 / scripts/build_ons_mwh_energy_use_placeholder.py · lines 1–36 of 36 · Entry point
- What it does
- Defines main. Uses libraries json, datetime, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (topic 'markets-data'): 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 ons_mwh_energy_use_placeholder.json.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- json, datetime, pathlib
- Used by
- none found
- Produces
- main
- Defines here
- main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/build_ons_mwh_energy_use_placeholder.py:1-36 · blob 0f9781b45b140d360d51dc26440eb46b6318ecb8 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
import json
from datetime import datetime, timezone
from pathlib import Path
OUT = Path('uk_energy_tracking_v6/generation_history/mwh_energy_use/ons_mwh_energy_use_placeholder.json')
def main():
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text(json.dumps({
'generatedUTC': datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z'),
'status': 'placeholder',
'source': 'ONS Energy use by industry, source and fuel workbook or future API connector',
'conversion': {
'mtoeToTwh': 11.63,
'twhToMwh': 1000000,
'formula': 'MWh = Mtoe * 11.63 * 1000000'
},
'purpose': 'Annual MWh energy accounting layer for GlobalGrid2050 generation and electrification education.',
'rows': [],
'plannedFields': [
'year',
'economicSector',
'sourceName',
'activityName',
'fuel',
'mtoe',
'twh',
'mwh'
]
}, indent=2), encoding='utf-8')
print(f'Wrote {OUT}')
if __name__ == '__main__':
main()GlobalGrid2050 Build Renewables V6 Dashboard
A Python command-line tool in the scripts folder that reads major projects, major project news, Renewable Energy Planning Database (REPD) master and the REPD register.
ingestglobalgrid2050 / scripts/build_renewables_v6_dashboard.py · lines 1–79 of 79 · Entry point
- What it does
- It loads major projects, major project news, REPD master and the REPD register. Defines validate. Uses libraries __future__, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'renewables'): 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 major_projects_v6.json; JSON file major_project_news_v6.json; JSON file repd_master.json; JSON file major_project_news_v5.json.
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 Harden Renewables V6 Dashboard (globalgrid2050); GlobalGrid2050 Major Project News V6 Workflow (globalgrid2050).
- What it achieves
- It is built from the validate step (`validate`). Read-only structural gate for the maintained standalone V6 dashboard.
- Why it matters
- Imported by GlobalGrid2050 Harden Renewables V6 Dashboard. Run by GlobalGrid2050 Major Project News V6 Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- __future__, pathlib
- Used by
- imported by GlobalGrid2050 Harden Renewables V6 Dashboard (import), run by GlobalGrid2050 Major Project News V6 Workflow (workflow run)
- Produces
- validate
- Defines here
- validate
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/build_renewables_v6_dashboard.py:1-79 · blob a0f11ffcd5f4caedfa74c299403bccb9af425ead · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Read-only structural gate for the maintained standalone V6 dashboard.
V6 is no longer regenerated from V5: doing so silently reintroduced the shared
V5 data loader. V1–V5 remain immutable regression baselines; the maintained V6
file is validated directly.
"""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DASHBOARD = ROOT / "uk_renewables_pipeline" / "dashboard_v6_live.html"
def validate():
html = DASHBOARD.read_text(encoding="utf-8")
lower = html.lower()
required = {
"standalone V6 title": "UK RENEWABLES PIPELINE V6",
"same-origin project snapshot": "../dist/major_projects_v6.json",
"same-origin V6 newspaper": "../dist/major_project_news_v6.json",
"official publication page": "https://www.gov.uk/government/publications/renewable-energy-planning-database-quarterly-extract",
"analytics gauges": 'id="g3"',
"newspaper": "ENERGY DAILY",
"news ALL filter": 'data-mode="ALL"',
"news solar filter": 'data-mode="SOLAR"',
"news BESS filter": 'data-mode="BESS"',
"news consent filter": 'data-mode="CONSENT"',
"news construction filter": 'data-mode="CONSTRUCTION"',
"news operational filter": 'data-mode="OPERATIONAL"',
"news finance filter": 'data-mode="FINANCE"',
"news search": 'id="newsSearch"',
"asset status filter": 'id="state"',
"asset geography filter": 'id="county"',
"asset search": 'id="assetSearch"',
"project table": 'id="tbody"',
"CSV export": 'id="export"',
"GlobalGrid project ID": "GLOBALGRID PROJECT ID",
"GlobalGrid development ID": "GLOBALGRID DEVELOPMENT ID",
"REPD Ref": "REPD REF",
"REPD update date": "REPD UPDATED",
"official status": "REPD STATUS",
"separate news signal": "NEWS SIGNAL",
"missing official date": "not supplied by REPD",
"calendar-date news horizon": "const editionDay=new Date",
"mobile CSS": "@media(max-width:768px)",
}
missing = [f"{label}: {token}" for label, token in required.items() if token not in html]
for lineage in (
"dashboard.html",
"dashboard_v2_2026-08-22.html",
"dashboard_v3_live_2026-08-22.html",
"dashboard_v4_live.html",
"dashboard_v5_live.html",
):
if lineage not in html:
missing.append(f"version-lineage link: {lineage}")
if "<iframe" in lower:
missing.append("V6 must not be an iframe")
if "papaparse" in lower or "papa.parse" in lower:
missing.append("browser-side CSV parser remains")
if "assets.publishing.service.gov.uk" in lower:
missing.append("government asset host remains in browser runtime")
if "../dist/repd_master.json" in html:
missing.append("shared V1–V5 REPD master remains in V6")
if "../dist/major_project_news_v5.json" in html:
missing.append("unsafe V5 news fallback remains")
if "editionDate.getTime()-183*86400000" in html:
missing.append("timestamp-based news horizon can reject a valid boundary-day article")
if "</html>" not in lower:
missing.append("closing HTML missing")
if missing:
raise RuntimeError("V6 dashboard structural gate failed:\n - " + "\n - ".join(missing))
print("V6 DASHBOARD STRUCTURAL PASS", len(html.encode("utf-8")), "bytes")
if __name__ == "__main__":
validate()