feat: add bounded npc memory retention

This commit is contained in:
Rijad Zuzo
2026-07-12 01:10:10 +02:00
parent 9a479ba182
commit 99b8146f75
17 changed files with 945 additions and 126 deletions
+21 -10
View File
@@ -37,7 +37,7 @@ transfer occurred.
## Persistence and determinism
`SimulationStateRecord` schema v6 stores the ordered event stream,
`SimulationStateRecord` schema v7 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. Schema v1 and
v2 saves migrate to an empty stream beginning at ID zero. Parsing rejects
@@ -63,6 +63,15 @@ performed/witnessed facts can cross this one social hop, so this is not yet a
rumour cascade. Relationship appraisal uses the listener's state when the fact
is acquired, not a reconstruction of their needs when the old event occurred.
Known facts are now bounded without deleting objective history. A fact is
lasting while it remains that NPC's current trust cause; other facts are recent.
An NPC keeps at most three recent facts, and a deterministic review once per
simulated-day-sized interval removes recent facts at least one day old. Current
causes remain so `Relationship` and `Because` never point at forgotten
evidence. Conversations prefer lasting direct facts, then the most recently
acquired direct fact. Communicated provenance snapshots how the speaker knew
the event, so a listener's memory stays valid after the speaker forgets.
The food-loop regression verifies this chain:
```text
@@ -78,15 +87,17 @@ save/restore continuity.
`NpcVisual` shows a small food sack whenever its authoritative inventory
contains food. A newly loaded visual derives the same state directly from the
NPC record, so unloading presentation does not lose the fact.
The selected-NPC inspector shows lasting/recent counts and labels the displayed
fact with both acquisition provenance and retention class.
## Deliberate limits
The stream is currently kept in full for the small simulation garden. Before
large populations or long-running worlds, add measured retention,
archival/summary rules, and query indexes. Proximity is the only current direct
witness rule, and communication is intentionally one-hop and tied to shared
activity arrival. Line of sight, hearing, acquisition timestamps, multi-hop
rumours, secrecy, false beliefs, multi-event causal graphs, and memory
retention belong in later event/history slices. They should extend this record
family without making prose authoritative or recomputing old evidence from
current positions.
The objective stream is currently kept in full for the small simulation
garden; only per-NPC known references are bounded. Before large populations or
long-running worlds, add measured archival/summary rules and query indexes.
Proximity is the only current direct witness rule, and communication is
intentionally one-hop and tied to shared activity arrival. Line of sight,
hearing, personalized reinforcement/decay, multi-hop rumours, secrecy, false
beliefs, and multi-event causal graphs belong in later event/history slices.
They should extend this record family without making prose authoritative or
recomputing old evidence from current positions.