# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-reputation-laundering-invariants-prevent-agents-from-cycling-identities-to-reset-reputation.md # Remnant Warrant: https://corpusfetch.com/c/what-reputation-laundering-invariants-prevent-agents-from-cycling-identities-to-reset-reputation.warrant.json # Markdown SHA-256: 49b663709d6360574ccf1c748869f312e53ecbcff86edd77d90cb84c946742d8 # Code AST SHA-256: 9258b2391da96997ae457e5fb9a558b760f31a5811fe274169fc14f4c97f6ab5 # Verified Classes: LaunderingVerdict, IdentityReputation, LaunderingPolicy, LaunderingManifest, ReputationLaunderingGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class LaunderingVerdict(Enum): BOUND_IDENTITY = auto() UNBOUND_IDENTITY = auto() CYCLING_SUSPECTED = auto() LOW_STAKES_EXEMPT = auto() @dataclass(frozen=True) class IdentityReputation: identity_id: str principal_id: str | None identity_reputation: float principal_aggregate_reputation: float | None cycling_risk_score: float operation_stakes: str # "LOW" | "MEDIUM" | "HIGH" @dataclass(frozen=True) class LaunderingPolicy: require_binding_for_stakes: frozenset[str] max_cycling_risk_score: float @dataclass(frozen=True) class LaunderingManifest: verdict: LaunderingVerdict effective_reputation: float directive: str manifest_digest: str class ReputationLaunderingGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_identity( cls, rep: IdentityReputation, policy: LaunderingPolicy ) -> LaunderingManifest: # Gate 1: Low stakes exemption if rep.operation_stakes == "LOW": digest = cls._hash(json.dumps({ "identity": rep.identity_id, "stakes": "LOW" }, sort_keys=True)) return LaunderingManifest( verdict=LaunderingVerdict.LOW_STAKES_EXEMPT, effective_reputation=rep.identity_reputation, directive=f"PROCEED: Low stakes, reputation binding not required.", manifest_digest=digest ) # Gate 2: Binding requirement if rep.operation_stakes in policy.require_binding_for_stakes: if not rep.principal_id: return LaunderingManifest( verdict=LaunderingVerdict.UNBOUND_IDENTITY, effective_reputation=0.0, directive=f"HALT: {rep.operation_stakes} stakes requires bound identity, {rep.identity_id} unbound.", manifest_digest=cls._hash(f"UNBOUND:{rep.identity_id}") ) # Gate 3: Cycling risk if rep.cycling_risk_score > policy.max_cycling_risk_score: return LaunderingManifest( verdict=LaunderingVerdict.CYCLING_SUSPECTED, effective_reputation=0.0, directive=f"HALT: Cycling risk {rep.cycling_risk_score:.2f} > {policy.max_cycling_risk_score:.2f}.", manifest_digest=cls._hash(f"CYCLING:{rep.identity_id}") ) # Gate 4: Bound with aggregate reputation effective_rep = rep.principal_aggregate_reputation if rep.principal_aggregate_reputation is not None else rep.identity_reputation digest = cls._hash(json.dumps({ "identity": rep.identity_id, "principal": rep.principal_id, "identity_rep": f"{rep.identity_reputation:.3f}", "aggregate_rep": f"{effective_rep:.3f}", "cycling_risk": f"{rep.cycling_risk_score:.3f}" }, sort_keys=True)) return LaunderingManifest( verdict=LaunderingVerdict.BOUND_IDENTITY, effective_reputation=effective_rep, directive=f"PROCEED: Identity bound to principal, effective reputation {effective_rep:.2f}.", manifest_digest=digest )