Skip to content

Official Codebase of 3DCodeVerse

Python

trim: tighten new comments to hold the review-3 net-line budget

gaoypeng72413e42c7d3
diff --git a/harness/codeverse/agents/cli_common.py b/harness/codeverse/agents/cli_common.py
index 74180c01..fd9cfd0e 100644
--- a/harness/codeverse/agents/cli_common.py
+++ b/harness/codeverse/agents/cli_common.py
@@ -304,12 +304,10 @@ def mcp_command_for(ws: Workspace, job: AgentJob) -> list[str]:
HARNESS_OWNED_DIRS = ("artifacts", "trajectories", "stages", "rounds", "_cand", "_assets", ".3dcv", ".gemini", ".claude", ".git")
HARNESS_OWNED_FILES = frozenset({"events.jsonl", "run_state.json", "record.json", "AGENTS.md", "GEMINI.md", "CLAUDE.md",
".mcp.json", ".geminiignore", ".aiexclude", ".gitignore"})
-#: gitignored control files git cannot revert: byte-snapshotted by :func:`begin_session`,
-#: compared + restored by :func:`_enforce_scope`. Downstream trusts both blindly
-#: (``ensure_materialized`` once-per-run, ``_prior_record_fields`` merge).
+#: gitignored control files git cannot revert (downstream trusts both blindly):
+#: byte-snapshotted by :func:`begin_session`, compared + restored by :func:`_enforce_scope`
UNTRACKED_CONTROL_FILES = ("run_state.json", "record.json")
-#: the one harness-owned file the harness itself appends to MID-session (event stream):
-#: exempt from the tamper revert — restoring it would delete legitimate harness rows.
+#: the harness appends to the event stream MID-session — exempt from the tamper revert
_CONTROL_EXEMPT = frozenset({"events.jsonl"})
@@ -452,8 +450,7 @@ def _enforce_scope(s: Session) -> dict[str, str]:
reverted: dict[str, str] = {}
restore: list[str] = []
remove: list[str] = []
- # control files are enforced even with an empty write scope — there is no job
- # narrow enough to make run_state.json or AGENTS.md agent-writable
+ # no empty-scope early-out: control files are enforced under ANY job scope
for f in s.ws.changed_files(s.head_before):
parts = Path(f.path).parts
if not parts or parts[0] in HARNESS_OWNED_DIRS or f.path in _CONTROL_EXEMPT:
diff --git a/harness/codeverse/agents/materialize.py b/harness/codeverse/agents/materialize.py
index d3ffd5a0..bb97b21a 100644
--- a/harness/codeverse/agents/materialize.py
+++ b/harness/codeverse/agents/materialize.py
@@ -71,9 +71,8 @@ def _tool_section(agent_kind: str, spatial_tools: bool, mcp_command: list[str],
)
from codeverse.spatial.registry import list_tools
- # the same track/language filter the MCP server applies (mcp_server.build_context):
- # this file is agy's ONLY tool documentation and its shell fallback is unscoped, so
- # documenting the whole registry taught scene/graphics agents dead-end object tools
+ # the MCP server's track/language filter (mcp_server.build_context): this file is
+ # agy's ONLY tool documentation, and the whole registry taught dead-end object tools
track = language = ""
if ws is not None and ws.spec_path.is_file():
try:
diff --git a/harness/codeverse/config.py b/harness/codeverse/config.py
index 8a19df5e..fc0d945d 100644
--- a/harness/codeverse/config.py
+++ b/harness/codeverse/config.py
@@ -225,8 +225,7 @@ class Settings(BaseSettings):
#: knob; both spellings now work and the doctor prints the short one.
_FLAT_ALIASES: ClassVar[dict[str, tuple[str, str]]] = {
"CV3D_MAX_IN_FLIGHT": ("rate", "max_in_flight"),
- # the spelling every doc and the node side (gpu_launch.cjs) use — pydantic-settings
- # only read CV3D_RENDER__GPU, so the documented knob was dead on 2 of 3 tracks
+ # the spelling every doc and gpu_launch.cjs use; only CV3D_RENDER__GPU was read
"CV3D_RENDER_GPU": ("render", "gpu"),
FEWER_TURNS_ENV: ("limits", "fewer_turns"),
SEED_RECIPES_ENV: ("limits", "seed_recipes"),
diff --git a/harness/codeverse/cost/instrument.py b/harness/codeverse/cost/instrument.py
index a16156ba..3923a5ba 100644
--- a/harness/codeverse/cost/instrument.py
+++ b/harness/codeverse/cost/instrument.py
@@ -103,9 +103,8 @@ class MeteredChatModel:
def generate(self, request: ChatRequest) -> ChatResponse:
call_id = uuid4().hex # joins the per-attempt rows to the call's logical row
# captured NOW: a hedge loser lands after this call returned, in a thread with
- # no context, so neither the run's ledger, its name nor the stage/role/round
- # attribution is reachable there — the loser's row used to fall back to what
- # the label alone says (baseline/None instead of candidate/r0)
+ # no context — neither the run's ledger, its name, nor the stage/role/round
+ # attribution (the loser's row used to fall back to the bare label) is reachable
ledger = default_ledger()
run = run_binding().run
ctx = attribute(label=request.label)
diff --git a/harness/codeverse/spatial/render.py b/harness/codeverse/spatial/render.py
index 7c8a504b..6f723acd 100644
--- a/harness/codeverse/spatial/render.py
+++ b/harness/codeverse/spatial/render.py
@@ -115,9 +115,8 @@ def render_glb(
"background": background,
"anim_time": anim_time,
"shadow": bool(shadow),
- # requested mode, not the resolved backend: 'auto' fragments from 'on'/'off',
- # which is accepted over a hit serving the other backend's pixels (and lying
- # about RenderSet.renderer) when someone flips CV3D_RENDER_GPU between runs
+ # requested mode ('auto' fragments from 'on'/'off' — accepted over a hit
+ # serving the other backend's pixels and lying about RenderSet.renderer)
"gpu": gpu,
"rig": _rig_signature(),
}
@@ -185,8 +184,7 @@ def _run_render(glb: Path, out_dir: Path, params: dict[str, Any], *, gpu: str, t
def _store_in_cache(cache_dir: Path, out_dir: Path, record: dict[str, Any]) -> None:
# per-writer tmp + tolerant rename (the vlm_judge._render_slices shape): a pid-only
- # tmp name let two threads of one judge fan-out share a dir — the loser's rmtree
- # deleted the winner's half-copied PNGs AFTER a successful render
+ # name let two judge threads share a tmp dir and delete each other's half-copied PNGs
tmp = cache_dir.parent / f".{cache_dir.name}.{os.getpid()}-{threading.get_ident()}.tmp"
shutil.rmtree(tmp, ignore_errors=True)
try:
diff --git a/harness/codeverse/tracks/candidates.py b/harness/codeverse/tracks/candidates.py
index 07d8cef1..721d296b 100644
--- a/harness/codeverse/tracks/candidates.py
+++ b/harness/codeverse/tracks/candidates.py
@@ -269,16 +269,13 @@ def choose_best_round(ctx: RunContext, rounds: list[RoundRecord], selector: Best
def replay_best_round(journal: Sequence[RoundRecord], selector: BestSelector | None = None) -> int | None:
"""The best index, walking the journal sequentially and honouring stored verdicts.
- ``rNN.json`` + the git commit are durable BEFORE the best is promoted and the state
- saved (``lifecycle._round_loop``), so a kill in that gap — or any resume of a run
- whose state predates ``best_considered_through`` — used to re-rank on score alone
- and reverse a ~$0.05 judgement the run had already bought (18 such runs on disk,
- 2026-08-30). Each round is an incumbent-vs-challenger step: a round that carries a
+ Each round is an incumbent-vs-challenger step: a round carrying a
:class:`PairwiseNote` was decided inside ``policy.pairwise_margin``, where score
ranking has nothing to say, so the stored verdict — replace or keep — is FINAL
- (a later, worse round can never revive a rejected challenger by global re-ranking);
- every other round advances by the same two-way ``BestSelector`` rule, whose key is
- a total order — so absent verdicts this equals the global pick."""
+ (a later round can never revive a rejected challenger by global re-ranking, and a
+ kill before the state save cannot reverse a paid ~$0.05 judgement — 18 such runs
+ on disk, 2026-08-30); every other round advances by the two-way ``BestSelector``
+ rule, whose key is a total order — absent verdicts this equals the global pick."""
selector = selector or BestSelector()
best: int | None = None
for i, rec in enumerate(journal):
diff --git a/harness/codeverse/tracks/generation.py b/harness/codeverse/tracks/generation.py
index ff9f5a85..cfff2c1c 100644
--- a/harness/codeverse/tracks/generation.py
+++ b/harness/codeverse/tracks/generation.py
@@ -509,12 +509,10 @@ def _charge(budget: Any | None, usage: Usage, *, task: GenerationTask, enforce:
def _deadline_preflight(budget: Any | None, wait_s: float, *, soft: bool = False) -> float:
- """Gate a model/agent session on the run clock: refuse to start past the HARD
- ceiling (``budget.check()`` raises — a timed-out session that produced nothing
- bills nothing, so the accounting-driven check alone never fires), and clip the
- session's wait to the remaining wall clock (a flat 30-minute session once ran
- 9 minutes PAST a 30-minute ceiling, measured 2026-08-27). ``soft=True`` keeps
- a caller-chosen window as its stage clipped it (scene.py's shares)."""
+ """Gate a session on the run clock: refuse to start past the HARD ceiling (a
+ timed-out session that produced nothing bills nothing, so the accounting-driven
+ check alone never fires) and clip the wait to the remaining wall clock (a flat
+ 30-minute session once ran 9 minutes past the ceiling, measured 2026-08-27)."""
if budget is None:
return wait_s
if hasattr(budget, "check"):
diff --git a/harness/codeverse/tracks/lifecycle.py b/harness/codeverse/tracks/lifecycle.py
index 484142d7..5fa37d26 100644
--- a/harness/codeverse/tracks/lifecycle.py
+++ b/harness/codeverse/tracks/lifecycle.py
@@ -761,8 +761,7 @@ class BaseTrack:
rebuild_err = f"{type(e).__name__}: {e}"[:300]
ctx.events.emit("finalise.rebuild_failed", error=rebuild_err)
if rebuild_err:
- # keep the earned status + judge scores (they were really paid and judged),
- # but the record must say the deliverable's artifact could not be rebuilt.
+ # keep the earned status + scores; the record says the artifact is gone
ctx.extra["finalise_rebuild_failed"] = rebuild_err
error = error or f"finalise rebuild failed: {rebuild_err}"
if rounds and not rebuild_err and self._texture_wanted(ctx):