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.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""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,
|
||||
}
|
||||
Reference in New Issue
Block a user