feat(governance): enforce fail-closed verification, handle shortfall edge cases, pass 23/23 tests
HIFFI QA & Governance Pipeline / governance-tests (push) Successful in 24s
HIFFI QA & Governance Pipeline / governance-tests (push) Successful in 24s
This commit is contained in:
1 parent
0b36fff7b1
commit
f40143cb69
2 files changed
+134
-18
No files matched your search
@@ -377,4 +377,82 @@ def test_publication_eligibility_gates(dataset):
|
||||
# 4. Check ranks are strictly unique and consecutive 1 to N
|
||||
ranks = gated["hiffi_xp_published_rank"].sort_values().tolist()
|
||||
expected_ranks = list(range(1, len(gated) + 1))
|
||||
assert ranks == expected_ranks, "Published ranks contain gaps or duplicates."
|
||||
assert ranks == expected_ranks, "Published ranks contain gaps or duplicates."
|
||||
|
||||
def test_publication_gate_blocks_unverified_identity():
|
||||
"""Confirms that UNCERTAIN_NEEDS_REVIEW status does not count toward evidence tiers."""
|
||||
engine = HIFFIRankingEngine()
|
||||
test_df = pd.DataFrame([
|
||||
{
|
||||
"name": "Artist Pending Verification",
|
||||
"production_hiffi_score": 95.0,
|
||||
"spotify_monthly_listeners": 40_000_000,
|
||||
"instagram_followers": 20_000_000,
|
||||
"instagram_verification_status": "UNCERTAIN_NEEDS_REVIEW",
|
||||
"hiffi_xp_score": 96.0,
|
||||
"hiffi_xp_rank": 1
|
||||
},
|
||||
{
|
||||
"name": "Artist Fully Verified",
|
||||
"production_hiffi_score": 90.0,
|
||||
"spotify_monthly_listeners": 35_000_000,
|
||||
"instagram_followers": 15_000_000,
|
||||
"instagram_verification_status": "AUTOMATED_VERIFIED",
|
||||
"hiffi_xp_score": 91.0,
|
||||
"hiffi_xp_rank": 2
|
||||
}
|
||||
])
|
||||
|
||||
gated = engine.apply_publication_eligibility_gates(test_df)
|
||||
pending_row = gated[gated["name"] == "Artist Pending Verification"].iloc[0]
|
||||
verified_row = gated[gated["name"] == "Artist Fully Verified"].iloc[0]
|
||||
|
||||
assert pending_row["platform_evidence_tier"] == 2
|
||||
assert verified_row["platform_evidence_tier"] == 3
|
||||
|
||||
|
||||
def test_publication_gate_missing_column_fails_closed():
|
||||
"""Confirms that omitting the verification column fails closed (gives 0 IG credit)."""
|
||||
engine = HIFFIRankingEngine()
|
||||
test_df = pd.DataFrame([
|
||||
{
|
||||
"name": "Artist No Status Column",
|
||||
"production_hiffi_score": 95.0,
|
||||
"spotify_monthly_listeners": 40_000_000,
|
||||
"instagram_followers": 20_000_000,
|
||||
"hiffi_xp_score": 96.0,
|
||||
"hiffi_xp_rank": 1
|
||||
}
|
||||
])
|
||||
|
||||
gated = engine.apply_publication_eligibility_gates(test_df)
|
||||
assert gated.loc[0, "platform_evidence_tier"] == 2
|
||||
|
||||
|
||||
def test_publication_gate_zero_multiplatform_cohort():
|
||||
"""Confirms an entirely Tier 1 cohort produces consecutive ranks and flags an audited shortfall."""
|
||||
engine = HIFFIRankingEngine()
|
||||
|
||||
records = [
|
||||
{
|
||||
"name": f"Solo Artist {i+1}",
|
||||
"production_hiffi_score": 85.0 - i,
|
||||
"spotify_monthly_listeners": np.nan,
|
||||
"instagram_followers": np.nan,
|
||||
"instagram_verification_status": "UNVERIFIED",
|
||||
"hiffi_xp_score": 80.0 - i,
|
||||
"hiffi_xp_rank": i + 1
|
||||
}
|
||||
for i in range(25)
|
||||
]
|
||||
|
||||
tier1_df = pd.DataFrame(records)
|
||||
gated, audit = engine.apply_publication_eligibility_gates(tier1_df, return_metadata=True)
|
||||
|
||||
# Must retain unique contiguous ordering 1 to 25
|
||||
assert gated["hiffi_xp_published_rank"].tolist() == list(range(1, 26))
|
||||
# All records remain Tier 1
|
||||
assert (gated["platform_evidence_tier"] == 1).all()
|
||||
# Shortfall must be explicitly reported
|
||||
assert audit["top_10_shortfall"] is True
|
||||
assert audit["top_50_shortfall"] is True
|
||||
Reference in new issue
Block a user