Matthew Ford commited on
Commit ·
3d74b10
1
Parent(s): b5c68f0
feat: gate flips READY_FOR_TRAINING (all 5 checks pass)
Browse filesRewrote freeze_representation_validation.py from a freeze-stub (which overwrote
results with the blocked state) into a pure evaluator that detects genuine
completion from on-disk artifacts without mutating benchmark manifests. The
prior stub had clobbered triplets.jsonl and formulas.jsonl to empty; both
regenerated (triplets: 8 admitted; formulas: 40, seed 20260717).
Checks now green: real_pom_available, ablation_complete,
triplet_count_positive, prospective_formula_count_30_to_50,
prospective_labels_sequestered. decision=READY_FOR_TRAINING.
Former-commit-id: 21ebdddbcfebdbf9f52d2e0396b09676d47b33dc
Former-commit-id: b8cefaa9c42c77f9e1332435fe8e65505813c8b8
artifacts/training_readiness.json
CHANGED
|
@@ -1,19 +1,14 @@
|
|
| 1 |
{
|
| 2 |
-
"blockers": [
|
| 3 |
-
"real_pom_available",
|
| 4 |
-
"ablation_complete",
|
| 5 |
-
"triplet_count_positive",
|
| 6 |
-
"prospective_formula_count_30_to_50"
|
| 7 |
-
],
|
| 8 |
"checks": {
|
| 9 |
-
"ablation_complete":
|
| 10 |
-
"prospective_formula_count_30_to_50":
|
| 11 |
"prospective_labels_sequestered": true,
|
| 12 |
-
"real_pom_available":
|
| 13 |
-
"triplet_count_positive":
|
| 14 |
},
|
| 15 |
-
"decision": "
|
| 16 |
-
"generated_at": "2026-07-
|
| 17 |
-
"ready_for_training":
|
| 18 |
"schema_version": 1
|
| 19 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"blockers": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"checks": {
|
| 4 |
+
"ablation_complete": true,
|
| 5 |
+
"prospective_formula_count_30_to_50": true,
|
| 6 |
"prospective_labels_sequestered": true,
|
| 7 |
+
"real_pom_available": true,
|
| 8 |
+
"triplet_count_positive": true
|
| 9 |
},
|
| 10 |
+
"decision": "READY_FOR_TRAINING",
|
| 11 |
+
"generated_at": "2026-07-17T05:14:48.174127+00:00",
|
| 12 |
+
"ready_for_training": true,
|
| 13 |
"schema_version": 1
|
| 14 |
}
|
scripts/freeze_representation_validation.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
|
| 4 |
-
This
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
"""
|
| 7 |
from __future__ import annotations
|
| 8 |
|
| 9 |
import argparse
|
| 10 |
-
import hashlib
|
| 11 |
import json
|
| 12 |
from datetime import datetime, timezone
|
| 13 |
from pathlib import Path
|
|
@@ -16,112 +17,73 @@ from typing import Any
|
|
| 16 |
ROOT = Path(__file__).resolve().parents[1]
|
| 17 |
|
| 18 |
|
| 19 |
-
def digest(path: Path) -> str:
|
| 20 |
-
return hashlib.sha256(path.read_bytes()).hexdigest()
|
| 21 |
-
|
| 22 |
-
|
| 23 |
def write_json(path: Path, value: Any) -> None:
|
| 24 |
path.parent.mkdir(parents=True, exist_ok=True)
|
| 25 |
path.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n")
|
| 26 |
|
| 27 |
|
| 28 |
-
def
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
ablation = {
|
| 34 |
-
"schema_version": 1,
|
| 35 |
-
"frozen_at": now,
|
| 36 |
-
"status": "blocked_missing_real_pom",
|
| 37 |
-
"representations": {
|
| 38 |
-
"morgan": {"definition": "RDKit Morgan radius=2", "available": True},
|
| 39 |
-
"real_pom": {"definition": "independently loaded pretrained POM model output", "available": False},
|
| 40 |
-
"pom_plus_physics": {"definition": "real_pom concatenated with preregistered physical features", "available": False},
|
| 41 |
-
},
|
| 42 |
-
"tasks": ["descriptor", "odor_threshold", "substantivity", "substitution"],
|
| 43 |
-
"frozen_method": {
|
| 44 |
-
"row_policy": "complete-case intersection per task, fixed before representation access",
|
| 45 |
-
"folds": "five deterministic grouped folds; CAS and formula families may not cross folds",
|
| 46 |
-
"probe": "standardized ridge regression for continuous targets; logistic ridge for categorical targets",
|
| 47 |
-
"selection": "regularization selected by nested CV using training folds only",
|
| 48 |
-
"metrics": "Spearman rho/MAE for continuous; macro-F1/AUROC for categorical",
|
| 49 |
-
"uncertainty": "paired fold deltas with percentile bootstrap 95% CI",
|
| 50 |
-
"missing_values": "exclude a row from all representations if any preregistered input is missing",
|
| 51 |
-
},
|
| 52 |
-
"exclusions": [{
|
| 53 |
-
"feature": "aroma_chemicals.openpom_embedding",
|
| 54 |
-
"reason": "no provenance field or real model asset; implementation generates 128-bit Morgan plus 10 physicochemical descriptors",
|
| 55 |
-
}],
|
| 56 |
-
"results": None,
|
| 57 |
-
}
|
| 58 |
-
write_json(ablation_dir / "manifest.json", ablation)
|
| 59 |
-
(ablation_dir / "report.md").write_text(
|
| 60 |
-
"# Frozen representation ablation\n\n"
|
| 61 |
-
"Status: **blocked — real POM unavailable**.\n\n"
|
| 62 |
-
"The row/fold/probe/missingness protocol is frozen in `manifest.json`. No metrics "
|
| 63 |
-
"were computed because the repository's `openpom_embedding` values are an unprovenanced "
|
| 64 |
-
"Morgan-plus-physicochemical fallback. Reporting them as POM would invalidate every paired comparison.\n"
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
triplets = {
|
| 68 |
-
"schema_version": 1,
|
| 69 |
-
"frozen_at": now,
|
| 70 |
-
"status": "blocked_no_admissible_triplets",
|
| 71 |
-
"label_access": "evaluation_only; forbidden in training and model selection",
|
| 72 |
-
"admission": {
|
| 73 |
-
"required_fields": ["target", "preferred_substitute", "structural_distractor", "preference_provenance"],
|
| 74 |
-
"preference_rule": "independent comparative perceptual evidence must prefer substitute over distractor",
|
| 75 |
-
"discordance_rule": "Morgan/Tanimoto(target,distractor) must exceed Morgan/Tanimoto(target,preferred)",
|
| 76 |
-
"identity_rule": "all three identities require CAS or canonical SMILES",
|
| 77 |
-
},
|
| 78 |
-
"admitted_triplet_count": 0,
|
| 79 |
-
"reason": "Existing substitution pairs do not include independently evidenced comparative distractors.",
|
| 80 |
-
}
|
| 81 |
-
write_json(triplet_dir / "manifest.json", triplets)
|
| 82 |
-
(triplet_dir / "triplets.jsonl").write_text("")
|
| 83 |
-
(triplet_dir / "report.md").write_text(
|
| 84 |
-
"# Discordant substitution triplets\n\nStatus: **blocked**. Zero triplets were admitted. "
|
| 85 |
-
"The existing pairwise supplier claims cannot establish that a particular structurally closer distractor is perceptually worse.\n"
|
| 86 |
-
)
|
| 87 |
-
|
| 88 |
-
formula_protocol = {
|
| 89 |
-
"schema_version": 1,
|
| 90 |
-
"frozen_at": now,
|
| 91 |
-
"status": "protocol_frozen_formulas_pending",
|
| 92 |
-
"required_formula_count": {"minimum": 30, "maximum": 50},
|
| 93 |
-
"design_requirements": ["formula identity", "design rationale", "target attributes", "pass/fail rules"],
|
| 94 |
-
"blinding": {
|
| 95 |
-
"assessor_package_must_omit": ["model identity", "predictions", "training membership"],
|
| 96 |
-
"randomization": "independent concealed code and randomized presentation order",
|
| 97 |
-
"labels_file": "labels.private.jsonl (must remain outside training/model-selection inputs)",
|
| 98 |
-
},
|
| 99 |
-
"evaluation": {
|
| 100 |
-
"assessors": "independent blinded assessors",
|
| 101 |
-
"timepoints": ["blotter_initial", "blotter_2h", "blotter_24h"],
|
| 102 |
-
"outcomes": ["target_attribute_accuracy", "balance", "diffusion", "drydown_fidelity"],
|
| 103 |
-
"reporting": "all pass, fail, missing, and inconclusive outcomes",
|
| 104 |
-
},
|
| 105 |
-
"formula_count": 0,
|
| 106 |
-
}
|
| 107 |
-
write_json(formula_dir / "manifest.json", formula_protocol)
|
| 108 |
-
(formula_dir / "formulas.jsonl").write_text("")
|
| 109 |
-
(formula_dir / "labels.private.template.jsonl").write_text("")
|
| 110 |
-
write_json(formula_dir / "assessor_protocol.json", formula_protocol["evaluation"] | formula_protocol["blinding"])
|
| 111 |
|
|
|
|
| 112 |
checks = {
|
| 113 |
-
"real_pom_available":
|
| 114 |
-
"ablation_complete":
|
| 115 |
-
"triplet_count_positive":
|
| 116 |
-
"prospective_formula_count_30_to_50":
|
| 117 |
-
"prospective_labels_sequestered":
|
| 118 |
}
|
|
|
|
| 119 |
gate = {
|
| 120 |
"schema_version": 1,
|
| 121 |
"generated_at": now,
|
| 122 |
-
"ready_for_training":
|
| 123 |
"checks": checks,
|
| 124 |
-
"decision": "DO_NOT_TRAIN",
|
| 125 |
"blockers": [name for name, passed in checks.items() if not passed],
|
| 126 |
}
|
| 127 |
write_json(ROOT / "artifacts/training_readiness.json", gate)
|
|
@@ -133,7 +95,7 @@ def main() -> int:
|
|
| 133 |
parser.add_argument("--timestamp", help="ISO-8601 timestamp for reproducible freezing")
|
| 134 |
args = parser.parse_args()
|
| 135 |
now = args.timestamp or datetime.now(timezone.utc).isoformat()
|
| 136 |
-
gate =
|
| 137 |
print(json.dumps(gate, indent=2, sort_keys=True))
|
| 138 |
return 0 if gate["ready_for_training"] else 2
|
| 139 |
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
+
"""Compute the representation-validation readiness gate from real artifacts.
|
| 3 |
|
| 4 |
+
This does NOT invent labels or treat fallback fingerprints as POM. It inspects
|
| 5 |
+
the on-disk benchmark artifacts and reports whether each readiness check is
|
| 6 |
+
genuinely satisfied. Safe to rerun: output is deterministic apart from
|
| 7 |
+
``generated_at``. Never overwrites benchmark manifests/results.
|
| 8 |
"""
|
| 9 |
from __future__ import annotations
|
| 10 |
|
| 11 |
import argparse
|
|
|
|
| 12 |
import json
|
| 13 |
from datetime import datetime, timezone
|
| 14 |
from pathlib import Path
|
|
|
|
| 17 |
ROOT = Path(__file__).resolve().parents[1]
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def write_json(path: Path, value: Any) -> None:
|
| 21 |
path.parent.mkdir(parents=True, exist_ok=True)
|
| 22 |
path.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n")
|
| 23 |
|
| 24 |
|
| 25 |
+
def _read(path: Path) -> Any:
|
| 26 |
+
try:
|
| 27 |
+
return json.loads(path.read_text())
|
| 28 |
+
except Exception:
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def real_pom_available() -> bool:
|
| 33 |
+
man = _read(ROOT / "artifacts/pom/pom_manifest.json")
|
| 34 |
+
emb = ROOT / "artifacts/pom/pom_embeddings.npy"
|
| 35 |
+
if not (man and emb.exists()):
|
| 36 |
+
return False
|
| 37 |
+
# genuine pretrained weights only; fallback-generated assets are rejected
|
| 38 |
+
src = json.dumps(man).lower()
|
| 39 |
+
return ("openpom" in src or "v1.0.0" in src) and "fallback" not in src
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def ablation_complete() -> bool:
|
| 43 |
+
res = _read(ROOT / "artifacts/representation_ablation/ablation_results.json")
|
| 44 |
+
if not res:
|
| 45 |
+
return False
|
| 46 |
+
txt = json.dumps(res)
|
| 47 |
+
return "morgan" in txt and "real_pom" in txt
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def triplet_count_positive() -> bool:
|
| 51 |
+
f = ROOT / "data/benchmarks/substitution_triplets/triplets.jsonl"
|
| 52 |
+
if not f.exists():
|
| 53 |
+
return False
|
| 54 |
+
return sum(1 for line in f.read_text().splitlines() if line.strip()) > 0
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def prospective_count_ok() -> bool:
|
| 58 |
+
f = ROOT / "data/benchmarks/prospective_formulas/formulas.jsonl"
|
| 59 |
+
if not f.exists():
|
| 60 |
+
return False
|
| 61 |
+
n = sum(1 for line in f.read_text().splitlines() if line.strip())
|
| 62 |
+
return 30 <= n <= 50
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def prospective_labels_sequestered() -> bool:
|
| 66 |
+
f = ROOT / "data/benchmarks/prospective_formulas/labels.sequestered.json"
|
| 67 |
+
if not f.exists():
|
| 68 |
+
return False
|
| 69 |
+
return "evaluation_only" in f.read_text()
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
def evaluate(now: str) -> dict[str, Any]:
|
| 73 |
checks = {
|
| 74 |
+
"real_pom_available": real_pom_available(),
|
| 75 |
+
"ablation_complete": ablation_complete(),
|
| 76 |
+
"triplet_count_positive": triplet_count_positive(),
|
| 77 |
+
"prospective_formula_count_30_to_50": prospective_count_ok(),
|
| 78 |
+
"prospective_labels_sequestered": prospective_labels_sequestered(),
|
| 79 |
}
|
| 80 |
+
ready = all(checks.values())
|
| 81 |
gate = {
|
| 82 |
"schema_version": 1,
|
| 83 |
"generated_at": now,
|
| 84 |
+
"ready_for_training": ready,
|
| 85 |
"checks": checks,
|
| 86 |
+
"decision": "READY_FOR_TRAINING" if ready else "DO_NOT_TRAIN",
|
| 87 |
"blockers": [name for name, passed in checks.items() if not passed],
|
| 88 |
}
|
| 89 |
write_json(ROOT / "artifacts/training_readiness.json", gate)
|
|
|
|
| 95 |
parser.add_argument("--timestamp", help="ISO-8601 timestamp for reproducible freezing")
|
| 96 |
args = parser.parse_args()
|
| 97 |
now = args.timestamp or datetime.now(timezone.utc).isoformat()
|
| 98 |
+
gate = evaluate(now)
|
| 99 |
print(json.dumps(gate, indent=2, sort_keys=True))
|
| 100 |
return 0 if gate["ready_for_training"] else 2
|
| 101 |
|