Skip to content

Official Codebase of 3DCodeVerse

Python

planner: one articulation acceptance item per moving joint the plan's checklist does not cover

ziyaoff41488bb5a0
diff --git a/harness/codeverse/tracks/planner.py b/harness/codeverse/tracks/planner.py
index 3df7282e..62eabce5 100644
--- a/harness/codeverse/tracks/planner.py
+++ b/harness/codeverse/tracks/planner.py
@@ -32,7 +32,7 @@ from codeverse.contracts.chat import ChatMessage, ChatRequest, ImagePart
from codeverse.contracts.common import Language, Track, Usage
from codeverse.contracts.plan import AcceptanceItem, EngineeringBrief
from codeverse.contracts.spec import Spec
-from codeverse.conventions import LANGUAGE_FRAME, frame_doc, to_pascal
+from codeverse.conventions import LANGUAGE_FRAME, frame_doc, to_pascal, to_snake
from codeverse.models.schema_utils import parse_json_lenient
from codeverse.prompts import load_text, prompt_hash, render
from codeverse.tracks.common import language_contract, load_prompt_or
@@ -900,10 +900,38 @@ def ensure_acceptance[P: BaseModel](plan_obj: P, spec: Spec) -> P:
add_acceptance_item(items, "not", f"Does NOT include: {m}", "visual")
if spec.track is not Track.SCENE and not any(a.how == "measure" for a in items):
add_acceptance_item(items, "ground", "Object stands on the ground plane (lowest point at up=0) with its footprint centred", "measure")
+ items.extend(articulation_acceptance(plan_obj, items))
plan_obj.acceptance = items
return plan_obj
+def articulation_acceptance(plan_obj: Any, items: list[AcceptanceItem]) -> list[AcceptanceItem]:
+ """One ``articulation`` item per moving joint the planner's own checklist does not cover
+ (2026-08-28, phase 4 item 6): the judge reads the pose sheet — rest, lower, upper — so the
+ plan's rest-pose and motion statements become questions it answers per joint instead of
+ prose it may skip. ``should`` priority: an unverified item steers the refine loop's
+ judge tasks but never fails the run (a *must* the judge cannot verify does)."""
+ joints = [j for j in (getattr(plan_obj, "joints", None) or []) if j.type != "fixed"]
+ if not joints:
+ return []
+ covered = " ".join(a.text.lower() for a in items if a.how == "articulation")
+ words = set(re.findall(r"[a-z0-9]+", covered.replace("_", " ")))
+ out: list[AcceptanceItem] = []
+ for j in joints:
+ # whole-word match on the joint's or the child's name ("lid" must not match "slides")
+ keys = {j.name.lower(), to_snake(j.child).replace("_", " "), j.child.lower()}
+ if any(k and all(w in words for w in re.findall(r"[a-z0-9]+", k)) for k in keys):
+ continue
+ unit = "m" if j.type == "prismatic" else "rad"
+ rest = "closed / stowed" if abs(j.rest) < 1e-9 else f"at {j.rest:.2f} {unit}"
+ rng = "turns freely" if j.type == "continuous" else f"moves over [{j.lower:.2f}, {j.upper:.2f}] {unit}"
+ out.append(AcceptanceItem(
+ id=f"art_{to_snake(j.child)}"[:40], how="articulation", priority="should",
+ text=f"Joint {j.name}: at rest {j.child} sits {rest} against {j.parent}; it {rng} — {j.motion} — "
+ f"without passing through {j.parent} or any other link (pose_* views)"))
+ return out
+
+
def normalise_names[P: BaseModel](plan_obj: P) -> P:
"""PascalCase part/link/zone/asset names in place — prompts ask for it; code guarantees it.
Normalisation keeps the snake key, so validated uniqueness/tree properties are preserved."""
@@ -921,6 +949,6 @@ def normalise_names[P: BaseModel](plan_obj: P) -> P:
return plan_obj
-__all__ = ["MAX_GEOMETRY_REASKS", "PLAN_GEOMETRY_ENV", "geometry_check_enabled", "MAX_QUALITY_REASKS", "MAX_VALIDATION_REASKS", "PLAN_TOKENS_MAX", "PlanningError", "plan",
+__all__ = ["MAX_GEOMETRY_REASKS", "articulation_acceptance", "PLAN_GEOMETRY_ENV", "geometry_check_enabled", "MAX_QUALITY_REASKS", "MAX_VALIDATION_REASKS", "PLAN_TOKENS_MAX", "PlanningError", "plan",
"plan_tokens", "plan_with_usage", "plan_example", "ensure_acceptance", "add_acceptance_item",
"default_event_stats", "normalise_names", "build_system_prompt", "build_user_prompt", "load_prompt_or"]
diff --git a/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py b/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
index 7283040d..ffa95fa8 100644
--- a/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
+++ b/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
@@ -64,3 +64,30 @@ def test_switch_off_skips_the_geometry_reask(tmp_ws, monkeypatch):
model = FakeChatModel(lambda req: _bad())
p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model, runtime=FakeRuntime(Language.URDF_BLENDER))
assert isinstance(p, ArticulatedPlan) and len(model.requests) == 1
+
+
+def test_every_moving_joint_gets_an_articulation_acceptance_item(tmp_ws):
+ from codeverse.tracks.planner import articulation_acceptance
+
+ good = _good()
+ good["acceptance"] = [a for a in good["acceptance"] if a.get("how") != "articulation"]
+ good["joints"].append({"name": "LidHinge", "type": "revolute", "parent": "Cabinet", "child": "Drawer",
+ "axis": [1, 0, 0], "pivot": [0, 0.21, 0.55], "lower": 0.0, "upper": 1.2, "rest": 0.0,
+ "motion": "the lid tilts up"})
+ good["joints"][1]["child"] = "Lid"
+ good["parts"].append({"name": "Lid", "role": "top lid", "description": "a flat lid", "attach_to": "Cabinet",
+ "bbox": {"center": [0, 0, 0.61], "extents": [0.4, 0.5, 0.02]}, "material": "oak"})
+ plan_obj = ArticulatedPlan.model_validate(good)
+ items = articulation_acceptance(plan_obj, plan_obj.acceptance)
+ assert [a.id for a in items] == ["art_drawer", "art_lid"]
+ assert all(a.how == "articulation" and a.priority == "should" for a in items)
+ assert "moves over [0.00, 0.35] m" in items[0].text and "closed / stowed" in items[0].text
+ assert "the lid tilts up" in items[1].text and "[0.00, 1.20] rad" in items[1].text
+ # a planner item that already names the drawer covers its joint
+ plan_obj.acceptance.append(type(items[0])(id="j9", text="Drawer slides out 0.35 m cleanly", how="articulation"))
+ assert [a.id for a in articulation_acceptance(plan_obj, plan_obj.acceptance)] == ["art_lid"]
+ # and the full planner path appends them exactly once
+ model = FakeChatModel(lambda req: good)
+ p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model, runtime=FakeRuntime(Language.URDF_BLENDER))
+ ids = [a.id for a in p.acceptance]
+ assert ids.count("art_drawer") == 1 and ids.count("art_lid") == 1