Official Codebase of 3DCodeVerse
Python
repair: skill pointers read the build's own reports too — a shader_preflight failure names c3d-threejs-shader-traps
gaoypengf3d4c8e2e145
diff --git a/harness/codeverse3d/tracks/repair.py b/harness/codeverse3d/tracks/repair.pyindex d87a5541..49274508 100644--- a/harness/codeverse3d/tracks/repair.py+++ b/harness/codeverse3d/tracks/repair.py@@ -209,7 +209,7 @@ def build_with_repair(ctx: RunContext, *, round_index: int, label: str, files_hidef make_repair_task(ctx: RunContext, build: BuildResult, lint: GateReport, *, round_index: int, attempt: int,repeats: int, label: str, files_hint: list[str], timeout_s: int | None = None) -> GenerationTask:"""Render prompts/tracks/repair.j2 for the current strategy."""- report = format_error_report(build, lint, ctx.cookbook_text, skills_hook.repair_pointers(ctx, lint))+ report = format_error_report(build, lint, ctx.cookbook_text, skills_hook.repair_pointers(ctx, build, lint))files = files_for_repair(ctx, build, lint, files_hint) if ctx.single_shot else {}prompt = render("tracks/repair.j2", **base_prompt_context(ctx, error_report=report, files=files, repeats=repeats, attempt=attempt,diff --git a/harness/codeverse3d/tracks/skills_hook.py b/harness/codeverse3d/tracks/skills_hook.pyindex 83db743e..8fe6effb 100644--- a/harness/codeverse3d/tracks/skills_hook.py+++ b/harness/codeverse3d/tracks/skills_hook.py@@ -18,7 +18,7 @@ from collections.abc import Sequencefrom typing import Anyfrom codeverse3d.config import get_settings-from codeverse3d.contracts.artifacts import GateReport+from codeverse3d.contracts.artifacts import BuildResult, GateReportfrom codeverse3d.contracts.run import SkillsUsagefrom codeverse3d.tracks.common import RunContext@@ -80,8 +80,10 @@ def with_inlined_skill(ctx: RunContext, tasks: Sequence[Any]) -> list[Any]:return [t.model_copy(update={"prompt": f"{text}\n---\n\n{t.prompt}"}) for t in tasks]-def repair_pointers(ctx: RunContext, lint: GateReport | None) -> str:- """Name the attached skills that answer the CURRENT lint/build failure.+def repair_pointers(ctx: RunContext, build: BuildResult, lint: GateReport) -> str:+ """Name the attached skills that answer the CURRENT failure: the lint and the build's own+ reports (``BuildResult.gates`` — a scene's shader_preflight), the same reports a refine+ round routes on.``tracks/repair.py`` already picks a cookbook section by keyword; this is the sameidea one level up, and it only names skills that are already in the workspace, so it@@ -93,7 +95,7 @@ def repair_pointers(ctx: RunContext, lint: GateReport | None) -> str:from codeverse3d.skills.prompting import repair_pointers as _fmtfrom codeverse3d.skills.registry import ROUTES, finding_kinds- kinds = finding_kinds([lint]) if lint is not None else []+ kinds = finding_kinds([lint, *build.gates])# ANY route for the skill, not just the rules that fired at attach time: the build/lint failure a# repair session is looking at was discovered afterwards, and the sheet that answers it is# already sitting in the workspacediff --git a/harness/tests/skills/test_hook.py b/harness/tests/skills/test_hook.pyindex 1427fb4a..bc116fbb 100644--- a/harness/tests/skills/test_hook.py+++ b/harness/tests/skills/test_hook.py@@ -8,7 +8,7 @@ from types import SimpleNamespace as NSimport pytestfrom codeverse3d.config import get_settings-from codeverse3d.contracts.artifacts import GateFinding, GateReport, Severity+from codeverse3d.contracts.artifacts import BuildResult, GateFinding, GateReport, Severityfrom codeverse3d.tracks import skills_hook as H@@ -38,7 +38,7 @@ def test_the_switch_off_means_no_files_no_events_no_record(ctx, monkeypatch):assert not (ctx.ws.root / ".agents").exists()assert ctx.events == [] and ctx.extra == {}assert H.record_usage(ctx, index=0, kind="baseline") is None- assert H.repair_pointers(ctx, None) == ""+ assert H.repair_pointers(ctx, BuildResult(ok=True, language="blender"), GateReport(gate="lint:blender", passed=True)) == ""def test_no_skill_failure_costs_the_round(ctx, monkeypatch):@@ -61,11 +61,23 @@ def test_no_skill_failure_costs_the_round(ctx, monkeypatch):assert got is not None and got.listed == []-def test_a_repair_names_the_sheet_that_answers_the_lint_it_is_fixing(ctx, monkeypatch):- """The lint is found after the round attached its set: R9 points at the sheet."""+def _report(gate: str, kind: str) -> GateReport:+ return GateReport(gate=gate, passed=False, findings=[GateFinding(gate=gate, severity=Severity.ERROR, message="m",+ data={"kind": kind})])++[email protected](("track", "language", "lint", "build_gates", "sheet"), [+ # the lint is found after the round attached its set: R9 points at the sheet+ ("static_object", "blender", _report("lint:blender", "part_not_imported"), [], "c3d-blender-forms"),+ # a scene's shader error is the BUILD's own report, not the lint's: R21 must see it too+ ("scene", "scene_threejs", GateReport(gate="lint:scene_threejs", passed=True),+ [_report("shader_preflight", "compile_error")], "c3d-threejs-shader-traps"),+])+def test_a_repair_names_the_sheet_that_answers_the_failure_it_is_fixing(ctx, monkeypatch, track, language, lint,+ build_gates, sheet):monkeypatch.setenv("C3D_SKILLS", "on")+ ctx.spec.track.value, ctx.language.value = track, language+ ctx.plan.effects = [NS(kind="shader", description="a custom water shader")]assert H.attach_for_round(ctx, index=0, kind="repair")- lint = GateReport(gate="lint:blender", passed=True, findings=[GateFinding(- gate="lint:blender", severity=Severity.WARN, message="src/parts/leg.py is never imported by src/model.py",- data={"kind": "part_not_imported"})])- assert "c3d-blender-forms" in H.repair_pointers(ctx, lint)+ build = BuildResult(ok=not build_gates, language=language, gates=build_gates)+ assert sheet in H.repair_pointers(ctx, build, lint)