Phase 4: close loot/refund leaks, landing-site garrisons, speed-scaled shipping, update/offsite tooling, broad e2e

Built:
- Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds).
- End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x).
- Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in.
- e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English.

Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented).
NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-12 00:58:12 +02:00
parent 9104480463
commit 3c23c51902
92 changed files with 4887 additions and 300 deletions

View file

@ -55,7 +55,7 @@ node tools/bot.js --help
| invariant | how it is checked |
|---|---|
| resources are conserved | `pools = sources + production - sinks`, per resource, at every midnight and at the end. Pools: POP stock, open trade escrow, cargo of movements that are out, landing-site stockpiles. **Production is exact**: a tap on `db.run` books the difference every `state.settle` writes (and drops it if the transaction rolls back). Sources: start stock of operators and founded POPs, the incumbent Hardware bonus. Sinks: build/train/research costs (command results), Backbone node levels, `cargoLost` in notifications (overflow at delivery), trade refunds clipped by the Rack hall cap (tap on the refund statement). Tolerance 0.5 per rounding event. |
| resources are conserved | `pools = sources + production - sinks`, per resource, at every midnight and at the end. Pools: POP stock, open trade escrow, cargo of movements that are out, landing-site stockpiles. **Production is exact**: a tap on `db.run` books the difference every `state.settle` writes (and drops it if the transaction rolls back). Sources: start stock of operators and founded POPs, the incumbent Hardware bonus. Sinks: build/train/research costs (command results), Backbone node levels, `cargoLost` in notifications (overflow at delivery), `trade_refund_clipped` notifications (a refund that did not fit: only after a shot-down Rack hall since B6, 0 in every standard run). Open trade escrow is a pool. Tolerance 0.5 per rounding event. |
| units are conserved | alive (home + stationed + on the road) = trained (`trainDone` events that ran) - lost (battle, scan, incumbent, landing reports, decommission notifications) - consumed (3 crews per founded POP, 1 M&A team per loyalty hit). Exact. |
| no negative stock | SQL scan of towns and landing sites. |
| no failed events | `events.status = 'failed'` and any server log line mentioning a failure. |
@ -228,11 +228,34 @@ much as 1000 per link at both speeds (59 days at 1x; best level 94 on day 110 at
was taken because the cost curve was set on purpose ("far more than anything else", DECISIONS E5, and DESIGN.md quotes 7.2 M) while carrying
500 units per trip is a convenience limit nobody argued for, and because it also lifts bulk trade a little.
**Not solved by B2:** speed does not shorten the end game the way it shortens everything else. A 3x world opens its sites on day 33, but
its alliances still take 76 days (seed 2) after that, about as long as a 1x world, because shipping is per sitting, not per hour (and
at day 33 the members are at field level ~12 with fewer links). `capacityPerLink x world speed` in `rules.transportPlan` would
restore the scaling (a 10x world with a final push finished 8.5 days after opening, below) but the client reads the constant directly
(trade form limits, send dialog), so it was left to the owner of that code.
**Not solved by B2 (solved by B7, below):** speed did not shorten the end game the way it shortens everything else. A 3x world opens its sites
on day 33, but its alliances still took 76 days (seed 2) after that, about as long as a 1x world, because shipping is per sitting, not per hour.
(Re-measurement, 2026-10-11: the table above was measured on an older tree. The same command on HEAD today, `--days 240` because 175 is no longer enough,
gives a winner on day 234.7 (134 days after opening) for seed 1 and day 200.2 (100 days) for seed 2 at speed 1, not 164 and 156. Something since the B2 runs
(B4/B5, bot changes, other work in the tree) moved the end game; it was not bisected. Every "before" in B7 and E6 below is a run of today's HEAD, not a number from the B2 table.)
### B7. Transport capacity x world speed (`rules.transportCapacity`)
| parameter | old | new | file |
|---|---|---|---|
| link capacity | `TRANSPORT.capacityPerLink` (1000) at every speed | `rules.transportCapacity(speed)` = `capacityPerLink x speed` | `public/js/rules.js` (`transportPlan`, `tradeTermsCheck`), `server/military/views.js`, `public/js/screens/trade.js`, the bots |
Why: one link makes one trip per sitting, and a sitting does not get more frequent when the world is faster, so at 3x the shipping that the node needs
(21.6 M units) took as many sittings as at 1x while everything else shortened. Cost: it applies to every transport and to the two sides of a trade
offer (each side must fit one transport); production is also x speed, so the ratio of what a POP makes per sitting to what it can carry is unchanged.
At speed 1 the factor is 1 and nothing changes, so **speed 1 cannot measure B7**: the table is speed 3 only. "Before" = HEAD today, "after" = this tree with
`--no-contest --set ENDGAME.heldDefenceMult=12` (the pre-E6 end game: striker only, held sites as heavy as before), so only the capacity differs.
`node tools/bot.js --players 50 --speed 3 --days 200 --seed S` (before, run from a `git archive HEAD` copy) and
`node tools/bot.js --players 50 --speed 3 --days 110 --seed S --no-contest --set ENDGAME.heldDefenceMult=12` (after). The sites open on day 33.3.
| speed 3 | before: winner (days after the sites opened) | after (B7 only): winner (days after) |
|---|---|---|
| seed 1 | day 131.1 (97.7 days) | day 68.7 (35.4 days) |
| seed 2 | day 109.9 (76.5 days) | day 62.8 (29.4 days) |
A 3x world now takes 29 to 35 days after opening, 2.6 to 2.8 times shorter, about a third of a 1x world's 100 to 134 days (which is what "3x" should mean),
instead of 77 to 98 days. Not measured: speed 10 with this change (the 10x numbers in section 5 are from the 500/1000 pass). Every run `INVARIANTS OK`.
### B4. Early-level build discount (the first hour and first day)
@ -388,10 +411,11 @@ net worth = everything spent on buildings, units and research plus the stock lef
`MILITARY.cacheMax 0.7 + cachePerLevel 0.14`: 4-6k, 181, -4 to -5 %; `cacheMax 0.8 + cachePerLevel 0.2`: 2-3k, 87 to 164, -8 to -11 %;
`MILITARY.raidLossFactor 0.8`: 4-6k, 142-158, -4 to -6 %; `script_crew carry 30, botnet 90`: 3k, 137-197, -7 to -12 %. Untouched:
10-11k, 188-198. None adopted: the untouched game is not dominant and bots scout better than most players will.
- **Loot is mostly wasted on arrival** (`m2-after-d30-s1`): loot is split evenly over Fiber, Hardware and Capital whatever the raider
needs, the raider's Hardware and Capital stores are usually full, and overflow at delivery is destroyed: over all deliveries of that run 77k Hardware,
14k Capital and 2k Fiber vanished against 251k looted in total. Real value of a raid is mostly its Fiber. A rule that weights
the split by free storage would double the effective loot; that is a design change, not a number.
- **Loot was partly destroyed on arrival, and the incumbent bonus mostly** (fixed by B6, section 9; this bullet used to blame raid loot for all of it). Loot is split evenly over
Fiber, Hardware and Capital whatever the raider needs, the raider's Hardware and Capital stores are usually full, and overflow at delivery was destroyed. Split by where it
happened (new line "overflow by place" in the bot report; HEAD before B6, 30 days, seeds 1 / 2 / 3): raid returns lost 31k / 62k / 56k (17 to 22 % of the 187k / 275k / 268k
looted, mostly Hardware and Capital), and the **one-time incumbent Hardware bonus lost 64.7k / 64.0k / 82.2k of the 77.5k / 77.5k / 97.5k it granted (83 to 84 %)**: the earlier
"77k Hardware lost against 251k looted" was mostly that bonus.
### Takeover is expensive enough
@ -419,11 +443,9 @@ plus 4 substations), so the market has no natural counterparties and trade is mo
other. Completed offers trade at 1.00 give/want (median). Not tuned: a thin market is an observation about this bot population, not a
number to move.
**Server finding S2 (not fixed):** the escrow of an offer that expires or is cancelled after the POP's store filled up again is
refunded only up to the Rack hall cap (`trade.refund`, decision R1). The harness books it: 36 refunds per 30-day run (all three seeds) lose
12 to 15k Hardware and Capital in total (`arch-d30-s1`: 3.3k Hardware, 11.2k Capital in 36 events), invisibly to the player.
DESIGN.md used to say nothing is lost in trade (corrected to describe the cap). Fix options: credit the clipped part back as a transport that waits, or let escrow refunds
exceed the cap the way the existing "stock above a lowered cap is kept" rule does for stock.
**Server finding S2 (fixed by B6, section 9):** the escrow of an offer that expired or was cancelled after the POP's store filled up again was
refunded only up to the Rack hall cap (`trade.refund`, decision R1), invisibly to the player: 43 to 48 refunds per 30-day run lost 26 to 28k Hardware and Capital
(seeds 1 / 2 / 3: 27.8k in 48, 26.7k in 44, 26.1k in 43 events). Now escrow keeps its room in the hall and the same runs clip 0.
### Power binds early and then recedes
@ -452,7 +474,7 @@ the capital's units offline (transient, fixed by the next substation level). Not
## 5. The end game
### What the bots do
### What the bots do (before E6; the changes are in "E6" below)
When the world is at day `ENDGAME.openDay / speed` every alliance with at least 3 members plans (a shared in-memory plan, what an
alliance would agree in its chat): the site with the lowest static defence (a little weight on distance); ONE member with an Ops lab trains
@ -467,7 +489,7 @@ against the full static defence, so attacks cannot be added up); once the allian
first attack that was strong enough; 3 of 3 landing attacks won), in the 3x world six sites were held by six alliances after 14 won attacks (sites
change hands while the defence is still low). The static defence of a site at day 100 is 27k to 45k depending on the site (600 x 5.0 x 12 x a seeded +-25 %), i.e. an army of
700 to 1 150 Script crews before research, which the striker (the member with the best economy and an Ops lab) had within days.
- **Nothing is contested afterwards, and nothing can be.** The biggest army any single POP held at the end was 55 to 62k attack before research;
- **(Before E6, HEAD: fixed by the next subsection.) Nothing is contested afterwards, and nothing can be.** The biggest army any single POP held at the end was 55 to 62k attack before research;
the defence of a built-up site was 200 to 240k at speed 1 (levels 89+), 370 to 440k at speed 3. Defence passes what one POP can send
at node level ~25 (weakest site) to ~40. That is E1 (no garrisons) showing up: after the opening days the race is shipping and node build
time, not war. The only interaction is the opening scramble (the 3x world saw 14 won attacks for 6 sites; the 1x worlds none after the
@ -483,16 +505,74 @@ against the full static defence, so attacks cannot be added up); once the allian
`INVARIANTS OK` (the first speed-1 runs of this pass were flagged only because the bots kept commanding an ended world; the harness now stops
and treats `world_ended` as expected).
### E6. Garrisons, a light static defence for held sites, a capture shield (the E1 finding)
What changed (all in `data.js` / `rules.js`, reasoning in DECISIONS E6): members of the holding alliance can station units in a site (`reinforce` to its x,y),
the units defend on top of the static value at their owner's research and draw their owner's power, a lost attack kills (A/D)^1.5 of them, a won attack
wipes them and takes the site; the static defence of a HELD site is `ENDGAME.heldDefenceMult` = 2 x incumbent (was 12; unheld sites keep 12);
a site that changed hands is shielded for `ENDGAME.captureShieldHours` = 72 world hours (this was 24 in the first runs, see below).
What the bots do now (`tools/bot/endgame.js`, `--no-contest` switches it off): the holders of a site train defenders (towards 1.1 x what the strongest
rival alliance could throw, shared by production, bots read it from the db: scouting is not simulated) and station every movable defender at the site;
the others, when the target has a garrison, train crews towards a share of 1.15 x static + 2.2 x garrison, and when a war game (`rules.resolveBattle`, wave by
wave over their members' real armies, nearest first) says the last wave takes the site, send their armies at their next sittings. A site without a garrison
is still taken by one striker with a single army that beats the static part (waves cannot wear a static number down).
Commands: `node tools/bot.js --players 50 --speed S --days D --seed N [--no-contest] [--set ENDGAME.captureShieldHours=H]`. The "before" column is HEAD today
(run from a `git archive HEAD` copy: it does not contain the other changes that are in the working tree now, e.g. the loot cap and the escrow room).
Days after the sites opened (day 100.3 at 1x, 33.3 at 3x); "flips" = won attacks on a site somebody already held; "met a garrison" = attacks on a held site
that found units there. Every run finished `INVARIANTS OK` (the ledger counts garrisons).
| world / seed | variant | winner: day (days after opening) | attacks on held sites | flips | met a garrison | units lost in landing battles (value) |
|---|---|---|---|---|---|---|
| 1x, 1 | before (HEAD) | 234.7 (134.4) | 0 | 0 | 0 | 1.05 M |
| 1x, 1 | **E6 adopted** (shield 72 h) | 202.8 (102.6) | 84 | 20 | 84 | 9.4 M |
| 1x, 1 | shield 24 h (first runs) | 202.8 (102.6) | 166 | 43 | 164 | 13.4 M |
| 1x, 2 | before (HEAD) | 200.2 (100.0) | 0 | 0 | 0 | 2.0 M |
| 1x, 2 | **E6 adopted** | 208.4 (108.1) | 194 | 33 | 186 | 13.5 M |
| 1x, 2 | shield 24 h | 220.7 (120.4) | 450 | 87 | 438 | 30.4 M |
| 3x, 1 | before (HEAD) | 131.1 (97.7) | 0 | 0 | 0 | 1.4 M |
| 3x, 1 | B7 only (`--no-contest`, held x12) | 68.7 (35.4) | 4 | 4 | 0 | 1.0 M |
| 3x, 1 | **E6 adopted** (B7 + garrisons, shield 72 h) | 65.1 (31.8) | 93 | 54 | 70 | 6.1 M |
| 3x, 1 | shield 24 h | 68.2 (34.9) | 188 | 142 | 108 | 12.7 M |
| 3x, 1 | no shield | 60.6 (27.3) | 271 | 246 | 77 | 12.6 M |
| 3x, 1 | shield 24 h, `heldDefenceMult` 3 | 68.2 (34.9) | 127 | 86 | 91 | 11.4 M |
| 3x, 2 | before (HEAD) | 109.9 (76.5) | 0 | 0 | 0 | 1.3 M |
| 3x, 2 | B7 only | 62.8 (29.4) | 4 | 4 | 0 | 1.0 M |
| 3x, 2 | **E6 adopted** | 69.8 (36.4) | 109 | 65 | 90 | 7.3 M |
| 3x, 2 | shield 24 h | 79.2 (45.8) | 266 | 174 | 193 | 14.5 M |
| 3x, 2 | no shield | 68.1 (34.7) | 241 | 231 | 52 | 8.5 M |
| 3x, 2 | shield 24 h, `heldDefenceMult` 3 | 80.9 (47.5) | 152 | 96 | 97 | 11.0 M |
(The adopted rows were re-run once with the new default in `data.js` and reproduce the `--set ENDGAME.captureShieldHours=72` runs exactly: 3x seed 1,
winner 65.1, 54 flips.)
Reading it:
- **Contests happen.** In the old world nobody attacked a held site after the opening (0 to 4 attacks, none against units). Now 84 to 194 attacks in the 100 days
after the opening at 1x and 93 to 109 in 32 to 36 days at 3x, 75 to 100 % of them against a garrison, 20 to 33 and 54 to 65 flips, 6 to 13 M of unit value dying in
landing battles (5 to 13 times before). That is a flip per site about every 25 to 35 days at 1x and about every 4 days at 3x (every 1.7 days with the 24 h shield).
- **The end game can still be won, and is not slower on average**: 1x, days after opening 102.6 / 108.1 (adopted) against 134.4 / 100.0 (before), mean 105 against 117;
3x 31.8 / 36.4 against 35.4 / 29.4 with B7 only, mean 34 against 32. With two seeds per cell that is "no worse", not a measurement of a difference.
- **How much churn is right is the owner's call, and the numbers make it concrete.** With the 24 h shield 76 % (142 of 188) and 65 % (174 of 266) of the attacks on held
sites at 3x succeeded, a site flipped every ~1.7 real days and the winner took up to 46 days; with no shield 91 to 96 % succeeded (the new holder had no garrison yet).
With 72 h 24 % and 17 % of the attacks succeed at 1x (20 of 84, 33 of 194), 58 % and 60 % at 3x (54 of 93, 65 of 109), and the flips drop to 54 / 65 at 3x. A higher static defence (x3) did not help
(`heldDefenceMult` is bounded from above by what one POP can send, DECISIONS E6). Not measured: a shield at 1x beyond 72 h, 72 h at speed 10, other seeds than 1 and 2.
- **The static rule expires with world age** (DECISIONS E6): at world age 240 a held level-100 site's static part is ~51 000, at age 330 ~68 000, above the ~60 000 a
single POP can send. The runs end (the winner appears) before that at 1x; a world that is meant to run longer needs `heldDefenceMult` or the growth to be capped.
- **Not shown by these runs**: any human reaction. The holders do not react to `backbone_incoming` (they would garrison in time or recall), the attackers never feint,
nobody scouts with `scan` (the bots read the garrison from the db), and every bot of an alliance obeys the plan. All of that is less friction than people.
## 6. Server findings
| # | finding | status |
|---|---|---|
| S1 | **Cargo above the Rack hall cap was destroyed silently on bounced shipments.** A shipment that comes home (landing site changed hands, POP gone) rides back on a `link` return leg; `events/return.js` sent no notification for link legs, so the overflow was invisible to the player and to any audit. The conservation ledger found it as 1 000 Hardware + 2 718 Capital of drift in the first speed-10 end-game run (`node tools/bot.js --players 50 --days 14 --seed 1 --speed 10 --endgame-step-min 30`; with the fix the same command shows no drift, and it reproduces the bug if the `carrying` condition in `return.js` is taken out). | **fixed** (`return.js` notifies when a link leg carries cargo), `test/bot-server-fixes.test.js` fails without the fix |
| S2 | Trade escrow refunds are clipped at the Rack hall cap and the loss is not reported (section 4). | open, design decision |
| S2 | Trade escrow refunds were clipped at the Rack hall cap and the loss was not reported (section 4). | **fixed** by B6 (escrow keeps its room in the hall; a refund that still cannot fit, after a shot-down hall, is reported), `test/economy-leaks.test.js` |
| S3 | `reports.id` is `INTEGER PRIMARY KEY` without `AUTOINCREMENT`; the 14-day cleanup can empty the table and SQLite then reuses low ids. A consumer that keeps "the last report id I saw" (the harness did, and silently missed every report after the first cleanup in a 170-day run) skips new reports. The API's own cursor (`GET /reports?after=` with `r.id < after`, newest first) is not hurt unless a client mixes old and new ids. Repro in five lines: insert three reports, `DELETE FROM reports`, insert one more: its id is 1 (the harness hit it in 170-day runs, where raids stop and every report expires). | open, low severity |
| S4 | Loot is split evenly over the three resources and destroyed on overflow (section 4). | open, design |
| S4 | Loot was split evenly over the three resources and destroyed on overflow; the incumbent bonus too (section 4). | **fixed** by B6 (loot limited to what home can bank, reported as `lootLeft`; the bonus is delivered above the cap), `test/economy-leaks.test.js` |
| S5 | `ensureSites` is lazy (E2): the first touch of a landing site writes `backbone_open`; the harness reads sites with `E.siteStates` and never triggers it. No bug, noted so nobody expects the push in a bot run. | known |
| S6 | **Room is still not reserved everywhere.** (a) Several raids from one home used to each project the same free room and the loot of all of them was banked against it (the overflow destroyed on landing); `combat.homeRoom` now subtracts the cargo of return legs that are already on the road to that POP, so the later raid is limited (and reports `lootLeft`). `test/economy-leaks.test.js` (two raids from one home with room for one) fails without it. (b) Still open, reported but not prevented: stock that production, a trade delivery or a transport adds while loot or a bounced shipment is on the road. A **bounced backbone shipment** (the site changed hands) rides home on a return leg and finds the hall full if production refilled it; the overflow is destroyed, and `movement_returned` carries the exact `cargoLost` (the client now prints it: "LOST, the Rack hall was full: ..."). Nobody reserves room for the outbound or the return leg of a shipment: that would cap production for as long as a shipment is in flight. (c) **Trade accept** now refuses with `no_room_for_goods` when the acceptor's hall will not have room for the goods at arrival (projected with production and other cargo already on the road to that POP; a projection, not a guarantee: stock can still grow on the way and then the overflow is destroyed and reported as before). | (a) **fixed**, (b) **open, reported**, (c) **fixed as a refusal**; `test/trade-flow.test.js`, `test/economy-leaks.test.js` |
## 7. Bot bugs that moved the numbers (so nobody trusts an early number from this pass)
@ -507,14 +587,15 @@ against the full static defence, so attacks cannot be added up); once the allian
## 8. What is still unknown
- Bots are not humans. They never forget to log in, never panic, never coordinate beyond a shared in-memory plan, never mis-click, and play
the same sittings every day. They do not use reinforcement, recall, the shared report folder, messages, sitters, or night play. They
the same sittings every day. They use reinforcement only to garrison landing sites (E6), and do not use recall, the shared report folder, messages, sitters, or night play. They
never choose a different capital or sell their stock off before an attack.
- No real players means no data on how many sittings a day people really play; the whole B1 argument rests on the 2-to-8 sittings-a-day
band that the CLAUDE.md pitch implies.
- Rural bonuses, wild slots and the Peering office size ladder were not examined. The offline/decommission power path never ran in a bot
run. The alliance war/peace states were exercised (NAP, confederation, war appear in the runs) but never made to matter in a fight.
- The end game was run with a single plan per alliance that nobody contests after the first days (section 5); a determined rival with
several armies cannot beat a built-up site (single-POP attack ceiling), so there is no data on what an actual fight for a site would look like.
- The end game has a contest now (E6, section 5), played by bots that follow one shared plan per alliance, read their rivals' armies and the garrison from the
db, and do not react to `backbone_incoming`. How humans would garrison, recall, feint or sit on a site is unknown; `heldDefenceMult` 2 and the 72 h shield are first
guesses with two seeds per cell, and the static defence outgrows one POP's army around world age 280.
- `--always-on` is an upper bound on attention, not a model of a person.
@ -524,3 +605,42 @@ against the full static defence, so attacks cannot be added up); once the allian
After B4 the owner's first hour on the live world was still described as "a bit slow". B4's own measurement (variant "START.resources 1000", no discount) showed
the mid game unchanged (head start 0 to 0.1 days) and a 60-minute first sitting going from 12.1 to 15.4 builds at 1 h, so `START.resources` is now 1000 per
resource. Not re-measured in combination with B4 beyond a 50 x 30-day bot run that ended INVARIANTS OK. No human data.
## 9. B6. Trade escrow keeps its room; loot is limited to what home can bank (S2 and S4)
Rules (decision B6 in DECISIONS.md has the reasoning and the rejected options):
- **Trade (S2):** goods escrowed in open offers still occupy the Rack hall: that resource stops filling at hall size minus the escrow (`rules.storageCapOf`), so cancel / expiry /
void always fit and the escrow is no extra storage (R1 stays closed). Residual clip only after a shot-down hall; it sends `trade_refund_clipped`.
- **Loot (S4):** a win takes at most what the raiders' home Rack hall can bank when they are back (hall size minus the stock projected to then); a resource with no room is skipped and the
carry goes to the others; the rest stays with the victim and the report shows it as "Left behind".
- **Incumbent bonus:** the once-only 2 500 Hardware is delivered above the cap if the store is full.
No `data.js` number changed.
**Before / after** (`node tools/bot.js --players 50 --days 30 --seed N --quiet --json out.json`, seeds 1 / 2 / 3; before = the tree at HEAD with the same reporting lines, after = this change; both
`INVARIANTS OK` in all six runs; every number from the report's "overflow by place", "trade refunds" and raid lines):
| per 30-day run | before (s1 / s2 / s3) | after (s1 / s2 / s3) |
|---|---|---|
| raid loot destroyed on arrival (Fiber+Hardware+Capital) | 31.0k / 61.5k / 56.5k | 0.1k / 1.0k / 0.7k |
| incumbent bonus destroyed on arrival | 64.7k / 64.0k / 82.2k of 77.5k / 77.5k / 97.5k | 0 (all delivered: 57.5k / 60.0k / 87.5k) |
| trade refunds clipped (events) | 27.8k (48) / 26.7k (44) / 26.1k (43) | 0 (0) / 0 (0) / 0 (0) |
| transport deliveries over the cap | 0 / 0 / 0 | 0 / 0 / 1 event (474 Fiber) |
| loot per the reports (nominal, before = what the carry split gave, after = what was banked) | 187k / 275k / 268k in 170 / 214 / 193 raids | 144k / 207k / 175k in 190 / 247 / 189 raids |
| loot left behind for lack of room (new) | - | 63k / 80k / 79k |
| won raids with empty hands (new) | - | 1 / 4 / 0 |
Side effects, mean of the three seeds: raider net worth 287.6k -> 288.3k, builder 357.7k -> 357.5k, builder median footprint 11 784 -> 11 824, Hardware lost to full stores 29 % -> 31 % of
what the rates would give (stores are as full as before, the loot just stops being destroyed). Offers completed per run 40 / 35 / 33 -> 42 / 28 / 39 (noise: the trajectories differ).
How to read it: **what changed is where the loss happens, not what players earn.** Before, the part of a raid that did not fit was thrown away at the door; now it is not taken, so it stays in the
victim's stores (the 63 to 80k "left behind"), and the raider's net worth did not move. The loot that was banked per raid went down in these runs (about 920 -> 760 in seed 1, 1 000 -> 830 in seed 2,
1 100 -> 920 in seed 3, counting before as nominal minus overflow). I did not find the cause; the raid mix changed (raids 170 -> 190 in seed 1) so it may be the bots targeting differently, or
the projection being conservative, and it did not show up in net worth. Raiding is not stronger or weaker for it on this evidence.
Also run: `--days 14 --speed 1 --seed 1` (the CLAUDE.md run), `--days 60 --seed 1`, and `--days 14 --speed 10 --endgame-step-min 30 --seed 1` (end game with shipments): all `INVARIANTS OK`
(the 60-day and speed-10 runs were not compared with a before; only the invariants were checked).
Not verified / left: the projection ignores other deliveries that reach the home store in between (hence the 0.1 to 1.0k that is still destroyed and still reported through `cargoLost`); transport
deliveries (including trade goods) onto a full store still lose the overflow, reported; a human would see the shrunk Fiber/Hardware/Capital store while an offer is open (UI says so, text only,
nobody has looked at it on a phone); how the reserved room changes what offers players post is not measured beyond the offer counts above.