Repository object · implementation
Check
Accepted implementation in the public catalog.
- Source path
src/epistemedia/check.py- Media type
text/x-python- Object ID
em:implementation:sha256:0a219a04d2f463b59beb167c74f24f4822e9145e47f7bef517412eea1d016744- Content digest
ed730858f301bada95de37bbd48ed60402c264e7df7b34f4ce677f478cebd583
Also filed under
Source content
"""One local and CI validation contract for accepted repository candidates."""
from __future__ import annotations
import hashlib
import subprocess
import sys
import tempfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
PUBLIC = ROOT / "generated" / "public"
def source_state() -> bytes:
return subprocess.check_output(
["git", "status", "--porcelain=v1", "--untracked-files=all"], cwd=ROOT
)
def tree_inventory(root: Path) -> list[tuple[str, str]]:
return [
(path.relative_to(root).as_posix(), hashlib.sha256(path.read_bytes()).hexdigest())
for path in sorted(root.rglob("*"))
if path.is_file()
]
def run(label: str, *args: str, quiet: bool = False) -> None:
print(f"==> {label}", flush=True)
subprocess.run(
[sys.executable, *args],
cwd=ROOT,
check=True,
stdout=subprocess.DEVNULL if quiet else None,
)
def main() -> int:
before = source_state()
with tempfile.TemporaryDirectory(prefix="epistemedia-check-") as temporary:
second = Path(temporary) / "public"
run("validate accepted inputs", "-m", "epistemedia", "validate")
run(
"build public projection",
"-m",
"epistemedia",
"build",
"--output",
str(PUBLIC),
quiet=True,
)
run("run tests", "-m", "pytest", "-q")
run("audit public projection", "-m", "epistemedia", "audit", "--public", str(PUBLIC))
run(
"build independent comparison projection",
"-m",
"epistemedia",
"build",
"--output",
str(second),
quiet=True,
)
if tree_inventory(PUBLIC) != tree_inventory(second):
raise SystemExit("generated public projection differs across independent builds")
print("==> deterministic public projection verified", flush=True)
after = source_state()
if before != after:
print("Repository state changed while make check was running.", file=sys.stderr)
print("Before:\n" + before.decode(errors="replace"), file=sys.stderr)
print("After:\n" + after.decode(errors="replace"), file=sys.stderr)
return 1
print("==> source-tree state unchanged", flush=True)
return 0
if __name__ == "__main__":
raise SystemExit(main())
Build receipt
Reproduce this projection
- Catalog
em:catalog:sha256:9bfc972213cba2cde167386103dc2c011ee74639fb7f0794c54120fbbdef1a5d- Frontier
em:frontier:sha256:f33be3eae4c75232d56750ef9a1aa79d96274ece3417d65a75c1391bf61a81bf- Accepted commit
f92846570180dfa4511263f8ba98ecd18f7772c9- Epistemic policy
commons-balanced-v0.1- Disclosure policy
public-noninterference-v0.1- Compiler
epistemedia/0.2.0