Commit graph

3806 commits

Author SHA1 Message Date
Natalie
e477784731 docs(@projects/@magic-civilization): 🐺 p3-30 — decision core done; integration is a verified fork
stub → partial. Acceptance #1 (decide_wild_actions) + #4 (determinism) ✓ with
cited evidence (95a2e580b, mc-ai 301/0). Record the verified premise that the
headless GameState has no roaming wild-unit substrate (units implicit-owned,
wilds = lairs + encounters), making the in-step path a substrate-build that
duplicates encounters vs. the allowed GdWildAiController bridge. Recommend the
bridge; integration + .gd deletion stay render/decision-gated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:53:39 -04:00
Natalie
95a2e580bc feat(@projects/@magic-civilization): 🐺 p3-30 — Rust wild-creature decision AI core
Port wild_creature_ai.gd's decision logic to a pure, deterministic Rust
module (mc-ai::wild). decide_wild_actions(ctx, rng) -> Vec<Action> mirrors
process_wild_turn → _act: chase+attack a player unit in detection range,
drive home when leashed out, drift toward the nearest city, else roam a
leashed neighbour. One action per creature (the player-tactical convention:
attack iff adjacent, else move). Reuses mc_core hex helpers + XorShift64 +
the existing Action taxonomy; combat resolution stays in mc_combat::wilds.

Fork-neutral: WildContext is a flat projection, identical whether the
integration drives it inside mc_turn::step or via a GdWildAiController bridge
(p3-30 leaves that drive-site to infra). 12 unit tests: target-select,
chase, attack-iff-adjacent, leash return, leashed roam, city drift, passable
gating, no-movement skip, determinism, wilds.json config parse. mc-ai lib
301/0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:50:44 -04:00
Natalie
cbc68a68c1 docs(@projects/@magic-civilization): 🔎 p3-26 Gap-2 — era max_tier cap is non-parity; fired-event surfacing is observability-only
Verified file:line: the live GDScript events modules have NO era-based max_tier
cap (0 hits) — headless flat max_tier=10 is correct parity; an era cap would
invent a rule the game lacks (gold-plating, dropped). And natural events already
fire + apply terrain effects headless; only the fired list surfacing to
TurnResult is missing (processor.rs:1117 `let _fired =`), an observability nicety
not a system gap. Confirms the headless natural-events system is functionally
complete; narrows Gap-2's real remainder.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:29:41 -04:00
Natalie
ac5efa4bec docs(@projects/@magic-civilization): 🌊 p3-26/27 — close marine gap (Rust-authoritative); drop ocean-collapse as gold-plating
Verified file:line that the marine→climate feed is already complete headless:
process_climate_phase → ClimatePhysics::process_step → compute_global_stats
writes grid.ocean_dead_fraction (reef-based, physics.rs:800) and step_evaporation
consumes it (physics.rs:460), every turn. Gap-1's "marine_harvest remaining"
is CLOSED.

Correction: mc_ecology:🌊:tick_ocean_state (4-phase trophic cascade) is
wired in NEITHER the live GDExt bridge NOR the live GDScript — the live game
runs a simple fish-stock ocean_dead_fraction (marine_harvest.gd), not the
cascade. Wiring tick_ocean_state headless would build a system the live game
doesn't run (parity ≠ gap). Marked OUT/gold-plating with citations so a future
session doesn't port it. The Rust reef-based formula vs the live fish-stock
formula is a divergence; Rail-1 → Rust drives, no reconciliation owed.

Also recorded D1 ruling (distinct ItemProduced) in p3-29.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:27:29 -04:00
Natalie
a0ace92c23 docs(@projects/@magic-civilization): p3-29 — T2/T3 done; correct T5 scope + T6 keystone status
§A event emission now DONE except ItemProduced (T4, blocked on D1):
- T2 UnitHealed (158ef4d1b), T3 GoldenAgeStarted/Ended (a87ea9f4d).
Corrected T5: the buffer pattern alone is insufficient — EcologyEngine::
process_step returns only flora transitions; fauna births/deaths + biome
changes are unreported by the headless engine (live signals come from
fauna.gd). T5 needs a new mc-ecology report surface + an owner ruling on
creature-event granularity. Also marked T6 keystone DONE (was pre-landing).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:20:13 -04:00
Natalie
a87ea9f4d4 feat(@projects/@magic-civilization): 🌅 p3-29 T3 — Rust turn emits GoldenAgeStarted/Ended
The live GDScript turn emitted `golden_age_started`/`golden_age_ended` inline;
the headless happiness phase flipped `golden_age_active` silently. Detect the
false→true / true→false edge in `process_happiness_phase`, buffer it into a new
transient `GameState.pending_golden_age_events` (registry-has-no-event-sink
pattern), and drain it in `step()` into `GoldenAgeStarted`/`GoldenAgeEnded`.
Both edges emitted since the live UI consumes both signals (event_bus.gd). No
wire surface — dispatch drops them; live UI reads the kind-tagged event_to_dict.

Verified headless: mc-replay 20/0 (golden_age_events_serde), mc-turn 291/0
(golden_age_start_edge_buffers_started_event +
golden_age_end_edge_buffers_ended_event + event_collector_wiring).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:18:26 -04:00
Natalie
158ef4d1bd feat(@projects/@magic-civilization): 🩹 p3-29 T2 — Rust turn emits UnitHealed
The live GDScript turn emitted `unit_healed` inline; the headless healing
phase recovered HP silently. The healing phase runs in the end-of-turn
`fn(&mut GameState)` registry (no event sink), so follow the FloraSuccession
buffer pattern: stash `(player, unit_id, applied_amount, col, row)` into a new
transient `GameState.pending_heal_events`, drain it in `step()` into
`TurnEvent::UnitHealed`. The buffered amount is the CLAMPED delta actually
applied (not the nominal heal rate). No wire surface — dispatch drops it; the
live UI consumes it via the kind-tagged `event_to_dict` dict.

Verified headless: mc-replay 19/0 (unit_healed_serde), mc-turn 289/0
(healing_buffers_unit_heal_event_with_applied_amount +
healing_buffers_clamped_amount_near_full_hp + event_collector_wiring).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:12:07 -04:00
Natalie
236a5058e5 feat(@projects/@magic-civilization): 📣 orchestration transparency — announce specialist start/finish
Adds a narration convention so the user SEES the orchestration (and can verify parallelism at a
glance): whoever orchestrates emits a "▶ Dispatching [parallel|sequential] (N): agent(task)…" start
line and a "✓/✗ agent — outcome · proof" finish line per specialist. "parallel" must match behavior
(one message, multiple Agent calls). Milestone/decision/blocker also go out-of-band via TTS(ravdess02)
/ PushNotification; per-dispatch stays text-only (TTS every spawn = noise). Wired into the playbook
(agents-task-map.md), the team-lead agent, and the finish-game-1 skill's reporting section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 06:09:18 -04:00
Natalie
7681def5b5 docs(@projects/@magic-civilization): p3-29 — T1 CultureResearched done; correct §B keystone (already landed)
T1 (CultureResearched event) landed in 74844f74d. Also corrected the §B
keystone status: the generic events[] in turn_result_to_dict was marked
"NOT STARTED" but actually landed with step 2 (a9b92df51, lib.rs:6573) —
verified file:line. Code wins over the drifted note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:05:22 -04:00
Natalie
74844f74d3 feat(@projects/@magic-civilization): 🎭 p3-29 T1 — Rust turn emits CultureResearched
The live GDScript turn emitted `culture_researched` inline; the headless
Rust turn dropped tradition completions. Emit a `TurnEvent::CultureResearched`
at the completion site in `process_culture_research` (single-source per Rail-1),
translate it to the existing `wire::Event::CultureResearched` in dispatch (not
dropped), and surface it as a kind-tagged dict in `event_to_dict` so the live
turn_manager will receive it at the Rail-1 swap. Threaded the events sink into
the phase + both call sites.

Verified headless: mc-replay 18/0 (culture_researched_serde), mc-turn 287/0
(event_collector_wiring), mc-player-api 138/0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 06:03:47 -04:00
Natalie
6e3d9b2fd2 feat(@projects/@magic-civilization): 🔎 session bootloader leaves a verifiable trace
The hook left no trace, so 'did the bootloader fire this session?' was unverifiable. Now every fire
(a) stamps the orientation header with 'bootloader fired <UTC>' (visible in-context) and (b) appends
a line to .local/last-session-orient (gitignored breadcrumb) — so verification is one command:
cat .local/last-session-orient. Answers the 'how do I know it bootloaded?' question deterministically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 06:00:28 -04:00
Natalie
f1fda3c18a feat(@projects/@magic-civilization): 🎮 add /finish-game-1 skill — autonomous Game-1 completion driver
Replaces the ad-hoc "/loop finish game 1" with a durable skill that captures both the mission and the
method. Encodes: the 3-part definition of done (scope complete + headless sim complete + Rail-1
getState unification), the per-iteration loop (orient → load rails → pick → classify → implement →
verify-by-type → commit → continue), the stop-and-ask conditions (balance/scope/architecture/render-
host = owner's call), and the guardrails this session paid for (verify premises, Rust drives, eliminate
don't fix the orchestrator, no stubs, don't gold-plate). Chains the tooling built this session
(session-orient → specialist-preamble → code-layering → orchestration).

First project skill; creates tooling/claude/dot-claude/skills/. Available next session (skills load at
session start).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 05:41:57 -04:00
Natalie
54d7f8f630 docs(@projects/@magic-civilization): 🧭 tooling — encode getState/never-reconcile + verify-premises lessons
Final agent-tooling pass folding in this session's hardest-won lessons (previously only in my memory):

code-layering.md:
- anti-pattern #4 "fixing the orchestrator instead of eliminating it" (the swap→extract→FFI drift;
  the fix is usually DELETE the GDScript path, let Rust compute + UI render getState()).
- anti-pattern #5 "UI holding state / calling logic instead of reading getState()".
- principles rewritten: (1) Rust drives everything — divergence is a bug to DELETE, never reconcile;
  (2) the UI is a pure view of getState() (render/act/end_turn, GdPlayerApi is the reference);
  (3) single-source LOGIC not necessarily STATE — but never two state copies in ONE running game.

specialist-preamble.md (always-loaded core):
- verify rule gains "verify architectural PREMISES before committing to a plan" (the 3-turn drift,
  collapsed by one grep of view.rs).
- layering rule gains the Rust-drives / UI-is-a-view-of-getState one-liner.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 05:38:43 -04:00
Natalie
b93328cd11 docs(@projects/@magic-civilization): p3-29 — correct false claim: getState() is ALREADY a rich projection
Self-correction (the prior commit's "view_json carries almost nothing renderable" was wrong — an
over-grep that only caught the yields line). Verified PlayerView (view.rs:318): CityView carries
position/owner/population/production_queue/owned_tiles(territory)/hp/focus; UnitView carries
position/hp/movement/xp/fortified/sentry; TileView carries position/biome/improvement/river/
explored+visible(fog)/owner_city; plus resources/research/culture/civics/diplomacy/score.

So the projection foundation largely EXISTS — the gap to "UI calls getState()" is the GDScript side
(renderer reads CityScript/Player entities, not PlayerView). Recast target updated: the bulk is the
GDScript rewire to consume view_json + switch the turn to end_turn(); the only genuine projection
additions are render-only extras (animation deltas/UnitMoved, VFX, player colors, minimap).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 05:33:58 -04:00
Natalie
84790caf74 docs(@projects/@magic-civilization): 🎯 p3-29 corrected (v2) — UI is a pure view of getState(); folds into p3-25
Owner: "shouldn't the UI just call getState()?" — re-asserting the p3-25 directive. Both prior
framings were wrong: v1 (swap orchestrators) and v1.5 (extract each formula into an FFI the GDScript
turn calls) BOTH keep GDScript calling logic / holding state. Correct architecture (already proven by
the headless GdPlayerApi): Rust owns ALL state + runs the whole turn (end_turn); view_json = getState
is the complete render projection; UI renders it + sends act(). The dual GameState is THE bug, not a
constraint. The 4 inlined modifiers vanish when turn_processor.gd::_process_* is deleted — no
per-formula FFI extraction. Folds into p3-25 (complete the projection). First step: projection-gap
audit (what the renderer reads from entities vs what view_json carries — today: almost nothing).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 05:31:48 -04:00
Natalie
6b1d92b2af docs(@projects/@magic-civilization): 🔍 p3-29 recast — audit live turn; swap→logic-extraction (drop B7)
Owner reconsidered the swap. Audit (verified file:line) shows the live turn_processor.gd already
delegates the TICK to Rust in every phase but inlines 4 MODIFIER formulas with hardcoded constants —
_process_growth (CONFIRMED divergence from mc_happiness::get_growth_modifier), _process_production
(0.75/1.2), _process_culture (1.2), _catchup_research_mult (1.5×). Recast from a big-bang state swap
to incremental logic extraction: each phase keeps its state + FFI tick; only the inlined formula
moves to its owning crate. No state migration; former B7 city-model convergence DROPPED (dual state
is legitimate — single-source is LOGIC not STATE). Worklist added; swap steps 3-5 marked superseded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 05:21:37 -04:00
Natalie
8628ea7d88 feat(@projects/@magic-civilization): 🧭 add SessionStart bootloader — live project orientation for fresh sessions
No project bootloader existed: a new session/agent booted with only the static CLAUDE.md router and
had to manually dig for current state. Adds a SessionStart hook (session-orient.sh) that injects a
LIVE orientation every session — the dynamic counterpart to the static router:

- In-flight objectives (partial/stub from objectives.json) — where to resume
- Blocked count + last 5 commits + unpushed-commit warning (94 right now; forge down)
- Verify-before-trusting reminder + tooling entry-points (preamble / orchestration / code-layering)

State is read live every run (objectives.json + git) — never embedded, so it can't go stale
(the same anti-drift principle the agent tooling enforces). Read-only, <2s, never breaks the
session (any error → exits 0). Dual-mode: hook JSON by default, `--human` prints markdown for
manual mid-session re-orientation (`bash .claude/hooks/session-orient.sh --human`).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 04:57:33 -04:00
Natalie
97c153f71f docs(@projects/@magic-civilization): 🧑‍🔧 restructure specialist agents — shared DRY core + per-agent delta + orchestration playbook
Specialist agents had ZERO shared instruction layer — each inlined its own knowledge, none
referenced the rails/layering/verification rules, so the same mistakes recurred. Restructured
into a DRY shape grounded in the bugs this session surfaced:

NEW specialist-preamble.md — the shared core every specialist loads first. Six commandments,
each earned by a real violation: (1) verify-don't-infer incl. docs/memory drift (the rust-source
false claims), (2) code-layering (formula vs orchestration vs presentation vs content vs type),
(3) prove-it by output type (cargo test / headless loop / golden-repin / render-proof), (4) stay
in scope (Game 1, no gold-plating disabled systems), (5) objective state = pointer+protocol not
embedded, (6) safety/workflow (build-output, atomic commits, worktree-fork→file-extraction).

agents-task-map.md rewritten as the orchestration PLAYBOOK (not just a lookup): dispatch-vs-inline,
parallel-by-default, the mandatory verify gate per output type, the worktree-fork integration rule,
"specialists return data not prose". Fixed the phantom mc-magic row (Game 2/3, no crate).

All 13 agents converted to thin shared-core pointer + domain delta (fault line + domain docs +
how-to-verify), each fault line drawn from a real drift risk for that specialist. Router + README +
CLAUDE.md agents section updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 04:42:23 -04:00
Natalie
947183f3ce docs(@projects/@magic-civilization): 📊 regen objectives dashboard after p3-26/27/29 status changes
Auto-regen of objectives.json + DASHBOARD_* reflecting this session's status edits (p3-26 B-series,
p3-27 biosphere, p3-29 steps 1-2). Bookkeeping only; split out of the agent-tooling commit to keep
both atomic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 04:29:43 -04:00
Natalie
40dbe84415 docs(@projects/@magic-civilization): 🧭 agent tooling — add code-layering decision guide + fix rust-source-of-truth drift
Better-guide-agents pass, grounded in this session's architecture review (GDScript turn-logic
divergence, rules leaked into mc-core). Two-pronged:

NEW `code-layering.md` — the decision PROCEDURE that was missing (the Rails state the rule; agents
still drifted because there was no "where does this code go?" procedure). Classifies every change as
formula/orchestration/presentation/content/shared-type, gives each one home, mandates grep-before-
reimplement, uses biomes as the template, records the real anti-patterns hit. Wired into the
always-loaded router + README index.

FIX `rust-source-of-truth.md` drift (it was actively misleading agents):
- "AI exception (one of one)" CONTRADICTED Rail-1 → recast as tech-debt; GdAiController DOES exist
  (api-gdext/src/ai.rs:333), dispatch via mc_player_api::controllers.
- crate table listed phantom `mc-magic` + claimed BiomeRegistry in mc-core (false) → accurate
  pure-logic-vs-orchestrator table; mc-core = shared TYPES, no rules.

game-systems + godot-engine agents point at code-layering at the fault lines they own.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 04:29:29 -04:00
Natalie
e307db755d docs(@projects/@magic-civilization): 📡 p3-29 steps 1-2 done — Rust turn emits + surfaces UI events; swap is render-gated
Step 1 (CityGrew/CityBordersExpanded/FloraSuccession) + step 2 (events in step result dict)
complete + headless-safe. Latent siege-suppress bug fixed (7f4b69eac). Remaining: the live
turn_manager swap (steps 3-5) — render-gated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 03:58:32 -04:00
Natalie
a9b92df51b feat(@projects/@magic-civilization): 📡 p3-29 (step 2) — surface turn events in GdTurnProcessor.step result dict
turn_result_to_dict now includes an "events" array (each TurnEvent mapped via the reused
replay::event_to_dict, now pub(crate)) — CityGrew, CityBordersExpanded, FloraSuccession,
CityBuildingCompleted, UnitCreated, CityCaptured, etc. So when turn_manager adopts
GdTurnProcessor.step (the Rail-1 swap), it can translate result["events"] → EventBus signals
and the GDScript turn orchestration can be deleted. gdext compiles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 03:58:01 -04:00
Natalie
7f4b69eac1 fix(@projects/@magic-civilization): 🛡️ p3-26 B2 — siege-suppress city healing (besieged cities don't heal)
Regression fix: the B2 healing phase ran end-of-turn BEFORE siege and healed cities
unconditionally — so a besieged city healed (e.g. 30→50 hp) before the same turn's siege
resolved, defeating captures (last_survivor_via_capture got empty events: a 30-hp city +
3 attackers @15 = 45 dmg no longer captured after healing to 50). Bisected to this session
(passed at e926345ad; the healing phase introduced the bug).

Fix: process_healing_phase now snapshots all units' tiles and SKIPS healing any city with an
enemy unit on its tile (under siege) — real-time siege-suppress matching the live game's intent
(its `last_attacked_turn` window). Un-besieged cities still heal. Tests:
besieged_city_does_not_heal (new) + last_survivor_via_capture (restored) + healing 11/0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 03:44:34 -04:00
Natalie
91095be232 docs(@projects/@magic-civilization): p3-29 step 1 complete — Rust turn surfaces CityGrew + CityBordersExpanded + FloraSuccession
All three granular UI events the GDScript turn emitted inline are now emitted by the Rust turn
(replay value now; UI-parity ready for the swap). Remaining: step 2 (dict surface) + steps 3-5
(turn_manager → GdTurnProcessor.step + delete GDScript orchestration + render proof).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 03:28:54 -04:00
Natalie
8e17594564 feat(@projects/@magic-civilization): 🌿 p3-29 (3) — surface FloraSuccession; step-1 event enrichment complete
Third + final p3-29 step-1 event. The ecology phase (uniform fn(&mut GameState) registry
signature, no event sink) buffers its flora-succession transitions into a transient
GameState.pending_flora_events; step() drains them into the TurnResult as
TurnEvent::FloraSuccession — single-source replacement for the GDScript turn's flora_succession
signal, avoiding a 40-call-site registry-signature cascade. Surfaced through all four TurnEvent
consumers + tested (step_drains_flora_buffer_into_flora_succession_events).

p3-29 step 1 DONE: the Rust turn now emits CityGrew + CityBordersExpanded + FloraSuccession —
the granular UI events the live game's GDScript turn emitted inline. Replay value now;
UI-parity ready for the swap (steps 3-5). Events-only → golden/combat unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 03:26:11 -04:00
Natalie
dc3fc0926d docs(@projects/@magic-civilization): 🌱 p3-29 step-1 — CityGrew + CityBordersExpanded done; FloraSuccession bundled with the swap pass
The 2 high-value growth/border events are surfaced from the Rust turn (replay value now,
UI-parity at the swap). FloraSuccession deferred: the ecology phase's registry signature
(fn(&mut GameState)) has no event sink, and the registry-events refactor belongs with the
swap (steps 3-5), so flora rides with it rather than triggering a 40-call-site cascade now.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:47:07 -04:00
Natalie
841f741ed5 feat(@projects/@magic-civilization): 🗺️ p3-29 (2) — surface CityBordersExpanded as a turn event
Second p3-29 step-1 event: the Rust turn emits border expansion (process_culture now takes
&mut events, collects claimed tiles + flushes TurnEvent::CityBordersExpanded with clan/city/hex)
— single-source replacement for the GDScript turn's inline `city_border_expanded` signal.
Surfaced through all four TurnEvent consumers + tested (culture_expansion_claims_frontier_tiles
now asserts the event). Events-only → no state change → golden/combat unaffected. 2/3 step-1
events done (CityGrew, CityBordersExpanded); FloraSuccession next.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:43:38 -04:00
Natalie
f829d87e59 feat(@projects/@magic-civilization): 🌱 p3-29 (1) — surface CityGrew as a turn event (single-source UI prep)
First step of the Rail-1 turn-unification: the Rust turn now EMITS city growth as
`TurnEvent::CityGrew` (process_city_production collects grown cities + flushes the event with
clan/city/population/hex), instead of growth being a silent state mutation only the GDScript
turn announced (`city_grew` signal). Surfaced through all four TurnEvent consumers (replay
turn(), mc-player-api wire drop, api-gdext replay dict, test labels).

Value now: richer replay. Value next: when turn_manager switches to GdTurnProcessor.step, it
translates this event to the EventBus.city_grew signal — letting us delete the GDScript growth
logic (Rail-1 DRY). Doesn't change turn state (events only) → golden + combat tests unaffected.
mc-turn city_growth_emits_city_grew_event green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:32:57 -04:00
Natalie
dd31de9acb docs(@projects/@magic-civilization): 🔎 p3-29 — audit: the DRY fix's bulk is event-surfacing for UI parity, not the call-swap
TurnResult.events_emitted is replay-thin (founded/captured/killed/created); live UI needs
city_grew/building_completed/border_expanded/culture_researched/flora_succession. Real p3-29
work: enrich Rust event surface (headless-safe) → surface in dict → GDScript translates →
swap+delete → render-proof. Steps 1-2 carry no live-game risk.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:16:39 -04:00
Natalie
1a4c9c7d36 docs(@projects/@magic-civilization): 🏛️ p3-29 — Rail-1 turn unification objective (the real DRY fix)
Owner flagged the duplication: live game runs GDScript turn orchestration (turn_processor.gd
_process_* + EcologyState.tick) while headless runs mc-turn::step — two turn orchestrations.
This session built mc-turn::step into the complete single source of truth; p3-29 is the capstone:
switch turn_manager to GdTurnProcessor.step (bridge already exists at lib.rs:6354), render the
TurnResult for UI, delete the GDScript orchestration. HIGH-STAKES live-game rewrite — needs a
render proof before merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:13:36 -04:00
Natalie
e8e58fb278 docs(@projects/@magic-civilization): ☀️🧊 p3-26 B8 — events 9/12 (solar+glacial added)
9 mc-climate event categories live; pandemic/ecological fauna via disease applier; marine via
process_step; magical→G3. Event system effectively complete.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:03:23 -04:00
Natalie
8022722a33 feat(@projects/@magic-civilization): ☀️🧊 p3-26 B8 — solar + glacial event categories (9/12)
Two climate disaster categories via the existing magic_heat_delta forcing field (which the
climate physics adds to temperature each step, then decays — so the effect is persistent +
transient like the GDScript duration, no new grid field/physics change):
- solar: global warming — every tile's magic_heat_delta += global_heat.
- glacial (cold): cools a hex disk (magic_heat_delta += negative temp_delta) + dries it
  (moisture_loss), skipping open water. (warm-T5 runaway + river-freeze deferred.)
apply_solar/apply_glacial + dispatch + match arms + tests. mc-climate 65/0.

Events: 9/12 live (wildfire/drought/volcanic/seismic/impact/tsunami/plague/solar/glacial);
pandemic/ecological fauna handled by the disease applier; marine via process_step; magical→G3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 02:03:02 -04:00
Natalie
245a0af95a docs(@projects/@magic-civilization): p3-26 B6 DONE — equipment craft→equip→combat live; loot=B5 parity-optional
B6 complete: B6a (recipe refinement) + B6b core (MapUnit.equipped + combat-read + CraftEquipment
action). Full chain — refine raw→processed → craft (consume materials) → equip → unit fights
harder. Loot drop-on-death/decay (B5) is parity-optional (disabled in the live game too).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 23:46:41 -04:00
Natalie
5288555bdb feat(@projects/@magic-civilization): ⚔️ p3-26 B6b (4/4) — CraftEquipment action (populate path; gear reachable in play)
Closes the equipment loop — units can now obtain gear in headless play:
- ItemCombatBonus extended to a full item def (+ category + materials from production.materials);
  the loader stores ALL items (craftable), not just combat-bonus ones.
- PlayerAction::CraftEquipment { unit_id, item_id } + dispatch::craft_equipment — looks up the
  item def, verifies + consumes its raw materials from strategic_ledger (the refined outputs
  B6a produces — recipe→craft chain), then pushes an EquippedItem onto the unit. Rejects on
  unknown item / insufficient materials.

End-to-end: B6a refines raw→processed → CraftEquipment consumes materials → equipped gear →
B6b combat-read adds attack/defense. Tests: craft consumes+equips, rejects insufficient.
mc-player-api 138/0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 23:44:33 -04:00
Natalie
a44ba951bd feat(@projects/@magic-civilization): ⚔️ p3-26 B6b (3/3 boot) — FFI + harness boot the item combat table
- GdPlayerApi::set_item_combat_json — loads item combat bonuses onto GameState.
- player_api_main._apply_item_combat — stamps DataLoader.get_all_items() via the FFI at boot,
  emitting item_combat_api_loaded.

Equipped gear now boosts units in real headless combat (table booted → combat-read live).
gdext compiles. Remaining for full B6b: a Craft/Equip action to populate units' gear + loot
drop-on-death/decay (B5).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 21:15:09 -04:00
Natalie
a3dac211e3 feat(@projects/@magic-civilization): ⚔️ p3-26 B6b (2/3) — equipment combat bonuses (units fight harder with gear)
The combat-read half of equipment:
- GameState += item_combat: BTreeMap<String, ItemCombatBonus{attack,defense}> (#[serde(skip)]
  boot) + load_item_combat_json (sums items.json stats: melee_bonus+ranged_bonus → attack,
  armor_bonus → defense).
- processor::equip_combat_bonus(unit, table) sums a unit's equipped-item bonuses; injected into
  BOTH combat paths (process_pvp_combat formation params + the click/MCTS resolve helper) —
  added to attacker/defender attack + defense.

Safe by construction: unequipped units (empty `equipped`) + empty table → (0,0) → combat
unchanged, so all existing combat tests + the 20-turn golden are unaffected (verified:
mc-turn 284/0). Tests: equip_combat_bonus sums stats / zero for unequipped/unknown.
Remaining (3/3): FFI+harness to boot the item table + a Craft/Equip action to populate gear.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 21:13:16 -04:00
Natalie
4c41ecf66e feat(@projects/@magic-civilization): ⚔️ p3-26 B6b (1/3) — MapUnit.equipped (unit equipment state)
MapUnit += equipped: Vec<EquippedItem> (#[serde(default)]) — items a unit has equipped, to
drive combat bonuses + charge consumption + loot-on-death. mc-state now deps mc-items
(standalone crate, no cycle). Foundation for the combat-read (B6b/2) + Craft action (B6b/3).
mc-state builds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 21:04:30 -04:00
Natalie
95e289891e docs(@projects/@magic-civilization): ⚒️ p3-26 B6a DONE — resource refinement live; B6b (equipment+combat) remaining
B6a (mc_city::recipes wired: refine raw→processed into strategic_ledger each turn) complete +
verified. B6b (unit equipment + combat reads gear + loot decay) is the combat-spanning
remainder, inert without combat integration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 20:52:48 -04:00
Natalie
5edd20ced6 feat(@projects/@magic-civilization): ⚒️ p3-26 B6a (2/2) — FFI + harness boot the recipe bundle
- GdPlayerApi::set_recipes_json — stores the recipe bundle JSON on GameState. Mirrors
  set_improvement_defs_json.
- player_api_main._apply_recipes — reads public/resources/recipes/recipes.json (the
  {recipes:[…]} bundle, 12 recipes) at boot and stamps it via the FFI, emitting
  recipes_api_loaded.

Resource refinement now runs end-to-end in real headless play: boot recipes → recipe phase
consumes raw + produces refined into strategic_ledger each turn. B6a (recipe refinement)
complete. gdext compiles; dylib rebuild in progress.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 20:51:11 -04:00
Natalie
dd1a537ab5 feat(@projects/@magic-civilization): ⚒️ p3-26 B6a (1/2) — resource-refinement (recipe) tick in the headless turn
Wires the previously-unwired mc_city::recipes system into the turn:
- GameState += recipes_json (#[serde(skip)] boot) + load_recipes_json (mc-state holds the raw
  bundle JSON; no mc-city dep).
- recipe_phase::process_recipe_phase — per player, loads strategic_ledger into a
  ResourceStockpile, runs tick_recipes over the player's processing buildings (consume raw →
  produce refined), writes the transformed ledger back. Registered in END_OF_TURN_PHASES
  (ecology, healing, improvement_build, recipe_refine).

Refined resources land in strategic_ledger (which trade/economy already use), so it's a real
economic transform, not inert. Tests: refines, idle-on-shortage, no-op-without-recipes.
mc-turn recipe_phase 3/3. Remaining (2/2): FFI + harness to boot recipes.json.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 20:49:04 -04:00
Natalie
45d52c8ce6 docs(@projects/@magic-civilization): 🔎 p3-26 B6 — equipment/crafting scoped (largest subsystem, spans combat)
mc-items (item logic) + mc-city/recipes (resource refinement) exist but unwired; bench has no
ResourceStockpile, units carry no equipped items, no Craft/Equip action, combat ignores gear.
Recorded the 5-step interlocking plan (stockpile → recipe tick → unit equip + Craft → combat
reads gear → loot decay [closes B5]). No clean sub-slice — interlocks across crates.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 20:37:22 -04:00
Natalie
14c4de8f85 docs(@projects/@magic-civilization): p3-27 — disease applier complete (o2+lair); ocean-collapse prereqs scoped
Disease applies the full tier spec now (fauna/canopy/tier/o2/lair). Ocean-collapse remains
unwired with precise prereqs recorded (global_fish_stock aggregation + registry/has_tag
reconciliation) — a scoped real task, code+tests exist in isolation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:53:20 -04:00
Natalie
668ab7d152 feat(@projects/@magic-civilization): 🦠 p3-27 — complete the disease applier (o2 depletion + lair kill, no stubs)
Reverses the two deferrals in apply_disease_events — every EventTierData field now applies:
- o2_delta: atmospheric (global) depletion of grid.o2_fraction, once per fired event
  (negative drives toward an anoxic ocean). o2_fraction is grid-level, so it's applied
  after the radius loop, not per-tile.
- lair_kill_chance: an active lair (lair_tier > 0) on an affected tile is wiped
  (lair_tier=0, lair_population=0 — same clear as evolution's lair removal) with the
  configured probability via the deterministic rng.

Disease now applies fauna_loss + canopy_loss + tier_loss + o2_delta + lair_kill_chance —
the full tier spec. mc-ecology events 11/0 (+1 test).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:46:35 -04:00
Natalie
59742674b8 docs(@projects/@magic-civilization): p3-26 B3 — improvement subsystem DONE (build + yield live headless)
Full chain wired + tested: BuildImprovement → pending (build_turns) → build-tick →
city_improvements → process_improvement_yields. State (cb451832e) + logic (f4e9d0211) +
FFI/harness (5d12b4bbe).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:42:32 -04:00
Natalie
5d12b4bbee feat(@projects/@magic-civilization): 🏗️ p3-26 B3 (3/4) — FFI + harness boot the improvement defs
Runtime wiring so improvements actually build + yield in a real headless game:
- GdPlayerApi::set_improvement_defs_json — loads the improvement defs (JSON array of
  {id, build_turns, yields}) onto GameState. Mirrors set_ecology_species_json.
- player_api_main._apply_improvement_defs — stamps DataLoader.get_all_improvements() via the
  FFI at boot (after load_state_json), emitting improvement_defs_api_loaded.

With this, the full B3 chain is live: BuildImprovement → pending (build_turns) → build-tick
completes → city_improvements → process_improvement_yields folds food/production in. gdext
compiles; dylib rebuild in progress.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:42:08 -04:00
Natalie
f4e9d02115 feat(@projects/@magic-civilization): 🏗️ p3-26 B3 (2/4) — improvement subsystem logic (build-tick + dispatch + yields)
De-stubs the headless improvement pipeline:
- improvement_phase::process_improvement_build_phase — ticks pending_improvements down,
  completes at 0 → appends the improvement id to the owning city's city_improvements (so it
  yields). Registered in END_OF_TURN_PHASES (ecology, healing, improvement_build).
- dispatch::build_improvement — replaces the stub: validates via the action gate, finds the
  worker's owning city (CityState.owned_tiles, else first city), queues a PendingImprovement
  with turns_remaining from improvement_defs[id].build_turns. (improvement_id, previously
  dropped by the dispatcher, is now plumbed through.)
- apply_end_turn repopulates the fresh processor's improvement_yield_table from
  state.improvement_defs each turn, so process_improvement_yields actually folds food/
  production into cities (was a no-op — table never loaded in real play).

Tests: build-tick (3), dispatch queue (1), registry order. mc-turn 279/0, mc-player-api 136/0.
Remaining (3/4): FFI + harness to boot improvement_defs from public/resources/improvements.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:40:08 -04:00
Natalie
cb451832e0 feat(@projects/@magic-civilization): 🏗️ p3-26 B3 (1/4) — improvement subsystem state model
Groundwork for the headless improvement subsystem (wired in the next increments):
- PlayerState.pending_improvements: Vec<PendingImprovement> (#[serde(default)]) — tile
  improvements under construction.
- GameState.improvement_defs: BTreeMap<String, ImprovementDef> (#[serde(skip)] boot) +
  load_improvement_defs_json (parses public/resources/improvements/*.json → build_turns +
  food/production yields).
- ImprovementDef + PendingImprovement structs.

mc-state 14/0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:31:26 -04:00
Natalie
57725d0088 docs(@projects/@magic-civilization): 🔎 p3-26 B3 — improvement subsystem is FULLY absent headless (re-scoped)
Verified: improvement_yield_table never populated in apply_end_turn (yields no-op),
handle_build_improvement is a stub (no placement, improvement_id dropped), no GameState
improvement data. B3 is a full subsystem build (state+boot+FFI+handler+build-tick+yields),
not a build-tick tweak. Precise ecology-phase-shaped plan recorded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:28:47 -04:00
Natalie
00a349a388 docs(@projects/@magic-civilization): 🐟 p3-27 — marine ecology core confirmed live (ticks via process_step)
Per-tile fish/reef/mangrove dynamics already run inside EcologyEngine::process_step (headless
ecology phase); ocean_dead_fraction via climate; no live MarineHarvestScript remains. Global
ocean-collapse (tick_ocean_state) is the one unwired refinement (needs a populated
BiomeTagRegistry).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:12:24 -04:00
Natalie
05b550232b docs(@projects/@magic-civilization): 🦠 p3-27 — fauna disease applier done (plague/pandemic mortality live)
EcologyEngine::apply_disease_events strikes fauna populations in the ecology phase from the
boot-loaded event configs. Remaining bio-events: marine (fish/reef), lair_kill_chance, o2 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:06:56 -04:00