Official Codebase of 3DCodeVerse
Python
scene assets: committed children are reused on resume, never re-paid
gaoypenga5723f07a1ff
diff --git a/harness/codeverse/tracks/scene_assets.py b/harness/codeverse/tracks/scene_assets.pyindex bd706e68..d83c7869 100644--- a/harness/codeverse/tracks/scene_assets.py+++ b/harness/codeverse/tracks/scene_assets.py@@ -166,6 +166,16 @@ def run_asset_stage(ctx: RunContext, *, judge_assets: bool = True) -> dict[str,def build_threejs_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> AssetResult:"""Single-shot → deterministic check → ONE repair → (only then) an agent session."""rel, pascal = asset_file(asset), to_pascal(asset.name)+ # committed-child reuse (review-3 S2): a resume that re-enters the stage — budget+ # stop after the commit, or a failed sibling — must not re-pay a finished asset.+ # Deterministic node import-check only, no model call; the skeleton stub never+ # passes it (single low-poly box), and `ran` guards the checker-unavailable path.+ if (ctx.ws.root / rel).is_file():+ chk0 = check_threejs_asset(ctx, rel, pascal, expected_size_m=asset.approx_size_m)+ if chk0.ran and chk0.ok:+ ctx.events.emit("asset.generated", asset=asset.name, strategy="reused", ok=True, tris=chk0.tris, errors=[])+ return AssetResult(name=asset.name, kind=asset.kind, ok=True, path=rel, size_m=chk0.size_m,+ strategy="reused", notes="committed module reused (import check passed)")sub = single_shot_ctx(ctx)chk: AssetCheck | None = Nonestrategy, notes = "", ""@@ -244,6 +254,13 @@ def _generate_asset(ctx: RunContext, asset: AssetPlan, rel: str, *, language: Ladef build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> AssetResult:"""Sub-workspace → Blender runtime → GLB → public/assets/<snake>.glb."""snake = to_snake(asset.name)+ # committed-child reuse (review-3 S2), blender twin: a GLB only exists at this+ # path when a previous session finished the build+copy; a measurable one is done.+ glb = ctx.ws.root / asset_file(asset)+ if glb.is_file() and glb.stat().st_size > 0 and (size := _measure_size(ctx, glb)) is not None:+ ctx.events.emit("asset.generated", asset=asset.name, strategy="reused", ok=True, tris=0, errors=[])+ return AssetResult(name=asset.name, kind=asset.kind, ok=True, path=asset_file(asset), size_m=size,+ strategy="reused", notes="committed GLB reused")sub_ws = Workspace(ctx.ws.root / "_assets" / snake).create()runtime = ctx.services.runtime(Language.BLENDER)sub_spec = Spec(id=f"{ctx.spec.id}-asset-{snake}", track=Track.STATIC_OBJECT, language=Language.BLENDER,diff --git a/harness/tests/orchestrator_tracks/test_prompts_assets.py b/harness/tests/orchestrator_tracks/test_prompts_assets.pyindex 51a8a8ec..70c2b07b 100644--- a/harness/tests/orchestrator_tracks/test_prompts_assets.py+++ b/harness/tests/orchestrator_tracks/test_prompts_assets.py@@ -104,6 +104,10 @@ def test_scene_templates_render_and_asset_stage_with_blender(tmp_ws, settings):assert crate_jobs == ["asset_crate", "asset_crate_fix"] and crate.fixedassert (tmp_ws.root / "_assets" / "crate" / "src" / "model.py").is_file() and "_assets/" in (tmp_ws.root / ".gitignore").read_text()assert results["FishingBoat"].ok and results["FishingBoat"].path == "src/assets/fishing_boat.js"+ # blender twin of the S2 reuse: the committed GLB short-circuits the second stage run+ n_jobs = len(agent.jobs)+ again = run_asset_stage(ctx)+ assert len(agent.jobs) == n_jobs and again["Crate"].strategy == "reused" and again["Crate"].okapi = asset_api_summary(plan, results)assert "buildFishingBoat" in api and "public/assets/crate.glb" in apisub = asset_plan(plan.assets[2])@@ -122,6 +126,30 @@ def test_scene_templates_render_and_asset_stage_with_blender(tmp_ws, settings):assert "buildBollard" in sa and "FIX PASS" in sa+def test_a_committed_asset_is_reused_on_a_second_stage_run(tmp_ws, settings):+ """Review-3 S2 (V3-claim4): re-entering the stage (budget stop after commit, or a+ failed sibling) reuses a committed, import-clean module without a model call;+ a committed but broken module is regenerated."""+ plan = ScenePlan.model_validate(plan_example(Track.SCENE))+ plan.assets = [a for a in plan.assets if a.kind == "threejs"]+ spec = make_spec(Track.SCENE, Language.SCENE_THREEJS)+ agent = FakeAgent(lambda job, ws: {job.prompt.split("write `")[1].split("`")[0] if "write `" in job.prompt else "src/x.js": _asset_module(job)})+ ctx = _ctx(tmp_ws, settings, spec, plan, agent_id="fake:x", services=FakeServices(judge=FakeJudge(scores=(0.9, 0.9))), agent=agent)+ ctx.runtime.skeleton(tmp_ws, plan)+ tmp_ws.commit("skeleton")+ results = run_asset_stage(ctx)+ assert results["FishingBoat"].ok and results["FishingBoat"].strategy != "reused"+ n_jobs = len(agent.jobs)+ results2 = run_asset_stage(ctx)+ assert len(agent.jobs) == n_jobs, "a committed passing asset must not be re-paid"+ assert results2["FishingBoat"].strategy == "reused" and results2["FishingBoat"].ok+ assert results2["FishingBoat"].path == results["FishingBoat"].path and results2["FishingBoat"].size_m is not None+ # a committed but import-broken module is NOT reused: it goes back through generation+ (tmp_ws.root / results["FishingBoat"].path).write_text("export function nope() {}\n")+ results3 = run_asset_stage(ctx)+ assert len(agent.jobs) > n_jobs and results3["FishingBoat"].strategy != "reused"++def test_a_model_outage_is_not_an_escalation_signal() -> None:"""A 503 reaches the asset stage only after models.retry spent its whole storm budgetwaiting; escalating to a full agent session then costs 10× and hits the same wall."""