proof-aware-crypto-tooling-.../tests/test_boundaries.py
mrwulf 2dae2ca0db audit v3: paper-reality congruence + external-pointer integrity (Fable-5 Socratic pass)
Two Fable-5 inventory agents cross-checked every empirical claim in the
paper against code/deployed log, and every external pointer against the
live internet. Fixes on both sides:

CODE (system brought up to the paper's claims):
- SECURITY: pin-store mutation (incl. permanent poisoning) was reachable
  via receipts whose head signature FAILED verification in two of three
  consumer paths (attestation.py, cli.py) - an unauthenticated forged
  head at the pinned size could poison a consumer's pin forever and
  pollute the equivocation-evidence pair with an unverifiable head,
  contradicting SS5.4's 'validly signed' precondition and Prop 1.
  Both paths now gate the store on a verified Ed25519 head signature
  (logclient.py already did). Regression test added.
- Prop 2 made literally true: _normalize_certificate now derives the
  cleanliness verdict purely from (observed cone, local allowed set) in
  EVERY branch; the operator's axiom_status label is never copied (was
  passed through for non-proven certs), missing cone => unverifiable
  always. Labels can deny, never grant. Test added.
- webdocs: '/v1/sth-history: every head ever signed' -> 'the published
  head history'.

PAPER (claims brought down to reality):
- 'every head ever signed' -> the signed head history since publication
  began (heads for sizes 1-7 predate the mirror and were not retained).
- Run-3 bullet: 'independently checkable by diffing the two commit
  trees' was no longer reproducible (pre-rewrite objects discarded);
  now states the log-internal corroboration (identical cert lists and
  cones across leaves 4-7 vs 8-11) and that tree diffs are not public.
- Appendix A leaf block now actually verbatim: scheme
  openssl-ed25519, verified_backend serial/u64, real Lean version
  (4.30.0-rc2) instead of 4.x.y placeholder, leaf's actual axiom order
  (finalize/new/update), machine_protection note quoted, elisions
  marked; preamble wording matches.
- Appendix C upstream boundary reordered to check.sh's verbatim order.
- '27 lines - all annotation' -> honest description (axiom-list entries
  + operation reordering from one fork's black_box barrier).
- Prop 2 proof + App A: status label consulted only negatively.
- SS7: provenance fields noted as outside the signed payload; consumer
  chain relies on none of them.
- Bibliography: all 20 entries verified against DBLP/RFC-editor - zero
  errors; added missing page numbers to 6 entries; thebibliography
  width 19->20. All URLs verified public; no PlanetMacro leakage.

17 pages, 106 tests green, accumulator untouched (tree_size 12).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 21:33:28 +02:00

92 lines
4 KiB
Python

from pacta.attestation import _normalize_certificate
from pacta.config import RepoConfig
from pacta.claims import build_claim_card
from pacta.profiles import get_profile
from pacta.profiles.ed25519 import APEX_BOUNDARIES, APEX_TIER_CERTIFICATES, R4_REQUIREMENTS
def _repo(boundary="dalek-wrappers"):
return RepoConfig(name="dalek-ed25519-verified", kind="ed25519", apex_boundary=boundary)
def test_apex_tiers_expect_the_fork_boundary_not_standard_three():
profile = get_profile("ed25519", _repo())
for tier in APEX_TIER_CERTIFICATES:
expected = profile.expected_axioms_for(tier)
assert "ed25519.Signature" in expected
assert set(expected) == set(APEX_BOUNDARIES["dalek-wrappers"])
# non-apex certificates stay standard-three
assert profile.expected_axioms_for("CurveFieldProofs.fieldImplementation") == [
"propext", "Classical.choice", "Quot.sound",
]
def test_unknown_boundary_is_a_hard_error():
import pytest
with pytest.raises(KeyError):
get_profile("ed25519", _repo(boundary="no-such-boundary"))
def test_agent_rederives_axiom_status_against_local_policy():
profile = get_profile("ed25519", _repo())
boundary = list(APEX_BOUNDARIES["dalek-wrappers"])
lying = {
"name": "CurveFieldProofs.verify_accepts_iff",
"status": "proven",
"axiom_status": "clean", # the provider's verdict is never trusted
"observed_axioms": boundary + ["backend.simd.avx2_dispatch"],
}
out = _normalize_certificate(lying, profile)
assert out["axiom_status"] == "dirty"
assert out["provider_axiom_verdict"] == "clean"
honest = dict(lying, observed_axioms=boundary)
assert _normalize_certificate(honest, profile)["axiom_status"] == "clean"
# a boundary axiom MISSING is just as dirty as an extra one
short = dict(lying, observed_axioms=boundary[:-1])
assert _normalize_certificate(short, profile)["axiom_status"] == "dirty"
# "proven" with no observed axioms cannot be re-derived: distrust
blind = {"name": "CurveFieldProofs.verify_accepts_iff", "status": "proven", "axiom_status": "clean"}
assert _normalize_certificate(blind, profile)["axiom_status"] == "unverifiable"
def test_full_fixture_scores_r4_and_partial_scores_r3(tmp_path):
full = _repo()
card = build_claim_card(full, tmp_path, offline_fixture=True)
assert card["risk"]["level"] == "R4"
assert any("SHA-512" in b for b in card["risk"]["blockers"])
assert set(R4_REQUIREMENTS) <= {c["name"] for c in card["certificates"]}
partial = RepoConfig(
name="dalek-ed25519-verified",
kind="ed25519",
apex_boundary="dalek-wrappers",
certificates=["CurveFieldProofs.fieldImplementation", "CurveFieldProofs.edwardsImplementation"],
)
card = build_claim_card(partial, tmp_path, offline_fixture=True)
assert card["risk"]["level"] == "R3"
assert any("R4 requires the full apex tier set" in b for b in card["risk"]["blockers"])
def test_verdict_never_copies_operator_labels():
"""Prop 2 (verdict integrity), literally: the cleanliness verdict is a
function of (observed cone, local allowed set) in EVERY branch. The
operator's axiom_status label is never copied - not even for
non-proven certificates - and a missing cone is always unverifiable."""
profile = get_profile("ed25519", _repo())
failed_flattered = {
"name": "CurveFieldProofs.verify_accepts_iff",
"status": "failed",
"axiom_status": "clean", # operator flattery, must not pass through
}
out = _normalize_certificate(failed_flattered, profile)
assert out["axiom_status"] == "unverifiable"
assert out["provider_axiom_verdict"] == "clean" # recorded, not believed
failed_with_cone = {
"name": "CurveFieldProofs.verify_accepts_iff",
"status": "failed",
"axiom_status": "clean",
"observed_axioms": ["propext", "sorryAx"],
}
assert _normalize_certificate(failed_with_cone, profile)["axiom_status"] == "dirty"