pytest-gpu-proof 0.5.1__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/.github/workflows/ci.yml +2 -1
  2. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/CHANGELOG.md +12 -0
  3. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/PKG-INFO +1 -1
  4. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/policy.md +1 -0
  5. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/security_model.md +1 -1
  6. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/pyproject.toml +1 -1
  7. pytest_gpu_proof-0.5.3/src/pytest_gpu_proof/__init__.py +1 -0
  8. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/signers/ed25519.py +19 -5
  9. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/verify.py +13 -4
  10. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_sharding.py +7 -1
  11. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_signing.py +35 -1
  12. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_verifier.py +8 -1
  13. pytest_gpu_proof-0.5.1/src/pytest_gpu_proof/__init__.py +0 -1
  14. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/.github/workflows/docs.yml +0 -0
  15. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/.github/workflows/publish-testpypi.yml +0 -0
  16. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/.github/workflows/publish.yml +0 -0
  17. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/.gitignore +0 -0
  18. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/AGENTS.md +0 -0
  19. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/CLAUDE.md +0 -0
  20. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/CONTRIBUTING.md +0 -0
  21. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/LICENSE +0 -0
  22. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/README.md +0 -0
  23. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/RELEASING.md +0 -0
  24. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/ROADMAP.md +0 -0
  25. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/SECURITY.md +0 -0
  26. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/architecture.md +0 -0
  27. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/ci_gpu_mode.md +0 -0
  28. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/index.md +0 -0
  29. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/landscape.md +0 -0
  30. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/local_mode.md +0 -0
  31. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/quickstart.md +0 -0
  32. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/docs/sharding.md +0 -0
  33. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_ctypes_matmul/Makefile +0 -0
  34. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_ctypes_matmul/README.md +0 -0
  35. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py +0 -0
  36. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_ctypes_matmul/matmul_kernel.cu +0 -0
  37. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_ctypes_matmul/test_cuda_ctypes_matmul.py +0 -0
  38. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/CMakeLists.txt +0 -0
  39. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/README.md +0 -0
  40. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/src/bindings.cpp +0 -0
  41. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/src/matmul_cuda.h +0 -0
  42. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu +0 -0
  43. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_nanobind_matmul/test_cuda_nanobind_matmul.py +0 -0
  44. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/CMakeLists.txt +0 -0
  45. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/README.md +0 -0
  46. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/src/bindings.cpp +0 -0
  47. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/src/matmul_cuda.h +0 -0
  48. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu +0 -0
  49. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/cuda_pybind11_matmul/test_cuda_pybind11_matmul.py +0 -0
  50. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/github_gpu_runner/.github/workflows/gpu-test.yml +0 -0
  51. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/jax_ffi_cuda_matmul/CMakeLists.txt +0 -0
  52. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/jax_ffi_cuda_matmul/README.md +0 -0
  53. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py +0 -0
  54. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu +0 -0
  55. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/jax_ffi_cuda_matmul/test_jax_ffi_cuda_matmul.py +0 -0
  56. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/local_receipt_verify/.github/workflows/verify.yml +0 -0
  57. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/minimal_python_only/conftest.py +0 -0
  58. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/minimal_python_only/test_minimal.py +0 -0
  59. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py +0 -0
  60. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py +0 -0
  61. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/install.sh +0 -0
  62. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/mkdocs.yml +0 -0
  63. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/requirements-dev.txt +0 -0
  64. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/requirements.txt +0 -0
  65. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/__main__.py +0 -0
  66. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/cli.py +0 -0
  67. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/compare.py +0 -0
  68. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/config.py +0 -0
  69. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/fingerprint.py +0 -0
  70. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/gitutils.py +0 -0
  71. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/merge.py +0 -0
  72. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/plugin.py +0 -0
  73. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/receipt.py +0 -0
  74. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/signers/__init__.py +0 -0
  75. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/src/pytest_gpu_proof/signers/base.py +0 -0
  76. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/conftest.py +0 -0
  77. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_cli.py +0 -0
  78. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_compare.py +0 -0
  79. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_config.py +0 -0
  80. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_fingerprint.py +0 -0
  81. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_gitutils.py +0 -0
  82. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_merge.py +0 -0
  83. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_plugin_capture.py +0 -0
  84. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/tests/test_receipt.py +0 -0
  85. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/README.md +0 -0
  86. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/build_site.py +0 -0
  87. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/check_site.py +0 -0
  88. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/favicon.svg +0 -0
  89. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/index.html +0 -0
  90. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/main.js +0 -0
  91. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/overrides/main.html +0 -0
  92. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/provenance.json +0 -0
  93. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/requirements.txt +0 -0
  94. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/style.css +0 -0
  95. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/test_site.py +0 -0
  96. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/workflow-mobile.svg +0 -0
  97. {pytest_gpu_proof-0.5.1 → pytest_gpu_proof-0.5.3}/website/workflow.svg +0 -0
@@ -7,7 +7,8 @@ on:
7
7
 
8
8
  jobs:
9
9
  test:
10
- runs-on: ubuntu-latest
10
+ # setup-python still provides the supported Python 3.9 build on 24.04.
11
+ runs-on: ubuntu-24.04
11
12
  strategy:
12
13
  fail-fast: false
13
14
  matrix:
@@ -4,6 +4,18 @@ All notable changes to pytest-gpu-proof are documented here. The format is
4
4
  based on [Keep a Changelog](https://keepachangelog.com/); versions follow
5
5
  [SemVer](https://semver.org/) (pre-1.0: minor bumps may break).
6
6
 
7
+ ## [0.5.3] — 2026-12-02
8
+
9
+ - The verifier retries the fetch of a signer's public keys from GitHub three
10
+ times, after 2, 5 and 10 seconds, before failing. GitHub returns a transient
11
+ 404 for that URL now and then, which failed valid receipts. A failed fetch is
12
+ never treated as success.
13
+
14
+ ## [0.5.2] — 2026-12-02
15
+
16
+ - Verifier policy can opt into `warn_on_age: true` for historical evidence.
17
+ Strict expiry remains the default. No receipt schema or signing change.
18
+
7
19
  ## [0.5.1] — 2026-11-03
8
20
 
9
21
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-gpu-proof
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys
5
5
  Project-URL: Homepage, https://a2r-lab.org/pytest-gpu-proof/
6
6
  Project-URL: Documentation, https://a2r-lab.org/pytest-gpu-proof/docs/
@@ -53,6 +53,7 @@ schema 3. Repositories that have finished migrating should pin
53
53
  | `allowed_key_fingerprints` | SSH SHA-256 fingerprints accepted in restricted mode |
54
54
  | `min_schema` | Minimum acceptable receipt schema version (1, 2, or 3) |
55
55
  | `max_age_days` | Maximum age of the merged/session receipt |
56
+ | `warn_on_age` | Boolean, default false. Report an exceeded session or carried-shard age limit on stderr instead of failing. Future timestamps and all other verification errors remain fatal. |
56
57
  | `require_mode` | Required receipt mode: `local` or `ci-gpu` (a `ci-gpu` receipt additionally requires `allowed_key_fingerprints` and must be signed by a listed key) |
57
58
  | `allow_dirty` | Permit dirty recording or verification trees |
58
59
  | `required_fingerprint_paths` | Exact tracked path list |
@@ -36,7 +36,7 @@ Many GPU projects otherwise rely on an unaudited statement that someone ran
36
36
  tests locally. The receipt makes that workflow explicit and machine-checkable:
37
37
 
38
38
  - code drift invalidates the manifest;
39
- - stale receipts fail freshness policy;
39
+ - stale receipts fail freshness policy by default; opting into advisory age accepts historical evidence, not evidence of current toolchain compatibility;
40
40
  - incomplete collections and setup/teardown failures are visible;
41
41
  - signer identity and key fingerprint are signed;
42
42
  - contributor receipts can be reviewed in open mode;
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-gpu-proof"
7
- version = "0.5.1"
7
+ version = "0.5.3"
8
8
  description = "pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -0,0 +1 @@
1
+ __version__ = "0.5.3"
@@ -10,6 +10,7 @@ import base64
10
10
  import hashlib
11
11
  import os
12
12
  import re
13
+ import time
13
14
  from pathlib import Path
14
15
  from typing import List, Optional
15
16
  from urllib.request import urlopen
@@ -116,6 +117,9 @@ def _parse_pubkey_line(line: str):
116
117
  return None
117
118
 
118
119
 
120
+ # Seconds to wait before each attempt at the key URL.
121
+ _KEY_FETCH_PAUSES = (0, 2, 5, 10)
122
+
119
123
  _GITHUB_USERNAME_RE = re.compile(r"^[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}$")
120
124
 
121
125
 
@@ -123,12 +127,22 @@ def fetch_github_public_keys(username: str) -> List:
123
127
  if not _GITHUB_USERNAME_RE.match(username):
124
128
  raise VerifierError(f"invalid GitHub username: {username!r}")
125
129
  url = f"https://github.com/{username}.keys"
126
- try:
127
- with urlopen(url, timeout=10) as resp:
128
- content = resp.read(1024 * 1024).decode()
129
- except Exception as e:
130
+ # GitHub answers this URL with a transient 404 or a timeout now and then.
131
+ # Retry before failing; a wrong answer is never accepted, only asked again.
132
+ content = None
133
+ for attempt, pause in enumerate(_KEY_FETCH_PAUSES):
134
+ if pause:
135
+ time.sleep(pause)
136
+ try:
137
+ with urlopen(url, timeout=10) as resp:
138
+ content = resp.read(1024 * 1024).decode()
139
+ break
140
+ except Exception as e:
141
+ error = e
142
+ if content is None:
130
143
  raise VerifierError(
131
- f"Could not fetch public keys for GitHub user {username!r}: {e}"
144
+ f"Could not fetch public keys for GitHub user {username!r} "
145
+ f"after {len(_KEY_FETCH_PAUSES)} attempts: {error}"
132
146
  )
133
147
 
134
148
  keys = [_parse_pubkey_line(line) for line in content.splitlines()]
@@ -39,6 +39,7 @@ _POLICY_KEYS = {
39
39
  "required_shard_fingerprints",
40
40
  "required_test_manifest",
41
41
  "signer_mode",
42
+ "warn_on_age",
42
43
  }
43
44
 
44
45
 
@@ -87,7 +88,7 @@ def _load_policy(policy_path: Optional[str]) -> dict:
87
88
  "required_fingerprint_paths",
88
89
  ):
89
90
  string_list(name)
90
- for name in ("allow_carried", "allow_dirty"):
91
+ for name in ("allow_carried", "allow_dirty", "warn_on_age"):
91
92
  if name in policy and type(policy[name]) is not bool:
92
93
  raise VerificationError(f"policy field {name!r} must be a boolean")
93
94
  for name in ("carried_max_age_days", "max_age_days"):
@@ -502,7 +503,7 @@ def _verify(
502
503
  if age < datetime.timedelta(minutes=-5):
503
504
  raise VerificationError("receipt timestamp is in the future")
504
505
  if age > datetime.timedelta(days=max_days):
505
- raise VerificationError(f"receipt is older than the {max_days}-day policy")
506
+ _over_age(policy, f"receipt is older than the {max_days}-day policy")
506
507
  # A session cannot have started before the commit it attests to existed
507
508
  # (5 min of clock skew allowed). Cheap replay/forgery guard without a nonce.
508
509
  committed = get_commit_time(stored_sha, root)
@@ -517,6 +518,12 @@ def _verify(
517
518
  print("[gpu-proof] Receipt verified successfully.")
518
519
 
519
520
 
521
+ def _over_age(policy: dict, message: str) -> None:
522
+ if not policy.get("warn_on_age", False):
523
+ raise VerificationError(message)
524
+ print(f"[gpu-proof] WARNING: {message}", file=sys.stderr)
525
+
526
+
520
527
  def _verify_shards(receipt: dict, root: str, policy: dict, max_days: int = 30) -> None:
521
528
  shards = receipt.get("shards")
522
529
  if not isinstance(shards, list) or not shards:
@@ -583,8 +590,10 @@ def _verify_shards(receipt: dict, root: str, policy: dict, max_days: int = 30) -
583
590
  limit = policy.get("carried_max_age_days", min(30, max_days))
584
591
  if type(limit) is not int or limit < 0:
585
592
  raise VerificationError("carried_max_age_days must be a non-negative integer")
586
- if age < datetime.timedelta(minutes=-5) or age > datetime.timedelta(days=limit):
587
- raise VerificationError(f"carried shard {name!r} is outside its age policy")
593
+ if age < datetime.timedelta(minutes=-5):
594
+ raise VerificationError(f"carried shard {name!r} timestamp is in the future")
595
+ if age > datetime.timedelta(days=limit):
596
+ _over_age(policy, f"carried shard {name!r} is outside its age policy ({limit} days)")
588
597
  if claimed != test_ids:
589
598
  raise VerificationError("shard membership does not exactly partition tests[]")
590
599
  if required and set(required) != names:
@@ -248,7 +248,7 @@ def test_carry_refuses_non_ancestor(tmp_path, tmp_git_repo, signer_with_key):
248
248
  "old.json", repo_root=str(tmp_git_repo))
249
249
 
250
250
 
251
- def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_key):
251
+ def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_key, capsys):
252
252
  signer, public_key, key_path = signer_with_key
253
253
  old, fresh = _carry_setup(tmp_path, tmp_git_repo, signer, old_days_ago=40.0)
254
254
  out = tmp_path / "merged.json"
@@ -261,6 +261,9 @@ def test_verify_rejects_stale_carried_shard(tmp_path, tmp_git_repo, signer_with_
261
261
  carried_max_age_days=30),
262
262
  str(tmp_git_repo), "testuser", None)
263
263
  # a permissive age window accepts the same receipt
264
+ _verify(str(out), _policy(tmp_path, allow_carried=True, warn_on_age=True),
265
+ str(tmp_git_repo), "testuser", None)
266
+ assert "WARNING: carried shard" in capsys.readouterr().err
264
267
  _verify(str(out), _policy(tmp_path, allow_carried=True,
265
268
  carried_max_age_days=60),
266
269
  str(tmp_git_repo), "testuser", None)
@@ -467,6 +470,9 @@ def test_direct_shard_validation_rejects_bad_carried_limit(
467
470
  )
468
471
  receipt = json.loads(path.read_text())
469
472
  receipt["shards"][0]["carried"] = {"original_ended_at": _utcstamp()}
473
+ receipt["shards"][0]["carried"]["original_ended_at"] = _utcstamp(days_ago=-1)
474
+ with pytest.raises(VerificationError, match="in the future"):
475
+ _verify_shards(receipt, str(tmp_git_repo), {"allow_carried": True, "warn_on_age": True})
470
476
  with pytest.raises(VerificationError, match="non-negative integer"):
471
477
  _verify_shards(
472
478
  receipt,
@@ -250,12 +250,17 @@ def test_parse_and_fetch_github_keys(monkeypatch, ssh_key_file):
250
250
 
251
251
 
252
252
  def test_fetch_github_keys_errors(monkeypatch):
253
+ calls = []
254
+
253
255
  def network_error(*args, **kwargs):
256
+ calls.append(1)
254
257
  raise OSError("offline")
255
258
 
259
+ monkeypatch.setattr("pytest_gpu_proof.signers.ed25519.time.sleep", lambda s: None)
256
260
  monkeypatch.setattr("pytest_gpu_proof.signers.ed25519.urlopen", network_error)
257
- with pytest.raises(VerifierError, match="Could not fetch"):
261
+ with pytest.raises(VerifierError, match="Could not fetch.*after 4 attempts"):
258
262
  fetch_github_public_keys("alice")
263
+ assert len(calls) == 4
259
264
 
260
265
  class Empty:
261
266
  def __enter__(self):
@@ -270,3 +275,32 @@ def test_fetch_github_keys_errors(monkeypatch):
270
275
  monkeypatch.setattr("pytest_gpu_proof.signers.ed25519.urlopen", lambda *a, **k: Empty())
271
276
  with pytest.raises(VerifierError, match="No usable"):
272
277
  fetch_github_public_keys("alice")
278
+
279
+
280
+ def test_fetch_github_keys_retries_a_transient_failure(monkeypatch, ssh_key_file):
281
+ from urllib.error import HTTPError
282
+
283
+ _, private_key = ssh_key_file
284
+ line = private_key.public_key().public_bytes(Encoding.OpenSSH, PublicFormat.OpenSSH).decode()
285
+ pauses, calls = [], []
286
+
287
+ class Response:
288
+ def __enter__(self):
289
+ return self
290
+
291
+ def __exit__(self, *a):
292
+ return False
293
+
294
+ def read(self, n):
295
+ return line.encode()
296
+
297
+ def flaky(url, timeout):
298
+ calls.append(url)
299
+ if len(calls) < 3:
300
+ raise HTTPError(url, 404, "Not Found", None, None)
301
+ return Response()
302
+
303
+ monkeypatch.setattr("pytest_gpu_proof.signers.ed25519.time.sleep", pauses.append)
304
+ monkeypatch.setattr("pytest_gpu_proof.signers.ed25519.urlopen", flaky)
305
+ assert len(fetch_github_public_keys("alice")) == 1
306
+ assert len(calls) == 3 and pauses == [2, 5]
@@ -142,7 +142,7 @@ def test_verify_fails_on_modified_receipt(good_receipt, tmp_git_repo):
142
142
  _verify(str(path), None, str(tmp_git_repo), "testuser", None)
143
143
 
144
144
 
145
- def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key):
145
+ def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key, capsys):
146
146
  signer, public_key = signer_with_key
147
147
  # Genuinely-signed receipt whose ended_at is far in the past: every check
148
148
  # up to freshness must pass, and freshness must be the one that fails.
@@ -152,6 +152,12 @@ def test_verify_fails_on_stale_receipt(tmp_path, tmp_git_repo, signer_with_key):
152
152
  with _mock_github_keys(public_key):
153
153
  with pytest.raises(VerificationError, match=r"older than the 30-day policy"):
154
154
  _verify(str(path), None, str(tmp_git_repo), "testuser", 30)
155
+ policy = _policy(tmp_path, {"warn_on_age": True})
156
+ with pytest.raises(VerificationError, match="before its commit existed"):
157
+ _verify(str(path), policy, str(tmp_git_repo), "testuser", 30)
158
+ with patch("pytest_gpu_proof.verify.get_commit_time", return_value=1500000000):
159
+ _verify(str(path), policy, str(tmp_git_repo), "testuser", 30)
160
+ assert "WARNING: receipt is older" in capsys.readouterr().err
155
161
 
156
162
 
157
163
  def test_verify_max_age_zero_is_respected(tmp_path, tmp_git_repo, signer_with_key):
@@ -428,6 +434,7 @@ def test_policy_validation_errors(tmp_path, content, message):
428
434
  ({"allowed_signers": [""]}, "list of strings"),
429
435
  ({"allow_dirty": "yes"}, "boolean"),
430
436
  ({"allow_carried": 1}, "boolean"),
437
+ ({"warn_on_age": "true"}, "boolean"),
431
438
  ({"max_age_days": True}, "non-negative integer"),
432
439
  ({"carried_max_age_days": -1}, "non-negative integer"),
433
440
  ({"require_mode": "remote"}, "local.*ci-gpu"),
@@ -1 +0,0 @@
1
- __version__ = "0.5.1"