Spaces:
Running
Running
Sync GitHub source a5d1879c781062f43a2a2102dd773128fc9662f2
Browse filesCanonical source: https://github.com/noqt/Lumi-Eggcracker/commit/a5d1879c781062f43a2a2102dd773128fc9662f2
Files changed (6)
36 unmodified lines3738394041424344144 unmodified lines18919019119219319419561 unmodified lines257258259260261262263264336 unmodified lines601602603604605606607608230 unmodified lines83984084184284384436 unmodified lines"size": 10537},"README.md": {"sha256": "829342729f67f8fb086f5645f1946125970a26710551d398ac9e10ad4db5a713","size": 39135},"RELEASE_NOTES.md": {"sha256": "64d330d0f297b15720fc65e6347ececc1b99a917a597d405ebfac04baf3222ea",144 unmodified lines"size": 4101},"index.html": {"sha256": "51dd6177b9bdbb164f87aeeb7ed22318064c82aa7b40c9e95714610f5708e510","size": 22790},"integrations/prometheus/eggcracker.rules.yml": {61 unmodified lines"size": 4746},"scripts/collect_supported_path_receipt.py": {"sha256": "528b3dc1ab4cb7999225f1d94165ece7f48282f83ef87183c633307103c368e0","size": 10593},"scripts/containment_probe.py": {"sha256": "104009c1c3f758633012826f3192d3c1f6433977f96b4c80b4f8f8ddfacc26e4",336 unmodified lines"size": 6820},"tests/test_collect_supported_path_receipt.py": {"sha256": "79ae57bf3d78cac5fbe1b9d7db60462328f70cb17214bc75a5b5e7eff3ea0eef","size": 15595},"tests/test_containment.py": {"sha256": "168e840c8928ed5521a1f11080b4bb5679c145f66635c8b3785a2fca60f19f06",230 unmodified lines},"schema": "noqt.huggingface_manifest.v1","source_repository": "https://github.com/noqt/Lumi-Eggcracker","source_revision": "4f3515c2e4cc473e7a2a3c10cbda496a3c889324","source_url": "https://github.com/noqt/Lumi-Eggcracker/commit/4f3515c2e4cc473e7a2a3c10cbda496a3c889324"}36 unmodified lines3738394041424344144 unmodified lines18919019119219319419561 unmodified lines257258259260261262263264336 unmodified lines601602603604605606607608230 unmodified lines83984084184284384436 unmodified lines"size": 10537},"README.md": {"sha256": "9769457cb12f80f20b11f3f3d55ba43a0860c3d36d4cd721b74a2762c8be1464","size": 40484},"RELEASE_NOTES.md": {"sha256": "64d330d0f297b15720fc65e6347ececc1b99a917a597d405ebfac04baf3222ea",144 unmodified lines"size": 4101},"index.html": {"sha256": "bf6a2388a76492e642b8a716dc2a05da4a9ed1171bca85b7690978c34453660c","size": 22790},"integrations/prometheus/eggcracker.rules.yml": {61 unmodified lines"size": 4746},"scripts/collect_supported_path_receipt.py": {"sha256": "88bd859e24e42ea8585bc484c6e46726865fc5cc9c1c37597b8d50ae397b2bfa","size": 18878},"scripts/containment_probe.py": {"sha256": "104009c1c3f758633012826f3192d3c1f6433977f96b4c80b4f8f8ddfacc26e4",336 unmodified lines"size": 6820},"tests/test_collect_supported_path_receipt.py": {"sha256": "a320bd635bec70932121b5f633fc451fd1d7c117e0477f4d42b7fae2edc49769","size": 27694},"tests/test_containment.py": {"sha256": "168e840c8928ed5521a1f11080b4bb5679c145f66635c8b3785a2fca60f19f06",230 unmodified lines},"schema": "noqt.huggingface_manifest.v1","source_repository": "https://github.com/noqt/Lumi-Eggcracker","source_revision": "a5d1879c781062f43a2a2102dd773128fc9662f2","source_url": "https://github.com/noqt/Lumi-Eggcracker/commit/a5d1879c781062f43a2a2102dd773128fc9662f2"}
12345658 unmodified lines65666768697071{"manifest": "HUGGINGFACE_MANIFEST.json","manifest_sha256": "c4f375e954b02597f9cdfa0e4f512aa938f48aeb736afaa996dc41cf6bc3c20e","mirrored_files": 194,"mode": "DERIVED_READ_ONLY_MIRROR","release_reference": {58 unmodified lines},"schema": "noqt.huggingface_sync.v1","source_repository": "https://github.com/noqt/Lumi-Eggcracker","source_revision": "4f3515c2e4cc473e7a2a3c10cbda496a3c889324","source_url": "https://github.com/noqt/Lumi-Eggcracker/commit/4f3515c2e4cc473e7a2a3c10cbda496a3c889324","target": "https://huggingface.co/spaces/noqt/eggcracker"}12345658 unmodified lines65666768697071{"manifest": "HUGGINGFACE_MANIFEST.json","manifest_sha256": "9ec261a44fd95098441b39d501ad0e602fafddfde6c99eba950d1b731484824d","mirrored_files": 194,"mode": "DERIVED_READ_ONLY_MIRROR","release_reference": {58 unmodified lines},"schema": "noqt.huggingface_sync.v1","source_repository": "https://github.com/noqt/Lumi-Eggcracker","source_revision": "a5d1879c781062f43a2a2102dd773128fc9662f2","source_url": "https://github.com/noqt/Lumi-Eggcracker/commit/a5d1879c781062f43a2a2102dd773128fc9662f2","target": "https://huggingface.co/spaces/noqt/eggcracker"}
10 unmodified lines11121314151617347 unmodified lines36536636736836937010 unmodified lines---> Official noqt Hugging Face distribution, generated from GitHub commit> [`4f3515c2e4cc`](https://github.com/noqt/Lumi-Eggcracker/commit/4f3515c2e4cc473e7a2a3c10cbda496a3c889324). This Space distributes the source for> discovery and cloning; Eggcracker itself runs on a supported native Linux> host, not on Hugging Face. A snapshot is called current only after the> release-linked sync job verifies its returned Hub commit and full manifest.347 unmodified linesReview the local JSON before deciding whether to share it; `permission_to_quote`records permission, but does not send or publish anything.### Qualify the offline boundaryOn the disposable native Ubuntu host, qualify the offline network primitive10 unmodified lines11121314151617347 unmodified lines36536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140210 unmodified lines---> Official noqt Hugging Face distribution, generated from GitHub commit> [`a5d1879c7810`](https://github.com/noqt/Lumi-Eggcracker/commit/a5d1879c781062f43a2a2102dd773128fc9662f2). This Space distributes the source for> discovery and cloning; Eggcracker itself runs on a supported native Linux> host, not on Hugging Face. A snapshot is called current only after the> release-linked sync job verifies its returned Hub commit and full manifest.347 unmodified linesReview the local JSON before deciding whether to share it; `permission_to_quote`records permission, but does not send or publish anything.#### Verify a final receipt offlineAfter a receipt has been written, verify that one final local file still hasthe closed v1 shape and the expected source identities without writing, usingroot, or making a network request:```shpython3 scripts/collect_supported_path_receipt.py \--verify-receipt ./supported-path-receipt.json \--expect-source-commit <exact-40-lowercase-hex-source-commit> \--expect-source-tree-sha256 <exact-64-lowercase-hex-source-tree-sha256>```Verification reads at most the receipt size bound from one local regular file,rejects links, duplicate members, invalid UTF-8, and closed-schema,timestamp, privacy or outcome drift, and compares the observed source IDs withthe two expected IDs. On success it emits only a bounded `outcome` and the`receipt_sha256` of the exact bounded bytes that were validated:```json{"outcome":"supported-success","receipt_sha256":"<64-lowercase-hex-digest>"}```Any verification failure emits a fixed, non-echoing diagnostic and exits withstatus 2.This establishes schema and source-ID consistency and identifies the validatedbytes. It is not receipt authenticity or tamper resistance without a trustedreference, does not prove the run or containment, and does not grantpermission to quote; the receipt's `permission_to_quote` field still requiresseparate review.### Qualify the offline boundaryOn the disposable native Ubuntu host, qualify the offline network primitive
3 unmodified lines45678910638 unmodified lines6496506516526536546553 unmodified lines<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Lumi Eggcracker is noqt's native Linux kill switch for unapproved supported local-AI workloads. Clone the complete source from Hugging Face."><meta name="noqt-source-revision" content="4f3515c2e4cc473e7a2a3c10cbda496a3c889324"><meta name="theme-color" content="#090a0c"><title>Lumi Eggcracker — Native Linux AI kill switch</title><style>638 unmodified lines<section><div class="shell source-bar"><div><div class="source-id">SOURCE COMMIT · 4f3515c2e4cc</div><h2>Inspect every line.</h2><p>Complete source, tests, qualification documents and reproducible proof tooling are distributed in this repository.</p></div>3 unmodified lines45678910638 unmodified lines6496506516526536546553 unmodified lines<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Lumi Eggcracker is noqt's native Linux kill switch for unapproved supported local-AI workloads. Clone the complete source from Hugging Face."><meta name="noqt-source-revision" content="a5d1879c781062f43a2a2102dd773128fc9662f2"><meta name="theme-color" content="#090a0c"><title>Lumi Eggcracker — Native Linux AI kill switch</title><style>638 unmodified lines<section><div class="shell source-bar"><div><div class="source-id">SOURCE COMMIT · a5d1879c7810</div><h2>Inspect every line.</h2><p>Complete source, tests, qualification documents and reproducible proof tooling are distributed in this repository.</p></div>
1234567897 unmodified lines17181920212250 unmodified lines73747576777838 unmodified lines11711811912012112212312412512612712812913013113213313413513613713813914014114246 unmodified lines18919019119219319419519619762 unmodified lines260261262263264265266267268269270271272273274275276277278279280281282#!/usr/bin/env python3"""Create one explicitly opted-in, redacted local supported-path receipt."""from __future__ import annotationsimport argparseimport jsonimport osimport re7 unmodified linesMAX_INPUT_BYTES = 4_096MAX_RECEIPT_BYTES = 8_192SCHEMA_VERSION = "lumi-eggcracker-supported-path-receipt-v1"SUPPORTED_ENVIRONMENT = "disposable-native-ubuntu-24.04-cgroup-v2"SUPPORTED_PATH = "containment-primitive-probe"EXACT_COMMAND = (50 unmodified linesraise ReceiptInputError("invalid command-line arguments")def _unique_object(pairs: list[tuple[str, object]]) -> dict[str, object]:value: dict[str, object] = {}for name, item in pairs:38 unmodified linesraise ReceiptInputError("source_tree_sha256 is not an exact lowercase tree identity")def _validate_input(value: object) -> dict[str, object]:if not isinstance(value, dict):raise ReceiptInputError("input root must be an object")_require_exact_fields(value, INPUT_FIELDS, "input")fixed_strings = {"supported_environment": SUPPORTED_ENVIRONMENT,"supported_path": SUPPORTED_PATH,"exact_command": EXACT_COMMAND,"expected_result": EXPECTED_RESULT,}for field, expected in fixed_strings.items():if not isinstance(value[field], str) or value[field] != expected:raise ReceiptInputError(f"input field {field} is not the supported fixed value")permission = value["permission_to_quote"]if not isinstance(permission, bool):raise ReceiptInputError("permission_to_quote must be an explicit boolean")observed = value["observed_result"]if not isinstance(observed, dict):raise ReceiptInputError("observed_result must be an object")outcome = observed.get("outcome")46 unmodified lineselse:raise ReceiptInputError("observed_result outcome is not supported")return dict(value)def _safe_output_parent(destination: Path) -> Path:parent = Path(os.path.abspath(destination.parent))try:62 unmodified linesdef main(argv: Sequence[str] | None = None) -> int:parser = SafeArgumentParser(description="write one explicitly opted-in local supported-path receipt")parser.add_argument("--i-opt-in-to-write-local-receipt",action="store_true",help="explicitly allow this command to write the local redacted receipt",)parser.add_argument("--input", type=Path, required=True, help="bounded local JSON input")parser.add_argument("--output", type=Path, required=True, help="new local JSON receipt")try:arguments = parser.parse_args(argv)if not arguments.i_opt_in_to_write_local_receipt:raise ReceiptInputError("explicit opt-in is required; no receipt was written")value = _validate_input(_read_input(arguments.input))_write_new_receipt(arguments.output, _build_receipt(value))except ReceiptInputError as error:print(f"NOT WRITTEN: {error}", file=sys.stderr)return 2print("WROTE local redacted supported-path receipt")return 0123456789107 unmodified lines181920212223242526272829303132333435363750 unmodified lines8889909192939495969738 unmodified lines13613713813914014114246 unmodified lines18919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034162 unmodified lines404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484#!/usr/bin/env python3"""Create or verify one bounded, redacted local supported-path receipt."""from __future__ import annotationsimport argparseimport hashlibimport jsonimport osimport re7 unmodified linesMAX_INPUT_BYTES = 4_096MAX_RECEIPT_BYTES = 8_192SCHEMA_VERSION = "lumi-eggcracker-supported-path-receipt-v1"RECEIPT_FIELDS = {"schema_version","recorded_at_utc","supported_environment","supported_path","exact_command","expected_result","observed_result","permission_to_quote","privacy",}TIMESTAMP_PATTERN = re.compile(r"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z")SUPPORTED_ENVIRONMENT = "disposable-native-ubuntu-24.04-cgroup-v2"SUPPORTED_PATH = "containment-primitive-probe"EXACT_COMMAND = (50 unmodified linesraise ReceiptInputError("invalid command-line arguments")def _reject_nonstandard_number(_value: str) -> object:raise ReceiptInputError("receipt contains a non-standard number")def _unique_object(pairs: list[tuple[str, object]]) -> dict[str, object]:value: dict[str, object] = {}for name, item in pairs:38 unmodified linesraise ReceiptInputError("source_tree_sha256 is not an exact lowercase tree identity")def _validate_observed_result(observed: object) -> dict[str, object]:if not isinstance(observed, dict):raise ReceiptInputError("observed_result must be an object")outcome = observed.get("outcome")46 unmodified lineselse:raise ReceiptInputError("observed_result outcome is not supported")return dict(observed)def _validate_input(value: object) -> dict[str, object]:if not isinstance(value, dict):raise ReceiptInputError("input root must be an object")_require_exact_fields(value, INPUT_FIELDS, "input")fixed_strings = {"supported_environment": SUPPORTED_ENVIRONMENT,"supported_path": SUPPORTED_PATH,"exact_command": EXACT_COMMAND,"expected_result": EXPECTED_RESULT,}for field, expected in fixed_strings.items():if not isinstance(value[field], str) or value[field] != expected:raise ReceiptInputError(f"input field {field} is not the supported fixed value")permission = value["permission_to_quote"]if not isinstance(permission, bool):raise ReceiptInputError("permission_to_quote must be an explicit boolean")_validate_observed_result(value["observed_result"])return dict(value)def _safe_receipt_parent(path: Path) -> Path:parent = Path(os.path.abspath(path.parent))try:for candidate in (parent, *parent.parents):metadata = candidate.lstat()if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode):raise ReceiptInputError("receipt parent must contain no links or non-directories")except ReceiptInputError:raiseexcept (OSError, ValueError) as error:raise ReceiptInputError("receipt parent is not an existing regular directory") from errorreturn parentdef _read_final_receipt(path: Path) -> tuple[object, str]:_safe_receipt_parent(path)descriptor = -1try:metadata = path.lstat()if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISREG(metadata.st_mode):raise ReceiptInputError("receipt must be a regular file, not a link")flags = os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0) | getattr(os, "O_BINARY", 0)descriptor = os.open(path, flags)with os.fdopen(descriptor, "rb") as handle:descriptor = -1current = os.fstat(handle.fileno())if stat.S_ISLNK(current.st_mode) or not stat.S_ISREG(current.st_mode):raise ReceiptInputError("receipt must be a regular file, not a link")encoded = handle.read(MAX_RECEIPT_BYTES + 1)except ReceiptInputError:raiseexcept (OSError, ValueError) as error:raise ReceiptInputError("receipt could not be read") from errorfinally:if descriptor >= 0:try:os.close(descriptor)except OSError:passif len(encoded) > MAX_RECEIPT_BYTES:raise ReceiptInputError("receipt exceeds its safe size bound")receipt_sha256 = hashlib.sha256(encoded).hexdigest()try:value = json.loads(encoded.decode("utf-8"),object_pairs_hook=_unique_object,parse_constant=_reject_nonstandard_number,)except ReceiptInputError:raiseexcept (UnicodeError, json.JSONDecodeError, RecursionError, ValueError) as error:raise ReceiptInputError("receipt is not bounded UTF-8 JSON") from errorreturn value, receipt_sha256def _validate_expected_source_identity(value: object, pattern: re.Pattern[str], label: str) -> str:if not isinstance(value, str) or pattern.fullmatch(value) is None:raise ReceiptInputError(f"{label} is not an exact lowercase source identity")return valuedef _validate_final_receipt(value: object,*,expected_source_commit: str,expected_source_tree_sha256: str,) -> str:if not isinstance(value, dict):raise ReceiptInputError("receipt root must be an object")_require_exact_fields(value, RECEIPT_FIELDS, "receipt")fixed_strings = {"schema_version": SCHEMA_VERSION,"supported_environment": SUPPORTED_ENVIRONMENT,"supported_path": SUPPORTED_PATH,"exact_command": EXACT_COMMAND,"expected_result": EXPECTED_RESULT,}for field, expected in fixed_strings.items():if not isinstance(value[field], str) or value[field] != expected:raise ReceiptInputError(f"receipt field {field} is not the supported fixed value")recorded_at = value["recorded_at_utc"]if not isinstance(recorded_at, str) or TIMESTAMP_PATTERN.fullmatch(recorded_at) is None:raise ReceiptInputError("recorded_at_utc is not an exact UTC timestamp")try:datetime.strptime(recorded_at, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=UTC)except ValueError as error:raise ReceiptInputError("recorded_at_utc is not an exact UTC timestamp") from errorpermission = value["permission_to_quote"]if not isinstance(permission, bool):raise ReceiptInputError("permission_to_quote must be an explicit boolean")privacy = value["privacy"]if not isinstance(privacy, dict):raise ReceiptInputError("privacy does not match the closed schema")_require_exact_fields(privacy, set(PRIVACY), "privacy")for field, expected in PRIVACY.items():actual = privacy[field]if type(actual) is not type(expected) or actual != expected:raise ReceiptInputError("privacy does not match the required redacted values")observed = _validate_observed_result(value["observed_result"])_validate_expected_source_identity(expected_source_commit, SOURCE_COMMIT_PATTERN, "expected source_commit")_validate_expected_source_identity(expected_source_tree_sha256, SOURCE_TREE_PATTERN, "expected source_tree_sha256")if (observed["source_commit"] != expected_source_commitor observed["source_tree_sha256"] != expected_source_tree_sha256):raise ReceiptInputError("receipt source identity does not match the expected identities")outcome = observed["outcome"]if not isinstance(outcome, str):raise ReceiptInputError("observed_result outcome is not supported")return outcomedef _safe_output_parent(destination: Path) -> Path:parent = Path(os.path.abspath(destination.parent))try:62 unmodified linesdef main(argv: Sequence[str] | None = None) -> int:parser = SafeArgumentParser(description="write or verify one bounded local supported-path receipt")verification_requested = "--verify-receipt" in (sys.argv[1:] if argv is None else argv)modes = parser.add_mutually_exclusive_group()modes.add_argument("--i-opt-in-to-write-local-receipt",action="store_true",help="explicitly allow this command to write the local redacted receipt",)modes.add_argument("--verify-receipt",type=Path,help="read and verify one final local JSON receipt without writing",)parser.add_argument("--expect-source-commit",help="expected exact lowercase source commit identity for verification",)parser.add_argument("--expect-source-tree-sha256",help="expected exact lowercase source tree identity for verification",)parser.add_argument("--input", type=Path, help="bounded local JSON input")parser.add_argument("--output", type=Path, help="new local JSON receipt")try:arguments = parser.parse_args(argv)verification_requested = arguments.verify_receipt is not Noneif arguments.verify_receipt is not None:if (arguments.i_opt_in_to_write_local_receiptor arguments.input is not Noneor arguments.output is not None):raise ReceiptInputError("verification mode cannot be combined with write mode")if (arguments.expect_source_commit is Noneor arguments.expect_source_tree_sha256 is None):raise ReceiptInputError("verification requires both expected source identities")_validate_expected_source_identity(arguments.expect_source_commit, SOURCE_COMMIT_PATTERN, "expected source_commit")_validate_expected_source_identity(arguments.expect_source_tree_sha256,SOURCE_TREE_PATTERN,"expected source_tree_sha256",)receipt, receipt_sha256 = _read_final_receipt(arguments.verify_receipt)outcome = _validate_final_receipt(receipt,expected_source_commit=arguments.expect_source_commit,expected_source_tree_sha256=arguments.expect_source_tree_sha256,)print(json.dumps({"outcome": outcome, "receipt_sha256": receipt_sha256},sort_keys=True,separators=(",", ":"),))return 0if (arguments.expect_source_commit is not Noneor arguments.expect_source_tree_sha256 is not None):raise ReceiptInputError("expected source identities require --verify-receipt")if not arguments.i_opt_in_to_write_local_receipt:raise ReceiptInputError("explicit opt-in is required; no receipt was written")if arguments.input is None or arguments.output is None:raise ReceiptInputError("write mode requires --input and --output")value = _validate_input(_read_input(arguments.input))_write_new_receipt(arguments.output, _build_receipt(value))except ReceiptInputError as error:prefix = "NOT VERIFIED" if verification_requested else "NOT WRITTEN"print(f"{prefix}: {error}", file=sys.stderr)return 2print("WROTE local redacted supported-path receipt")return 0
123456115 unmodified lines122123124125126127232 unmodified lines360361362363364365from __future__ import annotationsimport astimport importlib.utilimport jsonimport os115 unmodified lines"collections","datetime","json","os","pathlib","re",232 unmodified linesself.assertNotIn(str(invalid_value), stderr.getvalue())self.assertFalse(output.exists())if __name__ == "__main__":unittest.main()1234567115 unmodified lines123124125126127128129232 unmodified lines362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618from __future__ import annotationsimport astimport hashlibimport importlib.utilimport jsonimport os115 unmodified lines"collections","datetime","json","hashlib","os","pathlib","re",232 unmodified linesself.assertNotIn(str(invalid_value), stderr.getvalue())self.assertFalse(output.exists())def write_final_receipt(self,directory: str,*,observed: dict[str, object] | None = None,quote: bool = False,suffix: bytes = b"\n",) -> tuple[Path, bytes]:receipt = collector._build_receipt(submission(quote=quote, observed=observed or success_observed()))encoded = (json.dumps(receipt, indent=2, sort_keys=True).encode("utf-8") + suffix)path = Path(directory) / "final-receipt.json"path.write_bytes(encoded)return path, encodeddef run_verifier(self,receipt: Path,*,source_commit: str = SOURCE_COMMIT,source_tree_sha256: str = SOURCE_TREE_SHA256,extra: list[str] | None = None,) -> tuple[int, StringIO, StringIO]:arguments = ["--verify-receipt",str(receipt),"--expect-source-commit",source_commit,"--expect-source-tree-sha256",source_tree_sha256,]if extra:arguments.extend(extra)stdout = StringIO()stderr = StringIO()with redirect_stdout(stdout), redirect_stderr(stderr):status = collector.main(arguments)return status, stdout, stderrdef test_verify_receipt_emits_only_outcome_and_digest_of_exact_bytes(self) -> None:with TemporaryDirectory() as directory:receipt, encoded = self.write_final_receipt(directory, suffix=b" \n")status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(0, status)self.assertEqual({"outcome": "supported-success","receipt_sha256": hashlib.sha256(encoded).hexdigest(),},json.loads(stdout.getvalue()),)self.assertEqual("", stderr.getvalue())def test_verify_receipt_accepts_reproducible_blocker_outcome(self) -> None:with TemporaryDirectory() as directory:receipt, _encoded = self.write_final_receipt(directory, observed=blocker_observed(), quote=True)status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(0, status)self.assertEqual("reproducible-blocker", json.loads(stdout.getvalue())["outcome"])self.assertEqual("", stderr.getvalue())def test_verify_receipt_rejects_schema_timestamp_privacy_and_outcome_drift(self) -> None:cases = (("schema_version", "other-schema"),("recorded_at_utc", "2026-13-14T00:00:00Z"),("permission_to_quote", "yes"),("privacy", {**collector.PRIVACY, "raw_output_collected": True}),("observed_result", success_observed(outcome="unsupported")),)for field, invalid_value in cases:with self.subTest(field=field), TemporaryDirectory() as directory:receipt_value = collector._build_receipt(submission(quote=False, observed=success_observed()))receipt_value[field] = invalid_valueencoded = (json.dumps(receipt_value, sort_keys=True) + "\n").encode("utf-8")receipt = Path(directory) / "receipt.json"receipt.write_bytes(encoded)status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertTrue(stderr.getvalue().startswith("NOT VERIFIED:"))self.assertNotIn(str(invalid_value), stderr.getvalue())def test_verify_receipt_rejects_duplicate_members_invalid_utf8_and_oversize(self) -> None:cases = (b'{"schema_version":"one","schema_version":"two"}',b"\xffprivate-marker",b" " * (collector.MAX_RECEIPT_BYTES + 1),)for encoded in cases:with self.subTest(encoded=encoded[:10]), TemporaryDirectory() as directory:receipt = Path(directory) / "receipt.json"receipt.write_bytes(encoded)status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertTrue(stderr.getvalue().startswith("NOT VERIFIED:"))self.assertNotIn("private-marker", stderr.getvalue())def test_verify_receipt_rejects_integer_digit_limit_without_file_changes(self) -> None:private_marker = "private-integer-limit-marker"digits = "9" * 4_301encoded = b'{"integer": ' + digits.encode("ascii") + b"}\n"self.assertLess(len(encoded), collector.MAX_RECEIPT_BYTES)with TemporaryDirectory() as directory:receipt = Path(directory) / f"{private_marker}.json"sibling = Path(directory) / "sibling.json"sibling_bytes = b"stable sibling\n"receipt.write_bytes(encoded)sibling.write_bytes(sibling_bytes)before_entries = sorted(path.name for path in Path(directory).iterdir())before_receipt_mtime = receipt.stat().st_mtime_nsbefore_sibling_mtime = sibling.stat().st_mtime_nsstatus, stdout, stderr = self.run_verifier(receipt)after_entries = sorted(path.name for path in Path(directory).iterdir())after_receipt_mtime = receipt.stat().st_mtime_nsafter_sibling_mtime = sibling.stat().st_mtime_nsafter_receipt_bytes = receipt.read_bytes()after_sibling_bytes = sibling.read_bytes()self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertEqual("NOT VERIFIED: receipt is not bounded UTF-8 JSON\n", stderr.getvalue())self.assertNotIn("Traceback", stderr.getvalue())self.assertNotIn(private_marker, stderr.getvalue())self.assertNotIn(digits, stderr.getvalue())self.assertEqual(before_entries, after_entries)self.assertEqual(encoded, after_receipt_bytes)self.assertEqual(before_receipt_mtime, after_receipt_mtime)self.assertEqual(sibling_bytes, after_sibling_bytes)self.assertEqual(before_sibling_mtime, after_sibling_mtime)@unittest.skipUnless(hasattr(os, "symlink"), "symlinks are unavailable")def test_verify_receipt_rejects_symlink_without_reading_target(self) -> None:with TemporaryDirectory() as directory:target, _encoded = self.write_final_receipt(directory)receipt = Path(directory) / "receipt-link.json"try:receipt.symlink_to(target)except OSError:self.skipTest("symlink creation is not permitted")status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertIn("regular file", stderr.getvalue())def test_verify_receipt_requires_matching_source_ids_and_read_only_mode(self) -> None:private_marker = "private-source-marker"with TemporaryDirectory() as directory:receipt, _encoded = self.write_final_receipt(directory)status, stdout, stderr = self.run_verifier(receipt, source_commit=private_marker)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertIn("exact lowercase source identity", stderr.getvalue())self.assertNotIn(private_marker, stderr.getvalue())status, stdout, stderr = self.run_verifier(receipt,extra=["--i-opt-in-to-write-local-receipt"],)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertEqual("NOT VERIFIED: invalid command-line arguments\n", stderr.getvalue())def test_verify_receipt_rejects_independent_valid_but_mismatched_source_ids(self) -> None:cases = (("commit", "c" * 40, SOURCE_TREE_SHA256),("tree", SOURCE_COMMIT, "d" * 64),)for label, expected_commit, expected_tree in cases:with self.subTest(identity=label), TemporaryDirectory() as directory:receipt, _encoded = self.write_final_receipt(directory)status, stdout, stderr = self.run_verifier(receipt,source_commit=expected_commit,source_tree_sha256=expected_tree,)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertTrue(stderr.getvalue().startswith("NOT VERIFIED:"))self.assertIn("does not match", stderr.getvalue())self.assertNotIn(expected_commit, stderr.getvalue())self.assertNotIn(expected_tree, stderr.getvalue())def test_verify_receipt_rejects_missing_and_additional_top_level_members(self) -> None:private_marker = "private-top-level-marker"cases = ("missing", "additional")for case in cases:with self.subTest(case=case), TemporaryDirectory() as directory:receipt_value = collector._build_receipt(submission(quote=False, observed=success_observed()))if case == "missing":receipt_value.pop("privacy")else:receipt_value[private_marker] = "private-top-level-value"receipt = Path(directory) / "receipt.json"receipt.write_text(json.dumps(receipt_value), encoding="utf-8")status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertIn("closed schema", stderr.getvalue())self.assertNotIn(private_marker, stderr.getvalue())self.assertNotIn("private-top-level-value", stderr.getvalue())def test_verify_receipt_rejects_non_regular_directory_path_without_echoing_it(self) -> None:private_marker = "private-receipt-directory"with TemporaryDirectory() as directory:receipt = Path(directory) / private_markerreceipt.mkdir()status, stdout, stderr = self.run_verifier(receipt)self.assertEqual(2, status)self.assertEqual("", stdout.getvalue())self.assertIn("regular file", stderr.getvalue())self.assertNotIn(private_marker, stderr.getvalue())def test_verify_receipt_does_not_create_or_modify_sibling_or_receipt_files(self) -> None:with TemporaryDirectory() as directory:receipt, encoded = self.write_final_receipt(directory)sibling = Path(directory) / "sibling.json"sibling_bytes = b"stable sibling\n"sibling.write_bytes(sibling_bytes)before_entries = sorted(path.name for path in Path(directory).iterdir())before_receipt_mtime = receipt.stat().st_mtime_nsbefore_sibling_mtime = sibling.stat().st_mtime_nsstatus, stdout, stderr = self.run_verifier(receipt)after_entries = sorted(path.name for path in Path(directory).iterdir())after_receipt_mtime = receipt.stat().st_mtime_nsafter_sibling_mtime = sibling.stat().st_mtime_nsafter_receipt_bytes = receipt.read_bytes()after_sibling_bytes = sibling.read_bytes()self.assertEqual(0, status)self.assertNotEqual("", stdout.getvalue())self.assertEqual("", stderr.getvalue())self.assertEqual(before_entries, after_entries)self.assertEqual(encoded, after_receipt_bytes)self.assertEqual(before_receipt_mtime, after_receipt_mtime)self.assertEqual(sibling_bytes, after_sibling_bytes)self.assertEqual(before_sibling_mtime, after_sibling_mtime)if __name__ == "__main__":unittest.main()
HUGGINGFACE_MANIFEST.json+9-9
HUGGINGFACE_SYNC.json+3-3
README.md+33-1
index.html+2-2
scripts/collect_supported_path_receipt.py+228-26
tests/test_collect_supported_path_receipt.py+253