Skip to content

Remove orphan assertion referencing out-of-scope variables#266

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

Remove orphan assertion referencing out-of-scope variables#266
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-237/issue-237

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Integrates MilestoneManager into main.gd's tick loop, save/load, and bootstrap (Option A).

Fixes #237

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

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

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai dismissed its-saffron[bot]’s stale review July 8, 2026 11:28

The merge-base changed after approval.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 595294d to d1467a6 Compare July 8, 2026 11:28
its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot dismissed their stale review July 8, 2026 14:32

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot dismissed their stale review July 8, 2026 16:28

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 0e03728 to 2f712b0 Compare July 8, 2026 17:17
@its-saffron its-saffron Bot dismissed their stale review July 8, 2026 17:23

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot dismissed their stale review July 8, 2026 21:42

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 9, 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: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

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

Reason: Failing check: Headless smoke test (failure)

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

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

@its-saffron its-saffron Bot dismissed their stale review July 9, 2026 19:07

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 6d62c59 to 43f27b2 Compare July 9, 2026 22:49
@its-saffron its-saffron Bot dismissed their stale review July 9, 2026 22:55

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 43f27b2 to 50dd9ea Compare July 10, 2026 02:03
its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 50dd9ea to 0a589c9 Compare July 10, 2026 05:03
its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 0a589c9 to 321a296 Compare July 10, 2026 05:33
its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 321a296 to 701a54b Compare July 10, 2026 08:08
its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot dismissed their stale review July 10, 2026 08:53

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 8579960 to 39aca08 Compare July 10, 2026 09:48
@its-saffron its-saffron Bot dismissed their stale review July 10, 2026 09:52

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

Wire scripts/milestone_manager.gd into scripts/main.gd (Option A from
the issue). The previous integration attempt was removed in a revert;
re-apply it with the same correctness standards, and add explicit type
annotations to milestone_manager.gd so the GDScript "inferred from
Variant" warnings stop being treated as errors by the headless smoke
test (CI failure root cause).

Changes in scripts/main.gd:
- Preload MilestoneManager alongside GoalReward at the class scope.
- Add current_milestone_id (String) and completed_milestone_ids (Array)
  state variables so milestone progress is tracked between ticks and
  across save/load.
- bootstrap_state() seeds both fields from MilestoneManager.make_goal_state()
  on a fresh colony, so the player starts on the first catalog entry.
- load_or_boot() restores the two fields from the save dict, falling
  back to make_goal_state() defaults for legacy saves that predate
  milestone tracking.
- _on_tick() evaluates the active milestone once per tick (at function
  scope, not inside the reward loop — the previous attempt's bad
  indentation is fixed), pushes a "Milestone reached: …" event on
  completion, and advances to the next milestone via
  MilestoneManager.advance_to_next().
- persist() writes both fields into the save dict (using .duplicate()
  for the array, matching the pattern used for completed_goal_ids and
  active_rewards).

Changes in scripts/milestone_manager.gd:
- Add explicit type annotations to every `:=` declaration in
  evaluate_milestone(), is_milestone_complete(), and advance_to_next()
  whose right-hand side comes from a Dictionary.get() Variant (mtype,
  target, build_kind, builds, resource, amount, harvested, current,
  count, workers, active, eval, current_index, next_index). This
  silences the "variable type is being inferred from a Variant value"
  parse warnings, which the project's CI runs as errors and which
  were the root cause of the headless smoke test failure.

Acceptance criteria for Option A (all met):
- MilestoneManager preloaded and initialized in main.gd
- Milestones evaluated each tick
- Completion fires a push_event with the milestone description
- Milestone state persists in save data
- tests/test_milestone_goals.gd continues to pass: existing tests
  already cover the make_goal_state / get_current_milestone /
  is_milestone_complete / advance_to_next / milestone_description
  surface and a full JSON round-trip via the same field names
  (milestone_id, completed_ids) that main.gd now persists.

Fixes #237

Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
@itsmiso-ai itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-237/issue-237 branch from 39aca08 to 7422627 Compare July 10, 2026 10:41
@its-saffron its-saffron Bot dismissed their stale review July 10, 2026 10:47

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@joryirving joryirving added ai-review Request an AI pull request review. and removed needs-human Human input or decision is required. labels Jul 10, 2026
@its-saffron its-saffron Bot dismissed their stale review July 10, 2026 13:43

Superseded by a newer automated review for this pull request.

@its-saffron its-saffron Bot removed the ai-review Request an AI pull request review. label Jul 10, 2026

@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 (incremental)

Incremental review: reviewed the changes since the last managed review; unresolved findings from that review are carried forward.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)

PR Review: Wire MilestoneManager into main.gd (Fixes PR 237)

Recommendation: Approve

This PR correctly implements Option A from issue PR 237: wiring MilestoneManager into main.gd rather than removing it as dead code. All CI checks pass, the implementation follows existing repository patterns, and there are no blockers.


Change-by-Change Analysis

scripts/main.gd

  1. Preload addition (line 18): Added MilestoneManager preload alongside the existing GoalProgression and RotatingGoal preloads. This follows the established pattern for game logic modules.

  2. State variables (lines 103-104): Introduced current_milestone_id: String and completed_milestone_ids: Array to track milestone progression, paralleling how active_goal and completed_goal_ids track goal progression.

  3. bootstrap_state() initialization (lines 769-772): Seeds milestone state using MilestoneManager.make_goal_state() when starting a new colony. This is correct — new games get the first milestone in the catalog.

  4. load_saved_game() restoration (lines 924-927): Restores milestone state with safe defaults for legacy saves that lack milestone keys. Uses state.get() with fallback to MilestoneManager.make_goal_state() defaults. This handles backward compatibility correctly.

  5. _on_tick() evaluation (lines 1412-1418): Added milestone completion check after reward processing. When complete:

    • Pushes "Milestone reached" event to the event log
    • Adds completed milestone ID to tracking array
    • Advances to next milestone via advance_to_next()
      This follows the same flow as goal rewards.
  6. persist() save (lines 2461-2462): Saves both current_milestone_id and completed_milestone_ids to the save state.

scripts/milestone_manager.gd

The diff shows only type annotation changes (from := inference to explicit typed declarations). These are style-only changes that improve code clarity and IDE support with no runtime behavior change.


Standards Compliance

Requirement Status
Save/version migration handled (migration-first principle) ✅ Correctly handled — bootstrap_state() seeds defaults; load_saved_game() falls back gracefully for legacy saves
Follows existing code patterns ✅ Uses the same initialization/load/persist/evaluate pattern as GoalProgression
No blocking patterns or regressions ✅ All CI checks pass

Linked Issue Fit

Issue PR 237 asked to either wire MilestoneManager into main.gd or remove as dead code. This PR implements the wiring option (Option A) by integrating milestone state into:

  • Bootstrap: New colonies get the initial milestone
  • Save/Load: Milestone progress is persisted and restored with legacy save compatibility
  • Tick loop: Milestones are evaluated each tick and advance when complete

The event log integration ("Milestone reached: %s") provides player feedback consistent with the existing reward notification pattern.


Evidence Provider Findings

No evidence providers were configured for this review.


Tool Harness Findings

All planned verification calls completed successfully. Key evidence confirmed:

  • milestone_manager.gd exists at the expected path with the expected class_name MilestoneManager
  • test_milestone_goals.gd exists and tests milestone functionality
  • Issue PR 237 is open and correctly labeled as enhancement/tech-debt

CI Results

All CI checks passed for commit 7422627:

  • ✅ macOS validation
  • ✅ Script test suite
  • ✅ Export validation (Linux, Windows, macOS)
  • ✅ Headless smoke test

Unknowns / Needs Verification

None. The implementation is complete and verifiable:

  • Logic follows existing repository patterns
  • Save/load handling is correct with backward compatibility
  • Tests exist for milestone functionality
  • CI validates the change comprehensively

Findings

No issues identified.

@joryirving joryirving merged commit 67abbff into main Jul 10, 2026
8 checks passed
@joryirving joryirving deleted the foreman/wl-misospace-windowstead-237/issue-237 branch July 10, 2026 14:16
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.

Wire MilestoneManager into main.gd or remove as dead code

2 participants