Check locked sources afresh before Play screenshot publishing

This commit is contained in:
waozi committed 2026-10-08 23:44:55 -03:00
1 parent eafa106a86
commit c34602893e
4 files changed
+81 -2

No files matched your search

+4 -1
View File
@@ -1173,7 +1173,10 @@ social-post-dry-run:
screenshot: $(TARGET)
./scripts/generate-screenshots.sh "$(TARGET)"
.PHONY: screenshot-verify screenshot-review screenshot-export play-preflight lumi-promo
.PHONY: screenshot-verify screenshot-review screenshot-export screenshot-source-check play-preflight lumi-promo
screenshot-source-check: $(ZI2C_BIN) | build-laws
@ZI_CHECK_DEFINES="$(ZI_NATIVE_DEFINES)" python3 scripts/check-zi-sources.py $(ZI2ZIR_BIN) $(KRYON_DIR)/src/ui $(ZIRAN_DIR)/std $(KSS_DIR)/src
screenshot-verify:
python3 scripts/screenshot-harness.py verify
+2
View File
@@ -104,6 +104,8 @@ source, scene definitions, Kryon, binaries, bundles, or screenshot bytes
invalidates publishing preflight. A historical capture can still be visually
reviewed and used for a review video; Play requires a fresh capture of the
current locked build. Local Kryon preview builds cannot pass Play preflight.
Preflight checks every dependency against its locked commit and runs a fresh
source check, so reused incremental preview outputs cannot hide missing imports.
Keep credentials in the ignored `.env.play` using `.env.play.example`.
The uploader defaults to validating and discarding its remote edit. After
review, `PLAY_COMMIT=1 python3 scripts/upload-play-screenshots.py` validates
+36
View File
@@ -51,6 +51,41 @@ def dependency_digest(root):
return result.hexdigest()
def check_locked_sources():
"""Check pins and compile afresh, without trusting incremental stamps."""
lock = json.loads((ROOT / "ziran.lock").read_text())
aliases = {package_id: name.replace("_", "-")
for name, package_id in lock["root"]["dependencies"].items()}
packages = [(aliases.get(package["id"], package["name"].casefold()),
package["commit"]) for package in lock["packages"]]
packages.append(("ziran", lock["toolchain"]["commit"]))
for name, commit in packages:
path = ROOT / "build/packages" / name
require(path.is_dir(), f"missing locked package: {name}")
head = subprocess.check_output(
["git", "-C", str(path), "rev-parse", "HEAD"], text=True).strip()
require(head == commit, f"package {name} does not match ziran.lock")
changed = subprocess.check_output(
["git", "-C", str(path), "status", "--porcelain",
"--ignore-submodules=none"], text=True).strip()
require(not changed, f"modified locked package: {name}")
env = dict(os.environ)
for name in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY",
"DBUS_SESSION_BUS_ADDRESS", "MAKEFLAGS", "MFLAGS",
"MAKEOVERRIDES"):
env.pop(name, None)
result = subprocess.run(
["make", "--no-print-directory", "screenshot-source-check",
"PACKAGE_FLAGS=--locked", "KRYON_DIR=build/packages/kryon",
"KSS_DIR=build/packages/kss", "ZIRAN_DIR=build/packages/ziran"],
cwd=ROOT, env=env, capture_output=True,
text=True, timeout=120)
require(result.returncode == 0,
"current source does not compile against locked packages; "
"finish dependency updates before Play publishing:\n" +
result.stdout.strip() + "\n" + result.stderr.strip())
def config():
value = json.loads(CONFIG.read_text())
scenes = value["scenes"]
@@ -231,6 +266,7 @@ def export():
def store_preflight(images_root=IMAGES):
value = verify(reviewed=True)
require(Path(value["kryon_source"]).resolve() == (ROOT / "build/packages/kryon").resolve(), "captures used a local Kryon preview; rebuild and recapture with locked packages before Play publishing")
check_locked_sources()
receipt = json.loads((images_root / "screenshot-review.json").read_text())
require(receipt["capture_sha256"] == digest(OUTPUT / "capture.json"), "store assets are from a different capture")
selected = [row for row in value["rows"] if row["store"] and row["store_dir"]]
+39 -1
View File
@@ -24,6 +24,44 @@ def rejects(operation, message):
raise AssertionError(message)
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
for name in ("kryon", "daochi-client", "ziran"):
(root / "build/packages" / name).mkdir(parents=True)
(root / "build/zi-check").mkdir()
(root / "build/zi-check/native.fresh").touch()
(root / "ziran.lock").write_text(json.dumps(dict(
root=dict(dependencies=dict(kryon="ui", daochi_client="client")),
packages=[dict(id="ui", name="Kryon", commit="pinned"),
dict(id="client", name="DaochiClient", commit="pinned")],
toolchain=dict(commit="pinned"))))
def git_result(command, **kwargs):
return "pinned\n" if "rev-parse" in command else ""
environment = dict(DISPLAY=":0", WAYLAND_DISPLAY="wayland-0",
XAUTHORITY="owner", DBUS_SESSION_BUS_ADDRESS="owner",
MAKEFLAGS="KRYON_DIR=preview")
with patch.object(harness, "ROOT", root), patch.object(harness.subprocess,
"check_output", side_effect=git_result), patch.dict(os.environ, environment), \
patch.object(harness.subprocess, "run", return_value=subprocess.CompletedProcess(
[], 0, "checked", "")) as compiler:
harness.check_locked_sources()
assert compiler.call_count == 1, "an incremental stamp skipped the fresh check"
assert "screenshot-source-check" in compiler.call_args.args[0]
assert "KRYON_DIR=build/packages/kryon" in compiler.call_args.args[0]
assert not any(name in compiler.call_args.kwargs["env"] for name in environment)
compiler.return_value = subprocess.CompletedProcess([], 1, "", "missing import")
rejects(harness.check_locked_sources, "missing locked import passed preflight")
for head, status in (("other commit\n", ""),
("pinned\n", " M src/ui/scroll.zi\n")):
def changed_git_result(command, **kwargs):
return head if "rev-parse" in command else status
with patch.object(harness, "ROOT", root), patch.object(harness.subprocess,
"check_output", side_effect=changed_git_result), patch.object(harness.subprocess,
"run") as compiler:
rejects(harness.check_locked_sources, "wrong or dirty pin passed preflight")
assert not compiler.called, "a wrong dependency reached the compiler"
definition = harness.config()
assert len(definition["scenes"]) == 16 and len(definition["buckets"]) == 4
assert next(b for b in definition["buckets"] if b["name"] == "phone")["scale"] == 25
@@ -76,4 +114,4 @@ with tempfile.TemporaryDirectory() as temporary:
manifest["source_sha256"] = "old"
harness.write_json(output / "capture.json", manifest)
rejects(lambda: harness.verify(output), "stale source passed")
print("PASS screenshot coverage and release gates: blank, dimensions, review, tampering, build, completeness and source")
print("PASS screenshot coverage and release gates: locked imports, pins, blank, dimensions, review, tampering, build, completeness and source")