Skip to content

Lay out a town's streets and square before any of it is written (game half of renderedstep/engine#103) - #402

Merged
calebl merged 4 commits into
mainfrom
fm/ta-town-s3-map-server
Dec 4, 2026
Merged

calebl merged 4 commits into
mainfrom
fm/ta-town-s3-map-server

Conversation

@calebl

@calebl calebl commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

The game half of renderedstep/engine#103. A place with a towns row is a town. The engine lays out its streets, square, ways in, anchored buildings and lots with no model. That happens either in the new post-pull step or on the turn somebody first walks into the town. This PR carries the engine PR's "What the game needs" items 1 to 10, and pins the engine at that PR's merge commit (3558baa).

  1. Migration. 20261204140420 CreateTowns, numbered by bin/rails generate migration. Its version is distinct from every migration on main (4f7ec7e, merged in here; main's 20261204143219 CreateArtworks landed after it, and db/schema.rb carries both). Its declaration is the shape store::OPTIONAL_SHAPES pins.
  2. The model. Town has belongs_to :location, and Location has_one :town, dependent: :destroy.
    • streets is a whole number of at least 0, and square is true or false.
    • It mirrors the engine's room count, a bound on how many frontages a town can have, and the frontage side, which Roll::FRONTAGE_SIDE (22) names.
    • Factory and model test included.
  3. The loader and the exporter.
    • WorldSeed::Loader reads town: { streets, square } in load_towns!. Both keys are written in both directions, and an absent square writes false.
    • It refuses:
      • a town that is also a floor;
      • a town with a parent or a position;
      • streets outside 0..Town::MOST_STREETS;
      • a location inside a town that is neither a building (a footprint) nor a street (a box).
    • A building of a town may carry a building's word.
    • The footprint is optional. A re-seed keeps the footprint the engine wrote for a laid-out town.
    • WorldSeed::Exporter writes town: back. A laid-out town's streets, lots and doorways are exported as the rows they are, so a fresh load is the same town already laid out.
  4. Laying the town out.
    • RenderedStep.lay_out_towns(database, story_id, dry_run) calls Engine::lay_out_towns, and Playthrough::RustEngine.lay_out_towns wraps it.
    • Update::Steps::LayOutTowns runs before LayOutRooms.
    • WorldSeed::Loader#lay_out_rooms! skips a town. The loader never lays a town out itself.
  5. The way in. Location::Interior.entry_room and Location#laid_out? take the first child with a box. A town's building is never its way in.
  6. EngineData. location/town is one of the engine's own data files, listed next to location/size in test/models/engine_data_test.rb.
  7. Doctor warnings. There are three, and each is reported and never repaired:
    • town_doorway_left_on_the_town: a laid-out town that still has a doorway on the town place.
    • town_with_more_than_it_can_front: a town not yet laid out that has more ways in and buildings than any layout of it can front.
    • street_past_four_doorways: a street with more than four doorways.
  8. The map page.
    • A town's streets and square are drawn in its plane.
    • Each building fronting a street, whether an anchor or a lot, is drawn as a bar on the side that street's writer is told it is on.
    • The side matches the engine's own request for the sweep world: "The Shrine, which fronts it on the north side".
  9. The Ruby loop. Location::Generator never sends a town place to a model. Two other places learned about towns:
    • the one-room fold moves towns.location_id and never folds a town;
    • the playthrough package carries towns.
  10. The world, the script and the pin.
    • Added lib/engine_sweep/worlds/a-town-of-three-streets.yml and lib/engine_sweep/scripts/a-town-laid-out-before-it-is-written.yml.
    • Vendored the golden and the layout and reach vector portions.
    • Wrote the checks file with SCRIPT=a-town-laid-out-before-it-is-written bin/rails engine:checks.
    • The sweep walk now finds a realized room under the name it had before the step, because this script's streets are renamed as they are written. It also records the footprint that a town's layout writes.
    • This repository vendors goldens, scripts and engine-owned vector portions. The engine keeps its parity/records and parity/worlds files itself.

Post-update step

This PR adds Update::Steps::LayOutTowns to Update::REGISTRY. bin/update lays out every stored town that has no streets yet. It makes no model call, and a second run finds nothing to do.

What a model is sent

On this side, nothing changes.

  • Every existing script matches its golden on the Rust engine.
  • bin/rails engine:kept_requests passes.
  • bin/rails eval:realization_digest matches the checked-in baseline's message, corpus and branch-request identities.

The new street wording is the engine's, in the engine PR.

The world dump

I loaded a-town-of-three-streets through the loader with the parity README's procedure and dumped it. The engine's parity/worlds/a-town-of-three-streets.sql at 3558baa is that dump, byte for byte, at migration 20261204140420.

Checks

All run with both provider keys unset.

  • bin/rails test: 5597 runs, 0 failures, 1 skip (main's Ren'Py export lint, which needs TA_RENPY_SDK). This includes rake game:sweep.
  • bundle exec rubocop: no offenses.
  • bin/rails zeitwerk:check: all good.
  • bin/brakeman --no-pager: no warnings.
  • bin/rails engine:rust_gates: all 116 scripts pass.
  • bin/rails engine:kept_requests: passes.
  • bin/rails engine:vectors: only the two vendored portions differ from main.
  • bin/rails engine:vendored: the goldens, the scripts and the engine's own vector portions are 3558baa's, byte for byte.

…s and square before any of it is written

A place with a `towns` row is a town: the engine lays its streets, square,
ways in, anchored buildings and lots out with no model, either from the
post-pull step or on the turn somebody first walks into it. Every existing
world's requests are unchanged; nothing a model reads changes on this side.

- Migration 20261204140420 CreateTowns (the generator's version), the shape
  the engine's store::OPTIONAL_SHAPES pins. Town model (streets >= 0, square
  true or false, the engine's room count, frontage bound and frontage side),
  factory and test; Location has_one :town. Roll::FRONTAGE_SIDE (22) named.
- WorldSeed::Loader reads `town: { streets, square }` (load_towns!), both keys
  in both directions, and refuses a town that is also a floor, has a parent or
  a position, a street count outside 0..100, or a location in it that is
  neither a building (footprint) nor a street (box). A building of a town may
  carry a building's word. lay_out_rooms! skips a town, and a re-seed keeps a
  laid-out town's footprint. The loader never lays a town out itself.
- WorldSeed::Exporter writes `town:` back; a laid-out town's streets, lots and
  doorways round-trip as the rows they are.
- RenderedStep.lay_out_towns binds Engine::lay_out_towns, wrapped by
  Playthrough::RustEngine.lay_out_towns. Update::Steps::LayOutTowns runs
  before LayOutRooms, with a dry run.
- Location::Interior.entry_room and Location#laid_out? read the first child
  with a box, so a town's building is never its way in.
- EngineData: location/town is one of the engine's own data files.
- Story::Doctor warns of a laid-out town with a doorway still on the town
  place, an unlaid town asked to front more than any layout of it can, and a
  street past four doorways.
- The map draws a town's streets and square in its plane, and each building
  fronting a street as a bar on the side the street's writer is told.
- Location::Generator never sends a town place to the model. The one-room
  fold moves towns.location_id and never folds a town; the playthrough
  package carries towns.
- Sweep: world a-town-of-three-streets and script
  a-town-laid-out-before-it-is-written, golden vendored and checks file
  written; the layout and reach vector portions vendored. The walk finds a
  realized room under the name it had before the step, and records the
  footprint a town's layout writes.
…ipt and world are the ones the game writes

The engine now stores parity/scripts/a-town-laid-out-before-it-is-written.yml
re-emitted, so bin/rails engine:vendored agrees byte for byte, and its
parity/worlds/a-town-of-three-streets.sql is the loader-built dump at migration
20261204140420. No engine source changed between the two pins.
Its tree differs from c724c05 only in the engine's own CI workflow; the
goldens, scripts and vector portions here are 3558baa's, byte for byte.
@calebl
calebl merged commit 0fee3e3 into main Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant