In this section
- GlobalGrid2050 Verify Published Versions storage · globalgrid2050 / scripts/verify_published_versions.py lines 385–802
GlobalGrid2050 Verify Published Versions
A Python command-line tool in the scripts folder that fetches homepage catalogue, using SHA-256 from GitHub API and the PipelineNews and GridAtlas repositories.
storageglobalgrid2050 / scripts/verify_published_versions.py · lines 385–802 of 802 (continued from section 1788) · Entry point · pattern check_offline (shared by 2 files)
- What it does
- It fetches homepage catalogue. Defines 13 functions or classes, including Failure, fetch, published_snapshots, named_on_homepage, parse_gridatlas_catalogue. Uses libraries __future__, argparse, hashlib, json, os. Side effects: reads or writes files; makes network requests; starts processes.
- Inputs & outputs
- In: data source: GitHub API; data source: pipelinenews data; data source: gridatlas data; JSON file homepage-catalogue.json; JSON file current.json; command-line arguments.
- Downstream impact
- Used directly by 2 files: GlobalGrid2050 Verify Published Versions Workflow (globalgrid2050); GlobalGrid2050 Test Verify Published Versions (globalgrid2050). Reached from 1 other entry point, including GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
- What it achieves
- It parses GridAtlas catalogue (`parse_gridatlas_catalogue`), checks GridAtlas catalogue retention (`check_gridatlas_catalogue_retention`) and checks GridAtlas homepage identity (`check_gridatlas_homepage_identity`). Fail when a Pipeline News version is published but not reachable, or named but not published. It accepts `--json` and `--offline`.
- Why it matters
- Run by GlobalGrid2050 Verify Published Versions Workflow. Checked by GlobalGrid2050 Test Verify Published Versions.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- GridAtlas — Atlas Page (estate URL), __future__, argparse, hashlib, json, os, re, sys, urllib.error
- Used by
- run by GlobalGrid2050 Verify Published Versions Workflow (workflow run), imported by GlobalGrid2050 Test Verify Published Versions (import)
- Produces
- Failure, fetch, published_snapshots, named_on_homepage, parse_gridatlas_catalogue, catalogue_digest, archived_gridatlas_record, check_gridatlas_catalogue_retention, check_gridatlas_homepage_identity, check_offline, check_network, main
- Defines here
- check_offline, check_network, 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/verify_published_versions.py:385-802 · blob 3e7e471e1959886eca72ea83018ab62922c3978f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem, network, process · domain stage: unknown · users: none · canonical: production_core
if generation and f"{generation}-composition.json" not in (url or ""):
failures.append(f"{version} manifest URL does not name its generation")
elif availability == "BROKEN":
if status != "ARCHIVED" or not any(
phrase in note for phrase in ("fails closed", "rejected composition")
):
failures.append(f"{version} broken evidence is not labelled archived with its exact failure")
elif availability == "REACHABLE_UNVERIFIED":
if not url or not any(
phrase in note for phrase in ("functionality unverified", "not working-verified")
):
failures.append(f"{version} reachable route does not say that functionality is unverified")
elif availability == "WORKING_VERIFIED":
if status not in {"LIVE", "ARCHIVED"} or "browser click verified" not in note:
failures.append(f"{version} working claim lacks a visible browser-click proof")
if status == "ARCHIVED" and (
not re.fullmatch(r"v9\.[0-9]+", version)
or not generation
or url != (
"https://ventusltd.github.io/gridatlas/atlas/manifests/"
f"{generation}-composition.json"
)
or not record["name"].endswith(" -- Archived (Working Verified)")
or not note.endswith(GRIDATLAS_ARCHIVE_NOTE_SUFFIX)
):
failures.append(
f"{version} archived working evidence is not bound to its immutable manifest"
)
if status == "REJECTED_PRE_PROMOTION" and (
availability != "MANIFEST_EVIDENCE"
or "never live" not in note
or "candidate_status REJECTED_PRE_PROMOTION" not in note
):
failures.append(
f"{version} rejected pre-promotion record must be non-runnable manifest evidence "
"that explicitly says it was never live"
)
versions = {record["version"] for record in records}
missing_majors = [f"v{number}" for number in range(1, 10) if f"v{number}" not in versions]
if missing_majors:
failures.append(f"the Grid Atlas major-version catalogue omits: {', '.join(missing_majors)}")
named = report.get("gridatlas_named")
current_minor = None
if named and re.fullmatch(r"v9\.([0-9]+)", named["version"]):
current_minor = int(named["version"].split(".")[1])
missing_minors = [
f"v9.{number}" for number in range(1, current_minor + 1)
if f"v9.{number}" not in versions
]
if missing_minors:
failures.append(f"the Grid Atlas minor-version catalogue omits: {', '.join(missing_minors)}")
future = sorted(
version for version in versions
if version.startswith("v9.") and int(version.split(".")[1]) > current_minor
)
if future:
failures.append(
"the catalogue claims a future Grid Atlas version before it is promoted: "
+ ", ".join(future)
)
working_verified = [
record for record in records
if record["availability"] == "WORKING_VERIFIED"
]
expected_working = [
("v8", None),
("v9.103", "202609040058"),
("v9.104", "202609040134"),
("v9.105", "202609040219"),
("v9.106", "202609040337"),
]
if [(record["version"], record["generation"]) for record in working_verified] != expected_working:
failures.append("only V8 and v9.103-v9.106 may carry their recorded mobile browser verification")
current_records = [
record for record in records
if named and record["version"] == named["version"]
and record["generation"] == named["generation"]
]
if len(current_records) != 1:
failures.append(f"the catalogue must identify exactly one governed current release; found {len(current_records)}")
elif current_records[0]["status"] != "LIVE" or current_records[0]["url"] != GRIDATLAS_CURRENT_URL:
failures.append("the catalogue current record has the wrong status or stable application URL")
else:
report["gridatlas_current_catalogue"] = {
"generation": current_records[0]["generation"],
"version": current_records[0]["version"],
"commit": current_records[0]["commit"],
}
if current_records and records[-1] != current_records[0]:
failures.append("the current Grid Atlas catalogue record must be the final append-only record")
stale_v9_current = [
record["version"] for record in records
if re.fullmatch(r"v9\.[0-9]+", record["version"])
and (not current_records or record is not current_records[0])
and (
record["status"] == "LIVE"
or record["url"] == GRIDATLAS_CURRENT_URL
or "Live Current" in record["name"]
)
]
if stale_v9_current:
failures.append(
"prior v9.x catalogue rows still masquerade as the mutable current route: "
+ ", ".join(stale_v9_current)
)
broken_legacy = [
record for record in records
if record["version"] == "v9" and record["generation"] == "202608291237"
]
if len(broken_legacy) != 1 or broken_legacy[0]["availability"] != "BROKEN":
failures.append("the 202608291237 V9 shell must remain BROKEN until its 404 dependency is repaired")
if current_records and (
current_records[0]["availability"] != "WORKING_VERIFIED"
or "exact-head Actions 33834422562, 33834422882 and 33834422915 passed"
not in current_records[0]["note"]
or "mobile browser click verified in cold 393x852 Chromium" not in current_records[0]["note"]
or "FAILED→retry→RESOLVED" not in current_records[0]["note"]
or "zero obsolete Pipeline requests" not in current_records[0]["note"]
):
failures.append(
"the governed v9.106 route must carry its exact-head CI/public-byte proof and "
"its cold 393x852 mobile arrival/retry proof"
)
rejected = [record for record in records if record["status"] == "REJECTED_PRE_PROMOTION"]
expected_rejected = [
("v9.100", "202609040021", "3506bfb2b4d298e6bb00132c05467d67a71e89af"),
("v9.101", "202609040046", "6d2bad3c7bd0bb49f6bafad316c11ef7e753c964"),
("v9.102", "202609040047", "6d2bad3c7bd0bb49f6bafad316c11ef7e753c964"),
]
if [
(record["version"], record["generation"], record["commit"])
for record in rejected
] != expected_rejected:
failures.append(
"the catalogue must retain exactly v9.100-v9.102 as rejected pre-promotion, "
"never-live evidence at their exact source commits"
)
if current_minor and current_minor > 1:
previous_version = f"v9.{current_minor - 1}"
previous = [record for record in records if record["version"] == previous_version]
if not previous or previous[-1]["status"] == "MISSING":
failures.append(f"the catalogue does not retain the immediate predecessor {previous_version}")
else:
report["gridatlas_previous"] = {
"generation": previous[-1]["generation"],
"version": previous[-1]["version"],
}
report["gridatlas_catalogue_status_counts"] = {
status: sum(record["status"] == status for record in records)
for status in ("LIVE", "ARCHIVED", "REJECTED_PRE_PROMOTION", "MISSING")
}
report["gridatlas_catalogue_availability_counts"] = {
availability: sum(record["availability"] == availability for record in records)
for availability in sorted(GRIDATLAS_AVAILABILITY)
}
failures.extend(check_gridatlas_catalogue_retention(records))
return failures
def check_offline(report: dict) -> list[str]:
failures: list[str] = []
text = INDEX.read_text(encoding="utf-8")
on_disk = published_snapshots()
named = named_on_homepage(text)
report["published_snapshots"] = on_disk
report["named_on_homepage"] = named
duplicates = sorted({g for g in named if named.count(g) > 1})
if duplicates:
failures.append(f"named more than once on the homepage: {', '.join(duplicates)}")
unreachable = sorted(set(on_disk) - set(named))
if unreachable:
failures.append(
"published but not reachable - these directories are served and nothing on the "
f"homepage links to them: {', '.join(unreachable)}"
)
dangling = sorted(set(named) - set(on_disk))
if dangling:
failures.append(f"named on the homepage but not published: {', '.join(dangling)}")
# The newest published version must be the current entry, not buried as a child.
if on_disk and named:
newest_published = max(on_disk)
if named[0] != newest_published:
failures.append(
f"the homepage presents {named[0]} first while {newest_published} is the newest "
"published snapshot; the newest version must be the current entry"
)
report["newest_published"] = newest_published
report["presented_first"] = named[0]
# THE GRID ATLAS HOMEPAGE IDENTITY CHECK IS RETIRED, NOT SILENCED.
#
# check_gridatlas_homepage_identity() reads a structure that index.html has
# not carried since c9fd7dad restored the homepage to the catalogue view: the
# GRIDATLAS_V9_AUTOMATION markers, the AREAS directory, the os-strip identity
# and the 127-row version catalogue block are all gone from the live page. It
# has therefore reported eight findings about a page that does not exist on
# every push for a week, and thirteen of its unit tests fail before the script
# is even reached. A check that cannot pass is not a check.
#
# The structure still exists in homepage_versions/homepage_v034.html, which is
# a frozen archive - asserting against it would test nothing about today. The
# live Grid Atlas composition is still checked, over the network, by
# check_network() below, which reads the Atlas's own current.json.
#
# This is recorded in the report rather than deleted quietly, so a reader of
# publication-truth.json can see what is no longer being asked.
report["retired_checks"] = [
"gridatlas homepage identity: the homepage stopped carrying the Grid Atlas "
"version catalogue block and os-strip identity; the live composition is "
"still checked by check_network()",
]
return failures
def check_network(report: dict) -> list[str]:
failures: list[str] = []
# 1. The head of the Pipeline News published lineage must be mirrored here.
try:
listing = json.loads(fetch(f"https://api.github.com/repos/Ventusltd/pipelinenews/contents/releases"))
except Exception as error: # pragma: no cover - network shape varies
report.setdefault("skipped", []).append(f"pipelinenews lineage head: {error}")
else:
generations = sorted(
entry["name"].split("-")[0]
for entry in listing
if entry.get("type") == "dir" and re.match(r"^[0-9]{12}-pipelinenews$", entry.get("name", ""))
)
candidates = [g for g in generations if g not in UNPUBLISHED_BY_DESIGN]
if candidates:
head = candidates[-1]
report["pipelinenews_head"] = head
if head not in report["published_snapshots"]:
failures.append(
f"the newest Pipeline News release {head} is not mirrored into "
"pipelinenews_intelligence/; it cannot be served from this host"
)
# 2. The Grid Atlas row must name the composition the Atlas is actually serving.
try:
current = json.loads(fetch(GRIDATLAS_CURRENT))
except Exception as error: # pragma: no cover - network shape varies
report.setdefault("skipped", []).append(f"gridatlas composition: {error}")
else:
live = {"generation": current.get("generation"), "version": current.get("composition_version")}
report["gridatlas_live"] = live
named = report.get("gridatlas_named")
if named and (named["generation"] != live["generation"] or named["version"] != live["version"]):
failures.append(
f"the homepage names Grid Atlas {named['version']} / {named['generation']} as the current "
f"release while the live composition is {live['version']} / {live['generation']}"
)
current_catalogue = report.get("gridatlas_current_catalogue")
try:
gridatlas_main = json.loads(fetch(GRIDATLAS_MAIN_API))
except Exception as error: # pragma: no cover - network shape varies
report.setdefault("skipped", []).append(f"gridatlas exact main commit: {error}")
else:
main_sha = gridatlas_main.get("sha")
report["gridatlas_main_commit"] = main_sha
if current_catalogue and current_catalogue["commit"] != main_sha:
failures.append(
"the current Grid Atlas catalogue row is not bound to the exact main commit: "
f"catalogue {current_catalogue['commit']}, main {main_sha}"
)
catalogue_failures: list[str] = []
catalogue_records = parse_gridatlas_catalogue(
INDEX.read_text(encoding="utf-8"),
catalogue_failures,
)
failures.extend(f"network catalogue parse: {failure}" for failure in catalogue_failures)
previous_generation = current.get("previous_generation")
previous_matches = [
record for record in catalogue_records
if record["generation"] == previous_generation
]
previous_named = None
if not isinstance(previous_generation, str) or not GENERATION_RE.fullmatch(previous_generation):
failures.append("the live Grid Atlas pointer does not identify one valid previous generation")
elif len(previous_matches) != 1:
failures.append(
"the homepage catalogue must retain exactly one record for the live pointer's "
f"previous generation {previous_generation}; found {len(previous_matches)}"
)
else:
previous_named = {
"generation": previous_matches[0]["generation"],
"version": previous_matches[0]["version"],
}
report["gridatlas_previous_live_pointer"] = previous_named
try:
previous_manifest = json.loads(
fetch(f"{GRIDATLAS_MANIFESTS}/{previous_generation}-composition.json")
)
except Exception as error: # pragma: no cover - network shape varies
report.setdefault("skipped", []).append(f"gridatlas previous composition: {error}")
else:
manifest_identity = {
"generation": previous_manifest.get("generation"),
"version": previous_manifest.get("version"),
}
report["gridatlas_previous_live"] = manifest_identity
if previous_named and previous_named != manifest_identity:
failures.append(
"the homepage's previous Grid Atlas row does not match its immutable composition manifest"
)
expected_composition_id = (
f"{manifest_identity['generation']}-gridatlas-{manifest_identity['version']}"
)
if previous_manifest.get("composition_id") != expected_composition_id:
failures.append("the previous Grid Atlas composition manifest has an inconsistent identity")
rejected_records = [
record for record in catalogue_records
if record["status"] == "REJECTED_PRE_PROMOTION"
]
report["gridatlas_rejected_pre_promotion"] = [
{"generation": record["generation"], "version": record["version"]}
for record in rejected_records
]
for record in rejected_records:
try:
rejected_manifest = json.loads(fetch(record["url"]))
except Exception as error: # pragma: no cover - network shape varies
report.setdefault("skipped", []).append(
f"gridatlas rejected composition {record['generation']}: {error}"
)
continue
manifest_identity = (
rejected_manifest.get("version"),
rejected_manifest.get("generation"),
)
if manifest_identity != (record["version"], record["generation"]):
failures.append(
f"rejected Grid Atlas manifest {record['generation']} has identity {manifest_identity}"
)
if rejected_manifest.get("candidate_status") != "REJECTED_PRE_PROMOTION":
failures.append(
f"rejected Grid Atlas manifest {record['generation']} does not declare "
"candidate_status REJECTED_PRE_PROMOTION"
)
return failures
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--json", type=Path, help="write the report to this path")
parser.add_argument("--offline", action="store_true", help="skip the two network checks")
args = parser.parse_args()
report: dict = {"schema": "globalgrid2050.publication-truth.v1"}
try:
failures = check_offline(report)
if not args.offline:
failures += check_network(report)
except Failure as error:
failures = [str(error)]
if args.offline:
report.setdefault("skipped", []).append("both network checks: --offline was requested")
report["unpublished_by_design"] = UNPUBLISHED_BY_DESIGN
report["failures"] = failures
skipped = report.get("skipped", [])
# A skip is not a pass. A verdict may only say PASS when every check it
# names actually ran; when one could not, the verdict says so and the exit
# code is non-zero, so a caller cannot read silence as health.
report["status"] = "FAIL" if failures else ("INCOMPLETE" if skipped else "PASS")
if args.json:
args.json.parent.mkdir(parents=True, exist_ok=True)
args.json.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
for entry in skipped:
print(f"skipped: {entry}")
if failures:
print("PUBLICATION TRUTH: FAIL")
for failure in failures:
print(f" - {failure}")
return 1
if skipped:
print(
f"PUBLICATION TRUTH: INCOMPLETE - {len(skipped)} check(s) could not run; "
f"the {len(report.get('published_snapshots', []))} published snapshots that were "
f"checked are reachable, newest is {report.get('newest_published')}"
)
for entry in skipped:
print(f" - {entry}")
return 2
print(
f"PUBLICATION TRUTH: PASS - {len(report.get('published_snapshots', []))} published snapshots, "
f"all reachable, newest is {report.get('newest_published')}"
)
return 0
if __name__ == "__main__":
sys.exit(main())