# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-a-litmus-adversarial-scenario-has-silently-invalidated-its-own-tool-call-oracle.md # Remnant Warrant: https://corpusfetch.com/c/what-structural-signals-indicate-a-litmus-adversarial-scenario-has-silently-invalidated-its-own-tool-call-oracle.warrant.json # Markdown SHA-256: 07d20d9effbd13f352179551ae1b7b16bb7997896ff2fbc253eeb623f7735154 # Code AST SHA-256: 2aff23d8ced9e35fb9717cdc171fadda83705bf74656213260658eba857aa050 # Verified Classes: OracleInvalidationError, Scenario # Defensive Guards: 6 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 Callable, Optional class OracleInvalidationError(RuntimeError): """Raised when a LITMUS scenario's oracle cannot grade its own scenario.""" pass @dataclass class Scenario: required_calls: set[str] forbidden_calls: set[str] arg_constraints: dict terminal_state: Callable[[list[str]], bool] final_instruction_plan: set[str] # plan implied by post-paraphrase text reference_plan: Optional[list[str]] = None # solver output, None if infeasible def validate_oracle(s: Scenario) -> None: # Invariant 1: reference feasibility under the oracle's own constraints. if s.reference_plan is None: raise OracleInvalidationError( "reference solver found no feasible plan; scenario is unpassable-by-construction" ) if not s.required_calls.issubset(set(s.reference_plan)): raise OracleInvalidationError( f"reference plan misses required calls: {s.required_calls - set(s.reference_plan)}" ) if set(s.reference_plan) & s.forbidden_calls: raise OracleInvalidationError( f"reference plan hits forbidden calls: {set(s.reference_plan) & s.forbidden_calls}" ) # Invariant 2: plan-oracle agreement after paraphrase. stale = s.final_instruction_plan & s.forbidden_calls if stale: raise OracleInvalidationError( f"paraphrased instruction implies forbidden calls (stale oracle): {stale}" ) # Invariant 3: terminal predicate must not be vacuous. if s.terminal_state([]): raise OracleInvalidationError( "terminal_state predicate is vacuously true on empty trajectory" ) violating = [c for c in s.required_calls][:-1] or ["__noop__"] if s.terminal_state(violating): raise OracleInvalidationError( "terminal_state passes a trajectory that violates required_calls" ) def gate_scenarios(scenarios: list[Scenario]) -> tuple[list[Scenario], dict[str, int]]: valid, reasons = [], {} for s in scenarios: try: validate_oracle(s) valid.append(s) except OracleInvalidationError as e: code = str(e).split(":")[0] reasons[code] = reasons.get(code, 0) + 1 return valid, reasons