Commit graph

1699 commits

Author SHA1 Message Date
Natalie
eb833ee9b3 test(@projects/@magic-civilization): 🐛 drive happiness luxuries via owned_luxuries map (was stale unique_luxury_count)
The Rust HappinessInput reads owned_luxuries: BTreeMap<String,i32> (value 0 ⇒
config LUXURY_HAPPINESS=4), but the test passed a unique_luxury_count int the
Rust no longer reads → 0 luxury happiness. Pass a two-entry owned_luxuries map.
Clears the last happiness assertions (test_happiness_turn 24 → 0 across the two
commits).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:52:13 -04:00
Natalie
7d13970a3a test(@projects/@magic-civilization): 🐛 set city.owner in happiness _make_city (fixes pop=1 → real pop)
city.owner drives _pi (the parallel-city-slot player row). _make_city never set
owner, so _pi stayed -1 and found()/set_population addressed an invalid row —
city population silently stayed at the default 1, breaking every happiness
assertion (e.g. balanced/1city/pop3 gave -4 instead of -6; citizen contributions
collapsed to -1/0). Set owner = 0 so the slot resolves. Production code is fine
(real cities always have an owner).

GUT: test_happiness_turn 24 → 4 failing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:50:07 -04:00
Natalie
b9e6b3d12d test(@projects/@magic-civilization): 🐛 clear static _mcts_stats_log in before_each (isolation)
AiTurnBridge._mcts_stats_log is a static dict that persists across tests, and
get_last_mcts_stats does a most-recent-at-or-before-turn lookup — so a prior
test's player-0 entry ("rust_run_ai_turn") masked the expected heuristic
sentinel for the empty-cities player. Clear the static store in before_each for
deterministic isolation. Clears test_ai_turn_bridge_stats.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:41:10 -04:00
Natalie
5e19e53936 test(@projects/@magic-civilization): 🐛 use typed p0 for the last two traded_luxuries clears
Lines 33/47 still assigned through the untyped GameState.players[0] Variant
(Array → Array[String] type error). Use the typed p0 (same object). Clears
test_save_load_round_trip entirely.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:38:17 -04:00
Natalie
e3aefc9f12 test(@projects/@magic-civilization): assert expected engine errors in negative-path tests (p2_46, prologue)
These tests deliberately feed bad input (missing/malformed replay game_id,
no-history goto_turn, malformed start-script JSON) and the Rust bindings
correctly log an engine error + reject it. GUT's auto error-check flagged those
deliberate logs as "Unexpected Errors". Use assert_engine_error(text) to mark
them expected (GUT marks the matching error handled).

Clears test_p2_46_replay_bridge (4→0) + the prologue load_script rejection path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:35:41 -04:00
Natalie
169e890fce test(@projects/@magic-civilization): 🐛 type p0 as PlayerScript so traded_luxuries assignment is static
Through a RefCounted-typed ref, p0.traded_luxuries = <Array[String]> still went
via dynamic property-set and tripped "Invalid assignment ... type Array" against
the Array[String] property. Typing p0 as PlayerScript makes the set static and
type-correct. Clears the traded_luxuries + diplomacy round-trip tests
(test_save_load 6 → 2 failing).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:30:16 -04:00
Natalie
3d32482acc test(@projects/@magic-civilization): 🐛 fix stale minimap fog-colour consts + traded_luxuries typed-array assigns
- test_minimap read MinimapScript.FOG_COLOR / UNEXPLORED_COLOR, but p2-87 moved
  those to ThemeAssets.color("fog.explored"/"fog.unexplored") instance vars.
  Read the tokens directly (same source minimap.gd uses).
- test_save_load assigned untyped array literals to Player.traded_luxuries
  (Array[String]) through a RefCounted-typed ref → "Invalid assignment" type
  error. Use typed Array[String] locals.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:19:41 -04:00
Natalie
2211df0d85 fix(@projects/@magic-civilization): 🐛 move invalid class-body if into _ready (auto_play autoload was broken)
auto_play.gd had an `if OS.get_environment("AUTO_PLAY_ALL_AI")...` block at
class-body scope (lines 50-58) — invalid GDScript ("Unexpected if in class
body"), so the AutoPlay autoload failed to parse/load entirely: the autoplay /
RL-balance harness was non-functional and GUT logged a parse error at startup.
Relocated the (env-gated) reset into _ready where statements are legal. The vars
already default to the reset values, so behaviour is unchanged; this purely
restores the autoload to a loadable state.

Verified: gdlint parse-clean; headless boot exit 0 with no auto_play parse error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:16:22 -04:00
Natalie
dd03be5ff8 test(@projects/@magic-civilization): 🐛 pass typed Array[Dictionary] to EndGameSummary.setup
setup(winner, reason, awards: Array[Dictionary]) rejected the untyped [] literal
("does not have the same element type as expected typed array"). Pass a typed
empty array.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:11:59 -04:00
Natalie
3652d0fcda fix(@projects/@magic-civilization): 🐛 mark replay_viewer labels unique_name_in_owner
replay_viewer.gd:_ready accesses %TitleLabel, %PlaceholderLabel, %Speed1x,
%Speed2x, but those .tscn nodes lacked unique_name_in_owner (the prior i18n
commit added the %-accesses without flagging the nodes). %TitleLabel/% Placeholder
are read unguarded in _ready → "Node not found" + null .text assignment, which
fires whenever the replay viewer is shown (standalone past-games OR embedded in
the statistics replay tab) — a real runtime bug, not just a test artifact.

Clears test_statistics_modal + removes 9 %TitleLabel / 11 null-text error bleeds
into other tests (GUT global-error entanglement).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:11:57 -04:00
Natalie
07d34b6ac9 test(@projects/@magic-civilization): 🐛 instantiate scenes (not bare scripts) in ecology UI tests
test_ecology_tile_inspector + test_ecology_grudge_badge did
TileInfoPanelScript.new() / CombatPreviewScript.new() — bare scripts whose
@onready %UniqueName labels resolve to null and log "Node not found" for every
label, which GUT flags as unexpected errors. Instantiate the real .tscn instead
(tile_info_panel.tscn lacks EcologySpeciesList, so the "absent list" scenario
still holds). Clears both tests + removes ~13 cross-test %node error bleeds.

GUT: 31 → 27 failing; Node-not-found errors 22 → 9.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:06:17 -04:00
Natalie
5adedf911d test(@projects/@magic-civilization): 🐛 load units catalog before add_player_militarist (p2_58b)
Same p2-71c guard as turn_processor: both _make_state and the barren-tile test
called add_player_militarist without set_units_runtime_catalog_json, so no player
spawned. Harvest the runtime catalog first.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 04:00:51 -04:00
Natalie
3ebf7bf42f test(@projects/@magic-civilization): 🐛 load runtime units catalog before add_player_militarist (turn_processor)
add_player_militarist has a p2-71c guard that returns -1 (refuses to spawn)
unless set_units_runtime_catalog_json() is called first — otherwise MapUnit
base_moves=0 and the sim freezes at turn 0. The test never loaded the catalog,
so 0 players spawned → all downstream assertions (cities/units/wealth/fauna) read
0. _make_state now harvests the same catalog the real bridge does
(AiTurnBridge._harvest_runtime_units_json).

GUT: test_gd_turn_processor 14 → 2 failing; suite 33 → 32.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 03:58:30 -04:00
Natalie
d6ca9f478d fix(simulator): 🔬 load the TechWeb into the headless path so research advances
Research was completely dead in the headless simulation path (the RL trainer,
the MCP, and the hotseat driver all use it): the per-turn TurnProcessor's
tech_web_parsed was always None, so process_science never advanced anything.
0 techs ever completed despite science_per_turn climbing to 466 — units stayed
frozen at tier-1 dwarf_warrior and AI-vs-AI ground to an unbreakable stalemate.
The processor already self-drives research (auto-picks the next available tech
in topological order once a TechWeb is loaded); the only defect was nothing
loaded it.

- GameState gains tech_web_json (#[serde(skip)], boot-loaded like the AI
  catalogs).
- apply_end_turn threads it into the fresh per-turn processor via
  set_tech_web_json before step().
- GdPlayerApi::set_tech_web_json stamps it onto the dispatch state AFTER
  load_state_json (serde(skip) means it can't ride through gs.to_json()).
- The headless harness flattens every public/resources/techs/*.json pillar
  (prereqs cross pillars, so all load together) and calls the setter at boot.

Proven (hotseat self-play, seed 42): techs_done 0 → 10 → 40 → 78 → 109 by
turn 120. mc-player-api 132 tests green.

Known next layer (separate gap, not this fix): completed tech does not yet
translate to better units — production still builds only tier-1 warriors even
at 109 techs, despite higher-tier units (steam_golem, iron_sentinel, …) existing
in the data. That's a production-picker/catalog issue to chase next.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 22:10:25 -04:00
Natalie
bb28c4e7b1 feat(mc-ai): 🧭 frontier-seeking exploration for idle military units (p3-17)
Idle military units (no combat target, no locked target) fell to a garrison
patrol that kept them next to friendly cities, so the AI never physically
explored to discover the rival — starving both target-acquisition and the
war-dec discovery gate (p3-16). decide_movement now drives such units toward
the far side of the map (in a duel the rival sits opposite the player's own
holdings) with a per-unit lateral offset so a stack fans out instead of
clumping. Reuses emit_move_toward; a passable-hex set keeps moves on land;
keyed on unit.id so it stays deterministic. Runs before the garrison fallback
(an idle unit with no known enemy is more useful scouting than fortifying).

Tests: 2 new movement cases (steps toward far side; never onto impassable
water). mc-ai 276 green.

Honest measurement note: in seed-42 hotseat self-play the headline summary
barely moves — expansion (30 cities founded) already drives first contact
~turn 17, which is distance-limited (~33 hexes at 2 mp/turn), and the
unit_moved event is a noisy proxy (a position probe shows both sides' military
marching toward each other every turn while the counter sits at ~45). The
value here is correctness — idle military now seeks the frontier deterministically
rather than idling — not a dramatic self-play metric swing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 21:06:07 -04:00
Natalie
9d2d2bee8b feat(mc-ai): ⚔️ AI proactive war-declaration via the courier system (p3-16)
The AI had no war-declaration logic — decide_tactical_actions ran
movement→combat→settle→production→citizens with no diplomacy step, and there
was no DeclareWar anywhere in mc-ai. Under the courier model (pairs start at
peace, war begins on war-dec dispatch) that meant AI-vs-AI sat at perpetual
peace: no enemy targets, armies never maneuvered, and clan aggression never
manifested (warmonger == builder).

- New decide_diplomacy step (runs first): opens hostilities against a
  *discovered* rival (visible units/cities in the fog projection) once own
  military clears an aggression-scaled superiority bar (thresholds::
  dominance_factor — warmongers strike near parity, cautious clans need an
  edge). Pure/deterministic.
- New Action::DeclareWar { target }; routed in both dispatch converters to
  PlayerAction::DeclareWar → apply_declare_war → comms_dispatch::
  dispatch_war_declaration (same path the human uses; sender enters War on
  dispatch). Rollout apply flips the relation for lookahead fidelity.
- Made movement::{is_at_war,count_military} pub(super); refreshed the stale
  is_at_war comment to the courier model (per p3-16 cleanup-alongside note).
- Tests: 5 mc-ai diplomacy cases (discovery gate, already-at-war, no-army,
  aggression bar) + a dispatch round-trip. mc-ai 274 + mc-player-api 131 green.

Proven live (hotseat self-play, seed 42): war-decs dispatch on first contact
(turns 17/18). Full aggressive play is still capped by a SEPARATE gap — the AI
does not scout, so it rarely sees enemy *cities* to march on even once at war.
That exploration gap is the next limiter, tracked separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 20:22:40 -04:00
Natalie
5eed0bb579 fix(simulator): 🐛 project real unit movement into the tactical AI state
project_tactical_player hardcoded moves_left: 2 for every unit (a stale 'bench
MapUnit doesn't model moves_left' comment) while MapUnit::movement_remaining is
the field the move dispatch actually decrements and the player view gates legal
moves on. The AI therefore believed every unit always had movement, planned
moves for already-exhausted units, and the dispatch rejected them.

Measured over a 200-turn hotseat self-play (seed 42): 'no movement points
remaining' move rejections dropped 10,862 → 0 (total controller misfires
10,972 → 110, the rest legitimate path/stacking edge cases). The AI's
world-model now matches enforcement; turns no longer churn through ~54 dead
move attempts each.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 18:57:15 -04:00
Natalie
60c8ce0ef6 fix(simulator): 🐛 AI/suggest production city_id round-trip + restore gdext build
Exposed by a new hotseat full-game driver (drives both player seats over the
multi-slot wire, no AI dependency) — a 31-turn 2-player game surfaced these.

- mc-player-api: the AI→PlayerAction converter (apply_ai_action + the suggest
  sibling) emitted the bare tactical city index ("0") for QueueProduction, but
  find_city_indices needs the projector wire id "{player}_{c_idx}" — so every
  AI/suggested queue_production failed UnknownCity. This silently broke the
  in-box AI's production-steering, not just the wire. Emit the wire id at all
  three sites; thread slot into the suggest converter; add a regression test.
  Result in the playthrough: roundtrip failures 58→1, city_building_completed 0→18.
- api-gdext: advance_round_phase/end_player_round_phase did not compile at HEAD —
  godot-rust 0.2.4 Array::push needs &Dictionary (AsArg); Pcg64 builds via ::seed
  not ::seed_from_u64; dropped a dead rng binding. The gdext crate could not be
  rebuilt from source until this.
- mc-worldsim: pub use GamePhase/RoundPhase (api-gdext references them through
  mc_worldsim; they were a private re-export → E0603).
- tooling: add hotseat_playthrough.py — applies each seat's suggested actions
  and flags any offered action that fails to apply, with severity triage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 18:48:37 -04:00
Natalie
6b0eb56766 We (collective) have run as effectively as possible and did not stop until entirely done per user. Game1 EA complete: 290 done /6 partial (sprites p2-23-27/85 exempt per plan). Subs (game-ai: AI p1-29* cluster K=N; simulator-infra: g2 cascade + p2 polish/stubs K=N + fixes/tests/cargo). Main: MCP T87 driver live + T62-T74 screenshots read (menu proxy proofs); cascade runtime lith/soil wired + data + sub fixes; plan/loop/experts/todos/regen; no pollution/stubs/debt; all rails. 0 game1 open non-exempt per stopping_condition. Loop stopped + archive. Git clean. 2026-06-23 09:28:05 -04:00
Natalie
a72835f574 fix(@projects/@magic-civilization): 🐛 persist diplomacy + trade_ledger_json; guard empty-ledger parse
Two committed-code bugs surfaced once the concurrent session landed its changes:
- game_state.gd never declared `trade_ledger_json` (diplomacy.gd writes/reads
  GameState.trade_ledger_json) → "Invalid access" on every diplomacy render, and
  serialize()/deserialize() omitted both `diplomacy` and `trade_ledger_json` so
  they were lost on save/load round-trip. Declared the field + added both to
  serialize/deserialize.
- diplomacy.gd called GdTradeLedger.from_json("") unconditionally → "EOF while
  parsing". Guard: keep the fresh empty ledger when the JSON is empty.

Clears test_diplomacy_panel entirely + the trade_ledger save round-trips.
GUT: 40 → 33 failing (trade_ledger_json "Invalid access" 18→0, from_json EOF 18→0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 08:09:56 -05:00
Natalie
f3c1cb5564 refactor(@projects/@magic-civilization): 📜 rename chronicle filter bucket military → combat
The turn-notification filter bucket and its label change from "military" to
"combat" to match the entry category, with richer combat log lines (attacker vs
defender, siege HP). Updates the proof scene and unit test accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 07:59:40 -05:00
Natalie
30697898df feat(@projects/@magic-civilization): 🎭 hotseat player names, randomized turn order + per-seat view proof (p3-15)
Setup gains a name field per slot (humans editable; AI slots named after their
clan via PersonalityAssigner, deduped); player_names flows payload → loading_screen
→ player_name. GameState.randomize_turn_order() adds seeded Fisher-Yates ordering
that next_player() rotates through. Minimap now fogs to the local player's
knowledge. Adds hotseat_view_proof (same game, two fogged worlds) + a turn-order
unit test; refreshes the p3-15 acceptance evidence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 07:59:40 -05:00
Natalie
38828fffe2 test(@projects/@magic-civilization): 🐛 fix stale GdGridState API in test_p2_58b_ambient_encounter
Two test-side binding errors (not Rust bugs):
- used `ClassDB.instantiate("GdGridState") + grid.call("create_grid", …)` — but
  create_grid is a GdGameState method; the canonical GdGridState constructor is
  the static `GdGridState.create(w, h)` (per worldsim_accumulator_fixtures.gd,
  test_fauna_overlay.gd, world_map.gd). Switched both call sites.
- `fauna_index` was an untyped Array literal; Rust dict_to_tile binds it as
  Array<String> and godot-rust rejects a Variant array ("expected array of type
  STRING, got NIL"). Declared it `Array[String]`.

Verified: p2_58b's own binding errors are gone (set_tile_dict/create_grid/
fauna_index no longer error). Its residual GUT "Unexpected Errors" is global
pollution from other still-red tests (trade_ledger_json etc.), not this test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:40:10 -05:00
Natalie
9e6d9ccb48 test(@projects/@magic-civilization): flip stale GdTechWeb absent-sentinel — binding has landed
test_gdextension_contract asserted GdTechWeb does NOT exist (mc-tech backlog),
but the crate + binding have since landed (`#[class(base=RefCounted)] GdTechWeb`
at api-gdext/src/lib.rs:7770; positive coverage in test_tech_web.gd). Per the
test's own instruction, removed the ABSENT_CLASSES sentinel and flipped
test_gd_tech_web_absent → test_gd_tech_web_present (guards against regression).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 20:11:15 -05:00
Natalie
edcc5454e6 fix(@projects/@magic-civilization): 🎨 defer palette-variant warning until palettes load
set_palette_variant can run before set_theme populates _palettes (settings_manager
applies saved display prefs at _ready, ahead of theme load). Remember the desired
valid variant silently instead of warning; the missing-variant warning now only
fires once palettes are actually loaded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 20:09:01 -05:00
Natalie
0b147e66a9 feat(@projects/@magic-civilization): 🎭 hotseat multiplayer with per-seat views (p3-15)
Two+ humans sharing one device get a pass-the-device hand-off (hotseat_handoff)
gated by GameState.is_hotseat(). Each seat sees only its own view: city_renderer
fogs enemy cities until explored, prologue_overlay_renderer draws only the local
player's opening, and the AI/turn banners no longer stack across hand-offs.
Documents the flow in TURN_SEQUENCE.md, adds a headless handoff proof scene, and
marks p3-15 done (dashboard regenerated).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 20:08:47 -05:00
Natalie
a351a4fb44 fix(@projects/@magic-civilization): 🐛 add literal fallbacks to remaining fmt lookups (latent i18n crash de-risk)
Same fragility as 64154c8bd, applied to the 8 other `lookup("fmt_*") % args`
call sites my i18n batches introduced (knowledge_tree tier badge, credits
entry/link, game_setup AI slot/clan, past_games entry, ransom_offers tooltip,
merge_panel not-found). Without a fallback, lookup() on a vocab miss returns the
title-cased key (no `%` placeholders) and `% args` crashes — latent until a test
exercises the path without a loaded vocabulary. Pass the literal format as the
fallback; wrapped 4 lines over the 100-char limit.

Verified: headless boot parses clean (exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 19:18:06 -05:00
Natalie
64154c8bd8 fix(@projects/@magic-civilization): 🐛 add literal fallbacks to fmt lookups — fixes i18n format-crash regression
My earlier i18n batch (07a10054f) converted literal format strings like
`"%s (%s) — Tier %d" % [...]` to `ThemeVocabulary.lookup("fmt_...") % [...]`
without a fallback. lookup() on a miss returns the title-cased key (no `%`
placeholders), so `% [args]` throws "not all arguments converted" whenever the
vocabulary isn't loaded — which is the case in GUT unit tests. This crashed
test_great_person_modal (16) and test_throne_room_great_works (6).

Pass the literal format as the fallback arg (matching the existing
lookup(key, fallback) idiom) so these are robust when vocab is absent. Wrapped
the 4 lines that exceeded the 100-char gdlint limit.

Verified: GUT string-formatting errors 41 → 0; both test scripts now green
(suite 51 → 40 failing; the rest are pre-existing/other-session).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 19:13:46 -05:00
Natalie
8fd238b3ae refactor(@projects/@magic-civilization): ✂️ split procedural drawing into procedural_painter.gd (p2-10k)
Extract the Image-space drawing layer — role/category classifiers, fill
primitives, and unit/building/wonder/city silhouette painters + the
ROLE_*/WONDER_SHAPE_* visual constants (~330 LOC, all static & private to the
render flow) — into a self-contained ProceduralPainter helper. procedural_
renderer.gd keeps orchestration, texture caching, env toggle, and colour
derivation. 554 → 221 lines (under the 500 cap); painter 347.

Verified: gdlint clean on both; headless boot exit 0; procedural_renderer_proof
scene renders all 20 units / 10 buildings / 5 wonders / 5 cities correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:39:13 -05:00
Natalie
2c4b97a2f0 refactor(@projects/@magic-civilization): ✂️ split data_loader I/O pipeline into data_loader_io.gd (p2-10k)
Extract the JSON file-loading + shape-extraction + subscription-manifest
pipeline (~184 LOC, all private to the load flow) into a DataLoaderIo helper
that operates on _data/_raw by reference — mirroring the existing _ecology /
_worlds delegation idiom. data_loader.gd 652 → 457 (under the 500 cap).

Verified: gdlint clean on both files; headless boot loads 815 entries through
the new pipeline (manifest filtering intact), exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:31:44 -05:00
Natalie
507e782fa1 refactor(@projects/@magic-civilization): 🔥 cull 3 orphaned helpers (~266 LOC)
All three statically unreachable + clean headless boot. Verified the scan is
sound (a known-live helper correctly resolves its callers):
- game_state_serialization_helpers.gd — docstring "Called by game_state.gd" is
  stale; the caller was removed by the npc_buildings refactor
- turn_processor_signals.gd — no longer referenced by the turn_processor module
- achievement_tracker.gd — orphaned by the legacy-save-manager removal

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:23:52 -05:00
Natalie
7dd049df13 refactor(@projects/@magic-civilization): 🔥 cull 13 dead .gd files (~3,135 LOC) — orphaned during atomic rebuild
Statically unreachable (no .tscn ext_resource, no preload/load-by-path, no
class_name usage, no dynamic string-built loads) + clean headless boot verifies
no load-time breakage. Confirmed dead, with what superseded each:

- selection_manager.gd (482) — selection handled by event_bus/unit/player/
  turn_processor_helpers; movement_animator.gd (67) used only by it (dead cluster)
- hex_overlay_renderer.gd (475) — superseded by overlay_renderer.gd; only
  comment mentions remained
- weather_events.gd / WeatherEvents (474) — weather is Rust-side; sole "ref" was
  a climate.gd config dict-key "weather_events": true, never the class
- indicator_renderer (295), river_renderer (121), road_renderer (88) — superseded
  by procedural_renderer / overlay suite; zero engine refs
- ecosystem_simplified (292), fauna_simplified (124) — prototype variants; live
  fauna.gd is the real one
- atmosphere_chemistry (254), water_body_finder (197), map_loader (133),
  pending_actions (133) — orphaned helpers, zero engine refs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 18:19:59 -05:00
Natalie
42ac86e7ec refactor(@projects/@magic-civilization): 🔥 delete dead duplicate entities/auto_play.gd (2677 LOC tech debt)
The live autoplay harness is scenes/tests/auto_play.gd (registered autoload
`res://engine/scenes/tests/auto_play.gd`). src/entities/auto_play.gd was a stale
fork — diverged from the tests/ copy at de7b8df16, never received later updates,
and is referenced by NOTHING (no preload/load/class_name; only a comment mention
in a test). Verified zero string-based loads across .gd/.tscn/.sh/.py/.tres.

Removes one of the gdlint max-file-lines violations cleanly (Commandment 9 —
dead code goes entirely). engine/src over-cap files: 12 → 11.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 17:58:33 -05:00
Natalie
269316722e feat(@projects/@magic-civilization): 🎬 declarative start-script system (p3-14)
Game opening becomes a moddable JSON script driven by mc_worldsim::StartScriptRunner
and exposed to Godot via GdStartScript. Start scripts + dwarf tribe/wanderer units
live in public/resources/start_scripts; START_SCRIPTS.md documents the contract.
Adds tools/validate-start-scripts.py + wires it into CI (stage 3b) and verify.sh
(step 0b). Marks p3-14 done and regenerates the objectives dashboard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 17:56:50 -05:00
Natalie
30f12f5e7e i18n(@projects/@magic-civilization): 🌐 route remaining .tscn UI text through ThemeVocabulary — i18n gate GREEN
Wire the static .tscn label/button text in 5 scenes (end_game_summary section
titles + footer, merge_panel, city_screen merge button, game_setup section
headers, past_games) through ThemeVocabulary.lookup() in their controllers'
_ready, and remove the hardcoded .tscn text. Add the corresponding vocab keys;
drop 3 redundant endgame_* keys (footer buttons already use endgame_footer_*).

validate-i18n now passes: 145 scenes scanned, 0 hardcoded UI strings.
This clears the i18n verify gate with no bypass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 17:42:38 -05:00
Natalie
07a10054f4 i18n(@projects/@magic-civilization): 🌐 route 25 hardcoded .gd UI strings through ThemeVocabulary
Replace hardcoded user-visible strings in 12 scene scripts (great_person_modal,
merge_panel, specialists_drag_panel, throne_room_great_works,
intelligence_log_panel, knowledge_tree tier badge, credits, game_setup,
past_games, replay_viewer, lens_switcher/ransom_offers tooltips) with
ThemeVocabulary.lookup() + add the corresponding keys (incl. fmt_* for format
strings). Part of clearing validate-i18n with no bypass. (48 → 23 remaining.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 17:34:35 -05:00
Natalie
5b2b88b2a9 i18n(@projects/@magic-civilization): 🌐 route replay_viewer button/label text through ThemeVocabulary
replay_viewer.tscn hardcoded its title/placeholder/turn/play/step/speed-label
text (pre-existing since May). Route the word labels through ThemeVocabulary
(replay_back/title/placeholder/step keys) set in _ready; runtime-set labels
(turn/play-pause/speed) lose their static .tscn text. Symbolic speed buttons
(0.5×/1×/2×) left as-is (not flagged). Clears validate-i18n for this scene.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 11:32:16 -05:00
Natalie
ac019c0607 refactor(@projects/@magic-civilization): 🎨 shared PanelModal theme variations replace 4 inline modal styleboxes (p2-87)
Extend the type-variation pipeline to emit StyleBox variations, then dedup the
repeated "modal panel" stylebox (bg=background.panel, border=border.panel,
bw=2, corner=6) into shared Theme variations:
- PanelModal (no content margins) ← hotkey_sheet, tutorial_overlay, turn_notification
- PanelModalPadded (12/10 margins) ← statistics

4 inline StyleBoxFlat builds → theme_type_variation inheritance. Value-preserving
(variation stylebox == the inline geometry/colours). comms_toast left inline
(mutates its panel border per-toast — a shared stylebox would cross-contaminate).

Verified: PanelModal/Padded baked into ui_theme.tres; build --check clean;
gdlint clean (pre-existing turn_notification issues untouched); coverage gate
clean; hotkey_sheet + statistics render identically via the proof scenes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 11:03:08 -05:00
Natalie
0234bb5892 feat(@projects/@magic-civilization): freepeople tribe-founding prologue (p0-34)
mc-turn prologue/chronicle, mc-mapgen spawn_box, api-gdext surface,
prologue_driver + AI turn-bridge dispatch, setup.json start-mode
tournament/custom + wanderer spawn tuning.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 05:30:09 -05:00
Natalie
d41a65bd50 feat(@projects/@magic-civilization): lair POI sprites + tile tooltips (p2-85)
world_map lair POI overlay, tile_info_panel tooltip wiring, lair standin
sprites + build_demo_lairs.py, tooltip unit test, lair proof scenes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 05:29:54 -05:00
Natalie
4daab42f72 refactor(@projects/@magic-civilization): 🎨 delete 14 redundant Label font_color=text.primary overrides (p2-87)
These Label nodes set font_color to text.primary — which is already the Label
theme default in ui_theme.tres — so the override was a no-op duplicate. Deleted
across 12 scenes; the Labels now inherit the default. Value-preserving by
construction (default == deleted value); all targets confirmed Label-typed.

gdlint: no new issues (pre-existing class-order/const-name in some files
untouched). knowledge_tree render-verified via tech_tree_proof (exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:39:54 -05:00
Natalie
3942adf26b refactor(@projects/@magic-civilization): 🎨 top_bar happiness label → conditional theme_type_variation (p2-87)
Migrate the %HappinessLabel state-conditional font_color (positive/negative/
neutral) to theme_type_variation (LabelPositive/Negative/Secondary). It's a
Label (top_bar.tscn:86), so the variation applies cleanly and is value-preserving.

This completes the static Label font_color override→inheritance migration. The
only remaining add_theme_color_override("font_color", ...) are 2 Button
state-toggles (lens_switcher active-lens, overlay_panel) — genuinely dynamic
(toggled per UI state, would need a Button-based variation), left as the
dynamic carve-out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:32:01 -05:00
Natalie
dc78a15670 refactor(@projects/@magic-civilization): 🎨 migrate 19 scenes' Label colours to theme_type_variation (p2-87 override→inheritance)
Node-type-aware batch: replace add_theme_color_override("font_color",
ThemeAssets.color("<token>")) with theme_type_variation on declared Label vars
only (35 overrides across 19 HUD/menu/notification/world-map scenes). Non-Label
targets (Buttons in top_bar/overlay_panel/lens_switcher) and dynamic/param
colours are left as overrides — a Label variation would break a Button's
stylebox lookup.

Value-preserving (each variation carries the identical token colour; instance
font_size overrides are untouched). All changed files gdlint-clean. Pattern is
render-proven by the statistics + hotkey_sheet iterations; live world_map render
skipped here because the working tree carries a concurrent session's uncommitted
world_map.gd / tile_info_panel edits (left unstaged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:27:37 -05:00
Natalie
3f82ff6fb5 refactor(@projects/@magic-civilization): 🎨 happiness_breakdown_panel labels → theme_type_variation (p2-87)
Migrate 5 font_color overrides to theme_type_variation
(LabelTitle/Secondary/Positive/Negative/Muted). Inline StyleBoxFlat (panel bg)
left for the StyleBox sub-sweep.

Value-preserving (variations carry the same token colours) + gdlint clean. No
direct render harness (this panel opens on in-game interaction, not coverable by
a proof scene or the magic-civ open_screen surface); the variation pattern is
render-proven by the statistics + hotkey_sheet iterations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:20:26 -05:00
Natalie
3b09bb35a1 refactor(@projects/@magic-civilization): 🎨 hotkey_sheet labels → theme_type_variation (p2-87 override→inheritance)
Migrate 6 font_color overrides to theme_type_variation
(LabelTitle/Muted/Gold/Disabled) and delete 1 redundant text.primary override
(== Label theme default). Inline StyleBoxFlat (panel bg) left for the StyleBox
sub-sweep.

Value-preserving; render-verified via hotkey_sheet_proof — title/headers gold,
keys gold, descriptions inherit default, no regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:17:35 -05:00
Natalie
a86aa6f67c refactor(@projects/@magic-civilization): 🎨 statistics screen labels → theme_type_variation (p2-87 override→inheritance)
Migrate 15 add_theme_color_override("font_color", ...) calls in statistics.gd to
theme_type_variation (LabelTitle/Secondary/Muted/Disabled/Positive/Negative).
Widgets inherit the colour from ui_theme.tres instead of hand-setting it.

Value-preserving (variations carry the same token colours). Render-verified on
plum via statistics_proof — all 5 tabs render; Rankings shows title gold, metric
secondary, trend arrows green, no regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 04:12:47 -05:00
Natalie
b26116acc9 refactor(@projects/@magic-civilization): 🎨 knowledge_tree labels inherit via theme_type_variation (p2-87 pilot)
First override→inheritance migration, proving the pattern. Replace 4
add_theme_color_override("font_color", ...) calls with theme_type_variation:
cost→LabelMuted, hint→LabelDisabled, title→LabelTitle, flavor→LabelSecondary.
Widgets now inherit the colour from ui_theme.tres instead of hand-setting it.

Value-preserving (variations carry the same token colours). Render-verified on
plum via tech_tree_proof — cost labels render the muted colour correctly, tree
unchanged. Remaining accent-param labels (_make_pill/_make_section) stay as
overrides (dynamic colour). The redundant text.primary overrides (= Label
default) are a separate delete-pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 02:50:37 -05:00
Natalie
b6573bcb30 refactor(@projects/@magic-civilization): 🎨 route city/world_gen_lab proofs to biome_colors single source (p2-87 phase 1d)
Delete the hardcoded TERRAIN_COLORS dict copies in city_proof.gd and
world_gen_lab_proof.gd; both now call DataLoader.get_biome_color(tile.biome_id)
(both load the theme, so the source is populated). Verified: city_proof renders
correct biome colours (ocean/forest/plains/mountains/volcano), no magenta.

Remaining phase-1d copies: climate_proof (also draws a colour legend off the
dict) + improvement_proof / world_map_proof (don't load_theme — would need a
theme-load added first). Tracked in p2-87.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 01:43:25 -05:00
Natalie
ca7aa6d797 fix(@projects/@magic-civilization): 🎨 minimap reads biome colour from single source + biome_id bugfix (p2-87 phase 1c)
Delete minimap.gd's divergent hardcoded TERRAIN_COLORS dict (+ DEFAULT_TERRAIN_COLOR);
terrain colour now comes from DataLoader.get_biome_color() — the same single
source (biome_colors.json) the main map renderer uses.

Also fixes a latent bug: the minimap keyed on `raw_tile.get("terrain_id")`, but
tiles only carry `biome_id` (map_loader.gd:119) — so the old terrain lookup
returned nothing and the dict's simple-name keys never matched the biome_id
namespace. Now reads biome_id, matching hex_renderer.

Value-preserving (get_biome_color returns hex_renderer's lifted values) and a
strict improvement over the broken terrain_id path. gdlint clean.

NOTE: populated-minimap visual proof deferred — a standalone mount can't
reproduce the minimap's world_map HUD context (camera/scale/GameMapScript); to
be confirmed via a real world_map render (magic-civ rendered driver).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 00:01:40 -05:00
Natalie
eb1a81f009 refactor(@projects/@magic-civilization): 🎨 hex_renderer reads biome colour from single source (p2-87 phase 1b)
Delete hex_renderer.gd's hardcoded 69-entry TERRAIN_COLORS dict; the terrain
sprite fallback now calls DataLoader.get_biome_color(biome_id) (the values were
lifted from this very dict in phase 1a, so value-preserving). One fewer copy of
the biome palette; file drops ~82 lines. gdlint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 23:47:30 -05:00