maniator / maniator/verticopolis
[Feature]: [P3] Move-in gate: cache the sustainability verdict (recompute cost)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Deferred from the Codex review of the move-in sustainability gate (PR #650). Three correctness-neutral recompute-cost findings that share one root: wouldEvictFreshTenant + buildSatisfactionContext are recomputed from scratch at each call site, up to a 48-step forward sim per candidate. The gate ships correct; these are perf follow-ups that want a shared revision-keyed verdict cache.
-
Gate loop cost in
attemptMoveIns(P2). The hourly move-in pass runs up to 48 satisfaction steps per empty condo/office; slow-eroding candidates use the full horizon every hour. In a large tower with many unsustainable vacancies the cost grows as (empty candidates × shafts × amenities).satCtxis already built once per pass; the remaining cost is the per-candidate step loop. Fix shape: cache each verdict against the tower + economy revisions, or precompute the static spatial inputs once. -
Context rebuild per simultaneous condo departure (P2). When a tower-wide problem expires many condo notices in the same tick,
vacate()callswouldEvictFreshTenant(sim, u, buildSatisfactionContext(sim, true))per buy-back for the honest toast note, so that tick is O(departing condos × units) plus a demand-map build each. Bounded (evictions are staggered and infrequent) but quadratic in the worst case. Fix shape: thread one context/verdict through the satisfaction pass, or batch the departure verdicts. -
Inspector recompute in the render path (P2).
wontLeaseText(src/game/gripeCopy.ts) rebuilds the full-tower context, computes a fresh demand map, and may replay 48 steps on every inspector render for a reachable empty condo/office. The mobile editor refreshes at ~6 Hz and desktop pointer moves re-render too, so inspecting one vacancy in a large save adds recurring full-tower work and can stutter. Fix shape: reuse a revision-keyed engine verdict instead of recomputing in the rendering path.
Common fix: a Simulation-level wouldEvictFreshTenant cache keyed by (unit id, tower.revision, demand-memo key) that all three call sites share, invalidated exactly like the noise/demand memos. Correctness is unaffected; this is purely to bound recompute on large saves.
Story: move-in sustainability gate. Mirrors the backlog row of the same id.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace wouldEvictFreshTenant and buildSatisfactionContext through attemptMoveIns, vacate(), and wontLeaseText in src/game/gripeCopy.ts. Compare the three recomputation paths and the existing noise/demand memo invalidation behavior. Done means the call sites share a revision-keyed Simulation verdict cache while preserving the current correctness and toast behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- game-dev, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100