codebase-state-structure

Document Rust GameState, PlayerState, WorldState, and NarrativeEngine serialization structures.

Updated Dec 13, 2025
One-click install
npx skills add https://github.com/EliasVahlberg/saltglass-steppe --skill codebase-state-structure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: codebase-state-structure
Source: https://github.com/EliasVahlberg/saltglass-steppe/tree/main/.kiro_snapshot_2026-04-04_1209/skills/codebase-state-structure
Command: npx skills add https://github.com/EliasVahlberg/saltglass-steppe --skill codebase-state-structure

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a clear, centralized reference for the game's persistent and runtime data layout so developers can quickly find where gameplay state is stored, how it is serialized, and what must be updated when extending the model.

Core Features & Use Cases

  • Overview of the primary GameState and its decomposed sub-structs: PlayerState, WorldState, and NarrativeEngine, including major fields and responsibilities.
  • Patterns and invariants to follow: spatial index lazy-rebuild, message capping, event emission pipeline, and which fields are skipped from serialization.
  • Practical guidance for tasks like adding new persistent or transient fields, marking fields with serde attributes, and bumping SAVE_VERSION to maintain save compatibility.

Quick Start

Ask the assistant to show where to add a new persistent field to PlayerState and what files and save version changes are required.

Frequently Asked Questions about codebase-state-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new persistent field to GameState in Rust without breaking save compatibility?

To add a persistent field to GameState, you add the field to the relevant sub-struct like PlayerState, apply serde attributes for defaults, and bump the SAVE_VERSION constant to maintain save compatibility. This ensures old saves deserialize correctly with the new layout.

What does the serde skip attribute do for transient game state fields?

The serde skip attribute excludes transient runtime fields from the persistent serialization process, preventing unnecessary data bloat in save files. It marks fields that should rebuild dynamically, such as spatial indices, instead of being stored on disk.

When do I need to bump SAVE_VERSION when refactoring GameState sub-structs?

You must bump SAVE_VERSION whenever the serialization layout of GameState changes, including adding, removing, or altering persistent fields in sub-structs like WorldState. This version bump signals the save system to handle migration or compatibility checks for existing saves.

How do spatial index rebuild patterns work for game state in Rust?

Spatial index rebuild patterns use lazy initialization to reconstruct the spatial index from serialized data only when the game world requires spatial queries at runtime. This avoids serializing derived data while ensuring the WorldState spatial structure is ready for gameplay.

Where is gameplay data stored in a decomposed Rust game architecture?

Gameplay data is centralized in the GameState model and decomposed into sub-structs like PlayerState, WorldState, and NarrativeEngine. Each struct holds specific runtime and persistent fields, distributing responsibilities across the game architecture for organized access.

Do I need to update NarrativeEngine files when changing the event emission pipeline?

Yes, modifying the event emission pipeline or message capping invariants requires updating the NarrativeEngine files to reflect the changes. This ensures the narrative state correctly processes and stores gameplay events during serialization.