Official Codebase of 3DCodeVerse
Python
generation: a single-shot answer can no longer overwrite src/lib/ — the envelope checked harness-owned paths by exact match, the CLI side by directory prefix (B1)
gaoypeng046a965042ee
diff --git a/harness/codeverse3d/tracks/generation.py b/harness/codeverse3d/tracks/generation.pyindex f42687d0..90720191 100644--- a/harness/codeverse3d/tracks/generation.py+++ b/harness/codeverse3d/tracks/generation.py@@ -43,7 +43,7 @@ from pydantic import BaseModel, Fieldfrom codeverse3d.contracts.agent import AgentJob, AgentResult, FileChangefrom codeverse3d.contracts.chat import ChatMessage, ChatRequest, ImagePart-from codeverse3d.contracts.common import Usage+from codeverse3d.contracts.common import Usage, is_harness_ownedfrom codeverse3d.proc import read_json_or_nonefrom codeverse3d.workspace import Workspace@@ -181,7 +181,8 @@ def write_files(``only`` (an ``edit_only`` task's file scope, entry included when owned) skips apath that ALREADY EXISTS and is not listed — new files stay allowed; ``frozen``- (the language's harness-owned files, ``src/recipes.glsl``) is skipped outright.+ (the language's harness-owned files and directories, ``src/recipes.glsl``, ``src/lib/``) is+ skipped outright (``is_harness_owned``, the CLI side's rule).The single-shot envelope has no write-time gate, so this is where a scoped task isstopped from rewriting a sibling's file — the mirror of the CLI backends' post-hoc``_enforce_scope`` (until 2026-08-29 only that side protected the harness files)."""@@ -198,7 +199,7 @@ def write_files(continuedest = ws.root / relexisted = dest.exists()- if rel in owned:+ if is_harness_owned(rel, owned):reason = "harness-owned: call its functions, never rewrite it"if on_skip is not None:on_skip(raw, reason)diff --git a/harness/tests/orchestrator_tracks/test_write_scope.py b/harness/tests/orchestrator_tracks/test_write_scope.pyindex df9b2588..d9e4479e 100644--- a/harness/tests/orchestrator_tracks/test_write_scope.py+++ b/harness/tests/orchestrator_tracks/test_write_scope.py@@ -132,6 +132,25 @@ def test_generate_files_never_rewrites_a_harness_owned_file(tmp_path):assert skip["path"] == "src/recipes.glsl" and "harness-owned" in skip["reason"]++def test_generate_files_never_writes_under_a_harness_owned_directory(tmp_path):+ """``HARNESS_OWNED_SRC`` names ``src/lib/`` as a DIRECTORY; the envelope checked by exact+ match, so a single-shot answer could overwrite the effect library (B1, 2026-09-22) while+ the CLI path (``is_harness_owned``) reverted the same write."""+ ws = Workspace(tmp_path / "ws").create()+ ws.write_json(ws.spec_path, {"language": "scene_threejs", "track": "scene"})+ (ws.src / "lib").mkdir(parents=True)+ (ws.src / "lib" / "post.js").write_text("// harness effect library\n")+ events = EventLog(tmp_path / "e.jsonl")+ answer = ("=== FILE: src/scene.js ===\n// scene\n=== END FILE ===\n"+ "=== FILE: src/lib/post.js ===\n// clobbered\n=== END FILE ===")+ res = generate_files(ws, model=ScriptedModel([(answer, "STOP")]),+ task=GenerationTask(label="baseline", prompt="p"), events=events)+ assert res.ok and [c.path for c in res.files_changed] == ["src/scene.js"]+ assert (ws.src / "lib" / "post.js").read_text() == "// harness effect library\n"+ (skip,) = [e for e in events.read() if e["event"] == "generate.skipped_path"]+ assert skip["path"] == "src/lib/post.js" and "harness-owned" in skip["reason"]+# --------------------------------------------------------------------------- entry ownershipdef test_always_writable_requires_ownership():part = GenerationTask(label="p", prompt="p", files_hint=["src/parts/seat.js"])