Skip to content

Official Codebase of 3DCodeVerse

Python

scene track: single-shot assets (-78% asset cost) + zone batching + soft sub-budget with graceful degradation + baseline salvage; cost audit package (ledger, price provenance, cache-order helper, cost guard, 3dcv cost) + docs/COST.md; run layout deliverable/evidence/telemetry + migration; CI: ruff + offline pytest matrix (validated in a clean venv, 484 passed); 1159 tests, ruff clean

gaoypeng63f9866b6948
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..e7240691
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,42 @@
+name: CI
+
+on:
+ push:
+ paths: ["harness/**", ".github/workflows/ci.yml"]
+ pull_request:
+ paths: ["harness/**", ".github/workflows/ci.yml"]
+
+jobs:
+ lint:
+ name: ruff (harness)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: "3.13"
+ - run: pip install ruff==0.15.20
+ - run: ruff check --output-format=github .
+ working-directory: harness
+
+ tests:
+ name: offline tests (py${{ matrix.python-version }})
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ python-version: ["3.11", "3.13"]
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: ${{ matrix.python-version }}
+ cache: pip
+ - name: Install the harness (no Blender / node / GPU on the runner)
+ run: pip install -e ./harness[dev]
+ # The suite is marked: `live` needs API keys, `blender` needs a Blender
+ # binary, `node` needs runtime_js/node_modules — none exist on a runner,
+ # so CI runs the pure-python subset (locally: 1159 tests, here ~900).
+ - name: pytest (pure python subset)
+ run: python -m pytest tests/core tests/models tests/judges tests/orchestrator_tracks tests/flywheel_cli tests/bench_prompts tests/cost -q -m "not live and not blender and not node"
+ working-directory: harness
diff --git a/harness/codeverse/cost/__init__.py b/harness/codeverse/cost/__init__.py
index c47e887a..536ce667 100644
--- a/harness/codeverse/cost/__init__.py
+++ b/harness/codeverse/cost/__init__.py
@@ -26,7 +26,13 @@ from codeverse.cost.caching import (
prefix_signature,
render_blocks,
)
-from codeverse.cost.guard import CostEstimate, CostGuard, cheapest_affordable, estimate_call, text_tokens
+from codeverse.cost.guard import (
+ CostEstimate,
+ CostGuard,
+ cheapest_affordable,
+ estimate_call,
+ text_tokens,
+)
from codeverse.cost.ledger import (
CostLedger,
ledger_path,
@@ -38,7 +44,13 @@ from codeverse.cost.ledger import (
)
from codeverse.cost.reconstruct import RunLedger, find_runs, reconstruct, reconstruct_run
from codeverse.cost.report import console, markdown
-from codeverse.cost.routing import ROUTES, Route, default_route, pro_break_even, samples_for_precision
+from codeverse.cost.routing import (
+ ROUTES,
+ Route,
+ default_route,
+ pro_break_even,
+ samples_for_precision,
+)
from codeverse.cost.types import CallCost, CostBucket, Role, Stage, Summary
__all__ = [
diff --git a/harness/codeverse/cost/ledger.py b/harness/codeverse/cost/ledger.py
index e88c7fd6..e5dbbf3a 100644
--- a/harness/codeverse/cost/ledger.py
+++ b/harness/codeverse/cost/ledger.py
@@ -24,8 +24,21 @@ from pathlib import Path
from typing import Any
from codeverse.contracts.common import Usage
-from codeverse.cost.types import CallCost, CostBucket, Role, Stage, Summary, normalise_ids, stage_for_label
-from codeverse.models.pricing import cache_write_surcharge, estimate_cost, price_provenance, unit_prices
+from codeverse.cost.types import (
+ CallCost,
+ CostBucket,
+ Role,
+ Stage,
+ Summary,
+ normalise_ids,
+ stage_for_label,
+)
+from codeverse.models.pricing import (
+ cache_write_surcharge,
+ estimate_cost,
+ price_provenance,
+ unit_prices,
+)
log = logging.getLogger(__name__)
diff --git a/harness/codeverse/prompts/scene_threejs/cookbook.md b/harness/codeverse/prompts/scene_threejs/cookbook.md
index 52669bc4..3c13174c 100644
--- a/harness/codeverse/prompts/scene_threejs/cookbook.md
+++ b/harness/codeverse/prompts/scene_threejs/cookbook.md
@@ -131,9 +131,9 @@ objects, animation fanned out through `env.update` and `zone.userData.update`.
## Ground that reads real (blend, paths, edges — never one flat colour)
-A single-colour plane is the #1 reason a scene reads as a toy. Real ground is
-**three or four materials blended by height, slope and noise**, with paths carved into
-the height function itself and dressed edges where anything meets it.
+A single-colour plane is the #1 reason a scene reads as a toy. Real ground is **three or
+four materials blended by height, slope and noise**, with paths carved into the height
+function itself and dressed edges where anything meets it.
```js
// --- deterministic value noise (no textures, no Math.random) -----------------
@@ -240,7 +240,8 @@ colour, or a raised bed that is a sharp box on top of grass, are both graded as
## Horizon: the world must not end (fixing `world_edge_visible`)
The single most repeated judge complaint on this track is *"a hard world edge is visible
-against the sky"*. Three cheap rules kill it for good:
+against the sky"*. Five rules kill it for good — and rules 4 and 5 are what separate a
+hazy horizon from *"plain untextured beige cut-outs"*, which scores worse than no backdrop:
1. **Ground reaches past the fog.** Ground size ≥ `2.4 × fogFar`. Detail only needs to
exist inside the bounds; beyond that, one big low-resolution disc is enough.
@@ -248,23 +249,33 @@ against the sky"*. Three cheap rules kill it for good:
instead of ending at it — and `fogFar` must be scaled to the scene (see the
time-of-day chapter: the table is for a 100 m scene, multiply by `diag / 100`).
3. **A silhouette ring** at `radius ≈ 0.6 × fogFar` (and ≥ 2 × the bounds half-diagonal):
- 24–40 low-poly hills / treeline / rooftops / mesa blocks, height 0.06–0.12 × radius,
- tinted **65–80 %** of the way toward the fog colour. At 0.6 × fogFar the fog itself
- desaturates them into aerial perspective — measured on a 45 m garden with fog 16/77 m:
- a ring at 46 m reads as distant hills, the same ring at 95 m reads as a spiky crater
- wall and the same ring at 20 m reads as a stone circle.
+ 24–40 low-poly hills / treeline / rooftops / mesa blocks, height 0.06–0.12 × radius.
+ Measured on a 45 m garden with fog 16/77 m: a ring at 46 m reads as distant hills, the
+ same ring at 95 m reads as a spiky crater wall, at 20 m as a stone circle.
+4. **Never hand-tint the backdrop toward the fog colour.** `scene.fog` already blends
+ every fogged material toward the fog colour by distance; lerping the material as well
+ double-applies it, and against a *light* fog (a golden or overcast horizon) it makes the
+ backdrop BRIGHTER than the terrain — which renders as pale cardboard and is graded
+ `placeholder_material`. Give it its natural colour **darkened**
+ (`base.multiplyScalar(0.6–0.8)`) and let fog do the haze. Verified A/B on one frame
+ with fog 0xf7cf9e: hand-lerped = beige cut-outs, darkened = receding hazy hills.
+5. **Solid geometry, never flat cut-outs.** A distant treeline is cones/boxes with volume;
+ a `PlaneGeometry` billboard reads as cardboard from every oblique and overview camera,
+ and its base floats.
```js
function buildHorizonRing(THREE, opts = {}) {
const r = opts.radius ?? (opts.fogFar ? opts.fogFar * 0.6 : 60); // 0.6 x fog far
const n = opts.count ?? 30, h0 = opts.minHeight ?? r * 0.06, h1 = opts.maxHeight ?? r * 0.12;
const base = new THREE.Color(opts.color ?? 0x3d5236), fog = new THREE.Color(opts.fogColor ?? 0xa8c4dd);
+ const dark = opts.darken ?? 0.72; // scene.fog supplies the haze; we only darken
const shape = opts.shape ?? 'hill'; // 'hill' (cone) | 'block' (city) | 'mesa'
const geo = shape === 'hill' ? new THREE.ConeGeometry(1, 1, 7)
: shape === 'mesa' ? new THREE.CylinderGeometry(0.75, 1, 1, 6)
: new THREE.BoxGeometry(1, 1, 1);
geo.translate(0, 0.5, 0); // origin at the base
- const mat = new THREE.MeshStandardMaterial({ color: base.clone().lerp(fog, opts.hazeMix ?? 0.7), roughness: 1, flatShading: true });
+ // hazeMix stays 0 unless the ring sits past fog.far, where fog can no longer reach it
+ const mat = new THREE.MeshStandardMaterial({ color: base.clone().multiplyScalar(dark).lerp(fog, opts.hazeMix ?? 0), roughness: 1, flatShading: true });
const mesh = new THREE.InstancedMesh(geo, mat, n);
const m = new THREE.Matrix4(), q = new THREE.Quaternion(), up = new THREE.Vector3(0, 1, 0), p = new THREE.Vector3(), s = new THREE.Vector3();
for (let i = 0; i < n; i++) {
@@ -280,7 +291,8 @@ function buildHorizonRing(THREE, opts = {}) {
mesh.name = 'HorizonRing'; mesh.castShadow = false; mesh.receiveShadow = false;
return mesh; // add to the SCENE (env), never to a zone
}
-console.log('horizon ring', buildHorizonRing(THREE, { shape: 'block', color: 0x2b3140 }).count);
+const ringDemo = buildHorizonRing(THREE, { shape: 'block', color: 0x2b3140, fogFar: 77 });
+console.log('horizon ring', ringDemo.count, 'r', (77 * 0.6).toFixed(1), '#' + ringDemo.material.color.getHexString());
```
Indoor scenes (greenhouse, cabin) need no ring — but the *outside* seen through the glass
@@ -295,17 +307,14 @@ row of the time-of-day table below for sky, sun, fill and fog, then add **practi
every lantern, window and fire is an emissive surface plus a small PointLight:
```js
-function addPracticals(THREE, scene, spots) {
+function addPracticals(THREE, scene, spots) { // ≤ 12; none cast shadows
const glowMat = new THREE.MeshStandardMaterial({ color: 0xffc070, emissive: 0xffa040, emissiveIntensity: 3.0 });
- const out = [];
- for (const [i, [x, y, z]] of spots.entries()) {
+ return spots.map(([x, y, z], i) => {
const bulb = new THREE.Mesh(new THREE.SphereGeometry(0.15, 12, 8), glowMat);
bulb.position.set(x, y, z); bulb.name = `Practical${i}`;
- const light = new THREE.PointLight(0xffa040, 1.5, 9, 2); // ≤ 12 of these, none cast shadows
- light.position.set(x, y, z);
- scene.add(bulb, light); out.push(light);
- }
- return out; // flicker them from update(): intensity ×0.75…×1.3
+ const light = new THREE.PointLight(0xffa040, 1.5, 9, 2); light.position.set(x, y, z);
+ scene.add(bulb, light); return light; // flicker from update(): ×0.75…×1.3
+ });
}
console.log('practicals', addPracticals(THREE, new THREE.Scene(), [[4, 1.8, 2], [-3, 2.1, 5]]).length);
```
@@ -315,11 +324,11 @@ practicals); hemisphere sky/ground colours carry the mood — turning the key do
you make dusk, tinting it is; ground albedo ≥ 0.25; no black `scene.background` (the sky
gradient's horizon band is the brightest thing in the frame).
-**Exposure self-check (after each build):** run `scene_views` and read the frame table
-(`camera_checks` in the render's metrics.json) for every authored camera: `mean_lum` ≥ 0.15,
-`dark_frac` ≤ 0.25, `blown_frac` ≤ 0.10, `content_frac` ≥ 0.25 on the establishing shot. If
-the establishing frame is below 0.15, raise HemisphereLight by +0.3 and the key by +0.8 and
-re-render — do not ship a frame you cannot read.
+**Exposure self-check (after each build):** `scene_views` → the frame table
+(`camera_checks` in metrics.json) for every authored camera: `mean_lum` ≥ 0.15, `dark_frac`
+≤ 0.25, `blown_frac` ≤ 0.10, `content_frac` ≥ 0.25 on the establishing shot. Below that,
+raise HemisphereLight by +0.3 and the key by +0.8 and re-render. Black shade is the most
+common cause: at sun elevation < 25° keep the hemisphere ≥ 1.0.
## Atmosphere: time-of-day triads with numbers
@@ -431,10 +440,9 @@ the shoreline (a radial depression term) or the shore z-fights.
## Vegetation that reads real (species, jitter, clusters, ground cover)
-A ring of identical cones is the second most common complaint. Fix it with **three to
-five species**, per-instance **scale / hue / rotation jitter**, **clustered** placement and
-a **ground-cover** layer. Every one of these is instanced, so the whole forest is 6–10
-draw calls.
+A ring of identical cones is the second most common complaint. Fix it with **three to five
+species**, per-instance **scale / hue / rotation jitter**, **clustered** placement and a
+**ground-cover** layer — all instanced, so a whole forest is 6–10 draw calls.
```js
// One species = one geometry pair (trunk + crown) with its own silhouette + hue band.
@@ -532,14 +540,14 @@ const coverDemo = buildGroundCover(THREE, { count: 400, area: { x: 0, z: 0, w: 2
console.log('ground cover', coverDemo.count, 'tris', coverDemo.count * 3);
```
-Density per 100 m² of planted zone: 2–5 trees, 8–20 shrubs, 250–600 ground-cover tufts,
-30–80 litter pieces. Less than that and the judge writes *"monotonous / undressed"*.
+Density per 100 m² of planted zone: 2–5 trees, 8–20 shrubs, 250–600 tufts, 30–80 litter
+pieces. Less and the judge writes *"monotonous / undressed"*.
## Rocks, cliffs and boulders that read organic (never a row of boxes)
-Stacked cuboids read as buildings — the desert-canyon run lost 0.2 to exactly that. A
-rock is a **noise-displaced polyhedron**; a cliff is a **ridge polyline of rotated,
-non-uniformly scaled rock chunks with jittered strata**, never an axis-aligned wall.
+Stacked cuboids read as buildings — the desert-canyon run lost 0.2 to exactly that. A rock
+is a **noise-displaced polyhedron**; a cliff is a **ridge polyline of rotated, non-uniformly
+scaled chunks with jittered strata**, never an axis-aligned wall.
```js
function rockGeometry(THREE, { radius = 1, detail = 1, rough = 0.34, seed = 1 } = {}) {
@@ -603,9 +611,8 @@ Counts that read as *lived in*, per zone (a zone is typically 10 × 10 m to 30
| interior | 3–6 (bench rows, water feature) | 15–30 (pots, tools, watering cans, crates) | 40–100 (labels, trowels, gloves, jars) | n/a |
Cheap rules: 3 size bands per prop family, one InstancedMesh per band; place props
-**against something** (a wall base, a path edge, under a bench) — props alone in open
-ground read as scatter, not dressing; never a perfect grid or ring (≥ 20 % positional
-jitter, full yaw jitter).
+**against something** (wall base, path edge, under a bench) — props alone in open ground
+read as scatter; never a grid or ring (≥ 20 % positional jitter, full yaw jitter).
## Zones (`src/zones/*.js`): Groups with a bbox discipline
@@ -733,13 +740,13 @@ swayDemo.userData.update(1.5); const a1 = swayDemo.rotation.z;
console.log('sway delta (rad) over 1.5s', Math.abs(a1 - a0).toFixed(3), (Math.abs(a1 - a0) > 0.05 ? 'VISIBLE' : 'TOO SMALL'));
```
-Self-check: after `scene_views(times=[0, 1.5])`, look at the two sheets side by side. If
-you cannot point at what changed, the amplitude is too small — double it.
+Self-check: after `scene_views(times=[0, 1.5])` compare the two sheets. If you cannot
+point at what changed, double the amplitude.
## Scene layering: foreground, midground, background
-A "diorama on an empty plane" scores ~0.5 whatever else you do. Every authored camera
-must have **three depth layers**, and you build them on purpose:
+A "diorama on an empty plane" scores ~0.5 whatever else you do. Every authored camera needs
+**three depth layers**, built on purpose:
| layer | distance from camera | what lives there | how much of the frame |
|---|---|---|---|
@@ -793,9 +800,8 @@ Skipped instances are not deleted — write a zero-scale matrix (`m.makeScale(0,
the instance count and every index stay stable.
**Atmospheric perspective** does the rest: with fog matching the sky, a background object
-loses contrast and saturation with distance for free. Push it further by tinting distant
-materials 40–70 % toward the fog colour (`base.clone().lerp(fogColor, 0.5)`), as the
-horizon ring does.
+loses contrast and saturation with distance for free — do not hand-tint on top of it (see
+the horizon chapter); darken the distant material instead.
## Cameras: measured, never guessed
@@ -824,23 +830,11 @@ establishing → mid → detail. Compute positions from measured bounds/heightA
## Post-processing (optional; the default pipeline renders WITHOUT it)
-Imports: `EffectComposer`, `RenderPass`, `UnrealBloomPass`, `OutputPass` from
-`three/addons/postprocessing/*.js`.
-
-```js
-// Export from scene.js ONLY if the plan asks for bloom; harness support is optional, so
-// the scene must also look right without it (emissiveIntensity ≤ 3, no white-out).
-function makeComposer(THREE, renderer, scene, camera, width, height) {
- const composer = new EffectComposer(renderer);
- composer.setSize(width, height);
- composer.addPass(new RenderPass(scene, camera));
- const bloom = new UnrealBloomPass(new THREE.Vector2(width, height), 0.35, 0.6, 0.85);
- composer.addPass(bloom); // strength ≤ 0.5, threshold ≥ 0.8: glow, not soup
- composer.addPass(new OutputPass()); // ALWAYS last: tone mapping + sRGB live here
- return composer;
-}
-console.log('composer factory ready', typeof makeComposer);
-```
+Only if the plan asks for bloom, and the scene must still read without it
+(`emissiveIntensity` ≤ 3, no white-out). Build an `EffectComposer` from
+`three/addons/postprocessing/*`: `RenderPass` → `UnrealBloomPass(new THREE.Vector2(w, h),
+0.35, 0.6, 0.85)` (strength ≤ 0.5, threshold ≥ 0.8 — glow, not soup) → `OutputPass` **last**
+(tone mapping + sRGB live there), and export it from `scene.js` alongside the scene.
## Performance budget
@@ -888,9 +882,9 @@ console.log('composer factory ready', typeof makeComposer);
"Motion you can SEE".
16. **A tree 1 m in front of the establishing camera** → the scatter loop had no camera
mask; see `cameraMask` in "Scene layering".
-17. **Distant hills look like bright orange spikes, not haze** → the silhouette ring sits
- far inside `fog.far` (so fog never touches it) or its `hazeMix` is < 0.6. Ring radius
- ≈ 0.6 × fog far; fog far itself must be scaled to the bounds diagonal.
+17. **The backdrop reads as pale cardboard** → hand-lerped toward a light fog colour
+ (double haze → brighter than the ground) and/or built from flat planes. Darken the
+ base colour, let `scene.fog` haze it, use solid geometry.
18. **Jagged / stair-stepped shadows** → shadow texel = `2 × shadowSpan / mapSize`; keep it
≤ 0.05 m. A 60 m span needs 3072², a 100 m span needs 4096² — or shrink the span to
the bounds instead of the whole terrain.
@@ -898,6 +892,12 @@ console.log('composer factory ready', typeof makeComposer);
(HemisphereLight sky colour) must be ≥ 60° of hue away from the sun colour.
20. **The scene is a diorama on a plane** → no foreground layer and no background layer.
Three depth layers per authored camera, always ("Scene layering").
+21. **A pond / terrace / lawn is a hard-edged disc or square lying ON the ground** → carve
+ it into `heightAt` (a radial depression for water, a shallow shelf for a terrace) and
+ ring the seam with a kerb + dressing; a plane laid on top always shows its outline.
+22. **`camera is N m below ground level`** → the plan's camera heights are absolute
+ (metres above y = 0) but the terrain lifted the floor. Keep `heightAt` within about
+ ±1.5 m of 0 inside the bounds, or add `heightAt(x, z)` to the camera's y in scene.js.
## Self-check (before you call it done)
diff --git a/harness/codeverse/prompts/tracks/plan_scene.j2 b/harness/codeverse/prompts/tracks/plan_scene.j2
index 63aaceed..8108fa9b 100644
--- a/harness/codeverse/prompts/tracks/plan_scene.j2
+++ b/harness/codeverse/prompts/tracks/plan_scene.j2
@@ -29,12 +29,16 @@ WHAT TO PRODUCE (JSON, fields: {{ schema_fields }}):
out monochrome;
(c) fog hex (= the sky HORIZON colour, never white or grey unless overcast) + near/far in
meters, scaled to this scene: near ~ 0.4 x the bounds diagonal, far ~ 2 x the diagonal;
- (d) ground: the 3-4 material colours that blend across it (e.g. moss 0x4a602e, dry grass
+ (d) ground: the terrain stays within about +/-1.5 m of y = 0 inside the bounds (camera
+ heights below are absolute, and a lifted floor puts them underground); ponds, terraces
+ and gravel beds are carved INTO the terrain, never laid on it as flat discs;
+ the 3-4 material colours that blend across it (e.g. moss 0x4a602e, dry grass
0x8a8148, packed dirt 0x6b5334, gravel 0xa89a7c), which drives the blend (height, slope,
noise), and where the PATH runs as a polyline of 3-5 (x, z) points, 1.2-2.0 m wide;
(e) the BACKDROP that hides the world edge: a silhouette ring (hills / treeline / rooftops /
- mesas) at radius ~ 0.6 x fog far, 24-40 pieces, tinted 70 % toward the fog colour — or,
- for an interior, what is seen through the glass;
+ mesas) at radius ~ 0.6 x fog far, 24-40 SOLID pieces (never flat cut-out planes) in
+ their own colour darkened 0.6-0.8x — the scene fog supplies the haze, so never tint
+ them toward the fog colour — or, for an interior, what is seen through the glass;
(f) water plane height + colour, if any.
4. `zones` — 3 to 6 spatial regions with PascalCase names, a `bbox`, and `contents` = asset names
placed there. Zone bboxes tile the bounds without overlapping by more than 1 m.
@@ -77,10 +81,21 @@ WHAT TO PRODUCE (JSON, fields: {{ schema_fields }}):
for that shot ("establishing: the arched bridge at 14 m, framed by the maple on the right at
3 m, cedar ridge on the horizon").
- No camera may be inside or within 0.5 m of geometry; fov 35-60.
-9. `acceptance` — 6 to 12 items: each must-have from the brief, the hero assets visible from the
- establishing camera, time-of-day lighting reads correctly, the hero motion is visible between
- t=0 and t=1.5 s, no floating or sunken assets (`how: probe`), no hard world edge visible from
+9. `acceptance` — 6 to 12 items covering: each must-have from the brief, the hero assets visible
+ from the establishing camera, time-of-day lighting reads correctly, the hero motion is visible
+ between t=0 and t=1.5 s, no floating or sunken assets (`how: probe`), no hard world edge from
any authored camera, fps >= 30 at 1024x576.
+ **`priority` matters more than anything else in this list.** ANY unmet `must` item caps the
+ whole run's score at 0.60, however good the pictures are — one over-specified detail throws
+ away a passing scene. So:
+ - mark at most 4-6 items `must`, and only ones that restate a hard requirement of the brief
+ itself, that a person can confirm from ONE rendered frame, and that name no incidental
+ detail: "a raked gravel area is visible in the zen garden" is a `must`; "raked gravel with
+ concentric rings around each rock" is a `should`;
+ - mark everything else `priority: should` — craft goals, counts, specific patterns, exact
+ heights, fps and anything needing evidence the judge may not have;
+ - never write a `must` whose wording contains a number, a named style, or the word "and"
+ joining two independent claims — split it or demote it.
RULES
- Every name in `zones[].contents` must be an asset name; asset names unique; zone names unique.
diff --git a/harness/codeverse/prompts/tracks/scene_env.j2 b/harness/codeverse/prompts/tracks/scene_env.j2
index 94ac152b..1c3cda9b 100644
--- a/harness/codeverse/prompts/tracks/scene_env.j2
+++ b/harness/codeverse/prompts/tracks/scene_env.j2
@@ -41,17 +41,33 @@ Read these cookbook chapters and copy their recipes (`read_cookbook(section="...
`distToPath` in both height and colour. A single-colour `MeshStandardMaterial` plane is a
scored defect (`flat_ground`).
2. **No world edge.** Ground size >= 2.4 x fog far; `scene.fog` colour == the sky's HORIZON
- colour == `scene.background`; a silhouette ring (24-40 instanced hills / rooftops / mesas) at
- radius ~ 0.6 x fog far, height 0.06-0.12 x that radius, tinted 70 % toward the fog colour.
- Scale fog to THIS scene, not to a 100 m default.
-3. **Coloured atmosphere, not monochrome.** Warm key + cool fill (or the reverse) with >= 60
- degrees of hue between them; shade must carry sky colour, never black. Add 3-4 haze bands
+ colour == `scene.background`; a silhouette ring (24-40 instanced hills / rooftops / mesas /
+ treeline) at radius ~ 0.6 x fog far, height 0.06-0.12 x that radius. Scale fog to THIS
+ scene, not to a 100 m default.
+ Two rules decide whether that ring reads as a hazy horizon or as cardboard:
+ - Build it from SOLID geometry (cones, boxes, mesas). Flat `PlaneGeometry` cut-outs are
+ instantly readable as cardboard from every oblique and overview camera.
+ - Do NOT lerp its colour toward the fog colour. `scene.fog` already hazes it by distance;
+ tinting as well double-applies and, against a light golden/overcast horizon, makes the
+ backdrop BRIGHTER than the ground — measured, and scored as `placeholder_material`.
+ Use its natural colour darkened (`base.multiplyScalar(0.6-0.8)`) and let fog do the rest.
+3. **The floor stays near y = 0.** The plan's camera heights are absolute metres above y = 0
+ and were written before your terrain existed: keep `heightAt` within about +/-1.5 m of 0
+ inside the bounds (a knoll or a pond basin is fine, a 7 m plateau is not), or the harness
+ reports "camera N m below ground level" and caps the score at 0.50.
+ Ponds, terraces, lawns and gravel beds are CARVED INTO `heightAt` (a radial depression, a
+ shallow shelf) — never a hard-edged disc or square laid on top of the ground, which always
+ shows its outline from the overview cameras.
+4. **Coloured atmosphere, not monochrome.** Warm key + cool fill (or the reverse) with >= 60
+ degrees of hue between them; shade must carry sky colour, never black — with the sun below
+ 25 degrees elevation keep the hemisphere intensity >= 1.0 or the shadows render pitch black
+ and trip the `unlit_or_blown` defect (cap 0.60). Add 3-4 haze bands
(`depthWrite:false`, opacity 0.04-0.10, fog colour) for aerial perspective, and light shafts
if the brief mentions sun through something.
-4. **Shadows must not be jagged.** Shadow texel = `2 x shadowSpan / mapSize` <= 0.05 m: fit the
+5. **Shadows must not be jagged.** Shadow texel = `2 x shadowSpan / mapSize` <= 0.05 m: fit the
shadow camera to the BOUNDS (not the whole ground), then pick mapSize 2048 (span <= 30 m) /
3072 (<= 60 m) / 4096 (larger). `bias = -0.0004`, `normalBias = 0.02`.
-5. Keep the whole module <= 300 lines; no textures, no DOM, no fetch, no Math.random.
+6. Keep the whole module <= 300 lines; no textures, no DOM, no fetch, no Math.random.
## DON'T
- No assets/zones here (they come from other modules). No cameras. No `scene.background` image loads.
diff --git a/harness/codeverse/prompts/tracks/scene_refine.j2 b/harness/codeverse/prompts/tracks/scene_refine.j2
index 1efdb190..81b2d69f 100644
--- a/harness/codeverse/prompts/tracks/scene_refine.j2
+++ b/harness/codeverse/prompts/tracks/scene_refine.j2
@@ -56,6 +56,9 @@ timid: double the amplitude / the count / the contrast this time.
|---|---|
| flat / one-colour ground, no paths, hard raised-bed edges | `"Ground that reads real"` — vertex-colour blend, carve the path into `heightAt`, dress the seams |
| a hard world edge against the sky, missing horizon | `"Horizon: the world must not end"` — ground ≥ 2.4 × fog far, fog = sky horizon colour, silhouette ring at 0.6 × fog far |
+| the backdrop looks like flat / beige / untextured cut-outs | same chapter, rules 4-5 — solid geometry, darken the base colour, never lerp it toward the fog colour |
+| a pond / terrace is a hard-edged plane sitting on the ground | carve it into `heightAt` in `src/env.js` and dress the seam (`"Ground that reads real"`) |
+| "camera is N m below ground level" | the terrain lifted the floor: flatten `heightAt` toward y = 0 inside the bounds, or add `heightAt(x, z)` to that camera's y in `src/scene.js` |
| identical cones / stacked blocks / primitive repetition | `"Vegetation that reads real"`, `"Rocks, cliffs and boulders that read organic"` — 3+ silhouettes, clustered, scale/hue jitter, no axis-aligned stacks |
| sparse, token, "a diorama on a plane", empty midground | `"Set dressing"` + `"Scene layering"` — hit the per-zone prop counts, add a foreground element 2-4 m from each camera |
| flat / dark / monochrome light, black shade, jagged shadows | `"Atmosphere: time-of-day triads with numbers"` — warm key vs cool fill ≥ 60° apart, shadow texel ≤ 0.05 m |
diff --git a/harness/codeverse/prompts/tracks/scene_zone.j2 b/harness/codeverse/prompts/tracks/scene_zone.j2
index 3747d34e..e5f9068f 100644
--- a/harness/codeverse/prompts/tracks/scene_zone.j2
+++ b/harness/codeverse/prompts/tracks/scene_zone.j2
@@ -56,8 +56,11 @@ Copy the recipes from the cookbook (`read_cookbook(section="...")`):
seeds + members around them), never uniform scatter and never a ring of identical cones.
3. **Blend into the ground.** Anything that meets the terrain sinks 3-5 cm into it and gets
6-15 dressing pieces along the seam (tufts, pebbles, leaves). A raised bed gets a chamfered
- kerb, not a naked box on grass. Add the zone's share of ground cover (300-800 instanced
- tufts for a planted zone) unless the description says bare.
+ kerb, not a naked box on grass. NEVER lay a hard-edged disc or square (a pond, a gravel
+ bed, a terrace, a lawn patch) flat on top of the ground: use the depression `heightAt`
+ already carves for it and ring the seam with a kerb + dressing, or its outline shows from
+ every overview camera (`flat_ground` / `floating_or_sunken_asset`). Add the zone's share of
+ ground cover (300-800 instanced tufts for a planted zone) unless the description says bare.
4. **Serve the cameras.** Skip any SCATTER instance inside a ~4 m disc around an authored camera
(write a zero-scale matrix, keep the index; `cameraMask` in the cookbook) — a tree 1 m in front
of the establishing camera ruins the shot. Then, by hand (not scatter, so the mask does not
diff --git a/harness/codeverse/spatial/measure.py b/harness/codeverse/spatial/measure.py
index 48ef503a..725e88d4 100644
--- a/harness/codeverse/spatial/measure.py
+++ b/harness/codeverse/spatial/measure.py
@@ -15,6 +15,7 @@ empty parts — what connectivity / sections want.
from __future__ import annotations
+import contextlib
import re
import threading
from collections import OrderedDict
@@ -91,10 +92,8 @@ def _world_mesh(scene: trimesh.Scene, node: str) -> trimesh.Trimesh | None:
m.apply_transform(transform)
# exporters split vertices along hard edges / UV seams; topology queries
# (islands, watertightness) need positions merged back together
- try:
+ with contextlib.suppress(Exception):
m.merge_vertices(merge_tex=True, merge_norm=True)
- except Exception:
- pass
return m
@@ -134,7 +133,7 @@ def part_meshes(scene: trimesh.Scene) -> OrderedDict[str, trimesh.Trimesh | None
out: OrderedDict[str, trimesh.Trimesh | None] = OrderedDict()
links = scene.metadata.get("links") if isinstance(scene.metadata, dict) else None
nodes = set(scene.graph.nodes)
- if isinstance(links, list) and links and all(str(l) in nodes for l in links):
+ if isinstance(links, list) and links and all(str(link) in nodes for link in links):
for link in links:
link = str(link)
own = [n for n in _subtree_nodes(scene, link) if n == link or str(n).startswith(link + "__")]
diff --git a/harness/pyproject.toml b/harness/pyproject.toml
index e99fc6c1..94e00cbe 100644
--- a/harness/pyproject.toml
+++ b/harness/pyproject.toml
@@ -35,7 +35,7 @@ mesh = ["shapely>=2.0", "networkx>=3.2", "manifold3d>=2.3"] # cross_section are
mcp = ["mcp>=1.0"] # `3dcv mcp` spatial-tool server for the agentic CLIs
flywheel = ["pyarrow>=15"] # `3dcv flywheel export --pack` (parquet)
all = ["3dcodeverse[cad,urdf,graphics,mesh,mcp,flywheel]"]
-dev = ["pytest>=8", "pytest-timeout>=2.3", "ruff>=0.5"]
+dev = ["pytest>=8", "pytest-timeout>=2.3", "ruff>=0.5", "pyarrow>=15"]
[project.scripts]
3dcv = "codeverse.cli.main:app"
diff --git a/harness/tests/cost/test_audit_report.py b/harness/tests/cost/test_audit_report.py
index 1e6dac88..db4c9ec0 100644
--- a/harness/tests/cost/test_audit_report.py
+++ b/harness/tests/cost/test_audit_report.py
@@ -8,7 +8,12 @@ from pathlib import Path
import pytest
from codeverse.cost import audit_runs
-from codeverse.cost.audit import cached_input_share, price_confidence, stage_latency, uncached_if_no_cache
+from codeverse.cost.audit import (
+ cached_input_share,
+ price_confidence,
+ stage_latency,
+ uncached_if_no_cache,
+)
from codeverse.cost.report import console, markdown
diff --git a/harness/tests/cost/test_live.py b/harness/tests/cost/test_live.py
index 662d286b..117f95f1 100644
--- a/harness/tests/cost/test_live.py
+++ b/harness/tests/cost/test_live.py
@@ -38,11 +38,11 @@ def _send(model, text: str):
def test_cache_friendly_ordering_is_measurably_cheaper(arm: str):
"""A ≥12k-token stable prefix must cache when it comes FIRST and must not
when the volatile block precedes it (measured 2026-08-23: 69% vs 0%)."""
+ import uuid
+
from codeverse.config import get_settings
from codeverse.models.gemini import GeminiModel
- import uuid
-
keys = list(get_settings().gemini_api_keys)
if not keys:
pytest.skip("no gemini keys")
diff --git a/harness/tests/cost/test_reconstruct.py b/harness/tests/cost/test_reconstruct.py
index 729d6ac3..e24b3a91 100644
--- a/harness/tests/cost/test_reconstruct.py
+++ b/harness/tests/cost/test_reconstruct.py
@@ -88,7 +88,6 @@ def test_gemini_cli_recheck_finds_the_stale_parse():
def test_best_of_n_losers_are_attributed_and_counted_as_waste(fake_run: Path, tmp_path: Path):
"""A ``_cand/c<k>`` sub-workspace is the run's, not a run of its own; the
candidates that lost are money spent on artifacts nobody kept."""
- import json
import shutil
ws = tmp_path / "cands"
diff --git a/harness/tests/docs_html/test_architecture_html.py b/harness/tests/docs_html/test_architecture_html.py
index 26038e3c..a49fe0b3 100644
--- a/harness/tests/docs_html/test_architecture_html.py
+++ b/harness/tests/docs_html/test_architecture_html.py
@@ -27,7 +27,7 @@ PAGE = DOCS / "architecture.html"
MAX_BYTES = 8 * 1024 * 1024
#: HTML void elements — never on the open-tag stack.
-VOID = frozenset("area base br col embed hr img input link meta param source track wbr".split())
+VOID = frozenset(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"])
#: elements whose content is not markup (html.parser already treats these as CDATA)
RAW_TEXT = frozenset({"script", "style"})
#: mime types we allow inside a data: URI on this page
diff --git a/harness/tests/scene_prompts/test_quality_teaching.py b/harness/tests/scene_prompts/test_quality_teaching.py
index 7623aaf2..dadc5529 100644
--- a/harness/tests/scene_prompts/test_quality_teaching.py
+++ b/harness/tests/scene_prompts/test_quality_teaching.py
@@ -59,6 +59,20 @@ def test_planner_asks_for_density_layering_and_subject_framing() -> None:
assert token in text, token
+def test_planner_is_told_that_must_acceptance_caps_the_run() -> None:
+ """One unmet `must` caps the run at 0.60 (judges.caps.missing_must_acceptance). A scene
+ whose pictures score 0.81 must not lose 0.13 because the planner over-specified a detail
+ and then marked it `must` — measured on cq_japanese_garden_v2 r00 (0.809 → 0.729 → 0.60)."""
+ from codeverse.judges.rubrics import load_rubric
+
+ caps = {c.id: c for c in load_rubric("scene_v1").caps}
+ assert caps["missing_must_acceptance"].cap == 0.60
+ text = load_text("tracks/plan_scene.j2")
+ assert "priority: should" in text
+ assert "caps the whole run" in text or "caps the\n whole run" in text
+ assert "at most 4-6 items `must`" in text
+
+
def test_zone_prompt_demands_variation_dressing_and_visible_motion() -> None:
text = load_text("tracks/scene_zone.j2")
for token in ("3 distinct silhouettes", "hue jitter", "density counts",