Skip to content

Add deterministic reproducibility test for layered admissibility artifact#132

Merged
ProfRandom92 merged 1 commit into
mainfrom
codex/add-reproducibility-check-for-artifacts
May 19, 2026
Merged

Add deterministic reproducibility test for layered admissibility artifact#132
ProfRandom92 merged 1 commit into
mainfrom
codex/add-reproducibility-check-for-artifacts

Conversation

@ProfRandom92
Copy link
Copy Markdown
Owner

Summary:
Add a focused deterministic reproducibility test that regenerates committed benchmark artifacts via the existing layered admissibility generator and fails on any JSON drift; the check is implemented as an explicit, extensible artifact spec list so future artifacts can be added deliberately.

Changed files:

  • tests/test_artifact_reproducibility.py (new)

Testing:

  • python scripts/generate_layered_admissibility_artifact.py — produced artifacts/layered_admissibility_results.json successfully.
  • pytest tests/test_artifact_reproducibility.py -q — 1 passed.
  • pytest tests/test_degradation_curve_generator.py -q — 13 passed.
  • pytest tests/test_fixture_manifest.py -q — 8 passed.
  • npm run check — completed; full Python test suite ran and reported 197 passed.

Risks:

  • Low risk: this PR only adds a deterministic test and does not change generators, fixtures, or committed artifacts; the test uses logical JSON equality and will need explicit additions to the spec for any future deterministic artifacts.

Next:

  • If new deterministic benchmark artifacts are introduced, add them to ARTIFACT_SPECS in tests/test_artifact_reproducibility.py to include them in the reproducibility gate.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comptextv7 Ready Ready Preview, Comment May 19, 2026 3:07pm

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test suite to verify the reproducibility of committed artifacts, specifically for layered admissibility results. The feedback focuses on improving the robustness and maintainability of the tests by suggesting the use of a repository root constant for path resolution and refactoring the test logic to utilize pytest's parametrization for better isolation and reporting.

from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Import pytest and define REPO_ROOT to allow for robust path resolution relative to the repository structure, ensuring tests are runnable from any directory.

import pytest

REPO_ROOT = Path(__file__).resolve().parents[1]

ARTIFACT_SPECS: tuple[DeterministicArtifactSpec, ...] = (
DeterministicArtifactSpec(
name="layered_admissibility_results",
committed_path=Path("artifacts/layered_admissibility_results.json"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use REPO_ROOT to anchor the artifact path. This prevents the test from failing if executed from a directory other than the repository root.

Suggested change
committed_path=Path("artifacts/layered_admissibility_results.json"),
committed_path=REPO_ROOT / "artifacts/layered_admissibility_results.json",

Comment on lines +35 to +46
def test_committed_deterministic_artifacts_are_reproducible(tmp_path: Path) -> None:
for spec in ARTIFACT_SPECS:
regenerated_path = tmp_path / spec.committed_path.name
spec.regenerate(regenerated_path)

regenerated_payload = _load_json(regenerated_path)
committed_payload = _load_json(spec.committed_path)

assert regenerated_payload == committed_payload, (
f"Deterministic artifact drift detected for '{spec.name}'. "
f"Regenerate with: python scripts/generate_layered_admissibility_artifact.py"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Refactor the test to use pytest.mark.parametrize. This improves test isolation and provides clearer reporting by treating each artifact as a separate test case, which aligns with the extensible design mentioned in the PR description.

Suggested change
def test_committed_deterministic_artifacts_are_reproducible(tmp_path: Path) -> None:
for spec in ARTIFACT_SPECS:
regenerated_path = tmp_path / spec.committed_path.name
spec.regenerate(regenerated_path)
regenerated_payload = _load_json(regenerated_path)
committed_payload = _load_json(spec.committed_path)
assert regenerated_payload == committed_payload, (
f"Deterministic artifact drift detected for '{spec.name}'. "
f"Regenerate with: python scripts/generate_layered_admissibility_artifact.py"
)
@pytest.mark.parametrize("spec", ARTIFACT_SPECS, ids=lambda s: s.name)
def test_committed_deterministic_artifacts_are_reproducible(spec: DeterministicArtifactSpec, tmp_path: Path) -> None:
regenerated_path = tmp_path / spec.committed_path.name
spec.regenerate(regenerated_path)
regenerated_payload = _load_json(regenerated_path)
committed_payload = _load_json(spec.committed_path)
assert regenerated_payload == committed_payload, (
f"Deterministic artifact drift detected for '{spec.name}'. "
f"Regenerate with: python scripts/generate_layered_admissibility_artifact.py"
)

@ProfRandom92 ProfRandom92 merged commit 33f2278 into main May 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant