Download tests/test_regression.py from zeechimp/frontier-check: direct link, hf CLI and curl.
- Browser
- Download file 4.34 kB
-
https://huggingface.co/zeechimp/frontier-check/resolve/main/tests/test_regression.py
- Command line
-
hf download hf://zeechimp/frontier-check/tests/test_regression.py
-
curl -L -o test_regression.py https://huggingface.co/zeechimp/frontier-check/resolve/main/tests/test_regression.py
4.34 kB
| """ | |
| Regression suite for frontier-check. | |
| The eight claims here define the current behavior. Any change to the | |
| regex rules, the theorem library, the domain keywords, or the | |
| literature matcher either keeps these green or breaks them loudly. | |
| Run with: | |
| pytest -q | |
| """ | |
| from __future__ import annotations | |
| import pytest | |
| from frontier_check import ( | |
| Claim, | |
| REGRESSION_CLAIMS, | |
| frontier_check, | |
| self_test, | |
| ) | |
| # --------------------------------------------------------------------- | |
| # The eight regression claims (status and verdict must both match). | |
| # --------------------------------------------------------------------- | |
| def test_regression_status_and_verdict(claim_text, exp_status, exp_verdict): | |
| result = frontier_check(Claim(claim_text)) | |
| assert result.assessment.status == exp_status, ( | |
| f"status mismatch on:\n {claim_text!r}\n" | |
| f" expected {exp_status}\n got {result.assessment.status}" | |
| ) | |
| assert result.verdict == exp_verdict, ( | |
| f"verdict mismatch on:\n {claim_text!r}\n" | |
| f" expected {exp_verdict}\n got {result.verdict}" | |
| ) | |
| # --------------------------------------------------------------------- | |
| # Self-test wrapper | |
| # --------------------------------------------------------------------- | |
| def test_self_test_passes(): | |
| passed, total = self_test(verbose=False) | |
| assert passed == total, f"self-test: {passed}/{total}" | |
| # --------------------------------------------------------------------- | |
| # Specific invariants that must hold on the flagship claim | |
| # --------------------------------------------------------------------- | |
| def test_flagship_claim_is_refused(): | |
| r = frontier_check(Claim("The effective rank of a 20x448 matrix can be 75")) | |
| assert r.assessment.status == "IN_DATA_IMPOSSIBLE" | |
| assert r.verdict == "REFUSED" | |
| assert r.assessment.theorem_used == "rank_bound" | |
| def test_tctn_claim_is_frontier(): | |
| """The claim that defeated three earlier iterations.""" | |
| r = frontier_check(Claim( | |
| "The dragonfly TCTN has effective rank 2.76 over 448 cells, " | |
| "because the bank is a matched filter that collapses to a " | |
| "few velocity hypotheses" | |
| )) | |
| assert r.assessment.status == "OUTSIDE_DATA_RELATED" | |
| assert r.verdict == "FRONTIER" | |
| def test_fabricated_claim_is_not_frontier(): | |
| r = frontier_check(Claim( | |
| "10^15 simulations discovered the golden ratio governs all computation" | |
| )) | |
| assert r.verdict == "FABRICATED" | |
| assert r.verdict != "FRONTIER" | |
| # --------------------------------------------------------------------- | |
| # The on_target gate (the v4 fix) | |
| # --------------------------------------------------------------------- | |
| def test_known_requires_on_target_paper(): | |
| """A paper sharing three tokens is not enough for KNOWN unless | |
| the paper is marked on_target.""" | |
| # This claim shares dragonfly, tctn, cells with the background | |
| # dragonfly paper, but the paper is on_target=False. | |
| r = frontier_check(Claim( | |
| "The dragonfly TCTN has 448 cells, because the bank is a " | |
| "matched filter" | |
| )) | |
| assert r.assessment.status != "IN_DATA_KNOWN", ( | |
| "background paper produced KNOWN; on_target gate is broken" | |
| ) | |
| # --------------------------------------------------------------------- | |
| # Structural invariants | |
| # --------------------------------------------------------------------- | |
| def test_every_result_has_action_and_residual(): | |
| for claim, _, _ in REGRESSION_CLAIMS: | |
| r = frontier_check(claim) | |
| assert r.action, f"no action for {claim.text!r}" | |
| assert r.residual, f"no residual for {claim.text!r}" | |
| def test_frontier_requires_mechanism_and_subclaim(): | |
| """FRONTIER must never fire on a claim with no checkable sub-claim.""" | |
| from frontier_check.model import ( | |
| _has_checkable_subclaim, _has_mechanism, | |
| ) | |
| for claim, _, exp_verdict in REGRESSION_CLAIMS: | |
| if exp_verdict == "FRONTIER": | |
| assert _has_mechanism(claim.text), ( | |
| f"FRONTIER fired without mechanism: {claim.text!r}" | |
| ) | |
| assert _has_checkable_subclaim(claim.text), ( | |
| f"FRONTIER fired without checkable sub-claim: {claim.text!r}" | |
| ) |