# Task 10: CorridorCarver Pass **Depends on:** Task 6 ## Context Files - `.dev/2026-05-28-procgen-map-core/spec/design.md` — §4.7 (Connector role), §5 (data flow). - `.dev/2026-05-28-procgen-map-core/README.md` — inter-pass data contract (CorridorCarver row). - `reikhelm-core/src/pass.rs` — `Pass`, `GenContext` (Task 6). - `reikhelm-core/src/region.rs`, `reikhelm-core/src/map.rs` — `ConnGraph`, `Region`, `RegionKind::Corridor`, `Tile::Floor`. - `reikhelm-core/src/geometry.rs` — `Line`, `Point` (Task 2). - `reikhelm-core/src/passes/mod.rs` — append the module declaration here. ## Files - Create: `reikhelm-core/src/passes/corridor.rs` — `CorridorCarver`. - Modify: `reikhelm-core/src/passes/mod.rs` — append `pub mod corridor;` and re-export `CorridorCarver`. ## What to Build A connector (spec §4.7) that physically carves the connections chosen by `MstConnect`. For each edge in `ctx.graph`, carve an L-shaped corridor (one horizontal run + one vertical run, joined at an elbow; randomize which leg comes first) of `Tile::Floor` between the two rooms' centers. Append a `Region { kind: Corridor, .. }` describing each carved corridor's cells. All grid writes go through bounds-safe accessors (never panic). Carving over an existing `Floor` cell is fine (corridors may pass through or merge). This pass does not set door tiles or `edge.at` — that's `DoorPlacer`. It reads `ctx.graph` + Room region centers and writes `ctx.tiles` + Corridor regions. Tests construct the precondition (rooms + a graph) directly. ## Interface Dependencies - **Consumes:** `Pass`, `GenContext`, `Rng` (Task 6); `ConnGraph`, `Region`, `Tile` (Task 5); `Line`, `Point` (Task 2). - **Produces:** - `struct CorridorCarver { /* unit or small config; Default */ }` — `default()`/`new()`; `impl Pass` with `name() == "corridor_carver"`. - **Writes to context:** `Floor` corridors in `ctx.tiles`; one `Corridor` region per edge. ## Tests - Given two rooms (carved Floor rects) and one graph edge between them, after running: a contiguous `Floor` path connects the two room interiors (verify by flood-fill: both room centers are in the same connected floor component). - An L-corridor's cells are all in-bounds; carving never panics even if a center is near the map edge. - One `Corridor` region is added per edge. - Determinism: same seed/sub-stream → identical carved corridors. ## Success Criteria - [ ] `CorridorCarver` carves L-shaped `Floor` corridors for every graph edge and adds Corridor regions; rooms become floor-connected. - [ ] Bounds-safe; sets no doors and does not touch `edge.at`. - [ ] `pub mod corridor;` appended to `passes/mod.rs`. - [ ] Tests pass: `cargo test -p reikhelm-core corridor` ## Commit `"feat(core): CorridorCarver pass"`