Skip to content

Let a story set its own people and thing limits - #90

Merged
calebl merged 3 commits into
mainfrom
fm/ta-floors-s1-engine
Oct 30, 2026
Merged

calebl merged 3 commits into
mainfrom
fm/ta-floors-s1-engine

Conversation

@calebl

@calebl calebl commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Stage 1 of the dungeon plan, engine half: world limits for people and things. A story may name its own stories.people_limit and stories.things_limit; where it names none, the limits are today's 12 and 60, so every stored story plays and replays exactly as before.

What changed

  • Readers. realization::people_limit(story) / things_limit(story) read the nullable columns, with cast::MAX_PER_STORY (12) and realization::ITEMS_PER_STORY (60) as the fallback. Every place that used to read the constants now reads them:
    • the slot draw, cast::slots, through a new cast::Room::story_limit (src/turn/told/realize.rs passes the story's limit);
    • the room writer's thing allowance (realization.rs, items_instructions) and realization::room_for_people;
    • admission of a written thing and a written person (realize.rs, formerly :828 and :997).
  • Migration 20261030120000 adds stories.people_limit integer and stories.things_limit integer (nullable, no default). Every world dump in parity/worlds/ carries it, applied through sqlite exactly as Rails' SQLite adapter issues it (ALTER TABLE "stories" ADD "people_limit" integer, then things_limit), plus its schema_migrations row. A plain re-dump of each world was byte-identical before the migration was applied.
  • The game at its current pin still opens. SCHEMA_VERSION does not move and shape.txt does not gain the columns. Instead store::OPTIONAL_COLUMNS names the two exact facts (column stories.people_limit integer pk=0, same for things), and store::shape leaves them out. So a database with or without them opens, and one without reads both as null, which means the ordinary limits. A column declared any other way (for example NOT NULL DEFAULT 12) is still a difference and is refused. SERVER_COMMIT now points at the server pin PR's head, Pin renderedstep/engine#90's merge commit (44bd3ce): let a story set its own people and thing limits server#368 (ccc92ed), which carries the migration. So CI plays a-thirteenth-person-is-born through the real server half.
  • Sweep. New world a-crowded-cellar (story A Crowded Cellar): Nell and eleven others in a coaching inn, twelve people in all, and a stub Cellar with population: a crowd, danger: safe. The dump is what the game's own loader writes at Pin renderedstep/engine#90's merge commit (44bd3ce): let a story set its own people and thing limits server#368's head ccc92ed, with the migration and limits: { people: 20 }. There the inn's eleven people also have stats; no golden moves for them. New script a-thirteenth-person-is-born, in PASSING with a golden and a records file: walking into the cellar, the writer is asked for EXACTLY 3 people, and all three are born (the 13th–15th people of the story).
  • Goldens. All 99 existing goldens and records files are unchanged. vectors/cast.json is unchanged at the default.

Tests

  • cast::tests: the slot draw at the default (11 → 1 slot, 12 → none) and at a raised limit (12 of 20 → the crowd's full 3, with the same dice as an empty story; 19 of 20 → 1; 20 of 20 → none).
  • realization::tests: room_for_people with twelve people: (3, 0) with no limit of its own, (3, 8) at 20.
  • tests/engine.rs, walking into the crowded cellar with a scripted writer that names three people and two things:
    • no limit of its own: 12 people, and the writer is told to write NOBODY;
    • 20: 15 people (EXACTLY 3); 13: 13 people (EXACTLY 1);
    • things at 60: both admitted (AT MOST 3); at 1: one admitted (AT MOST 1).
  • Store: a database from before the migration (columns dropped, version row removed) opens and plays; a people_limit declared NOT NULL DEFAULT 12 is refused as a difference.
  • a_database_at_an_older_schema_is_refused now deletes every version from SCHEMA_VERSION on, since the worlds carry a later one.

Local runs: cargo fmt --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test --workspace and parity --check parity (100 of 104 agree; the other four are runner-only, as before) all pass. I ran the CI runner job locally against the game at its pin (f6458b9, extension built from this checkout): parity/runner.sh 103 of 104 agree, with a-thirteenth-person-is-born "not in the checkout yet", and engine:rust_gates PASSED for 103 scripts.

What the server pin PR must change

  1. Migration db/migrate/20261030120000_add_limits_to_stories.rb, with this exact version so the dumps here stay byte-true:
    class AddLimitsToStories < ActiveRecord::Migration[8.1]
      def change
        add_column :stories, :people_limit, :integer
        add_column :stories, :things_limit, :integer
      end
    end
    Both columns are nullable with no default, people first. db/schema.rb moves to 2026_10_30_120000.
  2. Loader (lib/world_seed/loader.rb). Today load_story! passes document["story"] whole to assign_attributes, so a limits: key would raise. Take limits out of the story document and write people_limit / things_limit from limits.people / limits.things. Write both in both directions on every load: an absent key writes nil, so deleting limits: and re-seeding restores 12 and 60. In validate!, refuse a value that is not a positive Integer ("20", 2.5, 0, -1, true are all refused) and any key under limits other than people and things. Loader tests: seeds with limits, refuses a non-integer, and an absent key is nil.
  3. Exporter (lib/world_seed/exporter.rb, story_document). Emit "limits" => { "people" => …, "things" => … }.compact, and omit the key when both are nil, like the other omitted-when-default keys. Round-trip test.
  4. Ruby registries. In Character::Registry (#world_for_people, registry.rb:321), use story.people_limit || MAX_PER_STORY. In Item::Registry (registry.rb:136), use story.things_limit || MAX_PER_STORY. Registry tests at the default and at a raised limit.
  5. Doctor (app/models/story/doctor.rb). story_over_the_cast_cap (:887) and the story_over_item_cap check (:1123) compare against the story's own limit (people_limit || MAX_PER_STORY, things_limit || MAX_PER_STORY), and their messages name the story's limit rather than the constant. story_over_the_cast_cap is the plan's "seeded cast over its limit" note. Make it fire when the world file's own cast is over the story's limit (for example limits: { people: 5 } with seven people in the file), and add a doctor test for it. Rooms the engine writes in that world are born with nobody.
  6. Sweep. Copy in the world lib/engine_sweep/worlds/a-crowded-cellar.yml and the script lib/engine_sweep/scripts/a-thirteenth-person-is-born.yml (with comments and why:; both are in this PR's description below). Then vendor the goldens, the script and test/engine_parity/a-thirteenth-person-is-born.* from this commit. The world's story: carries limits: { people: 20 }.
  7. Move the pin to this commit. A later engine change may then move SCHEMA_VERSION to 20261030120000 and put the two columns into shape.txt in place of OPTIONAL_COLUMNS.

Out of scope here, as the brief says: per-floor keys, a population or density lever, any other stage, and any prompt change. No model was called.

lib/engine_sweep/worlds/a-crowded-cellar.yml
# A crowded inn: the player and eleven others, twelve people in all, which is
# the ordinary story limit, and a cellar nobody has written yet whose word is
# `a crowd`. The story raises its own limit to twenty (`limits: people`), so
# the cellar is still born with people; under the ordinary twelve it would be
# born empty.
format: 2
universe:
  physics: Ordinary physics.
  technology: Lanterns, barrels and cart wheels.
  weapons: Cudgels.
  geographies: A coaching inn on a wet road.
  civilizations: A market county.
  history: The inn has stood at the crossroads for a century.
  economics: Coin for beds, ale and stabling.
  politics: The county reeve keeps the road.
  religion: Harvest festivals.
  races:
  - name: Countryfolk
    description: Ordinary people of the county.
story:
  title: A Crowded Cellar
  genre: country adventure
  start_time: '2026-09-21T19:00:00Z'
  preface: The Lantern Inn is full to the rafters on a wet night.
  summary: Nell looks for room in a full inn.
  limits:
    people: 20
opening_scene:
  location: Taproom
  characters: [Nell, Hob Allard, Ida Fenn]
  description: You stand dripping by the taproom door.
  summary: Nell comes in out of the rain.
characters:
- fullname: Nell
  nickname: Nell
  race: Countryfolk
  age: 33
  sex: female
  is_protagonist: true
  is_companion: false
  backstory: A tinker caught out by the rain.
  personality: Plain-spoken.
  appearance: A soaked cloak.
  likes: A dry corner.
  dislikes: Crowds.
  fears: Sleeping in the road.
  stats: {level: 10, hit_die: 8, strength: 12, dexterity: 12, will: 12}
- fullname: Hob Allard
  nickname: Hob
  race: Countryfolk
  location: Taproom
  age: 44
  sex: male
  is_protagonist: false
  is_companion: false
  backstory: The innkeeper, who has run the Lantern for twenty years.
  personality: Gruff and fair.
  appearance: A stained apron.
  likes: A full house.
  dislikes: Unpaid tabs.
  fears: A cold hearth.
- fullname: Ida Fenn
  nickname: Ida
  race: Countryfolk
  location: Taproom
  age: 27
  sex: female
  is_protagonist: false
  is_companion: false
  backstory: A barmaid saving for a boat of her own.
  personality: Quick and wry.
  appearance: Rolled sleeves.
  likes: Tips.
  dislikes: Spilled ale.
  fears: Deep water.
- fullname: Moss Tarrow
  nickname: Moss
  race: Countryfolk
  location: Kitchen
  age: 51
  sex: male
  is_protagonist: false
  is_companion: false
  backstory: The cook, who came with the inn.
  personality: Slow and certain.
  appearance: A floury shirt.
  likes: Fresh bread.
  dislikes: Haste.
  fears: Fire in the flue.
- fullname: Pell Quill
  nickname: Pell
  race: Countryfolk
  location: Kitchen
  age: 19
  sex: non-binary
  is_protagonist: false
  is_companion: false
  backstory: A scullion learning the trade.
  personality: Eager and clumsy.
  appearance: Wet cuffs.
  likes: Praise.
  dislikes: Scouring pots.
  fears: The cook's temper.
- fullname: Rue Ambry
  nickname: Rue
  race: Countryfolk
  location: Kitchen
  age: 36
  sex: female
  is_protagonist: false
  is_companion: false
  backstory: A carter waiting for her supper.
  personality: Tired and patient.
  appearance: A dusty coat.
  likes: A hot meal.
  dislikes: Delays.
  fears: A lame horse.
- fullname: Tam Brisk
  nickname: Tam
  race: Countryfolk
  location: Stable
  age: 23
  sex: male
  is_protagonist: false
  is_companion: false
  backstory: The ostler who minds the guests' horses.
  personality: Cheerful and loud.
  appearance: Straw in his hair.
  likes: Horses.
  dislikes: Tight fists.
  fears: Being kicked.
- fullname: Vey Corran
  nickname: Vey
  race: Countryfolk
  location: Stable
  age: 40
  sex: female
  is_protagonist: false
  is_companion: false
  backstory: A drover passing through with her herd.
  personality: Watchful.
  appearance: A long oilskin.
  likes: Open roads.
  dislikes: Fences.
  fears: Wolves.
- fullname: Wick Dunmore
  nickname: Wick
  race: Countryfolk
  location: Stable
  age: 62
  sex: male
  is_protagonist: false
  is_companion: false
  backstory: An old pedlar sleeping in the hay to save a coin.
  personality: Talkative.
  appearance: A patched pack.
  likes: A good story.
  dislikes: Paying for a bed.
  fears: Dying alone.
- fullname: Yara Holt
  nickname: Yara
  race: Countryfolk
  location: Loft
  age: 31
  sex: female
  is_protagonist: false
  is_companion: false
  backstory: A courier resting between runs.
  personality: Restless.
  appearance: Riding boots.
  likes: Speed.
  dislikes: Waiting.
  fears: A lost letter.
- fullname: Zeb Marrow
  nickname: Zeb
  race: Countryfolk
  location: Loft
  age: 29
  sex: male
  is_protagonist: false
  is_companion: false
  backstory: A fiddler hired for the evening.
  personality: Easygoing.
  appearance: A green waistcoat.
  likes: Applause.
  dislikes: Silence.
  fears: A broken string.
- fullname: Ash Penrose
  nickname: Ash
  race: Countryfolk
  location: Loft
  age: 34
  sex: trans man
  is_protagonist: false
  is_companion: false
  backstory: A surveyor laid up by the rain.
  personality: Precise.
  appearance: Ink on his fingers.
  likes: Straight lines.
  dislikes: Muddle.
  fears: Getting lost.
locations:
- name: Taproom
  detail_level: realized
  opening: true
  description: Benches packed shoulder to shoulder under smoky beams.
  teaser: A packed taproom.
  lore: The Lantern's taproom has never been this full.
- name: Kitchen
  detail_level: realized
  description: Steam, copper pans and a roaring range.
  teaser: A hot kitchen.
  lore: The range was built with the inn.
- name: Stable
  detail_level: realized
  description: Stalls of steaming horses and a hayloft ladder.
  teaser: A busy stable.
  lore: Every stall is let tonight.
- name: Loft
  detail_level: realized
  description: Pallets laid end to end under the eaves.
  teaser: A crowded loft.
  lore: The loft is let by the pallet.
- name: Cellar
  detail_level: stub
  danger: safe
  population: a crowd
  teaser: Steps down to the barrels.
connections:
- between: [Taproom, Kitchen]
  distance: adjacent
  travel_method: walking
- between: [Taproom, Stable]
  distance: adjacent
  travel_method: walking
- between: [Taproom, Loft]
  distance: adjacent
  travel_method: walking
- between: [Taproom, Cellar]
  distance: adjacent
  travel_method: walking
lib/engine_sweep/scripts/a-thirteenth-person-is-born.yml
# A STORY'S OWN PEOPLE LIMIT LETS A ROOM BE BORN WITH PEOPLE PAST TWELVE.
#
# The Lantern Inn already holds twelve people, the ordinary limit
# (`Character::Registry::MAX_PER_STORY`), and its cellar is a stub whose word
# is `a crowd`. The world file raises the story's limit to twenty
# (`story.limits.people`, `stories.people_limit`), so the cellar is drawn
# people and the room writer's people are admitted: the thirteenth person of
# the story is born. Under the ordinary twelve the same walk draws nobody and
# admits nobody the writer names.
story: A Crowded Cellar
steps:
- id: down-into-the-cellar
  type: /move Cellar
  why: twelve people already stand in the story, and the cellar is still born with its crowd
  browser:
    token: into-the-cellar
    realizes: Cellar
    replies:
    - purpose: location
      prompt_includes:
      - Write EXACTLY 3 people who are in this place right now.
      content:
        description: Barrels in rows and three latecomers on upturned crates.
        lore: The cellar takes the overflow on a full night.
        items: []
        people:
        - fullname: Orrin Vale
          nickname: Orrin
          appearance: A wet hat.
          personality: Grumbling but kind.
          backstory: A drover who came too late for a bed.
          likes: Dry socks.
          dislikes: Damp.
          fears: Rats.
        - fullname: Sabine Roe
          nickname: Sabine
          appearance: A mended shawl.
          personality: Calm.
          backstory: A weaver walking to the fair.
          likes: Quiet.
          dislikes: Noise.
          fears: Thieves.
        - fullname: Kit Lowan
          nickname: Kit
          appearance: A torn sleeve.
          personality: Restless.
          backstory: A runaway apprentice.
          likes: Freedom.
          dislikes: Masters.
          fears: Being found.
    - purpose: location
      content:
        exits:
        - name: Taproom
          teaser: Steps back up.
          distance: adjacent
          travel_method: walking
    - purpose: arrival
      unavailable: true
  expect:
    location: Cellar (realized)
    present: [Kit Lowan, Orrin Vale, Sabine Roe]
    changed: true

A story may name how many people (stories.people_limit) and how many
distinctly named things (stories.things_limit) it holds. Where it names
none, the limits are today's 12 and 60, so every stored story plays and
replays exactly as before. The slot draw (cast::slots, through the new
Room::story_limit), the room writer's people and item allowances, and the
admission of a written person or thing all read the story's own limit
(realization::people_limit / things_limit) instead of the constants.

Migration 20261030120000 adds both columns to stories (integer, nullable,
no default). Every world dump carries it, applied through sqlite as Rails'
SQLite adapter issues it (ALTER TABLE "stories" ADD "people_limit"
integer, then things_limit). SCHEMA_VERSION does not move and shape.txt
does not gain the columns: store::OPTIONAL_COLUMNS leaves them out of the
shape, so a database from before the migration (the game at its current
pin) still opens and reads both as null, while either column declared any
other way is still a difference.

New world a-crowded-cellar (written by the game's loader at f6458b9, then
the migration and people_limit = 20): Nell and eleven others in a coaching
inn, twelve people in all, and a stub cellar whose word is `a crowd`. New
script a-thirteenth-person-is-born, in PASSING with goldens and records:
the room writer is asked for exactly three people and all three are born,
the thirteenth to fifteenth of the story. Every other golden and records
file is unchanged; vectors/cast.json is unchanged at the default.
…r ccc92ed

The game's pin PR gives the inn's eleven people stats, so the world loads
healthy. The dump is now the one its loader writes, with the limits
migration and people_limit 20 its own. No golden or records file moves.
@calebl
calebl merged commit 44bd3ce into main Oct 30, 2026
4 checks passed
calebl added a commit to renderedstep/server that referenced this pull request Oct 30, 2026
44bd3ce adds to the head pinned before only the engine's CI and
parity/worlds/a-crowded-cellar.sql rebuilt from this branch's loader
(f0c5a9b), so the world dump now carries the stat blocks this repository's
world file gives the cellar's eleven people. No golden, script or vector
portion changed: bin/rails engine:vendored passes, engine:rust_gates passes
all 104 scripts.
calebl added a commit to renderedstep/server that referenced this pull request Oct 30, 2026
Pin renderedstep/engine#90's merge commit (44bd3ce): let a story set its own people and thing limits
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