# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-happens-when-an-instance-generates-litmus-adversarial-scenarios-from-its-own-skill-inventory-and-inherits-the-blind-spot-of-the-skills-it-is-tryi.md # Remnant Warrant: https://corpusfetch.com/c/what-happens-when-an-instance-generates-litmus-adversarial-scenarios-from-its-own-skill-inventory-and-inherits-the-blind-spot-of-the-skills-it-is-tryi.warrant.json # Markdown SHA-256: d6158a4539bbecebf0d6e4d024f21a7366dc1ff3bbd782d8b0b3b8792b960295 # Code AST SHA-256: 325f243845f10bb625ea39a7c7c2b6dd26aada5214cf28bc501432614e2b1cf0 # Verified Classes: CoverageCertificateError, SkillSchema, LitmusSuite # Defensive Guards: 3 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) from dataclasses import dataclass, field from typing import Dict, Set class CoverageCertificateError(RuntimeError): """Raised when a LITMUS suite is asked to certify resilience over a skill set that the generator cannot see, or over a version-skewed skill whose attack surface has not been probed.""" pass @dataclass class SkillSchema: name: str version: str injection_channels: Set[str] = field(default_factory=set) @dataclass class LitmusSuite: generator_registry: Dict[str, SkillSchema] target_registry: Dict[str, SkillSchema] probed_versions: Dict[str, str] = field(default_factory=dict) reported_success_rate: float = 0.0 def certify_resilience(suite: LitmusSuite) -> float: """Return the suite's success rate ONLY if it is a valid lower bound on deployment risk. Otherwise refuse.""" gen_names = set(suite.generator_registry) tgt_names = set(suite.target_registry) # Guardrail 1: registry closure. Any target skill the generator cannot see # is an unmeasured attack surface. Refuse to certify. unseen = tgt_names - gen_names if unseen: raise CoverageCertificateError( f"generator cannot see target skills {sorted(unseen)}; " f"reported rate {suite.reported_success_rate:.3f} is not a " f"lower bound on deployment risk" ) # Guardrail 2: schema fidelity for version-skewed skills. A skill present # in both registries but at different versions has an attack surface the # generator has not probed. Refuse to certify until probed. for name in gen_names & tgt_names: g, t = suite.generator_registry[name], suite.target_registry[name] if g.version != t.version: probed = suite.probed_versions.get(name) if probed != t.version: raise CoverageCertificateError( f"skill {name!r} is at generator version {g.version!r} " f"but target version {t.version!r}; attack surface " f"unprobed, cannot certify" ) # Even after probing, the probe must have covered every channel # the target actually exposes. uncovered = t.injection_channels - g.injection_channels if uncovered: raise CoverageCertificateError( f"skill {name!r} exposes unprobed injection channels " f"{sorted(uncovered)}; generator template is stale" ) return suite.reported_success_rate def run_suite(suite: LitmusSuite, certify: bool) -> float: """Run the suite. If certify=True, enforce the coverage invariant; if False, return the delta-only regression signal without certifying.""" if certify: return certify_resilience(suite) # Regression-only mode: the absolute rate is meaningless without coverage, # but the delta against a prior run with the same blind spot is not. return suite.reported_success_rate