Skip to content

Persist and re-sync reserved_resources on save/load - #241

Merged
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-231/issue-231
Jul 9, 2026
Merged

Persist and re-sync reserved_resources on save/load#241
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-231/issue-231

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Adds rebuild_reservations() to restore reserved_resources from active worker tasks on load, fixing double-booking after save/load.

Fixes #231

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

@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner July 8, 2026 00:05
its-saffron[bot]

This comment was marked as outdated.

its-saffron[bot]

This comment was marked as outdated.

@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 06:58

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai added the needs-human Human input or decision is required. label Jul 8, 2026
@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: macOS validation (failure)

Latest note: foreman fix exhausted 3/3 attempts (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-08T15:30:02.848Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-08T16:30:09.009Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-08T17:30:06.632Z

@its-saffron
its-saffron Bot dismissed their stale review July 8, 2026 20:53

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T08:30:02.433Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T09:30:02.508Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T10:30:02.552Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T11:30:02.516Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T12:30:03.053Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T13:30:02.586Z

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

Reason: Failing check: Script test suite (failure)

Latest note: foreman fix exhausted 3/3 attempts on ESCALATED (all coder tiers exhausted) (prfix-misospace-windowstead-241)

Posted automatically by Dispatch on 2026-07-09T14:30:02.519Z

@its-saffron
its-saffron Bot dismissed their stale review July 9, 2026 18:54

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

Add rebuild_reservations_from_workers() to game_state.gd that
rebuilds reserved_resources from active gather/haul worker tasks
when the field is missing or empty (old saves). Called after
migration in both localStorage and file-based load paths.

Add rebuild_reservations() to main.gd that clears and rebuilds
reserved_resources from current worker tasks. Called in both
load_or_boot() and load_saved_game() after break_ticks init.

Add save_game/load_game path parameter for test flexibility.
Fix file handle leak in save_game by calling file.close().

Add tests:
- test_reserved_resources_save_load: verifies saved reservations persist
- test_reserved_resources_resync_on_load: verifies empty reservations are rebuilt from workers

Fixes #231

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-231/issue-231 branch from 6be3214 to 07c99f1 Compare July 9, 2026 22:47
@its-saffron
its-saffron Bot dismissed their stale review July 9, 2026 23:04

Superseded by a newer automated review for this pull request.

@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: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)

Review: Persist and re-sync reserved_resources on save/load (PR 241)

Recommendation: Approve

This PR correctly implements the fix for issue PR 231, adding save/load persistence for reserved_resources with a re-sync mechanism to prevent double-booking after reload. All CI checks pass including macOS validation.


Change-by-Change Findings

scripts/game_state.gd

  • Added optional path parameter to save_game() and load_game() — enables testability and is a safe backward-compatible addition.
  • Added file.close() after save — correct resource management.
  • Added rebuild_reservations_from_workers() — scans workers' active tasks (gather/haul) to rebuild reserved_resources when missing or empty. Guarded with if not existing.is_empty() so it only runs on old saves or saves with missing reservation data.
  • Called rebuild_reservations_from_workers() in both localStorage and file-based load paths, after parsing/migration. This directly satisfies issue PR 231's acceptance criteria.

scripts/main.gd

  • Added rebuild_reservations() — mirrors the game_state logic but operates on main's state reference. Called in both load_or_boot() and load_saved_game() after state loading completes.
  • Observation: rebuild_reservations() is called in main.gd after load_game() has already called rebuild_reservations_from_workers(). This means reservations are rebuilt twice per load. The logic is idempotent so no correctness issue, but it is redundant work. Not a blocker given the consistent behavior.

tests/test_reservations.gd

  • test_reserved_resources_save_load: Verifies saved reserved_resources ({"wood": 2, "stone": 1}) survive a save/load cycle. Directly covers acceptance criterion PR 1.
  • test_reserved_resources_resync_on_load: Saves state with reserved_resources: {} and two workers (one gatherer, one hauler), then verifies reservations are correctly rebuilt (wood=1, stone=1). Directly covers acceptance criterion PR 2.

Standards Compliance

  • Save/version migration: Per AGENTS.md, "migration-first" is required because the game auto-loads on startup. The PR respects this by calling the rebuild logic after migrate_save() completes, not replacing migration. ✓
  • No regressions: The rebuild is gated on if existing.is_empty(), so existing valid saves with populated reservations are trusted as-is. ✓
  • Repository conventions: GDScript style is consistent with the codebase. No sidebar UI or other UX regressions introduced. ✓

Linked Issue Fit (PR 231)

Criterion Status
reserved_resources survives save/load cycle ✓ Verified by test_reserved_resources_save_load
On load, reservations are re-synced from active worker tasks ✓ Verified by test_reserved_resources_resync_on_load
Test added to tests/test_reservations.gd covering save/load ✓ Two tests added
No double-booking after reload ✓ Rebuild logic clears then reconstructs; idempotent guard prevents overwrites

Evidence Provider Findings

No evidence providers configured.


Tool Harness Findings

No tool calls were issued; reviewing from corpus directly.


CI Check Results

Check Result
Headless smoke test
Export validation (Windows)
Export validation (Linux)
Script test suite
macOS validation
Export validation (macOS)

All checks pass. The macOS validation is particularly important per this repository's conventions.


Unknowns / Needs Verification

  • Code duplication: rebuild_reservations() exists in both game_state.gd (line 66) and main.gd (line 2503) with identical logic. This appears intentional given the layered autoload architecture (game_state for persistence, main for runtime state), but worth confirming this is the preferred pattern rather than having one call the other. No functional issue detected.

Summary

The PR is correct, well-tested, and meets all acceptance criteria from issue PR 231. No blockers. Approve for merge.

@joryirving
joryirving merged commit fee733d into main Jul 9, 2026
7 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-231/issue-231 branch July 9, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human Human input or decision is required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist reserved_resources in save data

2 participants