Skip to content

Official Codebase of 3DCodeVerse

Python

lint: say when only the first instance of an instanced driver is followed

ziyao4952a65990a9
diff --git a/harness/bench/data/plan_stage/README.md b/harness/bench/data/plan_stage/README.md
index 7d7d3ad8..ad9eadc7 100644
--- a/harness/bench/data/plan_stage/README.md
+++ b/harness/bench/data/plan_stage/README.md
@@ -13,6 +13,12 @@ is identical. One row per call: `ok`, the error text, `invalid_reasks`, `restar
Kept in the repo rather than under `bench/out/` because a paper cites the p-value, and a
number whose data is not in the tree is not reproducible.
+`plan_once` runs the plan stage WITHOUT `Track.run`, so there is no run ledger and the
+workspace is deleted: these rows are the record, and each carries its own `cost_usd` (the
+script prints the total). `--keep-failed DIR` keeps the workspace of a call that produced
+no plan, which is how the `parent == child` class below can be read. Rows recorded before
+2026-09-03 carry no `started_at` / `tree_commit`; later ones do.
+
## The trigger, narrowed (2026-09-03)
Review narrowed the restart to the class the 200-call survey actually found — a
diff --git a/harness/bench/plan_stage_bench.py b/harness/bench/plan_stage_bench.py
index 359e1076..e477e8bf 100644
--- a/harness/bench/plan_stage_bench.py
+++ b/harness/bench/plan_stage_bench.py
@@ -96,8 +96,16 @@ def tree_provenance(tree: Path, codeverse_file: str) -> dict[str, str]:
return out
-def run_one(battery, item, backends, label: str, rep: int, provenance: dict[str, str] | None = None) -> dict:
- """One plan-stage call in a throwaway workspace; never raises."""
+def run_one(battery, item, backends, label: str, rep: int, provenance: dict[str, str] | None = None,
+ keep_failed: Path | None = None) -> dict:
+ """One plan-stage call in a throwaway workspace; never raises.
+
+ ``plan_once`` deliberately bypasses ``Track.run``: there is no build, no judge and no
+ run ledger, so the JSONL row IS the record (it carries the call's own ``cost_usd``
+ from the plan events, and the totals are printed at the end). ``keep_failed`` moves a
+ workspace that produced no plan out of the temp dir instead of deleting it, which is
+ the only way to read what the model actually wrote.
+ """
from bench.pin_plan import plan_once
from bench.run_bench import build_spec
@@ -112,7 +120,11 @@ def run_one(battery, item, backends, label: str, rep: int, provenance: dict[str,
row = {"tree": label, "prompt": item.id, "rep": rep, "ok": ok, "error": error,
"started_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(started)),
"seconds": round(time.time() - started, 1), **(provenance or {}), **_stats(root / "ws")}
- shutil.rmtree(root, ignore_errors=True)
+ if not ok and keep_failed is not None:
+ keep_failed.mkdir(parents=True, exist_ok=True)
+ shutil.move(str(root), str(keep_failed / f"{label}_{item.id}_r{rep}"))
+ else:
+ shutil.rmtree(root, ignore_errors=True)
return row
@@ -127,6 +139,9 @@ def main(argv: list[str] | None = None) -> int:
ap.add_argument("--ids", default="", help="comma list; default every prompt in the battery")
ap.add_argument("--planner", default=DEFAULT_PLANNER)
ap.add_argument("--env", default="", help="comma list of KEY=VALUE applied to this arm")
+ ap.add_argument("--keep-failed", type=Path, default=None,
+ help="move the workspace of any call that produced no plan here (plan stage "
+ "only, so they are small) instead of deleting it")
ns = ap.parse_args(argv)
for kv in (x for x in ns.env.split(",") if x.strip()):
@@ -159,14 +174,18 @@ def main(argv: list[str] | None = None) -> int:
# imap-style ordering: pool.map yields in submission order, so one slow call holds
# back every finished row behind it. Rows are the journal, so they go out as they
# land instead (resume reads what is on disk, order does not matter).
- futures = [pool.submit(run_one, battery, item, backends, ns.label, rep, prov) for item, rep in jobs]
+ futures = [pool.submit(run_one, battery, item, backends, ns.label, rep, prov, ns.keep_failed)
+ for item, rep in jobs]
for fut in cf.as_completed(futures):
row = fut.result()
fh.write(json.dumps(row) + "\n")
fh.flush()
print(f" {row['prompt']:28} r{row['rep']:<3} ok={row['ok']} restart={row['restarts']} {row['error'][:60]}")
rows = [json.loads(x) for x in ns.out.read_text().splitlines() if x.strip()]
- print(f"{ns.label}: {sum(1 for r in rows if r['ok'])}/{len(rows)} plans valid")
+ spent = sum(float(r.get("cost_usd") or 0.0) for r in rows)
+ print(f"{ns.label}: {sum(1 for r in rows if r['ok'])}/{len(rows)} plans valid, "
+ f"${spent:.2f} over {len(rows)} calls (the rows are the ledger: plan_once does not "
+ f"open one)")
return 0
diff --git a/harness/codeverse/languages/urdf/__init__.py b/harness/codeverse/languages/urdf/__init__.py
index 390c0507..8fa72c50 100644
--- a/harness/codeverse/languages/urdf/__init__.py
+++ b/harness/codeverse/languages/urdf/__init__.py
@@ -258,6 +258,20 @@ def _lint_mimics(joints: list[ET.Element], out: list[GateFinding]) -> None:
specs.append(MimicSpec(key=jname, name=jname, movable=movable, target=src or None,
multiplier=mult, offset=off, lower=lo, upper=hi))
known = sorted({el.get("name", "") for el in joints if el.get("name")})
+ # An instanced driver emits <driver>_1 .. _n and the skeleton binds followers to _1
+ # only, so _2..n stay independent inputs and the sweep drives them: real for the
+ # mechanism (each instance has its own coupling to declare), silent until now.
+ instanced = {n.rsplit("_", 1)[0] for n in known if n.rsplit("_", 1)[-1].isdigit()}
+ for spec in specs:
+ base = (spec.target or "").rsplit("_", 1)
+ if len(base) == 2 and base[1] == "1" and base[0] in instanced:
+ siblings = sorted(n for n in known if n.startswith(f"{base[0]}_") and n != spec.target)
+ if siblings:
+ out.append(_f(Severity.WARN, f"joint '{spec.name}': follows '{spec.target}' only; "
+ f"{', '.join(siblings)} stay independent inputs and the "
+ "sweep drives them separately", target=spec.name,
+ fix="give each instance its own <mimic>, or make the followers "
+ "follow one shared driver"))
for i in mimic_issues(specs):
j, t = i.joint, i.target
if i.kind == "immobile":
diff --git a/harness/tests/urdf_joints/test_mimic.py b/harness/tests/urdf_joints/test_mimic.py
index 4d9cf891..a024c662 100644
--- a/harness/tests/urdf_joints/test_mimic.py
+++ b/harness/tests/urdf_joints/test_mimic.py
@@ -288,3 +288,31 @@ def test_the_lint_warns_when_a_coupling_drives_past_the_follower_s_own_limits(tm
warns = [f for f in lint_workspace(ws).findings if "drives it over" in f.message]
assert len(warns) == 1 and warns[0].severity.value == "warn" and warns[0].target == "rib_a_hinge"
assert "1.5" in warns[0].message
+
+
+EXTRA_RUNNER = """ <link name="runner2"><visual><geometry><mesh filename="meshes/rib_b.glb"/></geometry></visual></link>
+ <joint name="runner_slide_2" type="prismatic">
+ <parent link="shaft"/><child link="runner2"/>
+ <origin xyz="0 0 0.6" rpy="0 0 0"/><axis xyz="0 0 1"/>
+ <limit lower="0" upper="0.3" effort="10" velocity="1"/>
+ </joint>
+</robot>"""
+
+
+def test_the_lint_says_when_only_the_first_instance_of_a_driver_is_followed(tmp_path):
+ """The skeleton binds a coupling to ``<driver>_1``, so with an INSTANCED driver the
+ other instances stay independent inputs and the sweep drives them separately. The
+ emitter's comment said so; the file that ships did not, so the over-driving was silent.
+ """
+ from codeverse.workspace import Workspace
+
+ urdf = (RIB.replace('joint name="runner_slide"', 'joint name="runner_slide_1"')
+ .replace('<mimic joint="runner_slide" ', '<mimic joint="runner_slide_1" ')
+ .replace("</robot>", EXTRA_RUNNER))
+ ws = Workspace(tmp_path / "ws").create()
+ (ws.src / "model.py").write_text("import bpy\n")
+ (ws.src / "robot.urdf").write_text(urdf)
+
+ warns = [f for f in lint_workspace(ws).findings if "stay independent inputs" in f.message]
+ assert len(warns) == 1 and warns[0].target == "rib_a_hinge"
+ assert "runner_slide_2" in warns[0].message and warns[0].severity.value == "warn"