Skip to content

fix(startup): surface load-failure notices at the cold menu (issue #520) - #541

Merged
joryirving merged 1 commit into
mainfrom
courier/misospace/windowstead/issue-520
Nov 21, 2026
Merged

joryirving merged 1 commit into
mainfrom
courier/misospace/windowstead/issue-520

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Collaborator

Closes #520

What changed

_load_failed() in scripts/main.gd now uses the same three steps the #516 no-colony save notice uses: seed state["events"] = [] when the state has none, push the notice, then redraw the event drawer. At a true cold start the state is {}, and ColonySim.push_event (scripts/colony_sim.gd:190) drops messages when there is no events key — so clicking Load Game at the startup menu with no (or an incompatible) save previously gave no feedback at all. The drawer redraw runs in both branches; mid-game (game_active) the existing render_sidebar() call is unchanged, and the drawer's event_rev cache makes the extra call a no-op when nothing changed.

tests/test_save_failure_surfaced.gd gains Flow 10: real scene, cold state = {}, both startup-menu load-failure messages, asserting the notice lands in state.events, the drawer label shows it, the seeded state still fails has_persistable_colony(), and no save write happens (save hook intercepts every write).

Invariants this change must keep, and every other path enforcing each

  • A bare or seeded startup state is never written to disk. Writers: persist() (the only GameState.save_game call site) gates on has_persistable_colony(), which requires a resources Dictionary; every forced write (exit_game, the WM_CLOSE flush, _flush_save_on_unload, the tick path) goes through persist(). Kept: this PR does not touch the gate; the seeded state has no resources, and Flow 10 asserts has_persistable_colony() stays false and the save-hook write count stays 0 (same reasoning as Flow 8).
  • The cold-start notice pattern (seed → push → redraw). Other enforcer: save_game()'s no-colony skip (fix(save): never persist an unstarted colony so startup exits keep the save (issue #513) #516, scripts/main.gd:985-988). Kept: unchanged; this PR mirrors it rather than refactoring it.
  • Colony render paths must not read the seeded bare state (Unify cold-startup gates on has_persistable_colony() once #516 lands #529). Enforcers: toggle_menu, open_build_popup, render_all, render_tile, _on_dock_side_selected gate on has_persistable_colony(), and _on_tick short-circuits on not game_active. Kept: the seed keeps the state non-persistable, so every gate still rejects it; Flow 8 pins the _on_tick proxy.
  • The drawer redraw is idempotent. Enforcer: render_event_drawer() returns early while _drawer_event_rev == sim.event_rev; push_event bumps event_rev. Kept: the unconditional call is a no-op unless this push changed the rev; no other renderer is affected.
  • Restore-revert notices still surface through _load_failed. Enforcers: load_saved_game's gate rejections and _revert_failed_restore are its only callers. Kept: unchanged call sites; both notices now seed-and-redraw through the fixed function.

Local validation (receipts)

  • mise exec -- just --justfile .justfile validate (cwd /workspace, head a2afdf5, pinned .tools/Godot_v4.7.1-stable_linux.x86_64 verified against godot-toolchain.json sha256): exit 0, 40/40 suites ok, no SCRIPT ERROR, no Parse Error.
  • Targeted: tests/test_save_failure_surfaced.gd → 57 passed, 0 failed (includes the 6 new Flow 10 assertions).
  • Independent review of the final diff: GO, no blocking findings.

CI on this branch is not yet observed (expected green per the identical local matrix).

Follow-up found during review

The restore-confirmation rejection notices (scripts/main.gd:432, scripts/main.gd:436) drop at the cold menu through the same mechanism. Filed as #540; out of scope here.

_load_failed() pushed its message into a state that, at a true cold
start, has no events array, so sim.push_event dropped it and the
drawer never redrew: clicking Load Game with no (or an incompatible)
save gave no feedback. Seed the events array, push, and redraw the
drawer -- the same three steps the #516 no-colony save notice uses.
The seeded bare state still fails has_persistable_colony(), so it can
never reach disk. Flow 10 in tests/test_save_failure_surfaced.gd pins
the notice landing in state.events and on the drawer label from a cold
{} state, with zero writes.

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

{"schema":"review-handoff/v1","review_id":"2dce14f35984e309","head_sha":"a2afdf5cd50caef969af5343ee59c4602e65f7da","verdict":"approve","review_result":"findings","required_checks":"none","items":[{"id":"f3b730d10cec3e2446ad2b2484bf12d12b9600a3e1e2bc2228274328316cc075","severity":"minor","category":"style","path":"scripts/main.gd","line":1005,"message":"The seed → push → redraw notice sequence is now duplicated in `save_game()` and `_load_failed()`; the issue suggested extracting a shared helper next to them."},{"id":"2adf5a4e142d033ca882971712862d8086df2c72e86b14a836f51f82b644bc0b","severity":"info","category":"verification","path":"tests/test_save_failure_surfaced.gd","line":474,"message":"The `_save_call_count == 0` assertion is only meaningful if the hooked `root.get_node(\"GameState\")` is the instance `main.gd` persists through; it mirrors Flow 6/8 and passes either way."}],"items_total":2,"items_truncated":false,"unresolved_requirement_ids":[],"unresolved_requirement_ids_total":0,"unresolved_requirement_ids_truncated":false,"unresolved_requirement_ids_source_total":0,"unresolved_required_checks":[],"unresolved_required_checks_total":0,"unresolved_required_checks_truncated":false,"unresolved_required_checks_source_total":0,"unresolved_review_obligations":[],"unresolved_review_obligations_total":0,"unresolved_review_obligations_truncated":false,"derived_obligation_state":null}

AI Automated Review

✅ Automated recommendation: APPROVE

Full PR review.

Analysis engine: MiniMax-M3.1-Flash (anthropic) — primary route · pr-reviewer-action v3.10.0

Findings (1 minor, 1 info)

Severity Location Finding
Minor scripts/main.gd:1005 The seed → push → redraw notice sequence is now duplicated in `save_game()` and `_load_failed()`; the issue suggested extracting a shared helper next to them.
Info tests/test_save_failure_surfaced.gd:474 The `_save_call_count == 0` assertion is only meaningful if the hooked `root.get_node("GameState")` is the instance `main.gd` persists through; it mirrors Flow 6/8 and passes either way.

Recommendation

Approve — the fix is the minimal seed → push → redraw mirror of PR 516, and the new Flow 10 exercises it against the real scene.

Findings

No blocker or major issues. Two minor/info items are in the findings array.

Requirement Coverage

  • req-82dc1b4c58b2 (colony render paths must not read the seeded bare state, PR 529): satisfied. toggle_menu (main.gd:939), open_build_popup (960), render_all (1542), render_tile (1636) and _on_dock_side_selected (1111) all gate on has_persistable_colony(), which requires a resources Dictionary; the seed adds only events, so every gate still rejects it, and _on_tick still short-circuits on not game_active (1405).

Claims

Held: 5/5 items. Claim 1 (Flow 10 asserts notice in state.events, drawer label text, has_persistable_colony() false, zero writes) is present in the diff. Claim 2: persist() (main.gd:2214/2234) is the only GameState.save_game call site and gates on has_persistable_colony(); exit_game, the WM_CLOSE flush, _flush_save_on_unload and the tick path all route through it. Claim 3: verified the five gates above. Claim 4: Flow 8 pins the _on_tick proxy on the seeded state. Claim 5: grep shows _load_failed's only callers are load_saved_game's two gate rejections and _revert_failed_restore; all now seed and redraw, which is a benign extension of the restore-revert notices.

Linked Issue Fit

Issue PR 520 asks to make _load_failed() show its message at the cold startup menu by seeding the events array and redrawing the event drawer, and names scripts/main.gd plus a regression assertion in tests/test_save_failure_surfaced.gd (cold state = {}, call _load_failed(...), assert the notice lands in state.events). All three are met, with both startup-menu message strings pinned. The restore-confirmation notices left out of scope are already tracked as PR 540.

Tool Harness Findings

40 read-only calls over 22 rounds (budget exhausted). Verified colony_sim.gd:190 drops push_event without an events key (the root cause), render_event_drawer()'s event_rev gate, has_persistable_colony(), the cold render gates, and the main.tscn drawer nodes. All CI checks on a2afdf5 are green, including the script test suite, which corroborates the local-validation claim in the PR body.

Unknowns or Needs Verification

One item could not be settled with the reads available: whether Flow 10's hooked root.get_node("GameState") is the same instance main.gd's persist() writes through, which decides whether the zero-write assertion is meaningful. It mirrors Flow 6/8 exactly, so it passes either way and does not affect the verdict.

Comment thread scripts/main.gd Resolved
Comment thread tests/test_save_failure_surfaced.gd Resolved
@joryirving
joryirving merged commit 289de75 into main Nov 21, 2026
14 checks passed
@joryirving
joryirving deleted the courier/misospace/windowstead/issue-520 branch November 21, 2026 18:47
@its-miso its-miso Bot mentioned this pull request Nov 21, 2026
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.

Load-game failure at the cold startup menu gives no feedback: the notice is silently dropped

2 participants