Skip to content

simplify: remove verified no-op machinery - #571

Open
itsmiso-ai wants to merge 1 commit into
mainfrom
simplify/noop-machinery-cleanup
Open

itsmiso-ai wants to merge 1 commit into
mainfrom
simplify/noop-machinery-cleanup

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Collaborator

Motivation

Behavior-preserving simplify pass. Read of the whole scripts/ tree (all 16 modules) plus the shared test harness surfaced three pieces of machinery whose observable behavior is nil, verified by exhaustive repo grep before touching anything.

Changes

  1. main.gd: drop dead tick / active_goal property setters — zero assignments to either property anywhere in the repo (scripts, tests, scenes); every writer goes through state["tick"] / state["active_goal"] directly. The read-only properties keep their unchanged getters, so the facade API for readers is untouched.

  2. main.gd: _is_valid_event_entry uses ColonySim.is_numeric instead of _is_event_tick_numeric, a local duplicate of the exact same typeof == TYPE_INT or TYPE_FLOAT predicate. This follows the pattern game_state.gd already documents for its _is_numeric ("the single implementation lives in ColonySim so the schema gate and the sim cannot disagree") — the event renderer now shares that one definition too.

  3. rotating_goal.gd: remove the dedup pass in rotate_after_completion — it built an order-preserving deduplicated copy of completed_ids, but the only consumer (select_next_active_goal) reads array membership via has(), so order and duplicates cannot change the selection. The replacement appends the completed goal's id (on a duplicate(), preserving the original's no-mutation-of-caller contract) and passes the array through. The existing test that passes duplicate ids (["gather_wood", "gather_wood"]) confirms membership semantics.

Validation

  • Full headless matrix, same command as just validate / test-all (Godot 4.7.1-stable, sha256-verified against godot-toolchain.json): all 40 suites pass, 0 failures, no SCRIPT ERRORs (~2,100 assertions).
  • Final-diff self-review: each hunk re-checked for accidental behavior changes; none found (net −10 lines, no formatting churn, no renames).

…predicate, no-op dedup)

- main.gd: drop the never-assigned 'tick' and 'active_goal' property
  setters; both properties are read-only in practice (zero assignments
  repo-wide), callers write state['tick']/state['active_goal'] directly.
- main.gd: _is_valid_event_entry now uses ColonySim.is_numeric instead
  of a local duplicate of the same typeof predicate, matching the
  single-implementation pattern game_state.gd documents for _is_numeric.
- rotating_goal.gd: rotate_after_completion built a deduplicated copy of
  completed_ids before selection, but select_next_active_goal only reads
  membership (Array.has), so order and duplicates cannot change the
  result. Append the completed goal id and pass the array through;
  duplicate() preserves the original's no-mutation-of-caller contract.

@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":"a396a23d16327597","head_sha":"fb8dfffde7dc27ebc0a03079208bb7e5835649ce","verdict":"approve","review_result":"findings","required_checks":"none","items":[{"id":"3504301e17ba7ae6b080cef60591fbdf50d763c4cd3f536d1cc6adfe024ca285","severity":"info","category":"style","path":"scripts/rotating_goal.gd","line":132,"message":"The four-line comment explaining the removed dedup pass could be trimmed to one line per the AGENTS.md source-comment convention (the non-obvious why fits in a single line)."},{"id":"2c3891065d1a5d26341a7e73a810c61cca7733aad3622142359640015c434ce4","severity":"info","category":"docs","path":"scripts/main.gd","line":2213,"message":"The new two-line comment restates the existing doc block above `_is_valid_event_entry`; folding the single-definition rationale into that block would avoid duplicated prose."}],"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.11.2

Findings (2 info)

Severity Location Finding
Info scripts/rotating_goal.gd:132 The four-line comment explaining the removed dedup pass could be trimmed to one line per the AGENTS.md source-comment convention (the non-obvious why fits in a single line).
Info scripts/main.gd:2213 The new two-line comment restates the existing doc block above `_is_valid_event_entry`; folding the single-definition rationale into that block would avoid duplicated prose.

Recommendation: approve — behavior-preserving cleanup; all three changes verified against current-head sources.

Findings by change

  1. scripts/main.gd — dropping the tick/active_goal setters: repo-wide grep finds no assignment to main.tick or main.active_goal in scripts/, tests/, or scenes/main.tscn (the only tick writers are state["tick"] in colony_sim.gd and test-local sim.state.tick = … dictionary writes, which bypass the facade property). Remaining uses of main.tick/main.active_goal in scripts/main.gd (L1618, L1813, L2056, L2253) and tests/test_save_failure_surfaced.gd:371 are reads and keep the unchanged getters. GDScript accepts getter-only properties, so no warning-as-error risk.

  2. scripts/main.gd — _is_valid_event_entry now calls ColonySim.is_numeric, which ColonySim already exposes (scripts/colony_sim.gd:199) with the identical TYPE_INT or TYPE_FLOAT predicate; ColonySim is already preloaded in main.gd, and the removed _is_event_tick_numeric had no other callers. The schema gate (game_state.gd:328) delegates to the same function, so renderer and validator now share one definition as claimed.

  3. scripts/rotating_goal.gd — the dedup pass only fed select_next_active_goal, which reads membership via has() (rotating_goal.gd:51), so order/duplicates cannot affect selection. The new duplicate() + append still leaves the caller's array untouched (the caller goal_progression.check_and_rotate appends its own id afterward), so the no-mutation contract holds. The duplicate-id case is still covered by tests/test_rotating_goal.gd:233.

Tool Harness Findings

40 read-only calls were used to verify the claims: full reads of scripts/main.gd, scripts/rotating_goal.gd, scripts/goal_progression.gd, scripts/colony_sim.gd, and tests/test_rotating_goal.gd, plus targeted greps for every setter/dedup/numeric-predicate call site in scripts/, tests/, scenes/, and docs/. The tool budget was exhausted before the final API probes, but the last three calls (PR metadata, check-runs, workflow runs) completed and confirm head fb8dfff with the full CI matrix green (headless smoke test, script suites on Linux/macOS/Windows, export validations).

No linked issue, so there is no acceptance-criteria ledger to reconcile; the gameplay skill's save/migration and validation invariants are unaffected by these hunks.

Comment thread scripts/rotating_goal.gd
seen[cid] = true

# Always include the just-completed goal's ID to prevent immediate repeat
# Select next non-completed goal from catalog. Only membership matters —

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.

Info (style): The four-line comment explaining the removed dedup pass could be trimmed to one line per the AGENTS.md source-comment convention (the non-obvious why fits in a single line).

Automated finding from AI PR review.

Comment thread scripts/main.gd
## 'tick' and a 'text' key (matching what colony_sim.gd push_event writes and
## what validate_save_schema now enforces at load). Used by the renderers to
## skip malformed entries rather than crash on int(entry.tick).
## Numeric is ColonySim.is_numeric — the same single definition the schema

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.

Info (docs): The new two-line comment restates the existing doc block above _is_valid_event_entry; folding the single-definition rationale into that block would avoid duplicated prose.

Automated finding from AI PR review.

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.

1 participant