Official Codebase of 3DCodeVerse
Python
judge input assembly: a bare base name beside indexed siblings no longer crashes instance_groups
gaoypeng33efb3950d22
diff --git a/harness/codeverse/spatial/measure.py b/harness/codeverse/spatial/measure.pyindex e091d990..a40ebfd1 100644--- a/harness/codeverse/spatial/measure.py+++ b/harness/codeverse/spatial/measure.py@@ -364,7 +364,9 @@ def instance_groups(names: list[str]) -> OrderedDict[str, list[str]]:out: OrderedDict[str, list[str]] = OrderedDict()for key, members in groups.items():if len(members) > 1:- members = sorted(members, key=lambda n: int(_INSTANCE_RE.match(n).group("idx"))) # type: ignore[union-attr]+ # a bare base name ("lens" beside "lens_1") lands in the group without+ # matching the regex — sort it first instead of crashing on the None match+ members = sorted(members, key=lambda n: int(m.group("idx")) if (m := _INSTANCE_RE.match(n)) else -1)out[key if len(members) > 1 else members[0]] = membersreturn outdiff --git a/harness/tests/agents/test_claude_code.py b/harness/tests/agents/test_claude_code.pyindex b8b0a26b..7d14e34d 100644--- a/harness/tests/agents/test_claude_code.py+++ b/harness/tests/agents/test_claude_code.py@@ -72,7 +72,9 @@ def test_argv_includes_mcp_when_materialized(tmp_ws: Workspace):materialize_workspace(tmp_ws, agent_kind="claude-code", contract_md="c", cookbook_rel="", spatial_tools=True,mcp_command=["python", "-m", "codeverse.spatial.mcp_server", "--workspace", str(tmp_ws.root)])a = ClaudeCodeAgent("sonnet", binary="claude")- s = begin_session(AgentJob(workspace=str(tmp_ws.root), prompt="p", system_append="S", max_turns=7), "claude-code")+ s = begin_session(AgentJob(workspace=str(tmp_ws.root), prompt="p", system_append="S", max_turns=7,+ mcp_command=["python", "-m", "codeverse.spatial.mcp_server", "--workspace", str(tmp_ws.root)]),+ "claude-code")argv = a.build_argv(s, "p")assert argv[:3] == ["claude", "-p", "p"]# the config is written fresh into THIS session's trajectory dir from the typed job,@@ -80,7 +82,7 @@ def test_argv_includes_mcp_when_materialized(tmp_ws: Workspace):cfg = Path(argv[argv.index("--mcp-config") + 1])assert cfg.name == "mcp.json" and cfg.parent == s.traj.dirserver = json.loads(cfg.read_text())["mcpServers"]["3dcv"]- assert server["command"].endswith("python") and "--workspace" in server["args"]+ assert server["command"] == "python" and "--workspace" in server["args"] # the TYPED job command, verbatim(tmp_ws.root / ".mcp.json").write_text(json.dumps({"mcpServers": {"3dcv": {"command": "/tmp/evil", "args": []}}}))argv2 = a.build_argv(s, "p") # a tampered workspace file changes nothingdiff --git a/harness/tests/spatial_tools/test_measure.py b/harness/tests/spatial_tools/test_measure.pyindex c98f7fd7..17d57191 100644--- a/harness/tests/spatial_tools/test_measure.py+++ b/harness/tests/spatial_tools/test_measure.py@@ -112,3 +112,12 @@ def test_load_scene_is_never_cached(stool_glb: Path) -> None:assert s1 is not s2g1 = s1.geometry[next(iter(s1.geometry))]assert g1 is not s2.geometry[next(iter(s2.geometry))]+++def test_instance_groups_bare_base_beside_indexed_siblings() -> None:+ """`lens` next to `lens_1` lands in the same group (the bare name is the regex+ non-match) — this crashed the judge input assembly with AttributeError on the+ None match until 2026-08-28 (scope_tj_ss r1/r2 lost their judgments to it)."""+ g = instance_groups(["lens", "lens_2", "lens_1", "tripod"])+ assert g["lens"] == ["lens", "lens_1", "lens_2"]+ assert g["tripod"] == ["tripod"]