Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# netherite (AGENTS.md)

Home: **Anvil-primary** - canonical at `anvil:~/dev/netherite`. Build and run
here. MacBook is control plane / Moonlight / image viewing only.
Home: **Anvil-primary** - canonical at `anvil:~/dev/netherite`. Build, run,
and validate here. MacBook is control plane / Moonlight / image viewing only.

Git remote: **https://github.com/Infatoshi/netherite**. That is the only
GitHub repo. `origin` on both machines points there.
Expand All @@ -14,10 +14,20 @@ next to the code they govern.

| OS | Role |
|----|------|
| **Linux x86_64** | Full stack. Build CPU/CUDA, run Java oracle, train blaze, sweep. Canonical host: anvil (Ubuntu). Needs JDK 8 + NVIDIA CUDA for GPU paths. |
| **Linux x86_64** | Full stack. Build CPU/CUDA, run Java oracle, train blaze, sweep. Canonical host: anvil (Ubuntu, 9950X3D). Needs JDK 8 + NVIDIA CUDA for GPU paths. All Linux validation runs here. |
| **macOS** | Build and verify the CPU and Metal game backends. Also serves as the control plane and image/video review host. Do not expect native `runClient` or CUDA here. |
| **Windows** | Not a supported build/run host for this monorepo. Use WSL2 Linux if you must, or a remote Linux box. |

### Hosts (where work runs)

| host | Role |
|------|------|
| **anvil** | Canonical clone. Linux validation: `make test`, magma CPU, tape replay, blaze M1/M2, `eval` (cpu/cuda/magma), oracle capture. CUDA `sm_120`. Shared GPUs: `nvidia-smi` first; long GPU jobs through `overnight-compute`. |
| **macOS** | Control plane. Metal build, `cpu==metal` kernel half, image/video review. Not the Linux validation host. |
| **gamer** | Not the validation host. Use only when a job needs the 3090 / `sm_86`. |

Do not stage magma CPU gates, 13-seed eval, tape replay, or `make test` on gamer. Anvil is the faster CPU.

Prism / MultiMC / official launcher: optional jar source for assets. Fresh
boxes do **not** need Prism credentials; `make -C java bootstrap-oracle` pulls
MC 1.11.2 via ForgeGradle (you must own the game).
Expand Down Expand Up @@ -65,9 +75,10 @@ sub-agents pointed at them without waiting for a human to pick items:
1. Pick from `magma/OPEN_DIVERGENCES.md` class A (top down) and
`blaze/OPEN_DIVERGENCES.md` unported rows (dependency order). One lane
per item. Skip items whose evidence (tape, golden) is not on this Mac.
2. Stage: `bash scripts/lane_stage.sh <lane> <host> [--tape NAME]...`
(gamer for magma CPU work; anvil for oracle captures, CUDA, blaze M2;
Metal half of a twins lane builds on the Mac).
2. Stage: `bash scripts/lane_stage.sh <lane> anvil [--tape NAME]...`
(anvil for magma CPU, oracle captures, CUDA, blaze M1/M2, eval.
Metal half of a twins lane builds on the Mac. Do not stage
validation on gamer.)
3. Prompt = `docs/SUBAGENT.md` + a goal block: the item text, the gate
command, the documented baseline numbers, the hard goal, and what is
forbidden. Launch from the lane worktree, in the background.
Expand Down
59 changes: 53 additions & 6 deletions blaze/OPEN_DIVERGENCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Definitions, so the list stays honest:
- Gate runner: `blaze/env/port_matrix.py` over `blaze/env/port_matrix.yaml`
(fail-closed; VERIFIED / BLOCKED / FAILED per row and tier).

Last documented: 2026-08-26 magma 13-seed transfer (`retrain_0821_best.bin` closed == cpu == cuda, 0/13 torches; replay MATCH 56/65. `ppo_ckpt_best.bin` closed t0:13; replay MATCH 45/65. Cam-px DIVERGE not blessed). No new M1/M2.
Last verified: lane/blocklight 2026-08-25 (Sweep row 3: World.checkLightFor BLOCK flood. test_blocklight matches magma Manhattan 0..14. Fluids M2 raw/warp/scalar VERIFIED after moving CU_LIGHT_Q off the CUDA thread stack. listed --no-deps M1 27 VERIFIED; M2 27 VERIFIED; mining_slice M1+M2 BLOCKED rc=3. Root make test PASS. SNAP v11 unchanged. No BP_ light digest.)
Last verified: lane/potions 2026-08-24 (Sweep row 13: SNAP v11 potion trailer after resume v10. Magma skip double fire decrement on shared hostile path. potions M1+M2 VERIFIED 120 raw/warp/scalar + resume N=90 M=30 dump version=11. listed --no-deps M1 27 VERIFIED; M2 27 VERIFIED; mining_slice BLOCKED: s14_t0_r48_no_liquid.bsnp is a v1 bake, 12 *_d*.bsnp present. Root make test PASS.)
Last verified: lane/resumegate 2026-08-23 (Sweep rows 4 and 8: snapshot v10 resume trailers + mob sidecars. continuous-vs-resume BP_ gate. listed --no-deps M1 VERIFIED; M2 VERIFIED raw/warp/scalar except mining_slice BLOCKED missing *_d*.bsnp).
Expand Down Expand Up @@ -122,15 +123,55 @@ Two consequences worth stating plainly:
48-point path cap), IntHashMap aliasing reproduced, all 8 detmob tapes
must be blaze-exact.

## Spawn -> dragon (policy vs magma)

A policy in blaze CUDA cannot complete magma `PRODUCT.md` steps 3-9
(Nether portal, fortress/rods, eyes, stronghold, End, dragon, `won`)
while matching magma. Gate 2 accepts spawn->torch. `docs/GATES.md`
forbids dragon-fight RL. Isolated kernels (`nether_portal.h`,
`end_portal.h`, `nether_full.h`, `chunk_provider_nether.h`,
`ender_dragon.h`) are CPU==CUDA units; they are not `blaze_tick`.
Java-vs-magma leftovers on that same route stay in
`magma/OPEN_DIVERGENCES.md` (stronghold L, tick order M, detmob nether
A*, class A pixels). Do not file missing Nether/End in this env as a
magma bug.

| PRODUCT step | Blaze env | Where |
|---|---|---|
| Overworld spawn, dig, craft, furnace, chests, fluids, TNT, overworld hostiles | yes, M1+M2 inside a `.bsnp` | Verified rows |
| Food / bed / buckets / flint / portal ignite | buckets tick but are not in `rl_crafts`; fire->portal follower not ported; `dimension` is always 0; id 51 edits unreachable | `blaze_core.h` (`cu_world_set_state` follower); sweep 2 |
| Linked Nether / End | no | unported `portals_dimensions`, `nether_route` |
| Fortress, blaze, ghast, pigman, magma cube, wither skeleton, silverfish | type tags exist (`entity_hostile_spine.h`); spawn table and live AI in the env are overworld only | `hostile_spawn.h` `hs_to_ew`; `blaze_core.h` header |
| Throw eyes of ender / fireballs | magma-only | projectiles close note |
| Stronghold hunt, end-portal frames, enter End | no dimension in the env. Magma vs Java stronghold is magma OPEN sweep 1 | magma `OPEN_DIVERGENCES.md` |
| Dragon, crystals, bed explode in DIM -1/1, exit portal, `won` | `ender_dragon.h` is a 200-tick fixed arena (no block destruction, no contact damage), not wired into `blaze_tick`. Bed explode in Nether/End is magma-only | unported `dragon_victory`; `player_bed.h` |

Even on overworld snapshots, a trained policy does not see or act as
magma `player_ctl`:

- Sweep 1: episode region is the snapshot (`cu_region_idx`,
`cu_recenter`); magma streams chunks. L.
- Sweep 2: no strafe, sneak, sprint, or slot-click. Camera planes are
log / leaves / coal / stone / dirt / table / occupancy / depth /
edge (`obs_pack.h` `pack_frame`). No mob, light, or health plane.
- Sweep 6: death is terminal.
- Detmob A* is magma-CPU (above).
- M1/M2 are BP_ digests inside that region, not a streamed survival
world.

Closing the port-matrix DAG does not by itself make a dragon policy:
sweep 1 and 2 still block long-horizon transfer. An isolated kernel
PASS is not env support.

## Sweep 2026-08-23 (codex full read, magma -> blaze; unverified by gate unless noted)

Ranked by RL fidelity. Each row: magma site; blaze site or absent; what
closing needs. Spot-checked by hand on 2026-08-23: rows 7 and 10 confirmed.

1. Episode region is fixed; no chunk streaming (`blaze/env/blaze_core.h:
456-516, 4652-4659`). Magma streams chunks around the player. Every
row is VERIFIED only inside the snapshot region. L; blocks long-horizon
transfer.
1. Episode region is fixed; no chunk streaming (`cu_region_idx`,
`cu_recenter` in `blaze/env/blaze_core.h`). Magma streams chunks around
the player. Every row is VERIFIED only inside the snapshot region. L;
blocks long-horizon transfer. See "Spawn -> dragon" above.
2. Policy actions are privileged helpers (craft/interact/smelt in
`blaze/rl/obs_pack.h:20-51`); no strafe, sneak, sprint, or slot-click
as magma `player_ctl` sees them. `do_place` is reachable: RL `a[8]` is
Expand Down Expand Up @@ -228,8 +269,14 @@ Observation exposes no mob, light, or health planes.

- Native ppo spawn->torch t0 is 0.215 (chain4 curriculum, 510M ticks) vs the
0.4 target; stage4->torch is 8/8 seeds. GATES row 1.
- No native transfer/eval of `ppo_ckpt.bin` into magma (torch eval scripts
removed). GATES row 2.
- Native magma eval is wired (`eval --backend magma --transfer closed|replay`)
and the 32-tick BOLR harness is `make -C blaze/rl test-eval-magma`.
13-seed tries=5 n=65 (gamer 2026-08-26): `retrain_0821_best.bin` magma
closed == cpu == cuda (torches 0/13, t0:6 logs3:7). Replay MATCH 56/65;
9 DIVERGE all cam 1-5 px, not blessed. `ppo_ckpt_best.bin` magma
closed == cpu == cuda t0:13; replay MATCH 45/65. Camera stays compile-time 64x36
(`oc_pixel`); `--rl-bin` is not a resolution flag. GATES row 2. Gate 2
accept stays open (0 torches).
- Python still owns replay/pixels/M2 verify; no binary tape; no root
`make verify`. GATES row 13.
- Blaze native Metal tick (M3) is sequenced after CUDA survival rows pass
Expand Down
38 changes: 29 additions & 9 deletions blaze/rl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ TEST_SKY_BIN := $(OUT)/test_skylight_water
TEST_BLK_BIN := $(OUT)/test_blocklight
SMOKE_BIN := $(OUT)/ppo
EVAL_BIN := $(OUT)/eval
EVAL_MAGMA_OBJ := $(OUT)/eval_magma.o
TEST_EVAL_MAGMA_BIN := $(OUT)/test_eval_magma
CKPT ?= out/blaze/rl/ppo_ckpt_best.bin
SAN_TEST_BIN := $(SAN_OUT)/test_train_config
SAN_CHAIN_BIN := $(SAN_OUT)/test_chain_reward
SAN_SMOKE_BIN := $(SAN_OUT)/ppo
Expand All @@ -122,7 +125,7 @@ CHAIN_OBJS := $(OUT)/chain_reward.o $(OUT)/chain_curr.o
.PHONY: all test-config test-chain test-capture test-entity-spine \
test-falling test-weather test-chests test-furnaces test-projectiles test-explosions test-randtick test-biome-plane test-mobs test-mobs-ss test-mobs-end test-mobs-witch test-passives test-hazards test-ground-items test-potions test-placement test-beds test-skylight-water test-blocklight smoke smoke-cpu smoke-cuda \
smoke-metal smoke-reset test sanitize clean env-cpu env-cuda \
env-metal eval
env-metal eval test-eval-magma eval-magma

all: test-config smoke

Expand All @@ -147,6 +150,9 @@ $(OUT)/chain_reward.o: chain_reward.c chain_reward.h | $(OUT)
$(OUT)/chain_curr.o: chain_curr.c chain_curr.h chain_reward.h | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -c -o $@ chain_curr.c

$(EVAL_MAGMA_OBJ): eval_magma.c eval_magma.h | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -c -o $@ eval_magma.c

# ---- Linux CUDA staging ----
ifneq ($(UNAME_S),Darwin)
$(OUT)/env_cuda_stage.o: env_cuda_stage.c env_cuda_stage.h | $(OUT)
Expand Down Expand Up @@ -400,21 +406,22 @@ $(SMOKE_BIN): ppo.c obs_pack.h rl_ckpt.h $(TRAIN_CFG_OBJ) $(CHAIN_OBJS) \
$(CHAIN_OBJS) $(METAL_OBS_OBJ) $(METAL_HOST_OBJ) $(NN_OBJS) \
$(LINK_LIBS) $(LDLIBS)

$(EVAL_BIN): eval.c obs_pack.h rl_ckpt.h $(CHAIN_OBJS) $(METAL_OBS_OBJ) \
$(METAL_HOST_OBJ) $(NN_OBJS) $(ENV_CPU_SO) $(METAL_LIB) | $(OUT)
$(METAL_CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ eval.c $(CHAIN_OBJS) \
$(METAL_OBS_OBJ) $(METAL_HOST_OBJ) $(NN_OBJS) \
$(EVAL_BIN): eval.c obs_pack.h rl_ckpt.h $(CHAIN_OBJS) $(EVAL_MAGMA_OBJ) \
$(METAL_OBS_OBJ) $(METAL_HOST_OBJ) $(NN_OBJS) $(ENV_CPU_SO) \
$(METAL_LIB) | $(OUT)
$(METAL_CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ eval.c $(EVAL_MAGMA_OBJ) \
$(CHAIN_OBJS) $(METAL_OBS_OBJ) $(METAL_HOST_OBJ) $(NN_OBJS) \
$(LINK_LIBS) $(LDLIBS)
else
$(SMOKE_BIN): ppo.c obs_pack.h rl_ckpt.h $(TRAIN_CFG_OBJ) $(CHAIN_OBJS) \
$(STAGE_OBJ) $(NN_OBJS) $(ENV_CPU_SO) $(ENV_CUDA_SO) | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ ppo.c $(TRAIN_CFG_OBJ) $(CHAIN_OBJS) \
$(STAGE_OBJ) $(NN_OBJS) $(LINK_LIBS)

$(EVAL_BIN): eval.c obs_pack.h rl_ckpt.h $(CHAIN_OBJS) $(STAGE_OBJ) $(NN_OBJS) \
$(ENV_CPU_SO) $(ENV_CUDA_SO) | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ eval.c $(CHAIN_OBJS) $(STAGE_OBJ) \
$(NN_OBJS) $(LINK_LIBS)
$(EVAL_BIN): eval.c obs_pack.h rl_ckpt.h $(CHAIN_OBJS) $(EVAL_MAGMA_OBJ) \
$(STAGE_OBJ) $(NN_OBJS) $(ENV_CPU_SO) $(ENV_CUDA_SO) | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ eval.c $(EVAL_MAGMA_OBJ) \
$(CHAIN_OBJS) $(STAGE_OBJ) $(NN_OBJS) $(LINK_LIBS)
endif

test-config: $(TEST_BIN)
Expand Down Expand Up @@ -556,6 +563,19 @@ smoke-reset: $(SMOKE_BIN)
# and t0 snaps). CUDA/Metal slot via --backend; default is CPU.
eval: $(EVAL_BIN)

# 32-tick Magma --rl-bin vs blaze_cpu BOLR. Not on `test`. Needs magma_game.
$(TEST_EVAL_MAGMA_BIN): test_eval_magma.c $(EVAL_MAGMA_OBJ) $(ENV_CPU_SO) | $(OUT)
$(CC) $(OWN_CFLAGS) $(CPPFLAGS) -o $@ test_eval_magma.c \
$(EVAL_MAGMA_OBJ) $(LDLIBS)

test-eval-magma: $(TEST_EVAL_MAGMA_BIN) $(ENV_CPU_SO)
cd $(REPO) && ./out/blaze/rl/test_eval_magma

# 13-seed magma closed-loop. Override CKPT=. Not on `test`.
eval-magma: $(EVAL_BIN) $(ENV_CPU_SO)
cd $(REPO) && ./out/blaze/rl/eval --checkpoint $(CKPT) \
--backend magma --stage 0

test: test-config test-chain test-capture smoke

# Sanitizer build of owned sources; env via dlopen of the same .so files.
Expand Down
Loading