Skip to content

Venue staff commute to work through the lobby or the Metro - #2238

Merged
maniator merged 1 commit into
mainfrom
claude/project-thread-u5g4vi-staff
Nov 15, 2026
Merged

maniator merged 1 commit into
mainfrom
claude/project-thread-u5g4vi-staff

Conversation

@maniator

@maniator maniator commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

What & why

In Modern towers, venue staff now come to work as people. This is the second half of the "no warping" plan for workers, after office commutes (#2228, shipped in 3.13.0). Each staffed venue has a crew of its own (Kind::staff_size):

  • 2 for a shop or boutique bay
  • 3 for fast food, amusements, a spa or a sky bar
  • 4 for a restaurant, nightclub, daycare, cinema or party hall
  • 6 for a food hall or aquatic center

The crew is called in four hours before the venue opens and rides in from the ground lobby or the Metro, so a shop that opens at 10 has its crew in by about 6:30, before the 7 to 10 AM office rush. The doors open once the first of them is in, and the crew leaves the same way after closing; a break of four hours or less, such as a restaurant's between lunch and dinner, keeps the crew in. A venue no route reaches never opens. Classic venues keep opening by the clock.

  • facilities/predicates.rs adds Kind::staff_size, Kind::staffed_at (the open hours plus the four hours before, CREW_CALL_AHEAD) and Kind::waits_for_staff(mode). rules/commute.rs adds venue_staff_commute_in_person, which is Modern only and follows the office commutes.
  • On the tower side, Unit::staff_in (a u8, not saved) is rebuilt from the crowd's desks. Unit::open_for_business(hour, mode) is is_open_at and, for a venue that waits for staff, at least one staffer in. It gates visits, walk-ins, takings (economy/traffic.rs) and the drawn presence.
  • crowd/workplace.rs (new) defines Workplace (an office or a venue) and what each asks of the commute: who counts as at work, the crew size, the errand a person card names, and what the hourly booking owes (due).
  • In crowd/commuters.rs, the hourly booking and reconcile now cover venues alongside offices:
    • A venue built or edited mid-hour calls its crew in at once, and so does one that finishes construction mid-hour (Crowd::book_venue_crews, called from finish_construction).
    • A save without a crowd, or one from before venue staff, loads with the crew already at work.
    • A bulldozed venue sends its crew out through the lobby.
  • A staffer's trip uses ErrandPlace::Work, saved as "work".
  • Two marks beside the crowd's desks (commuters_save::CrowdMarks) keep a reload on the same game:
    • crowd.desksStale marks a save taken after an edit the desks were not squared with yet: workers stranded by a bulldoze, or a venue built while it should be open whose crew the next step calls in. The load squares the desks without sending anyone (restore_desks) and leaves the rest to the first step, as the game that saved would have.
    • crowd.venueStaff marks a Modern save once a step has squared the desks, so a load keeps a venue whose crew is not in yet empty. A save without it (from before venue staff, or one no step had squared) loads with its open venues' crews at work, and its first step squares the desks as a new game's does.
    • save_delta now writes the rest of a delta save with serialize_without(&["units"]) instead of lending the units out of the tower, since the marks read them.
  • dispatch_waiting.rs (moved out of dispatch.rs, which was at the 500-line limit) holds ElevatorDispatch::accumulate_waiting. It now keeps the last room's kind answer (rooms of one kind sit together) and finds a floor's slot by index through DispatchFloors::slot (a slot_of table built with the served floors) instead of a search. This pays for the extra riders many times over; see Complexity.
  • crowd/seg_set.rs, the route search's seen-segment bitset, is on the named-flags allowlist (indexed by segment id). The crowd keeps one set between searches (Crowd::route_seen) and clears only the words it touched, so a search allocates nothing.
  • The housekeeping pass counts free housekeepers in the same walk that finds them (free_maids_counted) instead of scanning the people again.
  • On the help pages: a staff row in Food and shops, a Modern staff paragraph in Venues, and a Staff bullet in People.

Closes: n/a (no issue)

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • Classic-canon fix (matches the 1994 original for all towers)
  • Modern-mode feature (opt-in, "what the original couldn't do")
  • New player-facing feature (mode-agnostic)
  • Refactor / internal-only (no player-facing behavior change)
  • Docs / tooling

Game mode impact

  • This change is classic-canon (affects all towers, stays faithful to the 1994 original)
  • This change is modern-only (gated behind Modern mode, does not alter Classic behavior)
  • This change is mode-agnostic (identical in both modes)
  • Any mode-divergent behavior is isolated in the mode rule-set (resolved once at founding), not smeared into the simulation with ad-hoc mode checks

Kind::waits_for_staff(mode) reads venue_staff_commute_in_person from the commute rules. Classic answers false everywhere, and classic_shops_open_by_the_clock pins that. Classic saves carry neither mark.

Quality gates

  • npm run typecheck
  • npm run lint
  • npm test
  • npm run build

Locally on this base: the whole unit project (6,202 tests) and the whole integration project (1,614 tests) pass, plus typecheck and lint on the changed tests. CI runs the full set.

Engine: cargo fmt --check, cargo clippy --all-targets -D warnings with tooling,conformance, and cargo test --features tooling,conformance all pass. I regenerated the conformance lock, frame-days.json, the port-edit cases, the card-text parity record and the compat record (npm run engine:compat).

The rule tests in rule_tests/venue_staff.rs are:

  • a_shop_opens_once_its_staff_ride_in: nobody comes before 6, the crew rides in from the lobby and is all in by 7, the shop is still shut then, and it is open at 10:30. Every minute it also checks that the shop is never open with nobody in.
  • a_crew_is_called_in_four_hours_before_opening: the call-in hour for a shop, spa, restaurant, cinema and party hall, and a restaurant's crew staying through its afternoon break.
  • the_staff_leave_through_the_lobby_after_closing
  • a_shop_no_route_reaches_never_opens
  • classic_shops_open_by_the_clock
  • a_reload_keeps_the_staff_at_work
  • a_save_without_a_crowd_opens_with_its_staff_in
  • a_bulldozed_shop_sends_its_staff_out
  • a_reload_straight_after_a_bulldoze_keeps_the_crowd: a save taken between the bulldoze and the next step reloads to the same crowd, and one tick later still matches the game that saved.
  • a_reload_after_a_shop_opens_mid_hour_keeps_its_crew_on_the_way: a shop finished at half past calls its whole crew in at once, and a save before they arrive reloads with nobody in and plays the next hour the same.
  • a_reload_leaves_a_shop_whose_crew_never_got_in_empty: a shop no route reaches reloads empty and plays the next hour the same; with its desk row removed the venueStaff mark alone keeps it empty, and without the mark (a save from before venue staff) its crew loads at work.
  • no_venue_keeps_more_staff_than_an_office_holds: a save's desks are clamped to an office's head count (Cap office head counts read from a save #2230), so no crew may pass it.

Versioning

  • Added a .changes note with the right app: and crate: levels, or this PR changes no deployed path
  • Engine change: updated packages/verticopolis-engine/README.md and/or engine-rs/CRATE_README.md, or read both and put readmes: unchanged in the note, or this PR changes no engine source

app: minor and crate: minor, because of the new public items and a new saved errand. readmes: unchanged.

Complexity

  • Hot paths touched:
    • ElevatorDispatch::accumulate_waiting runs each step over the room units. It was O(rooms × log floors) with a kind check per room; it is now O(rooms) with one array index per room and the kind check only when the kind changes. DispatchFloors::slot_of is built once with the served floors (O(span)), alongside the table it already built.
    • bfs_route no longer allocates its seen set: the crowd keeps one SegSet and each search clears only the words it set, O(segments touched).
    • free_maids_counted returns the free list and its count from one walk of the crowd, so the housekeeping pass no longer rescans the people.
    • Crowd::book_commutes runs once per game hour, and again for venues only after a mid-hour edit or a venue finishing construction. reconcile runs each hour and on each tower edit. Both were O(rooms) over the offices and stay O(rooms), now matching venues in the same single pass.
    • start_commutes runs each step and pops the shifts that are due.
    • Unit::open_for_business adds one byte compare to is_open_at wherever spawn and traffic read it.
    • Kind::staffed_at runs per venue per hour and checks at most five hours.
    • CrowdMarks::of runs at save time only, one pass over the desks and the room units.
  • No new per-step scan and no new cache. staff_in is a field written from the desk, not a cache with its own invalidation. slot_of lives and dies with DispatchFloors. route_seen is scratch space, never saved and never read across searches.
  • Measurements: callgrind instruction counts over three game days from each save's time, release build with one codegen unit, main at a7cb8fe against this branch (the base differs from the latest main only in sprites and screenshots):
Tower main this PR Change
Split tower 26 (Metro, escalators) 6.154 G 5.939 G -3.5%
Split tower 24 (basements) 8.795 G 8.595 G -2.3%
Maxed Classic 15.245 G 11.285 G -26.0%
Maxed Modern 25.864 G 21.102 G -18.4%
  • Waits. Crews are extra riders, so they add some waiting. Summed over six seeds of three game days against main at a7cb8fe, samples of someone waiting over half an hour went down 5.2% on split tower 26 and up 5.7% on split tower 24 and 6.0% on the maxed Modern tower (one seed on the maxed tower is +12%; without it, +4.0%). On the earlier base these were +3.0%, +5.0% and +3.5%. I tried two other call-in rules there: never calling a crew during the 7 to 10 AM rush (after it instead: +4.9%, +7.5%, +6.0%) and calling those crews at 6 AM before it (+8.4%, -0.6%, +1.5%). Plain four hours ahead was the simplest and best on the biggest tower. The owner's split tower fixture still has nobody above the lobby waiting 70 minutes (full_car_passes).

Hot-path record (section 6): this comes with the review.

Screenshots / recordings

None. The screenshot scenes are Classic or before the venues open, and a Modern venue looks as it did: dark until it opens.

Notes for reviewers

  • Review round 1 (F1 to F4). F1: a venue finishing construction mid-hour books its crew at once, and the load's fill of desk-less venues now runs only for a save without venueStaff; the two reload tests above pin both. While testing it I found a save taken after building a venue but before the next step lost the venue booking on reload, so desksStale now also covers a venue crew the next step would call in. F2: SegSet is reused and cleared word by word. F3: free housekeepers are counted in one walk. F4: the closed_cars comment says it is saved as closedCars.
  • Venues opening late on the owner's tower. With the earlier one-hour call-in, 57 to 60 of 64 venues were serving at noon, against 64 on main; I have not recounted them with the four-hour call-in. The rest were waiting on staff stuck in the Metro line under the basement express. Office workers already wait up to 4 or 5 hours in that line on main, because the express runs full both ways in the rush: cars come down packed and leave the Metro packed.
    • I tried two changes: counting the riders waiting at the stops below in the router's line cost, and sending more than one car to a stop whose line fills several cars. Neither shortened the line. So this is the tower's express capacity, not a dispatch fault.
    • The owner chose to ship it this way (2026-11-15): staff wait in line like everyone else, and the venue stays dark until they arrive, which shows the player where transit is jammed.
  • Moved pins. fxSequences: the Modern ransom run now ends on one detonation, on floor 42, and the fire-rescue run guts 17 rooms, as on main. The services coverage list drops the inert cinema, housekeeping, parking floor, ramp, restaurant and shop that the old blast reached. load_stream_edit_tests streams 153 of its 400 edited saves (the base saves gained desks and marks). portReads and viewReader read their towers later in the day, since a venue opens once its crew is in. The perf comparison's split tower still peaks at 23 people over a day, as on main; docs/performance/ts-vs-wasm.md said 27 and now says 23.
  • Base. Rebased onto main at a500207 (after Write each unit and person straight to the save (stage 2 of faster local saves) #2323's direct save writer, My Towers: Open and Save As windows replace Saved Towers #2319's My Towers and Polish the service room sprites at 10 by 45 #2326).
  • staff_in is not saved, on purpose. The desks are saved with the crowd, and a save without a crowd puts the crew in at load, so a reload opens the same venues.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ms7trYcRHkvnh6N2YZqqjw

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
verticopolis Ready Ready Preview Nov 15, 2026 8:32pm UTC

Request Review

@github-actions github-actions Bot added this to the 4.0.0 milestone Nov 14, 2026
@maniator
maniator marked this pull request as ready for review November 14, 2026 23:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T18:49:21.813172Z
We couldn’t complete this review. Comment @codex review to try again.
802df5b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch from c2dd0f7 to 42bda6a Compare November 15, 2026 03:48
@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch from 42bda6a to 875f139 Compare November 15, 2026 04:46
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

The docs preview for this pull request was removed when it closed.

@github-actions

Copy link
Copy Markdown
Contributor

📸 Screenshot drift check

No drift: the committed screenshots already match a fresh deterministic generation. ✅

@maniator maniator left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of 875f139: CONDITIONAL GO (two small patches, the owner's call on cost, rebase)

Stand-in PR review plus a /gds-code-review lean pass (Blind Hunter, Edge Case Hunter, Acceptance Auditor, Hot-Path Auditor, triage), since Copilot, Codex and PR-Agent are down. This covers the whole diff over main at c48616b (4.0.0). It is a save change, so I ran the reload same-game proof myself.

What I checked myself

  • Same game after a reload. I played 13 hours, saved, reloaded, then hashed state and crowd every hour for 3 days. Maxed Modern, maxed Classic and the owner's tower all had 0 divergences in 72. A second probe reloaded a copy every minute from 8:20 AM to 1:20 PM on day 2, through the hours the staff ride in and the venues open, and compared it one minute later. The owner's tower and maxed Modern had 0 mismatches in 300.
  • desksStale is load-bearing. With the UNSQUARED mark taken out of restore_desks, a_reload_straight_after_a_bulldoze_keeps_the_crowd fails. All 9 venue_staff tests pass with it in.
  • Desk bookkeeping. The full-office rule from #2268 now covers venues through Workplace::crew, and desk_from's clamp at an office's 6 covers the largest crew, which no_venue_keeps_more_staff_than_an_office_holds pins. staff_in is synced at every desk change and at load (the standing check in reconcile), so it cannot drift. is_operational does not treat a closed venue's Empty state as gone, so staff can come in during the hour before opening.
  • Classic is untouched. waits_for_staff is false there, and open_for_business reduces to is_open_at.

Patches

  1. Workers leaving a bulldozed office lose their card purpose (commuters.rs: leave and the full or gone branch of at_destination). With the unit gone, Workplace::of returns None, so stamp sets no errand, and trip_facts shows Purpose::Unknown. On main, the same worker is stamped ErrandPlace::Office and reads "from work". Office and Work map to the same purpose (ToWork / FromWork), so a fallback restores the card. Either stamp ErrandPlace::Work when the kind is unknown, or keep the kind on the Commute or the Desk. Add a test that bulldozes an occupied office and checks the leaver's purpose.
  2. The change note says "a save without the key loads as before", which is not quite right. Before this PR, the load's reconcile sent stranded workers out at once. Now a save without desksStale whose desks are stranded (one from 4.0 taken between a bulldoze and the next step) loads with them still inside, and the next hourly pass sends them out. The window is one frame and nobody vanishes, so I'm not asking for a code change. Reword the note to say what happens.

The owner's call: per-tick cost of the new people (HP-2)

Whole-tick time, release build, zz_edit_bench2.rs, best of 7 per run, three interleaved rounds against main at c48616b (median, ms, main / this PR):

Tower Edit every minute 7-8 AM 8-9 AM
owner none 23.0 / 24.6 (+7%) 10.0 / 11.4 (+14%)
owner revision bump 102.0 / 109.1 (+7%) 162.0 / 152.1 (-6%)
owner stop set and cleared 101.3 / 110.0 (+9%) 162.6 / 153.5 (-6%)
split-tower-16 none 62.4 / 59.3 (-5%) 69.5 / 66.3 (-5%)
maxed-modern none 47.0 / 45.4 (-3%) 198.7 / 212.8 (+7%)
maxed-modern stop set and cleared 130.8 / 133.3 (+2%) 364.6 / 379.4 (+4%)

The no-edit rows on the owner's tower are slower in every round. I traced it to the staff themselves. Day 2 on that tower is a weekend, so main has no commuters from 7 to 9 AM and about 186 people. This PR has up to 118 staff on the move and 305 people at 8 AM. On maxed Modern at 8:45 AM, the crowd is 4,215 people against 3,954. The code adds no per-step scan: open_for_business is one compare, and book(venues_only) runs once per edit over the rooms. So this is the cost of the feature's own trips, not overhead. Under the zero-slowdown rule, the owner has to accept it in his own words, as he did for #2228's rush and #2272's re-routes. #2246 lands first and is faster by more than this, but that is his decision to make.

Conditions

  1. Fix patch 1 and reword the note (patch 2).
  2. The owner accepts the per-person cost above in his own words.
  3. Rebase onto main. The branch shows conflicts again after the latest merges. CI on 875f139 is green (38 passed, 8 skipped), and it needs to be green on the rebased head.

Hot-path record (section 6), 875f139, whole diff

Item Result What was checked Findings and resolution
HP-1 clear book_commutes (hourly) <- Simulation::tick. start_commutes (per step), which runs reconcile and book(venues_only) only on a revision change. open_for_business <- spawn_floors, walk_ins, spawn_venue_visit, meal_trips, traffic and presence. desks_stale <- serialize (per save). none
HP-2 finding (1) No new per-step scan. book(venues_only) is O(rooms) per edit. The added staff are new people with their own trips: +7% and +14% per tick on the owner's tower from 7 to 9 AM with no edits, and +7% on maxed Modern from 8 to 9 AM (table above). the owner accepts the cost, or the staff trips get cheaper
HP-3 clear shifts are pushed into the existing Vec. reconcile's id list is unchanged none
HP-4 clear sort_shifts is unchanged apart from a renamed key none
HP-5 clear desks stays a BTreeMap by id. staff_in is a u8 on Unit none
HP-6 clear open_for_business is is_open_at plus one byte compare none
HP-7 clear The office commute code moved into workplace.rs (hour_share, office_hours, sync_head_count) was re-read as new: same logic, with venues added beside offices none
HP-8 clear no cache. staff_in is state written from the desk at each change and at load, with no separate invalidation none
HP-9 finding (1) remedy for HP-2 named above as above
HP-10 clear deterministic. Reload gives the same game on three towers (hourly for 3 days, and every minute through the morning). The desksStale mutation is caught none
HP-11 clear no binding or frame layout change. The compat record moves only its lock digest none
HP-12 n/a no rendering change. presence reads open_for_business in the engine none

Reviewed against Verticopolis conventions (.github/copilot-instructions.md).


Generated by Claude Code

@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch from 3bfbd8a to 816f20b Compare November 15, 2026 05:13
@maniator
maniator marked this pull request as draft November 15, 2026 05:14

@maniator maniator left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming pass on 816f20b: both patches fixed; GO once the owner accepts the cost and CI is green

Stand-in PR review plus a /gds-code-review lean pass, covering 3bfbd8a (the rebase) and 816f20b (the fixes).

  • The rebase (3bfbd8a). I replayed 875f139 onto its new base and compared. Only regenerated goldens, the compat record's lock digest, frame-days.json and the STREAMED count differ.
  • Patch 1 is fixed. stamp now falls back to ErrandPlace::Work when the workplace is gone, so the card reads "from work" again. staff_leaving_a_bulldozed_shop_still_go_home_from_work checks every leaver of a bulldozed shop, and it fails on 3bfbd8a, as you said. One side effect, which is fine: a worker leaving a bulldozed office now carries Work, so on_the_job keeps their wait off the floor where the office stood. On main that wait stressed the floor. The office is gone, so nothing there should be judged by it.
  • Patch 2 is fixed. The change note now says a save without the key keeps the stranded workers until the next hourly pass.
  • The fxSequences re-pin (fire scenario firesGutRooms 10 to 12) comes from #2246's routing landing on main, not from this diff.

No new findings. Still open:

  1. The owner's acceptance, in his own words, of the per-tick cost of the staff's trips (HP-2 in my review of 875f139). The hot-path record from that review carries to this head, with HP-2 and HP-9 waiting on that answer.
  2. Green CI on 816f20b.

Reviewed against Verticopolis conventions (.github/copilot-instructions.md).


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Held out of 4.1 by Naftali (2026-11-15) because of the rush-tick cost of the staff's trips, so this is back to draft. The red engine-wasm here is the same install budget check as #2272, which is being raised to 6 MiB in its own PR. This branch gets rebased and reworked for a cheaper commute after 4.1.


Generated by Claude Code

@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch from 816f20b to 802df5b Compare November 15, 2026 18:48
@maniator
maniator marked this pull request as ready for review November 15, 2026 18:49
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch 2 times, most recently from c8be6a2 to 0014ef2 Compare November 15, 2026 18:58
@maniator maniator changed the title Venue staff commute to work through the lobby or the Metro (held) Venue staff commute to work through the lobby or the Metro Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Independent review (stand-in-pr-review + /gds-code-review, lean pass): CHANGES REQUESTED

Reviewed head 0014ef2. Its engine source is identical to 802df5b, which is what I probed; the last two pushes touch only the named-flags allowlist, the perf-comparison pin and ts-vs-wasm.md. Copilot, Codex and PR-Agent are down, so this is the stand-in review. The probes are scratch files, never committed.

What holds up

  • Classic is untouched. On maxed-classic, the full save text hashes are identical on base ae8d811 and the PR every hour for 48 game hours (48/48). Every Classic conformance case and Classic frame-days golden is unchanged; only Modern cases moved. The dispatch rewrite (dispatch_waiting.rs, DispatchFloors::slot, kind-answer reuse) folds rooms in the same order. alight_x, way_is_cut, station_underfoot and the housekeeping free_left == 0 shortcut each give the old answers (I traced assign_maid: with no free maid it returns NoneFree before any route, so the shortcut counts the same rooms as unreachable).

  • No staff warp in a running Modern game. Over one day on maxed-modern (440 staffed venues), I tracked every step. Each of the 709 rises in a venue's staff_in matched an inbound commuter of that venue who arrived, and each of the 1,412 falls matched a new outbound commuter by person id. Unmatched: 0. No venue that waits for staff was open with nobody in: 0 venue-minutes.

  • Reloads. On maxed-modern, saving and reloading at :30 every hour for 26 hours gave the same game an hour later each time (26/26). Bulldozing a staffed shop and an office at 12:00 and saving at once writes desksStale: true, and the reload matches the game that saved for the next 120 minutes.

  • Speed. cgu1 callgrind, one game day per tower, against base:

    tower base Ir PR Ir change
    maxed-classic 6.732 G 4.781 G −29.0%
    maxed-modern 11.629 G 8.554 G −26.5%
    split-tower-26 3.150 G 3.043 G −3.4%

    Most of the drop is dispatch_pass (Classic 168.4 M → 4.4 M, Modern 382.7 M → 15.4 M), bfs_route and accumulate. Two functions are slower on the small tower (F2, F3 below).

Findings

F1 (patch, NO WARPING and reload identity). A venue that becomes operational mid-hour, for example a shop whose construction finishes, gets no desk until the next hourly pass. Finishing construction does not move tower.revision, so start_commutes does not book it either. If the game is saved in that window (autosave included), the load runs reconcile's branch for saves from before this PR: no desk plus staffed_at(hour) puts staff_size inside at once. The crew appears inside without riding in, the shop opens, and the crowd diverges from the game that saved. The probe built a Modern shop at 6:00, 9:00 and 13:00, stepped until it turned operational (08:56, 11:56, 15:56) and saved at that step. Every reload loaded staff_in 2 with desk inside: 2, while the game had no desk, and crowd.view() differed from minute 4 on. The same window opens when a venue comes back after a fire. Fix: only fabricate staff on a load from a save that predates venue staff (a version or a marker the new writer always writes). Also have a venue that turns operational at a staffed hour call its crew in, as a newly built one does, rather than wait for the hour. Please add a regression test for a reload straight after construction finishes.

F2 (patch, HP-3). bfs_route now builds a SegSet on every call: 645 words (5.2 KB) allocated and zeroed for the whole lot, whatever the tower's size. On split-tower-26, bfs_route went from 0.82 M to 1.75 M Ir inclusive (+113%). The run is still faster overall, but NOTHING SLOWER covers each path. Remedy (HP-9): reuse one set kept on the crowd, clearing only the words a search touched, or size it to the tower's floor span.

F3 (patch, HP-2). dispatch_pass now scans crowd.people a second time (free_maid_count) right after free_maids built the same list. On split-tower-26, dispatch_pass went from 0.73 M to 1.35 M Ir. Remedy: sum the lengths of the lists in free.

F4 (patch, docs). In crowd/mod.rs, the closed_cars comment now says "never saved". crowd/save.rs:400 writes closedCars (#2240), so the comment should say so again.

Owner call, not mine. The 3.0% to 5.0% rise in waits over 30 minutes still needs Naftali's OK before merge, as the PR says.

Hot-path record (section 6), head 0014ef2

item result traced resolution
HP-1 clear accumulate_waiting ← ElevatorDispatch::accumulate ← sim step; book/reconcile ← book_commutes (hourly) and start_commutes (every step, edit-gated); bfs_route ← route search; dispatch_pass ← housekeeping step; desks_stale ← every save n/a
HP-2 finding (1) free_maid_count rescans people per pass; book(venues_only) walks rooms only on an edit; desks_stale is O(desks) per save F3
HP-3 finding (1) SegSet::new alloc + memset per bfs_route; book no longer inserts idle desks F2
HP-4 clear sort_shifts unchanged (hourly/edit); Banks sorts once per revision n/a
HP-5 clear AdjGraph, Memo.stops, cols, served set moved to FastMap/FastSet; checked for walks in hash order: adjacency(..).sorted() and passenger_parts sort before use n/a
HP-6 clear DispatchFloors::slot replaces a binary search; desks by id n/a
HP-7 clear moved accumulate_waiting reviewed as new; same fold order n/a
HP-8 clear no cache dropped; Banks keeps the per-revision memo with numbered landing lists n/a
HP-9 done remedies named for F2 and F3 F2, F3
HP-10 finding (1) Classic 48/48 hourly hashes identical across builds; Modern reload 26/26; bulldoze-then-save identical; the construction-done-then-save reload diverges F1
HP-11 clear staff_in is not exported; the save gains desksStale and the "work" errand only n/a
HP-12 n/a no rendering change n/a

Probes: zz_classic_hash.rs, zz_staff.rs (build, construction, hourly reload, bulldoze, no-warp) and zz_perf.rs in the project's review folder for this PR.


Generated by Claude Code

@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch from 0014ef2 to f44848d Compare November 15, 2026 20:02
@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch 2 times, most recently from 505fe09 to d5cd7ce Compare November 15, 2026 20:09
@maniator
maniator force-pushed the claude/project-thread-u5g4vi-staff branch 2 times, most recently from 61ac0f5 to 1ea4d84 Compare November 15, 2026 20:16
@maniator
maniator enabled auto-merge November 15, 2026 20:21
Every Modern shop, restaurant and venue now has a crew that commutes as
real people: they ride in from the ground lobby or a served Metro platform
four hours before the venue opens, the doors open once the first of them
is in, and they leave the same way after closing. A venue no route
reaches never opens. Classic venues keep opening by the clock.

The crew's trips use ErrandPlace::Work (saved as "work"), the desks and
bookings are saved with the crowd, and a save made between a bulldoze and
the next step carries crowd.desksStale so its load sends stranded staff
out as the game that saved would.

The dispatch's waiting pass keeps the last room's kind answer and finds a
floor's slot by index (DispatchFloors::slot), which more than pays for the
extra riders: the four benchmark towers run 2% to 30% fewer instructions
than main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trYcRHkvnh6N2YZqqjw

Copy link
Copy Markdown
Owner Author

Independent review, round 2: 1ea4d84 (= 9419511)

Verdict: GO. All four round-1 findings are fixed and verified with probes. No new patch findings and no defers. The 3% to 5% rise in long waits is the level the owner approved on 2026-11-15.

git range-diff shows that the rebase onto da3edaf (9419511) has the same patch as 1ea4d84, so this verdict covers both.

Round-1 findings

# Finding Status Evidence
F1 A venue built mid-hour and saved before the next step came back with its staff already inside after a reload (staff made up out of nothing) Fixed finish_construction now books crews at once through book_venue_crews. A Modern save that has squared once carries venueStaff, so restore_desks creates staff only for older saves. desksStale now also covers venue bookings that are due (venue_bookings_due). Scratch probe: building a shop at 11:30, 6:20 and 21:10, saving, reloading and stepping 120 minutes gives an identical crowd with staff_in 0 in both games. Finishing construction and then saving, at 06:00, 09:00 and 13:00, gives no crowd difference over the run, and the crew (coming: 2) is still on its way after the reload. The only difference is in milestones, at minute 1, and the same difference shows up on the control run with nothing built, so it comes from the test fixture and not from this PR.
F2 SegSet::new allocated 5 KB+ per search Fixed One Crowd::route_seen is kept between searches, and clear zeroes only the words a search touched. bfs_route (which allocates fresh) is now called only from tests. Its unit test compares it against a hashed set, inside and outside the lot, before and after a clear.
F3 free_maid_count() second scan Fixed free_maids_counted returns the pair in one pass, and both callers use it.
F4 The closed_cars comment said "never saved" Fixed

Probes I re-ran (scratch only, never committed)

  • Hourly reloads on maxed-modern: 26 of 26 save-and-reload points play an identical game an hour later.
  • Bulldoze then save: after bulldozing a staffed venue and an office at 12:00, the save carries desksStale: true, and the reload plays the same game over 2 hours.
  • Staff never appear or vanish: over a day on maxed-modern's 440 venues, I tracked staff by person id. There were 709 rises and 1,412 falls, and every one matched a commuter who arrived or set out (0 unmatched). No venue was open with nobody in.
  • Classic is untouched: on maxed-classic, the save hash every game hour for 48 hours is identical between main a500207 and this PR.

Hot-path record (docs/performance/hot-path-review.md, section 6)

Callgrind, cgu1 release, 1,440 one-minute ticks, total instructions (load included), main a500207 against the PR:

Tower main PR Change
maxed-classic 6.72 G 5.02 G -25.3%
maxed-modern 11.63 G 8.69 G -25.2%
split26 3.15 G 3.04 G -3.4%
Item Result Notes
HP-1 per-tick scans OK Venues are handled in the existing hourly book pass. book_venue_crews runs once per completed construction, which is an event and not a tick cost.
HP-2 nested scans OK None added on the tick path.
HP-3 allocation per tick OK The seen set is reused (F2). SegSet::insert now shows up at +0.29 G self on maxed-modern, and it replaces hashed-set costs that are larger than that.
HP-4 hashing in hot loops OK A bit test replaces the hash for in-lot ids.
HP-5 sorting OK Nothing new.
HP-6 tier budgets OK Every tower is faster than main.
HP-7 big-O growth OK desks_stale and venue_bookings_due are O(units + desks) and run only at save time, and only while the desks are unsquared.
HP-8 caches OK No cache dropped or bypassed. desk_revision and UNSQUARED keep the squaring lazy.
HP-9 wasm boundary n/a
HP-10 render or host n/a
HP-11 save and load OK One extra flag, venueStaff. Reload identity was checked above.
HP-12 measured OK The callgrind table above, on three towers.

CI on 9419511: everything that has finished is green. One e2e shard was still running when I checked.


Generated by Claude Code

@maniator
maniator merged commit a29617b into main Nov 15, 2026
47 checks passed
@maniator
maniator deleted the claude/project-thread-u5g4vi-staff branch November 15, 2026 20:33

This branch was successfully deployed

1 active and 1 inactive deployments
github-pages — 9419511c Deployed Nov 15, 2026 by maniator via docs-preview (remove) / docs-pages (deploy) #792
Preview — 9419511c Deployed Nov 15, 2026 by vercel[bot]
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.

2 participants