feat: introduce identity-backed goat

This commit is contained in:
Rijad Zuzo
2026-07-26 22:26:00 +02:00
parent 1f09ebe6b6
commit f79c2bb630
47 changed files with 1903 additions and 96 deletions
+19 -7
View File
@@ -10,6 +10,7 @@ resource_extracted
storage_deposited
storage_withdrawn
item_consumed
animal_fed
```
Each record contains a monotonically increasing event ID, event type,
@@ -17,8 +18,10 @@ simulation tick, actor ID, source ID, destination ID, item ID, and transferred
amount, plus the authoritative world position captured when the fact is
recorded. NPC events preserve their authoritative interaction target (or NPC
position when no target applies); player extraction/depletion events preserve
the ResourceNode interaction position. Actor `-1` identifies a player-triggered
extraction until persistent player identity is introduced.
the ResourceNode interaction position. `animal_fed` records one food moving
from `village_pantry` to a stable animal ID at the animal's authoritative
position. Actor `-1` identifies a player-triggered extraction or feeding until
persistent player identity is introduced.
Events are immutable facts about completed transfers. They do not perform the
transaction and are not replayed to reconstruct current state. Resource,
@@ -26,8 +29,10 @@ inventory, and storage records remain authoritative.
`SimulationEventLog` owns ordered event identity, append/restore behavior, and
history/rate queries, including exact lookup through `get_by_id()`.
`VillageEconomy` performs transactions and requests event records only after
state changes succeed; `SimulationManager` remains the public signal boundary
`VillageEconomy` performs inventory and storage transactions and requests event
records only after state changes succeed. `AnimalCareSystem` composes the
pantry withdrawal with animal hunger relief and requests `animal_fed` only
after both succeed. `SimulationManager` remains the scene-tree signal boundary
used by presentation.
An action whose definition-backed completion cost becomes unavailable records
@@ -38,17 +43,24 @@ transfer occurred.
## Persistence and determinism
`SimulationStateRecord` schema v9 stores the ordered event stream,
`SimulationStateRecord` schema v10 stores the ordered event stream,
`next_event_id`, directed relationships that may reference an exact event, and
per-NPC known-event references with first-acquisition provenance, plus
opportunity records that reference exact trigger/resolution events. Schema v1
and v2 saves migrate to an empty stream beginning at ID zero; world schemas
v1v7 migrate to an empty opportunity list, while world schema v8 preserves and
normalizes its pantry opportunity history. Parsing rejects duplicate event
v1v7 migrate to an empty opportunity list, while world schemas v8 and v9
preserve and normalize opportunity history. World v9 adds an empty animal list
during migration. Parsing rejects duplicate event
IDs, invalid or duplicate knowledge/opportunity references, impossible
communicator sources, relationship causes the observer does not know, and next
IDs that could collide with restored history.
Animal-feed facts receive an additional cross-record check: actor is either an
existing NPC or the player sentinel, source is the real pantry, destination is
an existing animal, item and definition cost are exactly one food, event tick
is not in the future, and the animal's `last_fed_tick` agrees with its latest
feed fact.
Positive food deposits, positive NPC food withdrawals from `village_pantry`
into that actor's matching inventory, and definition-backed patrol/study
`task_blocked` facts caused by missing wood at `village_woodpile` are currently