feat(simulation): region climate Atlas layer + quarter-footprint design (T-1113/T-1112) #179

Closed
jpmschweitzer wants to merge 0 commits from atlas-layer-wiring into main
Owner

Summary

The Atlas wiring pair. T-1113 wires the region climate stack (T-1078, implemented-but-never-called) into the cascade and serves it over the layer proxy; T-1112 records the QuarterFootprintLayer design as a D-226 amendment (Tyre data shape + Araminta encoding). Both visual overlays remain follow-up tickets by design.

T-1113 — region climate layer (server + one client line)

  • CascadeLayer::Region appended per the enum append-only Ord rule (depends only on seed/body_params/heightmap dims; documented on the variant). The region cache was already being computed and DISCARDED inside derive_all_districts — this retains it as its own layer (one-layer-one-concern; cheap double-derive accepted, documented).
  • BodyWorldState.regions: BTreeMap per the districts precedent; ~195x98 max, trivial footprint.
  • RegionGridLayer: dense row-major, all-integer wire encoding (season/weather repr(u8) discriminants; mean_temp as deci-degC i16 with i16::MIN airless sentinel; moisture_q u8). build_region_grid mirrors build_district_grid; the layer_proxy growth-ceiling doc already earmarked this ticket.
  • protocol.gd: one-line region_grid passthrough; wire fixtures regenerated via make fixtures.
  • Tests: cascade Region-layer determinism (bit-level f32 checks) + populated/skip paths; encoder unit test (dims, discriminants, rounding, sentinel, clamp); ordering pin. atlas:: suite 507 green.

T-1112 — QuarterFootprintLayer design (D-226 amendment, no code)

  • Aggregates-only, keyed by city_id: QuarterWorldState carries NO spatial position (QuarterId is a content-addressed hash) and a 512m quarter is sub-pixel at planetary projection — two independent analyses (data + rendering) converged on no-outline-by-construction.
  • Five quantized fields (density_avg_pct, dominant_district_type, dominant_zoning, landmark_count, corridor_count); D-226(d) aggregate-stats ceiling restated concretely; scaled-glyph encoding anchored on the L3 settlement dot (shape=dominant type, color=density ramp on the settlement-gold family); landmark/corridor counts tooltip-only; zoom gating reuses SETTLEMENT_LABEL_MIN_ZOOM; five wiring touch points named for the follow-up.

Also

  • test(client): input-roundtrip flaky fix — the server binds ~250ms after spawn, so a random-port collision (os error 98) escaped the spawn-liveness check and failed at the push gate; deaths during the connect window now retry on a fresh port. Targeted suite 6/6.

Verification

Full gate green: GDScript parse, client suite 2948 tests, fmt/clippy/full cargo test/deny; pql decisions validate + sync clean (387 records, 0 broken refs). No systems.db change (no stamp impact).

Follow-ups (filed at merge)

Climate overlay rendering (consumes region_grid); quarter-footprint wiring (implements the amendment); Atlas screenshot golden harness (T-1037).

## Summary The Atlas wiring pair. T-1113 wires the region climate stack (T-1078, implemented-but-never-called) into the cascade and serves it over the layer proxy; T-1112 records the QuarterFootprintLayer design as a D-226 amendment (Tyre data shape + Araminta encoding). Both visual overlays remain follow-up tickets by design. ### T-1113 — region climate layer (server + one client line) - CascadeLayer::Region appended per the enum append-only Ord rule (depends only on seed/body_params/heightmap dims; documented on the variant). The region cache was already being computed and DISCARDED inside derive_all_districts — this retains it as its own layer (one-layer-one-concern; cheap double-derive accepted, documented). - BodyWorldState.regions: BTreeMap per the districts precedent; ~195x98 max, trivial footprint. - RegionGridLayer: dense row-major, all-integer wire encoding (season/weather repr(u8) discriminants; mean_temp as deci-degC i16 with i16::MIN airless sentinel; moisture_q u8). build_region_grid mirrors build_district_grid; the layer_proxy growth-ceiling doc already earmarked this ticket. - protocol.gd: one-line region_grid passthrough; wire fixtures regenerated via make fixtures. - Tests: cascade Region-layer determinism (bit-level f32 checks) + populated/skip paths; encoder unit test (dims, discriminants, rounding, sentinel, clamp); ordering pin. atlas:: suite 507 green. ### T-1112 — QuarterFootprintLayer design (D-226 amendment, no code) - Aggregates-only, keyed by city_id: QuarterWorldState carries NO spatial position (QuarterId is a content-addressed hash) and a 512m quarter is sub-pixel at planetary projection — two independent analyses (data + rendering) converged on no-outline-by-construction. - Five quantized fields (density_avg_pct, dominant_district_type, dominant_zoning, landmark_count, corridor_count); D-226(d) aggregate-stats ceiling restated concretely; scaled-glyph encoding anchored on the L3 settlement dot (shape=dominant type, color=density ramp on the settlement-gold family); landmark/corridor counts tooltip-only; zoom gating reuses SETTLEMENT_LABEL_MIN_ZOOM; five wiring touch points named for the follow-up. ### Also - test(client): input-roundtrip flaky fix — the server binds ~250ms after spawn, so a random-port collision (os error 98) escaped the spawn-liveness check and failed at the push gate; deaths during the connect window now retry on a fresh port. Targeted suite 6/6. ### Verification Full gate green: GDScript parse, client suite 2948 tests, fmt/clippy/full cargo test/deny; pql decisions validate + sync clean (387 records, 0 broken refs). No systems.db change (no stamp impact). ### Follow-ups (filed at merge) Climate overlay rendering (consumes region_grid); quarter-footprint wiring (implements the amendment); Atlas screenshot golden harness (T-1037).
jpmschweitzer added 4 commits 2026-07-16 19:08:26 +02:00
CascadeLayer::Region appended per the enum's append-only Ord rule (depends only on seed/body_params/heightmap dims — documented); BodyWorldState.regions BTreeMap per the districts precedent; RegionGridLayer dense row-major all-integer encoding (season/weather repr(u8) discriminants, mean_temp deci-degC i16 with i16::MIN airless sentinel, moisture_q u8); build_region_grid mirrors build_district_grid; protocol.gd region_grid passthrough (visual overlay deliberately out of scope); wire fixtures regenerated via make fixtures. atlas:: suite 507 green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Aggregates-only layer keyed by city_id (QuarterWorldState carries no spatial position — QuarterId is a content-addressed hash; a 512m quarter is sub-pixel at planetary projection, so no outline geometry by construction). Five quantized fields (density_avg_pct, dominant_district_type, dominant_zoning, landmark_count, corridor_count); scaled-glyph encoding anchored on the L3 settlement dot (shape=dominant type, color=density ramp); landmark/corridor counts tooltip-only per the D-226(d) aggregate-stats ceiling; five wiring touch points named for the follow-up ticket.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The server binds AFTER ~250ms of plugin/sim init, so a random-port collision (os error 98) escapes the 0.15s spawn-liveness check and surfaced as a hard test failure at the push gate. Death during the connect window now retries on a fresh port within MAX_PORT_ATTEMPTS. Verified: targeted suite 6/6.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
Owner

Review: atlas-layer-wiring → main (type: code + design amendment)

Reviewers: Hoshe (code quality) + Troblum holding the architecture seat — Tyre authored this PR's D-226 amendment (T-1112), so the independent second opinion goes to the external sparring partner per his remit. Both read from the branch worktree at tip bba14cb9b. Gate passed pre-push (GDScript parse, 2948 client tests, fmt/clippy/full cargo test/deny) and was not duplicated.

Hoshe (Code Quality): REQUEST_CHANGES

Wiring verified sound: covering-grid math hand-traced (div_euclid, HEIGHTMAP_CELLS_PER_DISTRICT, DISTRICTS_PER_REGION=100), deci-°C i16 quantization safe against class-band extremes with the sentinel correctly reserved via clamp(i16::MIN+1, ...), fixtures/protocol.gd passthrough honest, flaky-test fix clean. Two findings:

# File Issue
H1 server/src/atlas/layer_proxy.rs:33-37 Stale doc: AtlasLayerRequest.up_to still documents run_work_item as running "through CascadeLayer::RoadGraph (the terminal layer, T-1038)" — this PR changed the terminal to Region and updated the growth-ceiling comment below but missed this one.
H2 server/src/atlas/layer_proxy.rs:1108-1184 Coverage gap: the REAL dispatch path (gen_queue up_to=Region → BodyWorldState.regions → handle_atlas_request → region_grid) is never exercised. body_params_reader_wired_produces_populated_regions asserts only districts despite its name; gen_queue's own tests always pass body_params: None. Cheap fix in existing plumbing: assert regions non-empty + cache-insert + second handle_atlas_request asserting region_grid.is_some(); sibling no-params test asserts regions empty.

Troblum (Architecture, independent): REQUEST_CHANGES

The T-1112 amendment's core claims verified independently: QuarterWorldState/QuarterSkeleton carry no spatial position (every field read), the city_id-recompute join is a real pure function, the sub-pixel scale math checks out, and every cited encoding convention exists as described. T-1113's tail-append ordering, double-derive tradeoff, and f32-internal/i16-wire split all ruled sound (D-227/D-010-consistent). Three findings:

# File Issue
T1 governance/decisions/architecture.md (T-1112 amendment §1, ~1581) The dominant_zoning tie-break ("lowest declaration-order variant") is not computable: ZoningType derives no Ord/PartialOrd (unlike DistrictType, which has them per its T-994 precedent). The §4 touch-point list must name the derive addition (or pin an Ord-free rule) — otherwise the wiring implementer diverges from the record silently.
T2 server/src/atlas/layer_proxy.rs:33-37 Same stale terminal-layer doc as H1 (found independently).
T3 server/src/atlas/believability.rs:506-535 cascade_for_body still hardcodes CascadeLayer::RoadGraph while production dispatch now runs to Region — silent harness/production depth divergence. Harmless today (verified: believability never reads state.regions), but D-245's climate-appropriateness condition is a natural future consumer that would silently see empty regions. Bump to Region (mirror production) or record the lag deliberately.

Verdict: CHANGES REQUESTED

4 unique findings (H1≡T2). All small and precisely located; fix round dispatched with the ruling on T3 = bump to mirror production.

## Review: atlas-layer-wiring → main (type: code + design amendment) Reviewers: Hoshe (code quality) + **Troblum** holding the architecture seat — Tyre authored this PR's D-226 amendment (T-1112), so the independent second opinion goes to the external sparring partner per his remit. Both read from the branch worktree at tip bba14cb9b. Gate passed pre-push (GDScript parse, 2948 client tests, fmt/clippy/full cargo test/deny) and was not duplicated. ### Hoshe (Code Quality): REQUEST_CHANGES Wiring verified sound: covering-grid math hand-traced (div_euclid, HEIGHTMAP_CELLS_PER_DISTRICT, DISTRICTS_PER_REGION=100), deci-°C i16 quantization safe against class-band extremes with the sentinel correctly reserved via clamp(i16::MIN+1, ...), fixtures/protocol.gd passthrough honest, flaky-test fix clean. Two findings: | # | File | Issue | |---|------|-------| | H1 | server/src/atlas/layer_proxy.rs:33-37 | Stale doc: AtlasLayerRequest.up_to still documents run_work_item as running "through CascadeLayer::RoadGraph (the terminal layer, T-1038)" — this PR changed the terminal to Region and updated the growth-ceiling comment below but missed this one. | | H2 | server/src/atlas/layer_proxy.rs:1108-1184 | Coverage gap: the REAL dispatch path (gen_queue up_to=Region → BodyWorldState.regions → handle_atlas_request → region_grid) is never exercised. body_params_reader_wired_produces_populated_regions asserts only districts despite its name; gen_queue's own tests always pass body_params: None. Cheap fix in existing plumbing: assert regions non-empty + cache-insert + second handle_atlas_request asserting region_grid.is_some(); sibling no-params test asserts regions empty. | ### Troblum (Architecture, independent): REQUEST_CHANGES The T-1112 amendment's core claims verified independently: QuarterWorldState/QuarterSkeleton carry no spatial position (every field read), the city_id-recompute join is a real pure function, the sub-pixel scale math checks out, and every cited encoding convention exists as described. T-1113's tail-append ordering, double-derive tradeoff, and f32-internal/i16-wire split all ruled sound (D-227/D-010-consistent). Three findings: | # | File | Issue | |---|------|-------| | T1 | governance/decisions/architecture.md (T-1112 amendment §1, ~1581) | The dominant_zoning tie-break ("lowest declaration-order variant") is not computable: ZoningType derives no Ord/PartialOrd (unlike DistrictType, which has them per its T-994 precedent). The §4 touch-point list must name the derive addition (or pin an Ord-free rule) — otherwise the wiring implementer diverges from the record silently. | | T2 | server/src/atlas/layer_proxy.rs:33-37 | Same stale terminal-layer doc as H1 (found independently). | | T3 | server/src/atlas/believability.rs:506-535 | cascade_for_body still hardcodes CascadeLayer::RoadGraph while production dispatch now runs to Region — silent harness/production depth divergence. Harmless today (verified: believability never reads state.regions), but D-245's climate-appropriateness condition is a natural future consumer that would silently see empty regions. Bump to Region (mirror production) or record the lag deliberately. | ### Verdict: CHANGES REQUESTED 4 unique findings (H1≡T2). All small and precisely located; fix round dispatched with the ruling on T3 = bump to mirror production.
jpmschweitzer added 1 commit 2026-07-16 19:22:24 +02:00
F1: T-1112 amendment touch-point list gains the ZoningType PartialOrd/Ord derive (mirroring DistrictType's T-994 precedent) so the dominant_zoning declaration-order tie-break is computable. F2: stale terminal-layer doc on AtlasLayerRequest.up_to corrected to Region. F3: believability cascade_for_body bumped to Region — harness mirrors production depth, invariant documented. F4: end-to-end dispatch coverage — populated-regions test asserts regions + second handle_atlas_request returns region_grid; no-params sibling asserts regions empty. Suites: layer_proxy 10, believability 4, gen_queue 8, cascade 10.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
Owner

Review response — all 4 findings fixed (commit 9d92d8090)

No pushbacks.

# Finding Resolution
T1 dominant_zoning tie-break not computable (ZoningType lacks Ord) Fixed — the T-1112 amendment's touch-point list (now six) names the enabling change: ZoningType gains PartialOrd/Ord mirroring DistrictType's T-994 precedent. Tie-break rule untouched; design-only framing preserved (derive is a named follow-up touch point, not built here). pql decisions validate ok.
H1/T2 Stale terminal-layer doc on AtlasLayerRequest.up_to Fixed — now documents CascadeLayer::Region as terminal (T-1113).
T3 Believability harness depth diverged from production Fixed per ruling — cascade_for_body bumped to Region; the mirror-production invariant is documented on the function (naming D-245 climate-appropriateness as the future state.regions consumer). Believability suite 4/4.
H2 No end-to-end dispatch coverage for regions Fixed — body_params_reader_wired_produces_populated_regions now asserts regions non-empty AND round-trips a second handle_atlas_request from the cache asserting Ready + region_grid.is_some(); the no-params sibling asserts regions stay empty. layer_proxy 10/10.

Gate re-run green on push (parse, full client suite, fmt/clippy/full cargo test/deny). Reviewers asked to confirm.

## Review response — all 4 findings fixed (commit 9d92d8090) No pushbacks. | # | Finding | Resolution | |---|---------|------------| | T1 | dominant_zoning tie-break not computable (ZoningType lacks Ord) | Fixed — the T-1112 amendment's touch-point list (now six) names the enabling change: ZoningType gains PartialOrd/Ord mirroring DistrictType's T-994 precedent. Tie-break rule untouched; design-only framing preserved (derive is a named follow-up touch point, not built here). pql decisions validate ok. | | H1/T2 | Stale terminal-layer doc on AtlasLayerRequest.up_to | Fixed — now documents CascadeLayer::Region as terminal (T-1113). | | T3 | Believability harness depth diverged from production | Fixed per ruling — cascade_for_body bumped to Region; the mirror-production invariant is documented on the function (naming D-245 climate-appropriateness as the future state.regions consumer). Believability suite 4/4. | | H2 | No end-to-end dispatch coverage for regions | Fixed — body_params_reader_wired_produces_populated_regions now asserts regions non-empty AND round-trips a second handle_atlas_request from the cache asserting Ready + region_grid.is_some(); the no-params sibling asserts regions stay empty. layer_proxy 10/10. | Gate re-run green on push (parse, full client suite, fmt/clippy/full cargo test/deny). Reviewers asked to confirm.
Author
Owner

Re-review verdict: APPROVED — Hoshe: both findings verified by execution (layer_proxy 10/10, cascade 10/10; full dispatch-to-region_grid loop closed). Troblum: all three resolved — the ZoningType derive is correctly record-only (design-only discipline held), stale doc fixed, believability harness now mirrors production depth with a forward-maintenance note. No new concerns; untouched files byte-identical to round one. Merging.

## Re-review verdict: APPROVED — Hoshe: both findings verified by execution (layer_proxy 10/10, cascade 10/10; full dispatch-to-region_grid loop closed). Troblum: all three resolved — the ZoningType derive is correctly record-only (design-only discipline held), stale doc fixed, believability harness now mirrors production depth with a forward-maintenance note. No new concerns; untouched files byte-identical to round one. Merging.
jpmschweitzer closed this pull request 2026-07-16 19:30:12 +02:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jpmschweitzer/settled-reach#179