A package loaded only on an app with exactly its host interface, so every interface change stranded packages on older apps. The host now runs packages built for interfaces from oldest_host_api to host_api (5 to 6), and each package declares the oldest interface it needs in apps/versions.json; all current packages keep 5, so their signed releases are unchanged. Interface 6 marks hosts that match record fields by name. The constants are generated into src/cells/host_api.zi, apart from the package versions, because they are compiled host behavior. Update checks name the host and module interfaces and a stable random device bucket, so the Waozi node answers with the newest release this app can run. package-release.py --rollout PERCENT --rollout-hours HOURS uploads changed releases staged to that share of devices; the node releases them to everyone when the time runs out, and a full upload promotes them earlier. Co-Authored-By: Claude Opus 5.5 <[email protected]>
67 lines
3.2 KiB
Python
67 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Check independent app release versions without changing the ledger."""
|
|
import argparse
|
|
from datetime import date
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
import sys
|
|
|
|
NAMES = {"inbe": "inbe", "lists": "lists", "habits": "habits",
|
|
"practices": "practice", "diary": "diary", "lumi": "lumi",
|
|
"leaderboard": "leaderboard"}
|
|
VERSION = r"(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})"
|
|
|
|
|
|
def validate(root):
|
|
ledger = json.loads((root / "apps/versions.json").read_text())
|
|
for api in ("host_api", "oldest_host_api", "module_api"):
|
|
if type(ledger.get(api)) is not int or not 0 < ledger[api] <= 65535:
|
|
raise ValueError(f"invalid {api}")
|
|
# The host runs packages from its oldest supported interface to its own.
|
|
if ledger["oldest_host_api"] > ledger["host_api"]:
|
|
raise ValueError("oldest_host_api is newer than host_api")
|
|
if set(ledger["apps"]) != set(NAMES):
|
|
raise ValueError("the ledger must contain the root and all six cells")
|
|
for name, source in NAMES.items():
|
|
component = ledger["apps"][name]
|
|
expected_id = "inbe" if name == "inbe" else "inbe." + name
|
|
if component.get("id") != expected_id:
|
|
raise ValueError(f"{name}: expected app ID {expected_id}")
|
|
if not isinstance(component.get("version"), str) or not re.fullmatch(VERSION, component["version"]):
|
|
raise ValueError(f"{name}: invalid numeric release version")
|
|
if type(component.get("sequence")) is not int or not 0 < component["sequence"] <= 2147483647:
|
|
raise ValueError(f"{name}: invalid release sequence")
|
|
if component.get("bundled") is not True:
|
|
raise ValueError(f"{name}: every cell must be bundled for offline use")
|
|
# A package declares the oldest host interface it runs on, so apps
|
|
# that keep an older host still receive it.
|
|
host = component.get("host_api", ledger["host_api"])
|
|
if type(host) is not int or not ledger["oldest_host_api"] <= host <= ledger["host_api"]:
|
|
raise ValueError(f"{name}: host_api must be between oldest_host_api and host_api")
|
|
changelog = root / "apps" / source / "CHANGELOG.md"
|
|
headings = re.findall(r"^## \[([^\]]+)\] - ([^\n]+)$", changelog.read_text(), re.M)
|
|
if not headings or not re.fullmatch(VERSION, headings[0][0]):
|
|
raise ValueError(f"{name}: first changelog entry must be a numeric release")
|
|
date.fromisoformat(headings[0][1])
|
|
if headings[0][0] != component["version"]:
|
|
raise ValueError(f"{name}: changelog and ledger differ; run ./update_version.sh --cell {name}")
|
|
return ledger
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
|
|
args = parser.parse_args()
|
|
try:
|
|
validate(args.root)
|
|
except (OSError, KeyError, ValueError, TypeError) as error:
|
|
print(f"Package version check failed: {error}", file=sys.stderr)
|
|
return 1
|
|
print("Independent package changelogs, versions, sequences and bundled apps agree")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|