Skip to content

Official Codebase of 3DCodeVerse

Python

restore read_only enforcement and retire the last api-agent fixtures

gaoypeng5882d5afb3de
diff --git a/harness/codeverse/agents/cli_common.py b/harness/codeverse/agents/cli_common.py
index 03cf5360..cb81d8fb 100644
--- a/harness/codeverse/agents/cli_common.py
+++ b/harness/codeverse/agents/cli_common.py
@@ -253,17 +253,20 @@ def begin_session(job: AgentJob, kind: str) -> Session:
def _enforce_scope(s: Session) -> list[str]:
"""Revert a CLI session's out-of-scope writes; returns the reverted paths.
- Post-hoc, because the CLI backends have no write-time file gate. Two layers:
- ``job.write_roots`` ALWAYS (what ``FileTools`` refuses outright for the api-agent —
- a CLI session used to be able to write and commit a root-level ``conftest.py``),
- then, for ``edit_only``, the narrowing to ``files_hint`` + ``always_writable``
- (a pre-existing file outside it is out of scope; new files stay allowed). Only
- safe because sessions on one workspace are serialised (:data:`EXCLUSIVE_KINDS`):
- ``head_before`` holds no sibling's in-flight work."""
+ Post-hoc, because every backend is a vendor CLI and none has a write-time file gate
+ (the in-process one that did was deleted 2026-08-28). Three layers:
+ ``job.read_only`` ALWAYS — harness-owned source the agent must call, never rewrite
+ (``src/recipes.glsl``); ``job.write_roots`` ALWAYS — a CLI session used to be able
+ to write and commit a root-level ``conftest.py``; then, for ``edit_only``, the
+ narrowing to ``files_hint`` + ``always_writable`` (a pre-existing file outside it is
+ out of scope; new files stay allowed). Only safe because sessions on one workspace
+ are serialised (:data:`EXCLUSIVE_KINDS`): ``head_before`` holds no sibling's
+ in-flight work."""
roots = tuple(r.strip("/") for r in s.job.write_roots if r.strip("/"))
+ frozen = frozenset(r for r in (str(x).strip() for x in s.job.read_only) if r)
narrow = (s.files_hint | frozenset(h for h in (str(x).strip() for x in s.job.always_writable) if h)
if (s.job.edit_only and s.files_hint) else frozenset())
- if not roots and not narrow:
+ if not roots and not narrow and not frozen:
return []
restore: list[str] = []
remove: list[str] = []
@@ -271,7 +274,9 @@ def _enforce_scope(s: Session) -> list[str]:
parts = Path(f.path).parts
if not parts or parts[0] in HARNESS_OWNED_DIRS or f.path in HARNESS_OWNED_FILES:
continue
- if roots and not any(f.path == r or f.path.startswith(r + "/") for r in roots):
+ if f.path in frozen:
+ pass # harness-owned: the agent calls it, never rewrites it
+ elif roots and not any(f.path == r or f.path.startswith(r + "/") for r in roots):
pass # outside write_roots: out of scope whatever its status
elif not narrow or f.status == "added" or _hinted(f.path, narrow):
continue
diff --git a/harness/tests/agents/test_cli_write_scope.py b/harness/tests/agents/test_cli_write_scope.py
index cda0a3ed..a973ab60 100644
--- a/harness/tests/agents/test_cli_write_scope.py
+++ b/harness/tests/agents/test_cli_write_scope.py
@@ -137,3 +137,22 @@ def test_unscoped_cli_sessions_keep_the_old_behaviour(scoped_ws: Workspace):
(ws.src / "parts" / "leg.py").write_text("# fine\n")
res = _finish(s)
assert res.ok and (ws.src / "parts" / "leg.py").read_text() == "# fine\n"
+
+
+def test_a_harness_owned_file_is_restored_when_the_agent_rewrites_it(tmp_ws, monkeypatch):
+ """src/recipes.glsl is written by the harness for the agent to CALL. FileTools used
+ to refuse the write outright; with the in-process agent deleted (2026-08-28) the
+ post-hoc check is the only guard, and without this layer the file was unprotected."""
+ owned = "src/recipes.glsl"
+ (tmp_ws.root / owned).parent.mkdir(parents=True, exist_ok=True)
+ (tmp_ws.root / owned).write_text("float aurora(vec2 p){return 0.0;}\n")
+ tmp_ws.commit("harness recipes")
+ job = AgentJob(workspace=str(tmp_ws.root), prompt="p", label="gfx",
+ write_roots=["src/"], read_only=[owned])
+ s = begin_session(job, "codex")
+ (tmp_ws.root / owned).write_text("// clobbered by the agent\n")
+ (tmp_ws.src / "shader.frag").write_text("void main(){}\n")
+ res = finish_session(s, ok=True, exit_reason="completed", text="done", usage=Usage(backend="fake"))
+ assert (tmp_ws.root / owned).read_text().startswith("float aurora"), "harness file must be restored"
+ assert (tmp_ws.src / "shader.frag").is_file(), "the agent's own file survives"
+ assert not res.ok and any(owned in e for e in res.errors)
diff --git a/harness/tests/compare_bench/test_compare_matrix.py b/harness/tests/compare_bench/test_compare_matrix.py
index d924bb47..96e5f395 100644
--- a/harness/tests/compare_bench/test_compare_matrix.py
+++ b/harness/tests/compare_bench/test_compare_matrix.py
@@ -40,7 +40,7 @@ from tests.compare_bench.conftest import ( # noqa: E402
fake_run_track,
)
-ARMS = "harness:api-agent:gemini:gemini-3.7-flash,oneshot:claude-code,oneshot+repair:codex,oneshot:gemini:gemini-3.7-flash"
+ARMS = "harness:gemini-cli:gemini-3.6-flash,oneshot:claude-code,oneshot+repair:codex,oneshot:gemini:gemini-3.7-flash"
def test_battery_compare_v1_is_valid():
@@ -54,7 +54,7 @@ def test_battery_compare_v1_is_valid():
def test_parse_arms():
arms = parse_arms(ARMS)
assert [a.kind for a in arms] == ["harness", "oneshot", "oneshot+repair", "oneshot"]
- assert arms[0].target == "api-agent:gemini:gemini-3.7-flash" and arms[2].target == "codex"
+ assert arms[0].target == "gemini-cli:gemini-3.6-flash" and arms[2].target == "codex"
assert arms[2].slug == "oneshot_plus_repair_codex"
for bad in ("harness", "foo:bar", "oneshot:gemini-cli:x", "oneshot:nope"):
with pytest.raises(ValueError):
@@ -101,7 +101,7 @@ def test_matrix_end_to_end_with_fakes(tmp_path: Path):
rows = run_matrix(BATTERY, out, parse_arms(ARMS), opts, deps)
assert len(rows) == 8 and (out / "matrix.json").is_file()
by = {(r.prompt_id, r.arm): r for r in rows}
- h = by[("cmp_easy_stool", "harness:api-agent:gemini:gemini-3.7-flash")]
+ h = by[("cmp_easy_stool", "harness:gemini-cli:gemini-3.6-flash")]
assert h.status == "scored" and h.score == pytest.approx(0.9) and h.passed and h.build_ok
assert h.gen_cost_usd == pytest.approx(0.9) and h.harness_status == "passed" and h.harness_loop_score == pytest.approx(0.8)
assert h.judge_cost_usd == pytest.approx(0.01) and h.tris == 900 and Path(h.sheet).is_file()
@@ -133,11 +133,11 @@ def test_matrix_end_to_end_with_fakes(tmp_path: Path):
# the arm row is n | dropped | over budget | mean: the two loss columns stay blank when
# nothing was lost, but must always be PRESENT so a drop can never hide (docs/EVAL.md §7)
assert "| arm | kind | n | dropped | over budget | mean |" in md, md
- assert "| harness:api-agent:gemini:gemini-3.7-flash | harness | 2 | | | 0.900 |" in md, md
+ assert "| harness:gemini-cli:gemini-3.6-flash | harness | 2 | | | 0.900 |" in md, md
assert "| cmp_easy_stool | easy | 0.90✓ | 0.60 | 0.75✓ | 0.00 ✗build |" in md
- assert "| harness:api-agent:gemini:gemini-3.7-flash | oneshot:claude-code | 2 | 2 | 0 | 0 | 100% |" in md
+ assert "| harness:gemini-cli:gemini-3.6-flash | oneshot:claude-code | 2 | 2 | 0 | 0 | 100% |" in md
page = (out / "report.html").read_text()
- assert "report_assets/cmp_easy_stool__harness_api-agent_gemini_gemini-3.7-flash.png" in page
+ assert "report_assets/cmp_easy_stool__harness_gemini-cli_gemini-3.6-flash.png" in page
assert len(list((out / "report_assets").glob("*.png"))) == 6
# ---- resume: nothing re-runs, nothing re-judged, results identical
@@ -257,11 +257,11 @@ def test_every_cell_and_its_harness_run_open_a_ledger(tmp_path: Path):
deps = _deps(ev, {"claude-code": FakeBackend(["```python\n" + GOOD.format(score=0.6) + "```"])}, run_track)
out = tmp_path / "cmp"
opts = CompareOptions(judge="gemini:fixed", limit=1, parallel=2, pairwise=False)
- rows = run_matrix(BATTERY, out, parse_arms("harness:api-agent:gemini:gemini-3.7-flash,oneshot:claude-code"),
+ rows = run_matrix(BATTERY, out, parse_arms("harness:gemini-cli:gemini-3.6-flash,oneshot:claude-code"),
opts, deps)
assert len(rows) == 2
cells = {r.arm: Path(r.workspace) for r in rows}
- harness = cells["harness:api-agent:gemini:gemini-3.7-flash"]
+ harness = cells["harness:gemini-cli:gemini-3.6-flash"]
assert [r.label for r in load_ledger(harness / "run")] == ["api-agent:baseline:t0"]
assert [r.label for r in load_ledger(harness)] == ["judge:static_object_v1:r00:s0"]
oneshot = cells["oneshot:claude-code"]
diff --git a/harness/tests/compare_bench/test_degraded.py b/harness/tests/compare_bench/test_degraded.py
index 9dc42227..7fc3fb93 100644
--- a/harness/tests/compare_bench/test_degraded.py
+++ b/harness/tests/compare_bench/test_degraded.py
@@ -55,7 +55,7 @@ def test_flag_degraded_rule(tmp_path, status, stop, rounds, cost, aborted, expec
battery = Battery.load(BATTERY)
opts = CompareOptions(judge="gemini:x", loop_judge="gemini:x", max_usd=2.5, degraded_min_wall_s=0)
deps = CompareDeps(FakeEvaluator(), run_track=_track(status, stop, rounds, cost, aborted))
- r = run_cell(battery, battery.prompts[0], parse_arm("harness:api-agent:gemini:gemini-3.7-flash"), tmp_path, opts, deps)
+ r = run_cell(battery, battery.prompts[0], parse_arm("harness:gemini-cli:gemini-3.6-flash"), tmp_path, opts, deps)
assert r.status == "scored" and r.score is not None
assert (r.harness_stop_reason, r.harness_rounds, r.harness_aborted_rounds) == (stop, rounds, aborted)
assert r.degraded is expect, r
diff --git a/harness/tests/compare_bench/test_infra_failures.py b/harness/tests/compare_bench/test_infra_failures.py
index f1367bf5..3ea23a79 100644
--- a/harness/tests/compare_bench/test_infra_failures.py
+++ b/harness/tests/compare_bench/test_infra_failures.py
@@ -113,7 +113,7 @@ def test_both_failure_paths_classify_the_same_way(tmp_path):
oneshot_backend=lambda t: ApiOneShot("gemini:gemini-3.7-flash", chat_model=DeadModel()))
opts = CompareOptions(judge="gemini:x", loop_judge="gemini:x")
got = {}
- for raw in ("harness:api-agent:gemini:gemini-3.7-flash", "oneshot:gemini:gemini-3.7-flash"):
+ for raw in ("harness:gemini-cli:gemini-3.6-flash", "oneshot:gemini:gemini-3.7-flash"):
arm = parse_arm(raw)
r = run_cell(battery, battery.prompts[0], arm, out, opts, deps)
got[arm.kind] = (r.status, r.score)
@@ -283,7 +283,7 @@ def test_a_harness_planning_failure_is_a_zero_not_a_dropped_cell(tmp_path):
battery = Battery.load(BATTERY)
opts = CompareOptions(judge="gemini:x", loop_judge="gemini:x")
- r = run_cell(battery, battery.prompts[0], parse_arm("harness:api-agent:gemini:gemini-3.7-flash"), tmp_path, opts,
+ r = run_cell(battery, battery.prompts[0], parse_arm("harness:gemini-cli:gemini-3.6-flash"), tmp_path, opts,
CompareDeps(FakeEvaluator(), run_track=no_plan))
assert (r.status, r.score, r.passed, r.build_ok) == ("no_code", 0.0, False, False)
assert r.error.startswith("PlanningError:")
diff --git a/harness/tests/core/test_cli_render_size.py b/harness/tests/core/test_cli_render_size.py
index a99105d4..a96de5a5 100644
--- a/harness/tests/core/test_cli_render_size.py
+++ b/harness/tests/core/test_cli_render_size.py
@@ -60,7 +60,7 @@ def _run(tmp_path: Path, language: Language, track: Track) -> Path:
runs = tmp_path / "runs"
ws = Workspace(runs / "r1").create()
ws.write_json(ws.spec_path, Spec(id="r1", track=track, language=language, prompt="a stool",
- backends=Backends(generator="api-agent:gemini:gemini-3.7-flash")))
+ backends=Backends(generator="gemini-cli:gemini-3.6-flash")))
(ws.artifacts / "object.glb").write_bytes(b"glTF\x02\x00\x00\x00")
return runs
diff --git a/harness/tests/core/test_events.py b/harness/tests/core/test_events.py
index 588f6c47..e28c8a53 100644
--- a/harness/tests/core/test_events.py
+++ b/harness/tests/core/test_events.py
@@ -41,7 +41,7 @@ def test_status_still_prints_the_run_when_events_are_truncated(tmp_path: Path) -
runs = tmp_path / "runs"
ws = Workspace(runs / "stool").create()
spec = Spec(id="stool", track=Track.STATIC_OBJECT, language=Language.BLENDER,
- prompt="a small wooden stool", backends=Backends(generator="api-agent:gemini:gemini-3.7-flash"))
+ prompt="a small wooden stool", backends=Backends(generator="gemini-cli:gemini-3.6-flash"))
ws.write_json(ws.spec_path, spec)
log = EventLog(ws.events_path)
log.emit("run.start")
diff --git a/harness/tests/cost/conftest.py b/harness/tests/cost/conftest.py
index a326e87d..383262cc 100644
--- a/harness/tests/cost/conftest.py
+++ b/harness/tests/cost/conftest.py
@@ -45,7 +45,7 @@ def fake_run(tmp_path: Path) -> Path:
cost_usd=float(session["cost_usd"]) + float(judge_usage["cost_usd"]) + plan_cost)
_write(ws / "record.json", {
"spec": {"track": "static_object", "language": "blender",
- "backends": {"generator": "api-agent:gemini:gemini-3.7-flash",
+ "backends": {"generator": "gemini-cli:gemini-3.6-flash",
"judge": "gemini:gemini-3.1-pro-preview"},
"budget": {"max_usd": 5.0}},
"status": "passed", "baseline_score": 0.6, "final_score": 0.8, "best_round": 0,
diff --git a/harness/tests/flywheel_cli/conftest.py b/harness/tests/flywheel_cli/conftest.py
index e6fb58c5..ce35482e 100644
--- a/harness/tests/flywheel_cli/conftest.py
+++ b/harness/tests/flywheel_cli/conftest.py
@@ -51,7 +51,7 @@ def _judgment(score: float, passed: bool, plan: list[str]) -> Judgment:
def make_fake_run(
runs_dir: Path, slug: str = "wooden_chair_ab12cd34", *, prompt: str = "a wooden dining chair",
- language: Language = Language.BLENDER, generator: str = "api-agent:gemini:gemini-3.7-flash",
+ language: Language = Language.BLENDER, generator: str = "gemini-cli:gemini-3.6-flash",
scores: tuple[float, float] = (0.55, 0.80), with_repair: bool = False, code_v2: str | None = None,
) -> tuple[Workspace, RunRecord]:
ws = Workspace(runs_dir / slug).create()
diff --git a/harness/tests/flywheel_cli/test_bench.py b/harness/tests/flywheel_cli/test_bench.py
index 20f65562..fa1c7494 100644
--- a/harness/tests/flywheel_cli/test_bench.py
+++ b/harness/tests/flywheel_cli/test_bench.py
@@ -56,7 +56,7 @@ def test_run_battery_resume_and_report(tmp_path: Path):
battery = REPO / "bench" / "prompts" / "static_objects_v1.yaml"
out = tmp_path / "bench_out"
scores = {"furn_easy_stool": (0.6, 0.85), "furn_med_dining_chair": (0.5, 0.7), "furn_hard_rolltop_desk": (0.4, 0.6)}
- opts = BenchOptions(parallel=2, limit=4, judge="gemini:gemini-3.7-flash", generator="api-agent:gemini:gemini-3.7-flash")
+ opts = BenchOptions(parallel=2, limit=4, judge="gemini:gemini-3.7-flash", generator="gemini-cli:gemini-3.6-flash")
res = run_battery(battery, out, opts, run_fn=_fake_run_fn(scores, fail_ids={"veh_easy_toy_car"}))
assert len(res) == 4
by_id = {r.id: r for r in res}
diff --git a/harness/tests/flywheel_cli/test_flywheel.py b/harness/tests/flywheel_cli/test_flywheel.py
index 5eedfe88..04fa3b94 100644
--- a/harness/tests/flywheel_cli/test_flywheel.py
+++ b/harness/tests/flywheel_cli/test_flywheel.py
@@ -174,7 +174,7 @@ def test_build_pairs(runs_dir: Path, tmp_path: Path):
assert rep["error"]["type"] == "SyntaxError" and rep["chosen"]["build_ok"] is True
assert "size=3.0" in rep["chosen"]["files"]["src/model.py"]
xb = next(x for x in pairs if x["kind"] == "cross_backend")
- assert xb["chosen"]["generator"].startswith("api-agent") and xb["rejected"]["generator"].startswith("codex")
+ assert xb["chosen"]["generator"].startswith("gemini-cli") and xb["rejected"]["generator"].startswith("codex")
assert xb["delta"] == pytest.approx(0.2)
diff --git a/harness/tests/flywheel_cli/test_run_layout_cli.py b/harness/tests/flywheel_cli/test_run_layout_cli.py
index 163cb82a..ff337384 100644
--- a/harness/tests/flywheel_cli/test_run_layout_cli.py
+++ b/harness/tests/flywheel_cli/test_run_layout_cli.py
@@ -240,7 +240,7 @@ def test_show_prints_three_separated_sections(fake_run):
assert "deliverable/object.glb" in out and "deliverable/src/model.py" in out
assert "static_object_v1" in out # evidence: rubric
assert "spent / budget" in out and "models per role" in out and "price table" in out
- assert "api-agent" in out and "generator" in out # settings: model id per role
+ assert "gemini-cli" in out and "generator" in out # settings: model id per role
def test_show_sections_can_be_selected(fake_run):