Persistent History, Causal Propagation & Decision Impact
This deep dive documents how elthoria-world-simulation-model, elthoria-world-simulation-engine, and elthoria-world-simulation-persistence-api maintain durable, deterministic world history and translate player/character decisions into physical room changes, buffered profile evolution, delayed aftershocks, compound crises, epistemic belief revision, and bidirectional macro-micro propagation.
TIP
Looking for the plain-English Game Master overview? Read Persistent History & How Player Choices Change the World.
Architecture: How Decisions Become Permanent History
CHARACTER / TABLE DECISION
├── Freeform table event (report_world_event / auto-hooks) ──► InboundWorldEvent
├── Weekly party choice / story candidate commit ──► PartyAction (25 ActionIds)
└── Played scene turns & NPC dialogue ──► Scene + SceneTurn
│
┌──────────────────────────────┼──────────────────────────────┐
▼ ▼ ▼
1. IMMEDIATE TRUTH 2. WEEKLY TICK PIPELINE 3. SCENE EVOLUTION
IngestionSystem WorldSimEngine.simulateWeek SceneDirector
.applyImmediateEffects() ├── applyInboundWorldEvents ├── WorldStateUpdateSystem
• Local mutation NOW │ (reactions, no double- │ (EntityState wear/state,
(death, town status, │ write if immediateApplied)│ LocationChange, locality,
party casualty) ├── PartyActionSystem │ GlobalWorldState >= 0.6)
• immediateApplied=true ├── ConsequenceSystem └── EvidencePromoter
• Visible immediately in │ (Pending → Matured + (HiddenTracker signals →
WorldSimulationContext │ correlationKey compound threshold-gated permanent
Formatter ("Since the │ crises) OpenSchemaProfile updates
last week turned") ├── RumorSystem + TruthMaint. on NPCs, Factions, Houses,
├── PropagationSystem and Places)
│ (Upward hop-decay +
│ Downward polity→region
│ →settlement cascade)
└── MacroWorld & Collapse
│
▼
4. FOUR-LAYER DURABLE HISTORY (H2 via elthoria-world-simulation-persistence-api)
├── WorldSimulationRecord (latest optimistic-locked WorldSimState JSON)
├── WorldSimWeekResultRecord (append-only weekly visibility-filtered digests)
├── WorldSimEventLogRecord (append-only queryable SimEvent ledger)
└── WorldSimArtifactRecord (weekly application/vnd.kompile.unified-graph archives)1. The Six Layers of Persistent World History
1.1 Physical Locality & Room Permanence (WorldStateUpdateSystem)
- During played scenes,
WorldStateUpdateSystem.applyTurnapplies physical wear (condition -= wear) and state transitions directly onto each mutatedEntityStateinside aLocationState, stampinglastChangedWeekandlastChangedSceneIdand appending an immutableLocationState.LocationChangerecord (week,sceneId,turnIndex,entityId,summary,causeActorId). - When a scene closes,
applyScenestores the room'saftermathmood and emitsSimEvent.Type.LOCATION_STATE_UPDATED. - Locality invariant: Locations that hosted no scene carry their exact
LocationStateandEntityStateforward untouched across weeks — nothing drifts merely because time passed elsewhere.
1.2 Buffered Open-Schema Evolution (EvidencePromoter & HiddenTracker)
- Characters (
CharacterEvolutionSystem), factions and noble houses (GroupEvolutionSystem), and towns/provinces (PlaceEvolutionSystem) share a single gate:EvidencePromoter.promote(state, scene, subject, maxPromotions, thresholdScale). - Instead of rewriting an NPC or faction on one noisy turn, scene outcomes accumulate
HiddenSignalentries in each subject'sHiddenTracker. - A signal promotes into a permanent
OpenSchemaDimensionupdate only whensignal.weight >= dimension.evidenceThreshold() * thresholdScale(and only ifdimension.isEvolvable()). - Ready signals are sorted by descending weight (tie-broken by ID) and capped at
maxPromotionsper scene so no actor or faction lurches abruptly. Each promoted dimension retainsconfidence = min(1.0, 0.4 + reinforcements * 0.15),promotedWeek, and up to 8provenancesource refs. Sub-threshold reinforcements emit privateHIDDEN_SIGNAL_ACCUMULATED(visibility = 0.0) ledger entries.
1.3 Global Prose History (GlobalWorldState)
WorldStateUpdateSystem.applyScenecomputesconsequenceOf(scene)and only lifts a scene intoGlobalWorldStatewhenconsequence >= 0.6(for example, a high-tensionScenarioResolvedor an open public breach).- Updates write to open-schema global dimensions (e.g.,
open_conflicts) and append to a boundedchangeLog.
1.4 Append-Only Event Ledger & Weekly Digests (SimEvent, WorldSimEventLogRecord, WorldSimWeekResultRecord)
- Every simulation subsystem appends typed
SimEvententries (week,type,actorId,targetId,sourceId,severity,visibility,tags,payload) toWorldSimState.eventLedger. - Persistence writes two append-only historical tables per week:
WorldSimWeekResultRecord: SerializedWeekResultdigest separatingDirect(majorEvents),Report/SecondhandRumor(newIncidents), andTrace/DistantTrace(traces) while excludingHiddenincidents from player-facing views.WorldSimEventLogRecord: Queryable historical ledger indexed bysimulationId,gameId,week,npcId,characterId, andlocationRef— backingget_world_chronology(WorldSimulationChronologyPort, defaultevent_limit = 100, max500) andget_world_event_log.
1.5 Immutable Weekly Unified-Graph Archives (WorldSimArtifactRecord & query_historical_world_graph)
- Each simulated week persists a
application/vnd.kompile.unified-graphbinary artifact keyed by(simulationId, week)inWorldSimArtifactRecord. query_historical_world_graphexecutes bounded, read-only graph queries (intent,entity_id,target_id,relation_type,query_text,max_depth,top_k) against any archived past week without touching liveWorldSimState(missing or corrupt archives fail closed with an explicit error).get_world_sim_unified_graph_archiveexposes raw metadata and base64 archive bytes for external tooling.
1.6 Campaign Journal & Lorebook Persistence (JournalEntry, Lorebook, HistoricalEvent)
- Human/GM-authored narrative canon sits in H2 alongside the simulation tables, feeding spoiler-free
/elthoria-recapreads and keyword-triggeredget_activated_entriesrecall without mutating numeric simulation vectors.
2. How Character Decisions Propagate Into the World
2.1 Two-Phase Live Event Ingestion (IngestionSystem & InboundWorldEvent)
Freeform table outcomes enter the living world via report_world_event or gameplay auto-hooks as InboundWorldEvent records (NPC_DEATH, NPC_STATUS_CHANGE, LOCATION_STATUS_CHANGE, FACTION_EVENT, PARTY_MEMBER_DEATH, PARTY_MEMBER_STATUS, CUSTOM_GM_EVENT):
- Phase 1 — Immediate Local Truth (
IngestionSystem.applyImmediateEffects):- Runs synchronously outside the weekly tick, writing only order-independent local state (this NPC is dead, this town burned, this party member fell) and setting
immediateApplied = true. - Never spawns rumors, succession, or RNG-dependent ripples — keeping weekly ticks bit-for-bit reproducible.
- Surfaces immediately in
WorldSimulationContextFormatterunderSince the last week turned (already true — react to it)andParty members the world has news of.
- Runs synchronously outside the weekly tick, writing only order-independent local state (this NPC is dead, this town burned, this party member fell) and setting
- Phase 2 — Deterministic Weekly Reaction (
IngestionSystem.applyInboundWorldEvents):- Drains
pendingWorldEventsin exact submission order (deliberately unsorted — submission order is the external-event determinism contract). - Skips local mutation when
immediateApplied == true(localOwed = !event.isImmediateApplied()), executing only the world reaction (reactToNpcDeath,reactToLocationStatusChange,reactToFactionEvent,reactToPartyMemberStatus, etc.) and appendingWORLD_EVENT_INGESTED.
- Drains
2.2 Weekly Party Actions (PartyActionSystem) & Counterfactual Story Branches
PartyActionSystem.resolvePartyAction(state, action) resolves all 25 PartyAction.ActionId values (scaled by intensity ∈ [0, 1], recording PARTY_ACTION on the ledger):
| Category | PartyAction.ActionId values | Primary world mutations |
|---|---|---|
| Civic & Realm | AidCommoners, FundRelief, CourtAudience, PetitionTemple | party.reputation, feedback.commonerUnrestPressure, partyHouse.wealth, partyAgent.influence / scandal |
| Social & Relationships | SocialVisit, SpendTimeWithNpc, HostGathering, NegotiateAlliance, RecruitAlly | Bidirectional 8-axis RelationshipVector (affinity, trust, etc.) + RelationshipProvenance, publicVector.attention, localGossipHeat |
| Information & Rumors | GatherInformation, InvestigateRumor, SpreadRumor, SuppressRumor, HuntQuestClue | partyAgent.information, rumor virality/truthValue/belief states, localGossipHeat, quest clue links |
| Direct & Covert Action | ConfrontRival, ProtectTarget, BribeOfficial | Target hostility/suspicion, scandal exposure, schedules aggressive DelayedConsequence records |
| Assets, Training & Travel | TradeVenture, ManageAssets, PayDownDebt, FortifyBase, StudyOrTrain, RestAndRecover, TravelToRegion, WaitAndObserve | partyHouse wealth/debt/security, deterministic RNG skill growth (SimKeys.SKILLS), stress recovery, overland travel |
- Counterfactual Previews (
preview_world_story_choice→choose_world_story_candidate/reject_world_story_candidate):- Previews clone
WorldSimStatein isolation, simulate committing the candidate'sPartyAction(choiceId,branchKey,sourceEventIds,sourcePressurePacketIds,sourceSituationIds), and return the delta without mutating persisted state. - Committing (
choose_world_story_candidate) or declining (reject_world_story_candidate) updates party disposition and removes the candidate from the active set.
- Previews clone
2.3 Delayed Aftershocks & Compound Crises (ConsequenceSystem)
Consequences do not all fire on the same turn a decision is made:
- Scheduling (
scheduleDelayedConsequencesFromCurrentWeek): Every current-weekObservableIncidentwithseverity >= 0.45— plus aggressivePartyActions — schedules aPendingDelayedConsequencewith a futurematuresWeek, optionalexpiresWeek,scope(Party | House | Faction | Province | Government | Polity | World),kind(HouseDebtAftershock,TempleInquiryAftershock,WarMobilizationAftershock,SpyBlowbackAftershock, etc.), andcorrelationKey. - Maturation (
processDelayedConsequences): Iterates duePendingconsequences (maturesWeek <= week) sorted by ID, flips status toMatured, applies state impact, spawns a follow-upPressurePacket, and appendsDELAYED_CONSEQUENCE_MATURED. Past-deadline items markExpired. - Compound Escalation: Overlapping matured/pending consequences sharing a
correlationKeycorrelate into compound crises (CompoundHouseCrisis,CompoundFactionCrisis,CompoundPolityCrisis).
2.4 Bidirectional Propagation & Epistemic Belief Revision (PropagationSystem, RumorSystem, TruthMaintenanceService)
- Upward (
PropagationSystem.applyUpwardEventPropagation):- Scans current-week
SimEvententries withseverity >= upwardResonanceCutoff. - Applies scaled desperation/opportunity to the actor's faction (
upwardDirectFactionScale), propagates up the parent-faction hierarchy decaying byupwardHopDecayper hop untilupwardHopFloor(bounded bySimMath.hopBudget), and feeds government/royal-court shifts intoPolityStatelegitimacy andsuccessionPressure(upwardGovernmentScale, soft-capped byfactionReactionPressureSoftCap).
- Scans current-week
- Epistemic Spread & Debunking (
RumorSystem+TruthMaintenanceService):- Rumors propagate across the social graph via subjective-logic
SimOpinionbeliefs (Ignorant,Spreader,BelieverSilent,Skeptic,Stifler). - When a character exposes or debunks a claim,
TruthMaintenanceServicerunsBeliefReviser.retractReviseAndPurgeover theJustificationIndex— purging solely-dependent derivedWorldFacts while retaining and MAP-downgrading facts still supported by independent evidence.
- Rumors propagate across the social graph via subjective-logic
- Downward (
PropagationSystem.applyDownwardPropagation):- On the next tick, updated
PolityState(collapseRisk,corruption) andMacroWorldState(warPrevalence) trickle back down to every sortedSimRegion(localUnrest += collapseRisk * 0.015 + war * 0.01,safety -= war * 0.015 + collapseRisk * 0.01,lawOrder -= corruption * 0.008,militaryPresence += war * 0.02), everySimSettlement(security,lawOrder,unrestRisk), and faction moralefear(+= collapseRisk * 0.01) — closing the macro ↔ micro causal loop.
- On the next tick, updated
Determinism & Debugging Invariants
- Strict sorted iteration before RNG: All consequence queues, regions, settlements, factions, and skill lists sort deterministically by stable string ID before calling
SimRng(seed, simConfigVersion, week). - Submission-order contract for external events:
IngestionSystempreserves the exact submission order ofpendingWorldEventswithout re-sorting. - Causal auditability: Every weekly tick stamps a canonical SHA-256 hash into
WeekResult.debugand recordsWorldFactderivations (supportingFactKeys,supportingRuleIds,runId = "seed:week") poweringexplain_world_factandWHY/WHY_NOT/PATHqueries.
Key Source Files
- Two-phase event ingestion:
elthoria-world-simulation-engine/.../systems/IngestionSystem.java - Weekly party decisions:
elthoria-world-simulation-engine/.../systems/PartyActionSystem.java,elthoria-world-simulation-model/.../PartyAction.java - Delayed & compound crises:
elthoria-world-simulation-engine/.../systems/ConsequenceSystem.java - Upward/downward cascade:
elthoria-world-simulation-engine/.../systems/PropagationSystem.java - Room permanence & global prose:
elthoria-world-simulation-engine/.../scene/WorldStateUpdateSystem.java - Threshold-gated profile permanence:
elthoria-world-simulation-engine/.../scene/EvidencePromoter.java - Chronology & historical graph MCP tools (in
elthoria-game):WorldSimMcpTools.java(get_world_chronology,query_historical_world_graph,get_world_sim_unified_graph_archive,report_world_event) andWorldNarrativeMcpTools.java(preview_world_story_choice,choose_world_story_candidate,reject_world_story_candidate)