Repository navigation
Refuse a save whose settler target is off the map - #27
dmccoystephenson wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the settler target validation change.
No open issues 🎉
What changed in this PR
This PR addresses #23 by rejecting saves with off-map settler targets before the simulation can use them for unchecked grid access.
Changes:
- Validate settler
txandtyduring loading, using the existingsettler state out of rangeerror. - Add regression checks for oversized and negative values in both target coordinates.
- Leave the save schema and simulation rules unchanged.
| File | Description |
|---|---|
tests/test_saves.cpp |
Adds rejection checks for invalid settler target coordinates. |
src/bridge/bridge.cpp |
Extends load-time range validation to settler targets. |
Review effort: Balanced
|
Self-review rubric for head
Two observations came out of the review:
Merge was withheld. A do-not-auto-merge path is not involved. The reason is the Tests-fix FAIL above: the gate calls for a human hand-off when no named rung can be reached, and a run-level merge pre-authorization does not satisfy it. The change is otherwise ready. This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
ec078ea to
38ef6f4
Compare
|
Follow-up review for rebased head Rebase. The branch was behind CI on the new head. All jobs are green (run). Both game jobs ran 8 of 8 tests, including Tests-fix, re-scored PASS. The earlier review scored this item FAIL because no named fallback rung had been used. The CI evidence was re-examined here. The test-only commit (now Behavioural claim re-checked. Unchanged items. Scope, Docs, Privacy, Save integrity (no The PR is being marked ready and merged under this dispatch's merge pre-authorization. This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
|
Correction to the previous comment: the PR was not merged. The step that takes it out of draft ( This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Extends the lossless section of test_saves with worlds whose colony:tx or colony:ty column holds 9999 or -1. fromWorld does not check those fields yet, so this commit is expected to fail the Strata test step. It is pushed alone so CI records the failure before the fix lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fromWorld checked a settler's x, y and task but not its tx, ty, which systems::tasks indexes the grid with unchecked when the task is Gather. Such a save loaded and then ran with undefined behaviour on its first tick. It is now refused with the existing out-of-range error. No valid save is affected: tx and ty start at 0 and are only set from findResource, which returns in-bounds cells. The test now clears why first, so the error text it compares comes from this refusal and not from the earlier x check. Closes #23 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38ef6f4 to
b48f9bd
Compare
|
Follow-up review for rebased head Rebase. The branch was behind CI on the new head. All jobs are green (run): rules on gcc-13, clang-18, asan-ubsan and msvc; game on Strata on Linux and Windows; the browser build. The Linux game job's log shows Rubric re-check on the rebased diff:
Not merged. The PR is still a draft. Taking it out of draft ( This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
bridge::fromWorldis made to refuse a save whose settler target cell (colony:tx,colony:ty) is off the map, with the existingsettler state out of rangeerror.systems::tasksindexes the grid from those two fields with no bounds check whentask == Gather(src/colony/systems.cpp:168-169), so such a save was accepted and then ran with undefined behaviour on its first tick. The save is now refused at load, with the live colony and the slot left untouched.src/bridge/bridge.cpp:tx,tyare added to the "Range checks the rules rely on" block.tests/test_saves.cpp: the lossless section gains worlds with 9999 and -1 in each ofcolony:txandcolony:ty.The check applies to every settler, not only to those in
Gather, because a target is only ever set from an in-bounds cell.Settlers::addstarts both fields at 0, and the only writes aresystems.cpp:152-153, whose values come fromfindResource, which skips anything out of bounds. No valid save is affected, andtest_save_fixturespasses against the released fixtures.The save format is unchanged: no
schema.hname, nokSchemaVersionbump, and nostrata.refchange. The rules are untouched, so the pinned fingerprint does not move.Closes #23
Skipped issues
--force-mods): deferred.app/main.cpphas no unit test, so a test needs the choice moved behindSession, and that API change was not attempted without a local compiler.ci.ymlorCMakeLists.txt, both of which are do-not-auto-merge paths.Regression evidence
The branch was deliberately pushed in two commits so that CI ran each state. No commit on it reverts the fix.
savesresult95265a9!bridge::fromWorld(bad, back, &why), 7 of 8 tests passing (run)ec078eaOne limit applies:
why.clear()and therefore a meaningfulwhy == "settler state out of range"assertion were added inec078ea, after the red run showed that assertion was reading a stale message. That single assertion has only been observed passing. The fourfromWorldassertions have been observed both failing and passing.Test plan
CIwas red on the test-only commit, naming the new checks intest_savesCIis green on the PR head (rules on gcc-13, clang-18, asan-ubsan and msvc; game on Strata on Linux and Windows)Browser buildis green on the PR headtest_save_fixturespasses in both game jobs (8 of 8 tests executed in each, read from the job logs)The local anchor is UNVERIFIED:
cmakeand the compilers were not permitted in this dispatch, and no local OpenUSD exists, so CI on the exact head SHA is the anchor.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson