Repository navigation
Refuse a save whose id counters lag its ids or whose stockpile overflows 32 bits - #37
dmccoystephenson wants to merge 2 commits into
Conversation
These cases fail against the current fromWorld: a save whose nextSettler/nextBuilding counter is at or behind its ids (or negative) loads, and a stockpile 2^32 off the map wraps back onto it. Pushed ahead of the fix so CI records the failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fromWorld now refuses a save whose nextSettler/nextBuilding counter is
negative or not greater than the last id in its table ("id counter
behind ids"), which would otherwise load and then throw at the first
birth or hut. The stockpile position is checked with fits() before its
32-bit cast, so a value 2^32 off the map no longer wraps back onto it.
The save format is unchanged.
Closes #29
Closes #31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Self-review rubric (head
The local build was not run: the session sandbox blocks This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
|
This PR meets the merge bar for this loop: every CI job is green on This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
Two more range checks are added to
bridge::fromWorld, in the "Range checks the rules rely on" block. Both refuse a save that hashes correctly but holds an impossible value. The live colony and the slot are left untouched, and the save format does not change.id counter behind idswhencolony:nextSettlerorcolony:nextBuildingis negative, or is not greater than the last id in its table. Before this change such a save loaded, and the first birth (systems::growth) or hut (systems::build,planHut) then threw an uncaughtstd::logic_errorfromSettlers::add/Buildings::add. The negative-counter condition covers an empty table, where "greater than the last id" says nothing. This follows the corrected expectation in the issue's comment. No check is added for strictly increasing ids, because Strata'shydratealready sorts rows by id and refuses duplicates.colony:stockX/colony:stockYare checked withfitsbefore the 32-bit cast. A value such as 2^32 + 5 therefore no longer wraps back onto the map, and it is refused with the existingstockpile out of boundserror.Saves written by the game satisfy both conditions: every id comes from the counters, and
generate()places the stockpile in bounds.test_save_fixtureschecks this against the released fixtures in CI.Regression evidence
The tests were pushed in a commit of their own (
af02172) before the fix. Thegame on StrataCI run on that commit is expected to fail on exactly the newCHECKs, and the fix commit is expected to turn it green. Both runs are linked from the self-review comment.Test plan
rules (gcc-13),rules (clang-18),rules (asan-ubsan),rules (msvc)green (no rules code changes)game on Strata (saves soak, headless smoke)red on the tests-only commit, naming the new checksgame on Stratagreen on the fix commit:test_saves(lossless section with the new cases, 1,000-tick soak) andtest_save_fixturesCHECKremoved or weakened;schema.h,strata.refand the pinned fingerprint are untouchedThe local build could not be run: the sandbox for this session blocks
cmake. CI on the PR head SHA is the only verification, and all changes are UNVERIFIED-locally.Closes #29
Closes #31
Deferred this cycle: #24 (F9 reload and
--force-mods, inapp/main.cpp), #25 (CLI exit codes, across three tools) and #30 (NaN prefab stats, inreadStats). Each touches different code from this load-validation batch and is left for a later cycle. Draft PR #35 (Strata pin bump) is waiting for the owner and was not touched.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson