Official Codebase of 3DCodeVerse
Python
skills: delete SkillRef, skills_for, SIGNAL_KEYS, the Delivery wrapper and the write-only paths/warnings — five surfaces nothing in production read
gaoypeng12272863c203
diff --git a/harness/codeverse3d/skills/__init__.py b/harness/codeverse3d/skills/__init__.pyindex 862e75e2..c125db59 100644--- a/harness/codeverse3d/skills/__init__.py+++ b/harness/codeverse3d/skills/__init__.py@@ -17,9 +17,9 @@ silently empty for exactly this reason.Public surface for the rest of the harness::- from codeverse3d.skills import skills_for, attach_skills, probe_reads+ from codeverse3d.skills import select, attach_skills, probe_reads-``skills_for`` is pure and testable; ``attach_skills`` writes the routed bundles into a+``select`` is pure and testable; ``attach_skills`` writes the routed bundles into aworkspace and returns what it wrote; ``probe_reads`` says afterwards which of them wereactually opened — from the CLI's own tool calls where its backend recorded them. Everythingis behind ``C3D_SKILLS``: ON by default since 2026-09-22, ``C3D_SKILLS=0`` turns it off.@@ -35,7 +35,6 @@ from codeverse3d.skills.model import (SKILL_FILE,Skill,SkillError,- SkillRef,parse_skill,validate_bundle,)@@ -104,9 +103,9 @@ def load_skill(name: str, root: Path | None = None) -> Skill:from codeverse3d.skills.materialize import attach_skills, materialize_skills # noqa: E402-from codeverse3d.skills.registry import plan_signals, select, skills_for # noqa: E402+from codeverse3d.skills.registry import plan_signals, select # noqa: E402from codeverse3d.skills.telemetry import probe_reads # noqa: E402-__all__ = ["Skill", "SkillError", "SkillRef", "all_skills", "attach_skills", "bundle_dirs",+__all__ = ["Skill", "SkillError", "all_skills", "attach_skills", "bundle_dirs","iter_skills", "load_skill", "materialize_skills", "plan_signals", "probe_reads", "select",- "skills_dir", "skills_for", "validate_bundle"]+ "skills_dir", "validate_bundle"]diff --git a/harness/codeverse3d/skills/materialize.py b/harness/codeverse3d/skills/materialize.pyindex c5066c71..9071252d 100644--- a/harness/codeverse3d/skills/materialize.py+++ b/harness/codeverse3d/skills/materialize.py@@ -83,7 +83,7 @@ CONTROL_REFERENCE_MD = ("Control reference. If this file's access time moved, thdef write_control(ws_root: Path) -> list[Path]:- """Materialise the control bundle into both roots, stamped like the real ones."""+ """The control bundle, in both roots; ``materialize_skills`` stamps it with the rest."""written: list[Path] = []for rel in SKILL_ROOTS:d = Path(ws_root) / rel / CONTROL_NAME@@ -91,9 +91,6 @@ def write_control(ws_root: Path) -> list[Path]:(d / "SKILL.md").write_text(CONTROL_SKILL_MD)(d / "references" / "control.md").write_text(CONTROL_REFERENCE_MD)written += [d / "SKILL.md", d / "references" / "control.md"]- now = time.time()- for p in written:- os.utime(p, (now, now))return written@@ -224,17 +221,15 @@ def attach_skills(out.inlined = nameout.index_tokens = 0if not name:- out.warnings.append("single-shot: every routed body is over the inline cap; nothing inlined")+ log.warning("single-shot: every routed body is over the inline cap; nothing inlined")write_index(ws_root, "")return outtry:- paths = materialize_skills(ws_root, [s.skill for s in sel])+ materialize_skills(ws_root, [s.skill for s in sel])except OSError as e: # a workspace we cannot write is a run problem, not a skills problem- out.warnings.append(f"could not materialise skills: {e}")log.warning("skills not materialised into %s: %s", ws_root, e)return out- out.paths = [str(p) for p in paths]out.index_tokens = index_tokens(sel)write_index(ws_root, index_block(sel))return outdiff --git a/harness/codeverse3d/skills/model.py b/harness/codeverse3d/skills/model.pyindex 0f1ba77d..bc560641 100644--- a/harness/codeverse3d/skills/model.py+++ b/harness/codeverse3d/skills/model.py@@ -63,19 +63,6 @@ class Skill(BaseModel):"""ISO date the bundle's claims were last checked against the harness."""return self.metadata.get("verified", "")- def ref(self) -> SkillRef:- return SkillRef(name=self.name, description=self.description, body_tokens=self.body_tokens)---class SkillRef(BaseModel):- """A skill without its body — what the index block and the run record carry."""-- model_config = {"frozen": True}-- name: str- description: str- body_tokens: int = 0-class Selection(BaseModel):"""One routed skill **with the reason it was routed**, so telemetry can say WHY.@@ -106,13 +93,11 @@ class SkillsMaterialized(BaseModel):listed: list[str] = Field(default_factory=list, description="skill names, in attach order")selections: list[Selection] = Field(default_factory=list, description="the routed rows, with the reason each fired")- paths: list[str] = Field(default_factory=list, description="every SKILL.md written (both roots)")reasons: dict[str, str] = Field(default_factory=dict, description="name → why it was attached")index_tokens: int = Field(default=0, description="estimated tokens the index/mandate adds to message 0")inlined: str = Field(default="", description="single-shot: the one body inlined, '' otherwise")attached_at: float = Field(default=0.0, description="epoch seconds of the attach: the read probe credits ""only tool calls a CLI session logged after it (telemetry.probe_reads)")- warnings: list[str] = Field(default_factory=list)# ===================================================================== loaderdiff --git a/harness/codeverse3d/skills/prompting.py b/harness/codeverse3d/skills/prompting.pyindex b101bad0..c49f88f7 100644--- a/harness/codeverse3d/skills/prompting.py+++ b/harness/codeverse3d/skills/prompting.py@@ -17,46 +17,27 @@ the in-process api-agent and went with it: ``agents/registry.KINDS`` accepts onlfrom __future__ import annotationsfrom collections.abc import Sequence-from dataclasses import dataclassfrom codeverse3d.cost.guard import text_tokensfrom codeverse3d.skills.model import Selection, Skill-__all__ = ["AGENTS_SKILL_ROOT", "CLAUDE_SKILL_ROOT", "Delivery", "delivery_for", "known_backends"]+__all__ = ["AGENTS_SKILL_ROOT", "CLAUDE_SKILL_ROOT", "skill_path"]#: discovery roots, relative to the workspace rootAGENTS_SKILL_ROOT = ".agents/skills"CLAUDE_SKILL_ROOT = ".claude/skills"--@dataclass(frozen=True)-class Delivery:- """What one backend needs in order to see the routed bundles."""-- root: str- """Discovery root this backend reads (bundles are written to every known root anyway,- so one copy is never the only copy — this is the path we NAME to it)."""---#: The whole per-backend policy. One row per backend; a kind not listed here (a test's-#: fake agent) reads the shared ``.agents`` root.-_BACKENDS: dict[str, Delivery] = {- "claude-code": Delivery(root=CLAUDE_SKILL_ROOT),- "codex": Delivery(root=AGENTS_SKILL_ROOT),- "gemini-cli": Delivery(root=AGENTS_SKILL_ROOT),- "agy": Delivery(root=AGENTS_SKILL_ROOT),+#: The whole per-backend policy: the discovery root each backend reads (bundles are written+#: to every root anyway, so this is only the path we NAME to it). One row per backend; a+#: kind not listed here (a test's fake agent) reads the shared ``.agents`` root.+_BACKEND_ROOTS: dict[str, str] = {+ "claude-code": CLAUDE_SKILL_ROOT,+ "codex": AGENTS_SKILL_ROOT,+ "gemini-cli": AGENTS_SKILL_ROOT,+ "agy": AGENTS_SKILL_ROOT,}-def delivery_for(agent_kind: str) -> Delivery:- """The delivery policy for ``agent_kind`` (``codex:gpt-5.6-sol`` is codex)."""- return _BACKENDS.get((agent_kind or "").split(":", 1)[0]) or Delivery(root=AGENTS_SKILL_ROOT)---def known_backends() -> tuple[str, ...]:- return tuple(_BACKENDS)--# ===================================================================== prompting#: what every backend is told. Its own index lists every skill it can see, including any#: the user installed globally, so "the ones that match" is the right instruction there.@@ -67,7 +48,9 @@ _HEADING = "## Skills"def skill_path(name: str, *, agent_kind: str = "") -> str:- return f"{delivery_for(agent_kind).root}/{name}/SKILL.md"+ """Where ``agent_kind``'s loader finds bundle ``name`` (``codex:gpt-5.6-sol`` is codex)."""+ root = _BACKEND_ROOTS.get((agent_kind or "").split(":", 1)[0], AGENTS_SKILL_ROOT)+ return f"{root}/{name}/SKILL.md"def index_block(skills: Sequence[Skill | Selection]) -> str:diff --git a/harness/codeverse3d/skills/registry.py b/harness/codeverse3d/skills/registry.pyindex c0d199e0..b4a10974 100644--- a/harness/codeverse3d/skills/registry.py+++ b/harness/codeverse3d/skills/registry.py@@ -266,11 +266,6 @@ ROUTED_SKILLS: tuple[str, ...] = tuple(dict.fromkeys(r.skill for r in ROUTES))# ===================================================================== routerlog = logging.getLogger(__name__)-#: plan-derived booleans/ints the table may test. Kept here (not on the Plan contracts)-#: because they are a routing concern: adding one must not migrate every stored plan.-SIGNAL_KEYS = ("n_parts", "multi_part", "has_instances", "has_symmetry", "has_assemblies",- "has_joints", "joint_types", "has_custom_shader", "wants_water", "wants_night")-_SHADER_WORDS = ("shader", "glsl", "onbeforecompile", "shadermaterial", "custom material","raymarch", "postprocess", "post-process")@@ -284,7 +279,8 @@ _NIGHT_WORDS = ("night", "neon", "dusk", "evening", "moonlit", "moonlight", "lamdef plan_signals(plan: Any | None) -> dict[str, Any]:"""Route-relevant facts about a plan. Tolerant by design: a missing/partial planyields all-false signals rather than raising, because a planner failure must not- also take out the round's skills."""+ also take out the round's skills. Kept here, not on the Plan contracts: adding a+ routing signal must not migrate every stored plan."""parts = list(getattr(plan, "parts", None) or [])joints = list(getattr(plan, "joints", None) or [])effects = list(getattr(plan, "effects", None) or [])@@ -384,19 +380,3 @@ def select(ranked = sorted(best.values(), key=lambda s: (-s.priority, first_seen[s.name]))return ranked[:max(0, max_skills)]--def skills_for(- track: str,- language: str,- kind: str,- *,- plan: Any | None = None,- findings: Any = (),- library: dict[str, Skill] | None = None,- max_skills: int = 5,- allow_unverified: bool = False,-) -> list[Skill]:- """``select`` without the reasons — the shape most callers want."""- sel = select(track, language, kind, signals=plan_signals(plan), findings=findings,- library=library, max_skills=max_skills, allow_unverified=allow_unverified)- return [s.skill for s in sel]diff --git a/harness/docs/SKILLS.md b/harness/docs/SKILLS.mdindex cd7ca9e2..d2eea5f7 100644--- a/harness/docs/SKILLS.md+++ b/harness/docs/SKILLS.md@@ -65,9 +65,9 @@ skills of its own; each is switched off with the CLI's documented knob where it| `gemini-cli` 0.53.0 | 2 built-ins (skill-creator, antigravity-support) — `gemini skills list` hides them, the model does not | `skills.disabled` in the per-session system settings (by name) | the user roots (`~/.gemini/skills`, `~/.agents/skills`): no switch; none here || `agy` 1.2.8 | 5 built-ins (agy-customizations, antigravity-guide, generative_ui, migrate-workflows, permissioned-github; `agy -p /skills` lists them without a turn) | none per session: built-ins survive even an agent's `inherit_user: false` | all 5 |-**Adding a backend is one row in that table.** A test (`tests/skills/test_delivery.py`)-fails if per-backend knowledge leaks back out into the other modules, and another checks-that `prompting.py` agrees with the policy rather than re-deriving it.+**Adding a backend is one row in that table** (`_BACKEND_ROOTS`, read by `skill_path`). A test+(`tests/skills/test_delivery.py`) fails if per-backend knowledge leaks back out into the other+modules, and another checks that a model-qualified kind (`codex:…`) resolves to its backend's row.### Why only native loaders@@ -193,7 +193,7 @@ against the 20 the rule requires (design §5.2 law 3).## 3. Routing`codeverse3d/skills/registry.py` holds the typed table (R1–R24) and `finding_kind()`, the one-place a gate message is pattern-matched; its router half (`select()`, `skills_for()`) turns+place a gate message is pattern-matched; its router half (`select()`) turns`(track, language, kind, plan signals, findings)` into a ranked, capped, reasoned set.Four laws, all tested:diff --git a/harness/tests/skills/test_delivery.py b/harness/tests/skills/test_delivery.pyindex da68366b..3e34d814 100644--- a/harness/tests/skills/test_delivery.py+++ b/harness/tests/skills/test_delivery.py@@ -2,58 +2,42 @@The owner's requirement: every coding agent shares ONE skill set, extending to a newbackend must be minimal, and the organisation has to hold up. So the whole per-backend-policy is one bit in `skills/prompting.py` — which discovery root — and every consumer-asks it rather than re-deriving. These tests pin that.+policy is one row per backend in `skills/prompting.py` — which discovery root — and every+consumer asks it rather than re-deriving. These tests pin that."""from __future__ import annotations-import pytest--from codeverse3d.skills.prompting import (- AGENTS_SKILL_ROOT,- CLAUDE_SKILL_ROOT,- delivery_for,- known_backends,-)+from codeverse3d.skills.prompting import AGENTS_SKILL_ROOT, CLAUDE_SKILL_ROOT, skill_pathdef test_a_qualified_kind_resolves_to_its_backend():"""`codex:gpt-5.6-sol` is codex; the model suffix must not fall through to unknown."""- assert delivery_for("codex:gpt-5.6-sol") == delivery_for("codex")- assert delivery_for("gemini-cli:gemini-3.6-flash") == delivery_for("gemini-cli")+ assert skill_path("x", agent_kind="codex:gpt-5.6-sol") == skill_path("x", agent_kind="codex")+ assert skill_path("x", agent_kind="claude-code:opus") == skill_path("x", agent_kind="claude-code")def test_claude_code_reads_its_own_root_and_nobody_else_does():"""Read out of the shipped binaries, not assumed: claude-code 2.1 has no `.agents`skill root at all, and the other three have no `.claude` one; an unlisted kind (atest's fake agent) reads the shared one."""- assert delivery_for("claude-code").root == CLAUDE_SKILL_ROOT+ assert skill_path("c3d-x", agent_kind="claude-code") == f"{CLAUDE_SKILL_ROOT}/c3d-x/SKILL.md"for kind in ("codex", "gemini-cli", "agy", "some-future-cli", ""):- assert delivery_for(kind).root == AGENTS_SKILL_ROOT, kind--[email protected]("kind", known_backends())-def test_every_consumer_agrees_with_the_policy(kind):- """`prompting` must not re-derive what `delivery` decides — one source, or they drift."""- from codeverse3d.skills.prompting import skill_path-- d = delivery_for(kind)- assert skill_path("c3d-x", agent_kind=kind) == f"{d.root}/c3d-x/SKILL.md"+ assert skill_path("c3d-x", agent_kind=kind) == f"{AGENTS_SKILL_ROOT}/c3d-x/SKILL.md", kinddef test_adding_a_backend_is_one_row():"""The guard behind the claim: if per-backend knowledge spreads back out of- delivery.py, this catches it. `prompting` may name the backends it re-exports."""+ prompting.py, this catches it."""import pathlibroot = pathlib.Path(__file__).resolve().parents[2] / "codeverse3d"names = ("claude-code", "gemini-cli", "codex")offenders = []for py in (root / "skills").rglob("*.py"):- if py.name in ("delivery.py", "prompting.py"):+ if py.name == "prompting.py":continuetext = py.read_text()if any(f'"{n}"' in text or f"'{n}'" in text for n in names):offenders.append(py.name)- assert not offenders, f"per-backend knowledge leaked out of delivery.py into {offenders}"+ assert not offenders, f"per-backend knowledge leaked out of prompting.py into {offenders}"diff --git a/harness/tests/skills/test_hook.py b/harness/tests/skills/test_hook.pyindex a5dc233a..b8fbc536 100644--- a/harness/tests/skills/test_hook.py+++ b/harness/tests/skills/test_hook.py@@ -96,7 +96,7 @@ def test_single_shot_inlines_one_body_into_every_task(ctx, monkeypatch):monkeypatch.setenv("C3D_SKILLS", "on")ctx.single_shot = Truegot = H.attach_for_round(ctx, index=0, kind="baseline")- assert got.inlined and got.paths == []+ assert got.inlinedclass Task:def __init__(self, prompt):diff --git a/harness/tests/skills/test_loader.py b/harness/tests/skills/test_loader.pyindex a41c0930..489815af 100644--- a/harness/tests/skills/test_loader.py+++ b/harness/tests/skills/test_loader.py@@ -26,7 +26,6 @@ def test_parses_frontmatter_body_and_references(tmp_path: Path):assert s.license == "Apache-2.0" and s.evidence == "measured" and s.verified == "2026-08-25"assert s.references == ("references/table.md", "references/traps.md")assert s.body_tokens > 0 and s.body_lines >= 1- assert s.ref().name == "c3d-demo"def test_a_directory_argument_finds_the_skill_file(tmp_path: Path):diff --git a/harness/tests/skills/test_materialize_prompting.py b/harness/tests/skills/test_materialize_prompting.pyindex fdfb2aad..826c9359 100644--- a/harness/tests/skills/test_materialize_prompting.py+++ b/harness/tests/skills/test_materialize_prompting.py@@ -173,9 +173,10 @@ def test_write_index_ignores_body_files_a_workspace_does_not_have(tmp_path: Pathdef test_attach_routes_writes_and_reports(ws, library):got = attach_skills(ws, track="static_object", language="blender", kind="baseline",plan=_plan(), library=library, max_skills=5, allow_unverified=False)- assert got.listed and got.paths and got.index_tokens > 0+ assert got.listed and got.index_tokens > 0assert set(got.reasons) == set(got.listed)- assert all("c3d-" in p for p in got.paths)+ for root in SKILL_ROOTS:+ assert all((ws / root / n / "SKILL.md").is_file() for n in got.listed)assert MANDATE in (ws / "AGENTS.md").read_text()assert got.inlined == ""@@ -184,7 +185,8 @@ def test_attach_for_a_single_shot_session_inlines_instead_of_writing_files(ws, lgot = attach_skills(ws, track="static_object", language="blender", kind="baseline",plan=_plan(), library=library, single_shot=True,max_skills=5, allow_unverified=False)- assert got.inlined and got.paths == [] and got.index_tokens == 0+ assert got.inlined and got.index_tokens == 0+ assert not any((ws / root / n).exists() for root in SKILL_ROOTS for n in got.listed)assert MARK_BEGIN not in (ws / "AGENTS.md").read_text()diff --git a/harness/tests/skills/test_router.py b/harness/tests/skills/test_router.pyindex 3791f7c4..247fed07 100644--- a/harness/tests/skills/test_router.py+++ b/harness/tests/skills/test_router.py@@ -11,7 +11,7 @@ from types import SimpleNamespace as NSimport pytestfrom codeverse3d.skills.model import EVIDENCE_INHERITED-from codeverse3d.skills.registry import QUIET_KINDS, plan_signals, select, skills_for+from codeverse3d.skills.registry import QUIET_KINDS, plan_signals, selectfrom tests.skills.conftest import write_bundle@@ -23,6 +23,10 @@ def static_plan(n=3, **kw):return NS(parts=[part(f"P{i}", **kw) for i in range(n)], summary="a chair", style_notes="")+def skills_for(track, language, kind, *, plan=None, **kw):+ return [s.skill for s in select(track, language, kind, signals=plan_signals(plan), **kw)]++# --------------------------------------------------------------------------- signalsdef test_plan_signals_read_the_typed_fields():s = plan_signals(NS(parts=[part(instances=4), part(symmetry="mirror_x", children=[NS(name="Burr")])],diff --git a/harness/tests/skills/test_routing_property.py b/harness/tests/skills/test_routing_property.pyindex 6799c4b8..e265a402 100644--- a/harness/tests/skills/test_routing_property.py+++ b/harness/tests/skills/test_routing_property.py@@ -9,7 +9,7 @@ import pytestfrom codeverse3d.skills import all_skills, bundle_dirs, select, skills_dirfrom codeverse3d.skills.model import EVIDENCE_INHERITED-from codeverse3d.skills.registry import QUIET_KINDS, ROUTED_SKILLS, ROUTES, SIGNAL_KEYS+from codeverse3d.skills.registry import QUIET_KINDS, ROUTED_SKILLS, ROUTES, plan_signalspytestmark = pytest.mark.skipif(not bundle_dirs(), reason=f"no bundles in {skills_dir()} yet")@@ -21,6 +21,7 @@ LANGUAGES = ("blender", "cadquery", "threejs", "urdf_blender", "scene_threejs",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)+SIGNAL_KEYS = tuple(plan_signals(None))FLAGS = tuple(k for k in SIGNAL_KEYS if k not in ("n_parts", "joint_types"))JUNK = ("", " ", "no_such_track", "STATIC_OBJECT", "static object", "1", "../etc")