Skip to content

Fix #329: Validate reserved_resources, milestone, and build-id fields in save schema - #336

Merged
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-329/issue-329
Aug 12, 2026
Merged

Fix #329: Validate reserved_resources, milestone, and build-id fields in save schema#336
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-329/issue-329

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

What

Added validation for reserved_resources, next_build_id, current_milestone_id, completed_milestone_ids, and migration_log fields in the save schema to prevent corrupt saves from loading. …

Fixes #329

Opened by foreman on review GO (workload wl-misospace-windowstead-329).

@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner August 12, 2026 15:17
its-saffron[bot]

This comment was marked as outdated.

…#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>
@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-329/issue-329 branch from 003e6a1 to 2dc3c47 Compare August 12, 2026 20:18

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in validate_save_schema() for reserved_resources, next_build_id, current_milestone_id, completed_milestone_ids, and migration_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/negative next_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 into run_tests(). The reserved_resources test also covers the end-to-end corrupt-save path (save_gameload_game() returns empty), satisfying the issue's regression requirement. All added assert_eq/assert_true/assert_empty calls include the required name argument, 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.md testing trap: all added assertions pass the required-name check for assert_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_ids and migration_log, plus non-String/empty entries in the milestone id list.
  • Corrupt-save regression test asserts load_game() returns {} for the malformed reserved_resources fixture.
  • 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.

@joryirving
joryirving merged commit 8035fe6 into main Aug 12, 2026
8 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-329/issue-329 branch August 12, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] Save schema validation omits reserved_resources and milestone fields — corrupt saves error at runtime

2 participants