Official Codebase of 3DCodeVerse
Python
skills: a body that names one of our constants must pin it, and the corpus audit skips a directory that is not a corpus
gaoypeng7882534bb7a0
diff --git a/harness/codeverse/skills/_claims/cv3d-glsl-craft.toml b/harness/codeverse/skills/_claims/cv3d-glsl-craft.tomlindex 706e9fb0..5d4ed086 100644--- a/harness/codeverse/skills/_claims/cv3d-glsl-craft.toml+++ b/harness/codeverse/skills/_claims/cv3d-glsl-craft.toml@@ -34,3 +34,9 @@ text = "0.98"python = "codeverse.spatial.frame_stats:BLOWN_LUM"scale = 1format = "{:.2f}"++[[claim]]+key = "duplicate_diff"+text = "0.0001"+python = "codeverse.spatial.frame_stats:DUPLICATE_DIFF"+format = "{:g}"diff --git a/harness/codeverse/skills/cv3d-glsl-craft/SKILL.md b/harness/codeverse/skills/cv3d-glsl-craft/SKILL.mdindex c9742536..913e29ef 100644--- a/harness/codeverse/skills/cv3d-glsl-craft/SKILL.md+++ b/harness/codeverse/skills/cv3d-glsl-craft/SKILL.md@@ -25,7 +25,7 @@ corpus actually name.|---|---|---|| static | `STATIC_DIFF` | mean absolute pixel difference between consecutive frames **< 0.002** || flicker | `FLICKER_DIFF` | any consecutive pair **> 0.35** |-| duplicate frames | `DUPLICATE_DIFF` | a pair under 1e-4 (INFO) |+| duplicate frames | `DUPLICATE_DIFF` | a pair under 0.0001 (INFO) || near-flat image | `LOW_DETAIL_EDGE` | mean edge density **< 0.002** (fraction of pixels whose luminance gradient exceeds 0.02) || black / blown | `BLACK_LUM` 0.03, `BLOWN_LUM` 0.98 | > 97% of pixels in every frame; ERROR, and the gate hint asks for mean luminance 0.2-0.6 |diff --git a/harness/tests/skills/test_corpus.py b/harness/tests/skills/test_corpus.pyindex c6c90326..de7953e9 100644--- a/harness/tests/skills/test_corpus.py+++ b/harness/tests/skills/test_corpus.py@@ -25,8 +25,10 @@ produced it, a tight recomputation compares two different populations and failswritten prose. Declaring those queries the way ``_claims/*.toml`` declares constants isthe open item — see docs/SKILLS.md.-Skipped when ``bench/out`` is absent (a fresh checkout, and CI), which is why it is also-marked slow: it walks a few hundred records.+Skipped when ``bench/out`` holds fewer than ``MIN_CORPUS`` graded runs — a fresh checkout,+CI, or a directory holding nothing but an A/B in flight. A corpus that small cannot audit+anything, and asserting against it would fail every honest bundle. Marked slow because it+walks a few hundred records."""from __future__ import annotations@@ -45,11 +47,8 @@ BUNDLES = bundle_dirs()SKILLS = list(iter_skills()) if BUNDLES else []BENCH_OUT = Path(__file__).resolve().parents[2] / "bench" / "out"-pytestmark = [- pytest.mark.slow,- pytest.mark.skipif(not BUNDLES, reason=f"no bundles in {skills_dir()} yet"),- pytest.mark.skipif(not BENCH_OUT.is_dir(), reason="no bench/out in this checkout"),-]+#: below this, the directory is not a corpus and this file has nothing to say+MIN_CORPUS = 50#: "102 graded blender runs", "23 graded urdf_blender runs", "9 graded glsl runs"_CLAIM = re.compile(r"\b(\d+)\s+graded\s+([a-z_]+?)(?:_blender)?\s*runs?\b", re.I)@@ -84,11 +83,14 @@ def _graded_by_language() -> Counter:return out-LIVE = _graded_by_language()-+LIVE = _graded_by_language() if BENCH_OUT.is_dir() else Counter()-def test_the_corpus_is_big_enough_to_be_worth_mining():- assert sum(LIVE.values()) >= 50, f"bench/out only holds {sum(LIVE.values())} graded runs"+pytestmark = [+ pytest.mark.slow,+ pytest.mark.skipif(not BUNDLES, reason=f"no bundles in {skills_dir()} yet"),+ pytest.mark.skipif(sum(LIVE.values()) < MIN_CORPUS,+ reason=f"bench/out holds {sum(LIVE.values())} graded runs, under {MIN_CORPUS}"),+]@pytest.mark.parametrize("s", SKILLS, ids=[s.name for s in SKILLS])diff --git a/harness/tests/skills/test_freshness.py b/harness/tests/skills/test_freshness.pyindex 16b37d4f..ea0926db 100644--- a/harness/tests/skills/test_freshness.py+++ b/harness/tests/skills/test_freshness.py@@ -226,3 +226,23 @@ def test_every_cookbook_section_a_skill_names_exists_in_that_cookbook(s):assert any(want in _squash(t) for t in titles), (f"{s.name} sends the agent to read_cookbook(section={want!r}), "f"which no cookbook of {sorted(langs)} has")++[email protected]("s", SKILLS, ids=[s.name for s in SKILLS])+def test_a_constant_a_body_names_is_also_pinned_by_a_claim(s):+ """Naming `PENETRATION_WARN_M` in prose is a promise about its VALUE.++ ``check_claims`` verifies the rows a bundle declares; nothing verified the rows it+ forgot. A body that names one of our constants is quoting the number beside it, so+ that number needs a claim row — otherwise moving the constant leaves a confident+ sentence with the old value and no test to notice. Found `DUPLICATE_DIFF` quoted at+ 1e-4 in cv3d-glsl-craft with no row behind it.+ """+ from codeverse.skills.claims import load_claims++ pinned = {str(r["python"]).rsplit(":", 1)[-1] for r in load_claims(s.name) if r.get("python")}+ named = {c for c in _CONST.findall(_prose(s.body)) if c in LIVE_CONSTANTS}+ unpinned = sorted(named - pinned)+ assert unpinned == [], (+ f"{s.name} names {unpinned} in prose but pins no claim to it — add a "+ f"[[claim]] row to skills/_claims/{s.name}.toml")