Files
NODEDC_MISSION_CORE/simulation/semantic-learning/fit_capacity.py
T
DCCONSTRUCTIONS 25dc0a1b44 feat(semantics): add portable annotation, learning and review contracts
Add portable corpus, annotation provenance, admission, review and bounded agent-cycle contracts. Preserve dataset ownership and explicit research acceptance limits.
2026-10-29 09:10:00 +03:00

36 lines
1.3 KiB
Python

"""Predeclared TRAIN-only capacity screen; never a deployment acceptance gate."""
import math
def capacity_screen(before, after):
"""Require halved BCE/weak misses/background errors and no clear-paint loss."""
for row in (before, after):
if set(row) != {"bce", "weak_fn", "background_fp", "clear_fn"}:
raise ValueError("Exact fixed support metrics required")
if (
isinstance(row["bce"], bool)
or not isinstance(row["bce"], (int, float))
or not math.isfinite(row["bce"])
or row["bce"] < 0
):
raise ValueError("Finite nonnegative objective required")
for key in ("weak_fn", "background_fp", "clear_fn"):
if type(row[key]) is not int or row[key] < 0:
raise ValueError("Nonnegative integer error counts required")
limits = {
"bce": before["bce"] * 0.5,
"weak_fn": before["weak_fn"] * 0.5,
"background_fp": before["background_fp"] * 0.5,
"clear_fn": before["clear_fn"],
}
failures = [key for key, limit in limits.items() if after[key] > limit]
return {
"passed": not failures,
"failures": failures,
"limits": limits,
"before": dict(before),
"after": dict(after),
"production_eligible": False,
}