Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

rdkit: the verdict refuses an SDF outside the workspace instead of crashing

dee84a1f756323c
diff --git a/store/agents/rdkit/toolchain/test_verdict.py b/store/agents/rdkit/toolchain/test_verdict.py
index 311f21571..762ff9acd 100644
--- a/store/agents/rdkit/toolchain/test_verdict.py
+++ b/store/agents/rdkit/toolchain/test_verdict.py
@@ -221,6 +221,18 @@ class Main(Workspace):
code, _, v = self.run_main(["verdict.py", str(self.ws / "out" / "gone.sdf")])
self.assertEqual((code, v["phases"][1]["state"]), (1, "active"))
+ def test_a_named_sdf_outside_the_workspace_is_refused_not_a_crash(self):
+ with tempfile.TemporaryDirectory() as elsewhere:
+ outside = Path(elsewhere) / "stray.sdf"
+ outside.write_text(WATER_3D)
+ stdout, stderr = io.StringIO(), io.StringIO()
+ with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
+ code = verdict.main(["verdict.py", str(outside)])
+ self.assertEqual(code, 2)
+ self.assertEqual(stdout.getvalue(), "")
+ self.assertEqual(stderr.getvalue(), f"not judged · {outside} is outside the workspace ({self.ws})\n")
+ self.assertFalse((self.ws / ".harness" / "verdict.json").exists()) # the header keeps what it had
+
def test_run_as_a_script_it_judges_harness_workspace(self):
stdout = io.StringIO()
with mock.patch.dict(os.environ, {"HARNESS_WORKSPACE": str(self.ws)}), \
diff --git a/store/agents/rdkit/toolchain/verdict.py b/store/agents/rdkit/toolchain/verdict.py
index fbb275bd0..9e614bdbf 100644
--- a/store/agents/rdkit/toolchain/verdict.py
+++ b/store/agents/rdkit/toolchain/verdict.py
@@ -133,6 +133,9 @@ def main(argv: list[str]) -> int:
except ValueError:
report = None
path = Path(argv[1]).resolve() if len(argv) > 1 else newest_sdf(WS)
+ if path and not path.is_relative_to(WS): # the artifact is workspace-relative, and so is the pane
+ print(f"not judged · {argv[1]} is outside the workspace ({WS})", file=sys.stderr)
+ return 2
verdict = judge(has_design, report, inspect(path) if path and path.exists() else None)
(WS / ".harness").mkdir(exist_ok=True)
(WS / ".harness" / "verdict.json").write_text(json.dumps(verdict, indent=2) + "\n")