feat(verified): add default-dark VERIFIED serving gate helper

Adds a default-dark verified_serving_enabled helper with focused tests. The helper is unwired: no runtime integration, no verify.py wiring, no eval producer imports, no served VERIFIED behavior, and no CLAIMS/metric movement.
This commit is contained in:
Shay 2026-06-09 10:06:36 -07:00 committed by GitHub
parent 1fff7dad59
commit 45835987b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,33 @@
"""VERIFIED serving gate helper — default-dark, no served-surface wiring.
This module centralizes the future kill-switch predicate for VERIFIED serving.
It is default-dark / fail-closed: if the config field is missing or malformed,
it must evaluate to False.
This helper only centralizes the future kill-switch predicate so that future serving code
has one audited predicate. It does not wire any served-surface or implement served
VERIFIED behavior. Missing field means False.
Note that eval-gold-backed producers (such as the verification producer in
evals/constraint_oracle/verified_producer.py) are not serving-eligible.
"""
from __future__ import annotations
from typing import Any
from core.config import DEFAULT_CONFIG, RuntimeConfig
def verified_serving_enabled(config: RuntimeConfig | Any | None = None) -> bool:
"""Return whether served VERIFIED delivery is explicitly enabled.
Missing attribute means False. This is the load-bearing dark-gate invariant:
the served VERIFIED path cannot light merely because the helper exists or because
an older RuntimeConfig instance lacks the future field.
"""
cfg = DEFAULT_CONFIG if config is None else config
return bool(getattr(cfg, "verified_serving_enabled", False))
__all__ = ["verified_serving_enabled"]

View file

@ -0,0 +1,74 @@
"""VERIFIED serving gate — default-dark invariant.
This proves the post-scoping kill-switch predicate is dark unless an
operator/config object explicitly opts in.
"""
from __future__ import annotations
import ast
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from core.config import DEFAULT_CONFIG, RuntimeConfig
from core.epistemic_disclosure.serving_gate import verified_serving_enabled
@dataclass(frozen=True, slots=True)
class _LegacyConfig:
"""A pre-field config shape: absence of the flag must mean dark."""
unrelated: bool = True
@dataclass(frozen=True, slots=True)
class _OptInConfig:
"""Config with the verified_serving_enabled field."""
verified_serving_enabled: bool | None
def test_default_runtime_config_keeps_verified_serving_dark() -> None:
assert verified_serving_enabled(DEFAULT_CONFIG) is False
assert verified_serving_enabled(RuntimeConfig()) is False
def test_missing_flag_is_dark_for_legacy_config_shape() -> None:
assert verified_serving_enabled(_LegacyConfig()) is False
def test_gate_only_lights_on_explicit_truthy_opt_in() -> None:
assert verified_serving_enabled(_OptInConfig(False)) is False
assert verified_serving_enabled(_OptInConfig(True)) is True
assert verified_serving_enabled(_OptInConfig(None)) is False
def test_none_uses_default_config_and_stays_dark() -> None:
assert verified_serving_enabled() is False
def test_verified_serving_gate_has_no_eval_or_runtime_imports() -> None:
path = Path(__file__).parent.parent / "core/epistemic_disclosure/serving_gate.py"
tree = ast.parse(path.read_text(encoding="utf-8"))
forbidden = {
"evals",
"evals.constraint_oracle",
"evals.constraint_oracle.verified_producer",
"verify",
"chat.runtime",
"generate.contemplation.pass_manager",
}
for node in ast.walk(tree):
if isinstance(node, ast.Import):
for name in node.names:
for banned in forbidden:
assert name.name != banned, f"Forbidden import: {name.name}"
assert not name.name.startswith(banned + "."), f"Forbidden import: {name.name}"
elif isinstance(node, ast.ImportFrom):
if node.module:
for banned in forbidden:
assert node.module != banned, f"Forbidden import from: {node.module}"
assert not node.module.startswith(banned + "."), f"Forbidden import from: {node.module}"