In this section
- Build Pages ingest · pipelinenews / atman/202608262014-build-pages.py lines 701–1400
Build Pages
A Python command-line tool in the atman folder of PipelineNews that reads atlas link and atlas current, using SHA-256 from the GridAtlas repository.
ingestpipelinenews / atman/202608262014-build-pages.py · lines 701–1400 of 1960 · version 2026-08-26 20:14 (continued from section 997) · Entry point · pattern validate_current_or_predecessor_pointer (shared by 2 files)
- What it does
- It loads atlas link and atlas current. Defines 42 functions or classes, including RuntimeAssets, __init__, handle_starttag, require, sha256. Uses libraries __future__, argparse, datetime, hashlib, html.parser. 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: data source: gridatlas data; JSON file -release-manifest.json; JSON file 202608261737-release-v9-5-1.json; JSON file atlas-link-manifest.json; JSON file build-manifest.json; JSON file release-manifest.json; JSON file live-set.json; JSON file current-v4.json.
- Downstream impact
- Used directly by 7 files: Audit Atlas V8 Deep Link Quarantine (pipelinenews); Extend Pages Atlas Link V2 (pipelinenews); Repair Pages Historical Source Attestation (pipelinenews); Test Pages Promotion Tooling (pipelinenews); and 3 more. Reached from 1 other entry point, including PipelineNews Pages Workflow (pipelinenews).
- What it achieves
- It reads JSON (`read_json`), verifies record (`verify_record`) and verifies record commit (`verify_record_at_commit`). Validate and stage the immutable modular PipelineNews Pages release. It accepts `--root`, `--generation` and `--stage`.
- Why it matters
- Run by 5 workflows and scripts, including Audit Atlas V8 Deep Link Quarantine, Extend Pages Atlas Link V2 and Repair Pages Historical Source Attestation. Checked by Test Pages Promotion Tooling.
- Application
- pipelinenews · atman · Python CLI
- Uses
- GridAtlas — Atlas Page (estate URL), __future__, argparse, datetime, hashlib, html.parser, json, os, pathlib
- Used by
- run by Audit Atlas V8 Deep Link Quarantine (script call), run by Extend Pages Atlas Link V2 (script call), run by Repair Pages Historical Source Attestation (script call), run by Test Pages Promotion Tooling (script call), run by Repair Pages Historical Source Attestation (workflow run), run by Repair Pages Historical Source Attestation V2 (workflow run), run by PipelineNews Pages V2 Workflow (workflow run)
- Produces
- RuntimeAssets, require, sha256, read_json, repository_path, web_path, verify_record, verify_record_at_commit, select_release, run_compiler, data_generation, validate_html_and_modules
- Defines here
- validate_pages_promotion_source_pointer, validate_pages_promotion_pointer, validate_current_or_predecessor_pointer, validate_timestamp_folder_release, validate_live_pointer, copy_file, copy_tree, require_no_symlink_components, normalise_candidate_output_path, compact_json_sha256, iso8601_instant, git_text, require_git_commit, require_commit_file, pages_public_change_base, candidate_publication_boundary
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 atman/202608262014-build-pages.py:701-1400 · blob 5d7354d645b9de568c75c9000ad3aa4d47facf2c · 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: production_core
identity = atlas.get("identity") or {}
require(
atlas.get("pipeline_release_id") == release_id
and (atlas.get("atlas") or {}).get("release_id") == "202608300453-atlas-v9"
and identity.get("parameter") == "repd_ref"
and identity.get("rule") == "EXACT_REPD_REF_ONLY"
and identity.get("golden_repd_ref") == "13599"
and identity.get("golden_url")
== "https://ventusltd.github.io/gridatlas/202608300453-atlas-v9/?repd_ref=13599",
"Atlas-link binding changed",
)
outputs, declared = _atlas_link_v2_outputs(root, folder_relative)
record_by_path = {record["path"]: record for record in outputs}
required = {
f"{folder_relative}/index.html",
release_manifest_relative,
build_manifest_relative,
atlas_relative,
}
require(required.issubset(declared), "Atlas-link ledger omits required evidence")
build_declared: set[str] = set()
files = build_manifest.get("files")
require(isinstance(files, list) and files, "Atlas-link build file list missing")
for index, record in enumerate(files):
require(isinstance(record, dict) and set(record) == {"path", "bytes", "sha256"}, f"Atlas-link build record {index} changed")
local = record["path"]
require(not Path(local).is_absolute() and posixpath.normpath(local) == local, f"unsafe Atlas-link build path: {local}")
relative = f"{folder_relative}/{local}"
require(relative in declared, f"Atlas-link build path absent from ledger: {relative}")
expected = record_by_path[relative]
require(record["bytes"] == expected["bytes"] and record["sha256"] == expected["sha256"], f"Atlas-link build record differs: {relative}")
require(relative not in build_declared, f"duplicate Atlas-link build record: {relative}")
build_declared.add(relative)
require(
declared - build_declared == {release_manifest_relative, build_manifest_relative},
"Atlas-link build and SHA ledgers differ",
)
actual = {
path.relative_to(root).as_posix()
for path in folder.rglob("*")
if path.is_file()
}
require(not any(path.is_symlink() for path in folder.rglob("*")), "symlink in Atlas-link release")
require(actual == {record["path"] for record in outputs}, "Atlas-link folder closure differs from ledger")
release_commit = git_text(root, "log", "--diff-filter=A", "-1", "--format=%H", "--", release_manifest_relative)
require(bool(COMMIT_RE.fullmatch(release_commit)), "Atlas-link release is not committed")
require(git_text(root, "show", "-s", "--format=%P", release_commit).split() == [source_commit], "Atlas-link release parent changed")
changes = {
line for line in git_text(root, "diff-tree", "--no-commit-id", "--name-only", "-r", release_commit).splitlines()
if line
}
require(changes == actual, "Atlas-link release commit differs from folder closure")
for record in outputs:
require_commit_file(root, release_commit, record["path"], record["sha256"], "Atlas-link committed output")
text_files = "\n".join(
path.read_text(encoding="utf-8")
for path in folder.rglob("*")
if path.is_file()
and (path.suffix in {".html", ".mjs", ".js"} or path.name == "atlas-link-manifest.json")
and path.name not in {"build-manifest.json", "release-manifest.json"}
and "provenance" not in path.parts
)
require(FORBIDDEN_ATLAS_V8_RECEIVER not in text_files, "Atlas V8 receiver leaked into Atlas-link release")
require("202608291430-atlas-v9" not in text_files, "superseded Atlas V9 receiver leaked")
require("202608300453-atlas-v9" in text_files, "current Atlas V9 receiver absent")
return {
"release_id": release_id,
"generation": generation,
"kind": "current-atlas-link-v2",
"folder_path": f"{folder_relative}/",
"index_path": f"{folder_relative}/index.html",
"index_sha256": record_by_path[f"{folder_relative}/index.html"]["sha256"],
"manifest_path": release_manifest_relative,
"manifest_sha256": sha256(release_manifest_path),
"manifest": release_manifest,
"outputs": outputs,
"release_commit": release_commit,
}
def validate_pages_promotion_source_pointer(pointer: dict, timestamp_folder: dict) -> dict:
"""Require the pointer's complete source receipt to match the wrapper."""
promotion = timestamp_folder["manifest"].get("promotion_wrapper") or {}
expected = {
"release_id": timestamp_folder["source_release_id"],
"commit": timestamp_folder["source_commit"],
"manifest": promotion.get("source_release_manifest"),
}
source = pointer.get("promotion_source")
require(source == expected, "promotion pointer source receipt changed")
return source
def validate_pages_promotion_pointer(root: Path, timestamp_folder: dict) -> dict:
"""Validate the two-file live pointer child of a promotion wrapper."""
state_relative = Path("state/live-set.json")
current_relative = Path("releases/current-v4.json")
require((root / state_relative).is_file() and (root / current_relative).is_file(),
"promotion live pointer copies are missing")
state_payload = (root / state_relative).read_bytes()
require((root / current_relative).read_bytes() == state_payload,
"promotion live pointer copies differ")
pointer = json.loads(state_payload)
release_id = timestamp_folder["release_id"]
generation = timestamp_folder["generation"]
require(pointer.get("schema") == "pipelinenews.live-pointer.v4"
and pointer.get("classification") == "VERIFIED_LIVE_TIMESTAMPED_RELEASE"
and pointer.get("generation") == generation
and pointer.get("release_id") == release_id,
"promotion live pointer identity changed")
require(pointer.get("route") == f"/pipelinenews/releases/{release_id}/"
and pointer.get("entrypoint") == f"releases/{release_id}/index.html",
"promotion live pointer route changed")
release_binding = pointer.get("release_manifest")
build_binding = pointer.get("build_manifest")
atlas_binding = pointer.get("atlas_link_manifest")
for label, binding, expected_path in (
("release", release_binding, timestamp_folder["manifest_path"]),
("build", build_binding, f"releases/{release_id}/build-manifest.json"),
("Atlas", atlas_binding, f"releases/{release_id}/atlas-link-manifest.json"),
):
require(isinstance(binding, dict) and binding.get("path") == expected_path,
f"promotion pointer {label} binding changed")
verify_record(root, binding, f"promotion pointer {label} binding")
deployed = require_git_commit(root, pointer.get("deployed_commit"),
"promotion deployed commit")
require(deployed == timestamp_folder["release_commit"],
"promotion pointer deployed commit differs from wrapper")
validate_pages_promotion_source_pointer(pointer, timestamp_folder)
require(pointer.get("release_source_commit") == timestamp_folder["source_commit"],
"promotion pointer source commit changed")
require(pointer.get("atlas_v9_receiver") == timestamp_folder["receiver"],
"promotion pointer receiver changed")
verification = pointer.get("verification")
require(isinstance(verification, dict)
and verification.get("mode") == "EXACT_HEAD_PREVIEW_DEPLOY_PUBLIC_READBACK"
and verification.get("source_rows") == 8756
and verification.get("clickable_rows") == 8743
and verification.get("synthetic_receiver") is False
and verification.get("route_interceptions") == 0,
"promotion pointer verification contract changed")
pointer_commit = git_text(root, "log", "-1", "--format=%H", "--",
current_relative.as_posix())
require(pointer_commit == git_text(root, "log", "-1", "--format=%H", "--",
state_relative.as_posix()),
"promotion live pointers were not committed together")
require(git_text(root, "show", "-s", "--format=%P", pointer_commit).split()
== [deployed], "promotion pointer is not a one-parent child of wrapper")
changes = {
line for line in git_text(root, "diff-tree", "--no-commit-id", "--name-only", "-r",
pointer_commit).splitlines() if line
}
require(changes == {current_relative.as_posix(), state_relative.as_posix()},
"promotion pointer commit changed paths outside two pointers")
subprocess.run(["git", "merge-base", "--is-ancestor", pointer_commit, "HEAD"],
cwd=root, check=True, capture_output=True)
return {
"paths": [current_relative.as_posix(), state_relative.as_posix()],
"bytes": len(state_payload),
"sha256": hashlib.sha256(state_payload).hexdigest(),
"pointer": pointer,
}
def validate_current_or_predecessor_pointer(root: Path, timestamp_folder: dict) -> dict | None:
if timestamp_folder.get("kind") == "pages-promotion-wrapper-v1":
state_path = root / "state" / "live-set.json"
if state_path.exists():
state = read_json(state_path)
if (state.get("schema") == "pipelinenews.live-pointer.v4"
and state.get("release_id") == timestamp_folder.get("release_id")):
return validate_pages_promotion_pointer(root, timestamp_folder)
state_relative = Path("state/live-set.json")
if not (root / state_relative).is_file():
return None
state_payload = (root / state_relative).read_bytes()
pointer = json.loads(state_payload)
schema = pointer.get("schema")
require(schema in {"pipelinenews.live-pointer.v3", "pipelinenews.live-pointer.v4"}, "live pointer schema changed")
current_relative = Path("releases/current-v4.json" if schema.endswith(".v4") else "releases/current-v3.json")
require((root / current_relative).is_file(), "matching live pointer copy missing")
require((root / current_relative).read_bytes() == state_payload, "live pointer copies differ")
release_id = pointer.get("release_id")
require(
pointer.get("classification") == "VERIFIED_LIVE_TIMESTAMPED_RELEASE"
and isinstance(release_id, str)
and TIMESTAMP_FOLDER_RE.fullmatch(release_id),
"live pointer identity changed",
)
require(pointer.get("entrypoint") == f"releases/{release_id}/index.html", "live pointer entrypoint changed")
require(repository_path(root, pointer["entrypoint"]).is_file(), "live pointer entrypoint missing")
release_binding = pointer.get("release_manifest") or {}
build_binding = pointer.get("build_manifest") or {}
verify_record(root, release_binding, "live pointer release manifest")
verify_record(root, build_binding, "live pointer build manifest")
deployed = require_git_commit(root, pointer.get("deployed_commit"), "live pointer deployed commit")
owner = git_text(root, "log", "--diff-filter=A", "-1", "--format=%H", "--", release_binding["path"])
proof = pointer.get("public_proof") or {}
require(proof.get("synthetic_receiver") is False and proof.get("route_interceptions") == 0, "live pointer proof changed")
public_paths = [current_relative, state_relative, Path("state/atlas-v9-current.json")]
if schema.endswith(".v4"):
require(release_id == timestamp_folder["release_id"], "v4 pointer does not bind candidate")
require(owner == timestamp_folder["release_commit"], "v4 pointer release owner changed")
subprocess.run(["git", "merge-base", "--is-ancestor", owner, deployed], cwd=root, check=True, capture_output=True)
atlas_binding = pointer.get("atlas_link_manifest") or {}
verify_record(root, atlas_binding, "v4 pointer Atlas manifest")
receiver = pointer.get("atlas_v9_receiver") or {}
require(
receiver.get("release_id") == "202608300453-atlas-v9"
and receiver.get("base_url") == "https://ventusltd.github.io/gridatlas/202608300453-atlas-v9/"
and receiver.get("identity_rule") == "EXACT_REPD_REF_ONLY"
and receiver.get("query_parameter") == "repd_ref"
and receiver.get("golden_repd_ref") == "13599",
"v4 pointer Atlas receiver changed",
)
proof_path = proof.get("path")
require(
proof.get("classification") == "VERIFIED_PUBLIC_PIPELINENEWS_ATLAS_V9_DEEP_LINK"
and proof.get("receiver_url")
== "https://ventusltd.github.io/gridatlas/202608300453-atlas-v9/?repd_ref=13599"
and isinstance(proof_path, str)
and repository_path(root, proof_path).is_file()
and sha256(repository_path(root, proof_path)) == proof.get("sha256"),
"v4 pointer public proof changed",
)
public_paths.append(Path("state/atlas-v9-link-contract.json"))
expected_changes = {
current_relative.as_posix(),
state_relative.as_posix(),
"state/atlas-v9-link-contract.json",
"machine-learning/proofs/202608300309-local-atlas-v9-deep-link-proof.json",
"machine-learning/proofs/202608300309-public-atlas-v9-deep-link-proof.json",
}
else:
require(release_id == "202608291447-pipelinenews" and owner == deployed, "predecessor pointer changed")
receiver = pointer.get("atlas_v9_receiver") or {}
require(
receiver.get("base_url") == "https://ventusltd.github.io/gridatlas/202608291430-atlas-v9/"
and receiver.get("golden_repd_ref") == "16135",
"predecessor Atlas receiver changed",
)
expected_changes = {current_relative.as_posix(), state_relative.as_posix()}
pointer_commit = git_text(root, "log", "-1", "--format=%H", "--", current_relative.as_posix())
require(
pointer_commit == git_text(root, "log", "-1", "--format=%H", "--", state_relative.as_posix()),
"live pointer copies were not committed together",
)
require(git_text(root, "show", "-s", "--format=%P", pointer_commit).split() == [deployed], "live pointer parent changed")
changes = {
line for line in git_text(root, "diff-tree", "--no-commit-id", "--name-only", "-r", pointer_commit).splitlines()
if line
}
require(changes == expected_changes, "live pointer commit changed unexpected paths")
subprocess.run(["git", "merge-base", "--is-ancestor", pointer_commit, "HEAD"], cwd=root, check=True, capture_output=True)
existing_public = [relative for relative in public_paths if (root / relative).is_file()]
return {
"paths": [relative.as_posix() for relative in existing_public],
"bytes": len(state_payload),
"sha256": hashlib.sha256(state_payload).hexdigest(),
"pointer": pointer,
}
def validate_timestamp_folder_release(root: Path, release_id: str) -> dict:
"""Validate one immutable, folder-local successor without promoting a pointer."""
match = TIMESTAMP_FOLDER_RE.fullmatch(release_id)
require(match is not None, "timestamp folder release must be YYYYMMDDHHMM-pipelinenews")
generation = match.group(1)
folder_relative = f"releases/{release_id}"
folder = repository_path(root, folder_relative)
require(folder.is_dir() and not folder.is_symlink(), f"missing timestamp release folder: {folder_relative}")
require_no_symlink_components(root, folder_relative, "timestamp release folder")
release_manifest_relative = f"{folder_relative}/release-manifest.json"
build_manifest_relative = f"{folder_relative}/build-manifest.json"
release_manifest_path = repository_path(root, release_manifest_relative)
build_manifest_path = repository_path(root, build_manifest_relative)
require(release_manifest_path.is_file(), "timestamp release manifest is missing")
require(build_manifest_path.is_file(), "timestamp build manifest is missing")
release_manifest = read_json(release_manifest_path)
build_manifest = read_json(build_manifest_path)
if release_manifest.get("schema") == "pipelinenews.current-atlas-link-release.v2":
return validate_current_atlas_link_v2(
root,
release_id,
generation,
folder_relative,
folder,
release_manifest_relative,
release_manifest_path,
release_manifest,
build_manifest_relative,
build_manifest,
)
require(release_manifest.get("schema") == TIMESTAMP_FOLDER_RELEASE_SCHEMA, "timestamp release schema changed")
require(build_manifest.get("schema") == TIMESTAMP_FOLDER_BUILD_SCHEMA, "timestamp build schema changed")
for manifest in (release_manifest, build_manifest):
require(manifest.get("generation") == generation, "timestamp manifest generation mismatch")
require(manifest.get("release_id") == release_id, "timestamp manifest release ID mismatch")
require(release_manifest.get("immutable") is True, "timestamp release is not immutable")
require(
release_manifest.get("classification") == "IMMUTABLE_TIMESTAMPED_RELEASE",
"timestamp release classification changed",
)
require(
release_manifest.get("entrypoint") == f"{folder_relative}/index.html",
"timestamp entrypoint is not folder-local index.html",
)
require(
release_manifest.get("public_url")
== f"https://ventusltd.github.io/pipelinenews/{folder_relative}/",
"timestamp public URL changed",
)
require(
release_manifest.get("publication_control", {}).get("pointer_and_attestation_live_outside_release_folder") is True,
"pointer state entered immutable release bytes",
)
require(
release_manifest.get("folder_contract", {}).get("pointer_state_encoded_in_release") is False,
"immutable release encodes transient pointer state",
)
identity_routing = release_manifest.get("atlas_v9_deep_link", {})
require(
identity_routing.get("inbound_match_semantics") == "EXACT_PROJECT_REPD_REF"
and identity_routing.get("general_search_parameter") == "q"
and identity_routing.get("relationship_context_allowed_for_q") is True
and identity_routing.get("relationship_context_allowed_for_repd_ref") is False,
"timestamp release exact identity-routing contract changed",
)
functional = build_manifest.get("functional_files")
outputs = release_manifest.get("outputs")
require(isinstance(functional, list), "timestamp functional output list missing")
require(isinstance(outputs, list), "timestamp release output list missing")
require(len(functional) == TIMESTAMP_FOLDER_FUNCTIONAL_FILES, "timestamp functional file count changed")
require(len(outputs) == TIMESTAMP_FOLDER_TOTAL_FILES - 1, "timestamp declared output count changed")
require(
build_manifest.get("functional_file_count") == TIMESTAMP_FOLDER_FUNCTIONAL_FILES,
"timestamp functional count field changed",
)
require(
build_manifest.get("inherited_functional_files") == TIMESTAMP_FOLDER_INHERITED_FILES,
"timestamp inherited functional count changed",
)
require(
build_manifest.get("shared_dependency_files") == TIMESTAMP_FOLDER_SHARED_FILES,
"timestamp shared dependency count changed",
)
require(
build_manifest.get("inherited_parent_output_files") == TIMESTAMP_FOLDER_PARENT_FILES,
"timestamp inherited parent output count changed",
)
require(
build_manifest.get("parent_evidence", {}).get("exact_manifest", {}).get("sha256")
== "025daf70f1c4b9c9a7c84a70d41ceb50e96232771f736faa309ca92c2c9c134d",
"permanent parent evidence changed",
)
require(
build_manifest.get("parent_evidence", {}).get("exact_manifest", {}).get("bytes") == 25073,
"permanent parent evidence byte count changed",
)
require(
build_manifest.get("provenance_files") == TIMESTAMP_FOLDER_PROVENANCE_FILES,
"timestamp provenance file count changed",
)
declared: set[str] = set()
for label, records in (("timestamp functional file", functional), ("timestamp output", outputs)):
local_seen: set[str] = set()
for index, record in enumerate(records):
require(isinstance(record, dict), f"{label} {index} is not an object")
require(set(record) == {"path", "bytes", "sha256"}, f"unexpected fields in {label} {index}")
relative = normalise_candidate_output_path(record.get("path"), f"{label} {index}")
require(relative.startswith(f"{folder_relative}/"), f"{label} escapes timestamp folder: {relative}")
require(relative not in local_seen, f"duplicate {label}: {relative}")
local_seen.add(relative)
verify_record(root, record, label)
if label == "timestamp output":
declared = local_seen
require(
{record["path"] for record in functional}.issubset(declared),
"functional closure is not contained in timestamp outputs",
)
require(build_manifest_relative in declared, "build manifest is not a declared output")
require(release_manifest_relative not in declared, "release manifest must not self-hash")
require(
release_manifest.get("build_manifest")
== next(record for record in outputs if record["path"] == build_manifest_relative),
"release/build manifest binding changed",
)
actual = {
path.relative_to(root).as_posix()
for path in folder.rglob("*")
if path.is_file()
}
require(not any(path.is_symlink() for path in folder.rglob("*")), "symlink in timestamp release")
require(actual == declared | {release_manifest_relative}, "timestamp folder closure differs from manifest")
require(len(actual) == TIMESTAMP_FOLDER_TOTAL_FILES, "timestamp total file count changed")
source_commit = require_git_commit(root, release_manifest.get("source_commit"), "timestamp source commit")
release_commit = git_text(root, "log", "-1", "--format=%H", "--", release_manifest_relative)
require(bool(COMMIT_RE.fullmatch(release_commit)), "timestamp release manifest is not committed")
release_parents = git_text(root, "show", "-s", "--format=%P", release_commit).split()
require(release_parents == [source_commit], "timestamp release commit is not a one-parent child of source commit")
release_changes = {
line for line in git_text(
root, "diff-tree", "--no-commit-id", "--name-only", "-r", release_commit
).splitlines() if line
}
require(release_changes == actual, "timestamp release commit differs from exact 40-file folder closure")
for record in outputs:
require_commit_file(root, release_commit, record["path"], record["sha256"], "timestamp committed output")
require_commit_file(
root,
release_commit,
release_manifest_relative,
sha256(release_manifest_path),
"timestamp committed release manifest",
)
pointers_present = any((root / relative).is_file() for relative in ("releases/current-v3.json", "state/live-set.json"))
if not pointers_present:
require(git_text(root, "rev-parse", "HEAD") == release_commit, "unpromoted timestamp release is not deployment HEAD")
registry_path = folder / f"data/{generation}-registry.json"
registry = read_json(registry_path)
require(registry.get("schema") == TIMESTAMP_FOLDER_REGISTRY_SCHEMA, "timestamp registry schema changed")
require(registry.get("generation") == generation, "timestamp registry generation changed")
require(registry.get("classification") == "IMMUTABLE_TIMESTAMPED_RELEASE", "registry classification changed")
require("deployment" not in registry, "transient deployment state entered registry")
registry_routing = registry.get("cache_contract", {}).get("atlas_deep_link", {})
require(
registry_routing.get("inbound_match_semantics") == "EXACT_PROJECT_REPD_REF"
and registry_routing.get("general_search_parameter") == "q"
and registry_routing.get("relationship_context_allowed_for_q") is True
and registry_routing.get("relationship_context_allowed_for_repd_ref") is False,
"timestamp registry exact identity-routing contract changed",
)
# Provenance is an exact historical manifest and therefore records the old
# receiver. Leakage policy applies to executable/functional release bytes.
functional_paths = [repository_path(root, record["path"]) for record in functional]
text = "\n".join(
path.read_text(encoding="utf-8")
for path in functional_paths
if path.suffix in {".html", ".mjs", ".js", ".json", ".css"}
)
require(FORBIDDEN_ATLAS_V8_RECEIVER not in text, "old Atlas V8 receiver leaked into timestamp release")
require("NOT DEPLOYED" not in text and "NOT CURRENT" not in text, "transient release wording leaked")
require("DEEP-LINK CANDIDATE" not in text and "fast candidate" not in text, "candidate product-state wording leaked")
index_record = next(record for record in outputs if record["path"] == f"{folder_relative}/index.html")
return {
"release_id": release_id,
"generation": generation,
"folder_path": f"{folder_relative}/",
"index_path": index_record["path"],
"index_sha256": index_record["sha256"],
"manifest_path": release_manifest_relative,
"manifest_sha256": sha256(release_manifest_path),
"manifest": release_manifest,
"outputs": outputs,
}
def validate_live_pointer(root: Path, timestamp_folder: dict | None) -> dict | None:
pointer_paths = [Path("releases/current-v3.json"), Path("state/live-set.json")]
existing = [(root / relative).is_file() for relative in pointer_paths]
require(existing in ([False, False], [True, True]), "live pointer copies must be absent or both present")
if not all(existing):
return None
require(timestamp_folder is not None, "live pointer exists without validated timestamp release")
for relative in pointer_paths:
require_no_symlink_components(root, relative.as_posix(), "live pointer")
first = (root / pointer_paths[0]).read_bytes()
second = (root / pointer_paths[1]).read_bytes()
require(first == second, "current-v3 and live-set pointer bytes differ")
pointer = json.loads(first)
release_id = timestamp_folder["release_id"]
expected = {
"schema": "pipelinenews.live-pointer.v3",
"generation": timestamp_folder["generation"],
"release_id": release_id,
"classification": "VERIFIED_LIVE_TIMESTAMPED_RELEASE",
"route": f"/pipelinenews/releases/{release_id}/",
"entrypoint": f"releases/{release_id}/index.html",
}
for key, value in expected.items():
require(pointer.get(key) == value, f"live pointer {key} changed")
require(bool(COMMIT_RE.fullmatch(pointer.get("release_source_commit", ""))), "invalid live pointer release source")
require(bool(COMMIT_RE.fullmatch(pointer.get("deployed_commit", ""))), "invalid live pointer deployed commit")
require(
isinstance(pointer.get("verified_at_utc"), str) and bool(ISO_8601_RE.fullmatch(pointer["verified_at_utc"])),
"invalid live pointer verification timestamp",
)
proof = pointer.get("public_proof", {})
require(str(proof.get("pages_run_id", "")).isdigit(), "live pointer has no Pages run")
require(bool(SHA256_RE.fullmatch(proof.get("browser_proof_sha256", ""))), "live pointer browser proof hash changed")
require(bool(SHA256_RE.fullmatch(proof.get("comparator_report_sha256", ""))), "live pointer comparator hash changed")
require(bool(SHA256_RE.fullmatch(proof.get("equivalence_report_sha256", ""))), "live pointer equivalence hash changed")
require(proof.get("synthetic_receiver") is False, "live pointer permits synthetic receiver")
require(proof.get("route_interceptions") == 0, "live pointer proof was intercepted")
receiver_contract = timestamp_folder["manifest"].get("atlas_v9_deep_link", {})
receiver_base = receiver_contract.get("base_url", "")
contractual_golden = str(receiver_contract.get("golden_repd_ref", ""))
require(bool(re.fullmatch(r"https://ventusltd\.github\.io/gridatlas/\d{12}-atlas-v9/", receiver_base)), "timestamp receiver URL changed")
require(bool(re.fullmatch(r"\d+", contractual_golden)), "timestamp contractual golden changed")
require(
pointer.get("atlas_v9_receiver", {}).get("pointer") == receiver_contract.get("pointer")
and pointer.get("atlas_v9_receiver", {}).get("pointer_commit") == receiver_contract.get("pointer_commit")
and pointer.get("atlas_v9_receiver", {}).get("golden_repd_ref") == contractual_golden,
"live pointer GridAtlas binding changed",
)
require(proof.get("receiver_url") == f"{receiver_base}?repd_ref={contractual_golden}", "live pointer receiver URL changed")
receiver_cards = proof.get("receiver_evidence", {}).get("cards", [])
require(
isinstance(receiver_cards, list)
and any(f"REPD {contractual_golden}" in str(card) for card in receiver_cards),
"live pointer has no durable contractual-golden receiver card",
)
release_binding = pointer.get("release_manifest", {})
build_binding = pointer.get("build_manifest", {})
require(release_binding.get("path") == timestamp_folder["manifest_path"], "live pointer release binding path changed")
require(release_binding.get("sha256") == timestamp_folder["manifest_sha256"], "live pointer release binding hash changed")
verify_record(root, release_binding, "live pointer release manifest")
verify_record(root, build_binding, "live pointer build manifest")
release_commit = git_text(root, "log", "-1", "--format=%H", "--", timestamp_folder["manifest_path"])
require(release_commit == pointer["deployed_commit"], "live pointer deployed commit does not own immutable release")
pointer_commits = {
git_text(root, "log", "-1", "--format=%H", "--", relative.as_posix())
for relative in pointer_paths
}
require(len(pointer_commits) == 1, "live pointer copies were not committed together")
pointer_commit = next(iter(pointer_commits))
require(pointer_commit == git_text(root, "rev-parse", "HEAD"), "live pointer commit is not deployment HEAD")
parents = git_text(root, "show", "-s", "--format=%P", pointer_commit).split()
require(parents == [release_commit], "live pointer commit is not a one-parent child of deployed release")
pointer_changes = {
line for line in git_text(
root, "diff-tree", "--no-commit-id", "--name-only", "-r", pointer_commit
).splitlines() if line
}
require(pointer_changes == {path.as_posix() for path in pointer_paths}, "live pointer commit changed paths outside two pointers")
return {
"paths": [relative.as_posix() for relative in pointer_paths],
"bytes": len(first),
"sha256": hashlib.sha256(first).hexdigest(),
"pointer": pointer,
}
def copy_file(source_root: Path, site_root: Path, relative: str) -> None:
source = source_root / relative
require(source.is_file(), f"historical publication input missing: {source}")
target = site_root / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, target)
def copy_tree(source: Path, target: Path) -> None:
require(source.is_dir(), f"historical publication tree missing: {source}")
shutil.copytree(source, target, dirs_exist_ok=True)
def require_no_symlink_components(root: Path, relative: str, label: str) -> None:
current = root
for component in relative.split("/"):
current = current / component
require(not current.is_symlink(), f"symlink in {label}: {relative}")
def normalise_candidate_output_path(value: object, label: str) -> str:
require(isinstance(value, str) and value, f"{label} has no path")
require("\\" not in value and "\x00" not in value, f"invalid path in {label}: {value!r}")
require(bool(SAFE_RELEASE_OUTPUT_RE.fullmatch(value)), f"unsafe release path in {label}: {value}")
normalised = posixpath.normpath(value)
require(normalised == value, f"non-normalised path in {label}: {value}")
components = value.split("/")
require(all(component not in ("", ".", "..") for component in components), f"unsafe path in {label}: {value}")
require(components[0] == "releases" and len(components) > 1, f"candidate output is outside releases/: {value}")
return value
def compact_json_sha256(value: object) -> str:
encoded = json.dumps(
value,
ensure_ascii=False,
sort_keys=True,
separators=(",", ":"),
).encode("utf-8")
return hashlib.sha256(encoded).hexdigest()
def iso8601_instant(value: str) -> datetime:
require(bool(ISO_8601_RE.fullmatch(value)), f"invalid ISO-8601 timestamp: {value!r}")
return datetime.fromisoformat(value.replace("Z", "+00:00"))
def git_text(root: Path, *arguments: str) -> str:
completed = subprocess.run(
["git", *arguments],
cwd=root,
check=True,
capture_output=True,
text=True,
)
return completed.stdout.strip()
def require_git_commit(root: Path, commit: object, label: str) -> str:
require(isinstance(commit, str) and bool(COMMIT_RE.fullmatch(commit)), f"invalid {label}: {commit!r}")
subprocess.run(
["git", "cat-file", "-e", f"{commit}^{{commit}}"],
cwd=root,
check=True,
capture_output=True,
)
return commit
def require_commit_file(root: Path, commit: str, relative: str, expected_sha256: str, label: str) -> None:
completed = subprocess.run(
["git", "show", f"{commit}:{relative}"],
cwd=root,
check=True,
capture_output=True,
)
actual = hashlib.sha256(completed.stdout).hexdigest()
require(actual == expected_sha256, f"{label} changed at {commit}: {relative}")
def pages_public_change_base(release: dict) -> str:
"""Anchor a promotion's public diff after its immutable source commit."""
timestamp_folder = release.get("timestamp_folder")
if timestamp_folder is not None and timestamp_folder.get("kind") == "pages-promotion-wrapper-v1":
source_commit = timestamp_folder.get("source_commit")
require(isinstance(source_commit, str) and bool(COMMIT_RE.fullmatch(source_commit)),
"promotion public-diff source changed")
return source_commit
return ATLAS_V9_SOURCE_PARENT
def candidate_publication_boundary(root: Path, release: dict) -> tuple[set[str], set[str]]:
"""Return excluded and owner-authorised immutable fast-candidate outputs."""
build = root / "build"
if not build.exists():
return set(), set()
require(build.is_dir() and not build.is_symlink(), f"invalid candidate build directory: {build}")
manifests = sorted(build.glob("*-v8-fast-site-manifest.json"))
candidates: dict[str, dict] = {}
owners: dict[str, str] = {}
protected = {"releases/current.json", "releases/candidate.json", release["release_path"]}
protected.update(record["path"] for record in release["manifest"]["outputs"])
protected.update(
record["path"] for record in release["manifest"]["inputs"]
if record["path"].startswith("releases/")
)
for manifest_path in manifests:
match = FAST_CANDIDATE_MANIFEST_RE.fullmatch(manifest_path.name)
require(match is not None, f"invalid fast candidate manifest name: {manifest_path.name}")
generation = match.group(1)
relative_manifest = f"build/{generation}-v8-fast-site-manifest.json"
require(manifest_path.relative_to(root).as_posix() == relative_manifest, f"misplaced fast candidate manifest: {manifest_path}")
require_no_symlink_components(root, relative_manifest, "fast candidate manifest path")
require(manifest_path.is_file(), f"fast candidate manifest is not a file: {relative_manifest}")
manifest = read_json(manifest_path)
require(isinstance(manifest, dict), f"fast candidate manifest is not an object: {relative_manifest}")
require(manifest.get("schema") == FAST_CANDIDATE_SCHEMA, f"fast candidate schema changed: {relative_manifest}")
require(manifest.get("generation") == generation, f"fast candidate generation mismatch: {relative_manifest}")
require(
manifest.get("deployment") == "not-authorised",
f"immutable fast candidate deployment state changed: {relative_manifest}",
)
source_commit = manifest.get("source_commit")
require(isinstance(source_commit, str) and bool(COMMIT_RE.fullmatch(source_commit)), f"invalid candidate source commit: {relative_manifest}")
build_run = manifest.get("github_run_id")
require(isinstance(build_run, str) and build_run.isdigit(), f"invalid candidate build run: {relative_manifest}")
cache_identity = manifest.get("cache_identity")
require(isinstance(cache_identity, str) and bool(SHA256_RE.fullmatch(cache_identity)), f"invalid candidate cache identity: {relative_manifest}")
outputs = manifest.get("outputs")
require(isinstance(outputs, list) and outputs, f"fast candidate has no outputs: {relative_manifest}")
manifest_paths: set[str] = set()
output_records: dict[str, dict] = {}
for index, record in enumerate(outputs):