Skip to content

Official Codebase of 3DCodeVerse

Python

tests: prompts, scene_prompts, skills, third pass — text the manifest already pins goes, twins fold (205 → 183, −232 lines)

gaoypeng2727bd2005eb
diff --git a/harness/tests/prompts/conftest.py b/harness/tests/prompts/conftest.py
index 84c28d7e..7537086a 100644
--- a/harness/tests/prompts/conftest.py
+++ b/harness/tests/prompts/conftest.py
@@ -22,8 +22,7 @@ PROMPTS_DIR = Path(__file__).resolve().parents[2] / "codeverse3d" / "prompts"
#: `src/lib/`, so a snippet may import from it exactly as an agent's file would
STARTER_LIB = Path(__file__).resolve().parents[2] / "codeverse3d" / "languages" / "scene_threejs" / "starter" / "src" / "lib"
-#: every file of the prompt corpus (relative to codeverse3d/prompts/), read off the tree —
-#: test_files.test_every_prompt_file_is_reached says how the package loads each one
+#: every file of the prompt corpus (relative to codeverse3d/prompts/), read off the tree
PROMPT_FILES = sorted(p.relative_to(PROMPTS_DIR).as_posix() for p in PROMPTS_DIR.rglob("*")
if p.is_file() and p.suffix != ".py" and "__pycache__" not in p.parts)
diff --git a/harness/tests/prompts/test_files.py b/harness/tests/prompts/test_files.py
index bf694b7b..f5ffdc63 100644
--- a/harness/tests/prompts/test_files.py
+++ b/harness/tests/prompts/test_files.py
@@ -1,24 +1,14 @@
-"""Every prompt file exists, renders through the loader, is reached by the package, and keeps its promises."""
+"""Every prompt file exists, renders through the loader, and every language ships its three files."""
from __future__ import annotations
-import ast
-from fnmatch import fnmatch
-
import jinja2
import pytest
from codeverse3d.contracts.common import Language
from codeverse3d.prompts import load_text, render
from codeverse3d.prompts.catalog import language_prompt
-from tests.prompts.conftest import PROMPT_FILES, PROMPTS_DIR, is_template, read_prompt
-
-#: files nothing in the package loads, each with the reason it still ships
-UNREACHED = {
- # the GLSL cookbook tells the agent this example is shipped, but no code copies it into a
- # workspace (review 2026-09-22, owner question Q9: ship it where the cookbook says, or drop it)
- "glsl_shader/examples/aurora_ridge.frag",
-}
+from tests.prompts.conftest import PROMPT_FILES, PROMPTS_DIR, is_template
@pytest.mark.parametrize("rel", PROMPT_FILES)
@@ -33,39 +23,6 @@ def test_prompt_file_contract(rel: str) -> None:
assert seq not in raw, f"{rel} contains {seq!r} which breaks jinja rendering"
-def test_every_prompt_file_is_reached_by_the_package() -> None:
- """A prompt file is loaded by a literal path, an f-string path (``system/role_{role}.j2``) or a
- per-language name through ``catalog.language_prompt`` / ``language_text`` — or it is dead."""
- literals: set[str] = set()
- patterns: list[str] = []
- names: set[str] = set()
- for py in (PROMPTS_DIR.parent).rglob("*.py"):
- for node in ast.walk(ast.parse(py.read_text())):
- if isinstance(node, ast.Constant) and isinstance(node.value, str):
- literals.add(node.value)
- elif isinstance(node, ast.JoinedStr) and isinstance(head := node.values[0], ast.Constant) and "/" in str(head.value):
- patterns.append("".join(v.value if isinstance(v, ast.Constant) else "*" for v in node.values))
- elif (isinstance(node, ast.Call) and getattr(node.func, "id", "") in ("language_prompt", "language_text")
- and len(node.args) == 2 and isinstance(node.args[1], ast.Constant)):
- names.add(node.args[1].value)
- per_language = {language_prompt(lang, n) for lang in Language for n in names}
- reached = {f for f in PROMPT_FILES if f in literals | per_language or any(fnmatch(f, p) for p in patterns)}
- assert set(PROMPT_FILES) - reached == UNREACHED
-
-
-def test_frames_consistent_with_conventions() -> None:
- """Contracts restate the frame; they must agree with conventions.py (Z-up −Y-front
- for blender/cadquery/urdf, Y-up +Z-front for the three.js languages)."""
- for rel in ("blender/contract.md", "cadquery/contract.md", "urdf/contract.md"):
- text = read_prompt(rel).replace("\u2212", "-")
- assert "Z up" in text or "Z is up" in text, f"{rel}: must state Z up"
- assert "-Y front" in text or "-Y is the front" in text, f"{rel}: must state -Y front"
- for rel in ("threejs/contract.md", "scene_threejs/contract.md"):
- text = read_prompt(rel).replace("\u2212", "-")
- assert "Y is up" in text or "Y-up" in text, f"{rel}: must state Y up"
- assert "+Z front" in text or "+Z is the front" in text, f"{rel}: must state +Z front"
-
-
def test_every_language_ships_a_system_prompt_a_contract_and_a_cookbook() -> None:
"""A missing per-language file silently reads as "" through ``language_text``."""
from codeverse3d.tracks.prompting import language_system_prompt
diff --git a/harness/tests/prompts/test_snippets_static.py b/harness/tests/prompts/test_snippets_static.py
index e128fdd7..1008d6f5 100644
--- a/harness/tests/prompts/test_snippets_static.py
+++ b/harness/tests/prompts/test_snippets_static.py
@@ -44,30 +44,6 @@ def test_xml_examples_follow_the_enforced_frame_recipe(rel: str, tmp_path) -> No
assert checked > 0, f"{rel}: expected at least one FK-checkable xml block"
-def test_glsl_strings_are_sane() -> None:
- """GLSL lives inside JS template strings; audit the obvious silent killers
- INSIDE the js code blocks (prose may mention them as pitfalls)."""
- for rel in ("scene_threejs/cookbook.md",):
- for b, body in enumerate(blocks(rel, "js")):
- assert not re.search(r"^\s*#version", body, re.MULTILINE), \
- f"{rel} js block {b}: never write #version in ShaderMaterial GLSL"
- for m in re.finditer(r"^(.*#include <\w+>.*)$", body, re.MULTILINE):
- line = m.group(1).strip()
- if "'" in line:
- # JS source line: inside every quoted chunk, each (escaped-\n separated)
- # GLSL line holding an include must be ONLY the include
- for chunk in re.findall(r"'([^']*#include[^']*)'", line):
- for glsl_line in re.split(r"\\+n", chunk):
- if "#include" not in glsl_line:
- continue
- assert re.fullmatch(r"\s*#include <\w+>\s*", glsl_line), \
- f"{rel} js block {b}: include shares a line with code: {line!r}"
- else:
- # raw GLSL line inside a template literal: must stand alone
- assert re.fullmatch(r"#include <\w+>", line), \
- f"{rel} js block {b}: #include must be alone on its line: {line!r}"
-
-
def test_singleshot_example_parses_with_harness_parser() -> None:
from codeverse3d.tracks import generation as gen
diff --git a/harness/tests/scene_prompts/test_prompt_assembler_contract.py b/harness/tests/scene_prompts/test_prompt_assembler_contract.py
index d2ccec36..3969f32c 100644
--- a/harness/tests/scene_prompts/test_prompt_assembler_contract.py
+++ b/harness/tests/scene_prompts/test_prompt_assembler_contract.py
@@ -2,42 +2,22 @@
from __future__ import annotations
-import re
-
-import pytest
-
from codeverse3d.contracts.plan import CameraPlan
from codeverse3d.languages.scene_threejs import render_scene_js
from codeverse3d.prompts import load_text
-CAMS = [CameraPlan(name="Establishing", position=(1.0, 2.0, 3.0), look_at=(0.0, 1.0, 0.0), fov=44.0)]
-
-
[email protected](scope="module")
-def generated() -> str:
- return render_scene_js(["pond_basin"], CAMS, [], env_ok=True)
-
-
[email protected](scope="module")
-def zone_prompt() -> str:
- return load_text("tracks/scene_zone.j2")
-
[email protected](scope="module")
-def env_prompt() -> str:
- return load_text("tracks/scene_env.j2")
-
-
-def test_generated_scene_js_is_what_we_think_it_is(generated: str) -> None:
- """Guard the four call sites the prompts promise (if this changes, the prompts must)."""
+def test_the_prompts_teach_the_hooks_the_assembler_calls() -> None:
+ """Guard the four call sites the prompts promise (if the assembler changes, the prompts must)."""
+ cams = [CameraPlan(name="Establishing", position=(1.0, 2.0, 3.0), look_at=(0.0, 1.0, 0.0), fov=44.0)]
+ generated = render_scene_js(["pond_basin"], cams, [], env_ok=True)
assert "import { build as buildPondBasin } from './zones/pond_basin.js';" in generated
assert "const env = (await buildEnv(ctx)) || {};" in generated
assert "if (env.update) env.update(t, dt);" in generated
assert "for (const z of zones) if (z.userData.update) z.userData.update(t, dt);" in generated
assert "tickEnv" not in generated and "userData.tick" not in generated
-
-def test_the_prompts_teach_the_hooks_the_assembler_calls(zone_prompt: str, env_prompt: str) -> None:
+ zone_prompt, env_prompt = load_text("tracks/scene_zone.j2"), load_text("tracks/scene_env.j2")
assert "export function build(ctx)" in zone_prompt and "userData.update" in zone_prompt
# the historical bug: `userData.tick`, a hook nothing calls, may appear only as a warning
assert all("never called" in ln for ln in zone_prompt.splitlines() if "userData.tick" in ln)
@@ -45,11 +25,3 @@ def test_the_prompts_teach_the_hooks_the_assembler_calls(zone_prompt: str, env_p
assert "update(t, dt)" in env_prompt and "tickEnv" in env_prompt and "NEVER called" in env_prompt
asset = load_text("tracks/scene_asset.j2")
assert "group.userData.update" in asset and "`userData.tick` is never called" in asset
-
-
-def test_env_prompt_sun_azimuth_matches_the_assembler_regex(env_prompt: str) -> None:
- from codeverse3d.languages.scene_threejs import _SUN_RE
-
- example = re.search(r"`?export const SUN_AZIMUTH_DEG[^`\n]*", env_prompt)
- assert example, "env prompt must show the export the assembler looks for"
- assert _SUN_RE.search("export const SUN_AZIMUTH_DEG = 235;")
diff --git a/harness/tests/scene_prompts/test_quality_teaching.py b/harness/tests/scene_prompts/test_quality_teaching.py
index 0e2698f3..387f3bbb 100644
--- a/harness/tests/scene_prompts/test_quality_teaching.py
+++ b/harness/tests/scene_prompts/test_quality_teaching.py
@@ -18,31 +18,6 @@ def test_scene_rubric_craft_defects_inform_and_cannot_zero_a_scene() -> None:
assert sum(d.penalty for d in r.defects) <= 0.62
-def test_extra_anchor_levels_reach_the_judge_prompt() -> None:
- from codeverse3d.judges.prompt_builder import _rubric_block
-
- block = _rubric_block(load_rubric("scene_v1"))
- assert "0.5: The scene reads as a diorama" in block
- # the four required levels are still rendered, richest first
- idx = [block.index(f" {lvl}: ") for lvl in ("1.0", "0.7", "0.4", "0.1")]
- assert idx == sorted(idx)
-
-
-def test_the_quality_chapters_travel_INSIDE_the_zone_and_env_prompts() -> None:
- """The chapters that decide the score are inlined into the brief (no session fetched them on demand)."""
- from codeverse3d.tracks.scene import ENV_RECIPES, ZONE_RECIPES
-
- cookbook = load_text("scene_threejs/cookbook.md")
- from codeverse3d.prompts.sections import find_section, split_sections
-
- secs = split_sections(cookbook)
- for names in (ENV_RECIPES, ZONE_RECIPES):
- for n in names:
- assert find_section(secs, n) is not None, n
- for tpl in ("tracks/scene_zone.j2", "tracks/scene_env.j2", "tracks/scene_refine.j2"):
- assert "{{ recipes }}" in load_text(tpl), tpl
-
-
def test_cookbook_sections_inlines_whole_chapters_and_clips_safely(tmp_path) -> None:
from types import SimpleNamespace
diff --git a/harness/tests/skills/test_hook.py b/harness/tests/skills/test_hook.py
index ee154c47..73a77788 100644
--- a/harness/tests/skills/test_hook.py
+++ b/harness/tests/skills/test_hook.py
@@ -7,6 +7,7 @@ from types import SimpleNamespace as NS
import pytest
+from codeverse3d.config import get_settings
from codeverse3d.tracks import skills_hook as H
@@ -39,27 +40,21 @@ def test_the_switch_off_means_no_files_no_events_no_record(ctx, monkeypatch):
assert H.repair_pointers(ctx, None) == ""
-
-def test_a_broken_library_costs_the_skills_not_the_round(ctx, monkeypatch, caplog):
- monkeypatch.setenv("C3D_SKILLS", "on")
- monkeypatch.setenv("C3D_SKILLS_DIR", "/definitely/not/a/directory")
- with caplog.at_level("WARNING"):
- got = H.attach_for_round(ctx, index=0, kind="baseline")
- assert got is not None and got.listed == [] # routed nothing, wrote nothing, raised nothing
-
-
-def test_a_failed_attach_clears_the_previous_rounds_set(ctx, monkeypatch):
- """Otherwise round N+1 probes round N's bundles and reports reads it never earned."""
+def test_no_skill_failure_costs_the_round(ctx, monkeypatch):
monkeypatch.setenv("C3D_SKILLS", "on")
assert H.attach_for_round(ctx, index=0, kind="baseline")
- monkeypatch.setattr("codeverse3d.skills.attach_skills",
- lambda *a, **k: (_ for _ in ()).throw(RuntimeError("boom")))
- assert H.attach_for_round(ctx, index=1, kind="refine") is None
+ # a probe failure is logged, not raised
+ with monkeypatch.context() as m:
+ m.setattr("codeverse3d.skills.telemetry.probe_reads", lambda *a, **k: (_ for _ in ()).throw(OSError("boom")))
+ assert H.record_usage(ctx, index=0, kind="baseline") is None
+ # a failed attach clears the previous round's set — otherwise round N+1 probes round N's
+ # bundles and reports reads it never earned
+ with monkeypatch.context() as m:
+ m.setattr("codeverse3d.skills.attach_skills", lambda *a, **k: (_ for _ in ()).throw(RuntimeError("boom")))
+ assert H.attach_for_round(ctx, index=1, kind="refine") is None
assert H.record_usage(ctx, index=1, kind="refine") is None
-
-
-def test_a_probe_failure_is_logged_not_raised(ctx, monkeypatch):
- monkeypatch.setenv("C3D_SKILLS", "on")
- H.attach_for_round(ctx, index=0, kind="baseline")
- monkeypatch.setattr("codeverse3d.skills.telemetry.probe_reads", lambda *a, **k: (_ for _ in ()).throw(OSError("boom")))
- assert H.record_usage(ctx, index=0, kind="baseline") is None
+ # a broken library costs the skills, not the round: routed nothing, wrote nothing, raised nothing
+ monkeypatch.setenv("C3D_SKILLS_DIR", "/definitely/not/a/directory")
+ get_settings.cache_clear()
+ got = H.attach_for_round(ctx, index=2, kind="refine")
+ assert got is not None and got.listed == []
diff --git a/harness/tests/skills/test_loader.py b/harness/tests/skills/test_loader.py
index d09f8dad..dd90a2fd 100644
--- a/harness/tests/skills/test_loader.py
+++ b/harness/tests/skills/test_loader.py
@@ -26,6 +26,8 @@ from tests.skills.conftest import write_bundle
("---\nname: c3d_demo\ndescription: d\n---\nbody\n", "must match"),
("---\n- a\n- b\n---\nbody\n", "must be a YAML mapping"),
("---\nname: c3d-demo\ndescription: d\nmetadata:\n a:\n b: c\n---\nbody\n", "must be a scalar"),
+ ("---\nname: c3d-elsewhere\ndescription: d\n---\nbody\n", "directory name"),
+ (f"---\nname: c3d-demo\ndescription: {'x' * 1025}\n---\nbody\n", "1024"), # the spec's limit
])
def test_malformed_frontmatter_is_rejected_with_a_reason(tmp_path: Path, text: str, expect: str):
d = tmp_path / "c3d-demo"
@@ -35,37 +37,14 @@ def test_malformed_frontmatter_is_rejected_with_a_reason(tmp_path: Path, text: s
parse_skill(d)
-def test_name_must_equal_the_directory_name(tmp_path: Path):
- d = tmp_path / "c3d-elsewhere"
- d.mkdir()
- (d / "SKILL.md").write_text("---\nname: c3d-demo\ndescription: d\n---\nbody\n")
- with pytest.raises(SkillError, match="directory name"):
- parse_skill(d)
-
-
-def test_description_length_is_the_spec_limit(tmp_path: Path):
- d = tmp_path / "c3d-demo"
- d.mkdir()
- (d / "SKILL.md").write_text(f"---\nname: c3d-demo\ndescription: {'x' * 1025}\n---\nbody\n")
- with pytest.raises(SkillError, match="1024"):
- parse_skill(d)
-
-
-def test_validate_reports_budget_evidence_and_layout(tmp_path: Path):
+def test_validate_reports_budget_evidence_layout_symlinks_and_the_verified_date(tmp_path: Path):
d = write_bundle(tmp_path, "c3d-big", evidence="guesswork", body="x\n" * (BODY_MAX_LINES + 5))
(d / "references" / "deeper").mkdir()
(d / "references" / "deeper" / "x.md").write_text("nope")
+ (d / "references" / "link.md").symlink_to(d / "SKILL.md") # codex refuses symlinks
issues = " | ".join(validate_bundle(d))
assert "cap is" in issues and "metadata.evidence" in issues and "one level of references" in issues
-
-
-def test_validate_flags_a_symlink_because_codex_refuses_them(tmp_path: Path):
- d = write_bundle(tmp_path, "c3d-demo")
- (d / "references" / "link.md").symlink_to(d / "SKILL.md")
- assert any("symlink" in i for i in validate_bundle(d))
-
-
-def test_validate_wants_a_verified_date(tmp_path: Path):
+ assert "symlink" in issues
d = tmp_path / "c3d-demo"
d.mkdir()
(d / "SKILL.md").write_text("---\nname: c3d-demo\ndescription: d\nmetadata:\n evidence: measured\n---\nbody\n")
diff --git a/harness/tests/skills/test_materialize_prompting.py b/harness/tests/skills/test_materialize_prompting.py
index 635eb60a..a32ad297 100644
--- a/harness/tests/skills/test_materialize_prompting.py
+++ b/harness/tests/skills/test_materialize_prompting.py
@@ -36,7 +36,7 @@ def ws(tmp_path: Path) -> Path:
# --------------------------------------------------------------------------- files
-def test_bundles_and_the_read_control_land_in_both_roots_as_real_files(ws, library):
+def test_bundles_and_the_read_control_land_in_both_roots_and_an_empty_route_sweeps_them(ws, library):
"""codex refuses symlinks; the never-routed control falsifies the read probe (git diff opens files too)."""
from codeverse3d.skills.materialize import CONTROL_NAME
from codeverse3d.skills.registry import ROUTED_SKILLS
@@ -50,17 +50,11 @@ def test_bundles_and_the_read_control_land_in_both_roots_as_real_files(ws, libra
assert not any(p.is_symlink() for p in (ws / root).rglob("*"))
assert len(written) == 2 * 3 * 2 # 2 roots x (2 skills + control) x (SKILL.md + one reference)
assert CONTROL_NAME not in index_block(skills) and CONTROL_NAME not in ROUTED_SKILLS
-
-
-def test_atime_equals_mtime_after_writing_so_the_read_probe_has_a_zero_point(ws, library):
- for p in materialize_skills(ws, [library["c3d-part-contact"]]):
+ for p in written: # atime == mtime after writing, so the read probe has a zero point
st = os.stat(p)
assert abs(st.st_atime - st.st_mtime) < 0.001
-
-def test_an_empty_selection_still_sweeps_last_rounds_bundles(ws, library):
- """V4b: an empty route still removes last round's bundles — native CLIs discover by directory."""
- materialize_skills(ws, [library["c3d-part-contact"]])
+ # V4b: an empty route still removes last round's bundles — native CLIs discover by directory
out = attach_skills(ws, track="static_object", language="threejs", kind="generation", library={})
assert out.listed == []
for root in SKILL_ROOTS:
@@ -76,18 +70,14 @@ def test_native_loader_backends_get_one_sentence_and_no_second_index(library):
assert index_tokens(skills) < 60
-def test_repair_pointers_name_only_the_gate_fired_skills(library):
+def test_repair_pointers_and_the_inlined_body_come_from_the_gate_fired_skill(library):
sel = select("static_object", "blender", "repair", signals={"multi_part": True},
findings=["connectivity/interpenetration"], library=library)
text = repair_pointers(sel)
assert "c3d-part-contact" in text and "connectivity/interpenetration" in text
assert "c3d-blender-forms" not in text # standing rows are already in the workspace
assert repair_pointers([]) == ""
-
-
-def test_inline_body_picks_the_highest_priority_body_and_respects_the_cap(library):
- sel = select("static_object", "blender", "repair", signals={"multi_part": True},
- findings=["connectivity/interpenetration"], library=library)
+ # single-shot: the highest-priority body is inlined, within the cap
name, text = inline_body(sel)
assert name == "c3d-part-contact" and "c3d-part-contact" in text
assert inline_body(sel, max_tokens=0) == ("", "")
diff --git a/harness/tests/skills/test_only_switch.py b/harness/tests/skills/test_only_switch.py
index 4bfd9d0e..6cab037a 100644
--- a/harness/tests/skills/test_only_switch.py
+++ b/harness/tests/skills/test_only_switch.py
@@ -30,20 +30,13 @@ def _listed(ws, **kw):
plan=_Plan(), **kw).listed
-def test_the_cap_cannot_drop_the_bundle_under_test(ws):
+def test_only_restricts_the_library_and_reaches_the_router(ws, monkeypatch):
"""It restricts the library, not the selection: a max of 1 over the full routing picks another bundle."""
assert _listed(ws, max_skills=1)[0] != "c3d-bbox-contract"
assert _listed(ws, only=frozenset({"c3d-bbox-contract"}), max_skills=1) == ["c3d-bbox-contract"]
-
-
-def test_an_unknown_name_attaches_nothing_rather_than_everything(ws, caplog):
- """A typo makes the variant visibly identical to its control, never the full set."""
+ # a typo makes the variant visibly identical to its control, never the full set
assert _listed(ws, only=frozenset({"c3d-typo"})) == []
- assert "C3D_SKILLS_ONLY" in caplog.text
-
-
-def test_the_switch_reaches_the_router(ws, monkeypatch):
- """``only=`` omitted, attach_skills reads ``C3D_SKILLS_ONLY`` (a comma list, blanks ignored)."""
+ # ``only=`` omitted, attach_skills reads ``C3D_SKILLS_ONLY`` (a comma list, blanks ignored)
monkeypatch.setenv("C3D_SKILLS_ONLY", " c3d-bbox-contract , ")
get_settings.cache_clear()
assert _listed(ws) == ["c3d-bbox-contract"], "attach_skills must consult the switch when only= is omitted"
diff --git a/harness/tests/skills/test_registry.py b/harness/tests/skills/test_registry.py
index d2a85f94..c2708b08 100644
--- a/harness/tests/skills/test_registry.py
+++ b/harness/tests/skills/test_registry.py
@@ -5,7 +5,7 @@ from __future__ import annotations
import json
from pathlib import Path
-from codeverse3d.skills.registry import ROUTES, Route, finding_kind, finding_kinds
+from codeverse3d.skills.registry import ROUTES, finding_kind, finding_kinds
DATA = Path(__file__).parent / "data" / "gate_findings.json"
GOLDEN = json.loads(DATA.read_text())["findings"]
@@ -62,13 +62,6 @@ def test_rule_ids_are_unique_and_the_design_numbers_are_all_present():
assert [r for r in ROUTES if r.rule.startswith("R24")], "R24 (the graphics gate row) is missing"
-def test_every_routed_skill_is_actually_in_the_library():
- """A route naming an absent bundle is silently skipped: retire its rows with the bundle."""
- from codeverse3d.skills import all_skills
-
- assert not (set(r.skill for r in ROUTES) - set(all_skills()))
-
-
def test_gate_fired_rows_always_outrank_standing_rows():
"""Law 2: a repair round must spend its budget on what actually broke."""
fired = [r for r in ROUTES if r.gate_fired]
@@ -86,10 +79,3 @@ def test_route_finding_patterns_are_real_kinds_or_families():
assert pat.split("/", 1)[0] in families, f"{r.rule} routes on unknown family {pat!r}"
-def test_matches_finding_supports_exact_and_family_patterns():
- """E1: repair pointers route through Route.matches_finding."""
- row = Route("X", "c3d-part-contact", 95, findings=("connectivity/*", "joint_sweep/link_overlap"))
- assert row.matches_finding(["connectivity/floating_part"]) == "connectivity/floating_part"
- assert row.matches_finding(["joint_sweep/link_overlap"]) == "joint_sweep/link_overlap"
- assert row.matches_finding(["joint_sweep/disconnected"]) is None
- assert row.matches_finding([]) is None
diff --git a/harness/tests/skills/test_router.py b/harness/tests/skills/test_router.py
index 62e3b9b5..833dee68 100644
--- a/harness/tests/skills/test_router.py
+++ b/harness/tests/skills/test_router.py
@@ -21,12 +21,6 @@ def skills_for(track, language, kind, *, plan=None, **kw):
return [s.skill for s in select(track, language, kind, signals=plan_signals(plan), **kw)]
-def test_custom_shader_is_detected_from_effects_or_from_words():
- assert plan_signals(NS(effects=[NS(kind="glsl_material", description="water")]))["has_custom_shader"]
- assert plan_signals(NS(summary="a raymarched tunnel"))["has_custom_shader"]
- assert not plan_signals(NS(summary="a wooden chair", parts=[part()]))["has_custom_shader"]
-
-
def test_a_repair_round_spends_its_budget_on_what_broke(library):
got = select("static_object", "blender", "repair",
signals=plan_signals(static_plan()),
diff --git a/harness/tests/skills/test_routing_property.py b/harness/tests/skills/test_routing_property.py
index 35da6617..a11816f9 100644
--- a/harness/tests/skills/test_routing_property.py
+++ b/harness/tests/skills/test_routing_property.py
@@ -2,8 +2,6 @@
from __future__ import annotations
-import itertools
-
import pytest
from codeverse3d.skills import all_skills, bundle_dirs, select, skills_dir
@@ -18,9 +16,8 @@ LANGUAGES = ("blender", "cadquery", "threejs", "urdf_blender", "scene_threejs",
"glsl_shader", "opengl_python")
KINDS = ("baseline", "part", "refine", "rebuild", "repair", "env", "zone",
"asset", "asset_fix", "reference")
-#: the boolean plan signals the table may test (n_parts / joint_types are derived)
+#: every plan signal plan_signals() produces — a route requiring any other can never fire
SIGNAL_KEYS = tuple(plan_signals(None))
-FLAGS = tuple(k for k in SIGNAL_KEYS if k not in ("n_parts", "joint_types"))
LIVE_KINDS = sorted({k for row in ROUTES for k in row.findings if not k.endswith("*")} |
{"connectivity/interpenetration", "connectivity/floating_part",
@@ -30,56 +27,16 @@ LIVE_KINDS = sorted({k for row in ROUTES for k in row.findings if not k.endswith
"lint/part_not_imported", "shader/compile_or_binding"})
-def _signal_sets():
- """Every boolean combination, each with the n_parts it implies."""
- for bits in itertools.product((False, True), repeat=len(FLAGS)):
- sig = dict(zip(FLAGS, bits, strict=True))
- sig["n_parts"] = 6 if sig["multi_part"] else 1
- sig["joint_types"] = ["revolute"] if sig["has_joints"] else []
- yield sig
-
-
BASE_INPUTS = [(t, lang, kind) for t in TRACKS for lang in LANGUAGES for kind in KINDS]
def test_every_signal_a_route_requires_is_in_the_input_space():
- """R26/R27 test wants_water / wants_night, which SIGNAL_KEYS (and so FLAGS) once lacked:
- the property tests below never exercised them."""
+ """R26/R27 test wants_water / wants_night, which SIGNAL_KEYS once lacked: a route that
+ requires a signal plan_signals() never sets is dead."""
for row in ROUTES:
assert set(row.requires_all) | set(row.requires_any) <= set(SIGNAL_KEYS), row.rule
-def test_the_cap_and_the_ordering_hold_over_the_whole_input_space():
- """Both settings of allow_unverified: R25–R28 (and the cadquery / threejs forms) name
- inherited-unverified bundles, which route only with it on."""
- expected = 2 * len(LANGUAGES) * len(KINDS) * 2 ** len(FLAGS)
- for track in TRACKS:
- seen = 0
- for unverified, language, kind in itertools.product((False, True), LANGUAGES, KINDS):
- for signals in _signal_sets():
- got = select(track, language, kind, signals=signals, library=LIBRARY, max_skills=5,
- allow_unverified=unverified)
- seen += 1
- assert len(got) <= 5, f"{track}/{language}/{kind} routed {len(got)}"
- assert len({skill.name for skill in got}) == len(got), "duplicate skill"
- priorities = [skill.priority for skill in got]
- assert priorities == sorted(priorities, reverse=True), (
- f"{track}/{language}/{kind} is out of order"
- )
- for skill in got:
- assert skill.rules and skill.reason, f"{skill.name} has no routing reason"
- assert seen == expected, track
-
-
-def test_routing_is_deterministic_over_the_whole_input_space():
- signals = {"multi_part": True, "has_instances": True, "has_custom_shader": True, "n_parts": 4}
- for track in TRACKS:
- for language, kind in itertools.product(LANGUAGES, KINDS):
- a = [s.name for s in select(track, language, kind, signals=signals, library=LIBRARY)]
- b = [s.name for s in select(track, language, kind, signals=signals, library=LIBRARY)]
- assert a == b, f"{track}/{language}/{kind}"
-
-
def test_every_corpus_finding_kind_routes_sanely_from_every_session():
"""A gate finding must never crash the router, never blow the cap, and never
silently outrank nothing — where a row answers it, it must come back at >= 90."""
diff --git a/harness/tests/skills/test_telemetry.py b/harness/tests/skills/test_telemetry.py
index 3dcb483d..78ef7e4b 100644
--- a/harness/tests/skills/test_telemetry.py
+++ b/harness/tests/skills/test_telemetry.py
@@ -143,18 +143,7 @@ def test_the_cli_transcript_is_the_evidence_when_every_session_left_one(ws, libr
assert usage.deep_read_rate == 1 / len(got.listed)
-def test_a_session_without_a_trace_sends_the_probe_back_to_atime(ws, library):
- """A partial trace would under-count exactly as a blind probe over-counts."""
- import time
-
- got = _attach(ws, library)
- _session(ws, "baseline", [{"tool": "Skill", "args": {}, "skill": got.listed[0]}], t=time.time() + 1)
- _session(ws, "repair", [], t=time.time() + 2, traced=False) # e.g. a CLI killed before its record
- usage = probe_reads(ws, got)
- assert usage.evidence == "atime" and usage.surfaced == []
-
-
-def test_only_sessions_after_the_attach_are_credited(ws, library):
+def test_only_traced_sessions_after_the_attach_are_credited(ws, library):
import time
got = _attach(ws, library)
@@ -163,6 +152,12 @@ def test_only_sessions_after_the_attach_are_credited(ws, library):
_session(ws, "baseline", [{"tool": "Read", "args": {"file_path": "src/model.py"}}], t=time.time() + 1)
usage = probe_reads(ws, got)
assert usage.evidence == "transcript" and usage.surfaced == [] # last round's activation is last round's
+ # a session without a trace sends the probe back to atime: a partial trace would
+ # under-count exactly as a blind probe over-counts
+ _session(ws, "baseline", [{"tool": "Skill", "args": {}, "skill": name}], t=time.time() + 2)
+ _session(ws, "repair", [], t=time.time() + 3, traced=False) # e.g. a CLI killed before its record
+ usage = probe_reads(ws, got)
+ assert usage.evidence == "atime" and usage.surfaced == []
def test_a_call_the_cli_marked_failed_read_nothing(ws, library):