Fix #329: Validate reserved_resources, milestone, and build-id fields in save schema - #336
Conversation
…#329) The previous validate_save_schema() left reserved_resources, next_build_id, current_milestone_id, completed_milestone_ids, and migration_log unchecked. A hand-edited or corrupt save whose reserved_resources was a String instead of a Dictionary passed validation and load, then crashed ColonySim.get_reserved() on the first sim tick with 'Invalid call. Nonexistent function get in base String'. This also let _validate_and_apply_save()'s rebuild_reservations_from_workers(..., trust_existing=true) keep a corrupt non-empty reserved_resources verbatim instead of rebuilding it from worker assignments. Extend validate_save_schema() to reject: - non-Dictionary reserved_resources and any non-numeric / negative reservation value - non-numeric / negative next_build_id - non-String current_milestone_id - non-Array completed_milestone_ids and any non-String entry - non-Array migration_log Add five independent regression tests in tests/test_runner.gd, one per field, so that later edits to either the combined fixture or the validator cannot silently drop coverage for any single field. Also add a round-trip test that confirms load_game() now returns {} for a save carrying reserved_resources="oops-not-a-dictionary" instead of letting the corrupt value reach runtime. Fixes #329 Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
003e6a1 to
2dc3c47
Compare
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: dsv4f@https://litellm.jory.dev/v1 (openai) — primary route
Recommendation
Approve. The PR directly implements issue PR 329's ask and acceptance criteria, adds regression coverage for every requested field, and all CI checks are green. No must_check items were specified by the PR classifier.
Change-by-change findings
scripts/game_state.gd: Adds presence-guarded validation invalidate_save_schema()forreserved_resources,next_build_id,current_milestone_id,completed_milestone_ids, andmigration_log. Each check rejects the malformed shapes called out in issue PR 329 (non-Dictionary reservations, non-numeric/negative reservation values, non-String milestone id, non-Array milestone list/migration log, non-numeric/negativenext_build_id). Optional-field semantics are preserved, and descriptive failure reasons are returned. I found no correctness, compatibility, or security issues.tests/test_runner.gd: Adds five focused regression tests and wires them intorun_tests(). Thereserved_resourcestest also covers the end-to-end corrupt-save path (save_game→load_game()returns empty), satisfying the issue's regression requirement. All addedassert_eq/assert_true/assert_emptycalls include the requirednameargument, so the repository's PR 321 parse-error trap does not apply.
Sources
- PR PR 336: upstream misospace/windowstead PR 336
- Linked issue PR 329: upstream misospace/windowstead issue 329
- CI status for 2dc3c47: all checks success (export validation macOS/Linux/Web/Windows, script test suite, headless smoke test, macOS validation)
Standards Compliance
AGENTS.mdtesting trap: all added assertions pass the required-name check forassert_eq; the suite ran under CI headless with no reported parse errors.- Repository conventions: no manifest changes, no release-process impact; the change is scoped to save-schema validation and test coverage exactly as the linked issue expects.
- No deviation from documented conventions found.
Linked Issue Fit
Issue PR 329's acceptance criteria are fully met:
- Rejects non-Dictionary
reserved_resources, non-numeric reservation values, and negative reservation values. - Rejects non-numeric and negative
next_build_id. - Rejects non-String
current_milestone_id. - Rejects non-Array
completed_milestone_idsandmigration_log, plus non-String/empty entries in the milestone id list. - Corrupt-save regression test asserts
load_game()returns{}for the malformedreserved_resourcesfixture. - Existing test suites stay green per CI.
- Expected files named in the issue (
scripts/game_state.gd,tests/test_runner.gd) are exactly the files changed.
Tool Harness Findings
Tool harness planning was still pending at review time, so no harness-produced findings were available for this review.
Unknowns or Needs Verification
No blocking unknowns. The review did not locally re-run the headless suite, but the CI Script test suite and all validation jobs are green on the PR head commit. If tool-harness planning completes later, its output can be checked against this review; nothing in the current corpus indicates a gap.
What
Added validation for
reserved_resources,next_build_id,current_milestone_id,completed_milestone_ids, andmigration_logfields in the save schema to prevent corrupt saves from loading. …Fixes #329
Opened by foreman on review GO (workload wl-misospace-windowstead-329).