Matthew Ford commited on
Commit
2e41740
·
1 Parent(s): 64a046c

fix: pre-existing test failures — draft_engine None-MW crash + stale gate test

Browse files

draft_engine._load_compounds: skip aroma_chemicals rows with NULL molecular_weight
(they cannot be tier-classified and crashed _classify_tiers with None<=int). Fixes
all 5 test_synthetic failures.

test_representation_validation: the old test asserted the gate FAILS against live
repo state, which broke once the gate legitimately went READY. Rewritten to (a)
exercise the failure path hermetically by running the real gate logic against an
empty tmp dir (asserts rc=2 / DO_NOT_TRAIN / non-empty blockers), and (b) assert
the live repo gate IS ready with all five checks passing (regression guard).

Full suite: 112 passed, 4 skipped, 0 failed (previously 6 failed).


Former-commit-id: 671bc1d1175a6ede27ee0bb2f7563d836cd42dc1
Former-commit-id: 9d4a91c3b761ab4f2808fb0a91c67fc8eda63146

src/pino/draft_engine.py CHANGED
@@ -69,6 +69,10 @@ class FormulaGenerator:
69
  continue
70
  if cas == self.solvent_cas:
71
  continue
 
 
 
 
72
  # Assign default guardrails based on IFRA.
73
  max_w = self._default_max_weight(record)
74
  record["max_weight_fraction"] = max_w
 
69
  continue
70
  if cas == self.solvent_cas:
71
  continue
72
+ # Skip rows lacking a molecular weight: they cannot be tier-classified
73
+ # (MW cutoffs) and would crash comparisons downstream.
74
+ if record.get("molecular_weight") is None:
75
+ continue
76
  # Assign default guardrails based on IFRA.
77
  max_w = self._default_max_weight(record)
78
  record["max_weight_fraction"] = max_w
tests/test_representation_validation.py CHANGED
@@ -16,17 +16,39 @@ def test_real_pom_requirement_fails_closed():
16
  OlfactoryEmbeddingEngine(use_fallback=False)
17
 
18
 
19
- def test_freeze_protocol_emits_failed_gate():
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  result = subprocess.run(
21
  [sys.executable, "scripts/freeze_representation_validation.py", "--timestamp", "2026-07-16T00:00:00+00:00"],
22
- cwd=ROOT,
23
  text=True,
24
  capture_output=True,
25
  )
26
  assert result.returncode == 2
27
- gate = json.loads((ROOT / "artifacts/training_readiness.json").read_text())
28
  assert gate["ready_for_training"] is False
29
  assert gate["decision"] == "DO_NOT_TRAIN"
30
- manifest = json.loads((ROOT / "artifacts/representation_ablation/manifest.json").read_text())
31
- assert manifest["representations"]["real_pom"]["available"] is False
32
- assert manifest["results"] is None
 
 
 
 
 
 
 
 
 
 
16
  OlfactoryEmbeddingEngine(use_fallback=False)
17
 
18
 
19
+ def test_freeze_protocol_blocks_when_artifacts_missing(tmp_path):
20
+ """The gate must FAIL (rc=2, DO_NOT_TRAIN) when readiness artifacts are absent.
21
+
22
+ Runs the real gate logic against an empty directory (via a copied script) so
23
+ the check is hermetic and independent of the repo's current READY state.
24
+ """
25
+ scripts_dir = tmp_path / "scripts"
26
+ scripts_dir.mkdir()
27
+ (tmp_path / "artifacts").mkdir()
28
+ (tmp_path / "data").mkdir()
29
+ # Copy the real gate script so it re-anchors ROOT at tmp_path (parents[1]).
30
+ src = (ROOT / "scripts" / "freeze_representation_validation.py").read_text()
31
+ (scripts_dir / "freeze_representation_validation.py").write_text(src)
32
+
33
  result = subprocess.run(
34
  [sys.executable, "scripts/freeze_representation_validation.py", "--timestamp", "2026-07-16T00:00:00+00:00"],
35
+ cwd=tmp_path,
36
  text=True,
37
  capture_output=True,
38
  )
39
  assert result.returncode == 2
40
+ gate = json.loads((tmp_path / "artifacts" / "training_readiness.json").read_text())
41
  assert gate["ready_for_training"] is False
42
  assert gate["decision"] == "DO_NOT_TRAIN"
43
+ assert gate["blockers"], "expected at least one failing readiness check on empty artifacts"
44
+
45
+
46
+ def test_current_repo_gate_is_ready_with_all_checks():
47
+ """The live repo gate should be READY with all five checks passing.
48
+
49
+ Guards against regressions that silently flip the gate back to DO_NOT_TRAIN.
50
+ """
51
+ gate = json.loads((ROOT / "artifacts" / "training_readiness.json").read_text())
52
+ assert gate["ready_for_training"] is True
53
+ assert gate["decision"] == "READY_FOR_TRAINING"
54
+ assert all(gate["checks"].values()), f"failing checks: {[k for k, v in gate['checks'].items() if not v]}"