Files
gamedev-the-steward/docs/PROJECT_CONTEXT.md
T

851 lines
31 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# The Steward — Project Context
> Agent-facing context for understanding the project quickly.
>
> Snapshot basis: repository state after commit `556d0fd`, July 2026. Treat the
> code as the source of truth when this document and the implementation differ.
See the [documentation map](README.md) for the authority and scope of each plan.
## Quick orientation
**The Steward** is currently a small Godot prototype for an embodied village
simulation. Its larger purpose is to become a learning laboratory for a
performant, large-scale NPC simulation that can later power a systemic
open-world RPG.
The current village is not intended to be the final game's scale. It is a
controlled environment in which to learn and validate:
- NPC needs and decision-making;
- professions, work, inventories, and economic dependencies;
- actions, consequences, and world events;
- relationships, memories, rumours, and persistent history;
- emergent situations that can be surfaced as quests;
- simulation level of detail for a much larger population;
- readable world presentation and satisfying embodied play.
The desired game is not an omniscient city builder and not primarily a scripted
quest RPG. The player exists physically inside the simulated society.
## North-star vision
> A systemic open-world RPG set around a city inspired by Jajce, Bosnia and
> Herzegovina, and its surrounding villages. Every important NPC participates
> in a simulated society, forms relationships, remembers events, and can affect
> history. The player can remain an ordinary citizen, pursue a profession,
> become a trader, criminal, warrior, or companion leader, command armies, and
> eventually lead a faction.
The world should generate situations. Quests should primarily communicate,
frame, and track those situations rather than manufacture disconnected content.
Example:
1. A harvest fails or a trade route becomes unsafe.
2. Food scarcity raises pressure on households and professions.
3. An NPC steals, migrates, changes work, joins a criminal group, or asks a
relative for help.
4. Witnesses form memories and spread partial information.
5. Relationships, prices, safety, and faction attitudes change.
6. The player learns about the situation through observation, conversation,
rumours, employment, or authority.
7. Any intervention changes the same world state that produced the problem.
The quest is therefore a view onto the simulation, not a parallel scripted
reality.
## Product pillars
### 1. Simulated lives
NPCs should be people rather than production modifiers. Their needs,
professions, possessions, schedules, abilities, ambitions, and circumstances
drive their choices.
### 2. Persistent history
Important actions create structured events. Events can become memories,
knowledge, rumours, relationships, reputations, grudges, obligations, and
political consequences.
### 3. Emergent narrative
Authored content should provide rules, cultures, locations, characters,
archetypes, and exceptional story beats. Ordinary quests and conflicts should
preferably emerge from unresolved world conditions.
### 4. Embodied freedom
The player walks through the same spaces, uses the same resources, and
participates in the same institutions as NPCs. They can play at different
social scales without being forced toward rulership.
### 5. Legible autonomy
Complexity is valuable only when players can understand its consequences. The
game should expose why an NPC chose an action and show resources moving through
the world.
### 6. Small stories inside a large world
The eventual map may be large, but emotional attachment comes from recognizable
people and local consequences. Simulation scale must not turn everyone into an
anonymous number.
### 7. Enjoyable action
Movement and combat should be satisfying independently of the simulation.
Companions and armies should offer expressive, enjoyable control rather than
only statistical resolution.
### 8. A recognizable setting
The core region is inspired by Jajce: dramatic elevation, a fortified urban
center, rivers, a waterfall, wooded slopes, lakes, watermills, roads, farms,
and surrounding villages. This is an inspiration rather than a requirement for
a literal historical reconstruction.
### 9. Cozy presentation with real stakes
The presentation should feel warm, painterly, pastoral, and inviting while the
simulation remains capable of scarcity, conflict, death, political ambition,
and social change.
## Build-in-public goals
Visual appeal and watchability are prototype requirements, not final polish.
Each simulation feature should have a visible expression:
| Simulation state | Visible expression |
| --- | --- |
| Hunger | Looking for food, checking storage, eating, asking, stealing, or weakening |
| Profession | Recognizable tools, clothing, workplace, route, and animation |
| Task choice | Purposeful movement plus optional task/thought icon |
| Production | Items visibly gathered, carried, stored, processed, and consumed |
| Relationship | Greeting, helping, arguing, avoiding, mourning, or celebrating |
| World event | Visible consequences and a concise event/history feed |
| Settlement change | Construction, depletion, prosperity, damage, migration, or recovery |
Development clips should communicate cause and effect without requiring viewers
to read console logs. A cinematic/debug toggle should eventually allow the same
scenario to be shown both beautifully and analytically.
## Visual direction
The target is an original stylized look characterized by:
- painterly natural colors and soft, warm lighting;
- readable, exaggerated terrain and building silhouettes;
- lush vegetation with restrained environmental motion;
- expressive, animation-friendly characters;
- appealing water, mist, smoke, weather, and seasonal variation;
- cozy settlements contrasted with a world capable of hardship;
- a clear elevated third-person view that makes NPC activity readable.
Avoid generic high-fantasy spectacle and avoid treating visual style as a
reason to hide the underlying simulation.
### Initial environment composition
The first public-facing environment should be a compressed simulation garden,
not the complete region:
- a fortress or fortified landmark on an upper ridge;
- a small settlement descending toward water;
- a river, bridge, and waterfall or strong vertical water feature;
- a mill channel and a small cluster of watermills;
- farm terraces and a wooded work area;
- a trade road and distant silhouettes that imply a larger world.
Terrain3D should own broad landforms, ground surfaces, distant landscape, and
large-scale vegetation placement. Roads, river surfaces, waterfalls, cliffs
that require overhangs, bridges, walls, buildings, and other authored landmarks
should use dedicated meshes or appropriate spline/modular tooling.
## Core player loop
The intended loop is:
1. **Observe** people, places, stores, and local problems.
2. **Understand** needs, causes, relationships, and competing priorities.
3. **Influence** people through work, trade, conversation, policy, reputation,
leadership, or force.
4. **Act** personally through movement, interaction, production, exploration,
and combat.
5. **Witness consequences** in the same people and systems.
6. **Adapt** to new opportunities and problems created by those consequences.
The current prototype implements a very early version of observe, autonomous
task choice, physical travel, work completion, resource change, and direct
player assistance. NPC `gather_food` and `gather_wood` tasks now use finite
world `ResourceNode` instances (berry bushes and trees) rather than abstract
zone markers. The obsolete farm, forest, and activity markers have been
removed. Eating and food transfer target the typed village pantry, while rest,
study, and patrol target typed activity sites. The migration is documented in
[the ResourceNode plan](RESOURCE_NODE_MIGRATION.md).
## Current technology
- **Engine:** Godot 4.7 project configuration
- **Renderer feature:** Forward Plus
- **Language:** GDScript (`odig` analysis with warnings treated as errors)
- **Main scene:** `res://main.tscn`
- **Terrain:** Terrain3D 1.0.2 is installed and enabled
- **Jajce runtime:** reusable 512 m Terrain3D seed, greybox landmarks, stable
ResourceNode placement, lookdev camera, and tested runtime navigation
- **Terrain compatibility floor:** Godot 4.4 according to the bundled extension
- **Version control:** Git
- **Primary branch:** `main`
- **Commit convention:** Conventional Commits
Terrain3D includes binaries, source, editor tooling, examples, and a `demo/`
directory. Most files under `addons/terrain_3d/` and `demo/` are third-party
plugin content, not game architecture.
## Current playable state
### World and player
- `main.tscn` instances the reusable Jajce Terrain3D world.
- The player is a `CharacterBody3D` represented by placeholder primitive
geometry.
- WASD movement is camera-relative.
- The elevated third-person camera rotates with the mouse and uses smoothed
follow/focus behavior.
- Pressing `E` near a berry bush or tree extracts its configured yield into the
village through the same `ResourceNode` contract used by NPCs.
- Guard, study, rest, and food interactions now use typed world sites.
- `Escape` releases captured mouse input.
### Village simulation
The simulation currently creates six NPCs:
- Amina
- Tarik
- Jasmin
- Elma
- Mirza
- Lejla
Each receives a random profession from:
- farmer;
- woodcutter;
- guard;
- scholar;
- wanderer.
Each simulated NPC currently stores:
- stable integer ID for the session;
- name and profession;
- hunger and energy;
- strength and intelligence;
- current task and task state;
- task duration and progress;
- simulated position;
- starvation state and duration;
- death state.
The village currently tracks:
- food, initially `20`;
- wood, initially `10`;
- safety, initially `50`;
- knowledge, initially `0`;
- per-resource modifiers;
- per-resource priorities.
### NPC task lifecycle
Task states are:
```text
idle -> traveling -> working -> complete -> idle
|
+-> navigation_failed -> wander -> idle
```
NPCs currently choose among:
- gather food;
- gather wood;
- patrol;
- study;
- eat;
- rest;
- wander.
Needs override ordinary work. Otherwise a utility-like score combines:
- village priority;
- critical and low resource thresholds;
- profession preference;
- a small random contribution.
The visual NPC walks toward the task's typed target position. Arrival tells the
simulation to start work. Work progresses on simulation ticks. The village
receives the result only when the task duration completes.
Starvation can reduce productivity and eventually kill an NPC. Dead visuals
stop moving, change appearance, and no longer collide.
### Current world targets
The former farm, forest, food, guard, study, and rest markers have been deleted.
The runtime now uses semantic world targets:
**Migration status:** NPC `gather_food` and `gather_wood` target `ResourceNode`
instances (berry bushes and trees), with no marker fallback. Non-resource
actions route through typed sites:
- patrol → `ActivitySite` (`guard_post`);
- study → `ActivitySite` (`study_desk`);
- rest → `ActivitySite` (`rest_bench`);
- eat/deposit/withdraw → `StorageNode` (`village_pantry`).
The player also harvests food and wood directly from nearby `ResourceNode`
instances. Extraction returns the actual amount removed, updates the village by
that amount, and releases an NPC reservation if the source is depleted.
Future resource expansion should add many finite `ResourceNode` instances rather
than broad resource zones: trees in foliage clusters, berry patches, animal
camps, and village stockpiles can be ranked by reachability, distance, safety,
profession, and NPC comfort range. The current resolver already combines
distance with resource `safety_risk`, `comfort_distance`, and
`discovery_priority` metadata.
### Jajce scaffold
`world/jajce/JajceWorld.tscn` provides the reusable environment instanced by
`main.tscn`:
- a centered 512 m Terrain3D landscape split across four regions;
- deterministic shaped terrain data and six game-owned surface layers;
- fortress, houses, mill, bridge, shader river/waterfall, mist, and smoke;
- warm sky, fog, shadows, and wind-reactive foliage;
- eight ResourceNodes preserving stable food/wood discovery IDs;
- typed village pantry storage and typed guard, study, and rest activity sites;
- a temporary baked navigation loop with 24 tested routes;
- a look-development scene and camera.
This is a runtime integration proof, not the final terrain composition.
Terrain3D startup requires several physics frames before reliable
NavigationServer path queries; the scaffold and runtime tests capture that
synchronization requirement.
### Current UI
A small village panel displays:
- food;
- wood;
- safety;
- knowledge;
- starving NPC count;
- selected village modifiers.
- a Tab-cycled NPC inspector with profession, needs, task state, destination,
decision reason, and utility scores.
NPC name/profession labels, definition-driven colors and props, and the
carried-food visual make active simulation state readable in the world.
## Runtime architecture
### `simulation/SimNPC.gd`
`SimNPC` is a `RefCounted` simulation model. It owns needs, task selection,
task progression, profession affinity, starvation, and death.
This separation from the visual node is an important architectural seed and
should be preserved.
### `simulation/SimVillage.gd`
`SimVillage` is a `RefCounted` aggregate for shared resources, modifiers,
priorities, and applying completed NPC work.
### `simulation/SimulationManager.gd`
`SimulationManager` is currently a scene-tree `Node` that:
- owns the village and NPC array;
- advances a tick approximately every 1.2 seconds;
- creates NPCs;
- coordinates task completion;
- emits village, task, and death signals;
- exposes direct resource-changing methods to the player.
It currently combines clock, orchestration, event publication, population
creation, and some gameplay API responsibilities.
### `world/world_view_manager.gd`
`WorldViewManager` bridges simulation data to visible NPC nodes. It:
- instantiates `NpcVisual` scenes;
- resolves resource nodes, random wander targets, and remaining activity
markers;
- writes the selected ResourceNode ID onto the NPC as a transitional behavior;
- sends targets to visuals;
- reports arrival and navigation failure back to `SimulationManager`;
- applies visual death state.
### `player/npc/NpcVisual.gd`
`NpcVisual` is the active-world representation of an NPC. It currently:
- owns a `NavigationAgent3D`;
- obtains a navigation path;
- moves and rotates toward path points;
- reports arrival;
- applies a simple death presentation.
### `player/player.gd` and `player/camera_rig.gd`
These implement camera-relative character movement, physical interaction
proximity checks, ResourceNode harvesting, mouse capture, and the elevated
follow camera.
### `world/ui/ui.gd`
The UI subscribes to village changes and formats aggregate village state.
## Current runtime flow
```text
SimulationManager tick
-> ActionExecutionSystem advances needs/work
-> ActionSelectionSystem chooses an action for idle NPCs
-> npc_target_requested
-> WorldViewManager supplies the active visual position
-> ActionTargetResolver consumes ActiveWorldAdapter facts
-> SimulationManager stores/reserves the target
-> npc_travel_requested
-> WorldViewManager commands visual travel
|
v
NpcVisual navigates through the active world
|
+-- arrived_at_target signal
| |
| v
| SimulationManager marks NPC as working
| |
| v
| Later ticks complete work
| |
| v
| ResourceStateRecord.extract() -> village.apply_resource_delta()
| |
| v
| village_changed signal updates the UI
|
+-- navigation_failed signal
|
v
SimulationManager releases reservation, sets last_task, sends NPC to wander
```
## Repository map
```text
.
├── addons/terrain_3d/ Third-party Terrain3D plugin
├── assets/foliage/ Early tree assets
├── demo/ Terrain3D's bundled demo, not the game
├── docs/ Project context and plans
├── player/
│ ├── camera_rig.gd
│ ├── player.gd
│ └── npc/
│ ├── NpcVisual.gd
│ └── NpcVisual.tscn
├── simulation/
│ ├── SimNPC.gd
│ ├── SimVillage.gd
│ ├── SimulationClock.gd
│ ├── SimulationManager.gd
│ ├── actions/ Selection, execution, and target resolution
│ ├── definitions/ Stable IDs and custom definition resources
│ └── state/ Versioned simulation-state records
├── tests/
│ ├── action_system_boundaries_test.gd
│ ├── deterministic_simulation_test.gd
│ ├── food_storage_loop_test.gd
│ ├── jajce_world_scaffold_test.gd
│ ├── jajce_runtime_integration_test.gd
│ ├── npc_visual_lifecycle_test.gd
│ ├── resource_node_player_parity_test.gd
│ ├── simulation_definitions_test.gd
│ └── simulation_state_serialization_test.gd
├── terrain/jajce/ Dedicated Terrain3D seed data and assets
├── tools/
│ └── generate_jajce_terrain_seed.gd
├── world/
│ ├── jajce/
│ │ ├── JajceWorld.tscn
│ │ ├── JajceLookdev.tscn
│ │ ├── jajce_world.gd
│ │ └── beauty_camera.gd
│ ├── resource_nodes/
│ │ ├── ResourceNode.gd
│ │ ├── ResourceNode.gd.uid
│ │ └── ResourceNode.tscn
│ ├── active_world_adapter.gd
│ ├── world_view_manager.gd
│ └── ui/ui.gd
├── main.tscn
└── project.godot
```
## Important limitations and technical debt
These are expected prototype constraints, not necessarily isolated bugs:
- Action and profession IDs are stable and definition-backed, but several
action effects remain hard-coded.
- Temporary activity markers have been removed; NPC and player food/wood
gathering use `ResourceNode` instances with no fallback, food transfer uses
the typed pantry `StorageNode`, and patrol/study/rest use `ActivitySite`.
- Current NPC, village, resource, storage, event, clock, and RNG state serialize
through world schema v3. F5/F9 provide one validated local quicksave; a save
menu, metadata, and player-transform persistence remain deferred.
- Simulation-owned resource records retain live amounts, reservations, and
usage definitions while ResourceNode scenes are unloaded.
- An explicit fixed-step clock converts frame delta into simulation ticks, but
orchestration still lives on the scene-tree `SimulationManager`.
- Automated coverage includes deterministic same-seed and save/restore
continuation checks, player-parity/resource-contention, flat-map, and Jajce
scaffold scenarios; broader gameplay coverage is still missing.
- Resources are global floating-point counters rather than items in locations
and inventories, except food, which now moves through sources, NPC inventory,
and the village pantry.
- NPCs do not have homes, schedules, possessions, memories, relationships,
goals, or social knowledge.
- The reason inspector exposes current decisions, but deeper historical traces
and rejected preconditions are not yet retained.
- Active navigation is used as if all agents are local; no simulation LOD exists.
- Unloaded traveling NPCs preserve their state but do not yet advance through
abstract travel time.
- There is no spatial query/index layer for large populations.
- SimulationManager still orchestrates multiple systems and player-facing
mutation APIs, but selection, execution, target resolution, and active-world
queries now have focused collaborators.
- Path failure and interruption emit a `navigation_failed` signal and send the NPC to wander; this is functional but not yet polished.
- Terrain3D and the bounded Jajce beauty baseline now run in the main game
scene; final visual review and character/profession readability remain.
- Combat, companions, factions, politics, trade, rumours, quests, persistence,
and regional travel do not yet exist.
- Placeholder geometry is sufficient for debugging but not for build-in-public
presentation.
## Target simulation architecture
### Separate definitions, state, systems, and presentation
Use four conceptual layers:
1. **Definitions** — immutable data for needs, actions, professions, items,
traits, event types, and locations.
2. **State** — serializable runtime records for NPCs, inventories,
relationships, settlements, factions, and history.
3. **Systems** — clocks, scoring, action resolution, economy, relationships,
events, rumours, and persistence.
4. **Presentation adapters** — Godot nodes that render nearby state, accept
player input, play animation, and provide UI.
Do not make the simulation core depend on `Node3D`, scene paths, animation,
physics frames, or a currently loaded map.
The authoritative-boundary decision is recorded in
[ADR 0001](decisions/0001-simulation-authority-boundary.md). The current
`ResourceNode` state and `WorldViewManager` target selection are transitional,
not patterns to extend into inventories, schedules, or relationships.
### Authority and active-world adapters
Persistent mutable state belongs in versioned, serializable simulation records.
Systems mutate those records. Godot nodes:
- present nearby records;
- expose active-world interaction transforms and navigation results;
- translate player input into simulation commands;
- synchronize active position through an explicit adapter;
- never become the only owner of a persistent amount, reservation, action, or
identity.
Target selection may consume facts supplied by the active world, but the
presentation bridge must not author an NPC's decision or persistent target.
### Stable identity
Every persistent entity should eventually have a stable ID:
- person;
- household;
- item stack or significant item;
- building;
- workplace;
- settlement;
- faction;
- location;
- event.
References between simulation records should use IDs rather than live node
references.
### Fixed and deterministic time
The simulation should advance with an explicit clock and controlled random
source. Given the same starting state, seed, and player commands, a headless
run should be reproducible.
This enables:
- debugging;
- automated scenario tests;
- balancing;
- replaying build-in-public demonstrations;
- comparing performance before and after optimization.
### Scheduled work rather than per-frame thinking
At scale, agents should wake for relevant decisions or scheduled updates rather
than running full reasoning every frame. Examples include:
- need threshold crossed;
- action completed or interrupted;
- new information received;
- path or workplace became unavailable;
- daily schedule boundary;
- relationship or faction event;
- periodic low-frequency maintenance.
### Simulation fidelity levels
The eventual world needs multiple representations:
1. **Active:** full node, physics, navigation, perception, animation, and combat.
2. **Local abstract:** individual position and scheduled actions without
continuous physics.
3. **Distant individual:** data-only people resolving travel and work by time.
4. **Settlement aggregate:** carefully chosen economic or demographic
aggregation for populations that do not currently need individual detail.
Moving between levels must preserve identity and important state. Aggregation
must not erase named relationships or unresolved history.
### Action model
Actions should become data-driven definitions with:
- preconditions;
- candidate targets;
- utility considerations;
- expected duration;
- reservations;
- resource costs;
- effects;
- interruption rules;
- visible presentation hints;
- reason tracing.
The first implementation can remain utility-based. Do not add a complex
planner until current action scoring and sequencing demonstrate a concrete need.
### Events and history
Important outcomes should create structured facts rather than prose-only logs.
A future event record might contain:
```text
event_id
event_type
simulation_time
location_id
actor_ids
target_ids
witness_ids
cause_event_ids
resource_changes
relationship_changes
visibility/secrecy
tags
```
Memories, rumours, reputation, and quests should reference or transform these
facts. Generated text is presentation; structured state remains authoritative.
### Emergent quest principle
A quest candidate should normally require:
- a real unresolved condition;
- an NPC or institution that knows or cares about it;
- a plausible way to communicate it;
- one or more achievable interventions;
- consequences that update the source simulation.
Avoid creating a duplicate quest-only bandit, item, victim, or relationship
when an existing simulated entity can provide the situation.
### Performance principle
Design for scale, but optimize measured bottlenecks:
- keep headless benchmarks;
- record agent count, simulated duration, tick cost, and allocations;
- prefer event-driven/scheduled updates;
- use spatial partitioning for local queries;
- batch homogeneous work when profiling justifies it;
- avoid premature native extensions or data-oriented rewrites before the
behavior model stabilizes.
## Development strategy
The project has two interleaved tracks.
### Living simulation
- deterministic clock and state;
- data-driven needs, professions, and actions;
- inventories and economic flow;
- events, history, relationships, and rumours;
- simulation LOD and performance;
- emergent opportunities and quests.
### Living presentation
- Jajce-inspired terrain composition;
- attractive lighting, water, foliage, and weather;
- readable characters and professions;
- visible work, transport, and consequences;
- interaction UI and simulation inspection;
- combat feel, companions, and command feedback.
Every major systems milestone should produce a shareable visual behavior. Every
visual milestone should support or reveal actual simulation state.
## Immediate milestone: scaffold, architecture gate, then simulation garden
Food and wood migration, the minimal `JajceWorld` proof, and the mandatory
architecture gate are complete:
- explicit fixed-step simulation clock;
- seeded per-NPC decision and wander random streams;
- headless fixed-seed scenario with a final-state checksum;
- versioned JSON records for NPC, village, resource, clock, and RNG state;
- deterministic save/restore continuation with exact 64-bit RNG preservation;
- simulation-owned resource amount/reservation state with ResourceNode
presentation binding and unload/rebind coverage;
- stable StringName action/profession IDs plus validated custom definition
resources used by simulation, targeting, generation, and persistence;
- separate selection, execution, target resolution, active-world query, and
visual travel responsibilities;
- authoritative active position and persisted travel destinations;
- checksum-invariant NPC visual unload/reload with reservation preservation.
The location-based food loop is complete and traceable: gathering creates
carried food, depositing fills the pantry, withdrawal retrieves one unit, and
eating consumes it. Each successful transfer creates a persisted structured
event, and active NPCs visibly carry food through presentation derived from
their inventory. The bounded save-slot slice is also complete, including
validation, atomic replacement recovery, and active-visual rebuilding.
Terrain3D runtime integration and the simulation-garden beauty pass are next.
The coherent visual slice can then aim for:
- one attractive valley section;
- six named villagers;
- three visibly distinct workplaces;
- food and wood as location-based resources;
- visible gathering, carrying, storing, and consuming;
- hunger and energy;
- one understandable shortage crisis;
- direct player assistance and priority influence;
- day/night presentation;
- an in-game reason inspector;
- deterministic replay or scenario reset;
- save/load for the slice;
- a stable 2030 minute session.
Safety and knowledge can remain present, but their deeper production chains
should follow a complete food loop rather than grow in parallel.
## Out of scope until the simulation garden works
- full regional map;
- large city population;
- multiplayer;
- procedural world generation;
- generations and inheritance;
- complete market simulation;
- kingdom-scale diplomacy;
- large battles;
- broad crafting catalog;
- fully generated dialogue;
- multiple large production chains;
- production-quality character customization.
These remain part of the vision, not the next implementation target.
## Agent working guidelines
1. Read this document, [the learning roadmap](LEARNING_ROADMAP.md),
[the ResourceNode migration](RESOURCE_NODE_MIGRATION.md), and
[the build-in-public plan](BUILD_IN_PUBLIC_PLAN.md) before proposing a large
architectural or world-production change.
2. Inspect `git status` and preserve unrelated user changes.
3. Treat `addons/terrain_3d/` and `demo/` as third-party code unless a task
explicitly concerns the plugin.
4. Preserve Godot `.uid` and asset `.import` sidecars. They are tracked project
metadata; `.godot/` is the disposable cache.
5. Keep simulation rules independent of visuals and loaded scenes.
6. Prefer small vertical behavior slices over broad scaffolding.
7. When adding a decision, add a way to inspect why it occurred.
8. When adding persistent state, define how it saves and migrates.
9. When optimizing, include a reproducible benchmark or measurement.
10. Keep new systems data-driven only where it improves reuse or iteration;
avoid abstraction without a demonstrated consumer.
11. Use Conventional Commits.
12. Update these documents when a decision materially changes the vision,
architecture, milestones, or current-state description.
13. Follow the authority order in [the documentation map](README.md); do not
let a focused visual or migration plan silently redefine system ownership.
## Definition of “reusable for the future game”
A system is reusable when:
- it has no dependency on this prototype's scene paths or placeholder zones;
- definitions can be supplied as data;
- mutable state is serializable;
- behavior can be exercised headlessly;
- presentation communicates through an adapter or events;
- performance characteristics are measured;
- its public API is documented by real use, not speculative abstraction.
Reusable does not necessarily mean a separate Godot plugin. Extract a library
only after the API has stabilized through use.
## Glossary
- **Active NPC:** A fully represented nearby character with a Godot scene node.
- **Agent:** A simulated decision-making entity, usually an NPC.
- **Event:** A structured fact that something happened in world time.
- **History:** Persisted events and their enduring consequences.
- **Memory:** An NPC's retained interpretation or knowledge of events.
- **Presentation adapter:** Code that translates simulation state into scenes,
animation, audio, UI, and player input.
- **Quest:** A player-facing framing and tracking mechanism for an opportunity
or unresolved condition.
- **Reason trace:** Data explaining the inputs and scores behind a decision.
- **Simulation garden:** A small, attractive, controlled world used to validate
deep systems and make them watchable.
- **Simulation LOD:** Changing computational fidelity based on relevance while
preserving important identity and state.
- **World event:** A consequential state transition that may be witnessed,
remembered, communicated, and acted upon.