ic-7zue: GH#8: Tier-2 Spec: World State Data Model
Snapshot: 2026-03-30T08:40:31Z
| Field | Value |
|---|---|
| Status | open |
| Assignee | (unassigned) |
| Priority | 2 |
| Labels | atlas |
| Created by | github-bridge |
| Created | 2026-03-28T19:00:09Z |
| Updated | 2026-03-28T19:00:09Z |
Description
GitHub issue: b4arena/spellkave#8 URL: https://github.com/b4arena/spellkave/issues/8
Context
The world state data model defines what exists in Spellkave and how it's stored. Following the SpacetimeDB + BitCraft architecture (#3), this means: component tables keyed by entity_id, with each aspect of an entity in its own table.
BitCraft uses ~150 component tables for its MMORPG. Spellkave needs a different set — D&D-style worlds emphasize social relationships, faction politics, reputation, memory, and narrative consequence over crafting/terrain. This is where FoundryVTT's D&D 5e data model is the primary reference.
What Atlas Should Deliver
A Tier-2 specification defining:
1. Entity Primitives
What kinds of entities exist and how they're identified:
- Characters (human-played and AI-inhabited)
- Locations (towns, dungeons, wilderness, buildings)
- Items (equipment, treasures, consumables)
- Factions (organizations, guilds, alliances)
- Events (historical occurrences — singular, irreversible per PRD)
2. Component Tables (Phase 0 minimum)
For each entity type, the state tables needed. Inspired by BitCraft's pattern (entity_id as shared key across tables):
Character components (reference: FoundryVTT dnd5e character.mjs):
AbilityScoreState— STR, DEX, CON, INT, WIS, CHAHealthState— HP, max HP, temp HP, death savesLocationState— position in the worldFactionMembershipState— which factions, standing, roleRelationshipState— entity-to-entity relationships (ally, enemy, debtor, etc.)MemoryState— what this character knows/remembers (critical for AI agents)ReputationState— how this character is perceived by othersInventoryState— what they carry
Location components:
LocationDescriptionState— terrain, features, dangersLocationPopulationState— who's here nowLocationOwnershipState— who controls this place
Faction components:
FactionState— name, goals, resources, territoryFactionRelationshipState— faction-to-faction standings
Event log:
WorldEventLog— timestamped, tagged, irreversible events (the "world memory")
3. Spatial Indexing
How location-based queries work. BitCraft uses chunk_index btree. Spellkave's world may be more abstract (rooms/areas vs. hex grid) — define the approach.
4. Static Data
Game constants loaded from CSV/config (à la BitCraft's static_data/):
- Ability score names, skill mappings → Rust enums
- Damage types, conditions, proficiency levels
- Spell tables, monster stat blocks
- Reference: dnd5e config.mjs
5. Data Lifecycle
How old data is archived to manage RAM ceiling:
- Event log compaction strategy
- Memory summarization for AI agents
- Archive thresholds
Key Reference Material
BitCraft (architecture patterns)
- messages/components.rs — ~150 table definitions, the component-entity pattern
- game/entities/ — impl blocks adding behavior to table structs
- Singleton pattern:
Config { version: 0 }for global state
FoundryVTT D&D 5e (data model reference — steal the schemas)
- character.mjs — the gold file: ability scores, skills, HP, levels, exhaustion
- npc.mjs — NPC-specific: CR, legendary actions, lair
- item/ directory — weapon, spell, feature, equipment schemas
- activity/ directory — action types: attack, save, check, damage, heal
- shared/ directory — composable field templates (movement, senses, currency)
- config.mjs — all D&D 5e constants → translate to Rust enums
FoundryVTT system abstraction (pluggability proof)
- Pathfinder 2e character model — different proficiency system (TEML), 3-action economy, same Actor base
- worldbuilding system — minimal game system (~500 lines) showing the thinnest possible contract
Dependencies
- Depends on #3 (SpacetimeDB architecture)
- Depends on #4 (Temporal Pacing) — time model affects state storage
- Feeds into #6 (Rules Engine) — the rules operate on these tables
- Feeds into #7 (Phase 0 Minimal Module) — the minimum table set
Acceptance Criteria
- Component tables defined with Rust struct pseudocode and SpacetimeDB annotations
- Entity-component relationship pattern documented (shared
entity_id) - Phase 0 minimum table set clearly identified (vs. "later" tables)
- Static data strategy defined (CSV loading, Rust enums)
- Data lifecycle / archival strategy for RAM management
- Spatial indexing approach decided
- Committed to
spellkaverepo