26 lines
1.4 KiB
Python
26 lines
1.4 KiB
Python
from fxhnt.application.gate_policy import POLICY, POLICY_VERSION, GatePolicy, policy_hash
|
|
|
|
_EXPECTED_HASH = "7be84eaa5a09581deaf608cf1a523ad900908584fae3858bba3e7eb25e6f791a"
|
|
|
|
|
|
def test_policy_defaults_match_todays_constants():
|
|
# these values must equal the pre-B1 reconciliation_gate / gate.py constants (byte-identical verdicts)
|
|
assert (POLICY.min_forward_days, POLICY.recon_tolerance_frac, POLICY.recon_min_band,
|
|
POLICY.recon_min_corr, POLICY.max_gap_days) == (14, 0.5, 0.05, 0.0, 1)
|
|
assert (POLICY.min_days, POLICY.min_total_return, POLICY.min_sharpe) == (20, 0.0, 0.0)
|
|
|
|
|
|
def test_policy_hash_is_stable_and_content_derived():
|
|
assert policy_hash(POLICY, POLICY_VERSION) == policy_hash(POLICY, POLICY_VERSION) # stable
|
|
changed = GatePolicy(min_forward_days=21) # field changed
|
|
# → different hash when policy changes
|
|
assert policy_hash(changed, POLICY_VERSION) != policy_hash(POLICY, POLICY_VERSION)
|
|
# version bump → different hash
|
|
assert policy_hash(POLICY, 2) != policy_hash(POLICY, 1)
|
|
|
|
|
|
def test_policy_hash_selfcheck_forces_version_bump():
|
|
# PIN the current hash. If a policy field changes without this literal being updated (and the version
|
|
# bumped), this test fails — forcing a deliberate, audited change. Update BOTH on any real policy change.
|
|
assert policy_hash(POLICY, POLICY_VERSION) == _EXPECTED_HASH # noqa: F821 — defined below in the test file
|