Repository navigation
release: attach the verified producer archives to the hub release #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0edc6f4
b5df1ed
e36fa0f
7ad38d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import hashlib | ||
| import json | ||
| import re | ||
| from urllib.parse import urlsplit | ||
|
|
||
| import release_pair as pair | ||
| from release_sources import RELEASE_TAG | ||
|
|
@@ -96,6 +97,58 @@ def version(value): | |
| return v | ||
|
|
||
|
|
||
| def asset_descriptor(obj, versions): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
high coupling complexity (Ca·Ce = 15). Grounded coupling-delta finding (deterministic), not an LLM guess. |
||
| """Validate one producer filename and its provenance; return its required kind.""" | ||
| keys(obj, ("name", "size", "sha256", "source")) | ||
| name = match(r"[A-Za-z0-9][A-Za-z0-9_.-]*", obj["name"]) | ||
| require(not name.startswith(("release-", "consumer-", "facts-", "delivery-")), | ||
| "reserved attachment name") | ||
| positive(obj["size"]) | ||
| match(SHA, obj["sha256"]) | ||
| source = obj["source"] | ||
| require(isinstance(source, str) and source.isascii() | ||
| and not any(c.isspace() or ord(c) < 32 or ord(c) == 127 for c in source), | ||
| "unsafe attachment source") | ||
| try: | ||
| parsed = urlsplit(source) | ||
| except ValueError: | ||
| raise Invalid("unsafe attachment source") from None | ||
| require(parsed.scheme == "https" and parsed.netloc in | ||
| ("github.com", "registry.npmjs.org", "files.pythonhosted.org") | ||
| and not parsed.query and not parsed.fragment | ||
| and source == "https://" + parsed.netloc + parsed.path, | ||
| "unexpected attachment origin") | ||
| parts = parsed.path.split("/") | ||
| require(parts[0] == "" and all(part not in ("", ".", "..") for part in parts[1:]) | ||
| and re.fullmatch(r"/[A-Za-z0-9_@./-]+", parsed.path) is not None | ||
| and parts[-1] == name, "unsafe attachment path") | ||
| if parsed.netloc == "registry.npmjs.org": | ||
| require(parsed.path == "/@pineforge/codegen-pyodide/-/" + name | ||
| and name.endswith((".tgz", ".tar.gz")), "unexpected npm attachment") | ||
| return "npm" | ||
| if parsed.netloc == "files.pythonhosted.org": | ||
| require(name.endswith(".tar.gz"), "unexpected sdist attachment") | ||
| return "sdist" | ||
| engine = versions["engine"] | ||
| for arch in ("x86_64", "aarch64"): | ||
| expected = f"pineforge-v{engine['version']}-linux-{arch}.tar.gz" | ||
| if name == expected: | ||
| require(source == f"https://github.com/pineforge-4pass/pineforge-engine/releases/download/{engine['tag']}/{name}", | ||
| "unexpected engine attachment source") | ||
| return arch | ||
| raise Invalid("unexpected engine attachment") | ||
|
|
||
|
|
||
| def validate_assets(assets, versions): | ||
| require(type(assets) is list and len(assets) == 4, "incomplete attachment inventory") | ||
| kinds = [asset_descriptor(obj, versions) for obj in assets] | ||
| names = [obj["name"] for obj in assets] | ||
| require(len(set(names)) == len(names) and names == sorted(names), | ||
| "attachment names must be unique and sorted") | ||
| require(set(kinds) == {"npm", "sdist", "x86_64", "aarch64"}, "unexpected attachment inventory") | ||
| return assets | ||
|
|
||
|
|
||
| def parity_capable(release): | ||
| # parity_bundle uses the byte primitives above; import the cutoff lazily | ||
| # so the shared byte contract does not introduce an import cycle. | ||
|
|
@@ -155,7 +208,8 @@ def parity_child_digests(image): | |
|
|
||
|
|
||
| def validate(manifest): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
fans out to 7 callees (efferent coupling). Grounded coupling-delta finding (deterministic), not an LLM guess. |
||
| keys(manifest, MANIFEST_KEYS) | ||
| require(type(manifest) is dict and set(manifest) in (MANIFEST_KEYS, MANIFEST_KEYS | {"assets"}), | ||
| "unexpected object fields") | ||
| require(manifest["schema"] == SCHEMA, "unsupported release schema") | ||
| v = version(manifest["release_version"]) | ||
| require(type(manifest["prerelease"]) is bool and manifest["prerelease"] == v.prerelease, | ||
|
|
@@ -206,14 +260,17 @@ def validate(manifest): | |
| match(COMMIT, facts["commit"]) | ||
| match(SHA, facts["sha256"]) | ||
| require(facts["path"] == "facts/facts.json" and facts["release_key"] == str(v), "unexpected facts identity") | ||
| if "assets" in manifest: | ||
| validate_assets(manifest["assets"], versions) | ||
| return manifest | ||
|
|
||
|
|
||
| def payload(raw): | ||
| manifest = validate(decode(raw)) | ||
| require(canonical(manifest) == raw, "noncanonical manifest bytes") | ||
| digest = sha256(raw) | ||
| return {**manifest, "event_id": "sha256:" + digest, "manifest": {"asset": ASSET, "sha256": digest}} | ||
| return {**{key: manifest[key] for key in MANIFEST_KEYS}, | ||
| "event_id": "sha256:" + digest, "manifest": {"asset": ASSET, "sha256": digest}} | ||
|
|
||
|
|
||
| def validate_candidate(obj): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
producer()fans out to 10 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.